当前位置: 首页>>代码示例>>Java>>正文


Java KRADUtils.materializeObjects方法代码示例

本文整理汇总了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);
                }
            }
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:79,代码来源:DictionaryValidationServiceImpl.java


注:本文中的org.kuali.rice.krad.util.KRADUtils.materializeObjects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。