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


Java KRADUtils.setObjectProperty方法代码示例

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

示例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
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:44,代码来源:KRADLegacyDataAdapterImpl.java


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