Merge branch 'release/5.22.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / e4 / TaxonEditorInputE4.java
index 3ee0517a63dd25069bc1bffa64acbaa746e0302b..acfd4651813a6590493da3bdbaab6ffdae58a268 100644 (file)
@@ -75,10 +75,9 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput<TaxonNode>
 
     private Map<TaxonBase, TaxonBaseDeletionConfigurator> toDeletes = new HashMap<>();
     private Set<Synonym> toSaveNewSynonyms = new HashSet<>();
-    private List<TaxonBase> toSaveNewConcepts = new ArrayList<>();
+    private List<TaxonBase> toSaveConcepts = new ArrayList<>();
     private List<TaxonName> toSaveNewNames = new ArrayList<>();
 
-
     private Set<AbstractPostOperation> operations = new HashSet<>();
 
     private TaxonEditorInputDataChangeBehaviourE4 dataChangeBehavior;
@@ -344,9 +343,8 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput<TaxonNode>
     public void addToSaveNewSynonym(Synonym toSaveNew) {
         this.toSaveNewSynonyms.add(toSaveNew);
     }
-    public void addToSaveNewConcept(Taxon toSaveNew) {
-       this.toSaveNewConcepts.add(toSaveNew);
-
+    public void addToSaveConcept(Taxon toSaveNew) {
+       this.toSaveConcepts.add(toSaveNew);
     }
 
     @Override
@@ -363,7 +361,50 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput<TaxonNode>
             delete(entry.getKey(), entry.getValue());
         }
         toDeletes.clear();
-        CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true);
+
+        // new concepts needs to be saved separately, the list contains all concepts, the
+        for (TaxonBase<?> concept: toSaveConcepts){
+            if (concept != null){
+                if (concept.getName() != null){
+                    for (HybridRelationship rel : concept.getName().getHybridChildRelations()){
+                        toSaveNewNames.add(rel.getParentName());
+                        toSaveNewNames.add(rel.getHybridName());
+                    }
+                }
+            }
+        }
+
+        //handle cascading for hybrid relationshis
+        //accepted taxa
+        if (taxonNode.getTaxon().getName() != null){
+            for (HybridRelationship rel : taxonNode.getTaxon().getName().getHybridChildRelations()){
+                toSaveNewNames.add(rel.getParentName());
+                toSaveNewNames.add(rel.getHybridName());
+            }
+        }
+        //synonyms
+        for (TaxonName synonymName : taxonNode.getTaxon().getSynonymNames()){
+            if (synonymName != null){
+                for (HybridRelationship rel : synonymName.getHybridChildRelations()){
+                    toSaveNewNames.add(rel.getParentName());
+                    toSaveNewNames.add(rel.getHybridName());
+                }
+            }
+        }
+//        for (TaxonName name:toSaveNewNames){
+//            name.get
+//        }
+
+        if (!toSaveNewNames.isEmpty()){
+            CdmStore.getService(INameService.class).merge(toSaveNewNames, true);
+        }
+        if (!toSaveConcepts.isEmpty()){
+            CdmStore.getService(ITaxonService.class).merge(toSaveConcepts, true);
+        }
+
+        toSaveNewNames.clear();
+        toSaveConcepts.clear();
+
         for(AbstractPostOperation<?> entry:operations){
             IStatus status = Status.CANCEL_STATUS;
             final IAdaptable uiInfoAdapter = WorkspaceUndoUtil
@@ -373,61 +414,20 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput<TaxonNode>
                 entry.addContext(IOperationHistory.GLOBAL_UNDO_CONTEXT);
                 status = entry.execute(new NullProgressMonitor(), uiInfoAdapter);
             } catch (ExecutionException e) {
-
                 MessagingUtils.operationDialog(AbstractUtility.class, e, TaxeditorStorePlugin.PLUGIN_ID, operationlabel, null);
-
             }
 
-            String statusString = status.equals(Status.OK_STATUS) ? "completed"
-                    : "cancelled";
-
             IPostOperationEnabled postOperationEnabled = entry
                     .getPostOperationEnabled();
             if (postOperationEnabled != null) {
                 postOperationEnabled.onComplete();
             }
 
-
             //AbstractUtility.executeOperation(entry,sync);
         }
 
         operations.clear();
-        for (Synonym syn: toSaveNewSynonyms){
-            for (HybridRelationship rel : syn.getName().getHybridChildRelations()){
-//                if (!rel.getParentName().isPersited()) {
-                    toSaveNewNames.add(rel.getParentName());
-//                }
-//                    if (!rel.getHybridName().isPersited()) {
-                   toSaveNewNames.add(rel.getHybridName());
-//                }
-
-            }
-        }
-
-        for (TaxonBase<?> concept: toSaveNewConcepts){
-            for (HybridRelationship rel : concept.getName().getHybridChildRelations()){
-//                if (!rel.getParentName().isPersited()) {
-                    toSaveNewNames.add(rel.getParentName());
-//                }
-//                if (!rel.getHybridName().isPersited()) {
-                    toSaveNewNames.add(rel.getHybridName());
-//                }
-
-            }
-        }
-        if (!toSaveNewNames.isEmpty()){
-            CdmStore.getService(INameService.class).merge(toSaveNewNames, true);
-        }
-        if (!toSaveNewConcepts.isEmpty()){
-            CdmStore.getService(ITaxonService.class).merge(toSaveNewConcepts, true);
-        }
-
-        toSaveNewNames.clear();
-        toSaveNewConcepts.clear();
-
-
-
-
+        CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true);
     }
 
     private void delete(TaxonBase key, TaxonBaseDeletionConfigurator value) {
@@ -462,27 +462,66 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput<TaxonNode>
                 "extensions", //$NON-NLS-1$
                 "rights", //$NON-NLS-1$
                 "sources", //$NON-NLS-1$
+                "sources.links", //$NON-NLS-1$
                 "identifiers",
                 "descriptions", //$NON-NLS-1$
                 "taxonNodes", //$NON-NLS-1$
                 "descriptions.descriptionElements.feature", //$NON-NLS-1$
                 "descriptions.descriptionElements.area", //$NON-NLS-1$
                 "descriptions.descriptionElements.status", //$NON-NLS-1$
+                "descriptions.descriptionElements.markers", //$NON-NLS-1$
+                "descriptions.descriptionElements.sources", //$NON-NLS-1$
+                "descriptions.descriptionElements.annotations", //$NON-NLS-1$
                 "descriptions.markers", //$NON-NLS-1$
+                "descriptions.descriptionSources", //$NON-NLS-1$
+                "descriptions.sources", //$NON-NLS-1$
+                "descriptions.annotations", //$NON-NLS-1$
+                "descriptions.links", //$NON-NLS-1$
                 "name.descriptions", //$NON-NLS-1$
                 "name.typeDesignations.typeSpecimen.derivedFrom.originals", //$NON-NLS-1$
+                "name.typeDesignations.source", //$NON-NLS-1$
+                "name.typeDesignations.source.nameUsedInSource", //$NON-NLS-1$
+                "name.typeDesignations.source.citation", //$NON-NLS-1$
+                "name.typeDesignations.source.links", //$NON-NLS-1$
+                "name.typeDesignations.text", //$NON-NLS-1$
+                "name.typeDesignations.sources", //$NON-NLS-1$
+                "name.typeDesignations.sources.links", //$NON-NLS-1$
                 "name.status", //$NON-NLS-1$
-                "name.nomenclaturalReference.inReference", //$NON-NLS-1$
+                "name.nomenclaturalSource", //$NON-NLS-1$
+                "name.nomenclaturalSource.nameUsedInSource", //$NON-NLS-1$
+                "name.nomenclaturalSource.links.description", //$NON-NLS-1$
+                "name.nomenclaturalSource.citation", //$NON-NLS-1$
+                "name.nomenclaturalSource.citation.inReference", //$NON-NLS-1$
+                "name.nomenclaturalSource.cdmSource", //$NON-NLS-1$
+                "name.nomenclaturalSource.cdmSource.description", //$NON-NLS-1$
+                "name.status.source", //$NON-NLS-1$
+                "name.status.source.links", //$NON-NLS-1$
                 "name.taxonBases.taxonNodes", //$NON-NLS-1$
                 "name.relationsFromThisName", //$NON-NLS-1$
+                "name.relationsFromThisName.source", //$NON-NLS-1$
+                "name.relationsFromThisName.source.links", //$NON-NLS-1$
                 "name.relationsToThisName", //$NON-NLS-1$
+                "name.relationsToThisName.source", //$NON-NLS-1$
+                "name.relationsToThisName.source.links", //$NON-NLS-1$
                 "name.homotypicalGroup.typifiedNames.taxonBases.synonyms.synonym.name.status", //$NON-NLS-1$
                 "name.homotypicalGroup.typifiedNames.relationsToThisName.fromName", //$NON-NLS-1$
+                "name.rank.vocabulary", //$NON-NLS-1$
                 "synonyms.name.status.type", //$NON-NLS-1$
-                "synonyms.name.relationsToThisName.fromName", //$NON-NLS-1$
-                "synonyms.name.nomenclaturalReference.inReference.authorship", //$NON-NLS-1$
-                "synonyms.name.nomenclaturalReference.authorship", //$NON-NLS-1$
-                "synonyms.name.homotypicalGroup.typifiedNames.taxonBases.synonyms" //$NON-NLS-1$
+                "synonyms.name.relationsToThisName.relatedFrom", //$NON-NLS-1$
+                "synonyms.name.relationsFromThisName.relatedTo", //$NON-NLS-1$
+                "synonyms.name.nomenclaturalSource", //$NON-NLS-1$
+                "synonyms.name.nomenclaturalSource.nameUsedInSource", //$NON-NLS-1$
+                "synonyms.name.nomenclaturalSource.links", //$NON-NLS-1$
+                "synonyms.name.nomenclaturalSource.citation", //$NON-NLS-1$
+                "synonyms.name.nomenclaturalSource.citation.inReference", //$NON-NLS-1$
+                "synonyms.name.nomenclaturalSource.cdmSource", //$NON-NLS-1$
+                "synonyms.name.nomenclaturalSource.cdmSource.description", //$NON-NLS-1$
+                "synonyms.name.nomenclaturalSource.citation.inReference.authorship", //$NON-NLS-1$
+                "synonyms.name.nomenclaturalSource.citation.authorship", //$NON-NLS-1$
+                "synonyms.name.homotypicalGroup.typifiedNames.taxonBases.synonyms", //$NON-NLS-1$
+                "relationsFromThisTaxon",//$NON-NLS-1$
+                "relationsToThisTaxon"//$NON-NLS-1$
+
         });
 
         return taxonBasePropertyPaths;
@@ -496,4 +535,4 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput<TaxonNode>
     public void addToSaveNewName(TaxonName newName) {
         this.toSaveNewNames.add(newName);
     }
-}
+}
\ No newline at end of file