|
35 | 35 | import ru.mystamps.web.support.spring.security.HasAuthority;
|
36 | 36 |
|
37 | 37 | @RequiredArgsConstructor
|
38 |
| -public class MichelCatalogServiceImpl implements StampsCatalogService { |
39 |
| - private static final Logger LOG = LoggerFactory.getLogger(MichelCatalogServiceImpl.class); |
| 38 | +public class StampsCatalogServiceImpl implements StampsCatalogService { |
| 39 | + private static final Logger LOG = LoggerFactory.getLogger(StampsCatalogServiceImpl.class); |
40 | 40 |
|
41 |
| - private final StampsCatalogDao michelCatalogDao; |
| 41 | + private final String catalogName; |
| 42 | + private final StampsCatalogDao stampsCatalogDao; |
42 | 43 |
|
43 | 44 | @Override
|
44 | 45 | @Transactional
|
45 | 46 | @PreAuthorize(HasAuthority.CREATE_SERIES)
|
46 |
| - public void add(Set<String> michelNumbers) { |
47 |
| - Validate.isTrue(michelNumbers != null, "Michel numbers must be non null"); |
48 |
| - Validate.isTrue(!michelNumbers.isEmpty(), "Michel numbers must be non empty"); |
| 47 | + public void add(Set<String> catalogNumbers) { |
| 48 | + Validate.isTrue(catalogNumbers != null, "%s numbers must be non null", catalogName); |
| 49 | + Validate.isTrue(!catalogNumbers.isEmpty(), "%s numbers must be non empty", catalogName); |
49 | 50 |
|
50 |
| - List<String> insertedNumbers = michelCatalogDao.add(michelNumbers); |
| 51 | + List<String> insertedNumbers = stampsCatalogDao.add(catalogNumbers); |
51 | 52 |
|
52 | 53 | if (!insertedNumbers.isEmpty()) {
|
53 |
| - LOG.info("Michel numbers {} were created", insertedNumbers); |
| 54 | + LOG.info("{} numbers {} were created", catalogName, insertedNumbers); |
54 | 55 | }
|
55 | 56 | }
|
56 | 57 |
|
57 | 58 | @Override
|
58 | 59 | @Transactional
|
59 | 60 | @PreAuthorize(HasAuthority.CREATE_SERIES)
|
60 |
| - public void addToSeries(Integer seriesId, Set<String> michelNumbers) { |
| 61 | + public void addToSeries(Integer seriesId, Set<String> catalogNumbers) { |
61 | 62 | Validate.isTrue(seriesId != null, "Series id must be non null");
|
62 |
| - Validate.isTrue(michelNumbers != null, "Michel numbers must be non null"); |
63 |
| - Validate.isTrue(!michelNumbers.isEmpty(), "Michel numbers must be non empty"); |
| 63 | + Validate.isTrue(catalogNumbers != null, "%s numbers must be non null", catalogName); |
| 64 | + Validate.isTrue(!catalogNumbers.isEmpty(), "%s numbers must be non empty", catalogName); |
64 | 65 |
|
65 |
| - michelCatalogDao.addToSeries(seriesId, michelNumbers); |
| 66 | + stampsCatalogDao.addToSeries(seriesId, catalogNumbers); |
66 | 67 |
|
67 |
| - LOG.info("Series #{}: michel numbers {} were added", seriesId, michelNumbers); |
| 68 | + LOG.info("Series #{}: {} numbers {} were added", seriesId, catalogName, catalogNumbers); |
68 | 69 | }
|
69 | 70 |
|
70 | 71 | @Override
|
71 | 72 | @Transactional(readOnly = true)
|
72 | 73 | public List<String> findBySeriesId(Integer seriesId) {
|
73 | 74 | Validate.isTrue(seriesId != null, "Series id must be non null");
|
74 | 75 |
|
75 |
| - return michelCatalogDao.findBySeriesId(seriesId); |
| 76 | + return stampsCatalogDao.findBySeriesId(seriesId); |
76 | 77 | }
|
77 | 78 |
|
78 | 79 | }
|
0 commit comments