49 |
49 |
import eu.etaxonomy.cdm.model.common.LanguageString;
|
50 |
50 |
import eu.etaxonomy.cdm.model.common.LanguageStringBase;
|
51 |
51 |
import eu.etaxonomy.cdm.model.common.Marker;
|
|
52 |
import eu.etaxonomy.cdm.model.common.MarkerType;
|
52 |
53 |
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
|
53 |
54 |
import eu.etaxonomy.cdm.model.common.RelationshipBase;
|
54 |
55 |
import eu.etaxonomy.cdm.model.common.SourcedEntityBase;
|
... | ... | |
75 |
76 |
import eu.etaxonomy.cdm.model.name.HybridRelationship;
|
76 |
77 |
import eu.etaxonomy.cdm.model.name.NameRelationship;
|
77 |
78 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
|
|
79 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
78 |
80 |
import eu.etaxonomy.cdm.model.name.Registration;
|
79 |
81 |
import eu.etaxonomy.cdm.model.name.TaxonName;
|
80 |
82 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
... | ... | |
112 |
114 |
private static final long serialVersionUID = 8917991155285743172L;
|
113 |
115 |
private static final Logger logger = Logger.getLogger(FauEu2CdmImportBase.class);
|
114 |
116 |
|
|
117 |
//quick and dirty
|
|
118 |
private FauEu2CdmImportState state;
|
115 |
119 |
|
116 |
120 |
//TODO move to state
|
117 |
121 |
private Map<UUID, CdmBase> sessionCache = new HashMap<>();
|
118 |
|
private Map<UUID, CdmBase> permanentCache = new HashMap<>();
|
119 |
|
private Set<UUID> movedObjects = new HashSet<>();
|
|
122 |
|
120 |
123 |
|
121 |
124 |
protected Set<CdmBase> toSave = new HashSet<>();
|
122 |
125 |
|
... | ... | |
153 |
156 |
return detache(cdmBase, false);
|
154 |
157 |
}
|
155 |
158 |
|
156 |
|
|
|
159 |
private Map<Class,Set<UUID>> existingObjects = new HashMap<>();
|
157 |
160 |
protected <T extends CdmBase> T detache(T cdmBase, boolean notFromSource) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
158 |
161 |
cdmBase = CdmBase.deproxy(cdmBase);
|
159 |
162 |
if (cdmBase == null ){
|
... | ... | |
161 |
164 |
}else if(isInCache(cdmBase)){
|
162 |
165 |
return getCached(cdmBase);
|
163 |
166 |
}else {
|
164 |
|
//TODO better load all existing UUIDs just in case any of the objects is already in the DB
|
165 |
|
if (cdmBase instanceof TermBase || movedObjects.contains(cdmBase.getUuid())){
|
|
167 |
if (existingObjects.get(cdmBase.getClass()) == null){
|
|
168 |
loadExistingUuids(cdmBase.getClass());
|
|
169 |
}
|
|
170 |
boolean exists = existingObjects.get(cdmBase.getClass()).contains(cdmBase.getUuid());
|
|
171 |
if (exists){
|
166 |
172 |
Class<T> clazz = (Class<T>)cdmBase.getClass();
|
167 |
|
T exists = getCommonService().find(clazz, cdmBase.getUuid());
|
168 |
|
if (exists != null){
|
169 |
|
return exists;
|
170 |
|
}else if (movedObjects.contains(cdmBase.getUuid())){
|
171 |
|
logger.warn("Object should be moved already but does not exist in target. This should not happen: " + cdmBase.getUuid());
|
|
173 |
T existingObj = getCommonService().find(clazz, cdmBase.getUuid());
|
|
174 |
if (existingObj != null){
|
|
175 |
cache(existingObj);
|
|
176 |
return existingObj;
|
|
177 |
}else{
|
|
178 |
logger.warn("Object should exist already but does not exist in target. This should not happen: " + cdmBase.getClass().getSimpleName() + "/" + cdmBase.getUuid());
|
172 |
179 |
}
|
173 |
180 |
}
|
174 |
181 |
}
|
... | ... | |
180 |
187 |
}
|
181 |
188 |
}
|
182 |
189 |
|
|
190 |
/**
|
|
191 |
* @param class1
|
|
192 |
* @return
|
|
193 |
*/
|
|
194 |
private Set<UUID> loadExistingUuids(Class<? extends CdmBase> clazz) {
|
|
195 |
List<UUID> list = getCommonService().listUuid(clazz);
|
|
196 |
Set<UUID> result = new HashSet<>(list);
|
|
197 |
existingObjects.put(clazz, result);
|
|
198 |
return result;
|
|
199 |
}
|
|
200 |
|
183 |
201 |
protected <A extends CdmBase> CdmBase handlePersisted(A cdmBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
184 |
202 |
if(cdmBase instanceof TaxonNode){
|
185 |
203 |
return handlePersistedTaxonNode((TaxonNode)cdmBase);
|
... | ... | |
253 |
271 |
return handlePersistedIntextReference((IntextReference)cdmBase);
|
254 |
272 |
}else if(cdmBase instanceof ExtensionType){
|
255 |
273 |
return handlePersistedExtensionType((ExtensionType)cdmBase);
|
|
274 |
}else if(cdmBase instanceof NomenclaturalStatusType){
|
|
275 |
return handlePersistedNomenclaturalStatusType((NomenclaturalStatusType)cdmBase);
|
|
276 |
}else if(cdmBase instanceof MarkerType){
|
|
277 |
return handlePersistedMarkerType((MarkerType)cdmBase);
|
256 |
278 |
}else if(cdmBase instanceof DefinedTerm){
|
257 |
279 |
return handlePersistedDefinedTerm((DefinedTerm)cdmBase);
|
258 |
280 |
}else if(cdmBase instanceof DefinedTermBase){
|
... | ... | |
269 |
291 |
if (result ==null){
|
270 |
292 |
return result;
|
271 |
293 |
}
|
|
294 |
//complete
|
272 |
295 |
handleCollection(result, TaxonNode.class, "agentRelations", TaxonNodeAgentRelation.class);
|
273 |
296 |
result.setTaxon(detache(result.getTaxon()));
|
274 |
297 |
result.setReference(detache(node.getReference()));
|
|
298 |
result.setSynonymToBeUsed(detache(result.getSynonymToBeUsed()));
|
275 |
299 |
handleMap(result, TaxonNode.class, "excludedNote", Language.class, LanguageString.class);
|
276 |
300 |
//classification, parent, children
|
277 |
301 |
this.setInvisible(node, "classification", detache(node.getClassification()));
|
... | ... | |
296 |
320 |
|
297 |
321 |
protected Taxon handlePersistedTaxon(Taxon taxon) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
298 |
322 |
Taxon result = handlePersisted((TaxonBase)taxon);
|
|
323 |
//complete
|
299 |
324 |
handleCollection(result, Taxon.class, "synonyms", Synonym.class);
|
300 |
325 |
// handleCollection(result, Taxon.class, "taxonNodes", TaxonNode.class);
|
301 |
326 |
setNewCollection(result, Taxon.class, "taxonNodes", TaxonNode.class);
|
302 |
327 |
handleCollection(result, Taxon.class, "relationsFromThisTaxon", TaxonRelationship.class);
|
303 |
328 |
handleCollection(result, Taxon.class, "relationsToThisTaxon", TaxonRelationship.class);
|
304 |
|
handleCollection(result, Taxon.class, "descriptions", TaxonDescription.class);
|
|
329 |
if (this.doDescriptions(state)){
|
|
330 |
handleCollection(result, Taxon.class, "descriptions", TaxonDescription.class);
|
|
331 |
}else{
|
|
332 |
setNewCollection(result, Taxon.class, "descriptions", TaxonDescription.class);
|
|
333 |
}
|
305 |
334 |
return result;
|
306 |
335 |
}
|
307 |
336 |
|
|
337 |
protected boolean doDescriptions(FauEu2CdmImportState state) {
|
|
338 |
return false;
|
|
339 |
}
|
|
340 |
|
308 |
341 |
protected Synonym handlePersistedSynonym(Synonym synonym) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
309 |
342 |
Synonym result = handlePersisted((TaxonBase)synonym);
|
|
343 |
//complete
|
310 |
344 |
setInvisible(result, "acceptedTaxon", detache(result.getAcceptedTaxon()));
|
311 |
345 |
result.setType(detache(result.getType()));
|
312 |
346 |
return result;
|
... | ... | |
314 |
348 |
|
315 |
349 |
protected TaxonRelationship handlePersistedTaxonRelationship(TaxonRelationship taxRel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
316 |
350 |
TaxonRelationship result = handlePersisted((RelationshipBase)taxRel);
|
|
351 |
//complete
|
317 |
352 |
result.setFromTaxon(detache(result.getFromTaxon()));
|
318 |
353 |
result.setToTaxon(detache(result.getToTaxon()));
|
319 |
354 |
result.setType(detache(result.getType()));
|
... | ... | |
322 |
357 |
|
323 |
358 |
protected NameRelationship handlePersistedNameRelationship(NameRelationship rel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
324 |
359 |
NameRelationship result = handlePersisted((RelationshipBase)rel);
|
|
360 |
//complete
|
325 |
361 |
setInvisible(result, "relatedFrom", detache(result.getFromName()));
|
326 |
362 |
setInvisible(result, "relatedTo", detache(result.getToName()));
|
327 |
363 |
// result.setFromName(detache(result.getFromName()));
|
... | ... | |
332 |
368 |
|
333 |
369 |
protected HybridRelationship handlePersistedHybridRelationship(HybridRelationship rel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
334 |
370 |
HybridRelationship result = handlePersisted((RelationshipBase)rel);
|
|
371 |
//complete
|
335 |
372 |
setInvisible(result, "relatedFrom", detache(result.getParentName()));
|
336 |
373 |
setInvisible(result, "relatedTo", detache(result.getHybridName()));
|
337 |
374 |
// result.setFromName(detache(result.getFromName()));
|
... | ... | |
342 |
379 |
|
343 |
380 |
protected NomenclaturalStatus handlePersistedNomenclaturalStatus(NomenclaturalStatus status) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
344 |
381 |
NomenclaturalStatus result = handlePersisted((ReferencedEntityBase)status);
|
|
382 |
//complete
|
345 |
383 |
result.setType(detache(result.getType()));
|
346 |
384 |
return result;
|
347 |
385 |
}
|
348 |
386 |
|
349 |
387 |
protected TypeDesignationBase handlePersistedTypeDesignationBase(TypeDesignationBase<?> designation) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
350 |
388 |
TypeDesignationBase result = handlePersisted((SourcedEntityBase)designation);
|
|
389 |
//complete
|
351 |
390 |
result.setCitation(detache(result.getCitation()));
|
352 |
391 |
handleCollection(result, TypeDesignationBase.class, "registrations", Registration.class);
|
353 |
392 |
handleCollection(result, TypeDesignationBase.class, "typifiedNames", TaxonName.class);
|
... | ... | |
357 |
396 |
|
358 |
397 |
protected InstitutionalMembership handlePersistedInstitutionalMembership(InstitutionalMembership institutionalMembership) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
359 |
398 |
InstitutionalMembership result = handlePersisted((VersionableEntity)institutionalMembership);
|
|
399 |
//complete
|
360 |
400 |
// result.setPerson(detache(result.getPerson()));
|
361 |
401 |
setInvisible(result, "person", detache(result.getPerson()));
|
362 |
402 |
result.setInstitute(detache(result.getInstitute()));
|
... | ... | |
365 |
405 |
|
366 |
406 |
protected Institution handlePersistedInstitution(Institution institution) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
367 |
407 |
Institution result = handlePersisted((AgentBase)institution);
|
|
408 |
//complete
|
368 |
409 |
result.setIsPartOf(detache(result.getIsPartOf()));
|
369 |
410 |
handleCollection(result, Institution.class, "types", DefinedTerm.class);
|
370 |
411 |
return result;
|
... | ... | |
372 |
413 |
|
373 |
414 |
protected TaxonNodeAgentRelation handlePersistedTaxonNodeAgentRelation(TaxonNodeAgentRelation nodeAgentRel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
374 |
415 |
TaxonNodeAgentRelation result = handlePersisted((AnnotatableEntity)nodeAgentRel);
|
375 |
|
if (result ==null){
|
376 |
|
return result;
|
377 |
|
}
|
|
416 |
//complete
|
378 |
417 |
result.setAgent(detache(result.getAgent()));
|
379 |
418 |
result.setType(detache(result.getType()));
|
380 |
419 |
setInvisible(result, "taxonNode", detache(result.getTaxonNode()));
|
... | ... | |
385 |
424 |
protected TaxonName handlePersistedTaxonName(TaxonName taxonName) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
386 |
425 |
@SuppressWarnings("rawtypes")
|
387 |
426 |
TaxonName result = handlePersisted((IdentifiableEntity)taxonName);
|
388 |
|
if (result ==null){
|
389 |
|
return result;
|
390 |
|
}
|
|
427 |
//complete
|
|
428 |
result.setRank(detache(result.getRank()));
|
391 |
429 |
result.setCombinationAuthorship(detache(result.getCombinationAuthorship()));
|
392 |
430 |
result.setExCombinationAuthorship(detache(result.getExCombinationAuthorship()));
|
393 |
431 |
result.setBasionymAuthorship(detache(result.getBasionymAuthorship()));
|
... | ... | |
396 |
434 |
result.setInCombinationAuthorship(detache(result.getInCombinationAuthorship()));
|
397 |
435 |
|
398 |
436 |
result.setNomenclaturalReference(detache(result.getNomenclaturalReference()));
|
|
437 |
result.setNomenclaturalSource(detache(result.getNomenclaturalSource()));
|
399 |
438 |
result.setHomotypicalGroup(detache(result.getHomotypicalGroup()));
|
400 |
439 |
handleCollection(result, TaxonName.class, "descriptions", TaxonNameDescription.class);
|
401 |
440 |
handleCollection(result, TaxonName.class, "hybridChildRelations", HybridRelationship.class);
|
... | ... | |
414 |
453 |
|
415 |
454 |
protected HomotypicalGroup handlePersistedHomotypicalGroup(HomotypicalGroup group) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
416 |
455 |
HomotypicalGroup result = handlePersisted((AnnotatableEntity)group);
|
417 |
|
if (result ==null){
|
418 |
|
return result;
|
419 |
|
}
|
|
456 |
//complete
|
420 |
457 |
handleCollection(result, HomotypicalGroup.class, "typifiedNames", TaxonName.class);
|
421 |
458 |
return result;
|
422 |
459 |
}
|
423 |
460 |
|
424 |
461 |
protected Annotation handlePersistedAnnotation(Annotation annotation) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
425 |
462 |
Annotation result = handlePersisted((AnnotatableEntity)annotation);
|
426 |
|
if (result ==null){
|
427 |
|
return result;
|
428 |
|
}
|
|
463 |
//complete
|
429 |
464 |
result.setAnnotationType(detache(annotation.getAnnotationType()));
|
|
465 |
result.setCommentator(detache(result.getCommentator()));
|
430 |
466 |
handleCollection(result, Annotation.class, "intextReferences", IntextReference.class);
|
431 |
467 |
return result;
|
432 |
468 |
}
|
433 |
469 |
|
434 |
470 |
protected Extension handlePersistedExtension(Extension extension) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
435 |
471 |
Extension result = handlePersisted((VersionableEntity)extension);
|
436 |
|
if (result ==null){
|
437 |
|
return result;
|
438 |
|
}
|
|
472 |
//complete
|
439 |
473 |
result.setType(detache(extension.getType()));
|
440 |
474 |
return result;
|
441 |
475 |
}
|
442 |
476 |
|
443 |
477 |
protected Marker handlePersistedMarker(Marker marker) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
444 |
478 |
Marker result = handlePersisted((VersionableEntity)marker);
|
445 |
|
if (result ==null){
|
446 |
|
return result;
|
447 |
|
}
|
|
479 |
//complete
|
448 |
480 |
result.setMarkerType(detache(marker.getMarkerType()));
|
449 |
481 |
return result;
|
450 |
482 |
}
|
451 |
483 |
|
452 |
484 |
protected Team handlePersistedTeam(Team team) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
453 |
485 |
Team result = handlePersisted((TeamOrPersonBase)team);
|
454 |
|
if (result ==null){
|
455 |
|
return result;
|
456 |
|
}
|
|
486 |
//complete
|
457 |
487 |
handleCollection(result, Team.class, "teamMembers", Person.class);
|
458 |
488 |
return result;
|
459 |
489 |
}
|
... | ... | |
479 |
509 |
|
480 |
510 |
protected Person handlePersistedPerson(Person person) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
481 |
511 |
Person result = handlePersisted((TeamOrPersonBase)person);
|
|
512 |
//complete
|
482 |
513 |
handleCollection(result, Person.class, "institutionalMemberships", InstitutionalMembership.class);
|
483 |
514 |
return result;
|
484 |
515 |
}
|
485 |
516 |
|
486 |
517 |
protected NamedArea handlePersistedNamedArea(NamedArea area) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
487 |
518 |
NamedArea result = handlePersisted((OrderedTermBase)area);
|
|
519 |
//complete
|
488 |
520 |
handleCollection(result, NamedArea.class, "countries", Country.class);
|
489 |
521 |
result.setLevel(detache(result.getLevel()));
|
490 |
522 |
result.setType(detache(result.getType()));
|
... | ... | |
494 |
526 |
|
495 |
527 |
protected Classification handlePersistedClassification(Classification classification) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
496 |
528 |
Classification result = handlePersisted((IdentifiableEntity)classification);
|
497 |
|
if (result ==null){
|
498 |
|
return result;
|
499 |
|
}
|
|
529 |
//complete
|
500 |
530 |
result.setName(detache(classification.getName()));
|
501 |
531 |
result.setReference(detache(classification.getReference()));
|
502 |
532 |
result.setRootNode(detache(classification.getRootNode()));
|
503 |
533 |
handleCollection(result, Classification.class, "geoScopes", NamedArea.class);
|
504 |
534 |
handleMap(result, Classification.class, "description", Language.class, LanguageString.class);
|
505 |
|
|
506 |
535 |
return result;
|
507 |
536 |
}
|
508 |
537 |
|
... | ... | |
516 |
545 |
}
|
517 |
546 |
|
518 |
547 |
protected SpecimenOrObservationBase<?> handlePersistedSpecimenOrObservationBase(SpecimenOrObservationBase specimen) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
|
548 |
//TODO implement for classes
|
519 |
549 |
SpecimenOrObservationBase<?> result = handlePersisted((IdentifiableEntity)specimen);
|
|
550 |
//complete
|
520 |
551 |
result.setSex(detache(result.getSex()));
|
521 |
552 |
result.setLifeStage(detache(result.getLifeStage()));
|
522 |
553 |
result.setKindOfUnit(detache(result.getKindOfUnit()));
|
523 |
|
//TODO implement for classes
|
524 |
554 |
handleCollection(result, SpecimenOrObservationBase.class, "determinations", DeterminationEvent.class);
|
525 |
555 |
handleCollection(result, SpecimenOrObservationBase.class, "descriptions", SpecimenDescription.class);
|
526 |
556 |
handleCollection(result, SpecimenOrObservationBase.class, "derivationEvents", DerivationEvent.class);
|
... | ... | |
530 |
560 |
|
531 |
561 |
protected IdentifiableSource handlePersistedIdentifiableSource(IdentifiableSource source) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
532 |
562 |
IdentifiableSource result = handlePersisted((OriginalSourceBase)source);
|
533 |
|
if (result ==null){
|
534 |
|
return null;
|
535 |
|
}
|
|
563 |
//complete
|
536 |
564 |
return result;
|
537 |
565 |
}
|
538 |
566 |
|
539 |
567 |
protected DescriptionElementSource handlePersistedDescriptionElementSource(DescriptionElementSource source) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
540 |
568 |
DescriptionElementSource result = handlePersisted((OriginalSourceBase)source);
|
|
569 |
//complete
|
541 |
570 |
result.setNameUsedInSource(detache(result.getNameUsedInSource()));
|
542 |
571 |
return result;
|
543 |
572 |
}
|
544 |
573 |
|
545 |
574 |
protected <T extends CommonTaxonName> T handlePersistedCommonTaxonName(CommonTaxonName element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
546 |
575 |
T result = handlePersisted((DescriptionElementBase)element);
|
|
576 |
//complete
|
547 |
577 |
result.setLanguage(detache(result.getLanguage()));
|
548 |
578 |
result.setArea(detache(result.getArea()));
|
549 |
579 |
return result;
|
... | ... | |
551 |
581 |
|
552 |
582 |
protected <T extends TextData> T handlePersistedTextData(TextData element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
553 |
583 |
T result = handlePersisted((DescriptionElementBase)element);
|
|
584 |
//complete
|
554 |
585 |
result.setFormat(detache(result.getFormat()));
|
555 |
586 |
handleMap(result, TextData.class, "multilanguageText", Language.class, LanguageString.class);
|
556 |
587 |
return result;
|
... | ... | |
558 |
589 |
|
559 |
590 |
protected <T extends Distribution> T handlePersistedDistribution(Distribution element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
560 |
591 |
T result = handlePersisted((DescriptionElementBase)element);
|
|
592 |
//complete
|
561 |
593 |
result.setArea(detache(result.getArea()));
|
562 |
594 |
result.setStatus(detache(result.getStatus()));
|
563 |
595 |
return result;
|
... | ... | |
565 |
597 |
|
566 |
598 |
protected ExtensionType handlePersistedExtensionType(ExtensionType term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
567 |
599 |
ExtensionType result = handlePersisted((DefinedTermBase)term);
|
|
600 |
//complete
|
|
601 |
return result;
|
|
602 |
}
|
|
603 |
|
|
604 |
protected MarkerType handlePersistedMarkerType(MarkerType term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
|
605 |
MarkerType result = handlePersisted((DefinedTermBase)term);
|
|
606 |
//complete
|
568 |
607 |
return result;
|
569 |
608 |
}
|
570 |
609 |
|
|
610 |
protected NomenclaturalStatusType handlePersistedNomenclaturalStatusType(NomenclaturalStatusType term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
|
611 |
NomenclaturalStatusType result = handlePersisted((OrderedTermBase)term);
|
|
612 |
//complete
|
|
613 |
return result;
|
|
614 |
}
|
571 |
615 |
|
572 |
616 |
protected DefinedTerm handlePersistedDefinedTerm(DefinedTerm term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
573 |
617 |
DefinedTerm result = handlePersisted((DefinedTermBase)term);
|
|
618 |
//complete
|
574 |
619 |
return result;
|
575 |
620 |
}
|
576 |
621 |
|
577 |
622 |
//placeholder for not implemented methods for subclasses
|
578 |
623 |
protected DefinedTermBase<?> handlePersistedTerm(DefinedTermBase term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
579 |
624 |
DefinedTermBase<?> result = handlePersisted(term);
|
|
625 |
logger.warn("Class not yet handled: " + term.getClass().getSimpleName());
|
580 |
626 |
return result;
|
581 |
627 |
}
|
582 |
628 |
|
... | ... | |
588 |
634 |
|
589 |
635 |
protected TermNode<?> handlePersistedTermNode(TermNode node) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
590 |
636 |
TermNode<?> result = (TermNode<?>)handlePersisted((TermRelationBase)node);
|
|
637 |
//complete
|
591 |
638 |
setInvisible(result, "parent", detache(result.getParent()));
|
592 |
639 |
handleCollection(result, TermNode.class, "inapplicableIf", FeatureState.class);
|
593 |
640 |
handleCollection(result, TermNode.class, "onlyApplicableIf", FeatureState.class);
|
... | ... | |
605 |
652 |
|
606 |
653 |
protected <T extends TermBase> T handlePersisted(TermBase termBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
607 |
654 |
T result = handlePersisted((IdentifiableEntity)termBase);
|
608 |
|
if (result ==null){
|
609 |
|
return null;
|
610 |
|
}
|
|
655 |
//complete
|
611 |
656 |
handleCollection(result, TermBase.class, "representations", Representation.class);
|
612 |
657 |
return result;
|
613 |
658 |
}
|
614 |
659 |
|
615 |
660 |
protected <T extends TermCollection> T handlePersisted(TermCollection termCollection) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
616 |
661 |
T result = handlePersisted((TermBase)termCollection);
|
617 |
|
if (result ==null){
|
618 |
|
return null;
|
619 |
|
}
|
|
662 |
//complete
|
620 |
663 |
handleCollection(result, TermCollection.class, "termRelations", TermRelationBase.class);
|
621 |
664 |
return result;
|
622 |
665 |
}
|
... | ... | |
632 |
675 |
User result = (User)handlePersistedCdmBase(user);
|
633 |
676 |
if (result.getUsername().equals("admin")){
|
634 |
677 |
result = getUserService().listByUsername("admin", MatchMode.EXACT, null, null, null, null, null).iterator().next();
|
635 |
|
permanentCache.put(user.getUuid(), result);
|
|
678 |
getState().putPermanent(user.getUuid(), result);
|
636 |
679 |
cache(result); //necessary?
|
637 |
680 |
toSave.add(result);
|
638 |
681 |
toSave.remove(user);
|
... | ... | |
648 |
691 |
|
649 |
692 |
protected LanguageString handlePersistedLanguageString(LanguageString languageString) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
650 |
693 |
LanguageString result = handlePersisted((LanguageStringBase)languageString);
|
|
694 |
//complete
|
651 |
695 |
handleCollection(result, LanguageString.class, "intextReferences", IntextReference.class);
|
652 |
696 |
return result;
|
653 |
697 |
}
|
... | ... | |
663 |
707 |
|
664 |
708 |
protected <T extends TaxonDescription> T handlePersistedTaxonDescription(TaxonDescription taxDescription) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
665 |
709 |
T result = handlePersisted((DescriptionBase)taxDescription);
|
|
710 |
//complete
|
666 |
711 |
setInvisible(taxDescription, "taxon", detache(taxDescription.getTaxon()));
|
667 |
712 |
handleCollection(taxDescription, TaxonDescription.class, "geoScopes", NamedArea.class);
|
668 |
713 |
handleCollection(taxDescription, TaxonDescription.class, "scopes", DefinedTerm.class);
|
... | ... | |
671 |
716 |
|
672 |
717 |
protected <T extends TaxonDescription> T handlePersistedTaxonNameDescription(TaxonNameDescription nameDescription) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
673 |
718 |
T result = handlePersisted((DescriptionBase)nameDescription);
|
|
719 |
//complete
|
674 |
720 |
setInvisible(nameDescription, "taxonName", detache(nameDescription.getTaxonName()));
|
675 |
721 |
return result;
|
676 |
722 |
}
|
... | ... | |
680 |
726 |
|
681 |
727 |
protected <T extends CdmBase> T handlePersistedCdmBase(CdmBase cdmBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
682 |
728 |
T result = (T)getTarget(cdmBase);
|
683 |
|
if (result == null){
|
684 |
|
return null;
|
685 |
|
}
|
|
729 |
//complete
|
686 |
730 |
cdmBase.setCreatedBy(detache(cdmBase.getCreatedBy()));
|
687 |
731 |
return result;
|
688 |
732 |
}
|
689 |
733 |
|
690 |
734 |
protected <T extends VersionableEntity> T handlePersisted(VersionableEntity entity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
691 |
735 |
T result = (T)handlePersistedCdmBase((CdmBase)entity);
|
692 |
|
if (result ==null){
|
693 |
|
return null;
|
694 |
|
}
|
|
736 |
//complete
|
695 |
737 |
entity.setUpdatedBy(detache(entity.getUpdatedBy()));
|
696 |
738 |
return result;
|
697 |
739 |
}
|
698 |
740 |
|
699 |
741 |
protected <T extends AnnotatableEntity> T handlePersisted(AnnotatableEntity entity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
700 |
742 |
T result = handlePersisted((VersionableEntity)entity);
|
701 |
|
if (result ==null){
|
702 |
|
return null;
|
703 |
|
}
|
|
743 |
//complete
|
704 |
744 |
handleCollection(result, AnnotatableEntity.class, "annotations", Annotation.class);
|
705 |
745 |
handleCollection(result, AnnotatableEntity.class, "markers", Marker.class);
|
706 |
746 |
return result;
|
... | ... | |
708 |
748 |
|
709 |
749 |
protected <T extends SourcedEntityBase> T handlePersisted(SourcedEntityBase sourcedEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
710 |
750 |
T result = handlePersisted((AnnotatableEntity)sourcedEntity);
|
711 |
|
if (result ==null){
|
712 |
|
return null;
|
713 |
|
}
|
|
751 |
//complete
|
714 |
752 |
handleCollection(result, SourcedEntityBase.class, "sources", OriginalSourceBase.class);
|
715 |
753 |
return result;
|
716 |
754 |
}
|
717 |
755 |
|
718 |
756 |
protected <T extends IdentifiableEntity> T handlePersisted(IdentifiableEntity identifiableEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
719 |
757 |
T result = handlePersisted((SourcedEntityBase)identifiableEntity);
|
720 |
|
if (result ==null){
|
721 |
|
return null;
|
722 |
|
}
|
|
758 |
//complete
|
723 |
759 |
handleCollection(result, IdentifiableEntity.class, "credits", Credit.class);
|
724 |
760 |
handleCollection(result, IdentifiableEntity.class, "extensions", Extension.class);
|
725 |
761 |
handleCollection(result, IdentifiableEntity.class, "identifiers", Identifier.class);
|
... | ... | |
729 |
765 |
|
730 |
766 |
protected <T extends DefinedTermBase> T handlePersisted(DefinedTermBase definedTermBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
731 |
767 |
T result = handlePersisted((TermBase)definedTermBase);
|
732 |
|
|
|
768 |
//complete
|
733 |
769 |
handleCollection(result, DefinedTermBase.class, "media", Media.class);
|
734 |
770 |
handleCollection(result, DefinedTermBase.class, "generalizationOf", DefinedTermBase.class);
|
735 |
771 |
handleCollection(result, DefinedTermBase.class, "includes", DefinedTermBase.class);
|
|
772 |
result.setKindOf(detache(result.getKindOf()));
|
|
773 |
result.setPartOf(detache(result.getPartOf()));
|
736 |
774 |
setInvisible(result, DefinedTermBase.class, "vocabulary", detache(result.getVocabulary()));
|
737 |
775 |
|
738 |
776 |
return result;
|
... | ... | |
740 |
778 |
|
741 |
779 |
protected <T extends OriginalSourceBase> T handlePersisted(OriginalSourceBase source) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
742 |
780 |
T result = handlePersisted((ReferencedEntityBase)source);
|
|
781 |
//complete
|
743 |
782 |
handleCollection(result, OriginalSourceBase.class, "links", ExternalLink.class);
|
744 |
|
|
745 |
783 |
return result;
|
746 |
784 |
}
|
747 |
785 |
|
748 |
786 |
protected <T extends LanguageStringBase> T handlePersisted(LanguageStringBase lsBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
749 |
787 |
T result = handlePersisted((AnnotatableEntity)lsBase);
|
|
788 |
//complete
|
750 |
789 |
result.setLanguage(detache(lsBase.getLanguage()));
|
751 |
790 |
return result;
|
752 |
791 |
}
|
753 |
792 |
|
754 |
793 |
protected <T extends TeamOrPersonBase> T handlePersisted(TeamOrPersonBase teamOrPerson) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
755 |
794 |
T result = handlePersisted((AgentBase)teamOrPerson);
|
|
795 |
//complete
|
756 |
796 |
return result;
|
757 |
797 |
}
|
758 |
798 |
|
759 |
799 |
protected <T extends AgentBase> T handlePersisted(AgentBase agent) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
760 |
800 |
T result = handlePersisted((IdentifiableMediaEntity)agent);
|
761 |
801 |
result.setContact(detache(result.getContact()));
|
|
802 |
//complete
|
762 |
803 |
return result;
|
763 |
804 |
}
|
764 |
805 |
|
765 |
806 |
protected <T extends TaxonBase> T handlePersisted(TaxonBase taxonBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
766 |
807 |
T result = handlePersisted((IdentifiableEntity)taxonBase);
|
|
808 |
//complete
|
767 |
809 |
result.setName(detache(taxonBase.getName()));
|
768 |
810 |
result.setSec(detache(taxonBase.getSec()));
|
769 |
811 |
return result;
|
... | ... | |
771 |
813 |
|
772 |
814 |
protected <T extends IdentifiableMediaEntity> T handlePersisted(IdentifiableMediaEntity mediaEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
773 |
815 |
T result = handlePersisted((IdentifiableEntity)mediaEntity);
|
|
816 |
//complete
|
774 |
817 |
handleCollection(result, IdentifiableMediaEntity.class, "media", Media.class);
|
775 |
818 |
return result;
|
776 |
819 |
}
|
777 |
820 |
|
778 |
821 |
protected <T extends ReferencedEntityBase> T handlePersisted(ReferencedEntityBase referencedEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
779 |
822 |
T result = handlePersisted((AnnotatableEntity)referencedEntity);
|
|
823 |
//complete
|
780 |
824 |
result.setCitation(detache(result.getCitation()));
|
781 |
825 |
return result;
|
782 |
826 |
}
|
783 |
827 |
|
784 |
828 |
protected <T extends DescriptionBase> T handlePersisted(DescriptionBase descriptionBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
785 |
829 |
T result = handlePersisted((IdentifiableEntity)descriptionBase);
|
|
830 |
//complete
|
786 |
831 |
handleCollection(result, DescriptionBase.class, "descriptionElements", DescriptionElementBase.class);
|
787 |
832 |
handleCollection(result, DescriptionBase.class, "descriptiveDataSets", DescriptiveDataSet.class);
|
788 |
833 |
handleCollection(result, DescriptionBase.class, "descriptionSources", Reference.class);
|
... | ... | |
792 |
837 |
|
793 |
838 |
protected <T extends DescriptionElementBase> T handlePersisted(DescriptionElementBase element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
|
794 |
839 |
T result = handlePersisted((AnnotatableEntity)element);
|
|
840 |
//complete
|
795 |
841 |
result.setFeature(detache(result.getFeature()));
|
796 |
842 |
setInvisible(result, DescriptionElementBase.class, "inDescription", detache(result.getInDescription()));
|
797 |
843 |
handleCollection(result, DescriptionElementBase.class, "sources", DescriptionElementSource.class);
|
... | ... | |
929 |
975 |
|
930 |
976 |
protected void cache(CdmBase cdmBase) {
|
931 |
977 |
if (cdmBase instanceof User || cdmBase instanceof DefinedTermBase){
|
932 |
|
permanentCache.put(cdmBase.getUuid(), cdmBase);
|
|
978 |
getState().putPermanent(cdmBase.getUuid(), cdmBase);
|
933 |
979 |
}else{
|
934 |
980 |
sessionCache.put(cdmBase.getUuid(), cdmBase);
|
935 |
981 |
}
|
936 |
|
movedObjects.add(cdmBase.getUuid());
|
|
982 |
addExistingObject(cdmBase);
|
|
983 |
|
|
984 |
}
|
937 |
985 |
|
|
986 |
private void addExistingObject(CdmBase cdmBase) {
|
|
987 |
cdmBase = CdmBase.deproxy(cdmBase);
|
|
988 |
Set<UUID> set = existingObjects.get(cdmBase.getClass());
|
|
989 |
if (set == null){
|
|
990 |
set = loadExistingUuids(cdmBase.getClass());
|
|
991 |
// set = new HashSet<>();
|
|
992 |
// existingObjects.put(cdmBase.getClass(), set);
|
|
993 |
}
|
|
994 |
set.add(cdmBase.getUuid());
|
938 |
995 |
}
|
939 |
996 |
|
940 |
997 |
protected boolean isInCache(CdmBase cdmBase) {
|
... | ... | |
944 |
1001 |
protected <T extends CdmBase> T getCached(T cdmBase) {
|
945 |
1002 |
T result = (T)sessionCache.get(cdmBase.getUuid());
|
946 |
1003 |
if (result == null){
|
947 |
|
result = (T)permanentCache.get(cdmBase.getUuid());
|
|
1004 |
result = (T)getState().getPermanent(cdmBase.getUuid());
|
948 |
1005 |
}
|
949 |
1006 |
return result;
|
950 |
1007 |
}
|
... | ... | |
953 |
1010 |
sessionCache.clear();
|
954 |
1011 |
}
|
955 |
1012 |
|
|
1013 |
public FauEu2CdmImportState getState() {
|
|
1014 |
return state;
|
|
1015 |
}
|
|
1016 |
|
|
1017 |
public void setState(FauEu2CdmImportState state) {
|
|
1018 |
this.state = state;
|
|
1019 |
}
|
|
1020 |
|
956 |
1021 |
}
|
ref #8479 split taxon and description import, remove auditing and some other improvements