com.flexive.shared.scripting.groovy
Class GroovyScriptExporterTools

java.lang.Object
  extended by com.flexive.shared.scripting.groovy.GroovyScriptExporterTools

public final class GroovyScriptExporterTools
extends java.lang.Object

Tools and utilities for GroovyScriptExporter code generation

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

Nested Class Summary
(package private) static class GroovyScriptExporterTools.IgnoreTypes
          Enumeration of SYSTEM TYPES which can optionally be ignored
(package private) static class GroovyScriptExporterTools.Indent
           
 
Field Summary
(package private) static java.lang.String DELHEADER
           
(package private) static java.lang.String DEPHEADER
           
(package private) static java.lang.String[] GROOVY_KEYWORDS
           
(package private) static java.lang.StringBuilder GROOVYPACKAGEIMPORTS
           
(package private) static java.lang.String[] JAVA_KEYWORDS
           
static org.apache.commons.logging.Log LOG
           
(package private) static java.lang.String SCRIPTASSHEADER
           
(package private) static java.lang.String SCRIPTHEADER
           
(package private) static java.lang.String STRUCTHEADER
           
 
Method Summary
static java.lang.String createChildAssignments(java.util.List<FxAssignment> childAssignments, java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments, boolean defaultsOnly, java.util.List<FxGroupAssignment> callOnlyGroups, int tabCount, boolean withoutDependencies, java.util.List<java.lang.Long> differingDerivedAssignments)
          This method is used to "route" the given child assignments to their respective evaluation methods The method's first call comes from #generateTypeAssignments" This method is subsequently called from #createGroup
static java.lang.String createDeleteCode(java.util.List<FxType> types)
          Generate code to delete ALL content instances for the given types, their assignments and the types themselves
static java.lang.String createGroup(FxGroupAssignment ga, java.util.List<FxAssignment> childAssignments, java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments, boolean isDerived, boolean defaultsOnly, java.util.List<FxGroupAssignment> callOnlyGroups, int tabCount, boolean withoutDependencies, java.util.List<java.lang.Long> differingDerivedAssignments)
          Write the script code to create a group
static java.lang.String createProperty(FxPropertyAssignment pa, boolean defaultsOnly, int tabCount, boolean withoutDependencies, java.util.List<java.lang.Long> differingDerivedAssignments)
          Write the script code to create a property from a given FxPropertyAssignment
static java.lang.String createScriptAssignments(java.util.Map<java.lang.Long,java.util.Map<java.lang.String,java.util.List<java.lang.Long>>> typeScriptMapping, java.util.Map<java.lang.Long,java.util.Map<java.lang.String,java.util.List<java.lang.Long>>> assignmentScriptMapping, boolean scriptOverride)
          Generate code for the script assignment mappings
static java.lang.String createType(FxType type, boolean defaultsOnly, boolean addWorkflow)
          This method generates the script code for a type
static java.lang.String createTypeAssignments(FxType type, java.util.List<FxAssignment> assignments, java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments, boolean defaultsOnly, java.util.List<FxGroupAssignment> callOnlyGroups, boolean withoutDependencies, java.util.List<java.lang.Long> differingDerivedAssignments)
          Contains the logic to generate the script code for a type's assignments
static boolean isSystemType(java.lang.String typeName)
          Iterates throught the enum IgnoreTypes
static java.lang.String updateGroupAssignment(FxGroupAssignment ga, boolean isDerived, java.util.List<java.lang.String> differences, boolean defaultsOnly, int tabCount, boolean withoutDependencies, java.util.List<java.lang.Long> differingDerivedAssignments)
          Write the script code to create a group assignment
static java.lang.String updatePropertyAssignment(FxPropertyAssignment pa, boolean isDerived, java.util.List<java.lang.String> differences, boolean defaultsOnly, int tabCount, boolean withoutDependencies, java.util.List<java.lang.Long> differingDerivedAssignments)
          Write the script code to update a property assignment, or to create a derived assignment

"acl", "defaultValue", "hint", "label", "multilang", "multiline", "multiplicity"

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROOVYPACKAGEIMPORTS

static final java.lang.StringBuilder GROOVYPACKAGEIMPORTS

SCRIPTHEADER

static final java.lang.String SCRIPTHEADER
See Also:
Constant Field Values

STRUCTHEADER

static final java.lang.String STRUCTHEADER
See Also:
Constant Field Values

DEPHEADER

static final java.lang.String DEPHEADER
See Also:
Constant Field Values

DELHEADER

static final java.lang.String DELHEADER
See Also:
Constant Field Values

SCRIPTASSHEADER

static final java.lang.String SCRIPTASSHEADER
See Also:
Constant Field Values

LOG

public static final org.apache.commons.logging.Log LOG

JAVA_KEYWORDS

static final java.lang.String[] JAVA_KEYWORDS

GROOVY_KEYWORDS

static final java.lang.String[] GROOVY_KEYWORDS
Method Detail

isSystemType

public static boolean isSystemType(java.lang.String typeName)
Iterates throught the enum IgnoreTypes

Parameters:
typeName - the type's name
Returns:
returns true if the type is a system type

createType

public static java.lang.String createType(FxType type,
                                          boolean defaultsOnly,
                                          boolean addWorkflow)
This method generates the script code for a type

Parameters:
type - the FxType which should be exported
defaultsOnly - use defaults only, do not analyse / script options
addWorkflow - add the type's current workflow to the code
Returns:
String returns the script code for a type

createTypeAssignments

public static java.lang.String createTypeAssignments(FxType type,
                                                     java.util.List<FxAssignment> assignments,
                                                     java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments,
                                                     boolean defaultsOnly,
                                                     java.util.List<FxGroupAssignment> callOnlyGroups,
                                                     boolean withoutDependencies,
                                                     java.util.List<java.lang.Long> differingDerivedAssignments)
Contains the logic to generate the script code for a type's assignments

Parameters:
type - a given type
assignments - a List of the given types immediate assignments
groupAssignments - the Map of GroupAssignments (keys) and their child assignments (List of values)
defaultsOnly - only use the defaults provided by the GroovyTypeBuilder
callOnlyGroups - a List of FxGroupAssignments for which no options should be generated
withoutDependencies - true of assignment:xpath statements should not be generated
differingDerivedAssignments - the List of assignment ids for derived assignments differing from their base assignments
Returns:
the script code

createProperty

public static java.lang.String createProperty(FxPropertyAssignment pa,
                                              boolean defaultsOnly,
                                              int tabCount,
                                              boolean withoutDependencies,
                                              java.util.List<java.lang.Long> differingDerivedAssignments)
Write the script code to create a property from a given FxPropertyAssignment

Parameters:
pa - the FxPropertyAssignment to be scripted
defaultsOnly - use only default settings provided by the GTB, no analysis of assignments will be performed
tabCount - the number of tabs to be added to the code's left hand side
withoutDependencies - true = do not create assignment:xpath code
differingDerivedAssignments - the List of assignment ids for derived assignments differing from their base assignments
Returns:
returns the partial script as a StringBuilder instance

updatePropertyAssignment

public static java.lang.String updatePropertyAssignment(FxPropertyAssignment pa,
                                                        boolean isDerived,
                                                        java.util.List<java.lang.String> differences,
                                                        boolean defaultsOnly,
                                                        int tabCount,
                                                        boolean withoutDependencies,
                                                        java.util.List<java.lang.Long> differingDerivedAssignments)
Write the script code to update a property assignment, or to create a derived assignment

"acl", "defaultValue", "hint", "label", "multilang", "multiline", "multiplicity"

Parameters:
pa - the FxPropertyAssignment to be updated
isDerived - the Assignment is derived
differences - the List of differences (map keys f. the builder)
defaultsOnly - use only default settings provided by the GTB, no analysis of assignments will be performed
tabCount - the number of tabs to be added to the code's left hand side
withoutDependencies - true = do not create assignment:xPath code
differingDerivedAssignments - the List of assignment ids for derived assignments differing from their base assignments
Returns:
returns the partial script as a StringBuilder instance

createGroup

public static java.lang.String createGroup(FxGroupAssignment ga,
                                           java.util.List<FxAssignment> childAssignments,
                                           java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments,
                                           boolean isDerived,
                                           boolean defaultsOnly,
                                           java.util.List<FxGroupAssignment> callOnlyGroups,
                                           int tabCount,
                                           boolean withoutDependencies,
                                           java.util.List<java.lang.Long> differingDerivedAssignments)
Write the script code to create a group

Parameters:
ga - the FxGroupAssignment to be scripted
childAssignments - a List of child assignments for the given group
groupAssignments - the map of FxGroupAssignments (keys) and their respective Lists of FxAssignments (values)
isDerived - set to "true" if the assignment to be written is derived from another property
defaultsOnly - use only default settings provided by the GTB, no analysis of assignments will be performed
callOnlyGroups - a List of FxGroupAssignments for which no options should be generated
tabCount - the number of tabs to be added to the code's left hand side
withoutDependencies - true = do not create assignment:xpath code
differingDerivedAssignments - the List of assignment ids for derived assignments differing from their base assignments
Returns:
returns the partial script as a String

updateGroupAssignment

public static java.lang.String updateGroupAssignment(FxGroupAssignment ga,
                                                     boolean isDerived,
                                                     java.util.List<java.lang.String> differences,
                                                     boolean defaultsOnly,
                                                     int tabCount,
                                                     boolean withoutDependencies,
                                                     java.util.List<java.lang.Long> differingDerivedAssignments)
Write the script code to create a group assignment

Parameters:
ga - the FxGroupAssignment to be scripted
isDerived - the Assignment is derived
differences - the List of differences (map keys f. the builder)
defaultsOnly - use only default settings provided by the GTB, no analysis of assignments will be performed
tabCount - the number of tabs to be added to the code's left hand side
withoutDependencies - true = do not create assignment:xpath code
differingDerivedAssignments - the List of assignment ids for derived assignments differing from their base assignments
Returns:
returns the partial script as a String

createChildAssignments

public static java.lang.String createChildAssignments(java.util.List<FxAssignment> childAssignments,
                                                      java.util.Map<FxGroupAssignment,java.util.List<FxAssignment>> groupAssignments,
                                                      boolean defaultsOnly,
                                                      java.util.List<FxGroupAssignment> callOnlyGroups,
                                                      int tabCount,
                                                      boolean withoutDependencies,
                                                      java.util.List<java.lang.Long> differingDerivedAssignments)
This method is used to "route" the given child assignments to their respective evaluation methods The method's first call comes from #generateTypeAssignments" This method is subsequently called from #createGroup

Parameters:
childAssignments - the List of FxAssignments (children of a given group)
groupAssignments - the map of FxGroupAssignments (keys) and their respective Lists of FxAssignments (values)
defaultsOnly - use only default settings provided by the GTB, no analysis of assignments will be performed
callOnlyGroups - a List of FxGroupAssignments for which no options should be generated
tabCount - the number of tabs to be added to the code's left hand side
withoutDependencies - true = do not create assignment:xpath code
differingDerivedAssignments - the List of assignment ids for derived assignments differing from their base assignments
Returns:
returns the script code or an empty String if the childassigments list is empty

createDeleteCode

public static java.lang.String createDeleteCode(java.util.List<FxType> types)
Generate code to delete ALL content instances for the given types, their assignments and the types themselves

Parameters:
types - the input List of FxTypes t.b. deleted
Returns:
the script code as a String

createScriptAssignments

public static java.lang.String createScriptAssignments(java.util.Map<java.lang.Long,java.util.Map<java.lang.String,java.util.List<java.lang.Long>>> typeScriptMapping,
                                                       java.util.Map<java.lang.Long,java.util.Map<java.lang.String,java.util.List<java.lang.Long>>> assignmentScriptMapping,
                                                       boolean scriptOverride)
Generate code for the script assignment mappings

Parameters:
typeScriptMapping - the type script mapping from the StructureExporterCallback
assignmentScriptMapping - the assignment script mapping from the StructureExporterCallback
scriptOverride - set to true to generate script override code (overwrite script if it exists)
Returns:
returns the Groovy code as a String