com.flexive.shared.content
Class FxContent

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

public class FxContent
extends java.lang.Object
implements java.io.Serializable

A content instance

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

Field Summary
static int POSITION_BOTTOM
          Bottommost position for relation positioning
static int POSITION_TOP
          Topmost position for relation positioning
 
Constructor Summary
FxContent(FxPK pk, long typeId, boolean relation, long mandatorId, long aclId, long stepId, int maxVersion, int liveVersion, boolean active, long mainLanguage, FxPK relatedSource, FxPK relatedDestination, int relatedSourcePosition, int relatedDestinationPosition, LifeCycleInfo lifeCycleInfo, FxGroupData data, long binaryPreviewId, long binaryPreviewACL)
          Constructor
 
Method Summary
 void checkValidity()
          Check if all required properties are present and valid, etc.
 boolean containsValue(java.lang.String XPath)
          Check if a value exists for the given XPath that is not empty
 FxContent copy()
          Create an independent copy of this FxContent
 FxContent copyAsNewInstance()
          Get an independent copy of this FxContent which is a new instance (can be saved as a copy)
 boolean equals(java.lang.Object obj)
          
 long getAclId()
          Getter for the ACL id
 java.util.List<java.lang.String> getAllPropertyXPaths()
          Get a list of all property XPaths contained in this content in correct order
 java.util.List<java.lang.String> getAllXPaths(java.lang.String groupPostfix)
          Get a list of all XPaths contained in this content in correct order
 long getBinaryPreviewACL()
          ACL that is needed to view the preview image
 long getBinaryPreviewId()
          Id of the binary used for previews
 FxString getCaption()
          Get the caption value of this instance.
 java.util.List<FxData> getData(java.lang.String XPath)
          Get all FxData (Group or Property) entries for the given XPath.
 FxGroupData getGroupData(java.lang.String XPath)
          Get the FxGroupData entry for the given XPath
 long getId()
          Getter for the Id
 LifeCycleInfo getLifeCycleInfo()
          Get the lifecycle information
 int getLiveVersion()
          Get the live version of this content or 0 if no live version exists
 long getMainLanguage()
          Get the main language
 long getMandatorId()
          Getter for the mandator id
 int getMaxVersion()
          Get the max version of this content
 PermissionSet getPermissions()
          Returns the permission set for the calling user.
 FxPK getPk()
          Getter for the primary key
 java.util.List<FxPropertyData> getPropertyData(long propertyId, boolean includeEmpty)
          Get a list of all FxPropertyData entries that are assigned to propertyId
 FxPropertyData getPropertyData(java.lang.String XPath)
          Get the FxPropertyData entry for the given XPath
 FxPK getRelatedDestination()
          If this is a relation get the assigned "to" (or destination) instance
 int getRelatedDestinationPosition()
          Get the position for the destination content instance
 FxPK getRelatedSource()
          If this is a relation get the assigned "from" (or source) instance
 int getRelatedSourcePosition()
          Get the position for the source content instance
 FxGroupData getRootGroup()
          Get the (virtual) root group of this content
 long getStepId()
          Getter for the step id
 long getTypeId()
          Getter for the type id
 FxValue getValue(java.lang.String XPath)
          Get the value of a (property) XPath.
 int getVersion()
          Getter for the version
 boolean hasCaption()
          Check if this content instance has a caption property assigned
 int hashCode()
           
 FxContent initSystemProperties()
           
 boolean isActive()
          Is this content active?
 boolean isLiveVersion()
          Is this content instance the live version
 boolean isMaxVersion()
          Is this content instance the max version
 boolean isPreviewAvailable()
          Is a preview available that is not a default image?
 boolean isRelation()
          Is this content a relation?
 boolean isXPathValid(java.lang.String XPath, boolean checkProperty)
          Check if the given XPath is valid for this content.
 void loadReferences(ContentEngine ce)
          Load all FxContent instances from properties of type FxReference
 boolean matchesPk(FxPK otherPk)
          Checks if the given PK matches this content.
 void move(java.lang.String XPath, int delta)
          Move data (group or property) within its hierarchy for delta positions up or down depending on the sign of delta without wrapping around if top or bottom position is reached.
 FxContent randomize()
          Drop all data and create random entries for testing purposes
 FxContent randomize(int maxMultiplicity)
          Drop all data and create random entries with a maximum multiplicity for testing purposes
 void remove(java.lang.String XPath)
          Remove the property or group denoted by XPath
 void replaceData(FxContent con)
          Replace our data with data from another content
 void resetBinaryPreview()
          Reset the preview image to show the default BinaryDescriptor.SYS_UNKNOWN image.
 void resolveBinaryPreview()
          Internal method that tries to find a matching preview image.
 void setAclId(long aclId)
          Set the ACL id
 void setActive(boolean active)
          (De-)activate this content
 void setBinaryPreview(long binaryId)
          Set the binary preview.
 void setBinaryPreview(java.lang.String XPath)
          Set the binary preview to an XPath.
 void setMainLanguage(long mainLanguage)
          Set the main language
 FxContent setRelatedDestination(FxPK dst)
          Set the primary key of the destination relation
 void setRelatedDestinationPosition(int relatedDestinationPosition)
           
 FxContent setRelatedSource(FxPK src)
          Set the primary key of the source relation
 void setRelatedSourcePosition(int relatedSourcePosition)
           
 void setStepId(long stepId)
          Set the workflow step id
 void setValue(java.lang.String XPath, FxValue value)
          Set a properties value, needed groups will be created
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSITION_TOP

public static final int POSITION_TOP
Topmost position for relation positioning

See Also:
Constant Field Values

POSITION_BOTTOM

public static final int POSITION_BOTTOM
Bottommost position for relation positioning

See Also:
Constant Field Values
Constructor Detail

FxContent

public FxContent(FxPK pk,
                 long typeId,
                 boolean relation,
                 long mandatorId,
                 long aclId,
                 long stepId,
                 int maxVersion,
                 int liveVersion,
                 boolean active,
                 long mainLanguage,
                 FxPK relatedSource,
                 FxPK relatedDestination,
                 int relatedSourcePosition,
                 int relatedDestinationPosition,
                 LifeCycleInfo lifeCycleInfo,
                 FxGroupData data,
                 long binaryPreviewId,
                 long binaryPreviewACL)
Constructor

Parameters:
pk - primary key
typeId - used type id
relation - is this a content for a relation?
mandatorId - mandator id
aclId - ACL id
stepId - step id
maxVersion - max. version for this instance
liveVersion - live version for this instance (0=no live version exists)
active - is this instance active
mainLanguage - main language
relatedSource - related source instance (only if this is a relation)
relatedDestination - related destination instance (only if this is a relation)
relatedSourcePosition - position for source instance (only if this is a relation)
relatedDestinationPosition - position for destination instance (only if this is a relation)
lifeCycleInfo - lifecycle
data - data
binaryPreviewId - id of the preview binary
binaryPreviewACL - id of the ACL of the preview binary
Method Detail

getPk

public FxPK getPk()
Getter for the primary key

Returns:
primary key

getId

public long getId()
Getter for the Id

Returns:
id

getVersion

public int getVersion()
Getter for the version

Returns:
version

getTypeId

public long getTypeId()
Getter for the type id

Returns:
type id

getMandatorId

public long getMandatorId()
Getter for the mandator id

Returns:
mandator id

getAclId

public long getAclId()
Getter for the ACL id

Returns:
ACL id

setAclId

public void setAclId(long aclId)
Set the ACL id

Parameters:
aclId - the ACL id

getStepId

public long getStepId()
Getter for the step id

Returns:
step id

setStepId

public void setStepId(long stepId)
Set the workflow step id

Parameters:
stepId - workflow step id

getMaxVersion

public int getMaxVersion()
Get the max version of this content

Returns:
max version of this content

isMaxVersion

public boolean isMaxVersion()
Is this content instance the max version

Returns:
if content instance the max version

getLiveVersion

public int getLiveVersion()
Get the live version of this content or 0 if no live version exists

Returns:
live version of this content or 0 if no live version exists

isLiveVersion

public boolean isLiveVersion()
Is this content instance the live version

Returns:
if content instance the live version

matchesPk

public boolean matchesPk(FxPK otherPk)
Checks if the given PK matches this content. This allows to match a generic PK (i.e. without a distinct version, but FxPK.LIVE or FxPK.MAX), which the FxPK equals method cannot do.

Parameters:
otherPk - the PK to be matched
Returns:
true if otherPk matches this content

getMainLanguage

public long getMainLanguage()
Get the main language

Returns:
main language

setMainLanguage

public void setMainLanguage(long mainLanguage)
Set the main language

Parameters:
mainLanguage - main language

isActive

public boolean isActive()
Is this content active?

Returns:
content is active

setActive

public void setActive(boolean active)
(De-)activate this content

Parameters:
active - active flag

isRelation

public boolean isRelation()
Is this content a relation?

Returns:
content is relation

getRelatedSource

public FxPK getRelatedSource()
If this is a relation get the assigned "from" (or source) instance

Returns:
the assigned "from" (or source) instance

setRelatedSource

public FxContent setRelatedSource(FxPK src)
Set the primary key of the source relation

Parameters:
src - source relation
Returns:
this

getRelatedDestination

public FxPK getRelatedDestination()
If this is a relation get the assigned "to" (or destination) instance

Returns:
the assigned "to" (or destination) instance

setRelatedDestination

public FxContent setRelatedDestination(FxPK dst)
Set the primary key of the destination relation

Parameters:
dst - destination relation
Returns:
this

getRelatedSourcePosition

public int getRelatedSourcePosition()
Get the position for the source content instance

Returns:
position for the source content instance

getRelatedDestinationPosition

public int getRelatedDestinationPosition()
Get the position for the destination content instance

Returns:
position for the destination content instance

setRelatedDestinationPosition

public void setRelatedDestinationPosition(int relatedDestinationPosition)

setRelatedSourcePosition

public void setRelatedSourcePosition(int relatedSourcePosition)

getLifeCycleInfo

public LifeCycleInfo getLifeCycleInfo()
Get the lifecycle information

Returns:
lifecycle information

getData

public java.util.List<FxData> getData(java.lang.String XPath)
                               throws FxInvalidParameterException,
                                      FxNotFoundException
Get all FxData (Group or Property) entries for the given XPath. Note: If the XPath refers to a group, only its child entries are returned and not the FxData of the group itsself. For accessing the group data ittself use getGroupData(String) instead.

Parameters:
XPath - requested XPath
Returns:
FxData elements for the given XPath
Throws:
FxInvalidParameterException - for invalid XPath provided
FxNotFoundException - if no match was found

getPropertyData

public FxPropertyData getPropertyData(java.lang.String XPath)
                               throws FxNotFoundException,
                                      FxInvalidParameterException
Get the FxPropertyData entry for the given XPath

Parameters:
XPath - requested XPath
Returns:
FxPropertyData entry for the given XPath
Throws:
FxInvalidParameterException - for invalid XPath provided or XPath is no property
FxNotFoundException - if no match was found

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
includeEmpty - include empty data instances?
Returns:
list of all FxPropertyData entries that are assigned to propertyId

getGroupData

public FxGroupData getGroupData(java.lang.String XPath)
                         throws FxNotFoundException,
                                FxInvalidParameterException
Get the FxGroupData entry for the given XPath

Parameters:
XPath - requested XPath
Returns:
FxGroupData entry for the given XPath
Throws:
FxInvalidParameterException - for invalid XPath provided or XPath is no property
FxNotFoundException - if no match was found

getRootGroup

public FxGroupData getRootGroup()
Get the (virtual) root group of this content

Returns:
root group

setValue

public void setValue(java.lang.String XPath,
                     FxValue value)
              throws FxNotFoundException,
                     FxInvalidParameterException,
                     FxNoAccessException,
                     FxCreateException
Set a properties value, needed groups will be created

Parameters:
XPath - FQ XPath
value - value to apply
Throws:
FxNotFoundException - if the requested XPath does not exist
FxInvalidParameterException - if the request XPath is invalid
FxNoAccessException - if the property for this XPath is marked readonly or no access
FxCreateException - if missing XPath entries failed to be created

getValue

public FxValue getValue(java.lang.String XPath)
                 throws FxNotFoundException,
                        FxInvalidParameterException
Get the value of a (property) XPath. This is actually a convenience method that internally calls getPropertyData(XPath).getValuXDEPTHe()

Parameters:
XPath - requested XPath
Returns:
FxValue
Throws:
FxNotFoundException - on errors
FxInvalidParameterException - on errors
See Also:
getPropertyData(String)

containsValue

public boolean containsValue(java.lang.String XPath)
Check if a value exists for the given XPath that is not empty

Parameters:
XPath - the XPath to check
Returns:
if a value exists for the given XPath that is not empty

isXPathValid

public boolean isXPathValid(java.lang.String XPath,
                            boolean checkProperty)
Check if the given XPath is valid for this content. This is a shortcut to the corresponding type's method!

Parameters:
XPath - the XPath to check
checkProperty - should the XPath point to a property?
Returns:
if the XPath is valid or not
See Also:
FxType.isXPathValid(String,boolean)

randomize

public FxContent randomize(int maxMultiplicity)
                    throws FxCreateException,
                           FxNotFoundException,
                           FxInvalidParameterException
Drop all data and create random entries with a maximum multiplicity for testing purposes

Parameters:
maxMultiplicity - the maximum multiplicity for groups
Returns:
this
Throws:
FxCreateException - on errors
FxNotFoundException - on errors
FxInvalidParameterException - on errors

randomize

public FxContent randomize()
                    throws FxCreateException,
                           FxNotFoundException,
                           FxInvalidParameterException
Drop all data and create random entries for testing purposes

Returns:
this
Throws:
FxCreateException - on errors
FxNotFoundException - on errors
FxInvalidParameterException - on errors

move

public void move(java.lang.String XPath,
                 int delta)
          throws FxInvalidParameterException,
                 FxNotFoundException
Move data (group or property) within its hierarchy for delta positions up or down depending on the sign of delta without wrapping around if top or bottom position is reached. 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:
XPath - FQ XPath
delta - relative number of positions to move
Throws:
FxInvalidParameterException - for invalid XPath
FxNotFoundException - XPath does not exist for this content

remove

public void remove(java.lang.String XPath)
            throws FxInvalidParameterException,
                   FxNotFoundException,
                   FxNoAccessException
Remove the property or group denoted by XPath

Parameters:
XPath - the XPath to remove
Throws:
FxInvalidParameterException - if the requested XPath is required and can not be removed
FxNotFoundException - if XPath is incorrect
FxNoAccessException - if data that is to be removed is readonly or no access

checkValidity

public void checkValidity()
                   throws FxInvalidParameterException
Check if all required properties are present and valid, etc.

Throws:
FxInvalidParameterException - if required properties are not present or the content is not valid

initSystemProperties

public FxContent initSystemProperties()
                               throws FxNotFoundException,
                                      FxInvalidParameterException
Throws:
FxNotFoundException
FxInvalidParameterException

getAllPropertyXPaths

public java.util.List<java.lang.String> getAllPropertyXPaths()
Get a list of all property XPaths contained in this content in correct order

Returns:
list of all property XPaths contained in this content in correct order

getAllXPaths

public java.util.List<java.lang.String> getAllXPaths(java.lang.String groupPostfix)
Get a list of all XPaths contained in this content in correct order

Parameters:
groupPostfix - String to append to found groups (useful to append "/" to kind of mark those XPaths as group XPaths)
Returns:
list of all XPaths contained in this content in correct order

isPreviewAvailable

public boolean isPreviewAvailable()
Is a preview available that is not a default image?

Returns:
preview available

getBinaryPreviewId

public long getBinaryPreviewId()
Id of the binary used for previews

Returns:
id of the binary used for previews

getBinaryPreviewACL

public long getBinaryPreviewACL()
ACL that is needed to view the preview image

Returns:
ACL that is needed to view the preview image

setBinaryPreview

public void setBinaryPreview(java.lang.String XPath)
Set the binary preview to an XPath. Illegal or non-existing values will be ignored!

Parameters:
XPath - the XPath of the requested binary to set as preview

setBinaryPreview

public void setBinaryPreview(long binaryId)
Set the binary preview. Illegal or non-existing values will be ignored!

Parameters:
binaryId - if of the requested binary to set as preview

resolveBinaryPreview

public void resolveBinaryPreview()
Internal method that tries to find a matching preview image. Searches for images and then regular binaries (preview is then set matching the mime type display). If neither are found the BinaryDescriptor.SYS_UNKNOWN image is used

See Also:
BinaryDescriptor.SYS_UNKNOWN

resetBinaryPreview

public void resetBinaryPreview()
Reset the preview image to show the default BinaryDescriptor.SYS_UNKNOWN image.

See Also:
BinaryDescriptor.SYS_UNKNOWN

copy

public FxContent copy()
Create an independent copy of this FxContent

Returns:
a copy of this FxContent

copyAsNewInstance

public FxContent copyAsNewInstance()
Get an independent copy of this FxContent which is a new instance (can be saved as a copy)

Returns:
a copy of this FxContent with a new pk

loadReferences

public void loadReferences(ContentEngine ce)
                    throws FxApplicationException
Load all FxContent instances from properties of type FxReference

Parameters:
ce - ContentEngine
Throws:
FxApplicationException - on errors

getPermissions

public PermissionSet getPermissions()
Returns the permission set for the calling user.

Returns:
the permission set for the calling user.

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

replaceData

public void replaceData(FxContent con)
                 throws FxApplicationException
Replace our data with data from another content

Parameters:
con - other content to take data from
Throws:
FxApplicationException - on errors

hasCaption

public boolean hasCaption()
                   throws FxApplicationException
Check if this content instance has a caption property assigned

Returns:
true if a caption property is assigned to this content instance
Throws:
FxApplicationException - on erros

getCaption

public FxString getCaption()
Get the caption value of this instance. If no caption property is assigned, this method will return null

Returns:
caption or null if not assigned