本文整理汇总了Java中org.kuali.rice.core.web.format.Formatter.findFormatter方法的典型用法代码示例。如果您正苦于以下问题:Java Formatter.findFormatter方法的具体用法?Java Formatter.findFormatter怎么用?Java Formatter.findFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.core.web.format.Formatter
的用法示例。
在下文中一共展示了Formatter.findFormatter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFormatterForType
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
private Formatter buildFormatterForType(Class propertyType) {
Formatter formatter = null;
if (Formatter.findFormatter(propertyType) != null) {
formatter = Formatter.getFormatter(propertyType);
}
return formatter;
}
示例2: retrieveBestFormatter
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
* Like when you're digging through your stuff drawer, you know the one in the kitchen with all the batteries and lint in it, this method
* goes through the stuff drawer of KNS formatters and attempts to return you a good one
*
* @param propertyName the name of the property to retrieve
* @param boClass the class of the BusinessObject the property is on
* @return a Formatter, or null if we were unsuccessful in finding
*/
protected Formatter retrieveBestFormatter(String propertyName, Class<? extends BusinessObject> boClass) {
Formatter formatter = null;
try {
Class<? extends Formatter> formatterClass = null;
final BusinessObjectEntry boEntry = getBusinessObjectEntry(boClass);
if (boEntry != null) {
final AttributeDefinition attributeDefinition = boEntry.getAttributeDefinition(propertyName);
if (attributeDefinition != null && attributeDefinition.hasFormatterClass()) {
formatterClass = (Class<? extends Formatter>)Class.forName(attributeDefinition.getFormatterClass());
}
}
if (formatterClass == null) {
final java.lang.reflect.Field propertyField = boClass.getDeclaredField(propertyName);
if (propertyField != null) {
formatterClass = Formatter.findFormatter(propertyField.getType());
}
}
if (formatterClass != null) {
formatter = formatterClass.newInstance();
}
} catch (SecurityException se) {
throw new RuntimeException("Could not retrieve good formatter", se);
} catch (ClassNotFoundException cnfe) {
throw new RuntimeException("Could not retrieve good formatter", cnfe);
} catch (NoSuchFieldException nsfe) {
throw new RuntimeException("Could not retrieve good formatter", nsfe);
} catch (IllegalAccessException iae) {
throw new RuntimeException("Could not retrieve good formatter", iae);
} catch (InstantiationException ie) {
throw new RuntimeException("Could not retrieve good formatter", ie);
}
return formatter;
}
示例3: getActionUrlHref
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
* Used by getActionUrls to print the url on the Vendor Lookup page for the links to edit a Vendor or to create a new division.
* We won't provide a link to copy a vendor because we decided it wouldn't make sense to copy a vendor. We should display the
* link to create a new division only if the vendor is a parent vendor, and also remove the vendor detail assigned id from the
* query string in the link to create a new division. We'll add the vendor detail assigned id in the query string if the vendor
* is not a parent, or if the vendor is a parent and the link is not the create new division link (i.e. if the link is "edit").
* We'll always add the vendor header id in the query string in all links.
*
* @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getActionUrlHref(org.kuali.rice.krad.bo.BusinessObject, java.lang.String, java.util.List)
*/
@Override
protected String getActionUrlHref(BusinessObject businessObject, String methodToCall, List pkNames){
if (!methodToCall.equals(OLEConstants.COPY_METHOD)) {
Properties parameters = new Properties();
parameters.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
parameters.put(OLEConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, businessObject.getClass().getName());
for (Iterator<String> iter = pkNames.iterator(); iter.hasNext();) {
String fieldNm = iter.next();
if (!fieldNm.equals(VendorPropertyConstants.VENDOR_DETAIL_ASSIGNED_ID) ||
!((VendorDetail) businessObject).isVendorParentIndicator()
|| (((VendorDetail) businessObject).isVendorParentIndicator())
&& !methodToCall.equals(OLEConstants.MAINTENANCE_NEWWITHEXISTING_ACTION)) {
Object fieldVal = ObjectUtils.getPropertyValue(businessObject, fieldNm);
if (fieldVal == null) {
fieldVal = OLEConstants.EMPTY_STRING;
}
if (fieldVal instanceof java.sql.Date) {
String formattedString = OLEConstants.EMPTY_STRING;
if (Formatter.findFormatter(fieldVal.getClass()) != null) {
Formatter formatter = Formatter.getFormatter(fieldVal.getClass());
formattedString = (String) formatter.format(fieldVal);
fieldVal = formattedString;
}
}
parameters.put(fieldNm, fieldVal.toString());
}
}
return UrlFactory.parameterizeUrl(OLEConstants.MAINTENANCE_ACTION, parameters);
} else {
return OLEConstants.EMPTY_STRING;
}
}
示例4: getActionUrlHref
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
* Used by getActionUrls to print the url on the Vendor Lookup page for the links to edit a Vendor or to create a new division.
* We won't provide a link to copy a vendor because we decided it wouldn't make sense to copy a vendor. We should display the
* link to create a new division only if the vendor is a parent vendor, and also remove the vendor detail assigned id from the
* query string in the link to create a new division. We'll add the vendor detail assigned id in the query string if the vendor
* is not a parent, or if the vendor is a parent and the link is not the create new division link (i.e. if the link is "edit").
* We'll always add the vendor header id in the query string in all links.
*
* @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getActionUrlHref(org.kuali.rice.krad.bo.BusinessObject, java.lang.String, java.util.List)
*/
@Override
protected String getActionUrlHref(BusinessObject businessObject, String methodToCall, List pkNames){
if (!methodToCall.equals(KFSConstants.COPY_METHOD)) {
Properties parameters = new Properties();
parameters.put(KFSConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
parameters.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, businessObject.getClass().getName());
for (Iterator<String> iter = pkNames.iterator(); iter.hasNext();) {
String fieldNm = iter.next();
if (!fieldNm.equals(VendorPropertyConstants.VENDOR_DETAIL_ASSIGNED_ID) ||
!((VendorDetail) businessObject).isVendorParentIndicator()
|| (((VendorDetail) businessObject).isVendorParentIndicator())
&& !methodToCall.equals(KFSConstants.MAINTENANCE_NEWWITHEXISTING_ACTION)) {
Object fieldVal = ObjectUtils.getPropertyValue(businessObject, fieldNm);
if (fieldVal == null) {
fieldVal = KFSConstants.EMPTY_STRING;
}
if (fieldVal instanceof java.sql.Date) {
String formattedString = KFSConstants.EMPTY_STRING;
if (Formatter.findFormatter(fieldVal.getClass()) != null) {
Formatter formatter = Formatter.getFormatter(fieldVal.getClass());
formattedString = (String) formatter.format(fieldVal);
fieldVal = formattedString;
}
}
parameters.put(fieldNm, fieldVal.toString());
}
}
return UrlFactory.parameterizeUrl(KFSConstants.MAINTENANCE_ACTION, parameters);
} else {
return KFSConstants.EMPTY_STRING;
}
}
示例5: getParametersFromPrimaryKey
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
protected Properties getParametersFromPrimaryKey(BusinessObject businessObject, List pkNames) {
Properties parameters = new Properties();
for (Iterator iter = pkNames.iterator(); iter.hasNext();) {
String fieldNm = (String) iter.next();
Object fieldVal = ObjectUtils.getPropertyValue(businessObject, fieldNm);
if (fieldVal == null) {
fieldVal = KRADConstants.EMPTY_STRING;
}
if (fieldVal instanceof java.sql.Date) {
String formattedString = "";
if (Formatter.findFormatter(fieldVal.getClass()) != null) {
Formatter formatter = Formatter.getFormatter(fieldVal.getClass());
formattedString = (String) formatter.format(fieldVal);
fieldVal = formattedString;
}
}
// Encrypt value if it is a secure field
if (getBusinessObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(businessObjectClass, fieldNm)) {
try {
if(CoreApiServiceLocator.getEncryptionService().isEnabled()) {
fieldVal = getEncryptionService().encrypt(fieldVal) + EncryptionService.ENCRYPTION_POST_PREFIX;
}
} catch (GeneralSecurityException e) {
LOG.error("Exception while trying to encrypted value for inquiry framework.", e);
throw new RuntimeException(e);
}
}
parameters.put(fieldNm, fieldVal.toString());
}
return parameters;
}
示例6: retrieveBestFormatter
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
* Like when you're digging through your stuff drawer, you know the one in the kitchen with all the batteries and lint in it, this method
* goes through the stuff drawer of KNS formatters and attempts to return you a good one
*
* @param propertyName the name of the property to retrieve
* @param boClass the class of the BusinessObject the property is on
* @return a Formatter, or null if we were unsuccessful in finding
*/
protected Formatter retrieveBestFormatter(String propertyName, Class<? extends BusinessObject> boClass) {
Formatter formatter = null;
try {
Class<? extends Formatter> formatterClass = null;
final BusinessObjectEntry boEntry = getBusinessObjectEntry(boClass);
if (boEntry != null) {
final AttributeDefinition attributeDefinition = boEntry.getAttributeDefinition(propertyName);
if (attributeDefinition != null && attributeDefinition.hasFormatterClass()) {
formatterClass = (Class<? extends Formatter>)Class.forName(attributeDefinition.getFormatterClass());
}
}
if (formatterClass == null) {
final java.lang.reflect.Field propertyField = boClass.getDeclaredField(propertyName);
if (propertyField != null) {
formatterClass = Formatter.findFormatter(propertyField.getType());
}
}
if (formatterClass != null) {
formatter = formatterClass.newInstance();
}
} catch (SecurityException se) {
throw new RuntimeException("Could not retrieve good formatter", se);
} catch (ClassNotFoundException cnfe) {
throw new RuntimeException("Could not retrieve good formatter", cnfe);
} catch (NoSuchFieldException nsfe) {
throw new RuntimeException("Could not retrieve good formatter", nsfe);
} catch (IllegalAccessException iae) {
throw new RuntimeException("Could not retrieve good formatter", iae);
} catch (InstantiationException ie) {
throw new RuntimeException("Could not retrieve good formatter", ie);
}
return formatter;
}
示例7: putInactivationBlockingErrorOnPage
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
* If there is a violation of an InactivationBlockingMetadata, it prints out an appropriate error into the error
* map
*
* @param document
* @param inactivationBlockingMetadata
*/
protected void putInactivationBlockingErrorOnPage(MaintenanceDocument document,
InactivationBlockingMetadata inactivationBlockingMetadata) {
if (!persistenceStructureService.hasPrimaryKeyFieldValues(newBo)) {
throw new RuntimeException("Maintenance document did not have all primary key values filled in.");
}
Properties parameters = new Properties();
parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE,
inactivationBlockingMetadata.getBlockedBusinessObjectClass().getName());
parameters
.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.METHOD_DISPLAY_ALL_INACTIVATION_BLOCKERS);
List keys = new ArrayList();
if (getPersistenceStructureService().isPersistable(newBo.getClass())) {
keys = getPersistenceStructureService().listPrimaryKeyFieldNames(newBo.getClass());
}
// build key value url parameters used to retrieve the business object
String keyName = null;
for (Iterator iter = keys.iterator(); iter.hasNext(); ) {
keyName = (String) iter.next();
Object keyValue = null;
if (keyName != null) {
keyValue = ObjectUtils.getPropertyValue(newBo, keyName);
}
if (keyValue == null) {
keyValue = "";
} else if (keyValue instanceof java.sql.Date) { //format the date for passing in url
if (Formatter.findFormatter(keyValue.getClass()) != null) {
Formatter formatter = Formatter.getFormatter(keyValue.getClass());
keyValue = (String) formatter.format(keyValue);
}
} else {
keyValue = keyValue.toString();
}
// Encrypt value if it is a secure field
if (businessObjectAuthorizationService.attributeValueNeedsToBeEncryptedOnFormsAndLinks(
inactivationBlockingMetadata.getBlockedBusinessObjectClass(), keyName)) {
try {
if(CoreApiServiceLocator.getEncryptionService().isEnabled()) {
keyValue = CoreApiServiceLocator.getEncryptionService().encrypt(keyValue);
}
} catch (GeneralSecurityException e) {
LOG.error("Exception while trying to encrypted value for inquiry framework.", e);
throw new RuntimeException(e);
}
}
parameters.put(keyName, keyValue);
}
String blockingUrl =
UrlFactory.parameterizeUrl(KRADConstants.DISPLAY_ALL_INACTIVATION_BLOCKERS_ACTION, parameters);
// post an error about the locked document
GlobalVariables.getMessageMap()
.putError(KRADConstants.GLOBAL_ERRORS, RiceKeyConstants.ERROR_INACTIVATION_BLOCKED, blockingUrl);
}
示例8: getParametersFromPrimaryKey
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
protected Properties getParametersFromPrimaryKey(BusinessObject businessObject, List pkNames) {
Properties parameters = new Properties();
for (Iterator iter = pkNames.iterator(); iter.hasNext();) {
String fieldNm = (String) iter.next();
// If we cannot find the attribute in the data dictionary, then we cannot determine whether it should be encrypted
if (getDataDictionaryService().getAttributeDefinition(businessObjectClass.getName(), fieldNm) == null) {
String errorMessage = "The field " + fieldNm + " could not be found in the data dictionary for class "
+ businessObjectClass.getName() + ", and thus it could not be determined whether it is a secure field.";
if (ConfigContext.getCurrentContextConfig().getBooleanProperty(KNSConstants.EXCEPTION_ON_MISSING_FIELD_CONVERSION_ATTRIBUTE, false)) {
throw new RuntimeException(errorMessage);
} else {
LOG.error(errorMessage);
continue;
}
}
Object fieldVal = ObjectUtils.getPropertyValue(businessObject, fieldNm);
if (fieldVal == null) {
fieldVal = KRADConstants.EMPTY_STRING;
}
if (fieldVal instanceof java.sql.Date) {
String formattedString = "";
if (Formatter.findFormatter(fieldVal.getClass()) != null) {
Formatter formatter = Formatter.getFormatter(fieldVal.getClass());
formattedString = (String) formatter.format(fieldVal);
fieldVal = formattedString;
}
}
// secure values are not passed in urls
if (getBusinessObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(businessObjectClass, fieldNm)) {
LOG.warn("field name " + fieldNm + " is a secure value and not included in pk parameter results");
continue;
}
parameters.put(fieldNm, fieldVal.toString());
}
return parameters;
}
示例9: putInactivationBlockingErrorOnPage
import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
* If there is a violation of an InactivationBlockingMetadata, it prints out an appropriate error into the error
* map
*
* @param document
* @param inactivationBlockingMetadata
*/
protected void putInactivationBlockingErrorOnPage(MaintenanceDocument document,
InactivationBlockingMetadata inactivationBlockingMetadata) {
if (!getPersistenceStructureService().hasPrimaryKeyFieldValues(newDataObject)) {
throw new RuntimeException("Maintenance document did not have all primary key values filled in.");
}
Properties parameters = new Properties();
parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE,
inactivationBlockingMetadata.getBlockedBusinessObjectClass().getName());
parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER,
KRADConstants.METHOD_DISPLAY_ALL_INACTIVATION_BLOCKERS);
List keys = new ArrayList();
if (getPersistenceStructureService().isPersistable(newDataObject.getClass())) {
keys = getPersistenceStructureService().listPrimaryKeyFieldNames(newDataObject.getClass());
}
// build key value url parameters used to retrieve the business object
String keyName = null;
for (Iterator iter = keys.iterator(); iter.hasNext(); ) {
keyName = (String) iter.next();
Object keyValue = null;
if (keyName != null) {
keyValue = ObjectUtils.getPropertyValue(newDataObject, keyName);
}
if (keyValue == null) {
keyValue = "";
} else if (keyValue instanceof java.sql.Date) { //format the date for passing in url
if (Formatter.findFormatter(keyValue.getClass()) != null) {
Formatter formatter = Formatter.getFormatter(keyValue.getClass());
keyValue = (String) formatter.format(keyValue);
}
} else {
keyValue = keyValue.toString();
}
// Encrypt value if it is a secure field
if (getDataObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(
inactivationBlockingMetadata.getBlockedBusinessObjectClass(), keyName)) {
try {
if(CoreApiServiceLocator.getEncryptionService().isEnabled()) {
keyValue = CoreApiServiceLocator.getEncryptionService().encrypt(keyValue);
}
} catch (GeneralSecurityException e) {
LOG.error("Exception while trying to encrypted value for inquiry framework.", e);
throw new RuntimeException(e);
}
}
parameters.put(keyName, keyValue);
}
String blockingUrl = UrlFactory.parameterizeUrl(KRADConstants.DISPLAY_ALL_INACTIVATION_BLOCKERS_ACTION,
parameters);
// post an error about the locked document
GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,
RiceKeyConstants.ERROR_INACTIVATION_BLOCKED, blockingUrl);
}