Reference citation = referenceDao.load(citationUuid);
switch (secHandling){
- case AlwaysDelete:
- citation = null;
- break;
- case UseNewParentSec:
- citation = newTaxonNode.getTaxon() != null? newTaxonNode.getTaxon().getSec(): null;
- break;
- case KeepOrWarn:
-
- Reference synSec = oldTaxonNode.getTaxon().getSec();
- if (synSec != null ){
- citation = CdmBase.deproxy(synSec);
- }
- break;
- case KeepOrSelect:
+ case AlwaysDelete:
+ citation = null;
+ break;
+ case UseNewParentSec:
+ citation = newTaxonNode.getTaxon() != null? newTaxonNode.getTaxon().getSec(): null;
+ break;
+ case KeepOrWarn:
- break;
- default:
- break;
- }
+ Reference synSec = oldTaxonNode.getTaxon().getSec();
+ if (synSec != null ){
+ citation = CdmBase.deproxy(synSec);
+ }
+ break;
+ case KeepOrSelect:
+ break;
+ default:
+ break;
+ }
DeleteResult result = makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNode,
newTaxonNode,
for (TaxonNode child: childNodesList){
parent.addChildNode(child, child.getReference(), child.getMicroReference());
}
-
}
}
this.exceptions.addAll(exceptions);\r
}\r
\r
- /**\r
- * Related objects that prevent the delete action to take place.\r
- * @return\r
- */\r
+ //updated CDM id-s\r
public Set<CdmEntityIdentifier> getUpdatedCdmIds() {\r
return updatedCdmIds;\r
}\r
this.updatedCdmIds.add(CdmEntityIdentifier.NewInstance(updatedObject));\r
}\r
\r
-\r
+ //updated objects\r
public Set<CdmBase> getUpdatedObjects() {\r
return updatedObjects;\r
}\r
public void addUpdatedObject(CdmBase relatedObject) {\r
this.updatedObjects.add(relatedObject);\r
- }\r
+ }\r
public void addUpdatedObjects(Set<? extends CdmBase> updatedObjects) {\r
this.updatedObjects.addAll(updatedObjects);\r
}\r
\r
+\r
+ //cdmEntity\r
+ public void setCdmEntity(CdmBase cdmBase) {\r
+ this.cdmEntity = cdmBase;\r
+ }\r
+ public CdmBase getCdmEntity(){\r
+ return cdmEntity;\r
+ }\r
+\r
+ //unchanged objects\r
+ public Set<CdmBase> getUnchangedObjects() {\r
+ return unchangedObjects;\r
+ }\r
+ public void addUnchangedObjects(Set<? extends CdmBase> unchangedObjects) {\r
+ this.unchangedObjects.addAll(unchangedObjects);\r
+ }\r
+ public void addUnChangedObject(CdmBase unchangedObject) {\r
+ this.unchangedObjects.add(unchangedObject);\r
+ }\r
+\r
//****************** CONVENIENCE *********************************************/\r
\r
/**\r
return this.status == Status.ERROR;\r
}\r
\r
+// *********************************** TO STRING ***************************************/\r
@Override\r
public String toString(){\r
String separator = ", ";\r
if(exceptionString.endsWith(separator)){\r
exceptionString = exceptionString.substring(0, exceptionString.length()-separator.length());\r
}\r
- String relatedObjectString = "";\r
+ String updatedObjectString = "";\r
for (CdmBase upatedObject: updatedObjects) {\r
if(upatedObject instanceof IIdentifiableEntity){\r
- relatedObjectString += ((IIdentifiableEntity) upatedObject).getTitleCache()+separator;\r
+ updatedObjectString += ((IIdentifiableEntity) upatedObject).getTitleCache()+separator;\r
}\r
else{\r
- relatedObjectString += upatedObject.toString()+separator;\r
+ updatedObjectString += upatedObject.toString()+separator;\r
}\r
}\r
- if(relatedObjectString.endsWith(separator)){\r
- relatedObjectString = relatedObjectString.substring(0, relatedObjectString.length()-separator.length());\r
+ if(updatedObjectString.endsWith(separator)){\r
+ updatedObjectString = updatedObjectString.substring(0, updatedObjectString.length()-separator.length());\r
}\r
return "[UpdateResult]\n" +\r
"Status: " + status.toString()+"\n" +\r
"Exceptions: " + exceptionString+"\n" +\r
- "Related Objects: "+relatedObjectString;\r
- }\r
- public void setCdmEntity(CdmBase cdmBase) {\r
- this.cdmEntity = cdmBase;\r
- }\r
-\r
- public CdmBase getCdmEntity(){\r
- return cdmEntity;\r
- }\r
-\r
- public Set<CdmBase> getUnchangedObjects() {\r
- return unchangedObjects;\r
- }\r
-\r
- public void addUnchangedObjects(Set<? extends CdmBase> unchangedObjects) {\r
- this.unchangedObjects.addAll(unchangedObjects);\r
- }\r
- public void addUnChangedObject(CdmBase unchangedObject) {\r
- this.unchangedObjects.add(unchangedObject);\r
+ "Updated Objects: " + updatedObjectString;\r
}\r
}\r
//old: if we want to reuse distribution only with exact same status
// Distribution distribution = findDistributionForAreaAndStatus(aggregationDescription, area, status);
- if(distribution == null) {
+ if(targetDistribution == null) {
// create a new distribution element
distribution = Distribution.NewInstance(area, status);
targetDescription.addElement(distribution);
}
Set<TaxonDescription> descriptions = descriptionsFor(taxon, excludedDescriptions);
- Set<Distribution> distributions = distributionsFor(descriptions);
+ Set<Distribution> existingDistributions = distributionsFor(descriptions);
// Step through superAreas for accumulation of subAreas
for (NamedArea superArea : superAreaList){
for(NamedArea subArea : subAreas){
if(logger.isTraceEnabled()){logger.trace("accumulateByArea() - \t\t" + termToString(subArea));}
// step through all distributions for the given subArea
- for(Distribution distribution : distributions){
+ for(Distribution distribution : existingDistributions){
//TODO AM is the status handling here correct? The mapping to CDM handled
if(subArea.equals(distribution.getArea()) && distribution.getStatus() != null) {
PresenceAbsenceTerm status = distribution.getStatus();
}
}
- private Distribution findDistributionForArea(TaxonDescription description, NamedArea area) {
+ private Distribution findDistributionToStayForArea(TaxonDescription description, NamedArea area) {
for(DescriptionElementBase item : description.getElements()) {
if(!(item.isInstanceOf(Distribution.class))) {
continue;
}
}
- private void flushAndClear() {
- flush();
- logger.debug("clearing session ...");
- getSession().clear();
- }
-
@Override
protected TaxonDescription createNewDescription(Taxon taxon) {
String title = taxon.getTitleCache();
- logger.debug("creating new description for " + title);
+ if (logger.isDebugEnabled()){logger.debug("creating new description for " + title);}
TaxonDescription description = TaxonDescription.NewInstance(taxon);
description.addType(DescriptionType.AGGREGATED_DISTRIBUTION);
setDescriptionTitle(description, taxon);
OrderedTermVocabulary<PresenceAbsenceTerm> voc = (OrderedTermVocabulary<PresenceAbsenceTerm>)getRepository().getVocabularyService().find(VocabularyEnum.PresenceAbsenceTerm.getUuid());
return voc;
}
-
- private void replaceSources(Distribution distribution, Set<DescriptionElementSource> newSources) {
- Set<DescriptionElementSource> toDeleteSources = new HashSet<>(distribution.getSources());
- for(DescriptionElementSource newSource : newSources) {
- boolean contained = false;
- for(DescriptionElementSource existingSource: distribution.getSources()) {
- if(existingSource.equalsByShallowCompare(newSource)) {
- contained = true;
- toDeleteSources.remove(existingSource);
- break;
- }
- }
- if(!contained) {
- try {
- distribution.addSource(newSource.clone());
- } catch (CloneNotSupportedException e) {
- // should never happen
- throw new RuntimeException(e);
- }
- }
- }
- for (DescriptionElementSource toDeleteSource : toDeleteSources){
- distribution.removeSource(toDeleteSource);
- }
- }
-
-
-}
+}
\ No newline at end of file
private void mergeDescriptionElement(CategoricalData elementToStay,
CategoricalData newElement) {
+
List<StateData> oldData = new ArrayList<>(elementToStay.getStateData());
List<StateData> newData = new ArrayList<>(newElement.getStateData());
for (StateData newStateData : newData){
private void mergeDescriptionElement(QuantitativeData elementToStay,
QuantitativeData newElement) {
+
Set<StatisticalMeasurementValue> oldValues = new HashSet<>(elementToStay.getStatisticalValues());
Set<StatisticalMeasurementValue> newValues = new HashSet<>(newElement.getStatisticalValues());
for (StatisticalMeasurementValue newValue : newValues){
// (equal instances existed in previous aggregation)
//add higher status to L. communis alpina/yug_mn
- Set<Distribution> nativ_mn_distr = new HashSet<>();
+ Set<Distribution> mn_distr = new HashSet<>();
Distribution distrNative = newDistribution(null, yug_mn, PresenceAbsenceTerm.INTRODUCED(), "5");
- nativ_mn_distr.add(distrNative);
- addDistributions(T_LAPSANA_COMMUNIS_ALPINA_UUID, nativ_mn_distr);
+ mn_distr.add(distrNative);
+ addDistributions(T_LAPSANA_COMMUNIS_ALPINA_UUID, mn_distr);
Set<DescriptionElementSource> lca_yug_ko_sources = descriptionService.loadDescriptionElement(distributions_LCA.get(1).getUuid(), null).getSources();
Assert.assertEquals(1, lca_yug_ko_sources.size());