com.flexive.shared.structure.export
Class StructureExporter

java.lang.Object
  extended by com.flexive.shared.structure.export.StructureExporter
All Implemented Interfaces:
StructureExporterCallback

public class StructureExporter
extends java.lang.Object
implements StructureExporterCallback

Generate an export hierarchy for (a) type(s). The StructureExporter creates a "flattened" view of a given structure (and its dependent assignments)

Author:
Christopher Blasnik (c.blasnik@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
com.flexive.shared.structure.export.StructureExporterCallback;

Nested Class Summary
(package private) static class StructureExporter.MultipleStructureExporter
          A class to handle multiple structureExporter requests (i.e.
(package private) static class StructureExporter.ResultObject
          A class to store result objects (from the GenericStructureExporter)
 
Method Summary
 java.util.Map<java.lang.Long,java.util.Map<java.lang.String,java.util.List<java.lang.Long>>> getAssignmentScriptMapping()
          
 java.util.Map<FxType,java.util.List<FxAssignment>> getDependencies()
          Get the (mutual) dependencies for (a) given type(s).
 StructureExporterCallback getDependencyStructure(long typeId)
          Returns a dependencyStructure for a given type's id
 java.util.List<StructureExporterCallback> getDependencyStructures()
          Returns instances of StructureExporterCallback containing the export structure of dependencies.
 java.util.Map<java.lang.Long,java.lang.Long> getDependentOnMapping()
          
 java.util.List<java.lang.Long> getDifferingDerivedAssignments()
          This method retrieve all derived assignments from a given DERIVED type whose properties differ (e.g.
 java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> getGroupAssignmentIds()
          Utility method returns the resulting group assignments as a Map<Long, List<Long>> of the groups' ids (keys) and their assigned children's ids (value List)
 java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> getGroupAssignments()
          Returns all groups and their respective child assignments.
 boolean getHasDependencies()
           
 boolean getIsMultipleTypeCall()
          
(package private)  StructureExporter.ResultObject getResult()
           
 java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> getTypeAssignmentIds()
          Utility method returns the resulting type assignments as a Map<Long, List<Long>> of the types' ids (keys) and their root assignments (value List)
 java.util.Map<FxType,java.util.List<FxAssignment>> getTypeAssignments()
          Returns a LinkedHashMap of immediate (root) assignments for the FxTypes considered.
 long getTypeId()
          
 java.util.List<java.lang.Long> getTypeIds()
          
 java.util.Map<java.lang.Long,java.util.Map<java.lang.String,java.util.List<java.lang.Long>>> getTypeScriptMapping()
          
static StructureExporter newInstance(java.util.List<java.lang.Long> typeIds, boolean ignoreDependencies)
          Returns an instance of the StructureExporter for a call with multiple type Ids
static StructureExporter newInstance(long typeId, boolean ignoreDependencies)
          Returns an instance of the StructureExporter
 void setDependencies(java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> dependencies)
          Set the (mutual) dependencies: a Map containing ids (Long) of FxTypes (keys) and Lists of ids (Long) of FxAssignments (values) (disregarding their hierarchical positions within a type) which are (mutually) dependent on other types This function must accumulate all dependencies in the case of a multiple type call
 void setDependentOnMapping(java.util.Map<java.lang.Long,java.lang.Long> dependentOnMapping)
          
 void setGroupAssignments(java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments)
          Set the group assignments: a Map<FxGroupAssignment> (keys) having the respective group's child assignments as values
 void setTypeAssignments(java.util.Map<FxType,java.util.List<FxAssignment>> typeAssignments)
          Sets the Map of (keys) and a List of FxAssignments (values) which reside in the root of a given type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static StructureExporter newInstance(long typeId,
                                            boolean ignoreDependencies)
Returns an instance of the StructureExporter

Parameters:
typeId - the id of the type to be exported
ignoreDependencies - set to true if dependencies on other types / assignments should be ignored
Returns:
returns an instance of the StructureExporter

newInstance

public static StructureExporter newInstance(java.util.List<java.lang.Long> typeIds,
                                            boolean ignoreDependencies)
Returns an instance of the StructureExporter for a call with multiple type Ids

Parameters:
typeIds - the List of type ids to be exported
ignoreDependencies - set to true of dependencies on other types / assignments should be ignored
Returns:
returns an instance of the StructureExporter containing the accumulated results

getTypeId

public long getTypeId()

Specified by:
getTypeId in interface StructureExporterCallback
Returns:
returns the initial typeId

setDependencies

public void setDependencies(java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> dependencies)
Set the (mutual) dependencies: a Map containing ids (Long) of FxTypes (keys) and Lists of ids (Long) of FxAssignments (values) (disregarding their hierarchical positions within a type) which are (mutually) dependent on other types This function must accumulate all dependencies in the case of a multiple type call

Specified by:
setDependencies in interface StructureExporterCallback
Parameters:
dependencies - Map<Long, List<Long>> of mutual dependencies

getDependencies

public java.util.Map<FxType,java.util.List<FxAssignment>> getDependencies()
                                                                   throws FxApplicationException
Get the (mutual) dependencies for (a) given type(s). Returns NULL IFF getHasDependencies() returns false This method returns the dependent assignments w/o their respective parents (structure-dependent)

Specified by:
getDependencies in interface StructureExporterCallback
Returns:
returns the Map<FxType, List<FxAssignment>> of (mutual) dependencies
Throws:
FxApplicationException - on errors

getDependencyStructures

public java.util.List<StructureExporterCallback> getDependencyStructures()
                                                                  throws FxInvalidStateException
Returns instances of StructureExporterCallback containing the export structure of dependencies. This method can only be called if the previous call to GenericStructureExporter was done with ignoreDependencies = false and if the subsequent evaluation returned (mutual) dependencies

Specified by:
getDependencyStructures in interface StructureExporterCallback
Returns:
returns an instance of StructureExporterCallback
Throws:
FxInvalidStateException - on errors

getDifferingDerivedAssignments

public java.util.List<java.lang.Long> getDifferingDerivedAssignments()
                                                              throws FxInvalidStateException
This method retrieve all derived assignments from a given DERIVED type whose properties differ (e.g. multiplicity) from its parent assignment. PREREQUISITES: getHasDependencies() must return true, dependencyStructures must have been initialised!

Specified by:
getDifferingDerivedAssignments in interface StructureExporterCallback
Returns:
the list derived assignments whose properties differ from their respective base assignments, or an empty list if no differences were found
Throws:
FxInvalidStateException - if export conditions are not met

setTypeAssignments

public void setTypeAssignments(java.util.Map<FxType,java.util.List<FxAssignment>> typeAssignments)
Sets the Map of (keys) and a List of FxAssignments (values) which reside in the root of a given type. Will automatically remove system types if the StructureExporter.ignoreFlexiveSystemTypes is set

Specified by:
setTypeAssignments in interface StructureExporterCallback
Parameters:
typeAssignments - the Map<FxType>, List<FxAssignment>>

setGroupAssignments

public void setGroupAssignments(java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments)
Set the group assignments: a Map<FxGroupAssignment> (keys) having the respective group's child assignments as values

Specified by:
setGroupAssignments in interface StructureExporterCallback
Parameters:
groupAssignments - Map<FxGroupAssignment, List<FxAssignment>>

getTypeAssignments

public java.util.Map<FxType,java.util.List<FxAssignment>> getTypeAssignments()
Returns a LinkedHashMap of immediate (root) assignments for the FxTypes considered. If a type has no Assignments, the List of values will be null. IMPORTANT: In the case of mutual dependencies, multiple FxTypes will be returned in the map. The ORDER of the the keys == order in which the FxTypes have to be created when reimporting via script / code

Specified by:
getTypeAssignments in interface StructureExporterCallback
Returns:
returns Map<FxType, List<FxAssignment>>

getGroupAssignments

public java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> getGroupAssignments()
Returns all groups and their respective child assignments. IMPORTANT: If a group has no assignments, the List of values will be null; If a type contains no groups, the returned Map will be null.

Specified by:
getGroupAssignments in interface StructureExporterCallback
Returns:
returns Map<FxGroupAssignment>, List<FxAssignment>>

getHasDependencies

public boolean getHasDependencies()
Specified by:
getHasDependencies in interface StructureExporterCallback
Returns:
Returns true if the current type has dependencies, false otherwise and if called with "ignoreDependencies=true" or if no dependencies were found in the evaluation phase

getDependencyStructure

public StructureExporterCallback getDependencyStructure(long typeId)
                                                 throws FxInvalidStateException
Returns a dependencyStructure for a given type's id

Specified by:
getDependencyStructure in interface StructureExporterCallback
Parameters:
typeId - the type Id for which a dependecy structure should be returned
Returns:
returns an instance of StructureExporterCallback if the structure was found, null otherwise
Throws:
FxInvalidStateException - on errors

getResult

StructureExporter.ResultObject getResult()
Returns:
returns the ResultObject

getIsMultipleTypeCall

public boolean getIsMultipleTypeCall()

Specified by:
getIsMultipleTypeCall in interface StructureExporterCallback
Returns:
Returns true if the call was made for multiple types

getTypeIds

public java.util.List<java.lang.Long> getTypeIds()

Specified by:
getTypeIds in interface StructureExporterCallback
Returns:
returns the List of initial typeIds

setDependentOnMapping

public void setDependentOnMapping(java.util.Map<java.lang.Long,java.lang.Long> dependentOnMapping)

Specified by:
setDependentOnMapping in interface StructureExporterCallback
Parameters:
dependentOnMapping - set the Map of assignment ids dependent on other assignments

getTypeScriptMapping

public java.util.Map<java.lang.Long,java.util.Map<java.lang.String,java.util.List<java.lang.Long>>> getTypeScriptMapping()

Specified by:
getTypeScriptMapping in interface StructureExporterCallback
Returns:
Returns the script mappings for each type: type id (key) --> event (key) --> script ids (value List)

getAssignmentScriptMapping

public java.util.Map<java.lang.Long,java.util.Map<java.lang.String,java.util.List<java.lang.Long>>> getAssignmentScriptMapping()

Specified by:
getAssignmentScriptMapping in interface StructureExporterCallback
Returns:
Returns the script mappings for each assignment: assignment id (key) --> event (key) --> script ids (value List)

getDependentOnMapping

public java.util.Map<java.lang.Long,java.lang.Long> getDependentOnMapping()

Specified by:
getDependentOnMapping in interface StructureExporterCallback
Returns:
returns the Map of assignment ids (keys) which are derived (dependent on) other assignments (values - ids)

getTypeAssignmentIds

public java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> getTypeAssignmentIds()
Utility method returns the resulting type assignments as a Map<Long, List<Long>> of the types' ids (keys) and their root assignments (value List)

Returns:
returns the typeAssignments as a Map of Long ids

getGroupAssignmentIds

public java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> getGroupAssignmentIds()
Utility method returns the resulting group assignments as a Map<Long, List<Long>> of the groups' ids (keys) and their assigned children's ids (value List)

Returns:
returns the groupAssignments as a Map of Long ids