1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
package org.kuali.rice.kns.service.impl; |
14 | |
|
15 | |
import java.util.Arrays; |
16 | |
import java.util.Collections; |
17 | |
import java.util.HashMap; |
18 | |
import java.util.List; |
19 | |
|
20 | |
import org.apache.commons.lang.StringUtils; |
21 | |
import org.kuali.rice.kns.bo.Parameter; |
22 | |
import org.kuali.rice.kns.service.BusinessObjectService; |
23 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
24 | |
import org.kuali.rice.kns.service.KualiConfigurationService; |
25 | |
|
26 | |
|
27 | 0 | public class KualiConfigurationServiceImpl extends AbstractStaticConfigurationServiceImpl implements KualiConfigurationService { |
28 | 0 | private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KualiConfigurationServiceImpl.class); |
29 | |
|
30 | |
@Deprecated |
31 | |
public List<String> getParameterValues(Parameter parameter) { |
32 | 0 | if (parameter == null || StringUtils.isBlank(parameter.getParameterValue())) { |
33 | 0 | return Collections.EMPTY_LIST; |
34 | |
} |
35 | 0 | return Arrays.asList(parameter.getParameterValue().split(";")); |
36 | |
} |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
@Deprecated |
43 | |
public Parameter getParameter(String namespaceCode, String detailTypeCode, String parameterName) { |
44 | 0 | if (StringUtils.isBlank(namespaceCode) || StringUtils.isBlank(detailTypeCode) || StringUtils.isBlank(parameterName)) { |
45 | 0 | throw new IllegalArgumentException( |
46 | |
"The getParameter method of KualiConfigurationServiceImpl requires a non-blank namespaceCode, parameterDetailTypeCode, and parameterName"); |
47 | |
} |
48 | 0 | Parameter param = getParameterWithoutExceptions(namespaceCode, detailTypeCode, parameterName); |
49 | 0 | if (param == null) { |
50 | 0 | throw new IllegalArgumentException( |
51 | |
"The getParameter method of KualiConfigurationServiceImpl was unable to find parameter: " |
52 | |
+ namespaceCode + " / " + detailTypeCode + " / " + parameterName); |
53 | |
} |
54 | 0 | return param; |
55 | |
} |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
@Deprecated |
78 | |
public List<String> getParameterValues(String namespaceCode, String parameterDetailTypeCode, String parameterName) { |
79 | 0 | return getParameterValues(getParameter(namespaceCode, parameterDetailTypeCode, parameterName)); |
80 | |
} |
81 | |
|
82 | |
@Deprecated |
83 | |
public boolean getIndicatorParameter(String namespaceCode, String parameterDetailTypeCode, String parameterName) { |
84 | 0 | return "Y".equals(getParameterValue(namespaceCode, parameterDetailTypeCode, parameterName)); |
85 | |
} |
86 | |
|
87 | |
@Deprecated |
88 | |
public String getParameterValue(String namespaceCode, String parameterDetailTypeCode, String parameterName) { |
89 | 0 | List<String> parameterValues = getParameterValues(getParameter(namespaceCode, parameterDetailTypeCode, parameterName)); |
90 | 0 | return parameterValues.isEmpty() ? "" : parameterValues.iterator().next(); |
91 | |
} |
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
private void checkParameterArgument(Parameter parameter, String methodName) { |
98 | 0 | if (parameter == null) { |
99 | 0 | throw new IllegalArgumentException("The " + methodName |
100 | |
+ " method of KualiConfigurationServiceImpl requires a non-null parameter"); |
101 | |
} |
102 | 0 | } |
103 | |
|
104 | |
public Parameter getParameterWithoutExceptions(String namespaceCode, String detailTypeCode, String parameterName) { |
105 | 0 | HashMap<String, String> crit = new HashMap<String, String>(3); |
106 | 0 | crit.put("parameterNamespaceCode", namespaceCode); |
107 | 0 | crit.put("parameterDetailTypeCode", detailTypeCode); |
108 | 0 | crit.put("parameterName", parameterName); |
109 | 0 | Parameter param = (Parameter) getBusinessObjectService().findByPrimaryKey(Parameter.class, crit); |
110 | 0 | return param; |
111 | |
} |
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
private BusinessObjectService getBusinessObjectService() { |
125 | 0 | return KNSServiceLocator.getBusinessObjectService(); |
126 | |
} |
127 | |
} |