com.flexive.shared.structure
Class FxAssignment

java.lang.Object
  extended by com.flexive.shared.structure.FxAssignment
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<FxAssignment>
Direct Known Subclasses:
FxGroupAssignment, FxPropertyAssignment

public abstract class FxAssignment
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<FxAssignment>

Base class for assignments of a group or property to a type or another group/property

Author:
Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
Serialized Form

Field Summary
protected  java.lang.String alias
          (optional) alias, if not defined the name of the assigned element
protected  long baseAssignment
          base assignment (if derived the parent, if not the root assignment, if its a root assignment FxAssignment.ROOT_BASE)
protected  int defaultMultiplicity
          Default multiplicity, will be auto adjusted if < min or > max
protected  boolean enabled
          Is this assignment enabled at all? Disabled assignments will only show up in the admin area for structure and will be hidden from all other areas
protected  FxString hint
          (optional) hint
protected  FxString label
          (optional) description
protected  FxMultiplicity multiplicity
          Multiplicity of this assignment
static long NO_BASE
          constant if an assignment has no base assignment
static long NO_PARENT
          parent id value if an assignment has no parent
(package private)  java.util.List<FxStructureOption> options
           
protected  FxGroupAssignment parentGroupAssignment
          (optional) parent group
protected  int position
          Position of this assignment within the same XPath hierarchy
static int POSITION_BOTTOM
          Position constant to assign if an assignment should be positioned at the bottom
static long ROOT_BASE
          base id value if an assignment belongs to the virtual root type
protected  java.util.Map<FxScriptEvent,long[]> scriptMapping
          Script mapping, is resolved while loading the environment
static int TYPE_GROUP
          Constant to determine type of the assignment in database; group
static int TYPE_PROPERTY
          Constant to determine type of the assignment in database; property
protected  java.lang.String XPath
          Absolute XPath without indices from the base FxType
 
Constructor Summary
protected FxAssignment(long assignmentId, boolean enabled, FxType assignedType, java.lang.String alias, java.lang.String xpath, int position, FxMultiplicity multiplicity, int defaultMultiplicity, FxGroupAssignment parentGroupAssignment, long baseAssignment, FxString label, FxString hint, java.util.List<FxStructureOption> options)
          Constructor
 
Method Summary
 FxAssignment _setSystemInternal()
          Mark this assignment as system internal - this is a one-way INTERNAL function!!!
 int compareTo(FxAssignment o)
          Compare function
abstract  FxData createEmptyData(FxGroupData parent, int index)
          Create an empty FxData entry for this assignment
abstract  FxData createRandomData(java.util.Random rnd, FxEnvironment env, FxGroupData parent, int index, int maxMultiplicity)
          Create a random FxData entry for this assignment
 boolean equals(java.lang.Object obj)
          
 java.lang.String getAlias()
          Get the alias of this assignment.
 FxType getAssignedType()
          The FxType this assignment is associated with
 long getBaseAssignmentId()
          base assignment (if derived the parent, if not the root assignment, if its a root assignment FxAssignment.ROOT_BASE)
 int getDefaultMultiplicity()
          Get the default multiplicity (used i.e.
 FxString getDisplayLabel()
          Return a human-readable string to present this assignment to the user.
 java.lang.String getDisplayName()
          Return a human-readable string to present this assignment to the user.
 FxString getHint()
          Get the optional hint
 long getId()
          The internal id of this assignment as stored in the database
 FxString getLabel()
          Get the assignment label
abstract  FxMultiplicity getMultiplicity()
          Get the multiplicity of this assignment.
 FxStructureOption getOption(java.lang.String key)
          Get an option entry for the given key, if the key is invalid or not found a FxStructureOption object will be returned with set set to false, overrideable set to false and value set to an empty String.
 java.util.List<FxStructureOption> getOptions()
          Get a (unmodifiable) list of all options set for this assignment
 FxGroupAssignment getParentGroupAssignment()
          If this assignment is assigned to a group, the assignment of the parent group (in the context of the current type)
 int getPosition()
          Get the position within the current XPath hierarchy
 long[] getScriptMapping(FxScriptEvent event)
          Get the mapped script ids for the requested script type
 java.lang.String getXPath()
          Get the XPath of this assignment without indices
 int hashCode()
          
 boolean hasOption(java.lang.String key)
          Check if an option is set for the requested key
 boolean hasParentGroupAssignment()
          Returns if this assignment is the child of another assignment or if it is directly attached to a FxType
 boolean hasScriptMapping(FxScriptEvent event)
          Does this assignment have mappings for the requested script event?
 boolean hasScriptMappings()
          Does this assignment have mappings for any script type?
 boolean isDerivedAssignment()
          Returns true if the assignment is derived from a supertype.
 boolean isEnabled()
          Is this assignment enabled?
 boolean isSystemInternal()
          Is this a system internal assignment?
 boolean isValid(java.lang.Object value)
          Validate the given value for this assignment.
 void resolveParentDependencies(java.util.List<FxAssignment> assignments)
          Resolve parent dependecies after initial loading
 void resolvePreloadDependencies(java.util.List<FxAssignment> assignments)
          Resolve preload dependecies after initial loading
 void resolveReferences(FxEnvironment environment)
          Resolve references after initial loading
static java.util.List<FxAssignment> sort(java.util.List<FxAssignment> assignments)
          Sort FxAssignments by their position
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_PARENT

public static final long NO_PARENT
parent id value if an assignment has no parent

See Also:
Constant Field Values

NO_BASE

public static final long NO_BASE
constant if an assignment has no base assignment

See Also:
Constant Field Values

ROOT_BASE

public static final long ROOT_BASE
base id value if an assignment belongs to the virtual root type

See Also:
Constant Field Values

TYPE_GROUP

public static final int TYPE_GROUP
Constant to determine type of the assignment in database; group

See Also:
Constant Field Values

TYPE_PROPERTY

public static final int TYPE_PROPERTY
Constant to determine type of the assignment in database; property

See Also:
Constant Field Values

POSITION_BOTTOM

public static final int POSITION_BOTTOM
Position constant to assign if an assignment should be positioned at the bottom

See Also:
Constant Field Values

enabled

protected boolean enabled
Is this assignment enabled at all? Disabled assignments will only show up in the admin area for structure and will be hidden from all other areas


multiplicity

protected FxMultiplicity multiplicity
Multiplicity of this assignment


defaultMultiplicity

protected int defaultMultiplicity
Default multiplicity, will be auto adjusted if < min or > max


position

protected int position
Position of this assignment within the same XPath hierarchy


XPath

protected java.lang.String XPath
Absolute XPath without indices from the base FxType


alias

protected java.lang.String alias
(optional) alias, if not defined the name of the assigned element


parentGroupAssignment

protected FxGroupAssignment parentGroupAssignment
(optional) parent group


baseAssignment

protected long baseAssignment
base assignment (if derived the parent, if not the root assignment, if its a root assignment FxAssignment.ROOT_BASE)


label

protected FxString label
(optional) description


hint

protected FxString hint
(optional) hint


scriptMapping

protected java.util.Map<FxScriptEvent,long[]> scriptMapping
Script mapping, is resolved while loading the environment


options

java.util.List<FxStructureOption> options
Constructor Detail

FxAssignment

protected FxAssignment(long assignmentId,
                       boolean enabled,
                       FxType assignedType,
                       java.lang.String alias,
                       java.lang.String xpath,
                       int position,
                       FxMultiplicity multiplicity,
                       int defaultMultiplicity,
                       FxGroupAssignment parentGroupAssignment,
                       long baseAssignment,
                       FxString label,
                       FxString hint,
                       java.util.List<FxStructureOption> options)
Constructor

Parameters:
assignmentId - internal id of this assignment
enabled - is this assignment enabled?
assignedType - the FxType this assignment belongs to
alias - an optional alias, if null the original name will be used
xpath - absolute XPath without indices from the base FxType
position - position within the same XPath hierarchy
multiplicity - multiplicity
defaultMultiplicity - default multiplicity
parentGroupAssignment - (optional) parent FxGroupAssignment this assignment belongs to
baseAssignment - base assignment (if derived the parent, if not the root assignment, if its a root assignment FxAssignment.ROOT_BASE)
label - (optional) label
hint - (optional) hint
options - options
Method Detail

getAlias

public java.lang.String getAlias()
Get the alias of this assignment. Groups and properties may define an alias to allow multiple use of the same group or property but using a different name. An alias is always defined, if not explicitly it is the properties/groups name.

Returns:
alias of this assignment

getId

public long getId()
The internal id of this assignment as stored in the database

Returns:
internal id of this assignment

isEnabled

public boolean isEnabled()
Is this assignment enabled?

Returns:
enabled

hasParentGroupAssignment

public boolean hasParentGroupAssignment()
Returns if this assignment is the child of another assignment or if it is directly attached to a FxType

Returns:
parent assignment

getParentGroupAssignment

public FxGroupAssignment getParentGroupAssignment()
If this assignment is assigned to a group, the assignment of the parent group (in the context of the current type)

Returns:
parent group assignment of this assignment

getBaseAssignmentId

public long getBaseAssignmentId()
base assignment (if derived the parent, if not the root assignment, if its a root assignment FxAssignment.ROOT_BASE)

Returns:
base assignment
See Also:
ROOT_BASE

isDerivedAssignment

public boolean isDerivedAssignment()
Returns true if the assignment is derived from a supertype.

Returns:
true if the assignment is derived from a supertype.

getAssignedType

public FxType getAssignedType()
The FxType this assignment is associated with

Returns:
FxType this assignment is associated with

getXPath

public java.lang.String getXPath()
Get the XPath of this assignment without indices

Returns:
XPath of this assignment without indices

getMultiplicity

public abstract FxMultiplicity getMultiplicity()
Get the multiplicity of this assignment. Depending on if the assigned element allows overriding of its base multiplicity the base elements multiplicity is returned or the multiplicity of the assignment

Returns:
multiplicity of this assignment

getDefaultMultiplicity

public int getDefaultMultiplicity()
Get the default multiplicity (used i.e. in user interfaces editors and determines the amount of values that will be initialized when creating an empty element).

If the set value is < min or > max multiplicity of this assignment it will be auto adjusted to the next valid value without throwing an exception

Returns:
default multiplicity

getPosition

public int getPosition()
Get the position within the current XPath hierarchy

Returns:
position within the current XPath hierarchy

getLabel

public FxString getLabel()
Get the assignment label

Returns:
the localized label of this assignment

getDisplayName

public java.lang.String getDisplayName()
Return a human-readable string to present this assignment to the user.

Returns:
the assignment's name as it should be displayed to the user

getDisplayLabel

public FxString getDisplayLabel()
Return a human-readable string to present this assignment to the user.

Returns:
the assignment's name as it should be displayed to the user

getHint

public FxString getHint()
Get the optional hint

Returns:
hint

hasOption

public boolean hasOption(java.lang.String key)
Check if an option is set for the requested key

Parameters:
key - option key
Returns:
if an option is set for the requested key

getOption

public FxStructureOption getOption(java.lang.String key)
Get an option entry for the given key, if the key is invalid or not found a FxStructureOption object will be returned with set set to false, overrideable set to false and value set to an empty String.

Parameters:
key - option key
Returns:
the found option or an object that indicates that the option is not set

getOptions

public java.util.List<FxStructureOption> getOptions()
Get a (unmodifiable) list of all options set for this assignment

Returns:
(unmodifiable) list of all options set for this assignment

hasScriptMapping

public boolean hasScriptMapping(FxScriptEvent event)
Does this assignment have mappings for the requested script event?

Parameters:
event - requested script event
Returns:
if mappings exist

hasScriptMappings

public boolean hasScriptMappings()
Does this assignment have mappings for any script type?

Returns:
if mappings exist

getScriptMapping

public long[] getScriptMapping(FxScriptEvent event)
Get the mapped script ids for the requested script type

Parameters:
event - requested script event
Returns:
mapped script ids or null if mappings do not exist for this assignment

createEmptyData

public abstract FxData createEmptyData(FxGroupData parent,
                                       int index)
                                throws FxCreateException
Create an empty FxData entry for this assignment

Parameters:
parent - the parent group
index - the index of the new entry
Returns:
FxData
Throws:
FxCreateException - on errors

createRandomData

public abstract FxData createRandomData(java.util.Random rnd,
                                        FxEnvironment env,
                                        FxGroupData parent,
                                        int index,
                                        int maxMultiplicity)
                                 throws FxCreateException
Create a random FxData entry for this assignment

Parameters:
rnd - the Random to use
env - environment
parent - the parent group
index - the index of the new entry
maxMultiplicity - the maximum multiplicity
Returns:
FxData
Throws:
FxCreateException - on errors

resolvePreloadDependencies

public void resolvePreloadDependencies(java.util.List<FxAssignment> assignments)
Resolve preload dependecies after initial loading

Parameters:
assignments - all known assignment

resolveReferences

public void resolveReferences(FxEnvironment environment)
                       throws FxNotFoundException
Resolve references after initial loading

Parameters:
environment - environment for references
Throws:
FxNotFoundException - on errors

resolveParentDependencies

public void resolveParentDependencies(java.util.List<FxAssignment> assignments)
Resolve parent dependecies after initial loading

Parameters:
assignments - all known assignments

compareTo

public int compareTo(FxAssignment o)
Compare function

Specified by:
compareTo in interface java.lang.Comparable<FxAssignment>
Parameters:
o - other assignment to compare to
Returns:
compare result

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

sort

public static java.util.List<FxAssignment> sort(java.util.List<FxAssignment> assignments)
Sort FxAssignments by their position

Parameters:
assignments - FxAssignments to sort
Returns:
sorted List with the assignments

isValid

public boolean isValid(java.lang.Object value)
Validate the given value for this assignment.

Parameters:
value - the value to be checked
Returns:
true if it is valid for this assignment, false otherwise

isSystemInternal

public boolean isSystemInternal()
Is this a system internal assignment?

Returns:
system internal

_setSystemInternal

public FxAssignment _setSystemInternal()
Mark this assignment as system internal - this is a one-way INTERNAL function!!!

Returns:
this

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object