org.kuali.rice.kns.util
Class FieldUtils

java.lang.Object
  extended by org.kuali.rice.kns.util.FieldUtils

public final class FieldUtils
extends Object

This class is used to build Field objects from underlying data dictionary and general utility methods for handling fields.


Method Summary
static void applyAuthorization(Field field, String maintenanceAction, MaintenanceDocumentRestrictions auths, String documentStatus, String documentInitiatorPrincipalId)
           
static Column constructColumnFromAttributeField(RemotableAttributeField attributeField)
           
static List<Column> constructColumnsFromAttributeFields(List<RemotableAttributeField> attributeFields)
           
static Field constructContainerField(String name, String label, List fields)
          Wraps list of fields into a Field of type CONTAINER
static Field constructContainerField(String name, String label, List fields, int numberOfColumns)
          Wraps list of fields into a Field of type CONTAINER and arrange them into multiple columns.
static RemotableAttributeField convertFieldToAttributeField(Field field)
           
static List<Field> convertRemotableAttributeField(RemotableAttributeField remotableAttributeField)
           
static List<Row> convertRemotableAttributeFields(List<RemotableAttributeField> remotableAttributeFields)
           
static List<RemotableAttributeField> convertRowsToAttributeFields(List<Row> rows)
           
static List<RemotableAttributeField> convertRowToAttributeFields(Row row)
           
static List<Field> createAndPopulateFieldsForLookup(List<String> lookupFieldAttributeList, List<String> readOnlyFieldsList, Class businessObjectClass)
           
static Field createRangeDateField(Field field)
          creates an extra field for date from/to ranges
static Field fixFieldForForm(Field field, List keyFieldNames, String namePrefix, String maintenanceAction, boolean readOnly, MaintenanceDocumentRestrictions auths, String documentStatus, String documentInitiatorPrincipalId)
          Does prefixing and read only settings of a Field UI for display in a maintenance document.
static String generateCollectionSubTabName(Field field)
          Finds a container field's sub tab name
static Formatter getFormatterForDataType(DataType dataType)
           
static Field getPropertyField(Class businessObjectClass, String attributeName, boolean convertForLookup)
          Builds up a Field object based on the propertyName and business object class.
static boolean isCollectionMultipleLookupEnabled(MaintainableCollectionDefinition definition)
          Returns whether the passed in collection has been properly configured in the maint doc dictionary to support multiple value lookups.
protected static boolean isLookupFieldLevelHelpDisabled(Class businessObjectClass, String attributeName)
          Determines whether field level help is disabled for the field corresponding to the dataObjectClass and attribute name If this value is true and isLookupFieldLevelHelpEnabled(Class, String) returns false, then the field level help will not be rendered.
protected static boolean isLookupFieldLevelHelpEnabled(Class businessObjectClass, String attributeName)
          Determines whether field level help is enabled for the field corresponding to the dataObjectClass and attribute name If this value is true, then the field level help will be enabled.
static List meshFields(List oldFields, List newFields, List keyFieldNames, String maintenanceAction, boolean readOnly, MaintenanceDocumentRestrictions auths, String documentStatus, String documentInitiatorPrincipalId)
          Merges together fields and an old maintainble row and new maintainable row, for each field call fixFieldForForm.
static List meshRows(List oldRows, List newRows, List keyFieldNames, String maintenanceAction, boolean readOnly, MaintenanceDocumentRestrictions auths, String documentStatus, String documentInitiatorPrincipalId)
          Merges together rows of an old maintainable section and new maintainable section.
static List meshSections(List oldSections, List newSections, List keyFieldNames, String maintenanceAction, boolean readOnly, MaintenanceDocumentRestrictions auths, String documentStatus, String documentInitiatorPrincipalId)
          Merges together sections of the old maintainable and new maintainable.
static void modifyFieldToSupportMultipleValueLookups(Field field, String parents, MaintainableCollectionDefinition definition)
          This method modifies the passed in field so that it may be used to render a multiple values lookup button
static Map populateBusinessObjectFromMap(BusinessObject bo, Map fieldValues)
          Uses reflection to get the property names of the business object, then checks for the property name as a key in the passed map.
static Map populateBusinessObjectFromMap(BusinessObject bo, Map<String,?> fieldValues, String propertyNamePrefix)
          Uses reflection to get the property names of the business object, then checks for the property name as a key in the passed map.
static List<Field> populateFieldsFromBusinessObject(List<Field> fields, BusinessObject bo)
          Uses reflection to get the property names of the business object, then checks for a matching field property name.
static void populateReadableField(Field field, BusinessObject businessObject)
           
static void populateSecureField(Field field, Object fieldValue)
           
static String scrubWhitespace(String s)
          This method removes any duplicating spacing (internal or on the ends) from a String, meant to be exposed as a tag library function.
static void setAdditionalDisplayPropertyForCodes(Class businessObjectClass, String attributeName, PropertyRenderingConfigElement field)
          For attributes that are codes (determined by whether they have a reference to a KualiCode bo and similar naming) sets the name as an additional display property
static void setFieldControl(Class businessObjectClass, String attributeName, boolean convertForLookup, Field field)
          Sets the control on the field based on the data dictionary definition
static void setInquiryURL(Field field, BusinessObject bo, String propertyName)
           
static List wrapFields(List fields)
          Wraps each Field in the list into a Row.
static List<Row> wrapFields(List<Field> fields, int numberOfColumns)
          This method is to implement multiple columns where the numberOfColumns is obtained from data dictionary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setInquiryURL

public static void setInquiryURL(Field field,
                                 BusinessObject bo,
                                 String propertyName)

setFieldControl

public static void setFieldControl(Class businessObjectClass,
                                   String attributeName,
                                   boolean convertForLookup,
                                   Field field)
Sets the control on the field based on the data dictionary definition

Parameters:
businessObjectClass - - business object class for the field attribute
attributeName - - name of the attribute whose Field is being set
convertForLookup - - whether the field is being build for lookup search which impacts the control chosen
field - - Field to set control on

getPropertyField

public static Field getPropertyField(Class businessObjectClass,
                                     String attributeName,
                                     boolean convertForLookup)
Builds up a Field object based on the propertyName and business object class. See KULRICE-2480 for info on convertForLookup flag


setAdditionalDisplayPropertyForCodes

public static void setAdditionalDisplayPropertyForCodes(Class businessObjectClass,
                                                        String attributeName,
                                                        PropertyRenderingConfigElement field)
For attributes that are codes (determined by whether they have a reference to a KualiCode bo and similar naming) sets the name as an additional display property

Parameters:
businessObjectClass - - class containing attribute
attributeName - - name of attribute in the business object
field - - property display element

wrapFields

public static List wrapFields(List fields)
Wraps each Field in the list into a Row.

Parameters:
fields -
Returns:
List of Row objects

wrapFields

public static List<Row> wrapFields(List<Field> fields,
                                   int numberOfColumns)
This method is to implement multiple columns where the numberOfColumns is obtained from data dictionary.

Parameters:
fields -
numberOfColumns -
Returns:

constructContainerField

public static Field constructContainerField(String name,
                                            String label,
                                            List fields)
Wraps list of fields into a Field of type CONTAINER

Parameters:
name - name for the field
label - label for the field
fields - list of fields that should be contained in the container
Returns:
Field of type CONTAINER

constructContainerField

public static Field constructContainerField(String name,
                                            String label,
                                            List fields,
                                            int numberOfColumns)
Wraps list of fields into a Field of type CONTAINER and arrange them into multiple columns.

Parameters:
name - name for the field
label - label for the field
fields - list of fields that should be contained in the container
numberOfColumns - the number of columns for each row that the fields should be arranged into
Returns:
Field of type CONTAINER

populateFieldsFromBusinessObject

public static List<Field> populateFieldsFromBusinessObject(List<Field> fields,
                                                           BusinessObject bo)
Uses reflection to get the property names of the business object, then checks for a matching field property name. If found, takes the value of the business object property and populates the field value. Iterates through for all fields in the list.

Parameters:
fields - list of Field object to populate
bo - business object to get field values from
Returns:
List of fields with values populated from business object.

populateReadableField

public static void populateReadableField(Field field,
                                         BusinessObject businessObject)

populateSecureField

public static void populateSecureField(Field field,
                                       Object fieldValue)

populateBusinessObjectFromMap

public static Map populateBusinessObjectFromMap(BusinessObject bo,
                                                Map fieldValues)
Uses reflection to get the property names of the business object, then checks for the property name as a key in the passed map. If found, takes the value from the map and sets the business object property.

Parameters:
bo -
fieldValues -
Returns:
Cached Values from any formatting failures

populateBusinessObjectFromMap

public static Map populateBusinessObjectFromMap(BusinessObject bo,
                                                Map<String,?> fieldValues,
                                                String propertyNamePrefix)
Uses reflection to get the property names of the business object, then checks for the property name as a key in the passed map. If found, takes the value from the map and sets the business object property.

Parameters:
bo -
fieldValues -
propertyNamePrefix - this value will be prepended to all property names in the returned unformattable values map
Returns:
Cached Values from any formatting failures

fixFieldForForm

public static Field fixFieldForForm(Field field,
                                    List keyFieldNames,
                                    String namePrefix,
                                    String maintenanceAction,
                                    boolean readOnly,
                                    MaintenanceDocumentRestrictions auths,
                                    String documentStatus,
                                    String documentInitiatorPrincipalId)
Does prefixing and read only settings of a Field UI for display in a maintenance document.

Parameters:
field - - the Field object to be displayed
keyFieldNames - - Primary key property names for the business object being maintained.
namePrefix - - String to prefix Field names with.
maintenanceAction - - The maintenance action requested.
readOnly - - Indicates whether all fields should be read only.
Returns:
Field

applyAuthorization

public static void applyAuthorization(Field field,
                                      String maintenanceAction,
                                      MaintenanceDocumentRestrictions auths,
                                      String documentStatus,
                                      String documentInitiatorPrincipalId)

meshSections

public static List meshSections(List oldSections,
                                List newSections,
                                List keyFieldNames,
                                String maintenanceAction,
                                boolean readOnly,
                                MaintenanceDocumentRestrictions auths,
                                String documentStatus,
                                String documentInitiatorPrincipalId)
Merges together sections of the old maintainable and new maintainable.

Parameters:
oldSections -
newSections -
keyFieldNames -
maintenanceAction -
readOnly -
Returns:
List of Section objects

meshRows

public static List meshRows(List oldRows,
                            List newRows,
                            List keyFieldNames,
                            String maintenanceAction,
                            boolean readOnly,
                            MaintenanceDocumentRestrictions auths,
                            String documentStatus,
                            String documentInitiatorPrincipalId)
Merges together rows of an old maintainable section and new maintainable section.

Parameters:
oldRows -
newRows -
keyFieldNames -
maintenanceAction -
readOnly -
Returns:
List of Row objects

meshFields

public static List meshFields(List oldFields,
                              List newFields,
                              List keyFieldNames,
                              String maintenanceAction,
                              boolean readOnly,
                              MaintenanceDocumentRestrictions auths,
                              String documentStatus,
                              String documentInitiatorPrincipalId)
Merges together fields and an old maintainble row and new maintainable row, for each field call fixFieldForForm.

Parameters:
oldFields -
newFields -
keyFieldNames -
maintenanceAction -
readOnly -
Returns:
List of Field objects

isLookupFieldLevelHelpEnabled

protected static boolean isLookupFieldLevelHelpEnabled(Class businessObjectClass,
                                                       String attributeName)
Determines whether field level help is enabled for the field corresponding to the dataObjectClass and attribute name If this value is true, then the field level help will be enabled. If false, then whether a field is enabled is determined by the value returned by isLookupFieldLevelHelpDisabled(Class, String) and the system-wide parameter setting. Note that if a field is read-only, that may cause field-level help to not be rendered.

Parameters:
businessObjectClass - the looked up class
attributeName - the attribute for the field
Returns:
true if field level help is enabled, false if the value of this method should NOT be used to determine whether this method's return value affects the enablement of field level help

isLookupFieldLevelHelpDisabled

protected static boolean isLookupFieldLevelHelpDisabled(Class businessObjectClass,
                                                        String attributeName)
Determines whether field level help is disabled for the field corresponding to the dataObjectClass and attribute name If this value is true and isLookupFieldLevelHelpEnabled(Class, String) returns false, then the field level help will not be rendered. If both this and isLookupFieldLevelHelpEnabled(Class, String) return false, then the system-wide setting will determine whether field level help is enabled. Note that if a field is read-only, that may cause field-level help to not be rendered.

Parameters:
businessObjectClass - the looked up class
attributeName - the attribute for the field
Returns:
true if field level help is disabled, false if the value of this method should NOT be used to determine whether this method's return value affects the enablement of field level help

createAndPopulateFieldsForLookup

public static List<Field> createAndPopulateFieldsForLookup(List<String> lookupFieldAttributeList,
                                                           List<String> readOnlyFieldsList,
                                                           Class businessObjectClass)
                                                    throws InstantiationException,
                                                           IllegalAccessException
Throws:
InstantiationException
IllegalAccessException

createRangeDateField

public static Field createRangeDateField(Field field)
creates an extra field for date from/to ranges

Parameters:
field -
Returns:
a new date field

modifyFieldToSupportMultipleValueLookups

public static final void modifyFieldToSupportMultipleValueLookups(Field field,
                                                                  String parents,
                                                                  MaintainableCollectionDefinition definition)
This method modifies the passed in field so that it may be used to render a multiple values lookup button

Parameters:
field - this object will be modified by this method
parents -
definition -

isCollectionMultipleLookupEnabled

public static final boolean isCollectionMultipleLookupEnabled(MaintainableCollectionDefinition definition)
Returns whether the passed in collection has been properly configured in the maint doc dictionary to support multiple value lookups.

Parameters:
definition -
Returns:

scrubWhitespace

public static String scrubWhitespace(String s)
This method removes any duplicating spacing (internal or on the ends) from a String, meant to be exposed as a tag library function.

Parameters:
s - String to remove duplicate spacing from.
Returns:
String without duplicate spacing.

convertRemotableAttributeFields

public static List<Row> convertRemotableAttributeFields(List<RemotableAttributeField> remotableAttributeFields)

convertRemotableAttributeField

public static List<Field> convertRemotableAttributeField(RemotableAttributeField remotableAttributeField)

convertRowsToAttributeFields

public static List<RemotableAttributeField> convertRowsToAttributeFields(List<Row> rows)

convertRowToAttributeFields

public static List<RemotableAttributeField> convertRowToAttributeFields(Row row)

convertFieldToAttributeField

public static RemotableAttributeField convertFieldToAttributeField(Field field)

constructColumnFromAttributeField

public static Column constructColumnFromAttributeField(RemotableAttributeField attributeField)

constructColumnsFromAttributeFields

public static List<Column> constructColumnsFromAttributeFields(List<RemotableAttributeField> attributeFields)

getFormatterForDataType

public static Formatter getFormatterForDataType(DataType dataType)

generateCollectionSubTabName

public static String generateCollectionSubTabName(Field field)
Finds a container field's sub tab name

Parameters:
field - the field for which to derive the collection sub tab name
Returns:
the sub tab name


Copyright © 2005-2014 The Kuali Foundation. All Rights Reserved.