com.flexive.shared.content
Class FxGroupData

java.lang.Object
  extended by com.flexive.shared.content.FxData
      extended by com.flexive.shared.content.FxGroupData
All Implemented Interfaces:
java.io.Serializable

public class FxGroupData
extends FxData

FxData extension for groups

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

Nested Class Summary
static class FxGroupData.AddGroupOptions
          Options for addGroup(String, com.flexive.shared.structure.FxGroupAssignment, int, AddGroupOptions)
 
Field Summary
(package private) static FxGroupData.AddGroupOptions DEFAULT_ADD_OPTIONS
           
 
Fields inherited from class com.flexive.shared.content.FxData
parent, POSITION_BOTTOM, POSITION_TOP, xpAlias, XPathFull, xpIndex, xpPrefix
 
Constructor Summary
FxGroupData(FxGroupData other, FxGroupData parent)
          Copy constructor.
FxGroupData(java.lang.String xpPrefix, java.lang.String alias, int index, java.lang.String xPath, java.lang.String xPathFull, int[] indices, long assignmentId, FxMultiplicity assignmentMultiplicity, int pos, FxGroupData parent, java.util.List<FxData> data, boolean systemInternal)
           
 
Method Summary
 FxData addChild(FxData child)
          Add a child FxData at the correct position
 FxData addEmptyChild(java.lang.String xPath, int pos)
          Add an and FxData entry with the given XPath to this group (must be a direct child of this group, no nesting allowed!).
 void addGroup(java.lang.String xPath, FxGroupAssignment fxGroupAssignment, int pos)
          Add a group entry at the given XPath.
 void addGroup(java.lang.String xPath, FxGroupAssignment fxGroupAssignment, int pos, FxGroupData.AddGroupOptions options)
          Add a group entry at the given XPath.
 void addProperty(java.lang.String xPath, FxPropertyAssignment assignment, FxValue value, int pos)
          Add a property at the given XPath location, removing eventually existing properties.
protected  void applyIndices()
          Apply the multiplicity to XPath and children if its a group
 void compactPositions(boolean includeSubGroups)
          Synchronize positions closing gaps optionally including sub groups
 FxData containsChild(XPathElement check)
          Check if a child with the same alias and multiplicity that is not empty exists.
protected  FxGroupData copy(FxGroupData parent)
          Create an independent copy of this group or property FxData
static FxGroupData createVirtualRootGroup(java.lang.String xpPrefix)
          Helper to create a virtual root group
 void explode(boolean explodeChildGroups)
          "Explode" this group by adding all creatable assignments at the bottom
 void fixChildIndices()
          'Fix' the indices of children after they have been added to reflect the parent groups index in their XPath Don't work in the root of a type
 FxValueChangeListener getChangeListener()
          Get thechange listener if attached
 java.util.List<FxData> getChildren()
          Get all child entries for this group
 java.util.Collection<FxData> getChildrenWithoutInternal()
          Get all child entries for this group, excluding all internal properties.
 java.util.List<java.lang.String> getCreateableChildren(boolean includeExisting)
          Get a list of child FxData instances (as XPath with full indices) that can be created as children for this group.
 FxGroupData getGroup(long assignmentId)
          Get the FxGroupData entry for the given group assignment.
 FxGroupData getGroup(java.lang.String xPath)
          Get the group denoted by the given XPath
 FxGroupAssignment getGroupAssignment()
          Get the groups assignment
 java.util.List<FxPropertyData> getPropertyData(long propertyId, boolean includeEmpty)
          Get a list of all FxPropertyData entries that are assigned to propertyId
protected  java.util.List<FxReference> getReferences(boolean includeSubGroups)
          Get a list of all FxReference values in this group and optionally all sub groups
 boolean hasChangeListener()
          Is a change listener attached
 boolean isEmpty()
          Is this data empty?
 boolean isGroup()
          Is this FxData a property or group?
 boolean isHasGroups()
          Return true if the content has at least one group.
 boolean isHasMultiLangProperty()
          Return true if this content has at least one multilingual property set.
 boolean isProperty()
          Is this FxData a property or group?
 boolean isRequiredPropertiesPresent()
          Are there any required properties (empty or non-empty) present?
 boolean isRootGroup()
          Is this group the root group?
 void moveChild(XPathElement xp, int delta)
          Move a child element identified by its alias and multiplicity by delta positions within this group If delta is Integer.MAX_VALUE the data will always be placed at the bottom, Integer.MIN_VALUE will always place it at the top.
 void removeChild(FxData data)
          Remove the requested child data and compact indices and positions
 void removeChildren(java.util.List<FxData> dataList)
          Remove the requested children and compact indices and positions
 void removeEmptyEntries()
          Remove all empty entries of this group that are not required
 void removeEmptyEntries(boolean includeRequired)
          Remove all empty entries of this group
 void removeNonInternalData()
          Remove all entries that are not system internal form the current group
 void replaceChild(XPathElement xpath, FxData data)
           
 void setChangeListener(FxValueChangeListener changeListener, boolean includeSubGroups)
          Set the change listener
 void setChildPosition(FxData child, int newPos)
          Move a child to a new position.
 void setEmpty()
          Replace all data with empty values/groups
protected  void setXPathFull(java.lang.String xpathFull)
          Update the XPath with indices.
protected  void valueChanged(java.lang.String xpath, FxValueChangeListener.ChangeType changeType)
          Called internally when a value has changed
 
Methods inherited from class com.flexive.shared.content.FxData
compact, createNew, equals, getAlias, getAssignment, getAssignmentId, getAssignmentMultiplicity, getCreateableElements, getElements, getIndex, getIndices, getOccurances, getParent, getPos, getRemoveableElements, getXPath, getXPathElement, getXPathFull, getXPathPrefix, hashCode, isRemoveable, isSystemInternal, mayCreateMore, move, moveIndex, setPos, toString, xpCached
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_ADD_OPTIONS

static final FxGroupData.AddGroupOptions DEFAULT_ADD_OPTIONS
Constructor Detail

FxGroupData

public FxGroupData(java.lang.String xpPrefix,
                   java.lang.String alias,
                   int index,
                   java.lang.String xPath,
                   java.lang.String xPathFull,
                   int[] indices,
                   long assignmentId,
                   FxMultiplicity assignmentMultiplicity,
                   int pos,
                   FxGroupData parent,
                   java.util.List<FxData> data,
                   boolean systemInternal)
            throws FxInvalidParameterException
Throws:
FxInvalidParameterException

FxGroupData

public FxGroupData(FxGroupData other,
                   FxGroupData parent)
Copy constructor.

Parameters:
other - the group data instance to copy
parent - the new parent
Since:
3.2.0
Method Detail

isProperty

public boolean isProperty()
Is this FxData a property or group?

Specified by:
isProperty in class FxData
Returns:
if this FxData is a property or group

isGroup

public boolean isGroup()
Is this FxData a property or group?

Specified by:
isGroup in class FxData
Returns:
if this FxData is a property or group

getGroupAssignment

public FxGroupAssignment getGroupAssignment()
Get the groups assignment

Returns:
FxGroupAssignment
Since:
3.1

getChildren

public java.util.List<FxData> getChildren()
Get all child entries for this group

Returns:
child entries

getChildrenWithoutInternal

public java.util.Collection<FxData> getChildrenWithoutInternal()
Get all child entries for this group, excluding all internal properties.

Returns:
child entries, excluding all internal properties.
Since:
3.1

isEmpty

public boolean isEmpty()
Is this data empty?

Specified by:
isEmpty in class FxData
Returns:
empty

setEmpty

public void setEmpty()
Replace all data with empty values/groups

Specified by:
setEmpty in class FxData

isRequiredPropertiesPresent

public boolean isRequiredPropertiesPresent()
Are there any required properties (empty or non-empty) present?

Specified by:
isRequiredPropertiesPresent in class FxData
Returns:
true if there any required properties (empty or non-empty) present

isHasMultiLangProperty

public boolean isHasMultiLangProperty()
Return true if this content has at least one multilingual property set.

Returns:
true if this content has at least one multilingual property set.
Since:
3.1

createVirtualRootGroup

public static FxGroupData createVirtualRootGroup(java.lang.String xpPrefix)
                                          throws FxInvalidParameterException
Helper to create a virtual root group

Parameters:
xpPrefix - XPath prefix like "FxType name[@pk=..]"
Returns:
virtual root group
Throws:
FxInvalidParameterException - on errors

moveChild

public void moveChild(XPathElement xp,
                      int delta)
Move a child element identified by its alias and multiplicity by delta positions within this group If delta is Integer.MAX_VALUE the data will always be placed at the bottom, Integer.MIN_VALUE will always place it at the top.

Parameters:
xp - element to move
delta - delta positions to move

addChild

public FxData addChild(FxData child)
Add a child FxData at the correct position

Parameters:
child - FxData to add
Returns:
the child

addEmptyChild

public FxData addEmptyChild(java.lang.String xPath,
                            int pos)
Add an and FxData entry with the given XPath to this group (must be a direct child of this group, no nesting allowed!). Empty groups consist of empty but preinitialized elements!

Parameters:
xPath - XPath to add to this group (must be a direct child of this group, no nesting allowed!)
pos - position in same hierarchy level
Returns:
the added data element

applyIndices

protected void applyIndices()
Apply the multiplicity to XPath and children if its a group

Specified by:
applyIndices in class FxData

setXPathFull

protected void setXPathFull(java.lang.String xpathFull)
Update the XPath with indices.

Specified by:
setXPathFull in class FxData
Parameters:
xpathFull - the complete XPath including indices.

fixChildIndices

public void fixChildIndices()
'Fix' the indices of children after they have been added to reflect the parent groups index in their XPath Don't work in the root of a type


removeEmptyEntries

public void removeEmptyEntries()
Remove all empty entries of this group that are not required

See Also:
removeEmptyEntries(boolean)

removeEmptyEntries

public void removeEmptyEntries(boolean includeRequired)
Remove all empty entries of this group

Parameters:
includeRequired - include entries that are required (but empty)?

compactPositions

public void compactPositions(boolean includeSubGroups)
Synchronize positions closing gaps optionally including sub groups

Parameters:
includeSubGroups - close gaps for subgroups as well?

isRootGroup

public boolean isRootGroup()
Is this group the root group?

Returns:
if this group is the root group

getGroup

public FxGroupData getGroup(java.lang.String xPath)
Get the group denoted by the given XPath

Parameters:
xPath - requested XPath for the group
Returns:
FxGroupData

getGroup

public FxGroupData getGroup(long assignmentId)
Get the FxGroupData entry for the given group assignment.

Parameters:
assignmentId - the group assignment ID
Returns:
FxGroupData entry for the given assignment
Throws:
FxRuntimeException - if the assignment was not found
Since:
3.1.4

isHasGroups

public boolean isHasGroups()
Return true if the content has at least one group.

Returns:
true if the content has at least one group.
Since:
3.1

addProperty

public void addProperty(java.lang.String xPath,
                        FxPropertyAssignment assignment,
                        FxValue value,
                        int pos)
Add a property at the given XPath location, removing eventually existing properties. The group for this property has to exist already!

Parameters:
xPath - requested XPath
assignment - assignment of the property
value - value
pos - position

containsChild

public FxData containsChild(XPathElement check)
Check if a child with the same alias and multiplicity that is not empty exists. No elements of subgroups are checked, just direct childs!

Parameters:
check - XPathElement to check
Returns:
FxData or null

replaceChild

public void replaceChild(XPathElement xpath,
                         FxData data)

addGroup

public void addGroup(java.lang.String xPath,
                     FxGroupAssignment fxGroupAssignment,
                     int pos)
              throws FxInvalidParameterException,
                     FxNotFoundException,
                     FxCreateException
Add a group entry at the given XPath. Existing entries will stay untouched but position adjusted. If parent groups of this group do not exist, they will be created as well.

Parameters:
xPath - requested XPath
fxGroupAssignment - the assignment of the group
pos - position
Throws:
FxInvalidParameterException - on errors
FxNotFoundException - on errors
FxCreateException - on errors

addGroup

public void addGroup(java.lang.String xPath,
                     FxGroupAssignment fxGroupAssignment,
                     int pos,
                     FxGroupData.AddGroupOptions options)
              throws FxInvalidParameterException,
                     FxNotFoundException,
                     FxCreateException
Add a group entry at the given XPath. Existing entries will stay untouched but position adjusted. If parent groups of this group do not exist, they will be created as well.

Parameters:
xPath - requested XPath
fxGroupAssignment - the assignment of the group
pos - position
options - options for creating the new group
Throws:
FxInvalidParameterException - on errors
FxNotFoundException - on errors
FxCreateException - on errors
Since:
3.2.0

removeChild

public void removeChild(FxData data)
Remove the requested child data and compact indices and positions

Parameters:
data - FxData to remove

removeChildren

public void removeChildren(java.util.List<FxData> dataList)
Remove the requested children and compact indices and positions

Parameters:
dataList - list of FxData to remove

explode

public void explode(boolean explodeChildGroups)
"Explode" this group by adding all creatable assignments at the bottom

Parameters:
explodeChildGroups - recursively explode all existing child groups?

getCreateableChildren

public java.util.List<java.lang.String> getCreateableChildren(boolean includeExisting)
Get a list of child FxData instances (as XPath with full indices) that can be created as children for this group. Readonly or no access properties or groups will not be returned!

Parameters:
includeExisting - include entries for children that already exist but with a new (higher) multiplicity?
Returns:
List of XPaths

copy

protected FxGroupData copy(FxGroupData parent)
Create an independent copy of this group or property FxData

Specified by:
copy in class FxData
Parameters:
parent - parent group
Returns:
independent copy

getReferences

protected java.util.List<FxReference> getReferences(boolean includeSubGroups)
Get a list of all FxReference values in this group and optionally all sub groups

Parameters:
includeSubGroups - collect FxReferences from sub groups as well?
Returns:
list of all FxReference values in this group and optionally all sub groups

getPropertyData

public java.util.List<FxPropertyData> getPropertyData(long propertyId,
                                                      boolean includeEmpty)
Get a list of all FxPropertyData entries that are assigned to propertyId

Parameters:
propertyId - the property id requested. -1 to return all properties.
includeEmpty - include empty data instances?
Returns:
list of all FxPropertyData entries that are assigned to propertyId

removeNonInternalData

public void removeNonInternalData()
Remove all entries that are not system internal form the current group

Since:
3.1

hasChangeListener

public boolean hasChangeListener()
Is a change listener attached

Returns:
a change listener is attached
Since:
3.1.6

getChangeListener

public FxValueChangeListener getChangeListener()
Get thechange listener if attached

Returns:
a change listener if attached
Since:
3.1.6

setChangeListener

public void setChangeListener(FxValueChangeListener changeListener,
                              boolean includeSubGroups)
Set the change listener

Parameters:
changeListener - change listener
includeSubGroups - set the change listener for subgroups as well?
Since:
3.1.6

setChildPosition

public void setChildPosition(FxData child,
                             int newPos)
Move a child to a new position.

Parameters:
child - the child data
newPos - the new position
Since:
3.2.0

valueChanged

protected void valueChanged(java.lang.String xpath,
                            FxValueChangeListener.ChangeType changeType)
Called internally when a value has changed

Parameters:
xpath - affected xpath
changeType - type of change