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.inquiry.KualiInquirableImpl; |
21 | |
import org.kuali.rice.krad.bo.BusinessObject; |
22 | |
import org.kuali.rice.krad.datadictionary.DataDictionaryException; |
23 | |
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; |
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 | |
@Override |
41 | |
public Object retrieveDataObject(Map fieldValues){ |
42 | 0 | BusinessObject result = (BusinessObject)super.retrieveDataObject(fieldValues); |
43 | |
|
44 | 0 | if (result == null) { |
45 | |
|
46 | 0 | String parameterDetailTypeCode = (String)fieldValues.get(PARAMETER_DETAIL_TYPE_CODE); |
47 | 0 | String parameterNamespaceCode = (String)fieldValues.get(PARAMETER_NAMESPACE_CODE); |
48 | |
|
49 | 0 | if (parameterDetailTypeCode == null) throw new RuntimeException(PARAMETER_DETAIL_TYPE_CODE + |
50 | |
" is a required key for this inquiry"); |
51 | 0 | if (parameterNamespaceCode == null) throw new RuntimeException(PARAMETER_NAMESPACE_CODE + |
52 | |
" is a required key for this inquiry"); |
53 | |
|
54 | |
List<Component> components; |
55 | |
try { |
56 | 0 | components = KRADServiceLocatorWeb.getRiceApplicationConfigurationMediationService().getNonDatabaseComponents(); |
57 | 0 | } catch (DataDictionaryException ex) { |
58 | 0 | throw new RuntimeException( |
59 | |
"Problem parsing data dictionary during full load required for inquiry to function: " + |
60 | |
ex.getMessage(), ex); |
61 | 0 | } |
62 | |
|
63 | 0 | for (Component pdt : components) { |
64 | 0 | if (parameterDetailTypeCode.equals(pdt.getCode()) && |
65 | |
parameterNamespaceCode.equals(pdt.getNamespaceCode())) { |
66 | 0 | result = ComponentBo.from(pdt); |
67 | 0 | break; |
68 | |
} |
69 | |
} |
70 | |
} |
71 | |
|
72 | 0 | return result; |
73 | |
} |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
@Override |
81 | |
public BusinessObject getBusinessObject(Map fieldValues) { |
82 | 0 | BusinessObject result = super.getBusinessObject(fieldValues); |
83 | |
|
84 | 0 | if (result == null) { |
85 | |
|
86 | 0 | String parameterDetailTypeCode = (String)fieldValues.get(PARAMETER_DETAIL_TYPE_CODE); |
87 | 0 | String parameterNamespaceCode = (String)fieldValues.get(PARAMETER_NAMESPACE_CODE); |
88 | |
|
89 | 0 | if (parameterDetailTypeCode == null) throw new RuntimeException(PARAMETER_DETAIL_TYPE_CODE + |
90 | |
" is a required key for this inquiry"); |
91 | 0 | if (parameterNamespaceCode == null) throw new RuntimeException(PARAMETER_NAMESPACE_CODE + |
92 | |
" is a required key for this inquiry"); |
93 | |
|
94 | |
List<Component> components; |
95 | |
try { |
96 | 0 | components = KRADServiceLocatorWeb.getRiceApplicationConfigurationMediationService().getNonDatabaseComponents(); |
97 | 0 | } catch (DataDictionaryException ex) { |
98 | 0 | throw new RuntimeException( |
99 | |
"Problem parsing data dictionary during full load required for inquiry to function: " + |
100 | |
ex.getMessage(), ex); |
101 | 0 | } |
102 | |
|
103 | 0 | for (Component pdt : components) { |
104 | 0 | if (parameterDetailTypeCode.equals(pdt.getCode()) && |
105 | |
parameterNamespaceCode.equals(pdt.getNamespaceCode())) { |
106 | 0 | result = ComponentBo.from(pdt); |
107 | 0 | break; |
108 | |
} |
109 | |
} |
110 | |
} |
111 | |
|
112 | 0 | return result; |
113 | |
} |
114 | |
|
115 | |
} |