Move getService to CdmStore
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 7 Dec 2015 17:03:56 +0000 (18:03 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 7 Dec 2015 17:03:56 +0000 (18:03 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java

index bd594ad..7439f00 100644 (file)
@@ -28,12 +28,28 @@ import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
 import eu.etaxonomy.cdm.api.cache.CdmServiceCacher;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.service.IAgentService;
+import eu.etaxonomy.cdm.api.service.ICollectionService;
 import eu.etaxonomy.cdm.api.service.ICommonService;
+import eu.etaxonomy.cdm.api.service.INameService;
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.api.service.IReferenceService;
 import eu.etaxonomy.cdm.api.service.IService;
+import eu.etaxonomy.cdm.api.service.IUserService;
+import eu.etaxonomy.cdm.api.service.molecular.IAmplificationService;
+import eu.etaxonomy.cdm.api.service.molecular.IPrimerService;
 import eu.etaxonomy.cdm.config.ICdmSource;
 import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.common.User;
+import eu.etaxonomy.cdm.model.molecular.Amplification;
+import eu.etaxonomy.cdm.model.molecular.Primer;
+import eu.etaxonomy.cdm.model.name.NonViralName;
+import eu.etaxonomy.cdm.model.occurrence.Collection;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.ICdmPermissionEvaluator;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.Role;
@@ -598,6 +614,38 @@ public class CdmStore {
     }
 
 
+    public static <T extends CdmBase> IService<T> getService(T cdmBase){
+        IService<T> service = null;
+        if(cdmBase!=null){
+            //get corresponding service
+            if(cdmBase.isInstanceOf(Reference.class)){
+                service = (IService<T>) getService(IReferenceService.class);
+            }
+            else if (cdmBase.isInstanceOf(AgentBase.class)){
+                service = (IService<T>) getService(IAgentService.class);
+            }
+            else if (cdmBase instanceof NonViralName) {
+                service = (IService<T>) getService(INameService.class);
+            }
+            else if (cdmBase instanceof SpecimenOrObservationBase) {
+                service = (IService<T>) getService(IOccurrenceService.class);
+            }
+            else if (cdmBase instanceof Collection) {
+                service = (IService<T>) getService(ICollectionService.class);
+            }
+            else if (cdmBase instanceof User) {
+                service = (IService<T>) getService(IUserService.class);
+            }
+            else if (cdmBase instanceof Primer) {
+                service = (IService<T>) getService(IPrimerService.class);
+            }
+            else if (cdmBase instanceof Amplification) {
+                service = (IService<T>) getService(IAmplificationService.class);
+            }
+        }
+        return service;
+    }
+
     public static void setManagedServer(CDMServer server) {
         managedServer = server;
     }
index 04771ac..d40ecf0 100644 (file)
@@ -89,7 +89,7 @@ public class EditFromSelectionWizard extends Wizard implements
                CdmFormFactory formFactory = selectionElement.getFormFactory();
                CdmBase entity = (CdmBase) HibernateProxyHelper
                                .deproxy(selectionElement.getEntity());
-               IService<CdmBase> service = EntitySelectionElement.getService(entity);
+               IService<CdmBase> service = CdmStore.getService(entity);
                rootElement = service.load(entity.getUuid());
                if (rootElement.isInstanceOf(Reference.class)) {
                        addPage(new ReferenceWizardPage(formFactory,
@@ -165,7 +165,7 @@ public class EditFromSelectionWizard extends Wizard implements
        /** {@inheritDoc} */
        @Override
        public boolean performFinish() {
-           IService<CdmBase> service = EntitySelectionElement.getService(rootElement);
+           IService<CdmBase> service = CdmStore.getService(rootElement);
            service.merge(rootElement, true);
            previousCdmEntitySession.load(rootElement, true);
                return true;
index cd60041..3b5cf35 100644 (file)
@@ -23,27 +23,13 @@ import org.springframework.security.core.GrantedAuthority;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.api.service.IAgentService;
-import eu.etaxonomy.cdm.api.service.ICollectionService;
-import eu.etaxonomy.cdm.api.service.INameService;
-import eu.etaxonomy.cdm.api.service.IOccurrenceService;
-import eu.etaxonomy.cdm.api.service.IReferenceService;
-import eu.etaxonomy.cdm.api.service.IService;
-import eu.etaxonomy.cdm.api.service.IUserService;
-import eu.etaxonomy.cdm.api.service.molecular.IAmplificationService;
-import eu.etaxonomy.cdm.api.service.molecular.IPrimerService;
 import eu.etaxonomy.cdm.common.CdmUtils;
-import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.Group;
 import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.model.molecular.Amplification;
 import eu.etaxonomy.cdm.model.molecular.Primer;
-import eu.etaxonomy.cdm.model.name.NonViralName;
-import eu.etaxonomy.cdm.model.occurrence.Collection;
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
 import eu.etaxonomy.taxeditor.model.ImageResources;
@@ -236,38 +222,6 @@ public class EntitySelectionElement<T extends CdmBase> extends
                setSelectionInternal(selection);
        }
 
-       public static <T extends CdmBase> IService<T> getService(T cdmBase){
-           IService<T> service = null;
-           if(cdmBase!=null){
-            //get corresponding service
-            if(cdmBase.isInstanceOf(Reference.class)){
-                service = (IService<T>) CdmStore.getService(IReferenceService.class);
-            }
-            else if (cdmBase.isInstanceOf(AgentBase.class)){
-                service = (IService<T>) CdmStore.getService(IAgentService.class);
-            }
-            else if (cdmBase instanceof NonViralName) {
-                service = (IService<T>) CdmStore.getService(INameService.class);
-            }
-            else if (cdmBase instanceof SpecimenOrObservationBase) {
-                service = (IService<T>) CdmStore.getService(IOccurrenceService.class);
-            }
-            else if (cdmBase instanceof Collection) {
-                service = (IService<T>) CdmStore.getService(ICollectionService.class);
-            }
-            else if (cdmBase instanceof User) {
-                service = (IService<T>) CdmStore.getService(IUserService.class);
-            }
-            else if (cdmBase instanceof Primer) {
-                service = (IService<T>) CdmStore.getService(IPrimerService.class);
-            }
-            else if (cdmBase instanceof Amplification) {
-                service = (IService<T>) CdmStore.getService(IAmplificationService.class);
-            }
-           }
-           return service;
-       }
-
        /**
         * Return the selected object
         *