1 package net.sumaris.core.extraction.dao.trip.cost;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import com.google.common.base.Preconditions;
26 import net.sumaris.core.extraction.dao.technical.XMLQuery;
27 import net.sumaris.core.extraction.dao.trip.rdb.ExtractionRdbTripDaoImpl;
28 import net.sumaris.core.extraction.vo.ExtractionFilterVO;
29 import net.sumaris.core.extraction.vo.trip.ExtractionTripFilterVO;
30 import net.sumaris.core.extraction.vo.trip.cost.ExtractionCostTripVersion;
31 import net.sumaris.core.extraction.vo.trip.rdb.ExtractionRdbTripContextVO;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34 import org.springframework.context.annotation.Lazy;
35 import org.springframework.stereotype.Repository;
36
37
38
39
40 @Repository("extractionCostTripDao")
41 @Lazy
42 public class ExtractionCostTripDaoImpl<C extends ExtractionRdbTripContextVO> extends ExtractionRdbTripDaoImpl<C> implements ExtractionCostTripDao {
43
44 private static final Logger log = LoggerFactory.getLogger(ExtractionCostTripDaoImpl.class);
45
46 private static final String XML_QUERY_COST_PATH = "cost/v%s/%s";
47 private String version = ExtractionCostTripVersion.VERSION_1_4.getLabel();
48
49 @Override
50 public C execute(ExtractionFilterVO filter) {
51 C context = super.execute(filter);
52
53
54 context.setFormatName(COST_FORMAT);
55 context.setFormatVersion(version);
56
57 return context;
58 }
59
60
61
62 protected XMLQuery createStationQuery(C context) {
63
64 XMLQuery xmlQuery = super.createStationQuery(context);
65
66
67
68 xmlQuery.setGroup("gearType", false);
69
70 return xmlQuery;
71 }
72
73 @Override
74 protected XMLQuery createSpeciesLengthQuery(C context) {
75 XMLQuery xmlQuery = super.createSpeciesLengthQuery(context);
76
77
78
79
80 xmlQuery.setGroup("sex", false);
81 xmlQuery.setGroup("lengthClass", false);
82 xmlQuery.setGroup("numberAtLength", false);
83
84 xmlQuery.injectQuery(getXMLQueryURL(context, "injectionSpeciesLengthTable"));
85
86 return xmlQuery;
87 }
88
89 protected String getQueryFullName(C context, String queryName) {
90 Preconditions.checkNotNull(context);
91 Preconditions.checkNotNull(context.getFormatVersion());
92
93 String versionStr = version.replaceAll("[.]", "_");
94 switch (queryName) {
95 case "injectionSpeciesLengthTable":
96 return String.format(XML_QUERY_COST_PATH, versionStr, queryName);
97 default:
98 return super.getQueryFullName(context, queryName);
99 }
100 }
101 }