LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.info
Class LyRelationFieldInfo

java.lang.Object
  extended by leon.info.LyTag
      extended by leon.info.LyInfo
          extended by leon.info.LyObjectInfo
              extended by leon.info.LyFieldInfo
                  extended by leon.info.LyRelationFieldInfo
All Implemented Interfaces:
java.lang.Cloneable, LyField, LyCommentInterface
Direct Known Subclasses:
LyStructFieldInfo

public class LyRelationFieldInfo
extends LyFieldInfo

This class implements the description of relation fields. These fields represent relations between objects of an application.

A relation may be multiple, this means an object is related to several objects in the same time.

In that case, relations can be ordered when the order of values for a given relation field has a meaning (the same list with a different order is not the same value).

For a relation field, related objects are taken into the specified list of classes (instances of LyClassInfo) authorized on this field. An optional additional filter may be associated to each of these classes to filter objects proposed to end_user when he has to enter a value on a relation field.

Relations can be typed. The type determines the graphical representation of the relation.

Relation may also have a direction. This property is used to indicate under which conditions the relation is usable when calculating cross-references between objects of different classes. The supported values are defined as constants, named Direction.XXX.

See Also:
LyClassInfo, LyFilter, LyRoute, LyRelationDaemon

Nested Class Summary
static class LyRelationFieldInfo.Direction
          Directions.
static class LyRelationFieldInfo.ShowAs
          Show as values.
static class LyRelationFieldInfo.Type
          Relation types.
 
Nested classes/interfaces inherited from class leon.info.LyTag
LyTag.Model
 
Field Summary
static java.lang.String __VERSION
           
 
Fields inherited from class leon.info.LyFieldInfo
__version, MARK_APP_ID, MARK_AUTO_COMPLETION, MARK_CHART, MARK_COMPLEX_TABLE, MARK_CONSULT, MARK_CREATE, MARK_CREATE_CONSULT, MARK_DISABLE, MARK_FILTER, MARK_FIND, MARK_HIDDEN, MARK_ID, MARK_LOAD, MARK_LOCAL, MARK_MAIN, MARK_NAME, MARK_NEED_POST, MARK_NO_CAPTION, MARK_NOT_NULL, MARK_OPTIONAL, MARK_PRIVATE, MARK_PROVIDER_VALUE, MARK_READ_ONLY, MARK_SEARCH, MARK_SECRET, MARK_SET, MARK_SET_CONSULT, MARK_SORT, MARK_STATUS, MARK_TABLE, MARK_TRANSLATE, MARK_UNIQUE, SECRET_VALUE, STRONG_DEPENDENCY_VALUE, WEAK_DEPENDENCY_VALUE
 
Fields inherited from class leon.info.LyObjectInfo
NULL, PART_ALL, PART_BIND, PART_DATA, PART_GUI, PART_LABEL
 
Method Summary
 LyValue buildFieldValue(java.lang.Object value)
          Builds the appropriate LyValue corresponding to this field for the given value object.
 java.lang.String checkValue(LyEnvironment environment, java.lang.Object fieldValue)
          Checks the given value : - the value must correspond to options of the choice.
 int compare(java.lang.Object value1, java.lang.Object value2, java.util.BitSet modifiers)
          Compares two objects for this fieldInfo.
 boolean contains(java.lang.Object value1, java.lang.Object value2, java.util.BitSet modifiers)
          Checks if the second value is contained in the first one, for this field.
 java.lang.String controlValue(LyEnvironment environment, java.lang.Object fieldValue)
          Controls the given value : - the number of values must be greater or equal to min, - the number of values must be lower or equal to max.
 boolean equals(java.lang.Object value1, java.lang.Object value2, java.util.BitSet modifiers)
          Compares two objects for equality.
 java.util.Vector<LyClassRef> getClasses()
          Returns the list of target classes available on this relation field.
 LyFieldInfo getClassField()
          Gets the class field of this relation.
 LyClassInfo getClassInfo(int idx)
          Retrieves the classInfo at the specified index associated to this relation field.
 int getClassInfoCount()
          Gets number of class infos allowed for this relation.
 LyInfoDataList<LyClassInfo,LyFilter> getClassInfos()
          Returns the list of target classes available on this relation field.
 LyRelationFieldInfo getContextField()
          Gets the context field of this relation.
 LyInfoDaemon getDaemon()
          Accessor of informations about the daemon to manage this relation.
 java.lang.String getDefault()
          Return a string representation of the default value or null if no default is specified.
 java.lang.Object getDefaultValue()
          Return the default value or null if no default is specified.
 LyRelationFieldInfo.Direction getDirection()
          Gets the direction of the relation.
 LyRelationFieldInfo getExtendedRelation()
          Returns the relation that is extended by this relation.
 LyFilter getFilter(int idx)
          Retrieves the filter at the specified index.
 LyFilter getFilter(LyClassInfo classInfo)
          Get filter associated to the given classInfo in this field.
 LyFilterExpression.Condition[] getFilterConditions()
          Returns the filter conditions authorized on this field.
 LyInfoList<LyFilter> getFilters()
          Retrieves all the filters associated to the classes of this relation, this is a COPY of the internal list.
 int getMax()
          Gets the max number of accepted values for this field info.
 int getMin()
          Gets the min number of required values for this field info.
 int getNCols()
          Gets the preferred number of columns shown to the user at the same time.
 int getNRows()
          Gets the preferred number of rows shown to the user at the same time.
 LySimpleObjectList getObjects(LyObject object)
          Gets value of this field as an objects list for the given instance.
 LySimpleObjectList getObjects(java.lang.Object value)
          Converts the given value of this field to an objects list.
 LyObjectId[] getOrderedIds(LyObjectId[] objectIds)
          Sort list of object identifiers.
 java.lang.Object getPeerValue(java.lang.Object value, java.lang.Class<?> objectClass, LyObject instance)
          Returns an object of the given class from a value of this fieldInfo.
 java.lang.Object[] getPeerValues(java.lang.Object value, java.lang.Class<?>[] objectClasses, LyObject instance)
          Returns a table of objects for the given classes from a value of this fieldInfo.
 LyRelationFieldInfo getReverseRelation()
          Returns the reverse relation of this relation.
 LyRoute getRoute(int index)
          Gets the route at the specified index in routes list.
 LyRoute getRoute(java.lang.String id)
          Gets the route with the specified id in routes list of this relation.
 LyInfoList<LyRoute> getRoutes()
          Returns the set of routes available of this relation.
 int getRoutesCount()
          Return the number of routes used to calculate values of this relation.
 LyRelationFieldInfo.ShowAs getShowAs()
          Accessor for the showAs property.
 LyInfoList<LyRelationFieldInfo> getSubTypes()
          Gets sub-types (list of relations).
 LyRelationFieldInfo.Type getType()
          Accessor to the relation type.
 java.lang.Class<?> getValueClass()
          Returns class of values for this field.
 java.lang.Object getValueFromObject(java.lang.Object object, LyObject instance)
          Constructs a value for this fieldInfo from an object for a given instance.
 boolean hasSubType(LyRelationFieldInfo relation)
          Checks if the given relation is a sub-type of this relation.
 boolean ignoresContext()
          Accessor to the noContext property.
 boolean inheritsFrom(LyRelationFieldInfo relation)
          Checks if this relation inherits from the given one.
 boolean isAbstract()
          Accessor to the abstract property.
 boolean isMultiple()
          Accessor to the multiple property.
 boolean isOrdered()
          Accessor to the ordered property.
 boolean isToolbarDisabled()
          Accessor to the noToolbar property.
 java.lang.Object parse(java.lang.String stringValue)
          Builds internal value for this field from a string (previously constructed by toString).
 boolean relatedWith(LyClassInfo classInfo)
          Test if this relation has the specified classInfo in its related classes.
 java.lang.String toName(java.lang.Object fieldValue)
          Returns the specified value for this field as a "displayable" string.
 java.lang.String toName(java.lang.Object fieldValue, java.lang.String separator)
          Returns the specified value for this field as a "displayable" string.
 java.lang.String toString(java.lang.Object fieldValue)
          Converts the specified value for this field to an "internal" string (string that enables reconstruction through parse).
 
Methods inherited from class leon.info.LyFieldInfo
addConstraint, addDepend, addDepend, buildLyValue, checkJavaName, compare, compute, compute, compute, compute, contains, convertFromFieldUnit, convertToFieldUnit, encodeValue, endsWith, equals, fromFieldTag, getBean, getBeans, getBehaviorClass, getBehaviorClassName, getBinding, getCaptionConstraint, getConstraint, getConstraint, getConstraints, getControl, getControlCount, getControls, getDefaultJavaName, getDepends, getDepends, getFieldBean, getFieldGroup, getFieldTab, getFieldUnit, getFilterModifiers, getFormat, getFormula, getFormulaFields, getFormulaImports, getGenericMarks, getImport, getJavaName, getLabel, getLabel, getLabelCount, getLabels, getLyFormula, getMark, getMark, getMarkName, getMarks, getPath, getSpecificMarks, getTab, getUnits, getUserLabel, getUserLabel, getUserLabelCount, hasMark, isCalculated, isComputed, isImported, isLocal, processValue, setImport, setPath, startsWith, toName, toShortName
 
Methods inherited from class leon.info.LyObjectInfo
clone, getAlias, getData, getDataList, getDatas, getFilePrefix, getGroup, getInternalAlias, getInternalFilePrefix, getInternalName, getMarks, getName, getTemplate, getTip, getUserData, hasMark, hasMarks, hasTemplate, isTemplate, putData, putData, removeData, toName
 
Methods inherited from class leon.info.LyInfo
getApplication, getFile, getId, getInclude, isIncluded, isInternal, isInternal, isLoaded, isLocked, load, setApplication, setFile, toString
 
Methods inherited from class leon.info.LyTag
getCommentsEnd, getCommentsStart, getEnvironment, getModelType, getParent, getRootProject, hasAncestor, isExtern, setCommentsEnd, setCommentsStart, wasCloned
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface leon.data.LyField
getId
 
Methods inherited from interface leon.parser.LyCommentInterface
getCommentsEnd, getCommentsStart, setCommentsEnd, setCommentsStart
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values
Method Detail

getValueClass

public java.lang.Class<?> getValueClass()
Returns class of values for this field. The value class corresponding to a number field is :

Specified by:
getValueClass in interface LyField
Specified by:
getValueClass in class LyFieldInfo
Returns:
Effective class of values built by this fieldInfo. This method is abstract, the real class depends on each type of field.
See Also:
LyObject.getValue(leon.info.LyFieldInfo)

buildFieldValue

public LyValue buildFieldValue(java.lang.Object value)
Builds the appropriate LyValue corresponding to this field for the given value object.

Specified by:
buildFieldValue in interface LyField
Overrides:
buildFieldValue in class LyFieldInfo
Parameters:
value - Value from which the LyValue is built.
Returns:
An instance of a class that inherits from LyValue corresponding the given value. Classes extending LyValue are given to ease data manipulations, they contain methods that encapsulate data conversions from and to the internal representation. There is one class for each type of field.
See Also:
LyRelationValue

parse

public java.lang.Object parse(java.lang.String stringValue)
                       throws LyFieldInfoFormatException
Builds internal value for this field from a string (previously constructed by toString).

Specified by:
parse in class LyFieldInfo
Parameters:
stringValue - The value presented as a string as produced by the toString method.
Returns:
The value decoded from the given string.
Throws:
LyFieldInfoFormatException - If the string can't be parsed properly.
See Also:
toString(java.lang.Object)

toName

public java.lang.String toName(java.lang.Object fieldValue)
Returns the specified value for this field as a "displayable" string.

Specified by:
toName in class LyFieldInfo
Returns:
The value presented as a displayable String.
See Also:
LyFieldInfo.getValueClass()

toName

public java.lang.String toName(java.lang.Object fieldValue,
                               java.lang.String separator)
Returns the specified value for this field as a "displayable" string.

Parameters:
Object - fieldValue : The fieldValue to display.
String - separator : The value of separator between field values.
Returns:
String : Formated String.

getOrderedIds

public LyObjectId[] getOrderedIds(LyObjectId[] objectIds)
Sort list of object identifiers.
Sort is made on the name of corresponding objects. If relation is ordered, current method does not sort the list which is returned as it is.

Parameters:
objectIds - list of object identifiers to be sorted.
Returns:
the list of object identifiers sorted by the names of the corresponding objects.

toString

public java.lang.String toString(java.lang.Object fieldValue)
Converts the specified value for this field to an "internal" string (string that enables reconstruction through parse).

Specified by:
toString in class LyFieldInfo
Returns:
the value as an internal String.
See Also:
parse(java.lang.String)

controlValue

public java.lang.String controlValue(LyEnvironment environment,
                                     java.lang.Object fieldValue)
Controls the given value : - the number of values must be greater or equal to min, - the number of values must be lower or equal to max.

Overrides:
controlValue in class LyFieldInfo
Parameters:
environment - Environment giving the user language if a message has to be produced.
Returns:
Returns an error message if the value is incorrect, null otherwise.
See Also:
LyFieldInfo.getValueClass()

checkValue

public java.lang.String checkValue(LyEnvironment environment,
                                   java.lang.Object fieldValue)
Checks the given value : - the value must correspond to options of the choice.

Overrides:
checkValue in class LyFieldInfo
Parameters:
environment - Environment giving the user language if a message has to be produced.
Returns:
Returns an error message if the value is incorrect, null otherwise.
See Also:
LyFieldInfo.getValueClass()

compare

public int compare(java.lang.Object value1,
                   java.lang.Object value2,
                   java.util.BitSet modifiers)
Compares two objects for this fieldInfo.

Specified by:
compare in class LyFieldInfo
Parameters:
value1 - First value.
value2 - Second value.
modifiers - Modifiers used for checking (see MOD_XXX constants of LyFilterExpression).
Returns:
0 If the two values are identical for the specified fieldInfo, a positive number if value1 is "greater" than value2. If value2 is "greater" than value1, a negative number is returned.
See Also:
LyFieldInfo.getValueClass()

getFilterConditions

public LyFilterExpression.Condition[] getFilterConditions()
Returns the filter conditions authorized on this field. The values must match the short constants defined in LyFilterExpression.

Overrides:
getFilterConditions in class LyFieldInfo
Returns:
An array of conditions corresponding to the authorized conditions on this field.
See Also:
LyFilterExpression

equals

public boolean equals(java.lang.Object value1,
                      java.lang.Object value2,
                      java.util.BitSet modifiers)
Compares two objects for equality.

Overrides:
equals in class LyFieldInfo
Parameters:
value1 - First value.
value2 - Second value.
modifiers - Modifiers used for checking (see MOD_XXX constants of LyFilterExpression).
Returns:
True if the values are equals, else false.
See Also:
LyFieldInfo.compare(java.lang.Object, java.lang.Object, java.util.BitSet), LyFieldInfo.getValueClass()

contains

public boolean contains(java.lang.Object value1,
                        java.lang.Object value2,
                        java.util.BitSet modifiers)
Checks if the second value is contained in the first one, for this field.

Overrides:
contains in class LyFieldInfo
Parameters:
value1 - First value.
value2 - Second value.
modifiers - Modifiers used for checking (see MOD_XXX constants of LyFilterExpression).
Returns:
True if the second value is contained in the first one, else returns false.

getValueFromObject

public java.lang.Object getValueFromObject(java.lang.Object object,
                                           LyObject instance)
Constructs a value for this fieldInfo from an object for a given instance. Supported conversions are the following :
LyObjectId, String, Object LyObjectId
LyObjectId[], Object[], String[], Vector LyObjectId[]

Overrides:
getValueFromObject in class LyFieldInfo
Parameters:
object - The peer value.
instance - Instance containing the required value (could be null). This instance is provided to be able to construct a value for complex bindings (bindings involving other fields).
Returns:
The logical value that was built (instance of the class returned from getValueClass).
Throws:
LyUnsupportedFieldBindingException - If the given object can't be converted to a value of this field.
See Also:
LyFieldInfo.getPeerValue(java.lang.Object, java.lang.Class, leon.data.LyObject), LyFieldBinding

getPeerValue

public java.lang.Object getPeerValue(java.lang.Object value,
                                     java.lang.Class<?> objectClass,
                                     LyObject instance)
Returns an object of the given class from a value of this fieldInfo. Supported conversions are the following :
LyObjectId LyObjectId, String
LyObjectId[] LyObjectId[], String[], Object[], Vector

Overrides:
getPeerValue in class LyFieldInfo
Parameters:
value - Value of this fieldInfo. This value is an instance of the class returned by getValueClass method.
objectClass - Expected class of the physical value.
instance - Instance containing the given value (could be null).
Throws:
LyUnsupportedFieldBindingException - If the requested conversion if none of the supported conversions.
See Also:
LyFieldInfo.getValueClass()

getPeerValues

public java.lang.Object[] getPeerValues(java.lang.Object value,
                                        java.lang.Class<?>[] objectClasses,
                                        LyObject instance)
Returns a table of objects for the given classes from a value of this fieldInfo.

Overrides:
getPeerValues in class LyFieldInfo
Parameters:
value - Value of this fieldInfo.
objectClasses - Expected classes of the physical values.
instance - Instance containing the given value (could be null).
Throws:
LyUnsupportedFieldBindingException - Thrown if we don't known how to build the peer values from the given parameters.
See Also:
LyFieldInfo.getValueClass()

getType

public LyRelationFieldInfo.Type getType()
Accessor to the relation type.

Returns:
Choice type.

getExtendedRelation

public final LyRelationFieldInfo getExtendedRelation()
Returns the relation that is extended by this relation.

Returns:
Relation extended by this relation, null otherwise.

isAbstract

public boolean isAbstract()
Accessor to the abstract property.

Returns:
True if this field is abstract.

isMultiple

public final boolean isMultiple()
Accessor to the multiple property.

Overrides:
isMultiple in class LyFieldInfo
Returns:
True if this field may have several values.

isOrdered

public final boolean isOrdered()
Accessor to the ordered property.

Returns:
True if this field is ordered.

ignoresContext

public final boolean ignoresContext()
Accessor to the noContext property.

Returns:
True if this relation field does not use the context of the views to compute the list of logical objects that may be used as values.

isToolbarDisabled

public final boolean isToolbarDisabled()
Accessor to the noToolbar property.

Returns:
True if this relation doesn't have a toolbar associated to it in edit forms.

getDefaultValue

public java.lang.Object getDefaultValue()
Return the default value or null if no default is specified.

Overrides:
getDefaultValue in class LyFieldInfo
Returns:
Default value. If the default value specified for this field in data description file starts with $, the returned value is the name of the variable following this character. Otherwise, the returned value is an instance of the class given by getValueClass.
See Also:
getValueClass()

getDefault

public java.lang.String getDefault()
Return a string representation of the default value or null if no default is specified.

Returns:
Default value.

getDirection

public final LyRelationFieldInfo.Direction getDirection()
Gets the direction of the relation.

Returns:
Direction of this relation field. One of the constants named Direction.XXX.

getClassField

public final LyFieldInfo getClassField()
Gets the class field of this relation. The class field is used to restrict the number of objects proposed to the end-user when he has to enter values corresponding to this field. The class field refers to an other field that gives at one time the enabled class(es) for this relation.

Returns:
Class field of this relation (may be null)

getContextField

public final LyRelationFieldInfo getContextField()
Gets the context field of this relation. The context field is used to restrict the number of objects proposed to the end-user when he has to enter values corresponding to this field. The context field refers to an other field of the same class that gives at one time a set of objects that is used to calculate via cross references the list of enabled objects for this relation.

Returns:
Context field of this relation (may be null)

relatedWith

public boolean relatedWith(LyClassInfo classInfo)
Test if this relation has the specified classInfo in its related classes.

Parameters:
classInfo - Class info to test.
Returns:
True if the relation has the specified class in its related classes, false otherwise.

getClassInfo

public final LyClassInfo getClassInfo(int idx)
Retrieves the classInfo at the specified index associated to this relation field.

Parameters:
idx - index of the requested classInfo.
Returns:
the reference to the instance of classInfo, or null if there is no classInfo for the specified index.

getFilter

public LyFilter getFilter(LyClassInfo classInfo)
Get filter associated to the given classInfo in this field.

Parameters:
classInfo - ClassInfo for which we look for an associated filter.
Returns:
The filter associated to the given classInfo, or null if no filter has been specified for this classInfo in this relation.

getFilter

public final LyFilter getFilter(int idx)
Retrieves the filter at the specified index.

Parameters:
idx - Index of the requested filter.
Returns:
Filter at the given position, or null if there is no filter for the specified index.

getClassInfoCount

public final int getClassInfoCount()
Gets number of class infos allowed for this relation.

Returns:
Number of allowed classes.

getClasses

public final java.util.Vector<LyClassRef> getClasses()
Returns the list of target classes available on this relation field.

Returns:
List of target classes of this relation (never returns null).

getClassInfos

public final LyInfoDataList<LyClassInfo,LyFilter> getClassInfos()
Returns the list of target classes available on this relation field.

Returns:
List of target classes of this relation (never returns null).

getFilters

public LyInfoList<LyFilter> getFilters()
Retrieves all the filters associated to the classes of this relation, this is a COPY of the internal list.

Returns:
List of filters associated to target classes of this relation.

getRoutesCount

public final int getRoutesCount()
Return the number of routes used to calculate values of this relation.

Returns:
Number of routes of this relation.

getRoute

public final LyRoute getRoute(int index)
Gets the route at the specified index in routes list.

Parameters:
index - Index of the searched route.
Returns:
The requested route, or null if it could not be found.

getRoute

public final LyRoute getRoute(java.lang.String id)
Gets the route with the specified id in routes list of this relation.

Parameters:
id - Id of the searched route.
Returns:
The requested route, or null if it could not be found.

getRoutes

public final LyInfoList<LyRoute> getRoutes()
Returns the set of routes available of this relation.

Returns:
Set of routes of this relation. Never returns null.

getDaemon

public final LyInfoDaemon getDaemon()
Accessor of informations about the daemon to manage this relation.

Returns:
The object that contains informations about the daemon to manage this relation.

getNRows

public final int getNRows()
Gets the preferred number of rows shown to the user at the same time. Not used for non multiple relations.

Returns:
Number of rows, or -1 if no preference is given.

getNCols

public final int getNCols()
Gets the preferred number of columns shown to the user at the same time.

Returns:
Number of cols, or -1 if no preference is given.

getMin

public final int getMin()
Gets the min number of required values for this field info. Not used for non multiple relations.

Returns:
Number of requiered values.

getMax

public final int getMax()
Gets the max number of accepted values for this field info. Not used for non multiple relations.

Returns:
Number of accepted values.

getSubTypes

public final LyInfoList<LyRelationFieldInfo> getSubTypes()
Gets sub-types (list of relations).

Returns:
Gets sub-types of this relation.

getObjects

public LySimpleObjectList getObjects(LyObject object)
Gets value of this field as an objects list for the given instance.

Parameters:
object - Instance for which the value is requested as an objects list.
Returns:
Objects list corresponding to the value of this field in the given instance (may be null).

getObjects

public LySimpleObjectList getObjects(java.lang.Object value)
Converts the given value of this field to an objects list.

Parameters:
value - Value to convert to an objects list. This value must be an instance of the class given by getValueClass.
Returns:
Objects list corresponding to the given value of this field (may be null).

getShowAs

public LyRelationFieldInfo.ShowAs getShowAs()
Accessor for the showAs property.

Returns:
The type of presentation used for this relation. One of the SHOW_AS_XXX value.

inheritsFrom

public boolean inheritsFrom(LyRelationFieldInfo relation)
Checks if this relation inherits from the given one.

Parameters:
relation - Checked relation.
Returns:
True if this relation inherits from the given one, false otherwise.

hasSubType

public boolean hasSubType(LyRelationFieldInfo relation)
Checks if the given relation is a sub-type of this relation.

Parameters:
relation - Sub type.
Returns:
True if the given relation is a sub-type of this relation, false otherwise.

getReverseRelation

public final LyRelationFieldInfo getReverseRelation()
Returns the reverse relation of this relation.

Returns:
Reverse relation of this relation.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com