improve messaging for deleteResult
authorU-BGBM\k.luther <k.luther@BGBM11732.bgbm.fu-berlin.de>
Tue, 6 Oct 2015 07:16:00 +0000 (09:16 +0200)
committerU-BGBM\k.luther <k.luther@BGBM11732.bgbm.fu-berlin.de>
Tue, 6 Oct 2015 07:16:00 +0000 (09:16 +0200)
65 files changed:
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/NameEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/OccurrenceEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/ReferenceEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/TaxonEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/UserEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationState.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmTransientEntityCacher.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/CdmEntitySession.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/CdmEntitySessionManager.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/DefaultNewEntityListener.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/ICdmEntitySession.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/ICdmEntitySessionManager.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/NullSession.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/mock/MockCdmEntitySession.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/mock/MockCdmEntitySessionManager.java
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/messages.properties
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/messages_de.properties
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/CdmAuthorityEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientAgentService.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientClassificationService.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientCollectionService.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientDescriptionService.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientNameService.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientOccurenceService.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientReferenceService.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientTaxonService.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientTermService.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateViewEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/contextMenu/CreateDerivateContextMenu.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionToOtherTaxonOperation.java
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/AlignmentEditor.java
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/AlignmentEditorInput.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermEditor.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/EditFeatureTreeWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/FeatureTreeEditorWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DeleteResultMessagingUtils.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewAmplificationWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewClassificationWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewCollectionWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewFieldUnitWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewGrantedAuthorityWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewGroupWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewInstitutionWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewNonViralNameWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewPersonWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewPolytomousKeyWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewPrimerWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTeamWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewUserWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/FeatureTreePreferences.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/CdmPreferencePage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementSourceSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateContentProvider.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/sessions/SessionsViewPart.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/operation/TaxonNameEditorTest.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/session/CdmEntitySessionAwareTest.java
eu.etaxonomy.taxeditor.test/src/test/resources/eu/etaxonomy/taxeditor/operation/TaxonNameEditorTest.xml

index 15ca691727c485428c2316c9648b0e3dac73e96a..49aaed016979134fb34b298ea768515b33ea906e 100644 (file)
@@ -10,6 +10,9 @@
 
 package eu.etaxonomy.taxeditor.bulkeditor.handler;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
@@ -44,6 +47,7 @@ import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
+import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
@@ -84,6 +88,7 @@ public class DeleteHandler extends AbstractHandler {
 
                                LineAnnotation annotation = (LineAnnotation) model.getAnnotation(object);
                                DeleteResult result = new DeleteResult();
+                               String errorMessage= "The object ";
                                //result.setError();
                                try {
                                        ICdmApplicationConfiguration controller;
@@ -93,60 +98,64 @@ public class DeleteHandler extends AbstractHandler {
                                                IOccurrenceService service = controller.getOccurrenceService();
                                                if (object != null){
                                                        result = service.delete(((SpecimenOrObservationBase) object).getUuid());
+                                                       errorMessage = "The specimen or observation ";
                                                }
                                        } else if (object instanceof Reference){
                                                IReferenceService service = controller.getReferenceService();
                                                if (object != null){
                                                        result = service.delete(((Reference) object).getUuid());
+                                                       errorMessage = "The reference ";
                                                }
 
                                        } else if (object instanceof Group){
                                                IGroupService service = controller.getGroupService();
                                                if (object != null){
                                                        result = service.delete(((Group) object).getUuid());
+                                                       errorMessage = "The group ";
                                                }
                                        }else if (object instanceof User){
                                                IUserService service = controller.getUserService();
                                                if (object != null){
                                                        result = service.delete(((User) object).getUuid());
+                                                       errorMessage = "The user ";
                                                }
                                        } else if (object instanceof TaxonNameBase){
                                                INameService service = controller.getNameService();
                                                if (object != null){
                                                        NameDeletionConfigurator config = new NameDeletionConfigurator();
                                                        result = service.delete(((TaxonNameBase) object).getUuid(), config);
+                                                       errorMessage = "The name ";
                                                }
                                        } else if (object instanceof TaxonBase){
                                                ITaxonService service = controller.getTaxonService();
                                                if (object != null){
                                                        if (object instanceof Taxon){
                                                                result = service.deleteTaxon(((TaxonBase) object).getUuid(), null, null);
+                                                               errorMessage = "The taxon ";
                                                        }else{
                                                                result = service.deleteSynonym(((Synonym)object).getUuid(), null);
+                                                               errorMessage = "The synonym ";
                                                        }
                                                }
                                        } else if (object instanceof TeamOrPersonBase){
                                                IAgentService service = controller.getAgentService();
                                                //TeamOrPersonBase teamOrPerson = (TeamOrPersonBase)service.load(((TeamOrPersonBase) object).getUuid());
                                                result = service.delete(((TeamOrPersonBase)object).getUuid());
+                                               errorMessage = "The team or person ";
                                        }
                                } catch (Exception e){
                                        MessagingUtils.errorDialog("Exception occured. Delete not possible", getClass(), e.getMessage(), TaxeditorBulkeditorPlugin.PLUGIN_ID, null, true);
                                }
                                if (result.isError() || result.isAbort()){
                                        if (!result.getExceptions().isEmpty()) {
-                                               String message = null;
+                                               List<String> messages = new ArrayList<String>();
                                                int i = result.getExceptions().size();
                                                for (Exception e:result.getExceptions()){
-                                                       i--;
-                                                       message+= e.getMessage();
-                                                       if (i>0){
-                                                               message+= ", ";
-                                                       }
+                                                       messages.add(e.getMessage());
                                                }
+                                               errorMessage += "could not be deleted.";
 
-
-                                               MessagingUtils.messageDialog("Delete not possible", getClass(), result.getExceptions().toString(), null);
+                                               DeleteResultMessagingUtils.messageDialogWithDetails(result,errorMessage, TaxeditorBulkeditorPlugin.PLUGIN_ID);
                                        }else{
                                                MessagingUtils.messageDialog("Delete not possible", getClass(), "The object could not be deleted. An exception occured.", null);
                                        }
@@ -154,7 +163,13 @@ public class DeleteHandler extends AbstractHandler {
                                if (result.isOk() ){
                                        ((BulkEditor) editor).removeAnnotatedLine(annotation);
                                        if(result.getUpdatedObjects().size() != 0 || !result.getExceptions().isEmpty()){
-                                               MessagingUtils.informationDialog("Delete successfull", "The object is deleted but there are updated objects: " + result.toString());
+                                           List<String> messages = new ArrayList<String>();
+                        int i = result.getExceptions().size();
+                        for (Exception e:result.getExceptions()){
+                            messages.add(e.getMessage());
+                        }
+                                           errorMessage += "was deleted but there where updated objects";
+                                           DeleteResultMessagingUtils.messageDialogWithDetails(result, errorMessage, TaxeditorBulkeditorPlugin.PLUGIN_ID);
                                        }
 
                                }
index c4c7854749c2c204e9b9d83d8cfec3b16ae8a917..cff075cc25788937175a05579a6445730732f74a 100644 (file)
@@ -148,7 +148,7 @@ public class AgentEditorInput extends AbstractBulkEditorInput<TeamOrPersonBase>
        @Override
        public TeamOrPersonBase save(TeamOrPersonBase entity) {
            if(CdmStore.getCurrentSessionManager().isRemoting()) {
-               return (TeamOrPersonBase) CdmStore.getService(IAgentService.class).merge(entity);
+               return (TeamOrPersonBase) CdmStore.getService(IAgentService.class).merge(entity, true);
            } else {
                CdmStore.getService(IAgentService.class).saveOrUpdate(entity) ;
                return entity;
index 1ec68333958a42b6fe3c518f45d7e3b0ffe25a85..6e44e52f6837dfd71e54852649148e4c3695ab65 100644 (file)
@@ -63,7 +63,7 @@ public class GroupEditorInput extends AbstractBulkEditorInput<Group> {
        @Override
        public Group save(Group entity) {
            if(CdmStore.getCurrentSessionManager().isRemoting()) {
-               return CdmStore.getService(IGroupService.class).merge(entity) ;
+               return CdmStore.getService(IGroupService.class).merge(entity, true) ;
            } else {
                CdmStore.getService(IGroupService.class).saveOrUpdate(entity);
                return entity;
index 2763b2f634f71e56540df838364ad4a38ea31460..8b56ea1a8c2e0399e99bd2ea15f7d464f2c71cb8 100644 (file)
@@ -119,7 +119,7 @@ public class NameEditorInput extends AbstractBulkEditorInput<TaxonNameBase> {
        @Override
     public TaxonNameBase save(TaxonNameBase entity) {
            if(CdmStore.getCurrentSessionManager().isRemoting()) {
-               return CdmStore.getService(INameService.class).merge(entity) ;
+               return CdmStore.getService(INameService.class).merge(entity, true) ;
            } else {
                CdmStore.getService(INameService.class).saveOrUpdate(entity);
                return entity;
index 1e66ad04702b96ff4d0664ef703bddefdd71a489..e219a500f5742ab117107a819ad8e06147729950 100644 (file)
@@ -138,7 +138,7 @@ public class OccurrenceEditorInput extends AbstractBulkEditorInput<SpecimenOrObs
        @Override
     public SpecimenOrObservationBase<IIdentifiableEntityCacheStrategy> save(SpecimenOrObservationBase entity) {
            if(CdmStore.getCurrentSessionManager().isRemoting()) {
-               return CdmStore.getService(IOccurrenceService.class).merge(entity) ;
+               return CdmStore.getService(IOccurrenceService.class).merge(entity, true) ;
            } else {
                CdmStore.getService(IOccurrenceService.class).save(entity);
                return entity;
index ea8598b67b1742711062f184bf8c071be87bbecd..32df06a57bba415052508f4c43776c4341b41e0f 100644 (file)
@@ -140,7 +140,7 @@ public class ReferenceEditorInput extends AbstractBulkEditorInput<Reference> {
        @Override
     public Reference save(Reference entity) {
            if(CdmStore.getCurrentSessionManager().isRemoting()) {
-               return CdmStore.getService(IReferenceService.class).merge(entity);
+               return CdmStore.getService(IReferenceService.class).merge(entity, true);
            } else {
                CdmStore.getService(IReferenceService.class).saveOrUpdate(entity);
                return entity;
index 1ce4878383e72f4dd9cd266a448669bc6fa51eac..4f8473544da1aafee7478afb87b8e45248a73b78 100644 (file)
@@ -72,7 +72,7 @@ public class TaxonEditorInput extends AbstractBulkEditorInput<TaxonBase>{
        @Override\r
        public TaxonBase save(TaxonBase entity) {\r
            if(CdmStore.getCurrentSessionManager().isRemoting()) {\r
-               return CdmStore.getService(ITaxonService.class).merge(entity);\r
+               return CdmStore.getService(ITaxonService.class).merge(entity, true);\r
            } else {\r
                CdmStore.getService(ITaxonService.class).saveOrUpdate(entity);\r
                return entity;\r
index e9469eca101555416640a607d1cbfdbeb6d9e92d..bcbff535c0bf5d4714358ab9d172089b4df89f10 100644 (file)
@@ -63,7 +63,7 @@ public class UserEditorInput extends AbstractBulkEditorInput<User> {
        @Override
        public User save(User entity) {
            if(CdmStore.getCurrentSessionManager().isRemoting()) {
-               return CdmStore.getService(IUserService.class).merge(entity);
+               return CdmStore.getService(IUserService.class).merge(entity, true);
            } else {
                CdmStore.getService(IUserService.class).saveOrUpdate(entity);
                return entity;
index 0cb1a8519ad0561c526984e780b99dbdef0b81ed..12b2ef19f297c8d11c6643d6379b60ceab99f0dc 100644 (file)
@@ -57,6 +57,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 import eu.etaxonomy.taxeditor.model.DescriptionHelper;
 import eu.etaxonomy.taxeditor.model.LineSelection;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
 
@@ -78,6 +79,11 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
 
        private String referencedObjectTitleCache;
        private ConversationHolder conversation;
+       private ICdmEntitySession cdmEntitySession;
+
+       public ReferencingObjectsView() {
+           cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
+       }
 
        /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createViewer(org.eclipse.swt.widgets.Composite)
@@ -149,6 +155,10 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
                viewer.setColumnProperties(titles);
        }
 
+       @Override
+       public void setFocus() {
+           cdmEntitySession.bind();
+       }
        /**
         * <p>updateReferencingObjects</p>
         *
@@ -171,9 +181,12 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
                                        @Override
                                        public void run() {
                                                if (entityUUID != null){
-
+                                                   ICdmEntitySession previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
+                                                   cdmEntitySession.bind();
                                                        List<CdmBase> referencingObjects = getReferencingObjects(entityUUID, objectClass);
-
+                                                       if(previousCdmEntitySession != null) {
+                                                           previousCdmEntitySession.bind();
+                                                       }
                                                        updateView(referencingObjects);
 
                                                }
@@ -313,6 +326,7 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
                conversation.close();
                selectionService.removePostSelectionListener(this);
                selectionService.removeSelectionListener(this);
+               cdmEntitySession.dispose();
                super.dispose();
 
        }
index 2c90c55b7fac2e52dd5cfe3000d8ccf23e795b91..1251d3325c3edd00e8a72c9de0dc9b36e54ce826 100644 (file)
@@ -20,7 +20,9 @@ import eu.etaxonomy.cdm.api.service.ICommonService;
 import eu.etaxonomy.cdm.api.service.IService;
 import eu.etaxonomy.cdm.api.service.ITestService;
 import eu.etaxonomy.cdm.io.service.IIOService;
+import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.taxeditor.service.ICachedCommonService;
+import eu.etaxonomy.taxeditor.session.DefaultNewEntityListener;
 
 /**
  * @author cmathew
@@ -43,6 +45,7 @@ public class CdmApplicationState {
     public static CdmApplicationState getInstance() {
         if(cdmApplicationState == null) {
             cdmApplicationState = new CdmApplicationState();
+            CdmBase.setNewEntityListener(new DefaultNewEntityListener());
         }
 
         return cdmApplicationState;
index d92bdad5577d0abf554fe0730bbf2c54577dc058..7e67ecd227ce679d42b066cfede1ec5e66f9c27b 100644 (file)
@@ -11,10 +11,12 @@ package eu.etaxonomy.taxeditor.remoting.cache;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheManager;
@@ -63,7 +65,7 @@ public class CdmTransientEntityCacher implements ICdmCacher {
 
     private final CacheLoader cacheLoader;
 
-
+    private final Map<UUID, CdmBase> newEntitiesMap = new HashMap<UUID, CdmBase>();
 
     public CdmTransientEntityCacher(String cacheId, ICdmEntitySessionManager cdmEntitySessionManager) {
         this.cacheId = cacheId;
@@ -75,6 +77,7 @@ public class CdmTransientEntityCacher implements ICdmCacher {
         this.cdmEntitySessionManager = cdmEntitySessionManager;
 
         cacheLoader = new CacheLoader(this);
+
     }
 
     public CdmTransientEntityCacher(Object sessionOwner, ICdmEntitySessionManager cdmEntitySessionManager) {
@@ -92,7 +95,7 @@ public class CdmTransientEntityCacher implements ICdmCacher {
      */
     private CacheConfiguration getEntityCacheConfiguration(String cacheId) {
         SizeOfPolicyConfiguration sizeOfConfig = new SizeOfPolicyConfiguration();
-        sizeOfConfig.setMaxDepth(10000);
+        sizeOfConfig.setMaxDepth(100);
         sizeOfConfig.setMaxDepthExceededBehavior("abort");
 
         return new CacheConfiguration(cacheId, 0)
@@ -186,7 +189,11 @@ public class CdmTransientEntityCacher implements ICdmCacher {
     }
 
 
-
+    public void addNewEntity(CdmBase newEntity) {
+        if(newEntity != null && newEntity.getId() == 0 && newEntity.getUuid() != null) {
+            newEntitiesMap.put(newEntity.getUuid(), newEntity);
+        }
+    }
 
     @Override
     public void put(CdmBase cdmEntity) {
@@ -200,9 +207,16 @@ public class CdmTransientEntityCacher implements ICdmCacher {
 
         cachedCdmEntity = getFromCache(id);
         if(cachedCdmEntity == null) {
-            getCache().put(new Element(id, cdmEntity));
-            cdmEntity.initListener();
-            logger.info(" - object of type " + cdmEntity.getClass().getName() + " with id " + cdmEntity.getId() + " put in cache");
+            CdmBase cdmEntityToCache = cdmEntity;
+            CdmBase newEntity = newEntitiesMap.get(cdmEntity.getUuid());
+            if(newEntity != null) {
+                newEntity.setId(cdmEntity.getId());
+                cdmEntityToCache = newEntity;
+            }
+            getCache().put(new Element(id, cdmEntityToCache));
+            cdmEntityToCache.initListener();
+            newEntitiesMap.remove(cdmEntity.getUuid());
+            logger.info(" - object of type " + cdmEntityToCache.getClass().getName() + " with id " + cdmEntityToCache.getId() + " put in cache");
             return;
         }
         logger.info(" - object of type " + cdmEntity.getClass().getName() + " with id " + cdmEntity.getId() + " already exists");
@@ -274,6 +288,7 @@ public class CdmTransientEntityCacher implements ICdmCacher {
     public void dispose() {
         CacheManager.create().removeCache(cache.getName());
         cache.dispose();
+        newEntitiesMap.clear();
 
     }
 
index a8cc4ecd9c6ea218040a1a87bf80ec8e7e9a8375..85c7d33bbaa76f044a2c33ce694ff5f3f2e94760 100644 (file)
@@ -64,6 +64,7 @@ public class CdmEntitySession implements ICdmEntitySession  {
 
 
 
+
     /* (non-Javadoc)
      * @see eu.etaxonomy.taxeditor.session.ICdmEntitySession#load(java.lang.Object, boolean)
      */
@@ -246,7 +247,7 @@ public class CdmEntitySession implements ICdmEntitySession  {
      */
     @Override
     public <T extends CdmBase> T remoteUpdate(IService<T> service, T cdmBase) {
-        T mergedCdmBase = service.merge(cdmBase);
+        T mergedCdmBase = service.merge(cdmBase, true);
         return mergedCdmBase;
     }
 
@@ -299,4 +300,12 @@ public class CdmEntitySession implements ICdmEntitySession  {
         return propertyPathsMap.get(obj);
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySession#addNewCdmEntity(eu.etaxonomy.cdm.model.common.CdmBase)
+     */
+    @Override
+    public void addNewCdmEntity(CdmBase newEntity) {
+        cdmTransientEntityCacher.addNewEntity(newEntity);
+    }
+
 }
index 5344a4800ace2dd333855ecfaba04f0ad9e371ee..1e5d7d889b77c3f3584158c840f53ed8fd395218 100644 (file)
@@ -62,12 +62,10 @@ public class CdmEntitySessionManager implements ICdmEntitySessionManager {
     }
 
     @Override
-    public ICdmEntitySession bindNullSession(ICdmEntitySessionEnabled sessionOwner) {
+    public ICdmEntitySession bindNullSession() {
 
         if(nullSession == null) {
-            nullSession = new NullSession(sessionOwner, this);
-        } else {
-            nullSession.setOwner(sessionOwner);
+            nullSession = new NullSession(null, this);
         }
 
         setActiveSession(nullSession);
@@ -188,6 +186,7 @@ public class CdmEntitySessionManager implements ICdmEntitySessionManager {
             setActiveSession(null);
         }
         ownerSessionMap.remove(owner);
+        notifyObservers();
 
     }
 
@@ -197,9 +196,13 @@ public class CdmEntitySessionManager implements ICdmEntitySessionManager {
         if(session != null) {
             session.dispose();
         }
-        notifyObservers();
+        if(nullSession != null && nullSession.getOwner() == owner) {
+            nullSession = null;
+        }
+
     }
 
+
     @Override
     public void disposeAll() {
         Set<ICdmEntitySessionEnabled> owners =
@@ -210,11 +213,12 @@ public class CdmEntitySessionManager implements ICdmEntitySessionManager {
                 session.dispose();
             }
         }
-        notifyObservers();
+
     }
 
     void addToOwnerSessionMap(ICdmEntitySessionEnabled owner, ICdmEntitySession session) {
         ownerSessionMap.put(owner, session);
+        notifyObservers();
     }
 
     /* (non-Javadoc)
diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/DefaultNewEntityListener.java b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/DefaultNewEntityListener.java
new file mode 100644 (file)
index 0000000..aaf23e9
--- /dev/null
@@ -0,0 +1,39 @@
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.session;
+
+import org.apache.log4j.Logger;
+
+import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController;
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
+import eu.etaxonomy.cdm.model.NewEntityListener;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+
+/**
+ * @author cmathew
+ * @date 30 Sep 2015
+ *
+ */
+public class DefaultNewEntityListener implements NewEntityListener {
+
+    private static final Logger logger = Logger.getLogger(DefaultNewEntityListener.class);
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.model.NewEntityListener#onCreate(eu.etaxonomy.cdm.model.common.CdmBase)
+     */
+    @Override
+    public void onCreate(CdmBase cdmBase) {
+        logger.warn("New Entity created : " + cdmBase);
+        if(CdmApplicationState.getCurrentAppConfig() instanceof CdmApplicationRemoteController){
+            ((CdmApplicationRemoteController)CdmApplicationState.getCurrentAppConfig()).getCdmEntitySessionManager().getActiveSession().addNewCdmEntity(cdmBase);
+        }
+    }
+
+}
index c43e88d43ea75b06633584a860b92d8da075c4a1..22388ed7e5b87827be47628f9c26375c4af6b586 100644 (file)
@@ -88,4 +88,6 @@ public interface ICdmEntitySession {
      */
     public List<String> getPropertyPaths(Object obj);
 
+    public void addNewCdmEntity(CdmBase newEntity);
+
 }
\ No newline at end of file
index 27e23a02f87ee80b1374fca377bd079f29be4ac7..ea2c7867b79a2b111101adf08654b173e3e996de 100644 (file)
@@ -13,7 +13,7 @@ public interface ICdmEntitySessionManager {
      * @param sessionOwner
      * @return
      */
-    public ICdmEntitySession bindNullSession(ICdmEntitySessionEnabled sessionOwner);
+    public ICdmEntitySession bindNullSession();
 
 
        public abstract void bind(ICdmEntitySessionEnabled sessionOwner);
@@ -72,4 +72,5 @@ public interface ICdmEntitySessionManager {
      */
     public ICdmEntitySession getNullSession();
 
+
 }
\ No newline at end of file
index eed1b494db784b984f47ab223988eaeba8fcef0c..65b8e7c245481d78c085db7d91c2dbaa73f35943 100644 (file)
@@ -141,7 +141,7 @@ public class NullSession implements ICdmEntitySession {
      */
     @Override
     public void bind() {
-        cdmEntitySessionManager.bindNullSession(sessionOwner);
+        cdmEntitySessionManager.bindNullSession();
     }
 
     /* (non-Javadoc)
@@ -177,7 +177,7 @@ public class NullSession implements ICdmEntitySession {
      */
     @Override
     public <T extends CdmBase> T remoteUpdate(IService<T> service, T cdmBase) {
-        T mergedCdmBase = service.merge(cdmBase);
+        T mergedCdmBase = service.merge(cdmBase, true);
         return mergedCdmBase;
     }
 
@@ -209,4 +209,13 @@ public class NullSession implements ICdmEntitySession {
         return propertyPathsMap.get(obj);
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySession#addNewCdmEntity(eu.etaxonomy.cdm.model.common.CdmBase)
+     */
+    @Override
+    public void addNewCdmEntity(CdmBase newEntity) {
+        // TODO Auto-generated method stub
+
+    }
+
 }
index 5db78a9f77f7dedbab8065107db25d89cd372a1a..ef72bfa021c366c021aeb87b850aba79d5122646 100644 (file)
@@ -198,5 +198,14 @@ public class MockCdmEntitySession implements ICdmEntitySession  {
         return null;
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySession#addNewCdmEntity(eu.etaxonomy.cdm.model.common.CdmBase)
+     */
+    @Override
+    public void addNewCdmEntity(CdmBase newEntity) {
+        // TODO Auto-generated method stub
+
+    }
+
 
 }
index 081cffbcfe838ca3a583f02d36c93a72a192851b..32467f377a8c2fd8cc59056a683e893eae137f4f 100644 (file)
@@ -122,7 +122,7 @@ public class MockCdmEntitySessionManager implements ICdmEntitySessionManager {
      * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager#bindNullSession(eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled)
      */
     @Override
-    public ICdmEntitySession bindNullSession(ICdmEntitySessionEnabled sessionOwner) {
+    public ICdmEntitySession bindNullSession() {
         return new MockCdmEntitySession();
     }
 
@@ -134,6 +134,4 @@ public class MockCdmEntitySessionManager implements ICdmEntitySessionManager {
         return new MockCdmEntitySession();
     }
 
-
-
 }
index 9b2fa831929c6d92132a811b56644a56a981be59..6b0f9e75115fe42e7948f56559e5cadc3a893f50 100644 (file)
@@ -1,8 +1,8 @@
 CreateDerivateContextMenu_ADD=Add...
 CreateDerivateContextMenu_DNA_SAMPLE=DNA Sample
 CreateDerivateContextMenu_MEDIA=Media...
-CreateDerivateContextMenu_MEDIA_EXISTING=Media Specimen with existing media
-CreateDerivateContextMenu_MEDIA_SPECIMEN=Media Specimen
+CreateDerivateContextMenu_MEDIA_EXISTING=Use existing media item
+CreateDerivateContextMenu_MEDIA_SPECIMEN=Media item
 CreateDerivateContextMenu_NO_CHILD_DERIVATE=No child derivatives
 CreateDerivateContextMenu_SEQUENCE=Consensus Sequence
 CreateDerivateContextMenu_SINGLE_READ=Single Read
index 319f600b5bc278e563890f5044d48229954375c6..e18d567305d6b44fa5f3daf5488d3df50d415854 100644 (file)
@@ -1,8 +1,8 @@
 CreateDerivateContextMenu_ADD=Hinzufügen...
 CreateDerivateContextMenu_DNA_SAMPLE=DNA Probe
 CreateDerivateContextMenu_MEDIA=Media...
-CreateDerivateContextMenu_MEDIA_EXISTING=Medienbeleg aus vorhandender Mediendatei
-CreateDerivateContextMenu_MEDIA_SPECIMEN=Medienbeleg
+CreateDerivateContextMenu_MEDIA_EXISTING=Vorhandendes Medienobjekt verwenden
+CreateDerivateContextMenu_MEDIA_SPECIMEN=Medienobjekt
 CreateDerivateContextMenu_NO_CHILD_DERIVATE=Keine Kind-Derivate
 CreateDerivateContextMenu_SEQUENCE=Konsensussequenz
 CreateDerivateContextMenu_SINGLE_READ=Single Read
index 77de015f12235de15deff65670b805486e22df27..59fa37378eb43b00b039cb4957041edb1a978fd3 100644 (file)
@@ -158,7 +158,7 @@ public class CdmAuthorityEditorInput extends CdmEntitySessionInput implements IE
     @Override
     public void merge() {
         if(CdmStore.getCurrentSessionManager().isRemoting()) {
-            group = CdmStore.getService(IGroupService.class).merge(group);
+            group = CdmStore.getService(IGroupService.class).merge(group, true);
         }
     }
 }
index fc872f5dea5f6b4ccedf9f6c84e69555d490520a..c128ec4fd38754e4a3fdf87f54070270590e0709 100644 (file)
@@ -800,4 +800,12 @@ public class TransientAgentService implements IAgentService {
         return defaultService.merge(arg0, arg1);
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.service.IService#merge(java.util.List, boolean)
+     */
+    @Override
+    public List<AgentBase> merge(List<AgentBase> arg0, boolean arg1) {
+        return defaultService.merge(arg0, arg1);
+    }
+
 }
index 747d9ebae71b6733426d43d524bb94e77908b8c3..426d05d1cc89a583a319d54356c8df334192f791 100644 (file)
@@ -958,6 +958,14 @@ public class TransientClassificationService implements IClassificationService {
         return defaultService.merge(arg0, arg1);
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.service.IService#merge(java.util.List, boolean)
+     */
+    @Override
+    public List<Classification> merge(List<Classification> arg0, boolean arg1) {
+        return defaultService.merge(arg0, arg1);
+    }
+
 
 
 }
index ba585ea97c72b876d6312a9b5af056ff11137c87..6ff656705aba346c2feb9f83d4d4ebcfe11bf851 100644 (file)
@@ -734,4 +734,12 @@ public class TransientCollectionService implements ICollectionService {
         return defaultService.merge(arg0, arg1);
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.service.IService#merge(java.util.List, boolean)
+     */
+    @Override
+    public List<Collection> merge(List<Collection> arg0, boolean arg1) {
+        return defaultService.merge(arg0, arg1);
+    }
+
 }
index 52f3d9ff066a166653b97a4f19c4761a36be8af5..eed62fa607605f0927732ae7d453c2d7e668b28f 100644 (file)
@@ -1205,12 +1205,23 @@ public class TransientDescriptionService implements IDescriptionService {
     }
 
     /* (non-Javadoc)
+
      * @see eu.etaxonomy.cdm.api.service.IDescriptionService#moveTaxonDescription(java.util.UUID, java.util.UUID)
      */
     @Override
     public UpdateResult moveTaxonDescription(UUID descriptionUuid, UUID targetTaxonUuid) {
-
         return defaultService.moveTaxonDescription(descriptionUuid, targetTaxonUuid);
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.service.IService#merge(java.util.List, boolean)
+     */
+    @Override
+    public List<DescriptionBase> merge(List<DescriptionBase> arg0, boolean arg1) {
+
+        return defaultService.merge(arg0, arg1);
+    }
+
+
+
 }
index 329dd9e17c540253f21864b28b11ccaec062d1a2..6e112f58e3e09d0fe116795e0433fa40d74fe17c 100644 (file)
@@ -1205,4 +1205,12 @@ public class TransientNameService implements INameService {
     public TaxonNameBase merge(TaxonNameBase arg0, boolean arg1) {
         return defaultService.merge(arg0, arg1);
     }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.service.IService#merge(java.util.List, boolean)
+     */
+    @Override
+    public List<TaxonNameBase> merge(List<TaxonNameBase> arg0, boolean arg1) {
+        return defaultService.merge(arg0, arg1);
+    }
 }
index 81b7a980b672eea7bf4ca3d6e429d563bbdebca7..dc6d6efb2f252e41df6ee500607a4195de0cbbdd 100644 (file)
@@ -1061,4 +1061,19 @@ public class TransientOccurenceService implements IOccurrenceService {
         return defaultService.merge(arg0, arg1);
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.service.IService#merge(java.util.List, boolean)
+     */
+    @Override
+    public List<SpecimenOrObservationBase> merge(List<SpecimenOrObservationBase> arg0, boolean arg1) {
+        return defaultService.merge(arg0, arg1);
+    }
+
+    @Override
+    public Pager<Media> getMediainHierarchy(SpecimenOrObservationBase arg0, Integer arg1, Integer arg2,
+            List<String> arg3) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }
index 4e9f29d564a09eaa3520e98db6fbc6ad6a968543..48192e404e2e397c06d45363884d4a57f2ff1e58 100644 (file)
@@ -741,4 +741,12 @@ public class TransientReferenceService implements IReferenceService {
     public Reference merge(Reference arg0, boolean arg1) {
         return defaultService.merge(arg0, arg1);
     }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.service.IService#merge(java.util.List, boolean)
+     */
+    @Override
+    public List<Reference> merge(List<Reference> arg0, boolean arg1) {
+        return defaultService.merge(arg0, arg1);
+    }
 }
index 7819a8cb966339dea6ff858ca33e0280caf6672d..b79f17f12c11885f46a1f2b568193e5e4ce63ef3 100644 (file)
@@ -1533,4 +1533,12 @@ public class TransientTaxonService implements ITaxonService {
         return defaultService.merge(arg0, arg1);
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.service.IService#merge(java.util.List, boolean)
+     */
+    @Override
+    public List<TaxonBase> merge(List<TaxonBase> arg0, boolean arg1) {
+        return defaultService.merge(arg0, arg1);
+    }
+
 }
index 40772762b22629c77b1255a95bbad34acb6f587a..3df4f25297eb190ccc22a895761e60727e351184 100644 (file)
@@ -911,4 +911,12 @@ public class TransientTermService implements ITermService {
     public DefinedTermBase merge(DefinedTermBase arg0, boolean arg1) {
         return defaultService.merge(arg0, arg1);
     }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.service.IService#merge(java.util.List, boolean)
+     */
+    @Override
+    public List<DefinedTermBase> merge(List<DefinedTermBase> arg0, boolean arg1) {
+        return defaultService.merge(arg0, arg1);
+    }
 }
index a2a7982feb3aac5fc414056f13775fc0d424a86d..f0d3afe2dfaab718431fceff60fec1ca0dc56a84 100644 (file)
@@ -238,7 +238,7 @@ public class DerivateViewEditorInput extends CdmEntitySessionInput implements IE
     @Override
     public void merge() {
         if(CdmStore.getCurrentSessionManager().isRemoting()) {
-            List<SpecimenOrObservationBase> mergedEntities = CdmApplicationState.getCurrentAppConfig().getOccurrenceService().merge(new ArrayList(getRootEntities()));
+            List<SpecimenOrObservationBase> mergedEntities = CdmApplicationState.getCurrentAppConfig().getOccurrenceService().merge(new ArrayList(getRootEntities()), true);
         }
 
     }
index a491a7abfcbab933ae08c9684d0719cbfe129526..8b45cb6f7ccd035c337281388b1a3ac9b125cf03 100644 (file)
@@ -127,29 +127,33 @@ public class CreateDerivateContextMenu extends CompoundContributionItem {
                 public void widgetSelected(SelectionEvent e) {
                     //select media
                     Media media = MediaSelectionDialog.select(AbstractUtility.getShell(), null, null);
-                    //create MediaSpecimen
-                    MediaSpecimen mediaSpecimen = MediaSpecimen.NewInstance(specimenType);
-                    mediaSpecimen.setMediaSpecimen(media);
-
-                    //attach to parent
-                    if(selectedNode.getValue() instanceof SpecimenOrObservationBase){
-                        SpecimenOrObservationBase<?> specimenOrObservationBase = (SpecimenOrObservationBase<?>)selectedNode.getValue();
-
-                        specimenOrObservationBase.addDerivationEvent(DerivationEvent.NewSimpleInstance(specimenOrObservationBase, mediaSpecimen, derivationEventType));
-                        mediaSpecimen.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
-                        mediaSpecimen.getTitleCache(); //update title cache
-                        CdmStore.getService(IOccurrenceService.class).merge(specimenOrObservationBase);
-                    }
+                    if(media!=null){
+                        //create MediaSpecimen
+                        MediaSpecimen mediaSpecimen = MediaSpecimen.NewInstance(specimenType);
+                        mediaSpecimen.setMediaSpecimen(media);
 
-                    //refresh view
-                    DerivateView derivateView = null;
-                    if(AbstractUtility.getActivePart() instanceof DerivateView){
-                        derivateView = (DerivateView) AbstractUtility.getActivePart();
-                    }
-                    if(derivateView!=null){
+                        //attach to parent
+                        if(selectedNode.getValue() instanceof SpecimenOrObservationBase){
+                            SpecimenOrObservationBase<?> specimenOrObservationBase = (SpecimenOrObservationBase<?>)selectedNode.getValue();
+
+                            specimenOrObservationBase.addDerivationEvent(DerivationEvent.NewSimpleInstance(specimenOrObservationBase, mediaSpecimen, derivationEventType));
+                            mediaSpecimen.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
+                            mediaSpecimen.getTitleCache(); //update title cache
+                            if(CdmStore.getCurrentSessionManager().isRemoting()) {
+                                CdmStore.getService(IOccurrenceService.class).merge(specimenOrObservationBase, true);
+                            }
+                        }
 
-                        derivateView.getConversationHolder().commit();
-                        derivateView.refreshTree(mediaSpecimen);
+                        //refresh view
+                        DerivateView derivateView = null;
+                        if(AbstractUtility.getActivePart() instanceof DerivateView){
+                            derivateView = (DerivateView) AbstractUtility.getActivePart();
+                        }
+                        if(derivateView!=null){
+
+                            derivateView.getConversationHolder().commit();
+                            derivateView.refreshTree(mediaSpecimen);
+                        }
                     }
                 }
             });
@@ -202,15 +206,19 @@ public class CreateDerivateContextMenu extends CompoundContributionItem {
                     Sequence newInstance = Sequence.NewInstance(dnaSample, "", 0); //$NON-NLS-1$
                     createdElement = newInstance;
                 }
-                CdmStore.getService(IOccurrenceService.class).merge((SpecimenOrObservationBase) selectedDerivate);
+                if(CdmStore.getCurrentSessionManager().isRemoting()) {
+                    CdmStore.getService(IOccurrenceService.class).merge((SpecimenOrObservationBase) selectedDerivate, true);
+                }
             }
             else if(selectedDerivate instanceof Sequence){
                 SingleRead newInstance = SingleRead.NewInstance();
                 ((Sequence) selectedDerivate).addSingleRead(newInstance);
                 createdElement = newInstance;
-                CdmApplicationState.getCurrentAppConfig().getSequenceService().merge((Sequence)selectedDerivate);
+                if(CdmStore.getCurrentSessionManager().isRemoting()) {
+                    CdmApplicationState.getCurrentAppConfig().getSequenceService().merge((Sequence)selectedDerivate, true);
+                }
             }
-            else if(selectedDerivate instanceof SpecimenOrObservationBase && DerivedUnit.class.isAssignableFrom(childClass)){
+            if(selectedDerivate instanceof SpecimenOrObservationBase && DerivedUnit.class.isAssignableFrom(childClass)){
                 SpecimenOrObservationBase<?> specimenOrObservationBase = (SpecimenOrObservationBase<?>)selectedDerivate;
                 DerivedUnit derivedUnit;
                 if(childClass.equals(DnaSample.class)){
@@ -234,12 +242,13 @@ public class CreateDerivateContextMenu extends CompoundContributionItem {
                 derivedUnit.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
                 derivedUnit.getTitleCache(); //update title cache
                 createdElement = derivedUnit;
-                CdmStore.getService(IOccurrenceService.class).merge((SpecimenOrObservationBase) selectedDerivate);
+                if(CdmStore.getCurrentSessionManager().isRemoting()) {
+                    CdmStore.getService(IOccurrenceService.class).merge((SpecimenOrObservationBase) selectedDerivate, true);
+                }
             }
 
             //refresh view
             if(derivateView!=null){
-                //CdmStore.getService(IOccurrenceService.class).merge((SpecimenOrObservationBase) selectedDerivate);
                 derivateView.getConversationHolder().commit();
                 derivateView.refreshTree(createdElement);
             }
index 0c9d862f78c73f7ba33a33f2de283b3ca73338d7..1a04b047cc568120fd57bf35534136d4dc6fd4ea 100644 (file)
 
 package eu.etaxonomy.taxeditor.editor.view.descriptive.operation;
 
+import org.apache.commons.lang.StringUtils;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.commands.operations.IUndoContext;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 
+import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController;
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.api.service.IDescriptionService;
+import eu.etaxonomy.cdm.model.common.Annotation;
+import eu.etaxonomy.cdm.model.common.AnnotationType;
+import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
@@ -72,7 +79,7 @@ public class MoveDescriptionToOtherTaxonOperation extends
                monitor.worked(20);
                bind();
 
-               /*String moveMessage = String.format("Description moved from %s", EditorUtil.getActiveMultiPageTaxonEditor().getTaxon());
+               String moveMessage = String.format("Description moved from %s", EditorUtil.getActiveMultiPageTaxonEditor().getTaxon());
                if(description.isProtectedTitleCache()){
                        String separator = "";
                        if(!StringUtils.isBlank(description.getTitleCache())){
@@ -84,9 +91,13 @@ public class MoveDescriptionToOtherTaxonOperation extends
                annotation.setAnnotationType(AnnotationType.TECHNICAL());
                description.addAnnotation(annotation);
                newAcceptedTaxonNode.getTaxon().addDescription(description);
-               CdmStore.getService(IDescriptionService.class).saveOrUpdate(description);*/
+               if (CdmApplicationState.getCurrentAppConfig() instanceof CdmApplicationRemoteController) {
+            CdmStore.getService(IDescriptionService.class).merge(description);
+        } else {
+            CdmStore.getService(IDescriptionService.class).saveOrUpdate(description);
+        }
 
-               CdmStore.getService(IDescriptionService.class).moveTaxonDescription(description.getUuid(), newAcceptedTaxonNode.getTaxon().getUuid());
+       //      CdmStore.getService(IDescriptionService.class).moveTaxonDescription(description.getUuid(), newAcceptedTaxonNode.getTaxon().getUuid());
                monitor.worked(40);
 
                return postExecute(description);
index 35b0a2df6a3f18915452ea3dcd99c7995a5e3029..4934d9a37d4394c85670d8b5f6d792e22ecfeaea 100644 (file)
@@ -371,6 +371,7 @@ public class AlignmentEditor extends EditorPart {
 
             //re-loading sequence to avoid session conflicts
                Sequence sequenceNode = CdmStore.getService(ISequenceService.class).load(((AlignmentEditorInput)getEditorInput()).getSequenceNodeUuid());
+               ((AlignmentEditorInput)getEditorInput()).setSequenceNode(sequenceNode);
                StringAdapter stringProvider = new StringAdapter(getEditableConsensusArea().getAlignmentModel(), false);  // Throws an exception if a token has more than one character.
 
                // Write consensus sequence:
@@ -415,6 +416,7 @@ public class AlignmentEditor extends EditorPart {
             }
             monitor.worked(1);
 
+            ((AlignmentEditorInput)getEditorInput()).merge();
             // Commit the conversation and start a new transaction immediately:
             conversationHolder.commit(true);
             monitor.worked(1);
@@ -490,8 +492,13 @@ public class AlignmentEditor extends EditorPart {
         if(conversationHolder!=null){
             conversationHolder.bind();
         }
+        ((AlignmentEditorInput)getEditorInput()).bind();
     }
 
+    @Override
+    public void dispose() {
+        ((AlignmentEditorInput)getEditorInput()).dispose();
+    }
 
     public boolean isInsertMode() {
         return getAlignmentsContainer().getEditSettings().isInsert();
index b82362551ddcb2e537f800eb2d0c32ed0695b12d..4bc956e3c574047187657a788b2118005a810ed3 100644 (file)
 package eu.etaxonomy.taxeditor.molecular.editor;
 
 
+import java.util.Arrays;
+import java.util.List;
 import java.util.UUID;
 
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IPersistableElement;
 
+import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
+import eu.etaxonomy.cdm.model.molecular.Sequence;
+import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
 
 
 /**
@@ -23,16 +30,17 @@ import org.eclipse.ui.IPersistableElement;
  * @author Ben Stöver
  * @date 04.08.2014
  */
-public class AlignmentEditorInput implements IEditorInput {
+public class AlignmentEditorInput extends CdmEntitySessionInput implements IEditorInput {
     private static final String name = "AlignmentEditor";
 
 
     private final UUID sequenceNodeUuid;
-
+    private Sequence sequenceNode;
 
     public AlignmentEditorInput(UUID sequenceNodeUuid) {
-               super();
+        super(false);
                this.sequenceNodeUuid = sequenceNodeUuid;
+               initSession();
        }
 
 
@@ -135,4 +143,28 @@ public class AlignmentEditorInput implements IEditorInput {
         }
                return true;
        }
+
+
+       public void setSequenceNode(Sequence sequenceNode) {
+           this.sequenceNode = sequenceNode;
+       }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
+     */
+    @Override
+    public List<Sequence> getRootEntities() {
+        return Arrays.asList(sequenceNode);
+    }
+
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
+     */
+    @Override
+    public void merge() {
+        if(CdmStore.getCurrentSessionManager().isRemoting()) {
+            CdmStore.getService(ISequenceService.class).merge(sequenceNode, true);
+        }
+    }
 }
index d83a187cb3fb349a39a54d2ce709478ef7100f12..3c1622449a607285cf67c703adf7986b26447cc9 100644 (file)
@@ -161,7 +161,9 @@ public class DefinedTermEditor extends EditorPart implements IConversationEnable
        @Override\r
        public void doSave(IProgressMonitor monitor) {\r
                getConversationHolder().commit();\r
-               CdmStore.getService(IVocabularyService.class).merge(new ArrayList<TermVocabulary>(getRootEntities()));\r
+               if(CdmStore.getCurrentSessionManager().isRemoting()) {\r
+                   CdmStore.getService(IVocabularyService.class).merge(new ArrayList<TermVocabulary>(getRootEntities()), true);\r
+               }\r
                setDirty(false);\r
                getDefinedTermEditorInput().initialiseVocabularies();\r
                viewer.refresh();\r
index 3c4466647a4ad9405d9fb6d47ed03f01f9f6fe19..a39b9ff525836a4753f2ff3babfe259afd50dfa4 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
  * Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy 
+ * European Distributed Institute of Taxonomy
  * http://www.e-taxonomy.eu
- * 
+ *
  * The contents of this file are subject to the Mozilla Public License Version 1.1
  * See LICENSE.TXT at the top of this package for the full license terms.
  */
@@ -49,7 +49,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  * <p>
  * EditFeatureTreeWizardPage class.
  * </p>
- * 
+ *
  * @author n.hoffmann
  * @created Aug 5, 2010
  * @version 1.0
@@ -69,7 +69,7 @@ public class EditFeatureTreeWizardPage extends WizardPage implements
         * <p>
         * Constructor for EditFeatureTreeWizardPage.
         * </p>
-        * 
+        *
         * @param pageName
         *            a {@link java.lang.String} object.
         */
@@ -80,7 +80,7 @@ public class EditFeatureTreeWizardPage extends WizardPage implements
 
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see
         * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
         * .Composite)
@@ -153,7 +153,7 @@ public class EditFeatureTreeWizardPage extends WizardPage implements
         * <p>
         * setSelectedTree
         * </p>
-        * 
+        *
         * @param featureTree
         *            a {@link eu.etaxonomy.cdm.model.description.FeatureTree}
         *            object.
@@ -200,8 +200,11 @@ public class EditFeatureTreeWizardPage extends WizardPage implements
                                                .getAdditionalFeatures();
                                for (Feature feature : additionalFeatures) {
                                        FeatureNode child = FeatureNode.NewInstance(feature);
-                                       CdmStore.getService(IFeatureNodeService.class)
-                                                       .saveOrUpdate(child);
+                                       if(CdmStore.getCurrentSessionManager().isRemoting()) {
+                                           CdmStore.getService(IFeatureNodeService.class).merge(child, true);
+                                       } else {
+                                           CdmStore.getService(IFeatureNodeService.class).saveOrUpdate(child);
+                                       }
                                        parent.addChild(child);
                                }
                                viewer.refresh();
@@ -237,8 +240,9 @@ public class EditFeatureTreeWizardPage extends WizardPage implements
                 */
                @Override
                public void dragFinished(DragSourceEvent event) {
-                       if (!event.doit)
-                               return;
+                       if (!event.doit) {
+                return;
+            }
                        // if the featureNode was moved, remove it from the source viewer
                        if (event.detail == DND.DROP_MOVE) {
                                IStructuredSelection selection = (IStructuredSelection) viewer
index 24a7795afecaed2f557a64ebf55cac2976e0f693..d65ad420e94c6cb1c34220b7246246ccedccc893 100644 (file)
@@ -1,20 +1,26 @@
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
 
 package eu.etaxonomy.taxeditor.featuretree;
 
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
 import org.eclipse.jface.wizard.Wizard;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
 import eu.etaxonomy.cdm.model.description.FeatureTree;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
@@ -24,30 +30,35 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  * @created Aug 5, 2010
  * @version 1.0
  */
-public class FeatureTreeEditorWizard extends Wizard {
-       
+public class FeatureTreeEditorWizard extends Wizard implements ICdmEntitySessionEnabled {
+
        private SelectFeatureTreeWizardPage selectFeatureTreePage;
        private EditFeatureTreeWizardPage editFeatureTreePage;
-       
+
        private FeatureTree selectedFeatureTree;
 
        private ConversationHolder conversation;
-       
+       private ICdmEntitySession cdmEntitySession;
+       private ICdmEntitySession previousCdmEntitySession;
+
        /**
         * <p>Constructor for FeatureTreeEditorWizard.</p>
         */
        public FeatureTreeEditorWizard(){
                conversation = CdmStore.createConversation();
+               previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
+               cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
                setWindowTitle("Feature Tree Editor");
        }
-       
+
        /**
         * <p>addPages</p>
         */
-       public void addPages() {
+       @Override
+    public void addPages() {
                selectFeatureTreePage = new SelectFeatureTreeWizardPage("SELECT");
                addPage(selectFeatureTreePage);
-               
+
                editFeatureTreePage = new EditFeatureTreeWizardPage("EDIT");
                addPage(editFeatureTreePage);
        }
@@ -59,16 +70,34 @@ public class FeatureTreeEditorWizard extends Wizard {
        public boolean performFinish() {
                try{
                        if (selectedFeatureTree != null){
-                               CdmStore.getService(IFeatureTreeService.class).saveOrUpdate(selectedFeatureTree);
+                           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+                               CdmStore.getService(IFeatureTreeService.class).merge(selectedFeatureTree, true);
+                           } else {
+                               CdmStore.getService(IFeatureTreeService.class).saveOrUpdate(selectedFeatureTree);
+                           }
                        }
                        conversation.commit();
                }finally{
                        conversation.close();
+                       cdmEntitySession.dispose();
+                       if(previousCdmEntitySession != null) {
+                           previousCdmEntitySession.bind();
+                       }
                }
-               
+
                return true;
        }
 
+       /** {@inheritDoc} */
+    @Override
+    public boolean performCancel() {
+        cdmEntitySession.dispose();
+        if(previousCdmEntitySession != null) {
+            previousCdmEntitySession.bind();
+        }
+        return true;
+    }
+
        /**
         * <p>Setter for the field <code>selectedFeatureTree</code>.</p>
         *
@@ -87,5 +116,31 @@ public class FeatureTreeEditorWizard extends Wizard {
        public FeatureTree getSelectedFeatureTree() {
                return selectedFeatureTree;
        }
-       
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
+     */
+    @Override
+    public ICdmEntitySession getCdmEntitySession() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
+     */
+    @Override
+    public List<FeatureTree> getRootEntities() {
+        return Arrays.asList(selectedFeatureTree);
+    }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
+     */
+    @Override
+    public Map<Object, List<String>> getPropertyPathsMap() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DeleteResultMessagingUtils.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DeleteResultMessagingUtils.java
new file mode 100644 (file)
index 0000000..ef473c3
--- /dev/null
@@ -0,0 +1,53 @@
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+import eu.etaxonomy.cdm.api.service.DeleteResult;
+
+/**
+ * @author k.luther
+ * @date Oct 5, 2015
+ *
+ */
+public class DeleteResultMessagingUtils extends MessagingUtils {
+    /**
+     * Displays a message {@link org.eclipse.jface.dialogs.MessageDialog}.
+     *
+     * @param title
+     * @param source
+     * @param message
+     */
+    public static void messageDialogWithDetails(DeleteResult result, String message, String pluginId) {
+        if (result.isOk() && result.getExceptions().isEmpty()){
+            return;
+        }
+        List<String> details = new ArrayList<String>();
+        String title= "";
+
+        if (result.isOk() && result.getExceptions().size() > 0){
+            for (Exception e:result.getExceptions()){
+                details.add(e.getMessage());
+            }
+            title = "The delete was successfull.";
+        }
+        String stackTraceWithContext = getContextInfo(details);
+        CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, new Status(IStatus.ERROR, pluginId, null), stackTraceWithContext);
+        ced.open();
+
+
+
+    }
+}
index b316c2a0692e06056eb5f368d5a5206dbb07c898..36777e8ca31e1e9dbcf5e70aa73468a226b11902 100644 (file)
@@ -219,6 +219,19 @@ public class MessagingUtils {
         return stackTraceAndContextInfo.toString();
     }
 
+    public static String getContextInfo(List<String> contextInfo)  {
+        StringBuffer scontextInfoStringBuffer = new StringBuffer();
+
+
+        for(String infoItem : contextInfo) {
+            scontextInfoStringBuffer.append(infoItem + System.getProperty("line.separator"));
+        }
+
+
+
+        return scontextInfoStringBuffer.toString();
+    }
+
     private static Throwable getDefaultThrowable() {
         return new Throwable("Error thrown but no associated exception");
     }
index 02012cdbb023b2670ad4cc66e5cf982ded21293f..69fc04ed2b324d6ad69b5d93f8589af99796bff6 100644 (file)
@@ -38,7 +38,11 @@ public class NewAmplificationWizard  extends AbstractNewEntityWizard<Amplificati
     /** {@inheritDoc} */
     @Override
     protected void saveEntity() {
-        CdmStore.getService(IAmplificationService.class).merge(getEntity());
+        if(CdmStore.getCurrentSessionManager().isRemoting()) {
+            CdmStore.getService(IAmplificationService.class).merge(getEntity(), true);
+        } else {
+            CdmStore.getService(IAmplificationService.class).save(getEntity());
+        }
     }
 
     /** {@inheritDoc} */
index c298a5781a61d905f78707b0ae8c436de73d8b82..4586b9275e2329e4580b97a9361e51ec122c32d3 100644 (file)
@@ -50,10 +50,13 @@ public class NewClassificationWizard extends AbstractNewEntityWizard<Classificat
        protected void saveEntity() {
                //CdmStore.getService(IClassificationService.class).saveOrUpdate(getEntity());
            Classification classification = getEntity();
-           CdmStore.getService(IClassificationService.class).merge(getEntity());
-
-           CdmApplicationState.getCurrentDataChangeService()
-        .fireChangeEvent(new CdmChangeEvent(Action.Create, classification, NewTaxonNodeWizard.class), true);
+           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+               CdmStore.getService(IClassificationService.class).merge(getEntity(), true);
+               CdmApplicationState.getCurrentDataChangeService()
+               .fireChangeEvent(new CdmChangeEvent(Action.Create, classification, NewTaxonNodeWizard.class), true);
+           } else {
+               CdmStore.getService(IClassificationService.class).save(getEntity());
+           }
 
        }
 
index e81a0e50b70b331b31d21fbadbdb773dfdbce9b4..8efc02f8cfa1f4db1f0fad5c2ea5e4b80353e2b3 100644 (file)
@@ -36,7 +36,11 @@ public class NewCollectionWizard extends AbstractNewEntityWizard<Collection> {
        /** {@inheritDoc} */
        @Override
        protected void saveEntity() {
-               CdmStore.getService(ICollectionService.class).merge(getEntity());
+           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+               CdmStore.getService(ICollectionService.class).merge(getEntity(), true);
+           } else {
+               CdmStore.getService(ICollectionService.class).save(getEntity());
+           }
        }
 
        /* (non-Javadoc)
index 59dee8496855c1bac5928fe4b999b16cd9d67b00..4905b26f77bfbe66ce559604d5affc2ab9a9b3b6 100644 (file)
@@ -113,7 +113,11 @@ public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<SpecimenOr
        /** {@inheritDoc} */
        @Override
        protected void saveEntity() {
-               CdmStore.getService(IOccurrenceService.class).merge(getEntity());
+           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+               CdmStore.getService(IOccurrenceService.class).merge(getEntity(), true);
+           } else {
+               CdmStore.getService(IOccurrenceService.class).save(getEntity());
+           }
        }
 
 
index 48bff08362a3577ea85f75b404616fbbb147e29a..59086434ccdf25bb50bd22367971a78dfbb995f9 100644 (file)
@@ -38,7 +38,11 @@ public class NewFieldUnitWizard extends AbstractNewEntityWizard<FieldUnit> {
        /** {@inheritDoc} */
        @Override
        protected void saveEntity() {
-               CdmStore.getService(IOccurrenceService.class).merge(getEntity());
+           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+               CdmStore.getService(IOccurrenceService.class).merge(getEntity(), true);
+           } else {
+               CdmStore.getService(IOccurrenceService.class).save(getEntity());
+           }
        }
 
        @Override
index 4a3fb425ce38408e5695e3b8c0bb06b5a3c4422a..c3342795473dbd318516f80f6dea016b12186660 100644 (file)
@@ -38,7 +38,11 @@ public class NewGrantedAuthorityWizard extends AbstractNewEntityWizard<GrantedAu
         */
        @Override
        protected void saveEntity() {
-               CdmStore.getService(IGrantedAuthorityService.class).merge(getEntity());
+           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+               CdmStore.getService(IGrantedAuthorityService.class).merge(getEntity(), true);
+           } else {
+               CdmStore.getService(IGrantedAuthorityService.class).save(getEntity());
+           }
        }
 
        /* (non-Javadoc)
index 54758d1fac71bbe74fc701bb26c699e04d4ce692..6f6b52236b12ff50c4d513070ad4cd05b43318a6 100644 (file)
@@ -38,7 +38,11 @@ public class NewGroupWizard extends AbstractNewEntityWizard<Group> {
         */
        @Override
        protected void saveEntity() {
-               CdmStore.getService(IGroupService.class).merge(getEntity());
+           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+               CdmStore.getService(IGroupService.class).merge(getEntity(), true);
+           } else {
+               CdmStore.getService(IGroupService.class).save(getEntity());
+           }
        }
 
        /* (non-Javadoc)
index c14d13ab09867d7f12096a1af40f2d4ec8b1c804..6ac2d44407d5d86204df615c1bf8493c72aef7f4 100644 (file)
@@ -35,7 +35,11 @@ public class NewInstitutionWizard extends AbstractNewEntityWizard<Institution> {
         */
        @Override
        protected void saveEntity() {
-               CdmStore.getService(IAgentService.class).merge(getEntity());
+           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+               CdmStore.getService(IAgentService.class).merge(getEntity(), true);
+           } else {
+               CdmStore.getService(IAgentService.class).save(getEntity());
+           }
        }
 
        /* (non-Javadoc)
index 575f6a7ee615cba3e3ef3ccf1719095b48568534..cfdd27d18fb41f4559b99ca07567dcf9baecd50e 100644 (file)
@@ -49,7 +49,11 @@ public class NewNonViralNameWizard extends AbstractNewEntityWizard<NonViralName>
        /** {@inheritDoc} */
        @Override
        protected void saveEntity() {
-               CdmStore.getService(INameService.class).merge(getEntity());
+           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+               CdmStore.getService(INameService.class).merge(getEntity(), true);
+           } else {
+               CdmStore.getService(INameService.class).save(getEntity());
+           }
        }
 
        @Override
index abb03bd1cbc80543739685411758b2d742c55344..ab5f7038d644a9df499ff241b833b0d777147968 100644 (file)
@@ -39,7 +39,11 @@ public class NewPersonWizard extends AbstractNewEntityWizard<Person> {
        /** {@inheritDoc} */
        @Override
        protected void saveEntity() {
-               CdmStore.getService(IAgentService.class).merge(getEntity());
+           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+               CdmStore.getService(IAgentService.class).merge(getEntity(), true);
+           } else {
+               CdmStore.getService(IAgentService.class).save(getEntity());
+           }
        }
 
        @Override
index 9333780ac38c754dc66e000de69a81ceacd63563..daade68014f9bb41c4229a9533f89d58c70cf284 100644 (file)
@@ -31,7 +31,11 @@ public class NewPolytomousKeyWizard extends AbstractNewEntityWizard<PolytomousKe
        @Override
        protected void saveEntity() {
            if(!polytomousKeyPage.getPolytomousKeyName().equals("")) {
-               CdmStore.getService(IPolytomousKeyService.class).merge(getEntity());
+               if(CdmStore.getCurrentSessionManager().isRemoting()) {
+                   CdmStore.getService(IPolytomousKeyService.class).merge(getEntity(), true);
+               } else {
+                   CdmStore.getService(IPolytomousKeyService.class).save(getEntity());
+               }
            }
        }
 
index 1e31797d6e9ba9905dd5bbf588c17272fdf01928..de52e18d14f64ec84e2786057f8796a511366066 100644 (file)
@@ -38,7 +38,11 @@ public class NewPrimerWizard  extends AbstractNewEntityWizard<Primer> {
     /** {@inheritDoc} */
     @Override
     protected void saveEntity() {
-        CdmStore.getService(IPrimerService.class).merge(getEntity());
+        if(CdmStore.getCurrentSessionManager().isRemoting()) {
+            CdmStore.getService(IPrimerService.class).merge(getEntity(),true);
+        } else {
+            CdmStore.getService(IPrimerService.class).save(getEntity());
+        }
     }
 
     /** {@inheritDoc} */
index 90a1dc935a1bca6b39b0ea00d3786b1e10ef45ce..ef365a8ec60eeee2293c100585813dc78d4458cf 100644 (file)
@@ -55,7 +55,7 @@ public class NewTaxonNodeWizard extends AbstractNewEntityWizard<ITaxonTreeNode>{
                 TaxonNode taxonNode = parent.addChildTaxon(taxon, parent.getReference(), parent.getMicroReference());
 
                 if(CdmStore.getCurrentSessionManager().isRemoting()) {
-                    taxonNode = CdmStore.getService(ITaxonNodeService.class).merge(taxonNode);
+                    taxonNode = CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true);
                 } else {
                     taxonNode = CdmStore.getService(ITaxonNodeService.class).save(taxonNode);
                 }
index faf7cb34069f5be98e870b5f8b565ba0c431af7c..74c82db1a9064ed36573da6b2efda2e088190184 100644 (file)
@@ -42,7 +42,11 @@ public class NewTeamWizard extends AbstractNewEntityWizard<Team> {
        /** {@inheritDoc} */
        @Override
        protected void saveEntity() {
-               CdmStore.getService(IAgentService.class).merge(getEntity());
+           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+               CdmStore.getService(IAgentService.class).merge(getEntity(), true);
+           } else {
+               CdmStore.getService(IAgentService.class).save(getEntity());
+           }
        }
 
        @Override
index 322b798dca2084d9669f4a86177d43e6782deae4..d14363c33c899f83f9c2fcf07c8c9faeee52b8cc 100644 (file)
@@ -24,7 +24,11 @@ public class NewUserWizard extends AbstractNewEntityWizard<User> {
 
        @Override
        protected void saveEntity() {
-               CdmStore.getService(IUserService.class).merge(getEntity());
+           if(CdmStore.getCurrentSessionManager().isRemoting()) {
+               CdmStore.getService(IUserService.class).merge(getEntity(), true);
+           } else {
+               CdmStore.getService(IUserService.class).save(getEntity());
+           }
        }
 
        @Override
index 769e24a1368e322063fee17e45c0a196541291c2..88d5d3a34073027c168b4735fd51e25c22fff060 100644 (file)
@@ -10,7 +10,6 @@
 
 package eu.etaxonomy.taxeditor.preference;
 
-import org.eclipse.jface.preference.PreferencePage;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridLayout;
@@ -19,6 +18,7 @@ import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
+import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
 
@@ -31,7 +31,7 @@ import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
  * @created Aug 5, 2010
  * @version 1.0
  */
-public class FeatureTreePreferences extends PreferencePage implements
+public class FeatureTreePreferences extends CdmPreferencePage implements
                IWorkbenchPreferencePage {
 
        /**
index 756d1461b4996553056138928e572e5f2260982a..02ff53a0d7b0c78f38f0fe44fa31c6531b70416c 100644 (file)
@@ -14,6 +14,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.ImageDescriptor;
 
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
@@ -27,40 +28,58 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  */
 public abstract class CdmPreferencePage extends PreferencePage implements ICdmEntitySessionEnabled {
 
+    private ICdmEntitySession previousCdmEntitySession;
+    private boolean isApply;
+
     public CdmPreferencePage() {
-        bindNullSession();
+        initSession();
     }
 
     public CdmPreferencePage(String title) {
         super(title);
-        bindNullSession();
+        initSession();
     }
 
-    private void bindNullSession() {
-        if(CdmStore.isActive()) {
-            CdmStore.getCurrentSessionManager().bindNullSession(this);
-        }
+    public CdmPreferencePage(String title, ImageDescriptor image) {
+        super(title, image);
+        initSession();
+    }
+
+    private void initSession() {
+        previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
+        bindNullSession();
     }
 
-    protected void disposeNullSession() {
+    private void bindNullSession() {
         if(CdmStore.isActive()) {
-            CdmStore.getCurrentSessionManager().dispose(this);
+            CdmStore.getCurrentSessionManager().bindNullSession();
         }
     }
 
     @Override
     public boolean performOk() {
-        disposeNullSession();
+        if(previousCdmEntitySession != null && !isApply) {
+            previousCdmEntitySession.bind();
+        }
         return super.performOk();
     }
 
     @Override
     public boolean performCancel() {
-        disposeNullSession();
+        if(previousCdmEntitySession != null) {
+            previousCdmEntitySession.bind();
+        }
         return super.performCancel();
     }
 
-       /* (non-Javadoc)
+    @Override
+    public void performApply() {
+        isApply = true;
+        super.performApply();
+        isApply = false;
+    }
+
+    /* (non-Javadoc)
      * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
      */
     @Override
index 7a876f545bc833655936bec3bdabe1791bd0d2b1..b53b064e53d61cdab87f79c7912b08fa4083b318 100644 (file)
@@ -63,7 +63,7 @@ public class AvailableDistributionPage extends WizardPage implements ICdmEntityS
     protected AvailableDistributionPage(String pageName) {
         super(pageName);
         // TODO check if configuration exists
-        CdmStore.getCurrentSessionManager().bindNullSession(this);
+        CdmStore.getCurrentSessionManager().bindNullSession();
     }
 
     /*
index 69ffb03cb04f8b97e2fa22eb54e9b5606b25f0f0..5cfb246549a750f05a9934204e98eeae9005cd6c 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * 
+ *
  */
 package eu.etaxonomy.taxeditor.ui.section.description;
 
@@ -9,6 +9,7 @@ import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.model.common.OriginalSourceType;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
@@ -37,6 +38,10 @@ public class DescriptionElementSourceSection extends AbstractEntityCollectionSec
        /** {@inheritDoc} */
        @Override
        public DescriptionElementSource createNewElement() {
+           if(getEntity().getId() == 0) {
+               MessagingUtils.warningDialog("Description not saved", this, "Please save the newly created description before adding source");
+               return null;
+           }
                return DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
        }
 
index d1ad70eac4ed661f35769d54f51e9bafeb4ad82e..65efef6d075eeec5e9cadf4f655ef02734a5e546 100644 (file)
@@ -75,7 +75,6 @@ public class DerivateContentProvider implements ITreeContentProvider {
                 node.setParent(currentnode);
                 children.add(node);
             }
-            return children.toArray();
         }
         else if(value instanceof Sequence){
             Set<SingleRead> singleReads = ((Sequence) value).getSingleReads();
@@ -86,7 +85,8 @@ public class DerivateContentProvider implements ITreeContentProvider {
             }
             return children.toArray();
         }
-        else if(value instanceof SpecimenOrObservationBase){
+
+        if(value instanceof SpecimenOrObservationBase){
                List<DerivedUnit> derivates = getDerivates((SpecimenOrObservationBase<?>) value);
                for (DerivedUnit derivedUnit:derivates) {
                 TreeNode node = new TreeNode(derivedUnit);
@@ -121,7 +121,8 @@ public class DerivateContentProvider implements ITreeContentProvider {
         else if(element instanceof Sequence){
             return !((Sequence)element).getSingleReads().isEmpty();
         }
-        else if(element instanceof SpecimenOrObservationBase){
+
+        if(element instanceof SpecimenOrObservationBase){
                SpecimenOrObservationBase<?> specimenOrObservation = (SpecimenOrObservationBase<?>)element;
                for(DerivationEvent event:specimenOrObservation.getDerivationEvents()){
                    if(!event.getDerivatives().isEmpty()){
index 07c94bbb85deb401bb163cf53ecac2c56cb0a095..9947664f697bc0e42968293e65e2a22d5690f3d9 100644 (file)
@@ -39,6 +39,7 @@ import eu.etaxonomy.taxeditor.remoting.cache.CdmRemoteCacheManager;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManagerObserver;
+import eu.etaxonomy.taxeditor.session.NullSession;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
@@ -259,18 +260,11 @@ public class SessionsViewPart extends ViewPart implements ICdmEntitySessionManag
             Collection<ICdmEntitySession> sessions = cdmEntitySessionManager.getSessions();
             txtNoOfSessions.setText(String.valueOf(sessions.size()));
             for(ICdmEntitySession session : sessions) {
-                if(session.getOwner() != null) {
-                    TableItem item = new TableItem(tableSessions, SWT.NULL);
-                    item.setText(session.getOwner().toString());
-                    String activePrefix = "";
-                    if(session.isActive()) {
-                        activePrefix = "*";
-                    }
-                    item.setText(0, activePrefix + session.getOwner().toString());
-                    LiveCacheStatistics cacheStatistics = session.getCacheStatistics();
-                    item.setText(1, getInMemoryStats(cacheStatistics));
-                    item.setText(2, getOnDiskStats(cacheStatistics));
-                }
+                addSession(session);
+            }
+            ICdmEntitySession nullSession = cdmEntitySessionManager.getNullSession();
+            if(nullSession != null) {
+                addSession(nullSession);
             }
             for (int i=0; i<titles.length; i++) {
                 tableSessions.getColumn (i).pack ();
@@ -301,6 +295,28 @@ public class SessionsViewPart extends ViewPart implements ICdmEntitySessionManag
 
     }
 
+    private void addSession(ICdmEntitySession session) {
+
+        TableItem item = new TableItem(tableSessions, SWT.NULL);
+
+        String activePrefix = "";
+        if(session.isActive()) {
+            activePrefix = "*";
+        }
+        String sessionOwnerString = "";
+        if(session instanceof NullSession) {
+            sessionOwnerString = "Null Session";
+        } else {
+            if(session.getOwner() != null) {
+                sessionOwnerString = session.getOwner().toString();
+            }
+        }
+        item.setText(0, activePrefix + sessionOwnerString);
+        LiveCacheStatistics cacheStatistics = session.getCacheStatistics();
+        item.setText(1, getInMemoryStats(cacheStatistics));
+        item.setText(2, getOnDiskStats(cacheStatistics));
+    }
+
     private String getInMemoryStats(LiveCacheStatistics statistics) {
         if(statistics != null) {
             long localHeapSize = statistics.getLocalHeapSize();
index 76e9242bf77ccdb23d1dacd3459220acafa8b8bf..57aa4c41019b5c591529a779c59c5b7ce835652a 100644 (file)
@@ -18,6 +18,7 @@ import java.util.UUID;
 import org.apache.log4j.Logger;
 import org.eclipse.core.commands.ExecutionException;
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.unitils.dbunit.annotation.DataSet;
 
@@ -25,6 +26,11 @@ import eu.etaxonomy.cdm.api.service.IClassificationService;
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.ITaxonService;
 import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.common.OriginalSourceType;
+import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.description.TextData;
 import eu.etaxonomy.cdm.model.name.BotanicalName;
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
 import eu.etaxonomy.cdm.model.name.NonViralName;
@@ -33,6 +39,7 @@ import eu.etaxonomy.cdm.model.taxon.Synonym;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
  * @author cmathew
@@ -151,5 +158,48 @@ public class TaxonNameEditorTest extends BaseOperationTest {
         taxonService.merge(taxon);
     }
 
+    @Ignore
+    @Test
+    public void addDescription() {
+        UUID taxonNodeUuid = UUID.fromString("ce54c396-3694-47f2-abb0-1d7b7e057985");
+
+        TaxonNode taxonNode = taxonNodeService.load(taxonNodeUuid);
+        Taxon taxon = taxonNode.getTaxon();
+        TaxonDescription description = TaxonDescription.NewInstance(taxon);
+
+
+        TextData textData = TextData.NewInstance();
+
+        textData.setFeature(Feature.ECOLOGY());
+        description.addElement(textData);
+
+        DescriptionElementSource descriptionElementSource = DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
+        textData.addSource(descriptionElementSource);
+
+
+        CdmStore.getService(ITaxonNodeService.class).merge(taxonNode);
+
+        description.getId();
+    }
+
+
+    @Test
+    public void addTaxonNodeCascadeProblem() {
+        UUID taxonNodeUuid = UUID.fromString("ce54c396-3694-47f2-abb0-1d7b7e057985");
+
+        TaxonNode taxonNode = taxonNodeService.load(taxonNodeUuid);
+        Taxon childTaxon = Taxon.NewInstance(null, null);
+        TaxonNode childTaxonNode = taxonNode.addChildTaxon(childTaxon, null, null);
+        Taxon grandChildTaxon = Taxon.NewInstance(null, null);
+        TaxonNode grandChildTaxonNode = childTaxonNode.addChildTaxon(grandChildTaxon, null, null);
+
+        CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true);
+
+        Assert.assertEquals(taxonNode.getChildNodes().get(0).getId(), childTaxonNode.getId());
+        Assert.assertEquals(taxonNode.getChildNodes().get(0).getTaxon().getId(), childTaxon.getId());
+        Assert.assertEquals(taxonNode.getChildNodes().get(0).getChildNodes().get(0).getId(), grandChildTaxonNode.getId());
+        Assert.assertEquals(taxonNode.getChildNodes().get(0).getChildNodes().get(0).getTaxon().getId(), grandChildTaxon.getId());
+    }
+
 }
 
index c89201247332d6c9b26833c7380d92810f056520..82b9e94d13020b096b20972adfc1a2e33b1cf565 100644 (file)
@@ -178,12 +178,12 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
         pKey = polytomousKeyService.merge(pKey, true);
         grandChildNode = pKey.getRoot().getChildAt(0).getChildAt(0);
         Assert.assertTrue(0 != grandChildNode.getId());
-
-        grandChildNode.setStatement(KeyStatement.NewInstance("test"));
+        KeyStatement ks = KeyStatement.NewInstance("test");
+        grandChildNode.setStatement(ks);
         pKey = polytomousKeyService.merge(pKey, true);
 
-        grandChildNode = pKey.getRoot().getChildAt(0).getChildAt(0);
-        KeyStatement ks = grandChildNode.getStatement();
+        //grandChildNode = pKey.getRoot().getChildAt(0).getChildAt(0);
+        //KeyStatement ks = grandChildNode.getStatement();
         Assert.assertTrue(0 != ks.getId());
 
     }
@@ -197,10 +197,8 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
         rootChildNode.addChild(grandChildNode);
 
 
-        grandChildNode = polytomousKeyNodeService.merge(grandChildNode);
+        polytomousKeyNodeService.merge(grandChildNode);
 
-        PolytomousKeyNode greatGrandChildNode = PolytomousKeyNode.NewInstance();
-        grandChildNode.addChild(greatGrandChildNode);
 
         Assert.assertFalse(pKey.getRoot().getChildAt(0).getChildAt(0).getId() == 0);
     }
index fb244293ad12b3c3196178fc290360a26b702543..5d91d4033ef92d0c6cdbafaf60310850d887f442 100644 (file)
@@ -35,4 +35,6 @@
   <SynonymRelationship id="50" created="2010-12-21 15:09:45.0" uuid="60d1466f-5823-4a69-a071-1887d0c1e72b" doubtful="false" partial="false" proparte="false"  relatedfrom_id="388" relatedto_id="387" />
 
   <LanguageString id="10"/>
+  <DescriptionBase/>
+  <DescriptionElementBase/>
 </dataset>