Revision 8419d12a
Added by Andreas Müller over 4 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiErmsValidator.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
private static final Logger logger = Logger.getLogger(PesiErmsValidator.class); |
33 | 33 |
|
34 |
private static final Source defaultSource = PesiSources.PESI2019_ERMS_2018();
|
|
34 |
private static final Source defaultSource = PesiSources.PESI2019_ERMS_2019();
|
|
35 | 35 |
// private static final Source defaultDestination = PesiDestinations.pesi_test_local_CDM_ERMS2PESI(); |
36 | 36 |
private static final Source defaultDestination = PesiDestinations.pesi_test_local_CDM_ERMS2PESI_2(); |
37 | 37 |
|
... | ... | |
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!, Implement single compare tests |
|
54 | 54 |
// success &= testCommonNames(); //source(s) discuss VLIZ, exact duplicates (except for sources), Anus(Korur) |
55 | 55 |
// success &= testDistributions(); //>1000 duplicates in "dr", sources (OccurrenceSource table), area spellings(Baelt Sea), 1 long note |
56 |
// success &= testNotes(); //ecology & link notes test (only count tested), sources untested (NoteSource table), few duplicates,
|
|
57 |
success &= testAdditionalTaxonSources(); //ready |
|
56 |
// success &= testNotes(); //ecology & link notes test (only count tested), sources untested (NoteSource table)
|
|
57 |
// success &= testAdditionalTaxonSources(); //ready
|
|
58 | 58 |
} catch (Exception e) { |
59 | 59 |
e.printStackTrace(); |
60 | 60 |
success = false; |
... | ... | |
266 | 266 |
+ " type.tu_displayname typename, type.tu_authority typeauthor, " |
267 | 267 |
+ " fo.fossil_name, qs.qualitystatus_name " |
268 | 268 |
+ " FROM tu t " |
269 |
+ " LEFT JOIN tu as tu1 on t.tu_parent = tu1.id" |
|
270 |
+ " LEFT JOIN (SELECT DISTINCT rank_id, rank_name FROM ranks WHERE NOT(rank_id = 40 AND rank_name = 'Subdivision' OR rank_id = 122 AND rank_name='Subsection')) as r ON t.tu_rank = r.rank_id "
|
|
269 |
+ " LEFT JOIN tu as tu1 on t.tu_parent = tu1.id "
|
|
270 |
+ " LEFT JOIN (SELECT DISTINCT rank_id, rank_name FROM ranks WHERE NOT(rank_id = 30 AND rank_name = 'Phylum (Division)' OR rank_id = 40 AND rank_name = 'Subphylum (Subdivision)' OR rank_id = 122 AND rank_name='Subsection')) as r ON t.tu_rank = r.rank_id "
|
|
271 | 271 |
+ " LEFT JOIN tu acc ON acc.id = t.tu_acctaxon " |
272 | 272 |
+ " LEFT JOIN status st ON st.status_id = t.tu_status " |
273 | 273 |
+ " LEFT JOIN tu type ON type.id = t.tu_typetaxon " |
... | ... | |
295 | 295 |
int i = 0; |
296 | 296 |
while (srcRS.next() && destRS.next()){ |
297 | 297 |
success &= testSingleTaxon(srcRS, destRS); |
298 |
//TODO success &= testLastAction(srcRsLastAction, destRS, String.valueOf(srcRS.getInt("id")), "Taxon");
|
|
298 |
success &= testLastAction(srcRsLastAction, destRS, String.valueOf(srcRS.getInt("id")), "Taxon");
|
|
299 | 299 |
i++; |
300 | 300 |
} |
301 | 301 |
success &= equals("Taxon count for single compare", n, i, String.valueOf(-1)); |
... | ... | |
314 | 314 |
success &= compareNameParts(srcRS, destRS, id); |
315 | 315 |
|
316 | 316 |
success &= equals("Taxon websearchname", srcRS.getString("tu_displayname"), destRS.getString("WebSearchName"), id); |
317 |
// success &= equals("Taxon WebShowName", srcRS.getString("tu_displayname"), destRS.getString("WebShowName"), id); |
|
317 |
//TODO success &= equals("Taxon WebShowName", srcRS.getString("tu_displayname"), destRS.getString("WebShowName"), id);
|
|
318 | 318 |
success &= equals("Taxon authority", srcRS.getString("tu_authority"), destRS.getString("AuthorString"), id); |
319 |
// success &= equals("Taxon FullName", srcFullName(srcRS), destRS.getString("FullName"), id);
|
|
319 |
success &= equals("Taxon FullName", srcFullName(srcRS), destRS.getString("FullName"), id); |
|
320 | 320 |
success &= isNull("NomRefString", destRS); |
321 | 321 |
// success &= equals("Taxon DisplayName", srcDisplayName(srcRS), destRS.getString("DisplayName"), id); //according to SQL script same as FullName, no nom.ref. information attached |
322 | 322 |
|
... | ... | |
402 | 402 |
private String srcFullName(ResultSet srcRs) throws SQLException { |
403 | 403 |
String result = null; |
404 | 404 |
String epi = srcRs.getString("tu_name"); |
405 |
epi = " a" + epi; |
|
406 | 405 |
String display = srcRs.getString("tu_displayname"); |
407 | 406 |
String sp = srcRs.getString("tu_sp"); |
408 |
if (display.indexOf(epi) != display.lastIndexOf(epi) && !sp.startsWith("#2#")){ //homonym, animal |
|
409 |
result = srcRs.getString("tu_displayname").replaceFirst(epi+" ", CdmUtils.concat(" ", " "+epi, srcRs.getString("tu_authority")))+" "; |
|
407 |
if (display.indexOf(epi) != display.lastIndexOf(epi) && !sp.startsWith("#2#")){ //autonym, !animal |
|
408 |
String authority = srcRs.getString("tu_authority"); |
|
409 |
result = srcRs.getString("tu_displayname").replaceFirst(epi+" ", CdmUtils.concat(" ", epi, authority)+" "); |
|
410 | 410 |
}else{ |
411 | 411 |
result = CdmUtils.concat(" ", srcRs.getString("tu_displayname"), srcRs.getString("tu_authority")); |
412 | 412 |
} |
... | ... | |
796 | 796 |
return success; |
797 | 797 |
} |
798 | 798 |
|
799 |
//NOTE: there could be better parsing of source_year during import, this may also need better normalizing in the database |
|
799 | 800 |
private String normalizeYear(String yearStr) { |
800 | 801 |
if (StringUtils.isBlank(yearStr)){ |
801 | 802 |
return yearStr; |
... | ... | |
804 | 805 |
if (yearStr.matches("\\d{4}-\\d{2}")){ |
805 | 806 |
yearStr = yearStr.substring(0, 5)+yearStr.substring(0, 2)+yearStr.substring(5); |
806 | 807 |
} |
808 |
if (yearStr.equals("20 Mar 1891")){ |
|
809 |
yearStr = "20.3.1891"; |
|
810 |
} |
|
811 |
if (yearStr.equals("July 1900")){ |
|
812 |
yearStr = "7.1900"; |
|
813 |
} |
|
807 | 814 |
return yearStr; |
808 | 815 |
} |
809 | 816 |
|
Also available in: Unified diff
ref #8508 latest changes to ERMS validation