to.etc.domui.component.meta.impl
Class PathPropertyMetaModel<T>

java.lang.Object
  extended by to.etc.domui.component.meta.impl.PathPropertyMetaModel<T>
All Implemented Interfaces:
PropertyMetaModel<T>, IValueAccessor<T>, IValueTransformer<T>

public class PathPropertyMetaModel<T>
extends java.lang.Object
implements PropertyMetaModel<T>, IValueAccessor<T>

This is a proxy for an existing PropertyMetaModel for path-based properties. This overrides the Accessor and replaces it with an accessor which walks the path to the target property. In addition this uses extended rules to determine the default label and stuff for the extended property.

Author:
Frits Jalvingh Created on Dec 29, 2008

Constructor Summary
PathPropertyMetaModel(java.lang.String dottedName, PropertyMetaModel<?>[] accessPath)
           
 
Method Summary
 java.lang.Class<T> getActualType()
          Returns the actual type of the property's value.
 ClassMetaModel getClassModel()
          The ClassModel that this property is a property of.
 java.lang.Class<? extends IComboDataSet<?>> getComboDataSet()
          If this should be represented by a combo this can be set to represent the default combo dataset.
 java.util.List<DisplayPropertyMetaModel> getComboDisplayProperties()
          For a relation, this is the list of properties that should be shown.
 java.lang.Class<? extends ILabelStringRenderer<?>> getComboLabelRenderer()
          When this relation-property is presented as a single field this can contain a class to render that field as a string.
 java.lang.Class<? extends INodeContentRenderer<?>> getComboNodeRenderer()
          When set this renderer should be used to render the nodes in the combobox.
 java.lang.String getComponentTypeHint()
          When present this gives a hint to the component factories to help with choosing a proper component to select a single record of the type specified by this property.
 ControlFactory getControlFactory()
          If a specific control factory is to be used to create controls for this item this returns that factory.
 IConverter<T> getConverter()
          Returns the user-specified converter to use when converting this property's value to and from string.
 java.lang.String getDefaultHint()
          Returns the default hint text (which pops up when the mouse is held over the control that inputs this item).
 java.lang.String getDefaultLabel()
          Return any default label (the text to use before the control that inputs this property) for this property.
 int getDisplayLength()
          Returns the #chars to be displayed by default for this item.
 java.lang.String getDomainValueLabel(java.util.Locale loc, java.lang.Object val)
          Retrieves the properly localized string representing a domain value in a type which has a fixed set of domain values (like enum or boolean).
 java.lang.Object[] getDomainValues()
          If the type for this property has a fixed set of domain values (like boolean or enum) this contains all possible values for this property.
 java.lang.String[][] getEditRoles()
          Defines the roles that a user must have to edit this field.
 java.lang.reflect.Type getGenericActualType()
          The abomination that is Java Generics requires a separate dysfunctional type system to represent generic typing, at the few places it is available.
 int getLength()
          Return the defined length for the item PROVIDED IT WAS SET - THIS SUFFERS FROM AN UTTER FUCKUP IN THE JPA "STANDARD".
 java.util.List<SearchPropertyMetaModel> getLookupFieldKeySearchProperties()
          When used in a LookupInput field, this fields are used to create the keyword search inputs.
 java.util.List<SearchPropertyMetaModel> getLookupFieldSearchProperties()
          When used in a LookupInput field, this fields are used to create the search inputs.
 java.util.List<DisplayPropertyMetaModel> getLookupSelectedProperties()
          When this class is to be selected as a parent in an UP relation using an InputLookup control this describes the properties to use to display the currently selected record in the edit page.
 java.lang.Class<? extends INodeContentRenderer<?>> getLookupSelectedRenderer()
          When this class is to be selected as a parent in an UP relation using an InputLookup control this describes the renderer to use to display the currently selected record in the edit page.
 java.util.List<DisplayPropertyMetaModel> getLookupTableProperties()
          When used in a LookupInput field, this fields are used to show the result of a Search in the DataTable.
 java.lang.String getName()
          Returns the name of the property.
 NumericPresentation getNumericPresentation()
          Used for numeric types, this returns how to present the number and defines the number's class, like a monetary amount.
 int getPrecision()
          Return the specified precision of the numeric field.
 YesNoType getReadOnly()
          Reports whether a property is readonly.
 java.lang.String getRegexpUserString()
          Use the string to use as the pattern indicator in regexp-validator error messages.
 java.lang.String getRegexpValidator()
          Returns the regexp to use to validate input.
 PropertyRelationType getRelationType()
          Tells if this property represents some kind of database relation (a "parent" property referring to the master of this child record, or a property representing the list of children).
 int getScale()
          For numeric types, this returns any defined scale.
 SortableType getSortable()
          Returns whether the property should be sortable when used in a default table, and defines the initial sort direction of the property.
 TemporalPresentationType getTemporal()
          If this is defined as some Date type this further defines the domain (date only, date time etc).
 PropertyMetaValidator[] getValidators()
          Get all validators to run on this property's input after conversion.
 T getValue(java.lang.Object in)
          Calculate the value to get.
 ClassMetaModel getValueModel()
          If applicable, the value type's class model.
 java.lang.String[][] getViewRoles()
          If this contains null the field can be seen by all users.
 boolean isPrimaryKey()
          Returns T if we know this property to be the PK.
 boolean isRequired()
          Whether the property is defined as requiring a value.
 boolean isTransient()
          If marked as transient in the persistent class this returns true
 void setValue(java.lang.Object target, T value)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PathPropertyMetaModel

public PathPropertyMetaModel(java.lang.String dottedName,
                             PropertyMetaModel<?>[] accessPath)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getValue

public T getValue(java.lang.Object in)
           throws java.lang.Exception
Calculate the value to get. If any path component is null this returns null, it does not throw exceptions.

Specified by:
getValue in interface IValueTransformer<T>
Throws:
java.lang.Exception
See Also:
IValueTransformer.getValue(java.lang.Object)

setValue

public void setValue(java.lang.Object target,
                     T value)
              throws java.lang.Exception
Specified by:
setValue in interface IValueAccessor<T>
Throws:
java.lang.Exception

getDefaultHint

public java.lang.String getDefaultHint()
Description copied from interface: PropertyMetaModel
Returns the default hint text (which pops up when the mouse is held over the control that inputs this item). The hint text is a single, short, line of text. Like the default label this gets looked up in the resource file for the class this is a property of. The property that is looked up is 'propertyname.hint'.

Specified by:
getDefaultHint in interface PropertyMetaModel<T>
Returns:
The hint text, or null if not known.
See Also:
PropertyMetaModel.getDefaultHint()

getDefaultLabel

public java.lang.String getDefaultLabel()
Description copied from interface: PropertyMetaModel
Return any default label (the text to use before the control that inputs this property) for this property. The default label is obtained from the resource file with the same location and name as the class file containing the property after doing NLS language replacement; the label text is looked up in that file as 'propertyname.label='. The code uses the "current" locale as set in NlsContext to lookup the proper resource file.

Specified by:
getDefaultLabel in interface PropertyMetaModel<T>
Returns:
the label text, or null if unknown.
See Also:
PropertyMetaModel.getDefaultLabel()

getActualType

public java.lang.Class<T> getActualType()
Description copied from interface: PropertyMetaModel
Returns the actual type of the property's value. This is the return type of the getter function.

Specified by:
getActualType in interface PropertyMetaModel<T>
Returns:

getValueModel

public ClassMetaModel getValueModel()
Description copied from interface: PropertyMetaModel
If applicable, the value type's class model. Can be asked for explicitly to allow for non-class-based metamodels. It will return null for all primitive and basic types.

Specified by:
getValueModel in interface PropertyMetaModel<T>
Returns:

getGenericActualType

public java.lang.reflect.Type getGenericActualType()
Description copied from interface: PropertyMetaModel
The abomination that is Java Generics requires a separate dysfunctional type system to represent generic typing, at the few places it is available. This returns the generic type information that is present on whatever type is the return type. This CAN return NULL!!!

Specified by:
getGenericActualType in interface PropertyMetaModel<T>
Returns:

getClassModel

public ClassMetaModel getClassModel()
Description copied from interface: PropertyMetaModel
The ClassModel that this property is a property of.

Specified by:
getClassModel in interface PropertyMetaModel<T>
Returns:

getComboDataSet

public java.lang.Class<? extends IComboDataSet<?>> getComboDataSet()
Description copied from interface: PropertyMetaModel
If this should be represented by a combo this can be set to represent the default combo dataset.

Specified by:
getComboDataSet in interface PropertyMetaModel<T>
Returns:

getComboDisplayProperties

public java.util.List<DisplayPropertyMetaModel> getComboDisplayProperties()
Description copied from interface: PropertyMetaModel
For a relation, this is the list of properties that should be shown. This is needed ONLY when the class metadata of the parent record does not specify a default display column or columnset.

Specified by:
getComboDisplayProperties in interface PropertyMetaModel<T>
Returns:

getComboLabelRenderer

public java.lang.Class<? extends ILabelStringRenderer<?>> getComboLabelRenderer()
Description copied from interface: PropertyMetaModel
When this relation-property is presented as a single field this can contain a class to render that field as a string.

Specified by:
getComboLabelRenderer in interface PropertyMetaModel<T>
Returns:

getComboNodeRenderer

public java.lang.Class<? extends INodeContentRenderer<?>> getComboNodeRenderer()
Description copied from interface: PropertyMetaModel
When set this renderer should be used to render the nodes in the combobox.

Specified by:
getComboNodeRenderer in interface PropertyMetaModel<T>
Returns:

getComponentTypeHint

public java.lang.String getComponentTypeHint()
Description copied from interface: PropertyMetaModel
When present this gives a hint to the component factories to help with choosing a proper component to select a single record of the type specified by this property. This is only used when this property points to a parent in an UP relation, and the child needs to add a control to help it select one parent.

Specified by:
getComponentTypeHint in interface PropertyMetaModel<T>
Returns:

getConverter

public IConverter<T> getConverter()
Description copied from interface: PropertyMetaModel
Returns the user-specified converter to use when converting this property's value to and from string. Can be null.

Specified by:
getConverter in interface PropertyMetaModel<T>
Returns:

getDisplayLength

public int getDisplayLength()
Description copied from interface: PropertyMetaModel
Returns the #chars to be displayed by default for this item. When present this overrides the length or precision as a size indicator.

Specified by:
getDisplayLength in interface PropertyMetaModel<T>
Returns:

getDomainValueLabel

public java.lang.String getDomainValueLabel(java.util.Locale loc,
                                            java.lang.Object val)
Description copied from interface: PropertyMetaModel
Retrieves the properly localized string representing a domain value in a type which has a fixed set of domain values (like enum or boolean). So for instance passing in an english locale and the constant Boolean.TRUE this could return "yes". The translated value is obtained by first looking up a translation in the base class's properties file; if it is undefined there it will be looked up in the enum's property file. If a proper representation cannot be found this will return a toString on the value.

Specified by:
getDomainValueLabel in interface PropertyMetaModel<T>
Returns:

getDomainValues

public java.lang.Object[] getDomainValues()
Description copied from interface: PropertyMetaModel
If the type for this property has a fixed set of domain values (like boolean or enum) this contains all possible values for this property. So this will contain the actual enum labels or the constants Boolean.TRUE and Boolean.FALSE. It returns null for other domains.

Specified by:
getDomainValues in interface PropertyMetaModel<T>
Returns:

getEditRoles

public java.lang.String[][] getEditRoles()
Description copied from interface: PropertyMetaModel
Defines the roles that a user must have to edit this field. See the description at PropertyMetaModel.getViewRoles() for details.

Specified by:
getEditRoles in interface PropertyMetaModel<T>
Returns:

getLength

public int getLength()
Description copied from interface: PropertyMetaModel
Return the defined length for the item PROVIDED IT WAS SET - THIS SUFFERS FROM AN UTTER FUCKUP IN THE JPA "STANDARD". This is valid for string-type fields mostly, and should hold the size defined in the database. This field is usually set from the @Column annotation specified. But since that annotation was written by an idiot with a brain the size of a pea the "default" value for the length field in that annotation is set to 255. Since 255 is a valid length value this makes it impossible to determine if the actual length IS 255, or that the user did not provide a value and we need to calculate one ourselves.

Specified by:
getLength in interface PropertyMetaModel<T>
Returns:
The size in characters of this item, or -1 if unknown.

getLookupSelectedProperties

public java.util.List<DisplayPropertyMetaModel> getLookupSelectedProperties()
Description copied from interface: PropertyMetaModel
When this class is to be selected as a parent in an UP relation using an InputLookup control this describes the properties to use to display the currently selected record in the edit page.

Specified by:
getLookupSelectedProperties in interface PropertyMetaModel<T>
Returns:

getLookupSelectedRenderer

public java.lang.Class<? extends INodeContentRenderer<?>> getLookupSelectedRenderer()
Description copied from interface: PropertyMetaModel
When this class is to be selected as a parent in an UP relation using an InputLookup control this describes the renderer to use to display the currently selected record in the edit page. If empty this will use the lookupFieldDisplayProperties.

Specified by:
getLookupSelectedRenderer in interface PropertyMetaModel<T>
Returns:

getLookupFieldSearchProperties

public java.util.List<SearchPropertyMetaModel> getLookupFieldSearchProperties()
Description copied from interface: PropertyMetaModel
When used in a LookupInput field, this fields are used to create the search inputs.

Specified by:
getLookupFieldSearchProperties in interface PropertyMetaModel<T>
Returns:

getLookupFieldKeySearchProperties

public java.util.List<SearchPropertyMetaModel> getLookupFieldKeySearchProperties()
Description copied from interface: PropertyMetaModel
When used in a LookupInput field, this fields are used to create the keyword search inputs.

Specified by:
getLookupFieldKeySearchProperties in interface PropertyMetaModel<T>
Returns:

getLookupTableProperties

public java.util.List<DisplayPropertyMetaModel> getLookupTableProperties()
Description copied from interface: PropertyMetaModel
When used in a LookupInput field, this fields are used to show the result of a Search in the DataTable.

Specified by:
getLookupTableProperties in interface PropertyMetaModel<T>
Returns:

getName

public java.lang.String getName()
Description copied from interface: PropertyMetaModel
Returns the name of the property.

Specified by:
getName in interface PropertyMetaModel<T>
Returns:

getPrecision

public int getPrecision()
Description copied from interface: PropertyMetaModel
Return the specified precision of the numeric field. Returns -1 if not known or not numeric.

Specified by:
getPrecision in interface PropertyMetaModel<T>
Returns:
the precision, or -1 if unknown. The precision is the total #of digits present in the number, including scale digits.

getReadOnly

public YesNoType getReadOnly()
Description copied from interface: PropertyMetaModel
Reports whether a property is readonly. For Java classes a property is defined as readOnly when it has no "setter" method.

Specified by:
getReadOnly in interface PropertyMetaModel<T>
Returns:

getRelationType

public PropertyRelationType getRelationType()
Description copied from interface: PropertyMetaModel
Tells if this property represents some kind of database relation (a "parent" property referring to the master of this child record, or a property representing the list of children).

Specified by:
getRelationType in interface PropertyMetaModel<T>
Returns:

getScale

public int getScale()
Description copied from interface: PropertyMetaModel
For numeric types, this returns any defined scale. If undefined this returns -1.

Specified by:
getScale in interface PropertyMetaModel<T>
Returns:

getSortable

public SortableType getSortable()
Description copied from interface: PropertyMetaModel
Returns whether the property should be sortable when used in a default table, and defines the initial sort direction of the property. This defaults to unsortable.

Specified by:
getSortable in interface PropertyMetaModel<T>
Returns:

getTemporal

public TemporalPresentationType getTemporal()
Description copied from interface: PropertyMetaModel
If this is defined as some Date type this further defines the domain (date only, date time etc).

Specified by:
getTemporal in interface PropertyMetaModel<T>
Returns:

getNumericPresentation

public NumericPresentation getNumericPresentation()
Description copied from interface: PropertyMetaModel
Used for numeric types, this returns how to present the number and defines the number's class, like a monetary amount. This gets overridden when a converter is set!

Specified by:
getNumericPresentation in interface PropertyMetaModel<T>
Returns:

getValidators

public PropertyMetaValidator[] getValidators()
Description copied from interface: PropertyMetaModel
Get all validators to run on this property's input after conversion.

Specified by:
getValidators in interface PropertyMetaModel<T>
Returns:

getViewRoles

public java.lang.String[][] getViewRoles()
Description copied from interface: PropertyMetaModel
If this contains null the field can be seen by all users. If it has a value the first-level array is a set of ORs; the second level are ANDs. Meaning that an array in the format:
 { {"admin"}
 , {"editroles", "user"}
 , {"tester"}
 };
 
this means that the field is visible for a user with the roles:
        "admin" OR "tester" OR ("editroles" AND "user")
 

Specified by:
getViewRoles in interface PropertyMetaModel<T>
Returns:

isPrimaryKey

public boolean isPrimaryKey()
Description copied from interface: PropertyMetaModel
Returns T if we know this property to be the PK.

Specified by:
isPrimaryKey in interface PropertyMetaModel<T>
Returns:

isRequired

public boolean isRequired()
Description copied from interface: PropertyMetaModel
Whether the property is defined as requiring a value.

Specified by:
isRequired in interface PropertyMetaModel<T>
Returns:

isTransient

public boolean isTransient()
Description copied from interface: PropertyMetaModel
If marked as transient in the persistent class this returns true

Specified by:
isTransient in interface PropertyMetaModel<T>

getRegexpUserString

public java.lang.String getRegexpUserString()
Description copied from interface: PropertyMetaModel
Use the string to use as the pattern indicator in regexp-validator error messages.

Specified by:
getRegexpUserString in interface PropertyMetaModel<T>
Returns:

getRegexpValidator

public java.lang.String getRegexpValidator()
Description copied from interface: PropertyMetaModel
Returns the regexp to use to validate input.

Specified by:
getRegexpValidator in interface PropertyMetaModel<T>
Returns:

getControlFactory

public ControlFactory getControlFactory()
Description copied from interface: PropertyMetaModel
If a specific control factory is to be used to create controls for this item this returns that factory.

Specified by:
getControlFactory in interface PropertyMetaModel<T>
Returns: