1 package fr.ifremer.quadrige3.core.dao.referential;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 import com.google.common.base.Joiner;
27 import com.google.common.collect.ImmutableList;
28 import com.google.common.collect.Maps;
29 import fr.ifremer.quadrige3.core.dao.administration.program.ProgramStrategyJdbcDao;
30 import fr.ifremer.quadrige3.core.dao.administration.program.ProgramStrategyJdbcDaoImpl;
31 import fr.ifremer.quadrige3.core.dao.administration.user.DepartmentJdbcDao;
32 import fr.ifremer.quadrige3.core.dao.administration.user.DepartmentJdbcDaoImpl;
33 import fr.ifremer.quadrige3.core.dao.administration.user.QuserJdbcDao;
34 import fr.ifremer.quadrige3.core.dao.administration.user.QuserJdbcDaoImpl;
35 import fr.ifremer.quadrige3.core.dao.system.rule.RuleListJdbcDao;
36 import fr.ifremer.quadrige3.core.dao.system.rule.RuleListJdbcDaoImpl;
37 import fr.ifremer.quadrige3.core.dao.technical.Assert;
38 import fr.ifremer.quadrige3.core.dao.technical.jdbc.OptionalDataSourceJdbcDaoSupport;
39 import fr.ifremer.quadrige3.core.exception.QuadrigeTechnicalException;
40 import fr.ifremer.quadrige3.core.vo.referential.AnalysisInstrumentVO;
41 import fr.ifremer.quadrige3.core.vo.referential.SamplingEquipmentVO;
42 import fr.ifremer.quadrige3.core.vo.referential.monitoringLocation.MonitoringLocationVO;
43 import fr.ifremer.quadrige3.core.vo.referential.pmfm.*;
44 import fr.ifremer.quadrige3.core.vo.referential.taxon.TaxonGroupVO;
45 import fr.ifremer.quadrige3.core.vo.referential.taxon.TaxonNameVO;
46 import fr.ifremer.quadrige3.synchro.meta.referential.ReferentialSynchroTables;
47 import fr.ifremer.quadrige3.synchro.meta.system.RuleSynchroTables;
48 import org.apache.commons.collections4.CollectionUtils;
49 import org.apache.commons.io.IOUtils;
50 import org.apache.commons.lang3.StringUtils;
51 import org.springframework.beans.factory.InitializingBean;
52 import org.springframework.beans.factory.annotation.Autowired;
53 import org.springframework.context.annotation.Lazy;
54 import org.springframework.stereotype.Repository;
55
56 import javax.annotation.Resource;
57 import javax.sql.DataSource;
58 import java.io.IOException;
59 import java.io.InputStream;
60 import java.sql.ResultSet;
61 import java.sql.SQLException;
62 import java.util.List;
63 import java.util.Map;
64 import java.util.Properties;
65 import java.util.stream.Collectors;
66
67
68
69
70 @Repository("referentialJdbcDao")
71 @Lazy
72 public class ReferentialJdbcDaoImpl
73 extends OptionalDataSourceJdbcDaoSupport
74 implements ReferentialJdbcDao, InitializingBean {
75
76 private final static String QUERIES_FILE_PATH = "queries.jdbc.xml";
77
78 @Resource(name = "queriesJdbcProperties")
79 private Properties queriesJdbcProperties;
80
81 @Resource(name = "quserJdbcDao")
82 private QuserJdbcDao quserJdbcDao;
83
84 @Resource(name = "departmentJdbcDao")
85 private DepartmentJdbcDao departmentJdbcDao;
86
87 @Resource(name = "programStrategyJdbcDao")
88 private ProgramStrategyJdbcDao programStrategyJdbcDao;
89
90 @Resource(name = "ruleListJdbcDao")
91 private RuleListJdbcDao ruleListJdbcDao;
92
93 protected final Properties connectionProperties;
94
95
96
97
98
99
100
101 @Autowired
102 public ReferentialJdbcDaoImpl(DataSource dataSource) {
103 super(dataSource);
104 this.connectionProperties = null;
105 }
106
107
108
109
110 public ReferentialJdbcDaoImpl() {
111 this((Properties) null);
112 }
113
114
115
116
117
118
119
120 public ReferentialJdbcDaoImpl(Properties connectionProperties) {
121 super();
122 this.connectionProperties = connectionProperties;
123 this.quserJdbcDao = new QuserJdbcDaoImpl(connectionProperties);
124 this.departmentJdbcDao = new DepartmentJdbcDaoImpl(connectionProperties);
125 this.programStrategyJdbcDao = new ProgramStrategyJdbcDaoImpl(connectionProperties);
126 this.ruleListJdbcDao = new RuleListJdbcDaoImpl(connectionProperties);
127
128
129 Properties properties = new Properties();
130 InputStream is = null;
131 try {
132 is = getClass().getClassLoader().getResourceAsStream(QUERIES_FILE_PATH);
133 properties.loadFromXML(is);
134
135 this.queriesJdbcProperties = properties;
136 } catch (IOException e) {
137 throw new QuadrigeTechnicalException(
138 String.format("Unable to read file [%s] from classpath", QUERIES_FILE_PATH),
139 e);
140 } finally {
141 IOUtils.closeQuietly(is);
142 }
143
144
145 checkAllQueriesExists();
146 }
147
148
149 @Override
150 public void afterPropertiesSet() {
151
152 checkAllQueriesExists();
153 }
154
155
156 @Override
157 public List<MonitoringLocationVO> getMonitoringLocationsByIds(List<Integer> ids) {
158
159 String sql = queriesJdbcProperties.getProperty("monitoringLocationsByIds");
160
161 sql = sql.replace(":ids", Joiner.on(",").skipNulls().join(ids));
162
163 Map<String, Object> paramMap = Maps.newHashMap();
164 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toMonitoringLocationVO(rs));
165 }
166
167
168 @Override
169 public MonitoringLocationVO getMonitoringLocationById(int id) {
170
171 String sql = queriesJdbcProperties.getProperty("monitoringLocationsByIds");
172
173 Map<String, Object> paramMap = Maps.newHashMap();
174 paramMap.put("ids", id);
175
176 return query(connectionProperties, sql, paramMap, this::toMonitoringLocationVO);
177 }
178
179
180 @Override
181 public List<TaxonNameVO> getTaxonNamesByReferenceTaxonIds(List<Integer> ids) {
182
183 String sql = queriesJdbcProperties.getProperty("taxonNamesByReferenceTaxonIds");
184
185 sql = sql.replace(":referenceTaxonIds", Joiner.on(",").skipNulls().join(ids));
186
187 Map<String, Object> paramMap = Maps.newHashMap();
188 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toTaxonVO(rs));
189 }
190
191
192 @Override
193 public TaxonNameVO getTaxonNameByReferenceTaxonId(int id) {
194
195 String sql = queriesJdbcProperties.getProperty("taxonNamesByReferenceTaxonIds");
196
197 Map<String, Object> paramMap = Maps.newHashMap();
198 paramMap.put("ids", id);
199
200 return query(connectionProperties, sql, paramMap, this::toTaxonVO);
201 }
202
203
204 @Override
205 public List<TaxonGroupVO> getTaxonGroupsByIds(List<Integer> ids) {
206
207 String sql = queriesJdbcProperties.getProperty("taxonGroupsByIds");
208
209 sql = sql.replace(":ids", Joiner.on(",").skipNulls().join(ids));
210
211 Map<String, Object> paramMap = Maps.newHashMap();
212 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toTaxonGroupVO(rs));
213 }
214
215
216 @Override
217 public TaxonGroupVO getTaxonGroupById(int id) {
218
219 String sql = queriesJdbcProperties.getProperty("taxonGroupsByIds");
220
221 Map<String, Object> paramMap = Maps.newHashMap();
222 paramMap.put("ids", id);
223
224 return query(connectionProperties, sql, paramMap, this::toTaxonGroupVO);
225 }
226
227
228 @Override
229 public List<ParameterVO> getParametersByCodes(List<String> codes) {
230
231 String sql = queriesJdbcProperties.getProperty("parametersByCodes");
232
233 sql = sql.replace(":codes", "'" + Joiner.on("','").skipNulls().join(codes) + "'");
234
235 Map<String, Object> paramMap = Maps.newHashMap();
236 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toParameterVO(rs));
237 }
238
239
240 @Override
241 public ParameterVO getParameterByCode(String code) {
242
243 String sql = queriesJdbcProperties.getProperty("parametersByCodes");
244
245 Map<String, Object> paramMap = Maps.newHashMap();
246 paramMap.put("codes", code);
247
248 return query(connectionProperties, sql, paramMap, this::toParameterVO);
249 }
250
251
252 @Override
253 public List<MatrixVO> getMatrixesByIds(List<Integer> ids) {
254
255 String sql = queriesJdbcProperties.getProperty("matrixesByIds");
256
257 sql = sql.replace(":ids", Joiner.on(",").skipNulls().join(ids));
258
259 Map<String, Object> paramMap = Maps.newHashMap();
260 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toMatrixVO(rs));
261 }
262
263
264 @Override
265 public MatrixVO getMatrixById(int id) {
266
267 String sql = queriesJdbcProperties.getProperty("matrixesByIds");
268
269 Map<String, Object> paramMap = Maps.newHashMap();
270 paramMap.put("ids", id);
271
272 return query(connectionProperties, sql, paramMap, this::toMatrixVO);
273 }
274
275
276 @Override
277 public List<FractionVO> getFractionsByIds(List<Integer> ids) {
278
279 String sql = queriesJdbcProperties.getProperty("fractionsByIds");
280
281 sql = sql.replace(":ids", Joiner.on(",").skipNulls().join(ids));
282
283 Map<String, Object> paramMap = Maps.newHashMap();
284 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toFractionVO(rs));
285 }
286
287
288 @Override
289 public FractionVO getFractionById(int id) {
290
291 String sql = queriesJdbcProperties.getProperty("fractionsByIds");
292
293 Map<String, Object> paramMap = Maps.newHashMap();
294 paramMap.put("ids", id);
295
296 return query(connectionProperties, sql, paramMap, this::toFractionVO);
297 }
298
299
300 @Override
301 public List<MethodVO> getMethodsByIds(List<Integer> ids) {
302
303 String sql = queriesJdbcProperties.getProperty("methodsByIds");
304
305 sql = sql.replace(":ids", Joiner.on(",").skipNulls().join(ids));
306
307 Map<String, Object> paramMap = Maps.newHashMap();
308 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toMethodVO(rs));
309 }
310
311
312 @Override
313 public MethodVO getMethodById(int id) {
314
315 String sql = queriesJdbcProperties.getProperty("methodsByIds");
316
317 Map<String, Object> paramMap = Maps.newHashMap();
318 paramMap.put("ids", id);
319
320 return query(connectionProperties, sql, paramMap, this::toMethodVO);
321 }
322
323
324 @Override
325 public List<PmfmVO> getPmfmsByIds(List<Integer> ids) {
326
327 String sql = queriesJdbcProperties.getProperty("pmfmsByIds");
328
329 sql = sql.replace(":ids", Joiner.on(",").skipNulls().join(ids));
330
331 Map<String, Object> paramMap = Maps.newHashMap();
332 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toPmfmVO(rs));
333 }
334
335
336 @Override
337 public PmfmVO getPmfmById(int id) {
338
339 String sql = queriesJdbcProperties.getProperty("pmfmsByIds");
340
341 Map<String, Object> paramMap = Maps.newHashMap();
342 paramMap.put("ids", id);
343
344 return query(connectionProperties, sql, paramMap, this::toPmfmVO);
345 }
346
347
348 @Override
349 public List<UnitVO> getUnitsByIds(List<Integer> ids) {
350
351 String sql = queriesJdbcProperties.getProperty("unitsByIds");
352
353 sql = sql.replace(":ids", Joiner.on(",").skipNulls().join(ids));
354
355 Map<String, Object> paramMap = Maps.newHashMap();
356 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toUnitVO(rs));
357 }
358
359
360 @Override
361 public UnitVO getUnitById(int id) {
362
363 String sql = queriesJdbcProperties.getProperty("unitsByIds");
364
365 Map<String, Object> paramMap = Maps.newHashMap();
366 paramMap.put("ids", id);
367
368 return query(connectionProperties, sql, paramMap, this::toUnitVO);
369 }
370
371
372 @Override
373 public List<AnalysisInstrumentVO> getAnalysisInstrumentsByIds(List<Integer> ids) {
374
375 String sql = queriesJdbcProperties.getProperty("analysisInstrumentsByIds");
376
377 sql = sql.replace(":ids", Joiner.on(",").skipNulls().join(ids));
378
379 Map<String, Object> paramMap = Maps.newHashMap();
380 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toAnalysisInstrumentVO(rs));
381 }
382
383
384 @Override
385 public AnalysisInstrumentVO getAnalysisInstrumentById(int id) {
386
387 String sql = queriesJdbcProperties.getProperty("analysisInstrumentsByIds");
388
389 Map<String, Object> paramMap = Maps.newHashMap();
390 paramMap.put("ids", id);
391
392 return query(connectionProperties, sql, paramMap, this::toAnalysisInstrumentVO);
393 }
394
395
396 @Override
397 public List<SamplingEquipmentVO> getSamplingEquipmentsByIds(List<Integer> ids) {
398
399 String sql = queriesJdbcProperties.getProperty("samplingEquipmentsByIds");
400
401 sql = sql.replace(":ids", Joiner.on(",").skipNulls().join(ids));
402
403 Map<String, Object> paramMap = Maps.newHashMap();
404 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toSamplingEquipmentVO(rs));
405 }
406
407
408 @Override
409 public SamplingEquipmentVO getSamplingEquipmentById(int id) {
410
411 String sql = queriesJdbcProperties.getProperty("samplingEquipmentsByIds");
412
413 Map<String, Object> paramMap = Maps.newHashMap();
414 paramMap.put("ids", id);
415
416 return query(connectionProperties, sql, paramMap, this::toSamplingEquipmentVO);
417 }
418
419
420 @Override
421 public List<QualitativeValueVO> getQualitativeValueByIds(List<Integer> ids) {
422
423 String sql = queriesJdbcProperties.getProperty("qualitativeValueByIds");
424
425 sql = sql.replace(":ids", Joiner.on(",").skipNulls().join(ids));
426
427 Map<String, Object> paramMap = Maps.newHashMap();
428 return query(connectionProperties, sql, paramMap, (rs, rowNum) -> toQualitativeValueVO(rs));
429 }
430
431
432 @Override
433 public QualitativeValueVO getQualitativeValueById(int id) {
434
435 String sql = queriesJdbcProperties.getProperty("qualitativeValueByIds");
436
437 Map<String, Object> paramMap = Maps.newHashMap();
438 paramMap.put("ids", id);
439
440 return query(connectionProperties, sql, paramMap, this::toQualitativeValueVO);
441 }
442
443
444 @Override
445 public List<?> getVOsByTableNameAndPks(String tableName, List<String> pks) {
446
447
448 if (tableName.equals(ReferentialSynchroTables.MONITORING_LOCATION.name())) {
449 return getMonitoringLocationsByIds(toIds(pks));
450 }
451
452
453 if (tableName.equals(ReferentialSynchroTables.REFERENCE_TAXON.name())) {
454 return getTaxonNamesByReferenceTaxonIds(toIds(pks));
455 }
456
457
458 if (tableName.equals(ReferentialSynchroTables.TAXON_GROUP.name())) {
459 return getTaxonGroupsByIds(toIds(pks));
460 }
461
462
463 if (tableName.equals(ReferentialSynchroTables.PARAMETER.name())) {
464 return getParametersByCodes(pks);
465 }
466
467
468 if (tableName.equals(ReferentialSynchroTables.MATRIX.name())) {
469 return getMatrixesByIds(toIds(pks));
470 }
471
472
473 if (tableName.equals(ReferentialSynchroTables.FRACTION.name())) {
474 return getFractionsByIds(toIds(pks));
475 }
476
477
478 if (tableName.equals(ReferentialSynchroTables.METHOD.name())) {
479 return getMethodsByIds(toIds(pks));
480 }
481
482
483 if (tableName.equals(ReferentialSynchroTables.PMFM.name())) {
484 return getPmfmsByIds(toIds(pks));
485 }
486
487
488 if (tableName.equals(ReferentialSynchroTables.UNIT.name())) {
489 return getUnitsByIds(toIds(pks));
490 }
491
492
493 if (tableName.equals(ReferentialSynchroTables.ANALYSIS_INSTRUMENT.name())) {
494 return getAnalysisInstrumentsByIds(toIds(pks));
495 }
496
497
498 if (tableName.equals(ReferentialSynchroTables.SAMPLING_EQUIPMENT.name())) {
499 return getSamplingEquipmentsByIds(toIds(pks));
500 }
501
502
503 if (tableName.equals(ReferentialSynchroTables.QUALITATIVE_VALUE.name())) {
504 return getQualitativeValueByIds(toIds(pks));
505 }
506
507
508 if (tableName.equals(ReferentialSynchroTables.QUSER.name())) {
509 return quserJdbcDao.getUsersByIds(toIds(pks));
510 }
511
512
513 if (tableName.equals(ReferentialSynchroTables.DEPARTMENT.name())) {
514 return departmentJdbcDao.getDepartmentsByIds(toIds(pks));
515 }
516
517
518 if (tableName.equals(ReferentialSynchroTables.PROGRAMME.name())) {
519 return programStrategyJdbcDao.getProgramsByCodes(pks);
520 }
521
522
523 if (tableName.equals(ReferentialSynchroTables.STRATEGY.name())) {
524 return programStrategyJdbcDao.getStrategiesByIds(toIds(pks));
525 }
526
527
528 if (tableName.equals(RuleSynchroTables.RULE_LIST.name())) {
529 return ruleListJdbcDao.getRuleListsByCodes(pks);
530 }
531
532 throw new QuadrigeTechnicalException(String.format("Unable to find DAO method for table [%s]", tableName));
533 }
534
535
536 @Override
537 public Object getVOByTableNameAndPk(String tableName, String pk) {
538
539 List<?> result = getVOsByTableNameAndPks(tableName, ImmutableList.of(pk));
540 if (CollectionUtils.isEmpty(result)) {
541 return null;
542 }
543 return result.get(0);
544 }
545
546
547
548
549
550
551 protected void checkAllQueriesExists() {
552 Assert.notNull(queriesJdbcProperties);
553
554 checkQueryExists("monitoringLocationsByIds");
555 checkQueryExists("taxonNamesByReferenceTaxonIds");
556 checkQueryExists("taxonGroupsByIds");
557 checkQueryExists("parametersByCodes");
558 checkQueryExists("matrixesByIds");
559 checkQueryExists("fractionsByIds");
560 checkQueryExists("methodsByIds");
561 checkQueryExists("pmfmsByIds");
562 checkQueryExists("unitsByIds");
563 checkQueryExists("analysisInstrumentsByIds");
564 checkQueryExists("samplingEquipmentsByIds");
565 checkQueryExists("qualitativeValueByIds");
566 }
567
568
569
570
571
572
573
574 protected void checkQueryExists(String queryName) {
575 if (StringUtils.isBlank(queriesJdbcProperties.getProperty(queryName))) {
576 throw new QuadrigeTechnicalException(String.format("Property with name [%s] not exists on JDBC queries file", queryName));
577 }
578 }
579
580
581
582
583
584
585
586
587
588
589
590
591 protected MonitoringLocationVO toMonitoringLocationVO(ResultSet rs) throws SQLException {
592 MonitoringLocationVO target = new MonitoringLocationVO();
593
594 int index = 0;
595 target.setId(rs.getInt(++index));
596 target.setLabel(rs.getString(++index));
597 target.setName(rs.getString(++index));
598
599 return target;
600 }
601
602
603
604
605
606
607
608
609
610
611
612
613 protected TaxonNameVO toTaxonVO(ResultSet rs) throws SQLException {
614 TaxonNameVO target = new TaxonNameVO();
615
616 int index = 0;
617 target.setId(rs.getInt(++index));
618 target.setName(rs.getString(++index));
619
620 return target;
621 }
622
623
624
625
626
627
628
629
630
631
632
633
634 protected TaxonGroupVO toTaxonGroupVO(ResultSet rs) throws SQLException {
635 TaxonGroupVO target = new TaxonGroupVO();
636
637 int index = 0;
638 target.setId(rs.getInt(++index));
639 target.setName(rs.getString(++index));
640
641 return target;
642 }
643
644
645
646
647
648
649
650
651
652
653
654
655 protected ParameterVO toParameterVO(ResultSet rs) throws SQLException {
656 ParameterVO target = new ParameterVO();
657
658 int index = 0;
659 target.setCode(rs.getString(++index));
660 target.setName(rs.getString(++index));
661
662 return target;
663 }
664
665
666
667
668
669
670
671
672
673
674
675
676 protected MatrixVO toMatrixVO(ResultSet rs) throws SQLException {
677 MatrixVO target = new MatrixVO();
678
679 int index = 0;
680 target.setId(rs.getInt(++index));
681 target.setName(rs.getString(++index));
682
683 return target;
684 }
685
686
687
688
689
690
691
692
693
694
695
696
697 protected FractionVO toFractionVO(ResultSet rs) throws SQLException {
698 FractionVO target = new FractionVO();
699
700 int index = 0;
701 target.setId(rs.getInt(++index));
702 target.setName(rs.getString(++index));
703
704 return target;
705 }
706
707
708
709
710
711
712
713
714
715
716
717
718 protected MethodVO toMethodVO(ResultSet rs) throws SQLException {
719 MethodVO target = new MethodVO();
720
721 int index = 0;
722 target.setId(rs.getInt(++index));
723 target.setName(rs.getString(++index));
724
725 return target;
726 }
727
728
729
730
731
732
733
734
735
736
737
738
739 protected PmfmVO toPmfmVO(ResultSet rs) throws SQLException {
740 PmfmVO target = new PmfmVO();
741
742 int index = 0;
743 target.setId(rs.getInt(++index));
744
745
746 ParameterVO parameter = new ParameterVO();
747 parameter.setCode(rs.getString(++index));
748 parameter.setName(rs.getString(++index));
749 target.setParameter(parameter);
750
751
752 MatrixVO matrix = new MatrixVO();
753 matrix.setId(rs.getInt(++index));
754 matrix.setName(rs.getString(++index));
755 target.setMatrix(matrix);
756
757
758 FractionVO fraction = new FractionVO();
759 fraction.setId(rs.getInt(++index));
760 fraction.setName(rs.getString(++index));
761 target.setFraction(fraction);
762
763
764 MethodVO method = new MethodVO();
765 method.setId(rs.getInt(++index));
766 method.setName(rs.getString(++index));
767 target.setMethod(method);
768
769
770 UnitVO unit = new UnitVO();
771 unit.setId(rs.getInt(++index));
772 unit.setName(rs.getString(++index));
773 unit.setSymbol(rs.getString(++index));
774 target.setUnit(unit);
775
776 return target;
777 }
778
779
780
781
782
783
784
785
786
787
788
789
790 protected UnitVO toUnitVO(ResultSet rs) throws SQLException {
791 UnitVO target = new UnitVO();
792
793 int index = 0;
794 target.setId(rs.getInt(++index));
795 target.setName(rs.getString(++index));
796 target.setSymbol(rs.getString(++index));
797
798 return target;
799 }
800
801
802
803
804
805
806
807
808
809
810
811
812 protected AnalysisInstrumentVO toAnalysisInstrumentVO(ResultSet rs) throws SQLException {
813 AnalysisInstrumentVO target = new AnalysisInstrumentVO();
814
815 int index = 0;
816 target.setId(rs.getInt(++index));
817 target.setName(rs.getString(++index));
818
819 return target;
820 }
821
822
823
824
825
826
827
828
829
830
831
832
833 protected SamplingEquipmentVO toSamplingEquipmentVO(ResultSet rs) throws SQLException {
834 SamplingEquipmentVO target = new SamplingEquipmentVO();
835
836 int index = 0;
837 target.setId(rs.getInt(++index));
838 target.setName(rs.getString(++index));
839
840 return target;
841 }
842
843
844
845
846
847
848
849
850
851
852
853
854 protected QualitativeValueVO toQualitativeValueVO(ResultSet rs) throws SQLException {
855 QualitativeValueVO target = new QualitativeValueVO();
856
857 int index = 0;
858 target.setId(rs.getInt(++index));
859 target.setName(rs.getString(++index));
860
861 ParameterVO parameter = new ParameterVO();
862 parameter.setCode(rs.getString(++index));
863 parameter.setName(rs.getString(++index));
864 target.setParameter(parameter);
865
866 return target;
867 }
868
869
870
871
872
873
874
875
876
877
878 protected List<Integer> toIds(List<String> pkStr) {
879 return pkStr.stream().map(s -> s == null ? null : Integer.parseInt(s.trim())).collect(Collectors.toList());
880 }
881 }