com.flexive.shared.structure.export
Class GenericStructureExporter

java.lang.Object
  extended by com.flexive.shared.structure.export.GenericStructureExporter

public class GenericStructureExporter
extends java.lang.Object

Walks through a type's properties and groups (and its dependent types and groups) and pushes the results to StructureExporter.
This Generic Class should never be called directly but rather through the StructureExporterCallback interface / StructureExporter

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

Nested Class Summary
(package private) static class GenericStructureExporter.DependencyAnalyser
          A class to analyse (circular / mutual) dependencies and derived assignments of types i.e.
 
Field Summary
protected  java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments
           
protected  boolean ignoreAssignmentDependencies
           
protected  FxType type
           
protected  java.util.Map<FxType,java.util.List<FxAssignment>> typeAssignments
           
protected  long typeId
           
protected  java.util.List<FxAssignment> whiteList
           
protected  boolean whiteListPresent
           
 
Method Summary
protected  java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> getGroupAssignments(FxGroupAssignment currentGroup, java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments)
          Recursive walks through a group's assignments and sub-assignments
protected  java.util.List<FxAssignment> getTypeAssignments(FxType type)
          Retrieve all of a type's assignments, check whether they should be ignored (enum IgnoreProps in GenericStructureExporterTools) and also check that they are not in a whitelist if one is present.
protected static GenericStructureExporter newInstance(StructureExporterCallback callback, long typeId, boolean ignoreDependencies)
          Returns an instance of the GenericStructureExporter ignoreDependencies switch: if set to "true" it will ignore any dependencies on other types / properties, i.e.
protected static GenericStructureExporter newInstance(StructureExporterCallback callback, long typeId, boolean ignoreDependencies, java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> dependencies, java.util.concurrent.ConcurrentMap<java.lang.Long,java.lang.Boolean> typesChecked, java.util.Map<FxType,java.util.List<FxAssignment>> typeAssignments, java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments, java.util.Map<java.lang.Long,java.lang.Long> dependentOnMapping)
          Returns an instance of the GenericStructureExporter ignoreList: a List of (derived) properties which should be ignored when creating the script.
protected static GenericStructureExporter newInstance(StructureExporter callback, long typeId, java.util.List<FxAssignment> whiteList)
          Returns an instance of the GenericStructureExporter for examination of whiteLists (= i.e.
protected  void populateTypeAssignments(FxType newType, java.util.List<FxAssignment> newList)
          This method maintains the correct order of keys in the LinkedHashMap typeAssignments on recursive calls, i.e.
 void run()
          This (management) method walks through a type's assignments (and, if set, through dependent types' assignments)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typeId

protected long typeId

type

protected FxType type

ignoreAssignmentDependencies

protected boolean ignoreAssignmentDependencies

whiteList

protected java.util.List<FxAssignment> whiteList

whiteListPresent

protected boolean whiteListPresent

typeAssignments

protected java.util.Map<FxType,java.util.List<FxAssignment>> typeAssignments

groupAssignments

protected java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments
Method Detail

newInstance

protected static GenericStructureExporter newInstance(StructureExporterCallback callback,
                                                      long typeId,
                                                      boolean ignoreDependencies)
Returns an instance of the GenericStructureExporter ignoreDependencies switch: if set to "true" it will ignore any dependencies on other types / properties, i.e. such properties will be exported as "assignment:" If set to "false", the reused types / properties etc. will be exported as well

Parameters:
callback - the callback interface
typeId - the id of the type to be exported
ignoreDependencies - whether dependencies on other types should be ignored
Returns:
returns an instance of the GenericStructureExporter

newInstance

protected static GenericStructureExporter newInstance(StructureExporterCallback callback,
                                                      long typeId,
                                                      boolean ignoreDependencies,
                                                      java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> dependencies,
                                                      java.util.concurrent.ConcurrentMap<java.lang.Long,java.lang.Boolean> typesChecked,
                                                      java.util.Map<FxType,java.util.List<FxAssignment>> typeAssignments,
                                                      java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments,
                                                      java.util.Map<java.lang.Long,java.lang.Long> dependentOnMapping)
Returns an instance of the GenericStructureExporter ignoreList: a List of (derived) properties which should be ignored when creating the script. Note: this affects derived properties / groups only (in the case of mutual dependencies)!

Parameters:
callback - the callback interface
typeId - the type's id
ignoreDependencies - whether dependencies on other types should be ignored
dependencies - a Map of typeIds --> FxAssignment ids which will be ignored when creating the script (dependent on other types / assignments)
typesChecked - a Map of typeIds --> boolean values = types for which dependencies exist & were scripted already
typeAssignments - the Map of FxTypes and their root assignments
groupAssignments - the Map of GroupAssignments --> FxAssignments (for recursive calls)
dependentOnMapping - the Map if assignment ids (keys) and the assignments' ids they depend on (values)
Returns:
returns an instance of the GenericStructureExporter

newInstance

protected static GenericStructureExporter newInstance(StructureExporter callback,
                                                      long typeId,
                                                      java.util.List<FxAssignment> whiteList)
Returns an instance of the GenericStructureExporter for examination of whiteLists (= i.e. exclusive List of FxAssignments for a given type). This call is very similar to a construction call providing the typeId and the ignoreDependencies flag only, except that it solely inspects the assignments given in the whitelist (for the given type) and automatically ignores any dependencies (it is assumed that the whiteList is the result of a previous mutual dependency analysis).

Parameters:
callback - the callback interface
typeId - the type's id
whiteList - the List of FxAssignments for which a script will be generated (all others are ignored)
Returns:
returns an instance of the GenericStructureExporter

run

public void run()
This (management) method walks through a type's assignments (and, if set, through dependent types' assignments)


populateTypeAssignments

protected void populateTypeAssignments(FxType newType,
                                       java.util.List<FxAssignment> newList)
This method maintains the correct order of keys in the LinkedHashMap typeAssignments on recursive calls, i.e. makes sure that the relevant element is prepended to the Map

Parameters:
newType - a new Map key which must be prepended
newList - a new value for the given key

getTypeAssignments

protected java.util.List<FxAssignment> getTypeAssignments(FxType type)
Retrieve all of a type's assignments, check whether they should be ignored (enum IgnoreProps in GenericStructureExporterTools) and also check that they are not in a whitelist if one is present.

Parameters:
type - the FxType
Returns:
returns a List of containing all Root assignments for a given FxType

getGroupAssignments

protected java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> getGroupAssignments(FxGroupAssignment currentGroup,
                                                                                            java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments)
Recursive walks through a group's assignments and sub-assignments

Parameters:
currentGroup - the current FxGroupAssignment to be examined
groupAssignments - a Map of FxGroupAssignments(keys) and FxAssignments (values as List)
Returns:
returns a Map FxGroupAssignment, List FxAssignment containing all groups and their respective child assignments