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


Java ObjectUtils类代码示例

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


ObjectUtils类属于org.kuali.rice.krad.util包,在下文中一共展示了ObjectUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testObjectUtils_getPropertyType

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
@Test
   /**
    * tests that various properties of the business object extension are of the expected Java Class
    */
public void testObjectUtils_getPropertyType() throws Exception {
	Account ta = new Account();
assertEquals("physical property type mismatch", PersistableBusinessObjectExtension.class, PropertyUtils
	.getPropertyType(ta, "extension"));
assertEquals("DD property type mismatch", AccountExtension.class, ObjectUtils.getPropertyType(ta, "extension",
           KNSServiceLocator.getPersistenceStructureService()));
assertEquals("extension.accountType attribute class mismatch", AccountType.class, ObjectUtils.getPropertyType(
	ta, "extension.accountType", KNSServiceLocator.getPersistenceStructureService()));
assertEquals("extension.accountType.codeAndDescription attribute class mismatch", String.class, ObjectUtils
	.getPropertyType(ta, "extension.accountType.codeAndDescription", KNSServiceLocator
		.getPersistenceStructureService()));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:ExtensionAttributeTest.java

示例2: updateUserFields

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
/**
 * Updates fields of type kualiuser sets the universal user id and/or name if required. 
 * 
 * @param field
 * @param businessObject
 */
private static final void updateUserFields(Field field, BusinessObject businessObject){
    // for user fields, attempt to pull the principal ID and person's name from the source object
    if ( field.getFieldType().equals(Field.KUALIUSER) ) {
        // this is supplemental, so catch and log any errors
        try {
            if ( StringUtils.isNotBlank(field.getUniversalIdAttributeName()) ) {
                Object principalId = ObjectUtils.getNestedValue(businessObject, field.getUniversalIdAttributeName());
                if ( principalId != null ) {
                    field.setUniversalIdValue(principalId.toString());
                }
            }
            if ( StringUtils.isNotBlank(field.getPersonNameAttributeName()) ) {
                Object personName = ObjectUtils.getNestedValue(businessObject, field.getPersonNameAttributeName());
                if ( personName != null ) {
                    field.setPersonNameValue( personName.toString() );
                }
            }
        } catch ( Exception ex ) {
            LOG.warn( "Unable to get principal ID or person name property in SectionBridge.", ex );
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:SectionBridge.java

示例3: getPropertyType

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
/**
 * Delegates to {@link PropertyUtils#getPropertyType(Object, String)}to look up the property type for the provided keypath.
 * Caches the resulting class so that subsequent lookups for the same keypath can be satisfied by looking in the cache.
 *
 * @throws NoSuchMethodException
 * @throws InvocationTargetException
 * @throws IllegalAccessException
 */
protected Class getPropertyType(String keypath) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    Map propertyTypes = (Map) classCache.get(getClass());
    if (propertyTypes == null) {
        propertyTypes = new HashMap();
        classCache.put(getClass(), propertyTypes);
    }

    // if type has not been retrieve previousely, use ObjectUtils to get type
    if (!propertyTypes.containsKey(keypath)) {
        Class type = ObjectUtils.easyGetPropertyType(this, keypath);
        propertyTypes.put(keypath, type);
    }

    Class propertyType = (Class) propertyTypes.get(keypath);
    return propertyType;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:PojoFormBase.java

示例4: isSuperUserAuthorized

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
public boolean isSuperUserAuthorized() {
    String docId = this.getDocId();
    if (StringUtils.isBlank(docId) || ObjectUtils.isNull(docTypeName)) {
        return false;
    }

    DocumentType documentType = KewApiServiceLocator.getDocumentTypeService().getDocumentTypeByName(docTypeName);
    String docTypeId = null;
    if (documentType != null) {
        docTypeId = documentType.getId();
    }
    String principalId =  GlobalVariables.getUserSession().getPrincipalId();
    if ( KewApiServiceLocator.getDocumentTypeService().isSuperUserForDocumentTypeId(principalId, docTypeId) ) {
        return true;
    }
    List<RouteNodeInstance> routeNodeInstances= KewApiServiceLocator.getWorkflowDocumentService().getRouteNodeInstances(
            docId);
    String documentStatus =  KewApiServiceLocator.getWorkflowDocumentService().getDocumentStatus(docId).getCode();
    return ((KewApiServiceLocator.getDocumentTypeService().canSuperUserApproveSingleActionRequest(
                principalId, this.getDocTypeName(), routeNodeInstances, documentStatus)) ||
            (KewApiServiceLocator.getDocumentTypeService().canSuperUserApproveDocument(
                principalId, this.getDocTypeName(), routeNodeInstances, documentStatus)) ||
            (KewApiServiceLocator.getDocumentTypeService().canSuperUserDisapproveDocument (
                principalId, this.getDocTypeName(), routeNodeInstances, documentStatus))) ;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:KualiDocumentFormBase.java

示例5: isStateAllowsApproveOrDisapprove

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
public boolean isStateAllowsApproveOrDisapprove() {
    if(this.getDocument().getDocumentHeader().hasWorkflowDocument()) {
        DocumentStatus status = null;
        WorkflowDocument document = WorkflowDocumentFactory.loadDocument(GlobalVariables.getUserSession().getPrincipalId(),
            this.getDocument().getDocumentHeader().getWorkflowDocument().getDocumentId());
        if (ObjectUtils.isNotNull(document)) {
            status = document.getStatus();
        } else {
            status = this.getDocument().getDocumentHeader().getWorkflowDocument().getStatus();
        }
        return !(isStateProcessedOrDisapproved(status) ||
                 isStateInitiatedFinalCancelled(status) ||
                 StringUtils.equals(status.getCode(), DocumentStatus.SAVED.getCode()));
    } else {
        return false;
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:KualiDocumentFormBase.java

示例6: retrieveFormValueForLookupInquiryParameters

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
/**
   * Retrieves a value from the form for the purposes of passing it as a parameter into the lookup or inquiry frameworks 
   * 
   * @param parameterName the name of the parameter, as expected by the lookup or inquiry frameworks
   * @param parameterValueLocation the name of the property containing the value of the parameter
   * @return the value of the parameter
   */
  public String retrieveFormValueForLookupInquiryParameters(String parameterName, String parameterValueLocation) {
  	// dereference literal values by simply trimming of the prefix
  	if (parameterValueLocation.startsWith(literalPrefixAndDelimiter)) {
  		return parameterValueLocation.substring(literalPrefixAndDelimiter.length());
  	}

  	Object value = ObjectUtils.getPropertyValue(this, parameterValueLocation);
if (value == null) {
	return null;
}
if (value instanceof String) {
	return (String) value;
}
Formatter formatter = Formatter.getFormatter(value.getClass());
return (String) formatter.format(value);	
  }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:KualiForm.java

示例7: copyParametersToBO

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
protected void copyParametersToBO(Map<String, String> parameters, PersistableBusinessObject newBO) throws Exception{
	for (String parmName : parameters.keySet()) {
		String propertyValue = parameters.get(parmName);

		if (StringUtils.isNotBlank(propertyValue)) {
			String propertyName = parmName;
			// set value of property in bo
			if (PropertyUtils.isWriteable(newBO, propertyName)) {
				Class type = ObjectUtils.easyGetPropertyType(newBO, propertyName);
				if (type != null && Formatter.getFormatter(type) != null) {
					Formatter formatter = Formatter.getFormatter(type);
					Object obj = formatter.convertFromPresentationFormat(propertyValue);
					ObjectUtils.setObjectProperty(newBO, propertyName, obj.getClass(), obj);
				}
				else {
					ObjectUtils.setObjectProperty(newBO, propertyName, String.class, propertyValue);
				}
			}
		}
	}
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:KualiMaintenanceDocumentAction.java

示例8: clearPrimaryKeyFields

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
/**
 * This method clears the value of the primary key fields on a Business Object.
 * 
 * @param document - document to clear the pk fields on
 */
   protected void clearPrimaryKeyFields(MaintenanceDocument document) {
	// get business object being maintained and its keys
	PersistableBusinessObject bo = document.getNewMaintainableObject().getBusinessObject();
	List<String> keyFieldNames = KRADServiceLocatorWeb.getLegacyDataAdapter().listPrimaryKeyFieldNames(bo.getClass());

	for (String keyFieldName : keyFieldNames) {
		try {
			ObjectUtils.setObjectProperty(bo, keyFieldName, null);
		}
		catch (Exception e) {
			LOG.error("Unable to clear primary key field: " + e.getMessage());
			throw new RuntimeException("Unable to clear primary key field: " + e.getMessage());
		}
	}
       bo.setObjectId(null);
       bo.setVersionNumber(new Long(1));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:KualiMaintenanceDocumentAction.java

示例9: getInquiryUrlForPrimaryKeys

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
@Deprecated
protected AnchorHtmlData getInquiryUrlForPrimaryKeys(Class clazz, Object businessObject, List<String> primaryKeys,
		String displayText) {
	if (businessObject == null)
		return new AnchorHtmlData(KRADConstants.EMPTY_STRING, KRADConstants.EMPTY_STRING);

	Properties parameters = new Properties();
	parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.START_METHOD);
	parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, clazz.getName());

	String titleAttributeValue;
	Map<String, String> fieldList = new HashMap<String, String>();
	for (String primaryKey : primaryKeys) {
		titleAttributeValue = (String) ObjectUtils.getPropertyValue(businessObject, primaryKey);
		parameters.put(primaryKey, titleAttributeValue);
		fieldList.put(primaryKey, titleAttributeValue);
	}
	if (StringUtils.isEmpty(displayText))
		return getHyperLink(clazz, fieldList, UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, parameters));
	else
		return getHyperLink(clazz, fieldList, UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, parameters),
				displayText);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:KualiInquirableImpl.java

示例10: validatePrimitiveFromDescriptor

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
protected List<RemotableAttributeError> validatePrimitiveFromDescriptor(String kimTypeId, String entryName, Object object, PropertyDescriptor propertyDescriptor) {
    List<RemotableAttributeError> errors = new ArrayList<RemotableAttributeError>();
    // validate the primitive attributes if defined in the dictionary
    if (null != propertyDescriptor && getDataDictionaryService().isAttributeDefined(entryName, propertyDescriptor.getName())) {
        Object value = ObjectUtils.getPropertyValue(object, propertyDescriptor.getName());
        Class<?> propertyType = propertyDescriptor.getPropertyType();

        if (TypeUtils.isStringClass(propertyType) || TypeUtils.isIntegralClass(propertyType) || TypeUtils.isDecimalClass(propertyType) || TypeUtils.isTemporalClass(propertyType)) {

            // check value format against dictionary
            if (value != null && StringUtils.isNotBlank(value.toString())) {
                if (!TypeUtils.isTemporalClass(propertyType)) {
                    errors.addAll(validateAttributeFormat(kimTypeId, entryName, propertyDescriptor.getName(), value.toString(), propertyDescriptor.getName()));
                }
            }
            else {
            	// if it's blank, then we check whether the attribute should be required
                errors.addAll(validateAttributeRequired(kimTypeId, entryName, propertyDescriptor.getName(), value, propertyDescriptor.getName()));
            }
        }
    }
    return errors;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:DataDictionaryTypeServiceBase.java

示例11: validateDuplicateIdentifierInDataDictionary

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
/**
 * This method validates that there should only exist one entry in the collection whose
 * fields match the fields specified within the duplicateIdentificationFields in the
 * maintenance document data dictionary.
 * If the duplicateIdentificationFields is not specified in the DD, by default it would
 * allow the addition to happen and return true.
 * It will return false if it fails the uniqueness validation.
 *
 * @param document
 * @param collectionName
 * @param bo
 * @return
 */
protected boolean validateDuplicateIdentifierInDataDictionary(MaintenanceDocument document, String collectionName,
        PersistableBusinessObject bo) {
    boolean valid = true;
    Object maintBo = document.getNewMaintainableObject().getDataObject();
    Collection maintCollection = (Collection) ObjectUtils.getPropertyValue(maintBo, collectionName);
    List<String> duplicateIdentifier = document.getNewMaintainableObject()
            .getDuplicateIdentifierFieldsFromDataDictionary(
                    document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName(), collectionName);
    if (duplicateIdentifier.size() > 0) {
        List<String> existingIdentifierString = document.getNewMaintainableObject()
                .getMultiValueIdentifierList(maintCollection, duplicateIdentifier);
        if (document.getNewMaintainableObject()
                .hasBusinessObjectExisted(bo, existingIdentifierString, duplicateIdentifier)) {
            valid = false;
            GlobalVariables.getMessageMap()
                    .putError(duplicateIdentifier.get(0), RiceKeyConstants.ERROR_DUPLICATE_ELEMENT, "entries in ",
                            document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
        }
    }
    return valid;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:35,代码来源:MaintenanceDocumentRuleBase.java

示例12: setNewCollectionLineDefaultValues

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
protected void setNewCollectionLineDefaultValues(String collectionName, PersistableBusinessObject addLine) {
	PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(addLine);
	for (int i = 0; i < descriptors.length; ++i) {
		PropertyDescriptor propertyDescriptor = descriptors[i];

		String fieldName = propertyDescriptor.getName();
		Class propertyType = propertyDescriptor.getPropertyType();
		String value = getMaintenanceDocumentDictionaryService().getCollectionFieldDefaultValue(getDocumentTypeName(),
				collectionName, fieldName);

		if (value != null) {
			try {
				ObjectUtils.setObjectProperty(addLine, fieldName, propertyType, value);
			}
			catch (Exception ex) {
				LOG.error("Unable to set default property of collection object: " + "\nobject: " + addLine
						+ "\nfieldName=" + fieldName + "\npropertyType=" + propertyType + "\nvalue=" + value, ex);
			}
		}

	}
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:KualiMaintainableImpl.java

示例13: clearCollectionRestrictedValues

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
protected void clearCollectionRestrictedValues(String fieldNamePrefix, BusinessObject businessObject,
		MaintainableCollectionDefinition collectionDefinition,
		MaintenanceDocumentRestrictions maintenanceDocumentRestrictions) {
	String collectionName = fieldNamePrefix + collectionDefinition.getName();
	Collection<BusinessObject> collection = (Collection<BusinessObject>) ObjectUtils.getPropertyValue(
			businessObject, collectionDefinition.getName());

	if (collection != null) {
		int i = 0;
		// even though it's technically a Collection, we're going to index
		// it like a list
		for (BusinessObject collectionItem : collection) {
			String collectionItemNamePrefix = collectionName + "[" + i + "].";
			for (MaintainableCollectionDefinition subCollectionDefinition : collectionDefinition
					.getMaintainableCollections()) {
				clearCollectionRestrictedValues(collectionItemNamePrefix, collectionItem, subCollectionDefinition,
						maintenanceDocumentRestrictions);
			}
			for (MaintainableFieldDefinition fieldDefinition : collectionDefinition.getMaintainableFields()) {
				clearFieldRestrictedValues(collectionItemNamePrefix, collectionItem, fieldDefinition,
						maintenanceDocumentRestrictions);
			}
			i++;
		}
	}
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:KualiMaintainableImpl.java

示例14: performCollectionForceUpperCase

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
protected void performCollectionForceUpperCase(String fieldNamePrefix, BusinessObject bo,
		MaintainableCollectionDefinition collectionDefinition, Map fieldValues) {
	String collectionName = fieldNamePrefix + collectionDefinition.getName();
	Collection<BusinessObject> collection = (Collection<BusinessObject>) ObjectUtils.getPropertyValue(bo,
			collectionDefinition.getName());
	if (collection != null) {
		int i = 0;
		// even though it's technically a Collection, we're going to index
		// it like a list
		for (BusinessObject collectionItem : collection) {
			String collectionItemNamePrefix = collectionName + "[" + i + "].";
			// String collectionItemNamePrefix = "";
			for (MaintainableFieldDefinition fieldDefinition : collectionDefinition.getMaintainableFields()) {
				performFieldForceUpperCase(collectionItemNamePrefix, collectionItem, fieldDefinition, fieldValues);
			}
			for (MaintainableCollectionDefinition subCollectionDefinition : collectionDefinition
					.getMaintainableCollections()) {
				performCollectionForceUpperCase(collectionItemNamePrefix, collectionItem, subCollectionDefinition,
						fieldValues);
			}
			i++;
		}
	}
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:KualiMaintainableImpl.java

示例15: checkPermission

import org.kuali.rice.krad.util.ObjectUtils; //导入依赖的package包/类
public void checkPermission() throws AuthorizationException {
    if (ObjectUtils.isNotNull(businessObjectEntry)) {
        String componentName = businessObjectEntry.getBusinessObjectClass().getName();
        String nameSpaceCode = "KR-NS";
        String templateName = "Export Records";
        String principalId = GlobalVariables.getUserSession().getPrincipalId();
        String principalUserName = GlobalVariables.getUserSession().getPrincipalName();
        Map<String, String> permissionDetails = new HashMap<String, String>();
        permissionDetails.put("componentName", componentName);
        boolean isAuthorized = KimApiServiceLocator.getPermissionService().isAuthorizedByTemplate(principalId, nameSpaceCode,
                templateName, permissionDetails, new HashMap<String, String>());
        if (!isAuthorized) {
            throw new AuthorizationException(principalUserName, "Exporting the LookUp Results", componentName);
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:ExportViewHelper.java


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