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


Java Formatter.format方法代码示例

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


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

示例1: retrieveFormValueForLookupInquiryParameters

import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的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);	
  }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:KualiForm.java

示例2: getFormattedPropertyValue

import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
 * Gets the property value from the business object, then based on the value
 * type select a formatter and format the value
 *
 * @param businessObject BusinessObject instance that contains the property
 * @param propertyName Name of property in BusinessObject to get value for
 * @param formatter Default formatter to use (or null)
 * @return Formatted property value as String, or empty string if value is null
 */
@Deprecated
public static String getFormattedPropertyValue(BusinessObject businessObject, String propertyName,
        Formatter formatter) {
    String propValue = KRADConstants.EMPTY_STRING;

    Object prop = ObjectUtils.getPropertyValue(businessObject, propertyName);
    if (formatter == null) {
        propValue = formatPropertyValue(prop);
    } else {
        final Object formattedValue = formatter.format(prop);
        if (formattedValue != null) {
            propValue = String.valueOf(formattedValue);
        }
    }

    return propValue;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:ObjectUtils.java

示例3: validateSearchParameters

import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
 * Overridden to validate the invoie amount and payment date fields to make sure they are parsable
 * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#validateSearchParameters(java.util.Map)
 */
@Override
public void validateSearchParameters(Map<String, String> fieldValues) {
    if (!StringUtils.isBlank(fieldValues.get(ArPropertyConstants.PAYMENT_DATE))) {
        validateDateField(fieldValues.get(ArPropertyConstants.PAYMENT_DATE), ArPropertyConstants.PAYMENT_DATE, getDateTimeService());
    }
    if (!StringUtils.isBlank(fieldValues.get(ArPropertyConstants.RANGE_LOWER_BOUND_KEY_PREFIX+ArPropertyConstants.PAYMENT_DATE))) {
        validateDateField(fieldValues.get(ArPropertyConstants.RANGE_LOWER_BOUND_KEY_PREFIX+ArPropertyConstants.PAYMENT_DATE), ArPropertyConstants.RANGE_LOWER_BOUND_KEY_PREFIX+ArPropertyConstants.PAYMENT_DATE, getDateTimeService());
    }
    if (!StringUtils.isBlank(fieldValues.get(ArPropertyConstants.INVOICE_AMOUNT))) {
        try {
            Formatter f = new CurrencyFormatter();
            f.format(fieldValues.get(ArPropertyConstants.INVOICE_AMOUNT));
        } catch (FormatException fe) {
            // we'll assume this was a parse exception
            final String label = getDataDictionaryService().getAttributeLabel(getBusinessObjectClass(), ArPropertyConstants.INVOICE_AMOUNT);
            GlobalVariables.getMessageMap().putError(ArPropertyConstants.INVOICE_AMOUNT, KFSKeyConstants.ERROR_NUMERIC, label);
        }
    }
    super.validateSearchParameters(fieldValues);
}
 
开发者ID:kuali,项目名称:kfs,代码行数:25,代码来源:ContractsGrantsPaymentHistoryReportLookupableHelperServiceImpl.java

示例4: getFormattedPropertyValue

import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
 * Gets the property value from the business object, then based on the value
 * type select a formatter and format the value
 *
 * @param businessObject BusinessObject instance that contains the property
 * @param propertyName Name of property in BusinessObject to get value for
 * @param formatter Default formatter to use (or null)
 * @return Formatted property value as String, or empty string if value is null
 */
public static String getFormattedPropertyValue(BusinessObject businessObject, String propertyName,
        Formatter formatter) {
    String propValue = KRADConstants.EMPTY_STRING;

    Object prop = ObjectUtils.getPropertyValue(businessObject, propertyName);
    if (formatter == null) {
        propValue = formatPropertyValue(prop);
    } else {
        final Object formattedValue = formatter.format(prop);
        if (formattedValue != null) {
            propValue = String.valueOf(formattedValue);
        }
    }

    return propValue;
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:26,代码来源:ObjectUtils.java

示例5: testFormat

import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
@Test 
public void testFormat() throws Exception {
    Formatter testFormatter = Formatter.getFormatter(KualiPercent.class, null);
            
    KualiDecimal decimal1 = new KualiDecimal(52);
    KualiDecimal decimal2 = new KualiDecimal(32.3); 

    String percent1 = (String)testFormatter.format(decimal1);
    String percent2 = (String)testFormatter.format(decimal2);
    
    assertEquals("52 percent", percent1);
    assertEquals("32.3 percent", percent2);

}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:15,代码来源:KualiPercentTest.java

示例6: getCreateDate

import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
 * Returns the formatted string of the create date. If the createDate is currently null, we'll
 * get the createDate from the workflowDocument.
 *
 * @return
 * @throws WorkflowException
 */
public String getCreateDate() throws WorkflowException {
    if (createDate == null) {
        Formatter formatter = new DateViewDateObjectFormatter();
        createDate = (String) formatter.format(getRequisition().getFinancialSystemDocumentHeader().getWorkflowDocument().getDateCreated().toDate());
    }
    return createDate;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:15,代码来源:ContractManagerAssignmentDetail.java

示例7: getTableCellValues

import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
 * Returns the values in a list of the passed in business object in order of the spring definition. The value for the
 * "EMPTY_CELL" entry is an empty string.
 * 
 * @param businessObject for which to return the values
 * @param allowColspan indicate whether colspan definition can be applied
 * @return the values being put into the table cells
 */
public List<String> getTableCellValues(BusinessObject businessObject, boolean allowColspan) {
    List<String> tableCellValues = new ArrayList<String>();

    for (Map.Entry<String, String> entry : orderedPropertyNameToHeaderLabelMap.entrySet()) {
        String attributeName = entry.getKey();

        if (attributeName.startsWith(OLEConstants.ReportConstants.EMPTY_CELL_ENTRY_KEY_PREFIX)) {
            tableCellValues.add(StringUtils.EMPTY);
        }
        else {
            try {
                Object propertyValue = retrievePropertyValue(businessObject, attributeName);
                
                if (ObjectUtils.isNotNull(propertyValue)) {
                    Formatter formatter = Formatter.getFormatter(propertyValue.getClass());
                    if(ObjectUtils.isNotNull(formatter) && ObjectUtils.isNotNull(propertyValue)) {
                        propertyValue = formatter.format(propertyValue);
                    }
                    else {
                        propertyValue = StringUtils.EMPTY;
                    }
                } else {
                    propertyValue = StringUtils.EMPTY;
                }
                
                tableCellValues.add(propertyValue.toString());
            }
            catch (Exception e) {
                throw new RuntimeException("Failed getting propertyName=" + entry.getKey() + " from businessObjecName=" + dataDictionaryBusinessObjectClass.getName(), e);
            }
        }
    }
    
    if(allowColspan) {
        this.applyColspanOnCellValues(tableCellValues);
    }

    return tableCellValues;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:48,代码来源:BusinessObjectReportHelper.java

示例8: 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;
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:44,代码来源:VendorLookupableHelperServiceImpl.java

示例9: getCreateDate

import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
 * Returns the formatted string of the create date. If the createDate is currently null, we'll
 * get the createDate from the workflowDocument.
 * 
 * @return
 * @throws WorkflowException
 */
public String getCreateDate() throws WorkflowException{
    if (createDate == null) {
        Formatter formatter = new DateViewDateObjectFormatter();
        createDate = (String)formatter.format(getRequisition().getFinancialSystemDocumentHeader().getWorkflowDocument().getDateCreated().toDate());
    }
    return createDate;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:15,代码来源:ContractManagerAssignmentDetail.java

示例10: getTableCellValues

import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
/**
 * Returns the values in a list of the passed in business object in order of the spring definition. The value for the
 * "EMPTY_CELL" entry is an empty string.
 * 
 * @param businessObject for which to return the values
 * @param allowColspan indicate whether colspan definition can be applied
 * @return the values being put into the table cells
 */
public List<String> getTableCellValues(BusinessObject businessObject, boolean allowColspan) {
    List<String> tableCellValues = new ArrayList<String>();

    for (Map.Entry<String, String> entry : orderedPropertyNameToHeaderLabelMap.entrySet()) {
        String attributeName = entry.getKey();

        if (attributeName.startsWith(KFSConstants.ReportConstants.EMPTY_CELL_ENTRY_KEY_PREFIX)) {
            tableCellValues.add(StringUtils.EMPTY);
        }
        else {
            try {
                Object propertyValue = retrievePropertyValue(businessObject, attributeName);
                
                if (ObjectUtils.isNotNull(propertyValue)) {
                    Formatter formatter = Formatter.getFormatter(propertyValue.getClass());
                    if(ObjectUtils.isNotNull(formatter) && ObjectUtils.isNotNull(propertyValue)) {
                        propertyValue = formatter.format(propertyValue);
                    }
                    else {
                        propertyValue = StringUtils.EMPTY;
                    }
                } else {
                    propertyValue = StringUtils.EMPTY;
                }
                
                tableCellValues.add(propertyValue.toString());
            }
            catch (Exception e) {
                throw new RuntimeException("Failed getting propertyName=" + entry.getKey() + " from businessObjecName=" + dataDictionaryBusinessObjectClass.getName(), e);
            }
        }
    }
    
    if(allowColspan) {
        this.applyColspanOnCellValues(tableCellValues);
    }

    return tableCellValues;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:48,代码来源:BusinessObjectReportHelper.java

示例11: 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;
    }
}
 
开发者ID:kuali,项目名称:kfs,代码行数:44,代码来源:VendorLookupableHelperServiceImpl.java

示例12: 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;
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:36,代码来源:AbstractLookupableHelperServiceImpl.java

示例13: listAllBlockerRecords

import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
@Override
public List<String> listAllBlockerRecords(BusinessObject blockedBo, InactivationBlockingMetadata inactivationBlockingMetadata) {
       String inactivationBlockingDetectionServiceBeanName = inactivationBlockingMetadata.getInactivationBlockingDetectionServiceBeanName();
       if (StringUtils.isBlank(inactivationBlockingDetectionServiceBeanName)) {
           inactivationBlockingDetectionServiceBeanName = KRADServiceLocatorWeb.DEFAULT_INACTIVATION_BLOCKING_DETECTION_SERVICE;
       }
       InactivationBlockingDetectionService inactivationBlockingDetectionService = KRADServiceLocatorWeb
               .getInactivationBlockingDetectionService(inactivationBlockingDetectionServiceBeanName);

       Collection<BusinessObject> collection = inactivationBlockingDetectionService.listAllBlockerRecords(blockedBo, inactivationBlockingMetadata);

       Map<String, Formatter> formatters = getFormattersForPrimaryKeyFields(inactivationBlockingMetadata.getBlockingReferenceBusinessObjectClass());

       List<String> displayValues = new ArrayList<String>();
       List<String> pkFieldNames = getLegacyDataAdapter().listPrimaryKeyFieldNames(inactivationBlockingMetadata.getBlockingReferenceBusinessObjectClass());
       Person user = GlobalVariables.getUserSession().getPerson();

       for (BusinessObject element : collection) {
       	StringBuilder buf = new StringBuilder();

       	// the following method will return a restriction for all DD-defined attributes
       	BusinessObjectRestrictions businessObjectRestrictions = getBusinessObjectAuthorizationService().getLookupResultRestrictions(element, user);
       	for (int i = 0; i < pkFieldNames.size(); i++) {
       		String pkFieldName = pkFieldNames.get(i);
       		Object value = KradDataServiceLocator.getDataObjectService().wrap(element).getPropertyValueNullSafe(pkFieldName);

       		String displayValue = null;
       		if (!businessObjectRestrictions.hasRestriction(pkFieldName)) {
       			Formatter formatter = formatters.get(pkFieldName);
       			if (formatter != null) {
       				displayValue = (String) formatter.format(value);
       			}
       			else {
       				displayValue = String.valueOf(value);
       			}
       		}
       		else {
       			FieldRestriction fieldRestriction = businessObjectRestrictions.getFieldRestriction(pkFieldName);
       			if (fieldRestriction.isMasked() || fieldRestriction.isPartiallyMasked()) {
	    			MaskFormatter maskFormatter = fieldRestriction.getMaskFormatter();
					displayValue = maskFormatter.maskValue(value);
       			}
       			else {
       				// there was a restriction, but we did not know how to obey it.
       				LOG.warn("Restriction was defined for class: " + element.getClass() + " field name: " + pkFieldName + ", but it was not honored by the inactivation blocking display framework");
       			}
       		}

       		buf.append(displayValue);
       		if (i < pkFieldNames.size() - 1) {
       			buf.append(" - ");
       		}
       	}

       	displayValues.add(buf.toString());
       }
	return displayValues;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:59,代码来源:InactivationBlockingDisplayServiceImpl.java

示例14: displayAllBlockingRecords

import org.kuali.rice.core.web.format.Formatter; //导入方法依赖的package包/类
@Override
public List<String> displayAllBlockingRecords(Object blockedBo, InactivationBlockingMetadata inactivationBlockingMetadata) {
    String inactivationBlockingDetectionServiceBeanName = inactivationBlockingMetadata.getInactivationBlockingDetectionServiceBeanName();
    if (StringUtils.isBlank(inactivationBlockingDetectionServiceBeanName)) {
        inactivationBlockingDetectionServiceBeanName = KRADServiceLocatorWeb.DEFAULT_INACTIVATION_BLOCKING_DETECTION_SERVICE;
    }
    InactivationBlockingDetectionService inactivationBlockingDetectionService = KRADServiceLocatorWeb
            .getInactivationBlockingDetectionService(inactivationBlockingDetectionServiceBeanName);

    Collection<?> collection = inactivationBlockingDetectionService.detectAllBlockingRecords(blockedBo, inactivationBlockingMetadata);

    Map<String, Formatter> formatters = getFormattersForPrimaryKeyFields(inactivationBlockingMetadata.getBlockingReferenceBusinessObjectClass());

    List<String> displayValues = new ArrayList<String>();
    List<String> pkFieldNames = getLegacyDataAdapter().listPrimaryKeyFieldNames(inactivationBlockingMetadata.getBlockingReferenceBusinessObjectClass());
    Person user = GlobalVariables.getUserSession().getPerson();

    for (Object element : collection) {
        StringBuilder buf = new StringBuilder();

        // the following method will return a restriction for all DD-defined attributes
        BusinessObjectRestrictions businessObjectRestrictions = getBusinessObjectAuthorizationService().getLookupResultRestrictions(element, user);
        for (int i = 0; i < pkFieldNames.size(); i++) {
            String pkFieldName = pkFieldNames.get(i);
            Object value = KradDataServiceLocator.getDataObjectService().wrap(element).getPropertyValueNullSafe(pkFieldName);

            String displayValue = null;
            if (!businessObjectRestrictions.hasRestriction(pkFieldName)) {
                Formatter formatter = formatters.get(pkFieldName);
                if (formatter != null) {
                    displayValue = (String) formatter.format(value);
                }
                else {
                    displayValue = String.valueOf(value);
                }
            }
            else {
                FieldRestriction fieldRestriction = businessObjectRestrictions.getFieldRestriction(pkFieldName);
                if (fieldRestriction.isMasked() || fieldRestriction.isPartiallyMasked()) {
                    MaskFormatter maskFormatter = fieldRestriction.getMaskFormatter();
                    displayValue = maskFormatter.maskValue(value);
                }
                else {
                    // there was a restriction, but we did not know how to obey it.
                    LOG.warn("Restriction was defined for class: " + element.getClass() + " field name: " + pkFieldName + ", but it was not honored by the inactivation blocking display framework");
                }
            }

            buf.append(displayValue);
            if (i < pkFieldNames.size() - 1) {
                buf.append(" - ");
            }
        }

        displayValues.add(buf.toString());
    }
    return displayValues;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:59,代码来源:InactivationBlockingDisplayServiceImpl.java

示例15: 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);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:68,代码来源:MaintenanceDocumentRuleBase.java


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