@Override public Class<?> getInquiryObjectClassIfNotTitle(Object dataObject, String propertyName) { Class<?> objectClass = ObjectUtils.materializeClassForProxiedObject(dataObject); org.kuali.rice.krad.bo.DataObjectRelationship relationship = dataObjectMetaDataService.getDataObjectRelationship( dataObject, objectClass, propertyName, "", true, false, true); if (relationship != null) { return relationship.getRelatedClass(); } return null; }
@Override public org.kuali.rice.krad.bo.DataObjectRelationship getDataObjectRelationship( Object dataObject, Class<?> dataObjectClass, String attributeName, String attributePrefix, boolean keysOnly, boolean supportsLookup, boolean supportsInquiry) { RelationshipDefinition ddReference = getDictionaryRelationship(dataObjectClass, attributeName); return dataObjectMetaDataService.getDataObjectRelationship( dataObject, dataObjectClass, attributeName, attributePrefix, keysOnly, supportsLookup, supportsInquiry); }
@Override public Map<String, String> getInquiryParameters( Object dataObject, List<String> keys, String propertyName) { Map<String, String> inquiryParameters = new HashMap<String, String>(); Class<?> objectClass = ObjectUtils.materializeClassForProxiedObject(dataObject); org.kuali.rice.krad.bo.DataObjectRelationship relationship = dataObjectMetaDataService.getDataObjectRelationship( dataObject, objectClass, propertyName, "", true, false, true); for (String keyName : keys) { String keyConversion = keyName; if (relationship != null) { keyConversion = relationship.getParentAttributeForChildAttribute(keyName); } else if (PropertyAccessorUtils.isNestedOrIndexedProperty(propertyName)) { String nestedAttributePrefix = KRADUtils.getNestedAttributePrefix(propertyName); keyConversion = nestedAttributePrefix + "." + keyName; } inquiryParameters.put(keyConversion, keyName); } return inquiryParameters; }
@Override public boolean hasLocalInquiry(Class<?> dataObjectClass) { return dataObjectMetaDataService.hasLocalInquiry(dataObjectClass); }
/** Legacy implementation of createQuickFinder. Uses the legacy DataObjectMetadataService. */ protected RemotableQuickFinder.Builder createQuickFinderLegacy( Class<?> containingClass, String attributeName) { Object sampleComponent; try { sampleComponent = containingClass.newInstance(); } catch (InstantiationException e) { throw new RiceRuntimeException(e); } catch (IllegalAccessException e) { throw new RiceRuntimeException(e); } String lookupClassName = null; Map<String, String> fieldConversions = new HashMap<String, String>(); Map<String, String> lookupParameters = new HashMap<String, String>(); org.kuali.rice.krad.bo.DataObjectRelationship relationship = getDataObjectRelationship( sampleComponent, containingClass, attributeName, "", true, true, false); if (relationship != null) { lookupClassName = relationship.getRelatedClass().getName(); for (Map.Entry<String, String> entry : relationship.getParentToChildReferences().entrySet()) { String fromField = entry.getValue(); String toField = entry.getKey(); fieldConversions.put(fromField, toField); } for (Map.Entry<String, String> entry : relationship.getParentToChildReferences().entrySet()) { String fromField = entry.getKey(); String toField = entry.getValue(); if (relationship.getUserVisibleIdentifierKey() == null || relationship.getUserVisibleIdentifierKey().equals(fromField)) { lookupParameters.put(fromField, toField); } } } else { // check for title attribute and if match build lookup to component class using pk fields String titleAttribute = dataObjectMetaDataService.getTitleAttribute(containingClass); if (StringUtils.equals(titleAttribute, attributeName)) { lookupClassName = containingClass.getName(); List<String> pkAttributes = dataObjectMetaDataService.listPrimaryKeyFieldNames(containingClass); for (String pkAttribute : pkAttributes) { fieldConversions.put(pkAttribute, pkAttribute); if (!StringUtils.equals(pkAttribute, attributeName)) { lookupParameters.put(pkAttribute, pkAttribute); } } } } if (StringUtils.isNotBlank(lookupClassName)) { String baseUrl = kualiConfigurationService.getPropertyValueAsString(KRADConstants.KRAD_LOOKUP_URL_KEY); RemotableQuickFinder.Builder builder = RemotableQuickFinder.Builder.create(baseUrl, lookupClassName); builder.setLookupParameters(lookupParameters); builder.setFieldConversions(fieldConversions); return builder; } return null; }
@Override public boolean equalsByPrimaryKeys(Object do1, Object do2) { return dataObjectMetaDataService.equalsByPrimaryKeys(do1, do2); }
@Override public Map<String, ?> getPrimaryKeyFieldValuesDOMDS(Object dataObject) { return dataObjectMetaDataService.getPrimaryKeyFieldValues(dataObject); }
/** * LookupServiceImpl calls BusinessObjectMetaDataService to listPrimaryKeyFieldNames. The * BusinessObjectMetaDataService goes beyond the PersistenceStructureService to consult the * associated ModuleService in determining the primary key field names. TODO: Do we need both * listPrimaryKeyFieldNames/persistenceStructureService and * listPrimaryKeyFieldNamesConsultingAllServices/businesObjectMetaDataService or can the latter * superset be used for the former? * * @param type the data object class * @return list of primary key field names, consulting persistence structure service, module * service and datadictionary */ protected List<String> listPrimaryKeyFieldNamesConsultingAllServices(Class<?> type) { return dataObjectMetaDataService.listPrimaryKeyFieldNames(type); }