Skip to content

Commit 5d148c0

Browse files
committed
SeriesServiceImpl.add(): port to JDBC.
Addressed to #120 Also exclude CyclomaticComplexity and StdCyclomaticComplexity PMD rules because we are prefer ModifiedCyclomaticComplexity usage. No functional changes.
1 parent 9ae9b21 commit 5d148c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1520
-398
lines changed

src/main/config/pmd.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@
5252
<rule ref="rulesets/java/typeresolution.xml" />
5353
<rule ref="rulesets/java/empty.xml" />
5454
<rule ref="rulesets/java/strings.xml" />
55-
<rule ref="rulesets/java/codesize.xml" />
55+
<rule ref="rulesets/java/codesize.xml">
56+
<!-- We are using ModifiedCyclomaticComplexity -->
57+
<exclude name="CyclomaticComplexity" />
58+
<exclude name="StdCyclomaticComplexity" />
59+
</rule>
5660
<rule ref="rulesets/java/braces.xml" />
5761

5862
<rule ref="rulesets/java/unusedcode.xml">

src/main/java/ru/mystamps/web/config/ApplicationContext.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@ public static PropertySourcesPlaceholderConfigurer getPropertySourcesPlaceholder
4646
new ClassPathResource("sql/category_dao_queries.properties"),
4747
new ClassPathResource("sql/country_dao_queries.properties"),
4848
new ClassPathResource("sql/collection_dao_queries.properties"),
49+
new ClassPathResource("sql/gibbons_catalog_dao_queries.properties"),
50+
new ClassPathResource("sql/image_dao_queries.properties"),
51+
new ClassPathResource("sql/michel_catalog_dao_queries.properties"),
52+
new ClassPathResource("sql/scott_catalog_dao_queries.properties"),
4953
new ClassPathResource("sql/user_dao_queries.properties"),
5054
new ClassPathResource("sql/users_activation_dao_queries.properties"),
5155
new ClassPathResource("sql/series_dao_queries.properties"),
52-
new ClassPathResource("sql/suspicious_activity_dao_queries.properties")
56+
new ClassPathResource("sql/suspicious_activity_dao_queries.properties"),
57+
new ClassPathResource("sql/yvert_catalog_dao_queries.properties")
5358
);
5459
return configurer;
5560
}

src/main/java/ru/mystamps/web/config/DaoConfig.java

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,9 @@
2222
import org.springframework.context.annotation.Configuration;
2323
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
2424

25-
import ru.mystamps.web.dao.JdbcCategoryDao;
26-
import ru.mystamps.web.dao.JdbcCollectionDao;
27-
import ru.mystamps.web.dao.JdbcCountryDao;
28-
import ru.mystamps.web.dao.JdbcUserDao;
29-
import ru.mystamps.web.dao.JdbcSeriesDao;
30-
import ru.mystamps.web.dao.JdbcUsersActivationDao;
31-
import ru.mystamps.web.dao.SuspiciousActivityDao;
32-
import ru.mystamps.web.dao.impl.JdbcCategoryDaoImpl;
33-
import ru.mystamps.web.dao.impl.JdbcCollectionDaoImpl;
34-
import ru.mystamps.web.dao.impl.JdbcCountryDaoImpl;
35-
import ru.mystamps.web.dao.impl.JdbcSuspiciousActivityDao;
36-
import ru.mystamps.web.dao.impl.JdbcUserDaoImpl;
37-
import ru.mystamps.web.dao.impl.JdbcSeriesDaoImpl;
38-
import ru.mystamps.web.dao.impl.JdbcUsersActivationDaoImpl;
25+
// CheckStyle: ignore AvoidStarImportCheck for next 2 lines
26+
import ru.mystamps.web.dao.*; // NOPMD: UnusedImports
27+
import ru.mystamps.web.dao.impl.*; // NOPMD: UnusedImports
3928

4029
@Configuration
4130
public class DaoConfig {
@@ -58,6 +47,26 @@ public JdbcCollectionDao getJdbcCollectionDao() {
5847
return new JdbcCollectionDaoImpl(jdbcTemplate);
5948
}
6049

50+
@Bean
51+
public GibbonsCatalogDao getGibbonsCatalogDao() {
52+
return new JdbcGibbonsCatalogDaoImpl(jdbcTemplate);
53+
}
54+
55+
@Bean
56+
public JdbcImageDao getJdbcImageDao() {
57+
return new JdbcImageDaoImpl(jdbcTemplate);
58+
}
59+
60+
@Bean
61+
public MichelCatalogDao getMichelCatalogDao() {
62+
return new JdbcMichelCatalogDaoImpl(jdbcTemplate);
63+
}
64+
65+
@Bean
66+
public ScottCatalogDao getScottCatalogDao() {
67+
return new JdbcScottCatalogDaoImpl(jdbcTemplate);
68+
}
69+
6170
@Bean
6271
public JdbcSeriesDao getJdbcSeriesDao() {
6372
return new JdbcSeriesDaoImpl(jdbcTemplate);
@@ -78,4 +87,9 @@ public SuspiciousActivityDao getSuspiciousActivityDao() {
7887
return new JdbcSuspiciousActivityDao(jdbcTemplate);
7988
}
8089

90+
@Bean
91+
public YvertCatalogDao getYvertCatalogDao() {
92+
return new JdbcYvertCatalogDaoImpl(jdbcTemplate);
93+
}
94+
8195
}

src/main/java/ru/mystamps/web/config/ServicesConfig.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ public CronService getCronService() {
8686

8787
@Bean
8888
public ImageService getImageService() {
89-
return new ImageServiceImpl(strategiesConfig.getImagePersistenceStrategy(), imageDao);
89+
return new ImageServiceImpl(
90+
strategiesConfig.getImagePersistenceStrategy(),
91+
imageDao,
92+
daoConfig.getJdbcImageDao()
93+
);
9094
}
9195

9296
@Bean
@@ -111,7 +115,15 @@ public UsersActivationService getUsersActivationService() {
111115

112116
@Bean
113117
public SeriesService getSeriesService() {
114-
return new SeriesServiceImpl(seriesDao, daoConfig.getJdbcSeriesDao(), getImageService());
118+
return new SeriesServiceImpl(
119+
seriesDao,
120+
daoConfig.getJdbcSeriesDao(),
121+
getImageService(),
122+
getMichelCatalogService(),
123+
getScottCatalogService(),
124+
getYvertCatalogService(),
125+
getGibbonsCatalogService()
126+
);
115127
}
116128

117129
@Bean
@@ -130,4 +142,24 @@ public UserService getUserService() {
130142
);
131143
}
132144

145+
@Bean
146+
public MichelCatalogService getMichelCatalogService() {
147+
return new MichelCatalogServiceImpl(daoConfig.getMichelCatalogDao());
148+
}
149+
150+
@Bean
151+
public ScottCatalogService getScottCatalogService() {
152+
return new ScottCatalogServiceImpl(daoConfig.getScottCatalogDao());
153+
}
154+
155+
@Bean
156+
public YvertCatalogService getYvertCatalogService() {
157+
return new YvertCatalogServiceImpl(daoConfig.getYvertCatalogDao());
158+
}
159+
160+
@Bean
161+
public GibbonsCatalogService getGibbonsCatalogService() {
162+
return new GibbonsCatalogServiceImpl(daoConfig.getGibbonsCatalogDao());
163+
}
164+
133165
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) 2009-2015 Slava Semushin <slava.semushin@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
package ru.mystamps.web.dao;
19+
20+
import java.util.Set;
21+
22+
public interface GibbonsCatalogDao {
23+
void add(Set<String> gibbonsNumbers);
24+
void addToSeries(Integer seriesId, Set<String> gibbonsNumbers);
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (C) 2009-2015 Slava Semushin <slava.semushin@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
package ru.mystamps.web.dao;
19+
20+
public interface JdbcImageDao {
21+
void addToSeries(Integer seriesId, Integer imageId);
22+
}

src/main/java/ru/mystamps/web/dao/JdbcSeriesDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919

2020
import java.util.Optional;
2121

22+
import ru.mystamps.web.dao.dto.AddSeriesDbDto;
2223
import ru.mystamps.web.service.dto.SeriesInfoDto;
2324
import ru.mystamps.web.service.dto.SitemapInfoDto;
2425

2526
// TODO: move stamps related methods to separate interface (#88)
2627
@SuppressWarnings("PMD.TooManyMethods")
2728
public interface JdbcSeriesDao {
29+
Integer add(AddSeriesDbDto series);
2830
Iterable<SitemapInfoDto> findAllForSitemap();
2931
Iterable<SeriesInfoDto> findLastAdded(int quantity, String lang);
3032
Iterable<SeriesInfoDto> findByCategoryIdAsSeriesInfo(Integer categoryId, String lang);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) 2009-2015 Slava Semushin <slava.semushin@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
package ru.mystamps.web.dao;
19+
20+
import java.util.Set;
21+
22+
public interface MichelCatalogDao {
23+
void add(Set<String> michelNumbers);
24+
void addToSeries(Integer seriesId, Set<String> michelNumbers);
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) 2009-2015 Slava Semushin <slava.semushin@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
package ru.mystamps.web.dao;
19+
20+
import java.util.Set;
21+
22+
public interface ScottCatalogDao {
23+
void add(Set<String> scottNumbers);
24+
void addToSeries(Integer seriesId, Set<String> scottNumbers);
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) 2009-2015 Slava Semushin <slava.semushin@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
package ru.mystamps.web.dao;
19+
20+
import java.util.Set;
21+
22+
public interface YvertCatalogDao {
23+
void add(Set<String> yvertNumbers);
24+
void addToSeries(Integer seriesId, Set<String> yvertNumbers);
25+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (C) 2009-2015 Slava Semushin <slava.semushin@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
package ru.mystamps.web.dao.dto;
19+
20+
import java.math.BigDecimal;
21+
import java.util.Date;
22+
23+
import lombok.Getter;
24+
import lombok.Setter;
25+
import lombok.ToString;
26+
27+
@Getter
28+
@Setter
29+
@ToString(exclude = { "comment", "createdAt", "createdBy", "updatedAt", "updatedBy" })
30+
@SuppressWarnings("PMD.TooManyFields")
31+
public class AddSeriesDbDto {
32+
private Integer categoryId;
33+
private Integer countryId;
34+
35+
private Integer quantity;
36+
private Boolean perforated;
37+
38+
private BigDecimal michelPrice;
39+
private String michelCurrency;
40+
41+
private BigDecimal scottPrice;
42+
private String scottCurrency;
43+
44+
private BigDecimal yvertPrice;
45+
private String yvertCurrency;
46+
47+
private BigDecimal gibbonsPrice;
48+
private String gibbonsCurrency;
49+
50+
private Integer releaseDay;
51+
private Integer releaseMonth;
52+
private Integer releaseYear;
53+
54+
private String comment;
55+
56+
private Date createdAt;
57+
private Integer createdBy;
58+
private Date updatedAt;
59+
private Integer updatedBy;
60+
}

0 commit comments

Comments
 (0)