com.flexive.shared.structure
Class FxGroupAssignment

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

public class FxGroupAssignment
extends FxAssignment
implements java.io.Serializable

Assignment of a (structure) group to a type or another assignment of a (structure) group

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

Field Summary
protected  FxGroup group
          The group assigned
protected  GroupMode mode
          mode used for children
 
Fields inherited from class com.flexive.shared.structure.FxAssignment
alias, baseAssignment, defaultMultCalc, defaultMultiplicity, enabled, hint, label, multiplicity, NO_BASE, NO_PARENT, options, parentGroupAssignment, position, POSITION_BOTTOM, ROOT_BASE, scriptMapping, TYPE_GROUP, TYPE_PROPERTY, XPath
 
Constructor Summary
FxGroupAssignment(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, FxGroup group, GroupMode mode, java.util.List<FxStructureOption> options)
          Constructor
 
Method Summary
protected  void addAssignment(FxAssignment as)
          Add and sort an assignment during initialization phase
 FxGroupAssignmentEdit asEditable()
          Get this FxGroupAssignment as editable
 FxData createEmptyData(FxGroupData parent, int index)
          Create an empty FxData entry for this assignment
 FxData createEmptyData(FxGroupData parent, int index, int position, boolean onlySystemInternal)
          Create an empty FxData entry for this assignment
 FxData createRandomData(java.util.Random rnd, FxEnvironment env, FxGroupData parent, int index, int maxMultiplicity)
          Create a random FxData entry for this assignment
 java.util.List<FxAssignment> getAllChildAssignments()
          Get all assignments of this group and its subgroups
 java.util.List<FxPropertyAssignment> getAllProperties()
          Return all property assignments that are assigned to this group or any subgroup.
 java.util.List<FxGroupAssignment> getAssignedGroups()
          Get all group assignments that are assigned to this assignment
 java.util.List<FxPropertyAssignment> getAssignedProperties()
          Get all property assignments that are assigned to this assignment
 FxAssignment getAssignment(java.util.List<XPathElement> XPath, java.lang.String fullXPath)
          Get an assignment for the given (relative to this group) XPath
 java.util.List<FxAssignment> getAssignments()
          Get all assignments (groups and properties in correct order) that are assigned to this group
 java.util.List<FxGroupAssignment> getDerivedAssignments(FxEnvironment environment)
          Return a list of all assignments that were derived from this one (i.e.
 FxGroup getGroup()
          Get the group this assignment relates to
 GroupMode getMode()
          Get the mode used for this group.
 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, overridable set to false and value set to an empty String.
 boolean hasMandatorySubAssignments()
          Check if any (direct) sub assignments of this group are mandatory
 FxGroupAssignmentEdit save()
          Save this assignment and return the saved instance.
 
Methods inherited from class com.flexive.shared.structure.FxAssignment
_setSystemInternal, compareTo, createEmptyData, equals, getAlias, getAssignedType, getAssignedTypeId, getBaseAssignmentId, getDefaultMultiplicity, getDepth, getDisplayLabel, getDisplayName, getDisplayName, getHint, getId, getLabel, getOptions, getParentGroupAssignment, getPosition, getScriptMapping, getXPath, hashCode, hasOption, hasParentGroupAssignment, hasScriptMapping, hasScriptMappings, isDerivedAssignment, isDerivedFrom, isEnabled, isSystemInternal, isValid, resolveDependencies, resolveReferences, sort, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

group

protected FxGroup group
The group assigned


mode

protected GroupMode mode
mode used for children

Constructor Detail

FxGroupAssignment

public FxGroupAssignment(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,
                         FxGroup group,
                         GroupMode mode,
                         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 - XPath relative to the assigned FxType
position - position within the same XPath hierarchy
multiplicity - multiplicity
defaultMultiplicity - default multiplicity
parentGroupAssignment - (optional) parent FxGroupAssignment this group 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
group - the assigned group
mode - used group mode (any-of or one-of)
options - options
Method Detail

getGroup

public FxGroup getGroup()
Get the group this assignment relates to

Returns:
group this assignment relates to

getMultiplicity

public 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

Specified by:
getMultiplicity in class FxAssignment
Returns:
multiplicity of this assignment

getAssignments

public java.util.List<FxAssignment> getAssignments()
Get all assignments (groups and properties in correct order) that are assigned to this group

Returns:
group assignments that are assigned to this assignment

getAssignedGroups

public java.util.List<FxGroupAssignment> getAssignedGroups()
Get all group assignments that are assigned to this assignment

Returns:
group assignments that are assigned to this assignment

getAssignedProperties

public java.util.List<FxPropertyAssignment> getAssignedProperties()
Get all property assignments that are assigned to this assignment

Returns:
property assignments that are assigned to this assignment

getAllProperties

public java.util.List<FxPropertyAssignment> getAllProperties()
Return all property assignments that are assigned to this group or any subgroup.

Returns:
all property assignments that are assigned to this group or any subgroup.

getAllChildAssignments

public java.util.List<FxAssignment> getAllChildAssignments()
Get all assignments of this group and its subgroups

Returns:
all assignments of this group and its subgroups

addAssignment

protected void addAssignment(FxAssignment as)
Add and sort an assignment during initialization phase

Parameters:
as - assignment to add at the correct position

createEmptyData

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

Specified by:
createEmptyData in class FxAssignment
Parameters:
parent - the parent group
index - the index of the new entry
Returns:
FxData
See Also:
FxAssignment.createEmptyData(com.flexive.shared.content.FxGroupData, int, int)

createEmptyData

public FxData createEmptyData(FxGroupData parent,
                              int index,
                              int position,
                              boolean onlySystemInternal)
Create an empty FxData entry for this assignment

Specified by:
createEmptyData in class FxAssignment
Parameters:
parent - the parent group
index - the index of the new entry
position - the position to use (to avoid puting multiple elemtns of the same type on the same position)
onlySystemInternal - when true, only system-internal groups or properties are added
Returns:
FxData
Since:
3.1.4

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, overridable set to false and value set to an empty String.

Overrides:
getOption in class FxAssignment
Parameters:
key - option key
Returns:
the found option or an object that indicates that the option is not set

createRandomData

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

Specified by:
createRandomData in class FxAssignment
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

getAssignment

public FxAssignment getAssignment(java.util.List<XPathElement> XPath,
                                  java.lang.String fullXPath)
                           throws FxNotFoundException
Get an assignment for the given (relative to this group) XPath

Parameters:
XPath - XPathElement array starting at this group
fullXPath - the full XPath for exception reporting
Returns:
FxAssignment
Throws:
FxNotFoundException - if no assignment was found

getMode

public GroupMode getMode()
Get the mode used for this group.

Returns:
group mode used

asEditable

public FxGroupAssignmentEdit asEditable()
Get this FxGroupAssignment as editable

Returns:
FxGroupAssignmentEdit

save

public FxGroupAssignmentEdit save()
                           throws FxApplicationException
Save this assignment and return the saved instance.

Returns:
the saved assignment
Throws:
FxApplicationException - on errors
Since:
3.1

getDerivedAssignments

public java.util.List<FxGroupAssignment> getDerivedAssignments(FxEnvironment environment)
Return a list of all assignments that were derived from this one (i.e. all assignments of subtypes with the same base assignment ID). An assignment can be inherited at most once in a type, since changing the (unique) alias breaks the inheritance chain.
Implementation analogous to method found in FxPropertyAssignment.

Parameters:
environment - the environment
Returns:
a list of all derived assignments
Since:
3.1.1

hasMandatorySubAssignments

public boolean hasMandatorySubAssignments()
Check if any (direct) sub assignments of this group are mandatory

Returns:
if any (direct) sub assignments of this group are mandatory
Since:
3.1.3