1 package org.kuali.rice.krad.service.impl;
2
3 import org.kuali.rice.krad.data.metadata.DataObjectMetadata;
4 import org.kuali.rice.krad.service.KRADServiceLocator;
5 import org.kuali.rice.krad.util.KRADUtils;
6 import org.springframework.beans.PropertyAccessorUtils;
7
8 import java.util.HashMap;
9 import java.util.List;
10 import java.util.Map;
11
12
13
14
15
16
17
18
19 public class KSKRADLegacyDataAdapterImpl extends KRADLegacyDataAdapterImpl {
20 @Override
21 public Map<String, String> getInquiryParameters(Object dataObject, List<String> keys, String propertyName) {
22 Map<String, String> inquiryParameters = new HashMap<String, String>();
23 DataObjectMetadata objectMetadata =
24 KRADServiceLocator.getDataObjectService().getMetadataRepository().getMetadata(dataObject.getClass());
25 org.kuali.rice.krad.data.metadata.DataObjectRelationship dataObjectRelationship = null;
26
27 if (objectMetadata != null) {
28 objectMetadata.getRelationshipByLastAttributeInRelationship(propertyName);
29 }
30 for (String keyName : keys) {
31 String keyConversion = keyName;
32 if (dataObjectRelationship != null) {
33 keyConversion = dataObjectRelationship.getParentAttributeNameRelatedToChildAttributeName(keyName);
34 } else if (PropertyAccessorUtils.isNestedOrIndexedProperty(propertyName)) {
35 String nestedAttributePrefix = KRADUtils.getNestedAttributePrefix(propertyName);
36 keyConversion = nestedAttributePrefix + "." + keyName;
37 }
38 inquiryParameters.put(keyConversion, keyName);
39 }
40 return inquiryParameters;
41 }
42 }