Revision dd68b822
Added by Andreas Müller over 4 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiErmsValidator.java | ||
---|---|---|
50 | 50 |
this.destination = destination; |
51 | 51 |
// success &= testReferences(); //ready, few minor issues to be discussed with VLIZ |
52 | 52 |
success &= testTaxa(); |
53 |
success &= testTaxonRelations(); //name relations count!, Implement single compare tests
|
|
53 |
// success &= testTaxonRelations(); //name relations count!, single record compare tests for synonyms and included in
|
|
54 | 54 |
// success &= testCommonNames(); //source(s) discuss VLIZ, exact duplicates (except for sources), Anus(Korur) |
55 |
// success &= testDistributions(); //>1000 duplicates in "dr", sources (OccurrenceSource table), area spellings(Baelt Sea), 1 long note
|
|
55 |
// success &= testDistributions(); //>1000 duplicates in "dr", sources (OccurrenceSource table), 1 long note |
|
56 | 56 |
// success &= testNotes(); //ecology & link notes test (only count tested), sources untested (NoteSource table) |
57 | 57 |
// success &= testAdditionalTaxonSources(); //ready |
58 | 58 |
} catch (Exception e) { |
... | ... | |
100 | 100 |
|
101 | 101 |
int countSynonyms; |
102 | 102 |
int countIncludedIns; |
103 |
private boolean testTaxonRelations() { |
|
103 |
private boolean testTaxonRelations() throws SQLException {
|
|
104 | 104 |
System.out.println("Start validate taxon relations"); |
105 |
boolean success = testSynonymRelations(); |
|
106 |
success &= testIncludedInRelations(); |
|
105 |
boolean success = testSynonymRelations(); //only count, single record test still missing
|
|
106 |
success &= testIncludedInRelations(); //only count, single record test still missing
|
|
107 | 107 |
success &= testTotalRelations(); |
108 | 108 |
success &= testNameRelations(); |
109 | 109 |
return success; |
... | ... | |
122 | 122 |
} |
123 | 123 |
} |
124 | 124 |
|
125 |
private boolean testSynonymRelations() { |
|
125 |
private boolean testSynonymRelations() throws SQLException {
|
|
126 | 126 |
|
127 | 127 |
int countSrc = source.getUniqueInteger(countSynonymRelation); |
128 | 128 |
int countDest = destination.getUniqueInteger("SELECT count(*) FROM RelTaxon WHERE RelTaxonQualifierFk > 101"); |
... | ... | |
276 | 276 |
+ " ORDER BY CAST(t.id as nvarchar(20)) "); |
277 | 277 |
ResultSet destRS = destination.getResultSet("SELECT t.*, " |
278 | 278 |
+ " pt.GenusOrUninomial p_GenusOrUninomial, pt.InfraGenericEpithet p_InfraGenericEpithet, pt.SpecificEpithet p_SpecificEpithet, " |
279 |
+ " pt.treeIndex pTreeIndex, " |
|
279 | 280 |
+ " s.Name as sourceName, type.IdInSource typeSourceId, r.Rank " |
280 | 281 |
+ " FROM Taxon t " |
281 | 282 |
+ " LEFT JOIN Taxon pt ON pt.TaxonId = t.ParentTaxonFk " |
... | ... | |
301 | 302 |
return success; |
302 | 303 |
} |
303 | 304 |
|
304 |
|
|
305 | 305 |
private boolean testSingleTaxon(ResultSet srcRS, ResultSet destRS) throws SQLException { |
306 | 306 |
String id = String.valueOf(srcRS.getInt("id")); |
307 |
//not complete yet |
|
307 | 308 |
boolean success = equals("Taxon ID", "tu_id: " + srcRS.getInt("id"), destRS.getString("IdInSource"), id); |
308 | 309 |
success &= equals("Taxon source", "ERMS export for PESI", destRS.getString("sourceName"), id); |
309 |
//TODO some |
|
310 |
|
|
310 | 311 |
success &= compareKingdom("Taxon kingdom", srcRS, destRS, id); |
311 | 312 |
success &= equals("Taxon rank fk", srcRS.getString("tu_rank"), destRS.getString("RankFk"), id); |
312 | 313 |
success &= equals("Taxon rank cache", normalizeRank(srcRS.getString("rank_name"), srcRS, id), destRS.getString("Rank"), id); |
313 | 314 |
success &= compareNameParts(srcRS, destRS, id); |
314 | 315 |
|
315 | 316 |
success &= equals("Taxon websearchname", srcRS.getString("tu_displayname"), destRS.getString("WebSearchName"), id); |
316 |
//TODO success &= equals("Taxon WebShowName", srcRS.getString("tu_displayname"), destRS.getString("WebShowName"), id);
|
|
317 |
//TODO webShowName success &= equals("Taxon WebShowName", srcRS.getString("tu_displayname"), destRS.getString("WebShowName"), id);
|
|
317 | 318 |
success &= equals("Taxon authority", srcRS.getString("tu_authority"), destRS.getString("AuthorString"), id); |
318 |
success &= equals("Taxon FullName", srcFullName(srcRS), destRS.getString("FullName"), id); |
|
319 |
// success &= equals("Taxon FullName", srcFullName(srcRS), destRS.getString("FullName"), id);
|
|
319 | 320 |
success &= isNull("NomRefString", destRS); |
320 | 321 |
// success &= equals("Taxon DisplayName", srcDisplayName(srcRS), destRS.getString("DisplayName"), id); //according to SQL script same as FullName, no nom.ref. information attached |
321 | 322 |
|
322 |
//TODO success &= equals("Taxon NameStatusFk", toNameStatus(nullSafeInt(srcRS, "tu_status")),nullSafeInt( destRS,"NameStatusFk"), id); |
|
323 |
//TODO success &= equals("Taxon NameStatusCache", srcRS.getString("status_name"), destRS.getString("NameStatusCache"), id); |
|
324 |
|
|
325 |
//TODO success &= equals("Taxon TaxonStatusFk", nullSafeInt(srcRS, "tu_status"),nullSafeInt( destRS,"TaxonStatusFk"), id); |
|
326 |
//TODO success &= equals("Taxon TaxonStatusCache", srcRS.getString("status_name"), destRS.getString("TaxonStatusCache"), id); |
|
323 |
//TODO nameStatusFk success &= equals("Taxon NameStatusFk", toNameStatus(nullSafeInt(srcRS, "tu_status")),nullSafeInt( destRS,"NameStatusFk"), id); |
|
324 |
//TODO nameStatusCache success &= equals("Taxon NameStatusCache", srcRS.getString("status_name"), destRS.getString("NameStatusCache"), id); |
|
327 | 325 |
|
326 |
success &= equals("Taxon TaxonStatusFk", makePesiTaxonStatus(srcRS, "tu_status"),nullSafeInt( destRS,"TaxonStatusFk"), id); |
|
327 |
/*//TODO taxonStatusCache success &= equals("Taxon TaxonStatusCache", srcRS.getString("status_name"), destRS.getString("TaxonStatusCache"), id); |
|
328 |
*/ |
|
328 | 329 |
//TODO ParentTaxonFk |
329 | 330 |
Integer orgigTypeNameFk = nullSafeInt(srcRS, "tu_typetaxon"); |
330 | 331 |
success &= equals("Taxon TypeNameFk", orgigTypeNameFk == null? null : "tu_id: " + orgigTypeNameFk, destRS.getString("typeSourceId"), id); |
331 | 332 |
//TODO success &= equals("Taxon TypeFullNameCache", CdmUtils.concat(" ", srcRS.getString("typename"), srcRS.getString("typeauthor")), destRS.getString("TypeFullNameCache"), id); |
332 | 333 |
success &= equals("Taxon QualityStatusFK", nullSafeInt(srcRS, "tu_qualitystatus"),nullSafeInt( destRS,"QualityStatusFk"), String.valueOf(id)); |
333 | 334 |
success &= equals("Taxon QualityStatusCache", srcRS.getString("qualitystatus_name"), destRS.getString("QualityStatusCache"), id); |
334 |
//TODO TreeIndex
|
|
335 |
success &= checkTreeIndex(destRS, ("TreeIndex"), ("pTreeIndex"), id);
|
|
335 | 336 |
success &= equals("Taxon FossilStatusFk", nullSafeInt(srcRS, "tu_fossil"),nullSafeInt( destRS,"FossilStatusFk"), String.valueOf(id)); |
336 | 337 |
success &= equals("Taxon FossilStatusCache", srcRS.getString("fossil_name"), destRS.getString("FossilStatusCache"), id); |
337 | 338 |
success &= equals("Taxon GUID", srcRS.getString("GUID"), destRS.getString("GUID"), id); |
... | ... | |
346 | 347 |
return success; |
347 | 348 |
} |
348 | 349 |
|
350 |
private Integer makePesiTaxonStatus(ResultSet srcRS, String string) throws SQLException { |
|
351 |
Integer status = nullSafeInt(srcRS, "tu_status"); |
|
352 |
if(status == 1 || status == 2){ //accepted, unaccepted |
|
353 |
return status; |
|
354 |
}else if (status == 3 || status == 6 || status == 7){ //nomen nudum, nomen dubium, temporary name |
|
355 |
return 2; |
|
356 |
} |
|
357 |
return -1; |
|
358 |
} |
|
359 |
|
|
360 |
private boolean checkTreeIndex(ResultSet destRS, String childIndexAttr, String parentIndexAttr, String id) throws SQLException { |
|
361 |
boolean result; |
|
362 |
int taxonStatusFk = destRS.getInt("TaxonStatusFk"); |
|
363 |
String parentTaxonId = destRS.getString("parentTaxonFk"); |
|
364 |
int rankFk = destRS.getInt("RankFk"); |
|
365 |
if (taxonStatusFk == 2 || rankFk <= 10){ //synonyms, Kingdom and higher |
|
366 |
result = isNull(childIndexAttr, destRS); |
|
367 |
}else{ |
|
368 |
String childIndex = destRS.getString(childIndexAttr); |
|
369 |
String parentIndex = destRS.getString(parentIndexAttr); |
|
370 |
parentIndex = parentIndex == null? "#": parentIndex; |
|
371 |
result = equals("Tree index", childIndex, parentIndex + parentTaxonId + "#", id); |
|
372 |
} |
|
373 |
return result; |
|
374 |
} |
|
375 |
|
|
349 | 376 |
boolean namePartsFirst = true; |
350 | 377 |
private boolean compareNameParts(ResultSet srcRS, ResultSet destRS, String id) throws SQLException { |
351 | 378 |
if (namePartsFirst){ |
Also available in: Unified diff
ref #8508 latest changes