本文整理汇总了Java中org.kuali.rice.krad.util.KRADUtils.setObjectProperty方法的典型用法代码示例。如果您正苦于以下问题:Java KRADUtils.setObjectProperty方法的具体用法?Java KRADUtils.setObjectProperty怎么用?Java KRADUtils.setObjectProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.krad.util.KRADUtils
的用法示例。
在下文中一共展示了KRADUtils.setObjectProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshReference
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void refreshReference(Object parentObject, String referenceObjectName) {
if (!(parentObject instanceof PersistableBusinessObjectBaseAdapter)) {
KRADServiceLocator.getDataObjectService().wrap(parentObject).fetchRelationship(referenceObjectName);
}
else {
//support legacy data objects
LegacyDataAdapter legacyDataAdapter = KRADServiceLocatorWeb.getLegacyDataAdapter();
DataDictionaryService dataDictionaryService = KRADServiceLocatorWeb.getDataDictionaryService();
if (legacyDataAdapter.hasReference(parentObject.getClass(), referenceObjectName) || legacyDataAdapter
.hasCollection(parentObject.getClass(), referenceObjectName)) {
// refresh via database mapping
legacyDataAdapter.retrieveReferenceObject(parentObject, referenceObjectName);
} else if (dataDictionaryService.hasRelationship(parentObject.getClass().getName(), referenceObjectName)) {
// refresh via data dictionary mapping
Object referenceObject = KradDataServiceLocator.getDataObjectService().wrap(parentObject).getPropertyValue(
referenceObjectName);
if (!(referenceObject instanceof PersistableBusinessObjectBaseAdapter)) {
LOG.warn("Could not refresh reference " + referenceObjectName + " off class " + parentObject.getClass()
.getName() + ". Class not of type PersistableBusinessObject");
return;
}
referenceObject = legacyDataAdapter.retrieve(referenceObject);
if (referenceObject == null) {
LOG.warn("Could not refresh reference " + referenceObjectName + " off class " + parentObject.getClass()
.getName() + ".");
return;
}
try {
KRADUtils.setObjectProperty(parentObject, referenceObjectName, referenceObject);
} catch (Exception e) {
LOG.error("Unable to refresh persistable business object: " + referenceObjectName + "\n" + e
.getMessage());
throw new RuntimeException(
"Unable to refresh persistable business object: " + referenceObjectName + "\n" + e
.getMessage());
}
} else {
LOG.warn("Could not refresh reference " + referenceObjectName + " off class " + parentObject.getClass()
.getName() + ".");
}
}
}
示例2: setObjectPropertyDeep
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
@Override
public void setObjectPropertyDeep(Object bo, String propertyName, Class type,
Object propertyValue) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
DataObjectWrapper<Object> dataObjectWrapper = dataObjectService.wrap(bo);
// Base return cases to avoid null pointers & infinite loops
if (KRADUtils.isNull(bo) || !PropertyUtils.isReadable(bo, propertyName) || (propertyValue != null
&& propertyValue.equals(dataObjectWrapper.getPropertyValueNullSafe(propertyName))) || (type != null
&& !type.equals(KRADUtils.easyGetPropertyType(bo, propertyName)))) {
return;
}
// Set the property in the BO
KRADUtils.setObjectProperty(bo, propertyName, type, propertyValue);
// Now drill down and check nested BOs and BO lists
PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(bo.getClass());
for (int i = 0; i < propertyDescriptors.length; i++) {
PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
// Business Objects
if (propertyDescriptor.getPropertyType() != null && (BusinessObject.class).isAssignableFrom(
propertyDescriptor.getPropertyType()) && PropertyUtils.isReadable(bo,
propertyDescriptor.getName())) {
Object nestedBo = dataObjectWrapper.getPropertyValueNullSafe(propertyDescriptor.getName());
if (nestedBo instanceof BusinessObject) {
setObjectPropertyDeep(nestedBo, propertyName, type, propertyValue);
}
}
// Lists
else if (propertyDescriptor.getPropertyType() != null && (List.class).isAssignableFrom(
propertyDescriptor.getPropertyType()) && dataObjectWrapper.getPropertyValueNullSafe(
propertyDescriptor.getName()) != null) {
List propertyList = (List) dataObjectWrapper.getPropertyValueNullSafe(propertyDescriptor.getName());
for (Object listedBo : propertyList) {
if (listedBo != null && listedBo instanceof BusinessObject) {
setObjectPropertyDeep(listedBo, propertyName, type, propertyValue);
}
} // end for
}
} // end for
}