Revision d7919b1c
Added by Andreas Müller about 7 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java | ||
---|---|---|
96 | 96 |
import eu.etaxonomy.cdm.model.media.MediaRepresentation; |
97 | 97 |
import eu.etaxonomy.cdm.model.media.MediaUtils; |
98 | 98 |
import eu.etaxonomy.cdm.model.name.HomotypicalGroup; |
99 |
import eu.etaxonomy.cdm.model.name.IZoologicalName; |
|
99 | 100 |
import eu.etaxonomy.cdm.model.name.Rank; |
100 | 101 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
101 | 102 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
... | ... | |
2140 | 2141 |
List <Synonym> inferredSynonyms = new ArrayList<>(); |
2141 | 2142 |
List<Synonym> inferredSynonymsToBeRemoved = new ArrayList<>(); |
2142 | 2143 |
|
2143 |
HashMap <UUID, ZoologicalName> zooHashMap = new HashMap<>(); |
|
2144 |
HashMap <UUID, IZoologicalName> zooHashMap = new HashMap<>();
|
|
2144 | 2145 |
|
2145 | 2146 |
|
2146 | 2147 |
UUID nameUuid= taxon.getName().getUuid(); |
2147 |
ZoologicalName taxonName = getZoologicalName(nameUuid, zooHashMap); |
|
2148 |
IZoologicalName taxonName = getZoologicalName(nameUuid, zooHashMap);
|
|
2148 | 2149 |
String epithetOfTaxon = null; |
2149 | 2150 |
String infragenericEpithetOfTaxon = null; |
2150 | 2151 |
String infraspecificEpithetOfTaxon = null; |
... | ... | |
2166 | 2167 |
if (node.getClassification().equals(classification)){ |
2167 | 2168 |
if (!node.isTopmostNode()){ |
2168 | 2169 |
TaxonNode parent = node.getParent(); |
2169 |
parent = HibernateProxyHelper.deproxy(parent);
|
|
2170 |
parent = CdmBase.deproxy(parent);
|
|
2170 | 2171 |
TaxonNameBase<?,?> parentName = parent.getTaxon().getName(); |
2171 |
ZoologicalName zooParentName = HibernateProxyHelper.deproxy(parentName, ZoologicalName.class);
|
|
2172 |
Taxon parentTaxon = HibernateProxyHelper.deproxy(parent.getTaxon());
|
|
2172 |
IZoologicalName zooParentName = CdmBase.deproxy(parentName);
|
|
2173 |
Taxon parentTaxon = CdmBase.deproxy(parent.getTaxon());
|
|
2173 | 2174 |
Rank rankOfTaxon = taxonName.getRank(); |
2174 | 2175 |
|
2175 | 2176 |
|
... | ... | |
2210 | 2211 |
synonymRelationOfParent); |
2211 | 2212 |
|
2212 | 2213 |
inferredSynonyms.add(inferredEpithet); |
2213 |
zooHashMap.put(inferredEpithet.getName().getUuid(), (ZoologicalName)inferredEpithet.getName());
|
|
2214 |
zooHashMap.put(inferredEpithet.getName().getUuid(), inferredEpithet.getName()); |
|
2214 | 2215 |
taxonNames.add(((ZoologicalName)inferredEpithet.getName()).getNameCache()); |
2215 | 2216 |
} |
2216 | 2217 |
|
... | ... | |
2227 | 2228 |
misappliedName); |
2228 | 2229 |
|
2229 | 2230 |
inferredSynonyms.add(inferredEpithet); |
2230 |
zooHashMap.put(inferredEpithet.getName().getUuid(), (ZoologicalName)inferredEpithet.getName());
|
|
2231 |
zooHashMap.put(inferredEpithet.getName().getUuid(), inferredEpithet.getName()); |
|
2231 | 2232 |
taxonNames.add(((ZoologicalName)inferredEpithet.getName()).getNameCache()); |
2232 | 2233 |
} |
2233 | 2234 |
} |
2234 | 2235 |
|
2235 | 2236 |
if (!taxonNames.isEmpty()){ |
2236 | 2237 |
List<String> synNotInCDM = dao.taxaByNameNotInDB(taxonNames); |
2237 |
ZoologicalName name; |
|
2238 |
IZoologicalName name;
|
|
2238 | 2239 |
if (!synNotInCDM.isEmpty()){ |
2239 | 2240 |
inferredSynonymsToBeRemoved.clear(); |
2240 | 2241 |
|
... | ... | |
2256 | 2257 |
|
2257 | 2258 |
for (Synonym synonymRelationOfTaxon:synonymsOfTaxon){ |
2258 | 2259 |
TaxonNameBase synName; |
2259 |
ZoologicalName inferredSynName; |
|
2260 |
IZoologicalName inferredSynName;
|
|
2260 | 2261 |
|
2261 | 2262 |
inferredGenus = createInferredGenus(taxon, |
2262 | 2263 |
zooHashMap, taxonName, epithetOfTaxon, |
2263 | 2264 |
genusOfTaxon, taxonNames, zooParentName, synonymRelationOfTaxon); |
2264 | 2265 |
|
2265 | 2266 |
inferredSynonyms.add(inferredGenus); |
2266 |
zooHashMap.put(inferredGenus.getName().getUuid(), (ZoologicalName)inferredGenus.getName());
|
|
2267 |
zooHashMap.put(inferredGenus.getName().getUuid(), inferredGenus.getName()); |
|
2267 | 2268 |
taxonNames.add(( (ZoologicalName)inferredGenus.getName()).getNameCache()); |
2268 | 2269 |
|
2269 | 2270 |
|
... | ... | |
2276 | 2277 |
inferredGenus = createInferredGenus(taxon, zooHashMap, taxonName, infraspecificEpithetOfTaxon, genusOfTaxon, taxonNames, zooParentName, misappliedName); |
2277 | 2278 |
|
2278 | 2279 |
inferredSynonyms.add(inferredGenus); |
2279 |
zooHashMap.put(inferredGenus.getName().getUuid(), (ZoologicalName)inferredGenus.getName());
|
|
2280 |
zooHashMap.put(inferredGenus.getName().getUuid(), inferredGenus.getName()); |
|
2280 | 2281 |
taxonNames.add(( (ZoologicalName)inferredGenus.getName()).getNameCache()); |
2281 | 2282 |
} |
2282 | 2283 |
} |
... | ... | |
2284 | 2285 |
|
2285 | 2286 |
if (!taxonNames.isEmpty()){ |
2286 | 2287 |
List<String> synNotInCDM = dao.taxaByNameNotInDB(taxonNames); |
2287 |
ZoologicalName name; |
|
2288 |
IZoologicalName name;
|
|
2288 | 2289 |
if (!synNotInCDM.isEmpty()){ |
2289 | 2290 |
inferredSynonymsToBeRemoved.clear(); |
2290 | 2291 |
|
... | ... | |
2305 | 2306 |
}else if (type.equals(SynonymType.POTENTIAL_COMBINATION_OF())){ |
2306 | 2307 |
|
2307 | 2308 |
Reference sourceReference = null; // TODO: Determination of sourceReference is redundant |
2308 |
ZoologicalName inferredSynName; |
|
2309 |
IZoologicalName inferredSynName;
|
|
2309 | 2310 |
//for all synonyms of the parent... |
2310 | 2311 |
for (Synonym synonymRelationOfParent:synonyMsOfParent){ |
2311 | 2312 |
TaxonNameBase synName; |
... | ... | |
2319 | 2320 |
// Determine the idInSource |
2320 | 2321 |
String idInSourceParent = getIdInSource(synonymRelationOfParent); |
2321 | 2322 |
|
2322 |
ZoologicalName parentSynZooName = getZoologicalName(synName.getUuid(), zooHashMap); |
|
2323 |
IZoologicalName parentSynZooName = getZoologicalName(synName.getUuid(), zooHashMap);
|
|
2323 | 2324 |
String synParentGenus = parentSynZooName.getGenusOrUninomial(); |
2324 | 2325 |
String synParentInfragenericName = null; |
2325 | 2326 |
String synParentSpecificEpithet = null; |
... | ... | |
2339 | 2340 |
|
2340 | 2341 |
for (Synonym synonymRelationOfTaxon:synonymsOfTaxon){ |
2341 | 2342 |
|
2342 |
ZoologicalName zooSynName = getZoologicalName(synonymRelationOfTaxon.getName().getUuid(), zooHashMap); |
|
2343 |
IZoologicalName zooSynName = getZoologicalName(synonymRelationOfTaxon.getName().getUuid(), zooHashMap);
|
|
2343 | 2344 |
potentialCombination = createPotentialCombination(idInSourceParent, parentSynZooName, zooSynName, |
2344 | 2345 |
synParentGenus, |
2345 | 2346 |
synParentInfragenericName, |
... | ... | |
2347 | 2348 |
|
2348 | 2349 |
taxon.addSynonym(potentialCombination, SynonymType.POTENTIAL_COMBINATION_OF()); |
2349 | 2350 |
inferredSynonyms.add(potentialCombination); |
2350 |
zooHashMap.put(potentialCombination.getName().getUuid(), (ZoologicalName)potentialCombination.getName());
|
|
2351 |
zooHashMap.put(potentialCombination.getName().getUuid(), potentialCombination.getName()); |
|
2351 | 2352 |
taxonNames.add(( (ZoologicalName)potentialCombination.getName()).getNameCache()); |
2352 | 2353 |
|
2353 | 2354 |
} |
... | ... | |
2372 | 2373 |
// Determine the idInSource |
2373 | 2374 |
String idInSourceParent = getIdInSource(misappliedParent); |
2374 | 2375 |
|
2375 |
ZoologicalName parentSynZooName = getZoologicalName(misappliedParentName.getUuid(), zooHashMap); |
|
2376 |
IZoologicalName parentSynZooName = getZoologicalName(misappliedParentName.getUuid(), zooHashMap);
|
|
2376 | 2377 |
String synParentGenus = parentSynZooName.getGenusOrUninomial(); |
2377 | 2378 |
String synParentInfragenericName = null; |
2378 | 2379 |
String synParentSpecificEpithet = null; |
... | ... | |
2387 | 2388 |
|
2388 | 2389 |
for (TaxonRelationship taxonRelationship: taxonRelListTaxon){ |
2389 | 2390 |
Taxon misappliedName = taxonRelationship.getFromTaxon(); |
2390 |
ZoologicalName zooMisappliedName = getZoologicalName(misappliedName.getName().getUuid(), zooHashMap); |
|
2391 |
IZoologicalName zooMisappliedName = getZoologicalName(misappliedName.getName().getUuid(), zooHashMap);
|
|
2391 | 2392 |
potentialCombination = createPotentialCombination( |
2392 | 2393 |
idInSourceParent, parentSynZooName, zooMisappliedName, |
2393 | 2394 |
synParentGenus, |
... | ... | |
2397 | 2398 |
|
2398 | 2399 |
taxon.addSynonym(potentialCombination, SynonymType.POTENTIAL_COMBINATION_OF()); |
2399 | 2400 |
inferredSynonyms.add(potentialCombination); |
2400 |
zooHashMap.put(potentialCombination.getName().getUuid(), (ZoologicalName)potentialCombination.getName());
|
|
2401 |
zooHashMap.put(potentialCombination.getName().getUuid(), potentialCombination.getName()); |
|
2401 | 2402 |
taxonNames.add(( (ZoologicalName)potentialCombination.getName()).getNameCache()); |
2402 | 2403 |
} |
2403 | 2404 |
} |
... | ... | |
2405 | 2406 |
|
2406 | 2407 |
if (!taxonNames.isEmpty()){ |
2407 | 2408 |
List<String> synNotInCDM = dao.taxaByNameNotInDB(taxonNames); |
2408 |
ZoologicalName name; |
|
2409 |
IZoologicalName name;
|
|
2409 | 2410 |
if (!synNotInCDM.isEmpty()){ |
2410 | 2411 |
inferredSynonymsToBeRemoved.clear(); |
2411 | 2412 |
for (Synonym syn :inferredSynonyms){ |
2412 | 2413 |
try{ |
2413 |
name = (ZoologicalName) syn.getName();
|
|
2414 |
name = syn.getName(); |
|
2414 | 2415 |
}catch (ClassCastException e){ |
2415 | 2416 |
name = getZoologicalName(syn.getName().getUuid(), zooHashMap); |
2416 | 2417 |
} |
... | ... | |
2438 | 2439 |
} |
2439 | 2440 |
|
2440 | 2441 |
private Synonym createPotentialCombination(String idInSourceParent, |
2441 |
ZoologicalName parentSynZooName, ZoologicalName zooSynName, String synParentGenus,
|
|
2442 |
IZoologicalName parentSynZooName, IZoologicalName zooSynName, String synParentGenus,
|
|
2442 | 2443 |
String synParentInfragenericName, String synParentSpecificEpithet, |
2443 |
TaxonBase syn, HashMap<UUID, ZoologicalName> zooHashMap) { |
|
2444 |
TaxonBase syn, HashMap<UUID, IZoologicalName> zooHashMap) {
|
|
2444 | 2445 |
Synonym potentialCombination; |
2445 | 2446 |
Reference sourceReference; |
2446 |
ZoologicalName inferredSynName; |
|
2447 |
IZoologicalName inferredSynName;
|
|
2447 | 2448 |
HibernateProxyHelper.deproxy(syn); |
2448 | 2449 |
|
2449 | 2450 |
// Set sourceReference |
... | ... | |
2508 | 2509 |
} |
2509 | 2510 |
|
2510 | 2511 |
private Synonym createInferredGenus(Taxon taxon, |
2511 |
HashMap<UUID, ZoologicalName> zooHashMap, ZoologicalName taxonName,
|
|
2512 |
HashMap<UUID, IZoologicalName> zooHashMap, IZoologicalName taxonName,
|
|
2512 | 2513 |
String epithetOfTaxon, String genusOfTaxon, |
2513 |
List<String> taxonNames, ZoologicalName zooParentName, |
|
2514 |
List<String> taxonNames, IZoologicalName zooParentName,
|
|
2514 | 2515 |
TaxonBase syn) { |
2515 | 2516 |
|
2516 | 2517 |
Synonym inferredGenus; |
2517 | 2518 |
TaxonNameBase synName; |
2518 |
ZoologicalName inferredSynName; |
|
2519 |
IZoologicalName inferredSynName;
|
|
2519 | 2520 |
synName =syn.getName(); |
2520 | 2521 |
HibernateProxyHelper.deproxy(syn); |
2521 | 2522 |
|
... | ... | |
2528 | 2529 |
//logger.warn(sourceReference.getTitleCache()); |
2529 | 2530 |
|
2530 | 2531 |
synName = syn.getName(); |
2531 |
ZoologicalName synZooName = getZoologicalName(synName.getUuid(), zooHashMap); |
|
2532 |
IZoologicalName synZooName = getZoologicalName(synName.getUuid(), zooHashMap);
|
|
2532 | 2533 |
String synSpeciesEpithetName = synZooName.getSpecificEpithet(); |
2533 | 2534 |
/* if (synonymsEpithet != null && !synonymsEpithet.contains(synSpeciesEpithetName)){ |
2534 | 2535 |
synonymsEpithet.add(synSpeciesEpithetName); |
... | ... | |
2586 | 2587 |
} |
2587 | 2588 |
|
2588 | 2589 |
private Synonym createInferredEpithets(Taxon taxon, |
2589 |
HashMap<UUID, ZoologicalName> zooHashMap, ZoologicalName taxonName,
|
|
2590 |
HashMap<UUID, IZoologicalName> zooHashMap, IZoologicalName taxonName,
|
|
2590 | 2591 |
String epithetOfTaxon, String infragenericEpithetOfTaxon, |
2591 | 2592 |
String infraspecificEpithetOfTaxon, List<String> taxonNames, |
2592 | 2593 |
TaxonNameBase parentName, TaxonBase syn) { |
2593 | 2594 |
|
2594 | 2595 |
Synonym inferredEpithet; |
2595 | 2596 |
TaxonNameBase<?,?> synName; |
2596 |
ZoologicalName inferredSynName; |
|
2597 |
IZoologicalName inferredSynName;
|
|
2597 | 2598 |
HibernateProxyHelper.deproxy(syn); |
2598 | 2599 |
|
2599 | 2600 |
// Determine the idInSource |
... | ... | |
2608 | 2609 |
} |
2609 | 2610 |
|
2610 | 2611 |
synName = syn.getName(); |
2611 |
ZoologicalName zooSynName = getZoologicalName(synName.getUuid(), zooHashMap); |
|
2612 |
IZoologicalName zooSynName = getZoologicalName(synName.getUuid(), zooHashMap);
|
|
2612 | 2613 |
String synGenusName = zooSynName.getGenusOrUninomial(); |
2613 | 2614 |
String synInfraGenericEpithet = null; |
2614 | 2615 |
String synSpecificEpithet = null; |
... | ... | |
2680 | 2681 |
} |
2681 | 2682 |
|
2682 | 2683 |
/** |
2683 |
* Returns an existing ZoologicalName or extends an internal hashmap if it does not exist. |
|
2684 |
* Returns an existing IZoologicalName or extends an internal hashmap if it does not exist.
|
|
2684 | 2685 |
* Very likely only useful for createInferredSynonyms(). |
2685 | 2686 |
* @param uuid |
2686 | 2687 |
* @param zooHashMap |
2687 | 2688 |
* @return |
2688 | 2689 |
*/ |
2689 |
private ZoologicalName getZoologicalName(UUID uuid, HashMap <UUID, ZoologicalName> zooHashMap) {
|
|
2690 |
ZoologicalName taxonName =nameDao.findZoologicalNameByUUID(uuid); |
|
2690 |
private IZoologicalName getZoologicalName(UUID uuid, HashMap <UUID, IZoologicalName> zooHashMap) {
|
|
2691 |
IZoologicalName taxonName =nameDao.findZoologicalNameByUUID(uuid);
|
|
2691 | 2692 |
if (taxonName == null) { |
2692 | 2693 |
taxonName = zooHashMap.get(uuid); |
2693 | 2694 |
} |
Also available in: Unified diff
ref #6362, ref #6365 remove occurrence of NonViralName, BotanicalName, ZoologicalName and others