本文整理汇总了Java中org.kuali.rice.krad.util.KRADUtils.createNewObjectFromClass方法的典型用法代码示例。如果您正苦于以下问题:Java KRADUtils.createNewObjectFromClass方法的具体用法?Java KRADUtils.createNewObjectFromClass怎么用?Java KRADUtils.createNewObjectFromClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.krad.util.KRADUtils
的用法示例。
在下文中一共展示了KRADUtils.createNewObjectFromClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetPropertyType
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
@Test
public void testGetPropertyType() throws Exception {
//Confirm simple nested property type works
ParameterBo param = KRADUtils.createNewObjectFromClass(ParameterBo.class);
Class propertyType = legacyDataAdapter.getPropertyType(param, "namespaceCode");
assertTrue("PropertyType is String",propertyType.isAssignableFrom(String.class));
//Confirm simple nested property type works
propertyType = legacyDataAdapter.getPropertyType(param, "component.name");
assertTrue("PropertyType is String",propertyType.isAssignableFrom(String.class));
//Confirm double nested property type works
propertyType = legacyDataAdapter.getPropertyType(param, "component.namespace.name");
assertTrue("PropertyType is String",propertyType.isAssignableFrom(String.class));
}
示例2: setViewHelperServiceClass
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* Setter for the <code>ViewHelperService</code> class name
* Also initializes the viewHelperService
*
* @param viewHelperServiceClass
*/
public void setViewHelperServiceClass(Class<? extends ViewHelperService> viewHelperServiceClass) {
checkMutable(true);
this.viewHelperServiceClass = viewHelperServiceClass;
if ((this.viewHelperService == null) && (this.viewHelperServiceClass != null)) {
viewHelperService = KRADUtils.createNewObjectFromClass(viewHelperServiceClass);
}
}
示例3: processCollectionAddBlankLine
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public void processCollectionAddBlankLine(ViewModel model, String collectionId, String collectionPath) {
if (!(model instanceof ViewModel)) {
return;
}
ViewModel viewModel = (ViewModel) model;
if (collectionId == null) {
logAndThrowRuntime(
"Unable to get collection group component for Id: " + collectionPath + " path: " + collectionPath);
}
// get the collection instance for adding the new line
Collection<Object> collection = ObjectPropertyUtils.getPropertyValue(model, collectionPath);
if (collection == null) {
logAndThrowRuntime("Unable to get collection property from model for path: " + collectionPath);
}
Class<?> collectionObjectClass = (Class<?>) viewModel.getViewPostMetadata().getComponentPostData(collectionId,
UifConstants.PostMetadata.COLL_OBJECT_CLASS);
Object newLine = KRADUtils.createNewObjectFromClass(collectionObjectClass);
List<Object> lineDataObjects = new ArrayList<Object>();
lineDataObjects.add(newLine);
viewModel.getViewPostMetadata().getAddedCollectionObjects().put(collectionId, lineDataObjects);
processAndAddLineObject(viewModel, newLine, collectionId, collectionPath);
}
示例4: getDefaultValueForField
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Object getDefaultValueForField(Object object, DataField dataField) {
View view = ViewLifecycle.getView();
Object defaultValue = null;
// if dataField.defaultValue is not null and not empty empty string use it
if (dataField.getDefaultValue() != null && !(dataField.getDefaultValue() instanceof String && StringUtils
.isBlank((String) dataField.getDefaultValue()))) {
defaultValue = dataField.getDefaultValue();
} else if ((dataField.getExpressionGraph() != null) && dataField.getExpressionGraph().containsKey(
UifConstants.ComponentProperties.DEFAULT_VALUE)) {
defaultValue = dataField.getExpressionGraph().get(UifConstants.ComponentProperties.DEFAULT_VALUE);
} else if (dataField.getDefaultValueFinderClass() != null) {
ValueFinder defaultValueFinder = KRADUtils.createNewObjectFromClass(dataField.getDefaultValueFinderClass());
defaultValue = defaultValueFinder.getValue();
} else if ((dataField.getExpressionGraph() != null) && dataField.getExpressionGraph().containsKey(
UifConstants.ComponentProperties.DEFAULT_VALUES)) {
defaultValue = dataField.getExpressionGraph().get(UifConstants.ComponentProperties.DEFAULT_VALUES);
} else if (dataField.getDefaultValues() != null) {
defaultValue = dataField.getDefaultValues();
}
ExpressionEvaluator expressionEvaluator = ViewLifecycle.getExpressionEvaluator();
if ((defaultValue != null) && (defaultValue instanceof String) && expressionEvaluator.containsElPlaceholder(
(String) defaultValue)) {
Map<String, Object> context = new HashMap<String, Object>(view.getPreModelContext());
context.putAll(dataField.getContext());
defaultValue = expressionEvaluator.replaceBindingPrefixes(view, object, (String) defaultValue);
defaultValue = expressionEvaluator.evaluateExpressionTemplate(context, (String) defaultValue);
}
return defaultValue;
}
示例5: buildInactivationBlockerQueryMap
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
@Deprecated
protected Map<String, String> buildInactivationBlockerQueryMap(BusinessObject blockedBo, InactivationBlockingMetadata inactivationBlockingMetadata) {
BusinessObject blockingBo = (BusinessObject) KRADUtils.createNewObjectFromClass(
inactivationBlockingMetadata.getBlockingReferenceBusinessObjectClass());
org.kuali.rice.krad.bo.DataObjectRelationship dataObjectRelationship = legacyDataAdapter
.getDataObjectRelationship(blockingBo, blockedBo.getClass(),
inactivationBlockingMetadata.getBlockedReferencePropertyName(), "", true, false, false);
RelationshipDefinition relationshipDefinition = KRADServiceLocatorWeb.getLegacyDataAdapter().getDictionaryRelationship(blockedBo.getClass(),inactivationBlockingMetadata.getBlockedReferencePropertyName());
// note, this method assumes that all PK fields of the blockedBo have a non-null and, for strings, non-blank values
if (dataObjectRelationship != null) {
Map<String, String> parentToChildReferences = dataObjectRelationship.getParentToChildReferences();
Map<String, String> queryMap = new HashMap<String, String>();
for (Map.Entry<String, String> parentToChildReference : parentToChildReferences.entrySet()) {
String fieldName = parentToChildReference.getKey();
Object fieldValue = KradDataServiceLocator.getDataObjectService().wrap(blockedBo).getPropertyValueNullSafe(parentToChildReference.getValue());
if (fieldValue != null && StringUtils.isNotBlank(fieldValue.toString())) {
queryMap.put(fieldName, fieldValue.toString());
} else {
LOG.error("Found null value for foreign key field " + fieldName
+ " while building inactivation blocking query map.");
throw new RuntimeException("Found null value for foreign key field '" + fieldName
+ "' while building inactivation blocking query map.");
}
}
return queryMap;
}
return null;
}
示例6: addFileUploadLine
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ModelAndView addFileUploadLine(final UifFormBase form) {
form.setAjaxReturnType(UifConstants.AjaxReturnTypes.UPDATECOMPONENT.getKey());
form.setAjaxRequest(true);
MultipartHttpServletRequest request = (MultipartHttpServletRequest) form.getRequest();
final String collectionId = request.getParameter(UifParameters.UPDATE_COMPONENT_ID);
final String bindingPath = request.getParameter(UifConstants.PostMetadata.BINDING_PATH);
Class<?> collectionObjectClass = (Class<?>) form.getViewPostMetadata().getComponentPostData(collectionId,
UifConstants.PostMetadata.COLL_OBJECT_CLASS);
Iterator<String> fileNamesItr = request.getFileNames();
while (fileNamesItr.hasNext()) {
String propertyPath = fileNamesItr.next();
MultipartFile uploadedFile = request.getFile(propertyPath);
final FileMeta fileObject = (FileMeta) KRADUtils.createNewObjectFromClass(collectionObjectClass);
try {
fileObject.init(uploadedFile);
} catch (Exception e) {
throw new RuntimeException("Unable to initialize new file object", e);
}
String id = UUID.randomUUID().toString() + "_" + uploadedFile.getName();
fileObject.setId(id);
fileObject.setDateUploaded(new Date());
fileObject.setUrl("?methodToCall=getFileFromLine&formKey="
+ form.getFormKey()
+ "&fileName="
+ fileObject.getName()
+ "&propertyPath="
+ propertyPath);
ViewLifecycle.encapsulateLifecycle(form.getView(), form, form.getViewPostMetadata(), null, request,
new Runnable() {
@Override
public void run() {
ViewLifecycle.getHelper().processAndAddLineObject(form, fileObject, collectionId,
bindingPath);
}
});
}
return getModelAndViewService().getModelAndView(form);
}
示例7: setPresentationControllerClass
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* Setter for the view's presentation controller by class
*
* @param presentationControllerClass
*/
public void setPresentationControllerClass(
Class<? extends ViewPresentationController> presentationControllerClass) {
checkMutable(true);
this.presentationController = KRADUtils.createNewObjectFromClass(presentationControllerClass);
}
示例8: setOptionsFinderClass
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void setOptionsFinderClass(Class<? extends KeyValuesFinder> optionsFinderClass) {
this.optionsFinder = KRADUtils.createNewObjectFromClass(optionsFinderClass);
}
示例9: setPropertyEditorClass
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void setPropertyEditorClass(Class<? extends PropertyEditor> propertyEditorClass) {
this.propertyEditor = KRADUtils.createNewObjectFromClass(propertyEditorClass);
}
示例10: processMultipleValueLookupResults
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public void processMultipleValueLookupResults(ViewModel model, String collectionId, String collectionPath,
String multiValueReturnFields, String lookupResultValues) {
// if no line values returned, no population is needed
if (StringUtils.isBlank(lookupResultValues) || !(model instanceof ViewModel)) {
return;
}
ViewModel viewModel = (ViewModel) model;
if (StringUtils.isBlank(collectionId)) {
throw new RuntimeException(
"Id is not set for this collection lookup: " + collectionId + ", " + "path: " + collectionPath);
}
// retrieve the collection group so we can get the collection class and collection lookup
Class<?> collectionObjectClass = (Class<?>) viewModel.getViewPostMetadata().getComponentPostData(collectionId,
UifConstants.PostMetadata.COLL_OBJECT_CLASS);
Collection<Object> collection = ObjectPropertyUtils.getPropertyValue(model, collectionPath);
if (collection == null) {
Class<?> collectionClass = ObjectPropertyUtils.getPropertyType(model, collectionPath);
collection = (Collection<Object>) KRADUtils.createNewObjectFromClass(collectionClass);
ObjectPropertyUtils.setPropertyValue(model, collectionPath, collection);
}
// get the field conversions
Map<String, String> fieldConversions =
(Map<String, String>) viewModel.getViewPostMetadata().getComponentPostData(collectionId,
UifConstants.PostMetadata.COLL_LOOKUP_FIELD_CONVERSIONS);
// filter the field conversions by what was returned from the multi value lookup return fields
Map <String, String> returnedFieldConversions = filterByReturnedFieldConversions(multiValueReturnFields,
fieldConversions);
List<String> toFieldNamesColl = new ArrayList<String>(returnedFieldConversions.values());
Collections.sort(toFieldNamesColl);
String[] toFieldNames = new String[toFieldNamesColl.size()];
toFieldNamesColl.toArray(toFieldNames);
// first split to get the line value sets
String[] lineValues = StringUtils.split(lookupResultValues, ",");
List<Object> lineDataObjects = new ArrayList<Object>();
// for each returned set create a new instance of collection class and populate with returned line values
for (String lineValue : lineValues) {
Object lineDataObject = null;
// TODO: need to put this in data object service so logic can be reused
ModuleService moduleService = KRADServiceLocatorWeb.getKualiModuleService().getResponsibleModuleService(
collectionObjectClass);
if (moduleService != null && moduleService.isExternalizable(collectionObjectClass)) {
lineDataObject = moduleService.createNewObjectFromExternalizableClass(collectionObjectClass.asSubclass(
org.kuali.rice.krad.bo.ExternalizableBusinessObject.class));
} else {
lineDataObject = KRADUtils.createNewObjectFromClass(collectionObjectClass);
}
String[] fieldValues = StringUtils.splitByWholeSeparatorPreserveAllTokens(lineValue, ":");
if (fieldValues.length != toFieldNames.length) {
throw new RuntimeException(
"Value count passed back from multi-value lookup does not match field conversion count");
}
// set each field value on the line
for (int i = 0; i < fieldValues.length; i++) {
String fieldName = toFieldNames[i];
ObjectPropertyUtils.setPropertyValue(lineDataObject, fieldName, fieldValues[i]);
}
lineDataObjects.add(lineDataObject);
processAndAddLineObject(viewModel, lineDataObject, collectionId, collectionPath);
}
viewModel.getViewPostMetadata().getAddedCollectionObjects().put(collectionId, lineDataObjects);
}
示例11: initializeNewCollectionLine
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* Initializes a new instance of the collection data object class for the add line.
*
* <p>If the add line property was not specified for the collection group the new lines will be
* added to the generic map on the {@code UifFormBase}, else it will be added to the property given by
* the addLineBindingInfo</p>
*
* <p>New line will only be created if the current line property is null or clearExistingLine is true.
* In the case of a new line default values are also applied</p>
*/
public void initializeNewCollectionLine(View view, Object model, CollectionGroup collectionGroup,
boolean clearExistingLine) {
Object newLine = null;
// determine if we are binding to generic form map or a custom property
if (StringUtils.isBlank(collectionGroup.getAddLinePropertyName())) {
// bind to form map
if (!(model instanceof UifFormBase)) {
throw new RuntimeException(
"Cannot create new collection line for group: " + collectionGroup.getPropertyName()
+ ". Model does not extend " + UifFormBase.class.getName()
);
}
// get new collection line map from form
Map<String, Object> newCollectionLines = ObjectPropertyUtils.getPropertyValue(model,
UifPropertyPaths.NEW_COLLECTION_LINES);
if (newCollectionLines == null) {
newCollectionLines = new HashMap<String, Object>();
ObjectPropertyUtils.setPropertyValue(model, UifPropertyPaths.NEW_COLLECTION_LINES, newCollectionLines);
}
// set binding path for add line
String newCollectionLineKey = KRADUtils.translateToMapSafeKey(
collectionGroup.getBindingInfo().getBindingPath());
String addLineBindingPath = UifPropertyPaths.NEW_COLLECTION_LINES + "['" + newCollectionLineKey + "']";
collectionGroup.getAddLineBindingInfo().setBindingPath(addLineBindingPath);
// if there is not an instance available or we need to clear create a new instance
if (!newCollectionLines.containsKey(newCollectionLineKey) || (newCollectionLines.get(newCollectionLineKey)
== null) || clearExistingLine) {
// create new instance of the collection type for the add line
newLine = KRADUtils.createNewObjectFromClass(collectionGroup.getCollectionObjectClass());
newCollectionLines.put(newCollectionLineKey, newLine);
}
} else {
// bind to custom property
Object addLine = ObjectPropertyUtils.getPropertyValue(model,
collectionGroup.getAddLineBindingInfo().getBindingPath());
if ((addLine == null) || clearExistingLine) {
newLine = KRADUtils.createNewObjectFromClass(collectionGroup.getCollectionObjectClass());
ObjectPropertyUtils.setPropertyValue(model, collectionGroup.getAddLineBindingInfo().getBindingPath(),
newLine);
}
}
// apply default values if a new line was created
if (newLine != null) {
ViewLifecycle.getHelper().applyDefaultValuesForCollectionLine(collectionGroup, newLine);
}
}
示例12: initializeComponentSecurity
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* Initializes (if necessary) the component security instance for the component type
*/
protected void initializeComponentSecurity() {
if (this.componentSecurity == null) {
this.componentSecurity = KRADUtils.createNewObjectFromClass(ComponentSecurity.class);
}
}
示例13: setDocumentPresentationControllerClass
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
public void setDocumentPresentationControllerClass(
Class<? extends DocumentPresentationController> documentPresentationControllerClass) {
this.documentPresentationController = KRADUtils.createNewObjectFromClass(documentPresentationControllerClass);
}
示例14: setDocumentAuthorizerClass
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
public void setDocumentAuthorizerClass(Class<? extends DocumentAuthorizer> documentAuthorizerClass) {
this.documentAuthorizer = KRADUtils.createNewObjectFromClass(documentAuthorizerClass);
}
示例15: setAuthorizerClass
import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
* Setter for the view's authorizer by class
*
* @param authorizerClass
*/
public void setAuthorizerClass(Class<? extends ViewAuthorizer> authorizerClass) {
checkMutable(true);
this.authorizer = KRADUtils.createNewObjectFromClass(authorizerClass);
}