1
2
3
4
5
6
7
8
9 package eu.etaxonomy.cdm.io.erms.validation;
10
11 import java.sql.ResultSet;
12 import java.sql.SQLException;
13 import java.util.Map;
14
15 import org.apache.log4j.Logger;
16 import org.springframework.stereotype.Component;
17
18 import eu.etaxonomy.cdm.io.common.IOValidator;
19 import eu.etaxonomy.cdm.io.common.ResultSetPartitioner;
20 import eu.etaxonomy.cdm.io.common.Source;
21 import eu.etaxonomy.cdm.io.common.mapping.DbImportMapping;
22 import eu.etaxonomy.cdm.io.erms.ErmsImportBase;
23 import eu.etaxonomy.cdm.io.erms.ErmsImportConfigurator;
24 import eu.etaxonomy.cdm.io.erms.ErmsImportState;
25 import eu.etaxonomy.cdm.model.common.CdmBase;
26
27
28
29
30
31
32
33
34 @Component
35 public class ErmsGeneralImportValidator extends ErmsImportBase<CdmBase> implements IOValidator<ErmsImportState> {
36 private static final Logger logger = Logger.getLogger(ErmsGeneralImportValidator.class);
37
38 public ErmsGeneralImportValidator(){
39 super(null, null, null);
40 }
41
42
43
44
45 @Override
46 protected boolean doCheck(ErmsImportState state){
47 return validate(state);
48 }
49
50
51
52
53
54 public boolean validate(ErmsImportState state) {
55 boolean result = true;
56 ErmsImportConfigurator config = state.getConfig();
57
58
59
60 return result;
61 }
62
63 protected boolean doInvoke(ErmsImportState state){
64 boolean success = true;
65
66 return success;
67
68 }
69
70 private boolean checkRelAuthorsExist(ErmsImportConfigurator config){
71
72 try {
73 boolean result = true;
74 Source source = config.getSource();
75 String strQuery = "SELECT Count(*) as n " +
76 " FROM RelAuthor "
77 ;
78 ResultSet rs = source.getResultSet(strQuery);
79 rs.next();
80 int count = rs.getInt("n");
81 if (count > 0){
82 System.out.println("========================================================");
83 logger.warn("There are "+count+" RelAuthors, but RelAuthors are not implemented for CDM yet.");
84 System.out.println("========================================================");
85 }
86 return result;
87 } catch (SQLException e) {
88 e.printStackTrace();
89 return false;
90 }
91
92 }
93
94 private boolean checkRelReferenceExist(ErmsImportConfigurator config){
95
96 try {
97 boolean result = true;
98 Source source = config.getSource();
99 String strQuery = "SELECT Count(*) as n " +
100 " FROM RelReference "
101 ;
102 ResultSet rs = source.getResultSet(strQuery);
103 rs.next();
104 int count = rs.getInt("n");
105 if (count > 0){
106 System.out.println("========================================================");
107 logger.warn("There are "+count+" RelReferences, but RelReferences are not implemented for CDM yet.");
108 System.out.println("========================================================");
109 }
110 return result;
111 } catch (SQLException e) {
112 e.printStackTrace();
113 return false;
114 }
115
116 }
117
118
119
120
121
122 @Override
123 protected String getTableName() {
124 return null;
125 }
126
127
128
129
130 @Override
131 public String getPluralString() {
132 return null;
133 }
134
135
136
137
138
139 protected boolean isIgnore(ErmsImportState state){
140 return false;
141 }
142
143
144
145
146 @Override
147 protected String getRecordQuery(ErmsImportConfigurator config) {
148 return null;
149 }
150
151
152
153
154 public boolean doPartition(ResultSetPartitioner partitioner, ErmsImportState state) {
155 return true;
156 }
157
158
159
160
161 public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs) {
162 return null;
163 }
164
165
166
167
168
169 public CdmBase createObject(ResultSet rs, ErmsImportState state) throws SQLException {
170 return null;
171 }
172
173
174
175
176 @Override
177 protected DbImportMapping<?, ?> getMapping() {
178
179 return null;
180 }
181
182
183
184 }