1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.core.web.component; |
17 | |
|
18 | |
import org.kuali.rice.core.api.component.Component; |
19 | |
import org.kuali.rice.core.impl.component.ComponentBo; |
20 | |
import org.kuali.rice.kns.bo.BusinessObject; |
21 | |
import org.kuali.rice.kns.datadictionary.DataDictionaryException; |
22 | |
import org.kuali.rice.kns.inquiry.KualiInquirableImpl; |
23 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
24 | |
|
25 | |
import java.util.List; |
26 | |
import java.util.Map; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public class ComponentInquirableImpl extends KualiInquirableImpl { |
36 | |
|
37 | |
private static final String PARAMETER_DETAIL_TYPE_CODE = "componentCode"; |
38 | |
private static final String PARAMETER_NAMESPACE_CODE = "namespaceCode"; |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
@Override |
46 | |
public BusinessObject getBusinessObject(Map fieldValues) { |
47 | 0 | BusinessObject result = super.getBusinessObject(fieldValues); |
48 | |
|
49 | 0 | if (result == null) { |
50 | |
|
51 | 0 | String parameterDetailTypeCode = (String)fieldValues.get(PARAMETER_DETAIL_TYPE_CODE); |
52 | 0 | String parameterNamespaceCode = (String)fieldValues.get(PARAMETER_NAMESPACE_CODE); |
53 | |
|
54 | 0 | if (parameterDetailTypeCode == null) throw new RuntimeException(PARAMETER_DETAIL_TYPE_CODE + |
55 | |
" is a required key for this inquiry"); |
56 | 0 | if (parameterNamespaceCode == null) throw new RuntimeException(PARAMETER_NAMESPACE_CODE + |
57 | |
" is a required key for this inquiry"); |
58 | |
|
59 | |
List<Component> components; |
60 | |
try { |
61 | 0 | components = KNSServiceLocatorWeb.getRiceApplicationConfigurationMediationService().getNonDatabaseComponents(); |
62 | 0 | } catch (DataDictionaryException ex) { |
63 | 0 | throw new RuntimeException( |
64 | |
"Problem parsing data dictionary during full load required for inquiry to function: " + |
65 | |
ex.getMessage(), ex); |
66 | 0 | } |
67 | |
|
68 | 0 | for (Component pdt : components) { |
69 | 0 | if (parameterDetailTypeCode.equals(pdt.getCode()) && |
70 | |
parameterNamespaceCode.equals(pdt.getNamespaceCode())) { |
71 | 0 | result = ComponentBo.from(pdt); |
72 | 0 | break; |
73 | |
} |
74 | |
} |
75 | |
} |
76 | |
|
77 | 0 | return result; |
78 | |
} |
79 | |
|
80 | |
} |