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


Java ObjectUtils.setObjectProperty方法代码示例

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


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

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

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

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

示例4: setBoField

import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
private void setBoField(PersistableBusinessObject bo, String fieldName, Object fieldValue) {
    try {
        ObjectUtils.setObjectProperty(bo, fieldName, fieldValue.getClass(), fieldValue);
    }
    catch (Exception e) {
        throw new RuntimeException("Could not set field [" + fieldName + "] on BO to value: " + fieldValue.toString() + " (see nested exception for details).", e);
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:BusinessObjectServiceImpl.java

示例5: setObjectProperty

import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
@Override
public void setObjectProperty(Object bo, String propertyName, Class propertyType,
        Object propertyValue) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException{
    ObjectUtils.setObjectProperty(bo,propertyName,propertyType,propertyValue);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:6,代码来源:KNSLegacyDataAdapterImpl.java

示例6: displayAllInactivationBlockers

import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
@Deprecated
public ActionForward displayAllInactivationBlockers(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	DisplayInactivationBlockersForm displayInactivationBlockersForm = (DisplayInactivationBlockersForm) form;
	DataDictionaryService dataDictionaryService = KRADServiceLocatorWeb.getDataDictionaryService();
	InactivationBlockingDisplayService inactivationBlockingDisplayService = KRADServiceLocatorWeb
               .getInactivationBlockingDisplayService();
	
	Class blockedBoClass = Class.forName(displayInactivationBlockersForm.getBusinessObjectClassName());
	BusinessObject blockedBo = (BusinessObject) blockedBoClass.newInstance();
	for (String key : displayInactivationBlockersForm.getPrimaryKeyFieldValues().keySet()) {
		ObjectUtils.setObjectProperty(blockedBo, key, displayInactivationBlockersForm.getPrimaryKeyFieldValues().get(key));
	}
	
	Map<String, List<String>> allBlockers = new TreeMap<String, List<String>>();
	
	Set<InactivationBlockingMetadata> inactivationBlockers = dataDictionaryService.getAllInactivationBlockingDefinitions(blockedBoClass);
	for (InactivationBlockingMetadata inactivationBlockingMetadata : inactivationBlockers) {
		String blockingBoLabel = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(inactivationBlockingMetadata.getBlockingReferenceBusinessObjectClass().getName()).getObjectLabel();
		String relationshipLabel = inactivationBlockingMetadata.getRelationshipLabel();
		String displayLabel;
		if (StringUtils.isEmpty(relationshipLabel)) {
			displayLabel = blockingBoLabel;
		}
		else {
			displayLabel = blockingBoLabel + " (" + relationshipLabel + ")";
		}
		List<String> blockerObjectList = inactivationBlockingDisplayService.listAllBlockerRecords(blockedBo, inactivationBlockingMetadata);
		
		if (!blockerObjectList.isEmpty()) {
			List<String> existingList = allBlockers.get(displayLabel);
			if (existingList != null) {
				existingList.addAll(blockerObjectList);
			}
			else {
				allBlockers.put(displayLabel, blockerObjectList);
			}
		}
	}
	
	displayInactivationBlockersForm.setBlockingValues(allBlockers);
	
	return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:44,代码来源:DisplayInactivationBlockersAction.java


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