#4932 Remove autowired members, Use serliaised cdm model map
[taxeditor.git] / eu.etaxonomy.taxeditor.cdmlib / src / main / java / eu / etaxonomy / taxeditor / service / CachedCommonServiceImpl.java
index e36138e698f7a2f4539b8bdc5b0d9ff872851c84..0e5b8f9e6e50e578cddeef78eb8c5ce14d405acc 100644 (file)
@@ -12,16 +12,12 @@ package eu.etaxonomy.taxeditor.service;
 import java.util.List;
 import java.util.UUID;
 
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController;
 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
-import eu.etaxonomy.cdm.api.service.ICommonService;
 import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.taxeditor.remoting.cache.ProxyUtils.CollectionField;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
-import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
 
 /**
  * @author cmathew
@@ -32,15 +28,8 @@ import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
 public class CachedCommonServiceImpl implements ICachedCommonService {
 
 
-    @Autowired
-    private ICommonService commonService;
-
     private static boolean cacheEnabled = true;
 
-    @Autowired
-    private ICdmEntitySessionManager cdmEntitySessionManager;
-
-
     public static boolean isCacheEnabled() {
         return cacheEnabled;
     }
@@ -55,7 +44,7 @@ public class CachedCommonServiceImpl implements ICachedCommonService {
     @Override
     public CdmBase find(Class<? extends CdmBase> clazz, int id) {
 //        if(cacheEnabled) {
-            CdmBase cdmEntity = commonService.find(clazz, id, getPropertyPaths(clazz));
+            CdmBase cdmEntity = CdmApplicationState.getCurrentAppConfig().getCommonService().find(clazz, id, getPropertyPaths(clazz));
             if(cdmEntity == null) {
                 throw new NullPointerException("CDM Entity of type " + clazz.getName() + " with id " + id  + " is null.");
             }
@@ -77,19 +66,12 @@ public class CachedCommonServiceImpl implements ICachedCommonService {
         return propertyPaths;
     }
 
-    @Override
-    public void updatePersistentCollection(CollectionField colf) {
-        if(cacheEnabled) {
-            cdmEntitySessionManager.load(colf.getCollection(), false);
-        }
-    }
-
     /* (non-Javadoc)
      * @see eu.etaxonomy.taxeditor.service.ICachedCommonService#initializeCollection(java.util.UUID, java.lang.String)
      */
     @Override
     public Object initializeCollection(UUID ownerUuid, String fieldName) {
-        return commonService.initializeCollection(ownerUuid, fieldName, getPropertyPaths(fieldName));
+        return  CdmApplicationState.getCurrentAppConfig().getCommonService().initializeCollection(ownerUuid, fieldName, getPropertyPaths(fieldName));
     }
 
 
@@ -98,7 +80,7 @@ public class CachedCommonServiceImpl implements ICachedCommonService {
      */
     @Override
     public boolean isEmpty(UUID ownerUuid, String fieldName) {
-            return commonService.isEmpty(ownerUuid, fieldName);
+            return  CdmApplicationState.getCurrentAppConfig().getCommonService().isEmpty(ownerUuid, fieldName);
 
     }
 
@@ -108,7 +90,7 @@ public class CachedCommonServiceImpl implements ICachedCommonService {
      */
     @Override
     public int size(UUID ownerUuid, String fieldName) {
-        return commonService.size(ownerUuid, fieldName);
+        return  CdmApplicationState.getCurrentAppConfig().getCommonService().size(ownerUuid, fieldName);
     }
 
 
@@ -118,7 +100,7 @@ public class CachedCommonServiceImpl implements ICachedCommonService {
      */
     @Override
     public boolean contains(UUID ownerUuid, String fieldName, Object element) {
-        return commonService.contains(ownerUuid, fieldName, element);
+        return  CdmApplicationState.getCurrentAppConfig().getCommonService().contains(ownerUuid, fieldName, element);
     }
 
 
@@ -127,7 +109,7 @@ public class CachedCommonServiceImpl implements ICachedCommonService {
      */
     @Override
     public boolean containsKey(UUID ownerUuid, String fieldName, Object key) {
-        return commonService.containsKey(ownerUuid, fieldName, key);
+        return  CdmApplicationState.getCurrentAppConfig().getCommonService().containsKey(ownerUuid, fieldName, key);
     }
 
 
@@ -136,7 +118,7 @@ public class CachedCommonServiceImpl implements ICachedCommonService {
      */
     @Override
     public boolean containsValue(UUID ownerUuid, String fieldName, Object element) {
-        return commonService.containsValue(ownerUuid, fieldName, element);
+        return  CdmApplicationState.getCurrentAppConfig().getCommonService().containsValue(ownerUuid, fieldName, element);
     }