1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.service.impl; |
17 | |
|
18 | |
import java.util.List; |
19 | |
import java.util.Map; |
20 | |
|
21 | |
import org.apache.log4j.Logger; |
22 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
23 | |
import org.kuali.rice.kns.bo.Parameter; |
24 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
25 | |
import org.kuali.rice.kns.service.ParameterEvaluator; |
26 | |
import org.kuali.rice.kns.service.ParameterService; |
27 | |
import org.kuali.rice.kns.util.KNSConstants; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public class ParameterServiceProxyImpl implements ParameterService { |
40 | |
private ParameterService parameterService; |
41 | |
public static final String PARAMETER_CACHE_PREFIX = "ParameterProxy:"; |
42 | |
public static final String PARAMETER_CACHE_GROUP_NAME = "SystemParameterProxy"; |
43 | |
|
44 | |
public Parameter retrieveParameter(String namespaceCode, String detailTypeCode, |
45 | |
String parameterName) { |
46 | 0 | Parameter parameter = fetchFromCache(namespaceCode, detailTypeCode, parameterName); |
47 | 0 | if (parameter != null) { |
48 | 0 | return parameter; |
49 | |
} |
50 | 0 | parameter = getParameterService().retrieveParameter(namespaceCode, detailTypeCode, parameterName); |
51 | 0 | insertIntoCache(parameter); |
52 | 0 | return parameter; |
53 | |
} |
54 | |
|
55 | |
@SuppressWarnings("unchecked") |
56 | |
public void setParameterForTesting(Class componentClass, String parameterName, String parameterText) { |
57 | 0 | getParameterService().setParameterForTesting(componentClass, parameterName, parameterText); |
58 | |
|
59 | 0 | } |
60 | |
|
61 | |
public String getDetailType(Class<? extends Object> documentOrStepClass) { |
62 | 0 | return getParameterService().getDetailType(documentOrStepClass); |
63 | |
} |
64 | |
|
65 | |
public boolean getIndicatorParameter( |
66 | |
Class<? extends Object> componentClass, String parameterName) { |
67 | 0 | return getParameterService().getIndicatorParameter(componentClass, |
68 | |
parameterName); |
69 | |
} |
70 | |
|
71 | |
public String getNamespace(Class<? extends Object> documentOrStepClass) { |
72 | 0 | return getParameterService().getNamespace(documentOrStepClass); |
73 | |
} |
74 | |
|
75 | |
public ParameterEvaluator getParameterEvaluator( |
76 | |
Class<? extends Object> componentClass, String allowParameterName, |
77 | |
String denyParameterName, String constrainingValue, |
78 | |
String constrainedValue) { |
79 | 0 | return getParameterService().getParameterEvaluator(componentClass, |
80 | |
allowParameterName, denyParameterName, constrainingValue, |
81 | |
constrainedValue); |
82 | |
} |
83 | |
|
84 | |
public ParameterEvaluator getParameterEvaluator( |
85 | |
Class<? extends Object> componentClass, String parameterName, |
86 | |
String constrainingValue, String constrainedValue) { |
87 | 0 | return getParameterService().getParameterEvaluator(componentClass, |
88 | |
parameterName, constrainingValue, constrainedValue); |
89 | |
} |
90 | |
|
91 | |
public ParameterEvaluator getParameterEvaluator( |
92 | |
Class<? extends Object> componentClass, String parameterName, |
93 | |
String constrainedValue) { |
94 | 0 | return getParameterService().getParameterEvaluator(componentClass, |
95 | |
parameterName, constrainedValue); |
96 | |
} |
97 | |
|
98 | |
public ParameterEvaluator getParameterEvaluator( |
99 | |
Class<? extends Object> componentClass, String parameterName) { |
100 | 0 | return getParameterService().getParameterEvaluator(componentClass, |
101 | |
parameterName); |
102 | |
} |
103 | |
|
104 | |
public String getParameterValue(Class<? extends Object> componentClass, |
105 | |
String parameterName, String constrainingValue) { |
106 | 0 | return getParameterService().getParameterValue(componentClass, |
107 | |
parameterName, constrainingValue); |
108 | |
} |
109 | |
|
110 | |
public String getParameterValue(Class<? extends Object> componentClass, |
111 | |
String parameterName) { |
112 | 0 | return getParameterService().getParameterValue(componentClass, |
113 | |
parameterName); |
114 | |
} |
115 | |
|
116 | |
public List<String> getParameterValues( |
117 | |
Class<? extends Object> componentClass, String parameterName, |
118 | |
String constrainingValue) { |
119 | 0 | return getParameterService().getParameterValues(componentClass, |
120 | |
parameterName, constrainingValue); |
121 | |
} |
122 | |
|
123 | |
public List<String> getParameterValues( |
124 | |
Class<? extends Object> componentClass, String parameterName) { |
125 | 0 | return getParameterService().getParameterValues(componentClass, |
126 | |
parameterName); |
127 | |
} |
128 | |
|
129 | |
public boolean parameterExists(Class<? extends Object> componentClass, |
130 | |
String parameterName) { |
131 | 0 | return getParameterService().parameterExists(componentClass, |
132 | |
parameterName); |
133 | |
} |
134 | |
|
135 | |
public ParameterService getParameterService() { |
136 | 0 | if ( parameterService == null ) { |
137 | 0 | parameterService = KNSServiceLocator.getParameterServerService(); |
138 | |
} |
139 | 0 | return parameterService; |
140 | |
} |
141 | |
|
142 | |
public List<Parameter> retrieveParametersGivenLookupCriteria( |
143 | |
Map<String, String> fieldValues) { |
144 | 0 | return getParameterService().retrieveParametersGivenLookupCriteria(fieldValues); |
145 | |
} |
146 | |
|
147 | |
public String getParameterValue(String namespaceCode, String detailTypeCode, String parameterName) { |
148 | 0 | return getParameterService().getParameterValue(namespaceCode, detailTypeCode, parameterName); |
149 | |
} |
150 | |
|
151 | |
public List<String> getParameterValues(String namespaceCode, String detailTypeCode, String parameterName) { |
152 | 0 | return getParameterService().getParameterValues(namespaceCode, detailTypeCode, parameterName); |
153 | |
|
154 | |
} |
155 | |
|
156 | |
public boolean getIndicatorParameter(String namespaceCode, String detailTypeCode, String parameterName) { |
157 | 0 | return getParameterService().getIndicatorParameter(namespaceCode, detailTypeCode, parameterName); |
158 | |
} |
159 | |
|
160 | |
public ParameterEvaluator getParameterEvaluator(String namespaceCode, String detailTypeCode, String parameterName) { |
161 | 0 | return getParameterService().getParameterEvaluator(namespaceCode, detailTypeCode, parameterName); |
162 | |
} |
163 | |
|
164 | |
public ParameterEvaluator getParameterEvaluator(String namespaceCode, String detailTypeCode, String parameterName, String constrainedValue) { |
165 | 0 | return getParameterService().getParameterEvaluator(namespaceCode, detailTypeCode, parameterName, constrainedValue); |
166 | |
} |
167 | |
|
168 | |
|
169 | |
public void clearCache() { |
170 | 0 | getParameterService().clearCache(); |
171 | 0 | KEWServiceLocator.getCacheAdministrator().flushGroup(PARAMETER_CACHE_GROUP_NAME); |
172 | 0 | } |
173 | |
|
174 | |
protected Parameter fetchFromCache(String namespaceCode, String detailTypeCode, String name) { |
175 | 0 | return (Parameter)KEWServiceLocator.getCacheAdministrator().getFromCache(getParameterCacheKey(namespaceCode, detailTypeCode, name)); |
176 | |
} |
177 | |
|
178 | |
protected void insertIntoCache(Parameter parameter) { |
179 | 0 | if (parameter == null) { |
180 | 0 | return; |
181 | |
} |
182 | 0 | KEWServiceLocator.getCacheAdministrator().putInCache(getParameterCacheKey(parameter.getParameterNamespaceCode(), parameter.getParameterDetailTypeCode(), parameter.getParameterName()), parameter, PARAMETER_CACHE_GROUP_NAME); |
183 | 0 | } |
184 | |
|
185 | |
protected void flushParameterFromCache(String namespaceCode, String detailTypeCode, String name) { |
186 | 0 | KEWServiceLocator.getCacheAdministrator().flushEntry(getParameterCacheKey(namespaceCode, detailTypeCode, name)); |
187 | 0 | } |
188 | |
|
189 | |
protected String getParameterCacheKey(String namespaceCode, String detailTypeCode, String name) { |
190 | 0 | return PARAMETER_CACHE_PREFIX + namespaceCode + "-" + detailTypeCode + "-" + name; |
191 | |
} |
192 | |
} |