Revision 9ff7f3d8
Added by Katja Luther over 3 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/merging/FaunaEuErmsFindIdenticalNamesActivator.java | ||
---|---|---|
95 | 95 |
resultOK = resultOK && sc.writeSameNamesdifferentAuthorToCsv(mergingObjects, sFileName + "_authors.csv"); |
96 | 96 |
resultOK = resultOK &&sc.writeSameNamesdifferentStatusToCsv(mergingObjects, sFileName + "_status.csv"); |
97 | 97 |
resultOK = resultOK &&sc.writeSameNamesToCsVFile(mergingObjects, sFileName + "_names.csv"); |
98 |
resultOK = resultOK &&sc.writeSameNamesdifferentPhylumToCsv(mergingObjects, sFileName + "_phylum.csv"); |
|
98 |
//do not create the phylum file, explanation inside the method writeSameNamesdifferentPhylumToCsv |
|
99 |
//resultOK = resultOK &&sc.writeSameNamesdifferentPhylumToCsv(mergingObjects, sFileName + "_phylum.csv"); |
|
99 | 100 |
resultOK = resultOK &&sc.writeSameNamesDifferentParentToCsv(mergingObjects, sFileName + "parent.csv"); |
100 | 101 |
|
101 | 102 |
System.err.println("End merging Fauna Europaea and Erms" + resultOK); |
... | ... | |
125 | 126 |
private boolean writeSameNamesdifferentPhylumToCsv(List<FaunaEuErmsMerging> mergingObjects, String sfileName){ |
126 | 127 |
try |
127 | 128 |
{ |
129 |
//do we really need this?? it is a taxon needed merged like all others? for erms only one taxon has different phylum. (Valencia, but these are not the same taxa -> fish and ribbon worms) |
|
128 | 130 |
FileWriter writer = new FileWriter(sfileName); |
129 | 131 |
|
130 | 132 |
//create Header |
... | ... | |
133 | 135 |
|
134 | 136 |
//write data |
135 | 137 |
for (FaunaEuErmsMerging merging : mergingObjects){ |
136 |
//TODO |
|
138 |
//TODO the phyllum is always different doing it this way, maybe we need to merge the phylum taxa first and then
|
|
137 | 139 |
if ((merging.getPhylumInErms()== null )^ (merging.getPhylumInFaunaEu()== null)){ |
138 | 140 |
writeCsvLine(writer, merging) ; |
139 | 141 |
}else if(!((merging.getPhylumInErms()==null) && (merging.getPhylumInFaunaEu()==null))){ |
140 |
if(!merging.getPhylumInErms().equals(merging.getPhylumInFaunaEu())){
|
|
142 |
if(!merging.getPhylumInErms().getNameTitleCache().equals(merging.getPhylumInFaunaEu().getNameTitleCache())){
|
|
141 | 143 |
writeCsvLine(writer, merging) ; |
142 | 144 |
} |
143 | 145 |
} |
... | ... | |
214 | 216 |
writer.append(';'); |
215 | 217 |
writer.append("id in Fauna Europaea"); |
216 | 218 |
writer.append(';'); |
217 |
writer.append("name"); |
|
219 |
writer.append("name in FE");
|
|
218 | 220 |
writer.append(';'); |
219 |
writer.append("author"); |
|
221 |
writer.append("author in FE");
|
|
220 | 222 |
writer.append(';'); |
221 |
writer.append("rank"); |
|
223 |
writer.append("rank in FE");
|
|
222 | 224 |
writer.append(';'); |
223 |
writer.append("state"); |
|
225 |
writer.append("state in FE");
|
|
224 | 226 |
writer.append(';'); |
225 |
writer.append("phylum"); |
|
227 |
writer.append("phylum in FE");
|
|
226 | 228 |
writer.append(';'); |
227 |
writer.append("parent"); |
|
229 |
writer.append("parent in FE");
|
|
228 | 230 |
writer.append(';'); |
229 |
writer.append("parent rank"); |
|
231 |
writer.append("parent rank in FE");
|
|
230 | 232 |
writer.append(';'); |
231 | 233 |
|
232 | 234 |
writer.append("uuid in Erms"); |
233 | 235 |
writer.append(';'); |
234 | 236 |
writer.append("id in Erms"); |
235 | 237 |
writer.append(';'); |
236 |
writer.append("name"); |
|
238 |
writer.append("name in Erms");
|
|
237 | 239 |
writer.append(';'); |
238 |
writer.append("author"); |
|
240 |
writer.append("author in Erms");
|
|
239 | 241 |
writer.append(';'); |
240 |
writer.append("rank"); |
|
242 |
writer.append("rank in Erms");
|
|
241 | 243 |
writer.append(';'); |
242 |
writer.append("state"); |
|
244 |
writer.append("state in Erms");
|
|
243 | 245 |
writer.append(';'); |
244 |
writer.append("phylum"); |
|
246 |
writer.append("phylum in Erms");
|
|
245 | 247 |
writer.append(';'); |
246 |
writer.append("parent"); |
|
248 |
writer.append("parent in Erms");
|
|
247 | 249 |
writer.append(';'); |
248 |
writer.append("parent rank"); |
|
250 |
writer.append("parent rank in Erms");
|
|
249 | 251 |
writer.append('\n'); |
250 | 252 |
} |
251 | 253 |
|
... | ... | |
348 | 350 |
} |
349 | 351 |
|
350 | 352 |
writer.append(';'); |
351 |
writer.append(merging.getPhylumInErms() != null? merging.getPhylumInErms().getTaxonTitleCache():"");
|
|
353 |
writer.append(merging.getPhylumInErms() != null? merging.getPhylumInErms().getTitleCache():""); |
|
352 | 354 |
writer.append(';'); |
353 | 355 |
writer.append(merging.getParentStringInErms()); |
354 | 356 |
writer.append(';'); |
... | ... | |
537 | 539 |
mergeObject.setRankInErms(ermsName.getRank().getLabel()); |
538 | 540 |
mergeObject.setRankInFaunaEu(faunaEuName.getRank().getLabel()); |
539 | 541 |
|
540 |
//set parent informations |
|
541 |
|
|
542 |
|
|
543 |
/* |
|
544 |
Set<HybridRelationship> parentRelations = zooName.getParentRelationships(); |
|
545 |
Iterator parentIterator = parentRelations.iterator(); |
|
546 |
HybridRelationship parentRel; |
|
547 |
ZoologicalName parentName; |
|
548 |
while (parentIterator.hasNext()){ |
|
549 |
parentRel = (HybridRelationship)parentIterator.next(); |
|
550 |
parentName = (ZoologicalName)parentRel.getParentName(); |
|
551 |
mergeObject.setParentRankStringInErms(parentName.getRank().getLabel()); |
|
552 |
mergeObject.setParentStringInErms(parentName.getNameCache()); |
|
553 |
} |
|
554 |
|
|
555 |
parentRelations = zooName2.getParentRelationships(); |
|
556 |
parentIterator = parentRelations.iterator(); |
|
557 |
|
|
558 |
while (parentIterator.hasNext()){ |
|
559 |
parentRel = (HybridRelationship)parentIterator.next(); |
|
560 |
parentName = (ZoologicalName)parentRel.getParentName(); |
|
561 |
mergeObject.setParentRankStringInFaunaEu(parentName.getRank().getLabel()); |
|
562 |
mergeObject.setParentStringInFaunaEu(parentName.getNameCache()); |
|
563 |
}*/ |
|
542 |
|
|
564 | 543 |
merge.add(mergeObject); |
565 | 544 |
} |
566 |
// } |
|
545 |
|
|
567 | 546 |
|
568 | 547 |
return merge; |
569 | 548 |
|
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/merging/FaunaEuErmsMergeActivator.java | ||
---|---|---|
19 | 19 |
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException; |
20 | 20 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
21 | 21 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
22 |
|
|
23 | 22 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
24 | 23 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
25 | 24 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
... | ... | |
36 | 35 |
import eu.etaxonomy.cdm.model.name.NameRelationship; |
37 | 36 |
import eu.etaxonomy.cdm.model.name.Rank; |
38 | 37 |
import eu.etaxonomy.cdm.model.reference.Reference; |
38 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
39 | 39 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
40 | 40 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
41 | 41 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
... | ... | |
50 | 50 |
static final int ermsUuid = 9; |
51 | 51 |
static final int rankFaunaEu = 4; |
52 | 52 |
static final int rankErms = 13; |
53 |
Classification faunaEuClassification; |
|
54 |
Classification ermsClassification; |
|
53 | 55 |
|
54 | 56 |
CdmApplicationController appCtrInit; |
55 | 57 |
|
... | ... | |
71 | 73 |
FaunaEuErmsMergeActivator sc = new FaunaEuErmsMergeActivator(); |
72 | 74 |
|
73 | 75 |
sc.initDb(faunaEuropaeaSource); |
74 |
//we also need to merge names completely identical! |
|
76 |
//we also need to merge names completely identical!
|
|
75 | 77 |
sc.mergeAuthors(); |
76 | 78 |
|
77 | 79 |
//set the ranks of Agnatha and Gnathostomata to 50 instead of 45 |
... | ... | |
203 | 205 |
|
204 | 206 |
TaxonBase<?> taxonFaunaEu; |
205 | 207 |
TaxonBase<?> taxonErms; |
206 |
|
|
208 |
List<String> propertyPaths = new ArrayList<>(); |
|
209 |
propertyPaths.add("taxonBases.nodes.*"); |
|
207 | 210 |
for (List<String> row: sameStatus){ |
208 |
taxonFaunaEu = appCtrInit.getTaxonService().find(UUID.fromString(row.get(faunaEuUuid)));
|
|
209 |
taxonErms = appCtrInit.getTaxonService().find(UUID.fromString(row.get(ermsUuid)));
|
|
211 |
taxonFaunaEu = appCtrInit.getTaxonService().load(UUID.fromString(row.get(faunaEuUuid)), propertyPaths);
|
|
212 |
taxonErms = appCtrInit.getTaxonService().load(UUID.fromString(row.get(ermsUuid)), propertyPaths);
|
|
210 | 213 |
moveAllInformationsFromFaunaEuToErms(taxonFaunaEu, taxonErms); |
211 | 214 |
if (taxonErms instanceof Taxon){ |
212 | 215 |
moveFaunaEuSynonymsToErmsTaxon((Taxon)taxonFaunaEu, (Taxon)taxonErms); |
... | ... | |
450 | 453 |
for (Credit credit: credits){ |
451 | 454 |
erms.addCredit(credit); |
452 | 455 |
} |
456 |
//move children to erms taxon |
|
457 |
if (faunaEu instanceof Taxon && ((Taxon)faunaEu).getTaxonNode(faunaEuClassification).hasChildNodes()) { |
|
458 |
Taxon acceptedErmsTaxon; |
|
459 |
if (erms instanceof Synonym) { |
|
460 |
acceptedErmsTaxon = ((Synonym)erms).getAcceptedTaxon(); |
|
461 |
}else { |
|
462 |
acceptedErmsTaxon = (Taxon)erms; |
|
463 |
} |
|
464 |
TaxonNode node = ((Taxon)acceptedErmsTaxon).getTaxonNode(ermsClassification); |
|
465 |
for (TaxonNode child:((Taxon)faunaEu).getTaxonNode(faunaEuClassification).getChildNodes()) { |
|
466 |
//add pesi reference as reference?? |
|
467 |
node.addChildNode(child, null, null); |
|
468 |
} |
|
469 |
} |
|
453 | 470 |
} |
454 | 471 |
|
455 | 472 |
//if name, rank, and status (accepted) are the same, then move the synonyms of faunaEu taxon to the erms taxon |
... | ... | |
474 | 491 |
//merged taxon should have a new sec reference |
475 | 492 |
private void addNewSecForMergedTaxon(Taxon taxon, Reference sec){ |
476 | 493 |
taxon.setSec(sec); |
477 |
taxon.setUuid(UUID.randomUUID()); |
|
494 |
//this does not work!! |
|
495 |
//taxon.setUuid(UUID.randomUUID()); |
|
478 | 496 |
} |
479 | 497 |
|
480 | 498 |
// ----------- methods for merging Erms synonyms and Fauna Europaea Taxon |
Also available in: Unified diff
merging fauna Eu - Erms -continue