com.flexive.shared.structure.export
Interface StructureExporterCallback

All Known Implementing Classes:
StructureExporter

public interface StructureExporterCallback

Generate a flattened export hierarchy for a given type ant its assignments and (optionally) any other types / assignments which the given type depends on.

Usage Description (incl. sample code):
Initialise a StructureExporter:

StructureExporterCallback sec = StructureExporter.newInstance(typeId, ignoreDependencies);


If ignoreDependencies = true, only the given type's assignments will be exported ignoring any FxAssignments which are derived from another type.
If ignoreDependencies = false, the given type's assignments and all structures which the current type depends on will be available for export.

Retrieve all types and their immediate assignments as a Map of <FxType, List<FxAssignment>>:
Map<FxType, List<FxAssignment>> typeAssignments = exp.getTypeAssignments(); 

Important!
The #getTypeAssignments() returns a LinkedHashMap. The order of the given keys can / should be used as for re-creating structures from a given export. However, types with several circular dependencies might yield different type orders, depending on the type which is used as the "starting point" for the export. Since all derived FxAssignments will be found in the dependency structure, it is only of importance to use first the type assignments and only then the outcome of
#getDependencyStructures

Given a Map having keys (FxTypes) A, B, C (#keySet()), the order of structure creation must be A, B, C as well in order to maintain integrity between referring type assignments.
This means, that any assignments retrieved from
#getDependencyStructures()
must also be created in this order.

Retrieve all FxGroupAssignments and their Child Assignments as a Map of <FxGroupAssignment, List<FxAssignment>>:
 Map<FxGroupAssignment, List<FxAssignment>> groupAssignments = exp.getGroupAssignments(); 
Any Groups which are child assignments to a given group will be a key in the given map.
Any Groups having empty Lists as values, either have no child assignments OR their child assignments are dependent on other structures and will be available by a call to
getDependencyStructures();
given that
getHasDependencies();
returns true.

Check whether dependencies for the given export type exist:
sec.getHasDependencies();
This will return true IFF ignoreDependencies=false && dependencies on other structures were found.

Optional:
Retrieve all dependencies, i.e. all Types and their (flattened) FxAssignments as a Map of <FxType, List<FxAssignment>>:
Note: the Map will return null if
getHasDependencies() == false
Map<FxType, List<FxAssignment>> dependencies = exp.getDependencies();


Retrieve a structure of dependencies, i.e. a representation of all types and their respective assignments for all types / assignments which the current type depends on:
List<StructureExporterCallback> mutualDepStructure = sec.getDependencyStructures();
 for (StructureExporterCallback callback : mutualDepStruct) {
      typeAssignments = callback.getTypeAssignments(); // reassign
      groupAssignments = callback.getGroupAssignments();
      // ... do stuff here ...
 }
 


Usage summary
Obtain a StructureExporter instance:
StructureExporter.newInstance(typeId, ignoreDependencies);
Retrieve the various immediate type assignments ...
#getTypeAssignments();
... and any given group assignments
#getGroupAssignments();
If dependencies are found (unless ignored initially) walk through the dependency structure ...
 if(#getHasDependencies()) {
      #getDependencyStructures();
... and add the various derived assignments ([circular] dependencies) to the exported types.
    // Do stuff here //
 }

Additional methods are provided to
- access scripts assigned to type events
- access script attached to assignment events

Author:
Christopher Blasnik (c.blasnik@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)

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<FxGroupAssignment,java.util.List<FxAssignment>> getGroupAssignments()
          Returns all groups and their respective child assignments.
 boolean getHasDependencies()
           
 boolean getIsMultipleTypeCall()
           
 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()
           
 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.
 

Method Detail

getTypeId

long getTypeId()
Returns:
returns the initial typeId

setDependencies

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

Parameters:
dependencies - Map<Long, List<Long>> of mutual dependencies

getDependencies

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)

Returns:
returns the Map<FxType, List<FxAssignment>> of (mutual) dependencies
Throws:
FxApplicationException - on errors

setTypeAssignments

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

Parameters:
typeAssignments - the Map<FxType>, List<FxAssignment>>

setGroupAssignments

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

Parameters:
groupAssignments - Map<FxGroupAssignment, List<FxAssignment>>

getDependencyStructures

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

Returns:
returns an instance of StructureExporterCallback
Throws:
FxInvalidStateException - on errors

getTypeAssignments

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

Returns:
returns Map<FxType, List<FxAssignment>>

getGroupAssignments

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.

Returns:
returns Map<FxGroupAssignment>, List<FxAssignment>>

getHasDependencies

boolean getHasDependencies()
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

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

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

getIsMultipleTypeCall

boolean getIsMultipleTypeCall()
Returns:
Returns true if the call was made for multiple types

getTypeIds

java.util.List<java.lang.Long> getTypeIds()
Returns:
returns the List of initial typeIds

setDependentOnMapping

void setDependentOnMapping(java.util.Map<java.lang.Long,java.lang.Long> dependentOnMapping)
Parameters:
dependentOnMapping - set the Map of assignment ids dependent on other assignments

getDependentOnMapping

java.util.Map<java.lang.Long,java.lang.Long> getDependentOnMapping()
Returns:
returns the Map of assignment ids (keys) which are derived (dependent on) other assignments (values - ids)

getTypeScriptMapping

java.util.Map<java.lang.Long,java.util.Map<java.lang.String,java.util.List<java.lang.Long>>> getTypeScriptMapping()
Returns:
Returns the script mappings for each type: type id (key) --> event (key) --> script ids (value List)

getAssignmentScriptMapping

java.util.Map<java.lang.Long,java.util.Map<java.lang.String,java.util.List<java.lang.Long>>> getAssignmentScriptMapping()
Returns:
Returns the script mappings for each assignment: assignment id (key) --> event (key) --> script ids (value List)

getDifferingDerivedAssignments

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!

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