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


Java KRADUtils.isNull方法代码示例

本文整理汇总了Java中org.kuali.rice.krad.util.KRADUtils.isNull方法的典型用法代码示例。如果您正苦于以下问题:Java KRADUtils.isNull方法的具体用法?Java KRADUtils.isNull怎么用?Java KRADUtils.isNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kuali.rice.krad.util.KRADUtils的用法示例。


在下文中一共展示了KRADUtils.isNull方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyVersionNumber

import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
@Override
public void verifyVersionNumber(Object dataObject) {
    if (isPersistable(dataObject.getClass())) {
        Object pbObject = businessObjectService.retrieve(dataObject);
        if ( dataObject instanceof Versioned ) {
         Long pbObjectVerNbr = KRADUtils.isNull(pbObject) ? null : ((Versioned) pbObject).getVersionNumber();
         Long newObjectVerNbr = ((Versioned) dataObject).getVersionNumber();
         if (pbObjectVerNbr != null && !(pbObjectVerNbr.equals(newObjectVerNbr))) {
             GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,
                     RiceKeyConstants.ERROR_VERSION_MISMATCH);
             throw new ValidationException(
                     "Version mismatch between the local business object and the database business object");
         }
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:KNSLegacyDataAdapterImpl.java

示例2: validateBusinessObjectsRecursively

import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
 * @param businessObject - business object to validate
 */
public void validateBusinessObjectsRecursively(Object businessObject, int depth) {
    if (KRADUtils.isNull(businessObject)) {
        return;
    }

    // validate primitives and any specific bo validation
    validateBusinessObject(businessObject);

    // call method to recursively find business objects and validate
    validateBusinessObjectsFromDescriptors(businessObject, PropertyUtils.getPropertyDescriptors(
            businessObject.getClass()), depth);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:16,代码来源:DictionaryValidationServiceImpl.java

示例3: validateBusinessObject

import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
 * @see org.kuali.rice.krad.service.DictionaryValidationService#validateBusinessObject(org.kuali.rice.krad.bo.BusinessObject,
 * boolean)
 */
@Override
public void validateBusinessObject(Object businessObject, boolean validateRequired) {
    if (KRADUtils.isNull(businessObject)) {
        return;
    }

    validate(businessObject, businessObject.getClass().getName(), (String) null, validateRequired);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:13,代码来源:DictionaryValidationServiceImpl.java

示例4: refreshAttachment

import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
 * The attachment BO is proxied in OJB.  For some reason when an attachment does not yet exist,
 * refreshReferenceObject is not returning null and the proxy cannot be materialized. So, this method exists to
 * properly handle the proxied attachment BO.  This is a hack and should be removed post JPA migration.
 */
protected void refreshAttachment() {
    if (KRADUtils.isNull(attachment)) {
        this.refreshReferenceObject("attachment");
        final boolean isProxy = attachment != null && ProxyHelper.isProxy(attachment);
        if (isProxy && ProxyHelper.getRealObject(attachment) == null) {
            attachment = null;
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:15,代码来源:MaintenanceDocumentBase.java

示例5: refreshAttachmentList

import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
protected void refreshAttachmentList() {
    if (KRADUtils.isNull(attachments)) {
        this.refreshReferenceObject("attachments");
        final boolean isProxy = attachments != null && ProxyHelper.isProxy(attachments);
        if (isProxy && ProxyHelper.getRealObject(attachments) == null) {
            attachments = null;
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:10,代码来源:MaintenanceDocumentBase.java

示例6: 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

示例7: 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.isNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。