Revision 2a2eb365
Added by Andreas Müller about 3 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiErmsValidator.java | ||
---|---|---|
236 | 236 |
return equals("CommonName count ", countSrc, countDest, String.valueOf(-1)); |
237 | 237 |
} |
238 | 238 |
|
239 |
private final String countSynonymRelation = "SELECT count(*) FROM tu syn LEFT JOIN tu acc ON syn.tu_acctaxon = acc.id WHERE (syn.id <> acc.id AND syn.tu_acctaxon IS NOT NULL AND syn.id <> acc.tu_parent) AND syn.id " + moneraFilter;
|
|
240 |
private final String countParentRelation = "SELECT count(*)-1 FROM tu syn LEFT JOIN tu acc ON syn.tu_acctaxon = acc.id WHERE (syn.id = acc.id OR syn.tu_acctaxon IS NULL OR syn.id = acc.tu_parent) AND syn.id " + moneraFilter;
|
|
239 |
private final String countSynonymRelation = "SELECT count(*) FROM tu syn LEFT JOIN tu acc ON syn.tu_accfinal = acc.id WHERE (syn.id <> acc.id AND syn.tu_accfinal IS NOT NULL AND syn.id <> acc.tu_parent) AND syn.id " + moneraFilter;
|
|
240 |
private final String countParentRelation = "SELECT count(*)-1 FROM tu syn LEFT JOIN tu acc ON syn.tu_accfinal = acc.id WHERE (syn.id = acc.id OR syn.tu_accfinal IS NULL OR syn.id = acc.tu_parent) AND syn.id " + moneraFilter;
|
|
241 | 241 |
|
242 | 242 |
private final String countTaxon = "SELECT count(*) FROM tu WHERE id " + moneraFilter; |
243 | 243 |
private boolean testTaxaCount() { |
... | ... | |
268 | 268 |
+ " FROM tu t " |
269 | 269 |
+ " LEFT JOIN tu as tu1 on t.tu_parent = tu1.id " |
270 | 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 |
+ " LEFT JOIN tu acc ON acc.id = t.tu_acctaxon "
|
|
271 |
+ " LEFT JOIN tu acc ON acc.id = t.tu_accfinal "
|
|
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 " |
274 | 274 |
+ " LEFT JOIN fossil fo ON t.tu_fossil = fo.fossil_id " |
... | ... | |
491 | 491 |
ResultSet srcRS = source.getResultSet("" |
492 | 492 |
+ " SELECT t.* " |
493 | 493 |
+ " FROM tu t " |
494 |
+ " WHERE t.id "+ moneraFilter + " AND tu_acctaxon <> id "
|
|
494 |
+ " WHERE t.id "+ moneraFilter + " AND tu_accfinal <> id "
|
|
495 | 495 |
+ " ORDER BY CAST(t.id as nvarchar(20)) "); |
496 | 496 |
ResultSet destRS = destination.getResultSet("SELECT rel.*, t1.IdInSource t1Id, t2.IdInSource t2Id " |
497 | 497 |
+ " FROM RelTaxon rel " |
... | ... | |
511 | 511 |
private boolean testSingleTaxonRelation(ResultSet srcRS, ResultSet destRS) throws SQLException { |
512 | 512 |
String id = String.valueOf(srcRS.getInt("id")); |
513 | 513 |
boolean success = equals("Taxon relation taxon1", "tu_id: " + srcRS.getInt("id"), destRS.getString("t1Id"), id); |
514 |
success &= equals("Taxon relation taxon2", "tu_id: " + srcRS.getInt("tu_acctaxon"), destRS.getString("t2Id"), id);
|
|
514 |
success &= equals("Taxon relation taxon2", "tu_id: " + srcRS.getInt("tu_accfinal"), destRS.getString("t2Id"), id);
|
|
515 | 515 |
success &= equals("Taxon relation qualifier fk", PesiTransformer.IS_SYNONYM_OF, destRS.getInt("RelTaxonQualifierFk"), id); |
516 | 516 |
success &= equals("Taxon relation qualifier cache", "is synonym of", destRS.getString("RelQualifierCache"), id); |
517 | 517 |
//TODO enable after next import |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiEuroMedValidator.java | ||
---|---|---|
195 | 195 |
private boolean testSingleSynonymRelation(ResultSet srcRS, ResultSet destRS) throws SQLException { |
196 | 196 |
String id = String.valueOf(srcRS.getInt("id")); |
197 | 197 |
boolean success = equals("Taxon relation taxon1", "NameId: " + srcRS.getInt("id"), destRS.getString("t1Id"), id); |
198 |
success &= equals("Taxon relation taxon2", "NameId: " + srcRS.getInt("tu_acctaxon"), destRS.getString("t2Id"), id);
|
|
198 |
success &= equals("Taxon relation taxon2", "NameId: " + srcRS.getInt("tu_accfinal"), destRS.getString("t2Id"), id);
|
|
199 | 199 |
success &= equals("Taxon relation qualifier fk", PesiTransformer.IS_SYNONYM_OF, destRS.getInt("RelTaxonQualifierFk"), id); |
200 | 200 |
success &= equals("Taxon relation qualifier cache", "is synonym of", destRS.getString("RelQualifierCache"), id); |
201 | 201 |
//TODO enable after next import |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsDistributionImport.java | ||
---|---|---|
63 | 63 |
@Override |
64 | 64 |
protected String getRecordQuery(ErmsImportConfigurator config) { |
65 | 65 |
String strRecordQuery = |
66 |
" SELECT dr.*, ISNULL(ISNULL(tu.tu_acctaxon, tu.tu_accfinal), tu.id) acctaxon, " +
|
|
66 |
" SELECT dr.*, ISNULL(ISNULL(tu.tu_accfinal, tu.tu_accfinal), tu.id) acctaxon, " +
|
|
67 | 67 |
" s.sessiondate lastActionDate, a.action_name lastAction, s.ExpertName " + |
68 | 68 |
" FROM dr INNER JOIN tu ON dr.tu_id = tu.id " + |
69 | 69 |
" LEFT OUTER JOIN dr_sessions MN ON MN.dr_id = dr.id " + |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonImport.java | ||
---|---|---|
192 | 192 |
String distributionTable = "dr"; |
193 | 193 |
String notesTable = "notes"; |
194 | 194 |
String sql = |
195 |
" SELECT id FROM tu WHERE tu_acctaxon is NULL" //id of taxa not having accepted taxon
|
|
196 |
+ " UNION SELECT DISTINCT tu_acctaxon FROM tu " //fk to accepted taxon (either the accepted taxon or the taxon itself, if accepted)
|
|
197 |
+ " UNION SELECT syn.id FROM tu syn INNER JOIN tu acc ON syn.tu_acctaxon = acc.id WHERE syn.id = acc.tu_parent AND acc.id <> syn.id " //see also ErmsTaxonRelationImport.isAccepted, there are some autonyms being the accepted taxon of there own parents
|
|
195 |
" SELECT id FROM tu WHERE tu_accfinal is NULL" //id of taxa not having accepted taxon
|
|
196 |
+ " UNION SELECT DISTINCT tu_accfinal FROM tu " //fk to accepted taxon (either the accepted taxon or the taxon itself, if accepted)
|
|
197 |
+ " UNION SELECT syn.id FROM tu syn INNER JOIN tu acc ON syn.tu_accfinal = acc.id WHERE syn.id = acc.tu_parent AND acc.id <> syn.id " //see also ErmsTaxonRelationImport.isAccepted, there are some autonyms being the accepted taxon of there own parents
|
|
198 | 198 |
+ " UNION SELECT DISTINCT %s FROM %s " //vernaculars |
199 | 199 |
+ " UNION SELECT DISTINCT %s FROM %s " //distributions |
200 | 200 |
+ " UNION SELECT DISTINCT %s FROM %s "; //notes |
... | ... | |
226 | 226 |
@Override |
227 | 227 |
public TaxonBase<?> createObject(ResultSet rs, ErmsImportState state) throws SQLException { |
228 | 228 |
int statusId = rs.getInt("status_id"); |
229 |
// Object accTaxonId = rs.getObject("tu_acctaxon");
|
|
229 |
// Object accTaxonId = rs.getObject("tu_accfinal");
|
|
230 | 230 |
Integer meId = rs.getInt("id"); |
231 | 231 |
|
232 | 232 |
TaxonName taxonName = getTaxonName(rs, state); |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonRelationImport.java | ||
---|---|---|
64 | 64 |
= DbImportTaxIncludedInMapper.NewInstance("id", TAXON_NAMESPACE, "accId", TAXON_NAMESPACE, "parentAccId", TAXON_NAMESPACE, null); |
65 | 65 |
mapping.addMapper(includedIn);//there is only one tree |
66 | 66 |
//synonym |
67 |
mapping.addMapper(DbImportSynonymMapper.NewInstance("id", "tu_acctaxon", TAXON_NAMESPACE,
|
|
67 |
mapping.addMapper(DbImportSynonymMapper.NewInstance("id", "tu_accfinal", TAXON_NAMESPACE,
|
|
68 | 68 |
"tu_unacceptreason", null, null, true)); |
69 | 69 |
//type designations |
70 | 70 |
mapping.addMapper(DbImportNameTypeDesignationMapper.NewInstance("id", "tu_typetaxon", ErmsImportBase.NAME_NAMESPACE, "tu_typedesignationstatus")); |
... | ... | |
84 | 84 |
//TODO get automatic by second path mappers |
85 | 85 |
String selectAttributes = |
86 | 86 |
" myTaxon.id, myTaxon.tu_parent, myTaxon.tu_typetaxon, myTaxon.tu_typedesignation, " |
87 |
+ " myTaxon.tu_acctaxon, myTaxon.tu_status, myTaxon.tu_unacceptreason, "
|
|
87 |
+ " myTaxon.tu_accfinal, myTaxon.tu_status, myTaxon.tu_unacceptreason, "
|
|
88 | 88 |
+ " parent.tu_status AS parentStatus, parent.id AS parentId, " |
89 | 89 |
+ " parentAcc.id AS parentAccId," |
90 | 90 |
+ " accTaxon.tu_parent accParentId, " |
... | ... | |
92 | 92 |
String strRecordQuery = |
93 | 93 |
" SELECT " + selectAttributes |
94 | 94 |
+ " FROM tu AS myTaxon " |
95 |
+ " LEFT JOIN tu AS accTaxon ON myTaxon.tu_acctaxon = accTaxon.id "
|
|
95 |
+ " LEFT JOIN tu AS accTaxon ON myTaxon.tu_accfinal = accTaxon.id "
|
|
96 | 96 |
+ " LEFT JOIN tu AS parent ON myTaxon.tu_parent = parent.id " |
97 |
+ " LEFT JOIN tu AS parentAcc ON parentAcc.id = parent.tu_acctaxon "
|
|
97 |
+ " LEFT JOIN tu AS parentAcc ON parentAcc.id = parent.tu_accfinal "
|
|
98 | 98 |
+ " WHERE ( myTaxon.id IN (" + ID_LIST_TOKEN + ") )"; |
99 | 99 |
return strRecordQuery; |
100 | 100 |
} |
... | ... | |
116 | 116 |
Set<String> nameIdSet = new HashSet<>(); |
117 | 117 |
while (rs.next()){ |
118 | 118 |
handleForeignKey(rs, taxonIdSet, "accId"); |
119 |
handleForeignKey(rs, taxonIdSet, "tu_acctaxon");
|
|
119 |
handleForeignKey(rs, taxonIdSet, "tu_accfinal");
|
|
120 | 120 |
handleForeignKey(rs, taxonIdSet, "id"); |
121 | 121 |
handleForeignKey(rs, nameIdSet, "tu_typetaxon"); |
122 | 122 |
handleForeignKey(rs, nameIdSet, "id"); |
... | ... | |
152 | 152 |
//here we should add the direct parent or the accepted taxon of the parent |
153 | 153 |
return !isAccepted; |
154 | 154 |
}else if (mapper instanceof DbImportSynonymMapper){ |
155 |
//the only exact rule in ERMS is that the accepted taxon (tu_acctaxon)
|
|
156 |
// of a synonym (def: id <> tu_acctaxon) never again has another
|
|
155 |
//the only exact rule in ERMS is that the accepted taxon (tu_accfinal)
|
|
156 |
// of a synonym (def: id <> tu_accfinal) never again has another
|
|
157 | 157 |
// accepted taxon. |
158 | 158 |
//So the synonym relation is clearly defined, no matter which status |
159 | 159 |
//both related taxa have. |
... | ... | |
170 | 170 |
|
171 | 171 |
private boolean isAccepted(ResultSet rs) throws SQLException { |
172 | 172 |
int id = rs.getInt("id"); |
173 |
Object accTaxonId = rs.getObject("tu_acctaxon");
|
|
173 |
Object accTaxonId = rs.getObject("tu_accfinal");
|
|
174 | 174 |
Object accParentId = rs.getObject("accParentId"); |
175 | 175 |
|
176 | 176 |
boolean isAccepted = false; |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsVernacularImport.java | ||
---|---|---|
62 | 62 |
@Override |
63 | 63 |
protected String getRecordQuery(ErmsImportConfigurator config) { |
64 | 64 |
String strRecordQuery = |
65 |
" SELECT v.*, tu.tu_acctaxon, tu.id, l.*, " +
|
|
65 |
" SELECT v.*, tu.tu_accfinal, tu.id, l.*, " +
|
|
66 | 66 |
" s.sessiondate lastActionDate, a.action_name lastAction, s.ExpertName " + |
67 | 67 |
" FROM vernaculars v INNER JOIN tu ON v.tu_id = tu.id " + |
68 | 68 |
" LEFT OUTER JOIN languages l ON l.LanID = v.lan_id " + |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsSourceUsesImportValidator.java | ||
---|---|---|
40 | 40 |
try { |
41 | 41 |
boolean result = true; |
42 | 42 |
Source source = bmiConfig.getSource(); |
43 |
String strSQL = " SELECT tu_sources.sourceuse_id, sourceuses.sourceuse_name, tu.tu_acctaxon, tu.tu_parent, tu.id, tu.tu_name, " +
|
|
43 |
String strSQL = " SELECT tu_sources.sourceuse_id, sourceuses.sourceuse_name, tu.tu_accfinal, tu.tu_parent, tu.id, tu.tu_name, " +
|
|
44 | 44 |
" tu.tu_authority, tu.tu_displayname, status.status_name " + |
45 | 45 |
" FROM tu_sources " + |
46 | 46 |
" INNER JOIN sourceuses ON tu_sources.sourceuse_id = sourceuses.sourceuse_id " + |
... | ... | |
54 | 54 |
i++; |
55 | 55 |
if (firstRow){ |
56 | 56 |
System.out.println("========================================================"); |
57 |
logger.warn("There are source uses of typ 'source of synonymy' having equal 'id' and 'tu_acctaxon'");
|
|
57 |
logger.warn("There are source uses of typ 'source of synonymy' having equal 'id' and 'tu_accfinal'");
|
|
58 | 58 |
System.out.println("========================================================"); |
59 | 59 |
} |
60 | 60 |
int id = rs.getInt("id"); |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsTaxonImportValidator.java | ||
---|---|---|
48 | 48 |
" parentAcc.tu_status AS Expr1 " + |
49 | 49 |
" FROM status AS parentAccStatus INNER JOIN " + |
50 | 50 |
" tu AS parentAcc ON parentAccStatus.status_id = parentAcc.tu_status RIGHT OUTER JOIN " + |
51 |
" tu AS parent ON parentAcc.id = parent.tu_acctaxon RIGHT OUTER JOIN " +
|
|
51 |
" tu AS parent ON parentAcc.id = parent.tu_accfinal RIGHT OUTER JOIN " +
|
|
52 | 52 |
" tu AS myTaxon ON parent.id = myTaxon.tu_parent LEFT OUTER JOIN " + |
53 | 53 |
" status AS parentStatus ON parent.tu_status = parentStatus.status_id LEFT OUTER JOIN " + |
54 | 54 |
" status AS childStatus ON myTaxon.tu_status = childStatus.status_id " + |
... | ... | |
61 | 61 |
i++; |
62 | 62 |
if (firstRow){ |
63 | 63 |
System.out.println("========================================================"); |
64 |
logger.warn("There are accepted taxa that have an unaccepted parent and also the parents accepted taxon (tu_acctaxon) is not accepted. ");
|
|
64 |
logger.warn("There are accepted taxa that have an unaccepted parent and also the parents accepted taxon (tu_accfinal) is not accepted. ");
|
|
65 | 65 |
System.out.println("========================================================"); |
66 | 66 |
} |
67 | 67 |
int childId = rs.getInt("childId"); |
... | ... | |
100 | 100 |
" SELECT myTaxon.id AS synonymId, myTaxon.tu_displayname AS synonymName, synonymStatus.status_name AS synonymStatus, " + |
101 | 101 |
" accTaxon.id AS acceptedId, accTaxon.tu_displayname AS acceptedName, acceptedStatus.status_name AS acceptedStatus " + |
102 | 102 |
" FROM tu AS myTaxon INNER JOIN " + |
103 |
" tu AS accTaxon ON myTaxon.tu_acctaxon = accTaxon.id INNER JOIN " +
|
|
103 |
" tu AS accTaxon ON myTaxon.tu_accfinal = accTaxon.id INNER JOIN " +
|
|
104 | 104 |
" status AS synonymStatus ON myTaxon.tu_status = synonymStatus.status_id INNER JOIN " + |
105 | 105 |
" status AS acceptedStatus ON accTaxon.tu_status = acceptedStatus.status_id " + |
106 | 106 |
" WHERE (myTaxon.tu_status <> 1) AND (accTaxon.tu_status <> 1) " + |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumGeneraImport.java | ||
---|---|---|
162 | 162 |
try{ |
163 | 163 |
// Set<String> taxonNameSet = new HashSet<>(); |
164 | 164 |
while (rs.next()){ |
165 |
// handleForeignKey(rs, taxonIdSet,"tu_acctaxon" );
|
|
165 |
// handleForeignKey(rs, taxonIdSet,"tu_accfinal" );
|
|
166 | 166 |
} |
167 | 167 |
|
168 | 168 |
//taxon map |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumHigherClassificationImport.java | ||
---|---|---|
273 | 273 |
try{ |
274 | 274 |
Set<String> taxonNameSet = new HashSet<String>(); |
275 | 275 |
// while (rs.next()){ |
276 |
// handleForeignKey(rs, taxonIdSet,"tu_acctaxon" );
|
|
276 |
// handleForeignKey(rs, taxonIdSet,"tu_accfinal" );
|
|
277 | 277 |
// } |
278 | 278 |
|
279 | 279 |
//taxon map |
Also available in: Unified diff
ref #1444 replace tu_acctaxon by tu_accfinal