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