本文整理汇总了Java中org.kuali.rice.krad.util.KRADUtils.materializeObjects方法的典型用法代码示例。如果您正苦于以下问题:Java KRADUtils.materializeObjects方法的具体用法?Java KRADUtils.materializeObjects怎么用?Java KRADUtils.materializeObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.krad.util.KRADUtils
的用法示例。
在下文中一共展示了KRADUtils.materializeObjects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateUpdatabableReferencesRecursively
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
protected void validateUpdatabableReferencesRecursively(Object businessObject, int maxDepth,
boolean validateRequired, boolean chompLastLetterSFromCollectionName, Set<Object> processedBOs) {
// if null or already processed, return
if (KRADUtils.isNull(businessObject) || processedBOs.contains(businessObject)) {
return;
}
processedBOs.add(businessObject); // add bo to list to prevent excessive looping
Map<String, Class> references = getLegacyDataAdapter().listReferenceObjectFields(businessObject.getClass());
for (String referenceName : references.keySet()) {
if (getLegacyDataAdapter().isReferenceUpdatable(businessObject.getClass(), referenceName)) {
Object referenceObj = KradDataServiceLocator.getDataObjectService().wrap(businessObject)
.getPropertyValueNullSafe(referenceName);
if (KRADUtils.isNull(referenceObj) || !(referenceObj instanceof PersistableBusinessObject)) {
continue;
}
BusinessObject referenceBusinessObject = (BusinessObject) referenceObj;
GlobalVariables.getMessageMap().addToErrorPath(referenceName);
validateBusinessObject(referenceBusinessObject, validateRequired);
if (maxDepth > 0) {
validateUpdatabableReferencesRecursively(referenceBusinessObject, maxDepth - 1, validateRequired,
chompLastLetterSFromCollectionName, processedBOs);
}
GlobalVariables.getMessageMap().removeFromErrorPath(referenceName);
}
}
Map<String, Class> collections = getLegacyDataAdapter().listCollectionObjectTypes(businessObject.getClass());
for (String collectionName : collections.keySet()) {
if (getLegacyDataAdapter().isCollectionUpdatable(businessObject.getClass(), collectionName)) {
Object listObj = KradDataServiceLocator.getDataObjectService().wrap(businessObject)
.getPropertyValueNullSafe(collectionName);
if (KRADUtils.isNull(listObj)) {
continue;
}
if (!(listObj instanceof List)) {
if (LOG.isInfoEnabled()) {
LOG.info("The reference named " + collectionName + " of BO class " +
businessObject.getClass().getName() +
" should be of type java.util.List to be validated properly.");
}
continue;
}
List list = (List) listObj;
//should we materialize the proxied collection or just skip validation here assuming an unmaterialized objects are valid?
KRADUtils.materializeObjects(list);
for (int i = 0; i < list.size(); i++) {
final Object o = list.get(i);
if (KRADUtils.isNotNull(o) && o instanceof PersistableBusinessObject) {
final BusinessObject element = (BusinessObject) o;
final String errorPathAddition;
if (chompLastLetterSFromCollectionName) {
errorPathAddition = StringUtils.chomp(collectionName, "s")
+ "["
+ Integer.toString(i)
+ "]";
} else {
errorPathAddition = collectionName + "[" + Integer.toString(i) + "]";
}
GlobalVariables.getMessageMap().addToErrorPath(errorPathAddition);
validateBusinessObject(element, validateRequired);
if (maxDepth > 0) {
validateUpdatabableReferencesRecursively(element, maxDepth - 1, validateRequired,
chompLastLetterSFromCollectionName, processedBOs);
}
GlobalVariables.getMessageMap().removeFromErrorPath(errorPathAddition);
}
}
}
}
}