1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.io.berlinModel.in.validation;
|
12
|
|
13
|
import java.sql.ResultSet;
|
14
|
import java.sql.SQLException;
|
15
|
import java.util.HashSet;
|
16
|
import java.util.Set;
|
17
|
|
18
|
import org.apache.log4j.Logger;
|
19
|
|
20
|
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator;
|
21
|
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportState;
|
22
|
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelReferenceImport;
|
23
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
24
|
import eu.etaxonomy.cdm.io.common.IOValidator;
|
25
|
import eu.etaxonomy.cdm.io.common.Source;
|
26
|
|
27
|
/**
|
28
|
* @author a.mueller
|
29
|
* @created 17.02.2010
|
30
|
* @version 1.0
|
31
|
*/
|
32
|
public class BerlinModelReferenceImportValidator implements IOValidator<BerlinModelImportState> {
|
33
|
private static final Logger logger = Logger.getLogger(BerlinModelReferenceImportValidator.class);
|
34
|
|
35
|
public boolean validate(BerlinModelImportState state, BerlinModelReferenceImport refImport){
|
36
|
boolean result = true;
|
37
|
BerlinModelImportConfigurator bmiConfig = state.getConfig();
|
38
|
result &= checkArticlesWithoutJournal(bmiConfig);
|
39
|
result &= checkPartOfJournal(bmiConfig);
|
40
|
result &= checkPartOfUnresolved(bmiConfig);
|
41
|
result &= checkPartOfPartOf(bmiConfig);
|
42
|
result &= checkPartOfArticle(bmiConfig);
|
43
|
result &= checkJournalsWithSeries(bmiConfig);
|
44
|
result &= checkObligatoryAttributes(bmiConfig, refImport);
|
45
|
result &= checkPartOfWithVolume(bmiConfig);
|
46
|
result &= checkArticleWithEdition(bmiConfig);
|
47
|
|
48
|
if (result == false ){System.out.println("========================================================");}
|
49
|
|
50
|
return result;
|
51
|
|
52
|
}
|
53
|
|
54
|
/* (non-Javadoc)
|
55
|
* @see eu.etaxonomy.cdm.io.common.IOValidator#validate(eu.etaxonomy.cdm.io.common.IoStateBase)
|
56
|
*/
|
57
|
@Deprecated //use validate(state, import) instead
|
58
|
public boolean validate(BerlinModelImportState state) {
|
59
|
logger.warn("BerlinModelReferenceImport uses wrong validation method");
|
60
|
return false;
|
61
|
}
|
62
|
|
63
|
|
64
|
//******************************** CHECK *************************************************
|
65
|
|
66
|
private static boolean checkArticlesWithoutJournal(BerlinModelImportConfigurator bmiConfig){
|
67
|
try {
|
68
|
boolean result = true;
|
69
|
Source source = bmiConfig.getSource();
|
70
|
String strQueryArticlesWithoutJournal = "SELECT Reference.RefId, InRef.RefId AS InRefID, Reference.RefCategoryFk, InRef.RefCategoryFk AS InRefCatFk, Reference.RefCache, Reference.NomRefCache, Reference.Title, RefCategory.RefCategoryAbbrev, InRefCategory.RefCategoryAbbrev AS InRefCat, InRef.Title AS InRefTitle " +
|
71
|
" FROM Reference INNER JOIN Reference AS InRef ON Reference.InRefFk = InRef.RefId INNER JOIN RefCategory ON Reference.RefCategoryFk = RefCategory.RefCategoryId INNER JOIN RefCategory AS InRefCategory ON InRef.RefCategoryFk = InRefCategory.RefCategoryId " +
|
72
|
" WHERE (Reference.RefCategoryFk = 1) AND (InRef.RefCategoryFk <> 9) ";
|
73
|
ResultSet resulSetarticlesWithoutJournal = source.getResultSet(strQueryArticlesWithoutJournal);
|
74
|
boolean firstRow = true;
|
75
|
while (resulSetarticlesWithoutJournal.next()){
|
76
|
if (firstRow){
|
77
|
System.out.println("========================================================");
|
78
|
logger.warn("There are Articles with wrong inRef type!");
|
79
|
System.out.println("========================================================");
|
80
|
}
|
81
|
int refId = resulSetarticlesWithoutJournal.getInt("RefId");
|
82
|
//int categoryFk = resulSetarticlesWithoutJournal.getInt("RefCategoryFk");
|
83
|
String cat = resulSetarticlesWithoutJournal.getString("RefCategoryAbbrev");
|
84
|
int inRefFk = resulSetarticlesWithoutJournal.getInt("InRefId");
|
85
|
//int inRefCategoryFk = resulSetarticlesWithoutJournal.getInt("InRefCatFk");
|
86
|
String inRefCat = resulSetarticlesWithoutJournal.getString("InRefCat");
|
87
|
String refCache = resulSetarticlesWithoutJournal.getString("RefCache");
|
88
|
String nomRefCache = resulSetarticlesWithoutJournal.getString("nomRefCache");
|
89
|
String title = resulSetarticlesWithoutJournal.getString("title");
|
90
|
String inRefTitle = resulSetarticlesWithoutJournal.getString("InRefTitle");
|
91
|
|
92
|
System.out.println("RefID:" + refId + "\n cat: " + cat +
|
93
|
"\n refCache: " + refCache + "\n nomRefCache: " + nomRefCache + "\n title: " + title +
|
94
|
"\n inRefFk: " + inRefFk + "\n inRefCategory: " + inRefCat +
|
95
|
"\n inRefTitle: " + inRefTitle );
|
96
|
result = firstRow = false;
|
97
|
}
|
98
|
|
99
|
return result;
|
100
|
} catch (SQLException e) {
|
101
|
e.printStackTrace();
|
102
|
return false;
|
103
|
}
|
104
|
}
|
105
|
|
106
|
private static boolean checkPartOfJournal(BerlinModelImportConfigurator bmiConfig){
|
107
|
try {
|
108
|
boolean result = true;
|
109
|
Source source = bmiConfig.getSource();
|
110
|
String strQueryPartOfJournal = "SELECT Reference.RefId, InRef.RefId AS InRefID, Reference.RefCategoryFk, InRef.RefCategoryFk AS InRefCatFk, Reference.RefCache, Reference.NomRefCache, Reference.Title, RefCategory.RefCategoryAbbrev, InRefCategory.RefCategoryAbbrev AS InRefCat, InRef.Title AS InRefTitle " +
|
111
|
" FROM Reference INNER JOIN Reference AS InRef ON Reference.InRefFk = InRef.RefId INNER JOIN RefCategory ON Reference.RefCategoryFk = RefCategory.RefCategoryId INNER JOIN RefCategory AS InRefCategory ON InRef.RefCategoryFk = InRefCategory.RefCategoryId " +
|
112
|
" WHERE (Reference.RefCategoryFk = 2) AND (InRef.RefCategoryFk = 9) ";
|
113
|
ResultSet rs = source.getResultSet(strQueryPartOfJournal);
|
114
|
boolean firstRow = true;
|
115
|
while (rs.next()){
|
116
|
if (firstRow){
|
117
|
System.out.println("========================================================");
|
118
|
logger.warn("There are part-of-references that have a Journal as in-reference!");
|
119
|
System.out.println("========================================================");
|
120
|
}
|
121
|
int refId = rs.getInt("RefId");
|
122
|
//int categoryFk = rs.getInt("RefCategoryFk");
|
123
|
String cat = rs.getString("RefCategoryAbbrev");
|
124
|
int inRefFk = rs.getInt("InRefId");
|
125
|
//int inRefCategoryFk = rs.getInt("InRefCatFk");
|
126
|
String inRefCat = rs.getString("InRefCat");
|
127
|
String refCache = rs.getString("RefCache");
|
128
|
String nomRefCache = rs.getString("nomRefCache");
|
129
|
String title = rs.getString("title");
|
130
|
String inRefTitle = rs.getString("InRefTitle");
|
131
|
|
132
|
System.out.println("RefID:" + refId + "\n cat: " + cat +
|
133
|
"\n refCache: " + refCache + "\n nomRefCache: " + nomRefCache + "\n title: " + title +
|
134
|
"\n inRefFk: " + inRefFk + "\n inRefCategory: " + inRefCat +
|
135
|
"\n inRefTitle: " + inRefTitle );
|
136
|
result = firstRow = false;
|
137
|
}
|
138
|
|
139
|
return result;
|
140
|
} catch (SQLException e) {
|
141
|
e.printStackTrace();
|
142
|
return false;
|
143
|
}
|
144
|
}
|
145
|
|
146
|
|
147
|
private static boolean checkPartOfUnresolved(BerlinModelImportConfigurator bmiConfig){
|
148
|
try {
|
149
|
boolean result = true;
|
150
|
Source source = bmiConfig.getSource();
|
151
|
String strQueryPartOfJournal = "SELECT Reference.RefId, InRef.RefId AS InRefID, Reference.RefCategoryFk, InRef.RefCategoryFk AS InRefCatFk, Reference.RefCache, Reference.NomRefCache, Reference.Title, RefCategory.RefCategoryAbbrev, InRefCategory.RefCategoryAbbrev AS InRefCat, InRef.Title AS InRefTitle " +
|
152
|
" FROM Reference INNER JOIN Reference AS InRef ON Reference.InRefFk = InRef.RefId INNER JOIN RefCategory ON Reference.RefCategoryFk = RefCategory.RefCategoryId INNER JOIN RefCategory AS InRefCategory ON InRef.RefCategoryFk = InRefCategory.RefCategoryId " +
|
153
|
" WHERE (Reference.RefCategoryFk = 2) AND (InRef.RefCategoryFk = 10) ";
|
154
|
ResultSet rs = source.getResultSet(strQueryPartOfJournal);
|
155
|
boolean firstRow = true;
|
156
|
while (rs.next()){
|
157
|
if (firstRow){
|
158
|
System.out.println("========================================================");
|
159
|
logger.warn("There are part-of-references that have an 'unresolved' in-reference!");
|
160
|
System.out.println("========================================================");
|
161
|
}
|
162
|
int refId = rs.getInt("RefId");
|
163
|
//int categoryFk = rs.getInt("RefCategoryFk");
|
164
|
String cat = rs.getString("RefCategoryAbbrev");
|
165
|
int inRefFk = rs.getInt("InRefId");
|
166
|
//int inRefCategoryFk = rs.getInt("InRefCatFk");
|
167
|
String inRefCat = rs.getString("InRefCat");
|
168
|
String refCache = rs.getString("RefCache");
|
169
|
String nomRefCache = rs.getString("nomRefCache");
|
170
|
String title = rs.getString("title");
|
171
|
String inRefTitle = rs.getString("InRefTitle");
|
172
|
|
173
|
System.out.println("RefID:" + refId + "\n cat: " + cat +
|
174
|
"\n refCache: " + refCache + "\n nomRefCache: " + nomRefCache + "\n title: " + title +
|
175
|
"\n inRefFk: " + inRefFk + "\n inRefCategory: " + inRefCat +
|
176
|
"\n inRefTitle: " + inRefTitle );
|
177
|
result = firstRow = false;
|
178
|
}
|
179
|
if (result == false){
|
180
|
System.out.println("\nChoose a specific type from the following reference types: \n" +
|
181
|
" 1) Article \n 2) Book \n 3) BookSection \n 4) CdDvd \n 5) ConferenceProceeding \n 6) Database\n" +
|
182
|
" 7) Generic \n 7) InProceedings \n 8) Journal \n 9) Map \n 10) Patent \n 11) PersonalCommunication\n" +
|
183
|
" 12) PrintSeries \n 13) Proceedings \n 14) Report \n 15) Thesis \n 16) WebPage");
|
184
|
}
|
185
|
return result;
|
186
|
} catch (SQLException e) {
|
187
|
e.printStackTrace();
|
188
|
return false;
|
189
|
}
|
190
|
}
|
191
|
|
192
|
private static boolean checkPartOfPartOf(BerlinModelImportConfigurator bmiConfig){
|
193
|
try {
|
194
|
boolean result = true;
|
195
|
Source source = bmiConfig.getSource();
|
196
|
String strQueryPartOfJournal = "SELECT Reference.RefId, InRef.RefId AS InRefID, Reference.RefCategoryFk, InRef.RefCategoryFk AS InRefCatFk, Reference.RefCache, Reference.NomRefCache, Reference.Title, RefCategory.RefCategoryAbbrev, InRefCategory.RefCategoryAbbrev AS InRefCat, InRef.Title AS InRefTitle, InRef.InRefFk as InInRefId, InInRef.Title as inInRefTitle, InInRef.RefCategoryFk as inInRefCategory " +
|
197
|
" FROM Reference " +
|
198
|
" INNER JOIN Reference AS InRef ON Reference.InRefFk = InRef.RefId " +
|
199
|
" INNER JOIN RefCategory ON Reference.RefCategoryFk = RefCategory.RefCategoryId " +
|
200
|
" INNER JOIN RefCategory AS InRefCategory ON InRef.RefCategoryFk = InRefCategory.RefCategoryId " +
|
201
|
" INNER JOIN Reference AS InInRef ON InRef.InRefFk = InInRef.RefId " +
|
202
|
" WHERE (Reference.RefCategoryFk = 2) AND (InRef.RefCategoryFk = 2) ";
|
203
|
ResultSet rs = source.getResultSet(strQueryPartOfJournal);
|
204
|
boolean firstRow = true;
|
205
|
while (rs.next()){
|
206
|
if (firstRow){
|
207
|
System.out.println("========================================================");
|
208
|
logger.warn("There are part-of-references that are part of an other 'part-of' reference!\n" +
|
209
|
" This is invalid or ambigous. Please try to determine the reference types more detailed ");
|
210
|
System.out.println("========================================================");
|
211
|
}
|
212
|
int refId = rs.getInt("RefId");
|
213
|
//int categoryFk = rs.getInt("RefCategoryFk");
|
214
|
String cat = rs.getString("RefCategoryAbbrev");
|
215
|
int inRefFk = rs.getInt("InRefId");
|
216
|
//int inRefCategoryFk = rs.getInt("InRefCatFk");
|
217
|
String inRefCat = rs.getString("InRefCat");
|
218
|
String refCache = rs.getString("RefCache");
|
219
|
String nomRefCache = rs.getString("nomRefCache");
|
220
|
String title = rs.getString("title");
|
221
|
String inRefTitle = rs.getString("InRefTitle");
|
222
|
int inInRefId = rs.getInt("InInRefId");
|
223
|
String inInRefTitle = rs.getString("inInRefTitle");
|
224
|
int inInRefCategory = rs.getInt("inInRefCategory");
|
225
|
|
226
|
System.out.println("RefID:" + refId + "\n cat: " + cat +
|
227
|
"\n refCache: " + refCache + "\n nomRefCache: " + nomRefCache + "\n title: " + title +
|
228
|
"\n inRefFk: " + inRefFk + "\n inRefCategory: " + inRefCat +
|
229
|
"\n inRefTitle: " + inRefTitle + "\n inInRefId: " + inInRefId + "\n inInRefTitle: " + inInRefTitle +
|
230
|
"\n inInRefCategory: " + inInRefCategory );
|
231
|
result = firstRow = false;
|
232
|
}
|
233
|
if (result == false){
|
234
|
System.out.println("\nChoose a specific type from the following reference types: \n" +
|
235
|
" 1) BookSection - Book - PrintSeries \n" +
|
236
|
" 2) InProceedings - pProceedings - PrintSeries");
|
237
|
}
|
238
|
return result;
|
239
|
} catch (SQLException e) {
|
240
|
e.printStackTrace();
|
241
|
return false;
|
242
|
}
|
243
|
}
|
244
|
|
245
|
|
246
|
private static boolean checkPartOfArticle(BerlinModelImportConfigurator bmiConfig){
|
247
|
try {
|
248
|
boolean result = true;
|
249
|
Source source = bmiConfig.getSource();
|
250
|
String strQueryPartOfJournal = "SELECT Reference.RefId, InRef.RefId AS InRefID, Reference.RefCategoryFk, InRef.RefCategoryFk AS InRefCatFk, Reference.RefCache, Reference.NomRefCache, Reference.Title, Reference.NomTitleAbbrev as nomTitleAbbrev, RefCategory.RefCategoryAbbrev, InRefCategory.RefCategoryAbbrev AS InRefCat, InRef.Title AS InRefTitle, InRef.nomTitleAbbrev AS inRefnomTitleAbbrev, InRef.refCache AS inRefCache, InRef.nomRefCache AS inRefnomRefCache " +
|
251
|
" FROM Reference INNER JOIN Reference AS InRef ON Reference.InRefFk = InRef.RefId INNER JOIN RefCategory ON Reference.RefCategoryFk = RefCategory.RefCategoryId INNER JOIN RefCategory AS InRefCategory ON InRef.RefCategoryFk = InRefCategory.RefCategoryId " +
|
252
|
" WHERE (Reference.RefCategoryFk = 2) AND (InRef.RefCategoryFk = 1) ";
|
253
|
ResultSet rs = source.getResultSet(strQueryPartOfJournal);
|
254
|
boolean firstRow = true;
|
255
|
while (rs.next()){
|
256
|
if (firstRow){
|
257
|
System.out.println("========================================================");
|
258
|
logger.warn("There are part-of-references that have an article as in-reference!");
|
259
|
System.out.println("========================================================");
|
260
|
}
|
261
|
int refId = rs.getInt("RefId");
|
262
|
//int categoryFk = rs.getInt("RefCategoryFk");
|
263
|
String cat = rs.getString("RefCategoryAbbrev");
|
264
|
int inRefFk = rs.getInt("InRefId");
|
265
|
//int inRefCategoryFk = rs.getInt("InRefCatFk");
|
266
|
String inRefCat = rs.getString("InRefCat");
|
267
|
String refCache = rs.getString("RefCache");
|
268
|
String nomRefCache = rs.getString("nomRefCache");
|
269
|
String title = rs.getString("title");
|
270
|
String nomTitleAbbrev = rs.getString("nomTitleAbbrev");
|
271
|
String inRefTitle = rs.getString("InRefTitle");
|
272
|
String inRefnomTitleAbbrev = rs.getString("inRefnomTitleAbbrev");
|
273
|
String inRefnomRefCache = rs.getString("inRefnomRefCache");
|
274
|
String inRefCache = rs.getString("inRefCache");
|
275
|
|
276
|
System.out.println("RefID:" + refId + "\n cat: " + cat +
|
277
|
"\n refCache: " + refCache + "\n nomRefCache: " + nomRefCache + "\n title: " + title + "\n titleAbbrev: " + nomTitleAbbrev +
|
278
|
"\n inRefFk: " + inRefFk + "\n inRefCategory: " + inRefCat +
|
279
|
"\n inRefTitle: " + inRefTitle + "\n inRefTitleAbbrev: " + inRefnomTitleAbbrev +
|
280
|
"\n inRefnomRefCache: " + inRefnomRefCache + "\n inRefCache: " + inRefCache
|
281
|
);
|
282
|
result = firstRow = false;
|
283
|
}
|
284
|
|
285
|
return result;
|
286
|
} catch (SQLException e) {
|
287
|
e.printStackTrace();
|
288
|
return false;
|
289
|
}
|
290
|
}
|
291
|
|
292
|
private static boolean checkJournalsWithSeries(BerlinModelImportConfigurator bmiConfig){
|
293
|
try {
|
294
|
boolean result = true;
|
295
|
Source source = bmiConfig.getSource();
|
296
|
String strQueryArticlesWithoutJournal = "SELECT Reference.RefId, Reference.RefCategoryFk, Reference.RefCache, Reference.NomRefCache, Reference.Title, Reference.NomTitleAbbrev, Reference.Series, RefCategory.RefCategoryAbbrev " +
|
297
|
" FROM Reference INNER JOIN " +
|
298
|
" RefCategory ON Reference.RefCategoryFk = RefCategory.RefCategoryId " +
|
299
|
" WHERE (Reference.RefCategoryFk = 9) AND ( Reference.series is not null AND Reference.series <>'') ";
|
300
|
ResultSet rs = source.getResultSet(strQueryArticlesWithoutJournal);
|
301
|
boolean firstRow = true;
|
302
|
while (rs.next()){
|
303
|
if (firstRow){
|
304
|
System.out.println("========================================================");
|
305
|
logger.warn("There are Journals with series! Series should be part of the according articles.");
|
306
|
System.out.println("========================================================");
|
307
|
}
|
308
|
int refId = rs.getInt("RefId");
|
309
|
//int categoryFk = rs.getInt("RefCategoryFk");
|
310
|
String cat = rs.getString("RefCategoryAbbrev");
|
311
|
String nomRefCache = rs.getString("nomRefCache");
|
312
|
String refCache = rs.getString("refCache");
|
313
|
String title = rs.getString("title");
|
314
|
String nomTitleAbbrev = rs.getString("nomTitleAbbrev");
|
315
|
String series = rs.getString("series");
|
316
|
|
317
|
System.out.println("RefID:" + refId + "\n cat: " + cat +
|
318
|
"\n refCache: " + refCache + "\n nomRefCache: " + nomRefCache +
|
319
|
"\n title: " + title + "\n nomTitleAbbrev: " + nomTitleAbbrev +
|
320
|
"\n series: " + series );
|
321
|
result = firstRow = false;
|
322
|
}
|
323
|
|
324
|
return result;
|
325
|
} catch (SQLException e) {
|
326
|
e.printStackTrace();
|
327
|
return false;
|
328
|
}
|
329
|
}
|
330
|
|
331
|
private static boolean checkPartOfWithVolume(BerlinModelImportConfigurator bmiConfig){
|
332
|
try {
|
333
|
boolean result = true;
|
334
|
Source source = bmiConfig.getSource();
|
335
|
String strQueryArticlesWithoutJournal = "SELECT Ref.RefId as refId, RefCategory.RefCategoryAbbrev as refCategoryAbbrev, Ref.nomRefCache as nomRefCache, Ref.refCache as refCache,Ref.volume as volume, Ref.Series as series, Ref.Edition as edition, Ref.title as title, Ref.nomTitleAbbrev as nomTitleAbbrev,InRef.RefCache as inRefRefCache, InRef.NomRefCache as inRefNomRefCache, InRef.RefId as inRefId, InRef.Volume as inRefVol, InRef.Series as inRefSeries, InRef.Edition as inRefEdition" +
|
336
|
" FROM Reference AS Ref " +
|
337
|
" INNER JOIN RefCategory ON Ref.RefCategoryFk = RefCategory.RefCategoryId " +
|
338
|
" LEFT OUTER JOIN Reference AS InRef ON Ref.InRefFk = InRef.RefId " +
|
339
|
" WHERE (Ref.RefCategoryFk = 2) AND ((Ref.Volume IS NOT NULL) OR (Ref.Series IS NOT NULL) OR (Ref.Edition IS NOT NULL)) " ;
|
340
|
ResultSet rs = source.getResultSet(strQueryArticlesWithoutJournal);
|
341
|
boolean firstRow = true;
|
342
|
while (rs.next()){
|
343
|
if (firstRow){
|
344
|
System.out.println("========================================================");
|
345
|
logger.warn("There are PartOfOtherTitles with volumes, editions or series !");
|
346
|
System.out.println("========================================================");
|
347
|
}
|
348
|
int refId = rs.getInt("refId");
|
349
|
String cat = rs.getString("refCategoryAbbrev");
|
350
|
String nomRefCache = rs.getString("nomRefCache");
|
351
|
String refCache = rs.getString("refCache");
|
352
|
String title = rs.getString("title");
|
353
|
String nomTitleAbbrev = rs.getString("nomTitleAbbrev");
|
354
|
String volume = rs.getString("volume");
|
355
|
String edition = rs.getString("edition");
|
356
|
String series = rs.getString("series");
|
357
|
String inRefRefCache = rs.getString("inRefRefCache");
|
358
|
String inRefNomRefCache = rs.getString("inRefNomRefCache");
|
359
|
int inRefId = rs.getInt("inRefId");
|
360
|
String inRefVolume = rs.getString("inRefVol");
|
361
|
String inRefSeries = rs.getString("inRefSeries");
|
362
|
String inRefEdition = rs.getString("inRefEdition");
|
363
|
|
364
|
System.out.println("RefID:" + refId + "\n cat: " + cat +
|
365
|
"\n refCache: " + refCache + "\n nomRefCache: " + nomRefCache +
|
366
|
"\n title: " + title + "\n nomTitleAbbrev: " + nomTitleAbbrev + "\n volume: " + volume + "\n series: " + series +"\n edition: " + edition +
|
367
|
"\n inRef-ID:" + inRefId + "\n inRef-cache: " + inRefRefCache +
|
368
|
"\n inRef-nomCache: " + inRefNomRefCache + "\n inRef-volume: " + inRefVolume +"\n inRef-series: " + inRefSeries +"\n inRef-edition: " + inRefEdition +
|
369
|
"" );
|
370
|
result = firstRow = false;
|
371
|
}
|
372
|
|
373
|
return result;
|
374
|
} catch (SQLException e) {
|
375
|
e.printStackTrace();
|
376
|
return false;
|
377
|
}
|
378
|
}
|
379
|
|
380
|
private static boolean checkArticleWithEdition(BerlinModelImportConfigurator bmiConfig){
|
381
|
try {
|
382
|
boolean result = true;
|
383
|
Source source = bmiConfig.getSource();
|
384
|
String strQueryArticlesWithoutJournal = "SELECT Ref.RefId as refId, RefCategory.RefCategoryAbbrev as refCategoryAbbrev, Ref.nomRefCache as nomRefCache, Ref.refCache as refCache,Ref.edition as edition, Ref.title as title, Ref.nomTitleAbbrev as nomTitleAbbrev,InRef.RefCache as inRefRefCache, InRef.NomRefCache as inRefNomRefCache, InRef.RefId as inRefId, InRef.Edition as inRefEdition" +
|
385
|
" FROM Reference AS Ref " +
|
386
|
" INNER JOIN RefCategory ON Ref.RefCategoryFk = RefCategory.RefCategoryId " +
|
387
|
" LEFT OUTER JOIN Reference AS InRef ON Ref.InRefFk = InRef.RefId " +
|
388
|
" WHERE (Ref.RefCategoryFk = 1) AND (NOT (Ref.Edition IS NULL)) " +
|
389
|
" ORDER BY InRef.RefId ";
|
390
|
ResultSet rs = source.getResultSet(strQueryArticlesWithoutJournal);
|
391
|
boolean firstRow = true;
|
392
|
while (rs.next()){
|
393
|
if (firstRow){
|
394
|
System.out.println("========================================================");
|
395
|
logger.warn("There are Articles with editions !");
|
396
|
System.out.println("========================================================");
|
397
|
}
|
398
|
int refId = rs.getInt("refId");
|
399
|
String cat = rs.getString("refCategoryAbbrev");
|
400
|
String nomRefCache = rs.getString("nomRefCache");
|
401
|
String refCache = rs.getString("refCache");
|
402
|
String title = rs.getString("title");
|
403
|
String nomTitleAbbrev = rs.getString("nomTitleAbbrev");
|
404
|
String edition = rs.getString("edition");
|
405
|
String inRefRefCache = rs.getString("inRefRefCache");
|
406
|
String inRefNomRefCache = rs.getString("inRefNomRefCache");
|
407
|
int inRefId = rs.getInt("inRefId");
|
408
|
String inRefEdition = rs.getString("inRefEdition");
|
409
|
|
410
|
System.out.println("RefID:" + refId + "\n cat: " + cat +
|
411
|
"\n refCache: " + refCache + "\n nomRefCache: " + nomRefCache +
|
412
|
"\n title: " + title + "\n nomTitleAbbrev: " + nomTitleAbbrev + "\n edition: " + edition +
|
413
|
"\n inRef-ID:" + inRefId + "\n inRef-cache: " + inRefRefCache +
|
414
|
"\n inRef-nomCache: " + inRefNomRefCache + "\n inRef-edition: " + inRefEdition +
|
415
|
"" );
|
416
|
result = firstRow = false;
|
417
|
}
|
418
|
|
419
|
return result;
|
420
|
} catch (SQLException e) {
|
421
|
e.printStackTrace();
|
422
|
return false;
|
423
|
}
|
424
|
}
|
425
|
|
426
|
protected boolean checkObligatoryAttributes(IImportConfigurator config, BerlinModelReferenceImport refImport){
|
427
|
boolean result = true;
|
428
|
|
429
|
try {
|
430
|
String strQuery = " SELECT Reference.* " +
|
431
|
" FROM Reference " +
|
432
|
// " INNER JOIN Reference ON Reference.RefId = RefDetail.RefFk " +
|
433
|
" WHERE (1=0) ";
|
434
|
BerlinModelImportConfigurator bmiConfig = (BerlinModelImportConfigurator)config;
|
435
|
Source source = bmiConfig.getSource();
|
436
|
ResultSet rs = source.getResultSet(strQuery);
|
437
|
int colCount = rs.getMetaData().getColumnCount();
|
438
|
Set<String> existingAttributes = new HashSet<String>();
|
439
|
for (int c = 0; c < colCount ; c++){
|
440
|
existingAttributes.add(rs.getMetaData().getColumnLabel(c+1).toLowerCase());
|
441
|
}
|
442
|
Set<String> obligatoryAttributes = refImport.getObligatoryAttributes(true, bmiConfig);
|
443
|
|
444
|
obligatoryAttributes.removeAll(existingAttributes);
|
445
|
for (String attr : obligatoryAttributes){
|
446
|
logger.warn("Missing attribute: " + attr);
|
447
|
}
|
448
|
|
449
|
//additional Attributes
|
450
|
obligatoryAttributes = refImport.getObligatoryAttributes(true, bmiConfig);
|
451
|
|
452
|
existingAttributes.removeAll(obligatoryAttributes);
|
453
|
for (String attr : existingAttributes){
|
454
|
logger.warn("Additional attribute: " + attr);
|
455
|
}
|
456
|
} catch (SQLException e) {
|
457
|
logger.error(e);
|
458
|
e.printStackTrace();
|
459
|
result = false;
|
460
|
}
|
461
|
return result;
|
462
|
}
|
463
|
|
464
|
protected boolean checkRefDetailUnimplementedAttributes(IImportConfigurator config){
|
465
|
boolean result = true;
|
466
|
|
467
|
try {
|
468
|
String strQuery = " SELECT Count(*) as n" +
|
469
|
" FROM RefDetail " +
|
470
|
// " INNER JOIN Reference ON Reference.RefId = RefDetail.RefFk " +
|
471
|
" WHERE SecondarySources is not NULL AND SecondarySources <> '' ";
|
472
|
BerlinModelImportConfigurator bmiConfig = (BerlinModelImportConfigurator)config;
|
473
|
Source source = bmiConfig.getSource();
|
474
|
ResultSet rs = source.getResultSet(strQuery);
|
475
|
|
476
|
rs.next();
|
477
|
int count = rs.getInt("n");
|
478
|
if (count > 0){
|
479
|
System.out.println("========================================================");
|
480
|
logger.warn("There are "+ count + " RefDetails with SecondarySources <> NULL ! Secondary sources are not yet implemented for Berlin Model Import");
|
481
|
System.out.println("========================================================");
|
482
|
|
483
|
}
|
484
|
strQuery = " SELECT Count(*) as n" +
|
485
|
" FROM RefDetail " +
|
486
|
// " INNER JOIN Reference ON Reference.RefId = RefDetail.RefFk " +
|
487
|
" WHERE IdInSource is not NULL AND IdInSource <> '' ";
|
488
|
rs = source.getResultSet(strQuery);
|
489
|
|
490
|
rs.next();
|
491
|
count = rs.getInt("n");
|
492
|
if (count > 0){
|
493
|
System.out.println("========================================================");
|
494
|
logger.warn("There are "+ count + " RefDetails with IdInSource <> NULL ! IdInSource are not yet implemented for Berlin Model Import");
|
495
|
System.out.println("========================================================");
|
496
|
|
497
|
}
|
498
|
|
499
|
} catch (SQLException e) {
|
500
|
logger.error(e);
|
501
|
e.printStackTrace();
|
502
|
result = false;
|
503
|
}
|
504
|
return result;
|
505
|
}
|
506
|
|
507
|
|
508
|
|
509
|
}
|