Revision d0c77267
Added by Andreas Müller over 5 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/validation/BerlinModelTaxonRelationImportValidator.java | ||
---|---|---|
36 | 36 |
result &= checkConceptRelationsWithSynonymTaxa(state); |
37 | 37 |
result &= checkRelPTaxonWithNotes(state); |
38 | 38 |
result &= checkTaxaWithNoRelations(state); |
39 |
result &= checkTaxonRelationsWithDifferingRelReferences(state); |
|
39 | 40 |
return result; |
40 | 41 |
} |
41 | 42 |
|
... | ... | |
306 | 307 |
return success; |
307 | 308 |
} |
308 | 309 |
|
310 |
private boolean checkTaxonRelationsWithDifferingRelReferences(BerlinModelImportState state) { |
|
311 |
boolean success = true; |
|
312 |
try { |
|
313 |
BerlinModelImportConfigurator config = state.getConfig(); |
|
314 |
|
|
315 |
Source source = config.getSource(); |
|
316 |
String strSelect = " SELECT rel.RelQualifierFk, rel.RelRefFk, syn.PTRefFk, * "; |
|
317 |
String strCount = " SELECT count(*) as n "; |
|
318 |
String strQueryBase = |
|
319 |
" SELECT rel.RelQualifierFk, rel.RelRefFk, syn.PTRefFk, * " + |
|
320 |
" FROM RelPTaxon rel " + |
|
321 |
" INNER JOIN PTaxon syn ON rel.PTRefFk1 = syn.PTRefFk AND rel.PTNameFk1 = syn.PTNameFk " + |
|
322 |
" WHERE rel.RelRefFk IS NOT NULL AND rel.RelRefFk <> syn.PTRefFk AND rel.RelRefFk <> rel.PTRefFk2 " + |
|
323 |
// -- AND rel.RelQualifierFk in (2, 6,7, 101, 102, 103, 104) |
|
324 |
" "; |
|
325 |
String strOrderBy = " ORDER BY rel.RelQualifierFk, rel.RelRefFk, syn.PTRefFk "; |
|
326 |
|
|
327 |
ResultSet rs = source.getResultSet(strCount + strQueryBase); |
|
328 |
rs.next(); |
|
329 |
int n = rs.getInt("n"); |
|
330 |
if (n > 0){ |
|
331 |
System.out.println("======================================================================="); |
|
332 |
System.out.println("There are "+n+" relationship with references that differ from taxon reference. This is mostly problematic for synonym relationships as they can not store these references!"); |
|
333 |
System.out.println("======================================================================="); |
|
334 |
} |
|
335 |
|
|
336 |
rs = source.getResultSet(strSelect + strQueryBase + strOrderBy); |
|
337 |
while (rs.next()){ |
|
338 |
|
|
339 |
int secRefFk = rs.getInt("secRefFk"); |
|
340 |
String secRef = rs.getString("secRef"); |
|
341 |
String nameCache = rs.getString("FullNameCache"); |
|
342 |
int nameId = rs.getInt("NameId"); |
|
343 |
String status = rs.getString("Status"); |
|
344 |
|
|
345 |
System.out.println("SecRef:" + secRefFk + |
|
346 |
"\n secRef: " + secRef + "\n name: " + nameCache + "\n nameId: " + nameId |
|
347 |
+ "\n status: " + status |
|
348 |
); |
|
349 |
} |
|
350 |
success = (n == 0); |
|
351 |
} catch (SQLException e) { |
|
352 |
e.printStackTrace(); |
|
353 |
success = false; |
|
354 |
} |
|
355 |
return success; |
|
356 |
} |
|
357 |
|
|
309 | 358 |
|
310 | 359 |
|
311 | 360 |
} |
Also available in: Unified diff
ref #3992, ref #7713, ref #3990 add test for differing synonym relation references