Revision 5a49a28f
Added by Cherian Mathew almost 9 years ago
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/service/CachedCommonServiceImpl.java | ||
---|---|---|
12 | 12 |
import java.util.List; |
13 | 13 |
import java.util.UUID; |
14 | 14 |
|
15 |
import org.springframework.beans.factory.annotation.Autowired; |
|
16 | 15 |
import org.springframework.stereotype.Component; |
17 | 16 |
|
18 | 17 |
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController; |
19 | 18 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
20 |
import eu.etaxonomy.cdm.api.service.ICommonService; |
|
21 | 19 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
22 |
import eu.etaxonomy.taxeditor.remoting.cache.ProxyUtils.CollectionField; |
|
23 | 20 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySession; |
24 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager; |
|
25 | 21 |
|
26 | 22 |
/** |
27 | 23 |
* @author cmathew |
... | ... | |
32 | 28 |
public class CachedCommonServiceImpl implements ICachedCommonService { |
33 | 29 |
|
34 | 30 |
|
35 |
@Autowired |
|
36 |
private ICommonService commonService; |
|
37 |
|
|
38 | 31 |
private static boolean cacheEnabled = true; |
39 | 32 |
|
40 |
@Autowired |
|
41 |
private ICdmEntitySessionManager cdmEntitySessionManager; |
|
42 |
|
|
43 |
|
|
44 | 33 |
public static boolean isCacheEnabled() { |
45 | 34 |
return cacheEnabled; |
46 | 35 |
} |
... | ... | |
55 | 44 |
@Override |
56 | 45 |
public CdmBase find(Class<? extends CdmBase> clazz, int id) { |
57 | 46 |
// if(cacheEnabled) { |
58 |
CdmBase cdmEntity = commonService.find(clazz, id, getPropertyPaths(clazz));
|
|
47 |
CdmBase cdmEntity = CdmApplicationState.getCurrentAppConfig().getCommonService().find(clazz, id, getPropertyPaths(clazz));
|
|
59 | 48 |
if(cdmEntity == null) { |
60 | 49 |
throw new NullPointerException("CDM Entity of type " + clazz.getName() + " with id " + id + " is null."); |
61 | 50 |
} |
... | ... | |
77 | 66 |
return propertyPaths; |
78 | 67 |
} |
79 | 68 |
|
80 |
@Override |
|
81 |
public void updatePersistentCollection(CollectionField colf) { |
|
82 |
if(cacheEnabled) { |
|
83 |
cdmEntitySessionManager.load(colf.getCollection(), false); |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 | 69 |
/* (non-Javadoc) |
88 | 70 |
* @see eu.etaxonomy.taxeditor.service.ICachedCommonService#initializeCollection(java.util.UUID, java.lang.String) |
89 | 71 |
*/ |
90 | 72 |
@Override |
91 | 73 |
public Object initializeCollection(UUID ownerUuid, String fieldName) { |
92 |
return commonService.initializeCollection(ownerUuid, fieldName, getPropertyPaths(fieldName));
|
|
74 |
return CdmApplicationState.getCurrentAppConfig().getCommonService().initializeCollection(ownerUuid, fieldName, getPropertyPaths(fieldName));
|
|
93 | 75 |
} |
94 | 76 |
|
95 | 77 |
|
... | ... | |
98 | 80 |
*/ |
99 | 81 |
@Override |
100 | 82 |
public boolean isEmpty(UUID ownerUuid, String fieldName) { |
101 |
return commonService.isEmpty(ownerUuid, fieldName);
|
|
83 |
return CdmApplicationState.getCurrentAppConfig().getCommonService().isEmpty(ownerUuid, fieldName);
|
|
102 | 84 |
|
103 | 85 |
} |
104 | 86 |
|
... | ... | |
108 | 90 |
*/ |
109 | 91 |
@Override |
110 | 92 |
public int size(UUID ownerUuid, String fieldName) { |
111 |
return commonService.size(ownerUuid, fieldName);
|
|
93 |
return CdmApplicationState.getCurrentAppConfig().getCommonService().size(ownerUuid, fieldName);
|
|
112 | 94 |
} |
113 | 95 |
|
114 | 96 |
|
... | ... | |
118 | 100 |
*/ |
119 | 101 |
@Override |
120 | 102 |
public boolean contains(UUID ownerUuid, String fieldName, Object element) { |
121 |
return commonService.contains(ownerUuid, fieldName, element);
|
|
103 |
return CdmApplicationState.getCurrentAppConfig().getCommonService().contains(ownerUuid, fieldName, element);
|
|
122 | 104 |
} |
123 | 105 |
|
124 | 106 |
|
... | ... | |
127 | 109 |
*/ |
128 | 110 |
@Override |
129 | 111 |
public boolean containsKey(UUID ownerUuid, String fieldName, Object key) { |
130 |
return commonService.containsKey(ownerUuid, fieldName, key);
|
|
112 |
return CdmApplicationState.getCurrentAppConfig().getCommonService().containsKey(ownerUuid, fieldName, key);
|
|
131 | 113 |
} |
132 | 114 |
|
133 | 115 |
|
... | ... | |
136 | 118 |
*/ |
137 | 119 |
@Override |
138 | 120 |
public boolean containsValue(UUID ownerUuid, String fieldName, Object element) { |
139 |
return commonService.containsValue(ownerUuid, fieldName, element);
|
|
121 |
return CdmApplicationState.getCurrentAppConfig().getCommonService().containsValue(ownerUuid, fieldName, element);
|
|
140 | 122 |
} |
141 | 123 |
|
142 | 124 |
|
Also available in: Unified diff
#4932 Remove autowired members, Use serliaised cdm model map