本文整理汇总了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");
}
}
}
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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;
}
}
}
示例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);
}
}
}
}
}
示例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
}