本文整理汇总了Java中org.kuali.rice.krad.util.ObjectUtils.getPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectUtils.getPropertyValue方法的具体用法?Java ObjectUtils.getPropertyValue怎么用?Java ObjectUtils.getPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.krad.util.ObjectUtils
的用法示例。
在下文中一共展示了ObjectUtils.getPropertyValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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;
}
示例4: validateBusinessObjectOnMaintenanceDocumentHelper
import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
protected void validateBusinessObjectOnMaintenanceDocumentHelper(BusinessObject businessObject,
List<? extends MaintainableItemDefinition> itemDefinitions, String errorPrefix) {
for (MaintainableItemDefinition itemDefinition : itemDefinitions) {
if (itemDefinition instanceof MaintainableFieldDefinition) {
if (getDataDictionaryService().isAttributeDefined(businessObject.getClass(),
itemDefinition.getName())) {
Object value = ObjectUtils.getPropertyValue(businessObject, itemDefinition.getName());
if (value != null && StringUtils.isNotBlank(value.toString())) {
Class propertyType = ObjectUtils.getPropertyType(businessObject, itemDefinition.getName(), null);
if (TypeUtils.isStringClass(propertyType) ||
TypeUtils.isIntegralClass(propertyType) ||
TypeUtils.isDecimalClass(propertyType) ||
TypeUtils.isTemporalClass(propertyType)) {
// check value format against dictionary
if (!TypeUtils.isTemporalClass(propertyType)) {
validateAttributeFormat(businessObject.getClass().getName(), itemDefinition.getName(),
value.toString(), errorPrefix + itemDefinition.getName());
}
}
}
}
}
}
}
示例5: generateSearchableAttributeFromChange
import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
protected DocumentAttribute generateSearchableAttributeFromChange(Object changeToPersist) {
List<String> primaryKeyNames = KRADServiceLocatorWeb.getLegacyDataAdapter().listPrimaryKeyFieldNames(changeToPersist.getClass());
for (Object primaryKeyNameAsObject : primaryKeyNames) {
String primaryKeyName = (String)primaryKeyNameAsObject;
Object value = ObjectUtils.getPropertyValue(changeToPersist, primaryKeyName);
if (value != null) {
final WorkflowAttributePropertyResolutionService propertyResolutionService = KNSServiceLocator
.getWorkflowAttributePropertyResolutionService();
DocumentAttribute saValue = propertyResolutionService.buildSearchableAttribute((Class)changeToPersist.getClass(), primaryKeyName, value);
return saValue;
}
}
return null;
}
示例6: 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++;
}
}
}
示例7: getFullyMaskedValue
import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
public static String getFullyMaskedValue(String className, String fieldName, Object formObject, String propertyName) {
String displayMaskValue = null;
Object propertyValue = ObjectUtils.getPropertyValue(formObject, propertyName);
DataDictionaryEntryBase entry = (DataDictionaryEntryBase) KRADServiceLocatorWeb.getDataDictionaryService()
.getDataDictionary().getDictionaryObjectEntry(className);
AttributeDefinition a = entry.getAttributeDefinition(fieldName);
AttributeSecurity attributeSecurity = a.getAttributeSecurity();
if (attributeSecurity != null && attributeSecurity.isMask()) {
MaskFormatter maskFormatter = attributeSecurity.getMaskFormatter();
displayMaskValue = maskFormatter.maskValue(propertyValue);
}
return displayMaskValue;
}
示例8: getPartiallyMaskedValue
import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
public static String getPartiallyMaskedValue(String className, String fieldName, Object formObject,
String propertyName) {
String displayMaskValue = null;
Object propertyValue = ObjectUtils.getPropertyValue(formObject, propertyName);
DataDictionaryEntryBase entry = (DataDictionaryEntryBase) KRADServiceLocatorWeb.getDataDictionaryService()
.getDataDictionary().getDictionaryObjectEntry(className);
AttributeDefinition a = entry.getAttributeDefinition(fieldName);
AttributeSecurity attributeSecurity = a.getAttributeSecurity();
if (attributeSecurity != null && attributeSecurity.isPartialMask()) {
MaskFormatter partialMaskFormatter = attributeSecurity.getPartialMaskFormatter();
displayMaskValue = partialMaskFormatter.maskValue(propertyValue);
}
return displayMaskValue;
}
示例9: containsIntermediateNull
import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
/**
* @param bo
* @param propertyName
* @return true if one (or more) of the intermediate objects in the given propertyName is null
*/
private static boolean containsIntermediateNull(Object bo, String propertyName) {
boolean containsNull = false;
if (StringUtils.contains(propertyName, ".")) {
String prefix = StringUtils.substringBefore(propertyName, ".");
Object propertyValue = ObjectUtils.getPropertyValue(bo, prefix);
if (propertyValue == null) {
containsNull = true;
}
else {
String suffix = StringUtils.substringAfter(propertyName, ".");
containsNull = containsIntermediateNull(propertyValue, suffix);
}
}
return containsNull;
}
示例10: getReferenceFKValue
import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
private Object getReferenceFKValue(Object persistableObject, ObjectReferenceDescriptor chkRefCld, String fkName) {
ClassDescriptor classDescriptor = getClassDescriptor(persistableObject.getClass());
Object referenceObject = ObjectUtils.getPropertyValue(persistableObject, chkRefCld.getAttributeName());
if (referenceObject == null) {
return null;
}
FieldDescriptor[] refFkNames = chkRefCld.getForeignKeyFieldDescriptors(classDescriptor);
ClassDescriptor refCld = getClassDescriptor(chkRefCld.getItemClass());
FieldDescriptor[] refPkNames = refCld.getPkFields();
Object fkValue = null;
for (int i = 0; i < refFkNames.length; i++) {
FieldDescriptor fkField = refFkNames[i];
if (fkField.getAttributeName().equals(fkName)) {
fkValue = ObjectUtils.getPropertyValue(referenceObject, refPkNames[i].getAttributeName());
break;
}
}
return fkValue;
}
示例11: testGetChildCollectionThrowsNestedNullException
import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
/**
* <p>Testing scenario that was not working in the linked issue off of
* KULRICE-6877: KualiMaintainbleImpl#performCollectionForceUpperCase blowing up</p>
*
* @throws Exception
*/
@Test
public void testGetChildCollectionThrowsNestedNullException() throws Exception {
// We need to initialize PropertyUtils to use our plugins
new PojoPlugin().init(null, new ModuleConfigImpl());
TestCollectionHolderHolder tchh = new TestCollectionHolderHolder();
tchh.setTch(new TestCollectionHolder());
// this simulates a situation in which the property (tch) is a proxied object
// that can't be fetched, so getting it works (returns the proxy) but trying
// to access the collection underneath it throws a NestedNullException
Object result = ObjectUtils.getPropertyValue(tchh, "tch.collection");
// before, the empty string was being returned, which doesn't make sense for a collection
assertFalse("".equals(result));
// now we return null
assertTrue(null == result);
}
示例12: getMultiValueIdentifierList
import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
@Override
public List<String> getMultiValueIdentifierList(Collection maintCollection, List<String> duplicateIdentifierFields) {
List<String> identifierList = new ArrayList<String>();
for (PersistableBusinessObject bo : (Collection<PersistableBusinessObject>) maintCollection) {
String uniqueIdentifier = new String();
for (String identifierField : duplicateIdentifierFields) {
uniqueIdentifier = uniqueIdentifier + identifierField + "-"
+ ObjectUtils.getPropertyValue(bo, identifierField);
}
if (StringUtils.isNotEmpty(uniqueIdentifier)) {
identifierList.add(uniqueIdentifier);
}
}
return identifierList;
}
示例13: hasBusinessObjectExisted
import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
@Override
public boolean hasBusinessObjectExisted(BusinessObject bo, List<String> existingIdentifierList,
List<String> duplicateIdentifierFields) {
String uniqueIdentifier = new String();
for (String identifierField : duplicateIdentifierFields) {
uniqueIdentifier = uniqueIdentifier + identifierField + "-"
+ ObjectUtils.getPropertyValue(bo, identifierField);
}
if (existingIdentifierList.contains(uniqueIdentifier)) {
return true;
}
else {
return false;
}
}
示例14: setGenerateBlankRequiredValues
import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
/**
*
* @see Maintainable#setGenerateBlankRequiredValues()
*/
@Override
public void setGenerateBlankRequiredValues(String docTypeName) {
try {
List<MaintainableSectionDefinition> sectionDefinitions = getMaintenanceDocumentDictionaryService()
.getMaintainableSections(docTypeName);
Map<String, String> defaultValues = new HashMap<String, String>();
for (MaintainableSectionDefinition maintSectionDef : sectionDefinitions) {
for (MaintainableItemDefinition item : maintSectionDef.getMaintainableItems()) {
if (item instanceof MaintainableFieldDefinition) {
MaintainableFieldDefinition maintainableFieldDefinition = (MaintainableFieldDefinition) item;
if (maintainableFieldDefinition.isRequired()
&& maintainableFieldDefinition.isUnconditionallyReadOnly()) {
Object currPropVal = ObjectUtils.getPropertyValue(this.getBusinessObject(), item.getName());
if (currPropVal == null
|| (currPropVal instanceof String && StringUtils.isBlank((String) currPropVal))) {
Class<? extends ValueFinder> defaultValueFinderClass = maintainableFieldDefinition
.getDefaultValueFinderClass();
if (defaultValueFinderClass != null) {
String defaultValue = defaultValueFinderClass.newInstance().getValue();
if (defaultValue != null) {
defaultValues.put(item.getName(), defaultValue);
}
}
}
}
}
}
}
FieldUtils.populateBusinessObjectFromMap(getBusinessObject(), defaultValues);
}
catch (Exception e) {
LOG.error("Unable to set blank required value " + e.getMessage(), e);
throw new RuntimeException("Unable to set blank required value" + e.getMessage(), e);
}
}
示例15: addNewLineToCollection
import org.kuali.rice.krad.util.ObjectUtils; //导入方法依赖的package包/类
@Override
public void addNewLineToCollection(String collectionName) {
if (LOG.isDebugEnabled()) {
LOG.debug("addNewLineToCollection( " + collectionName + " )");
}
// get the new line from the map
PersistableBusinessObject addLine = newCollectionLines.get(collectionName);
if (addLine != null) {
// mark the isNewCollectionRecord so the option to delete this line
// will be presented
addLine.setNewCollectionRecord(true);
// if we add back add button on sub collection of an "add line" we
// may need extra logic here
// get the collection from the business object
Collection maintCollection = (Collection) ObjectUtils.getPropertyValue(getBusinessObject(), collectionName);
// add the line to the collection
maintCollection.add(addLine);
// refresh parent object since attributes could of changed prior to
// user clicking add
String referencesToRefresh = LookupUtils
.convertReferencesToSelectCollectionToString(getAllRefreshableReferences(getBusinessObject()
.getClass()));
if (LOG.isInfoEnabled()) {
LOG.info("References to refresh for adding line to collection " + collectionName + ": "
+ referencesToRefresh);
}
refreshReferences(referencesToRefresh);
}
initNewCollectionLine(collectionName);
}