org.openbp.cockpit.generator
Class Generator

java.lang.Object
  extended by org.openbp.common.generic.description.DescriptionObjectImpl
      extended by org.openbp.common.generic.description.DisplayObjectImpl
          extended by org.openbp.cockpit.generator.Generator
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, Copyable, DescriptionObject, Displayable, DisplayObject, Validatable

public class Generator
extends DisplayObjectImpl
implements java.lang.Comparable

A template-based generation process for a particular item or item file. The generation process consists of
1. A check for the requirements of the generation (i. e. if particular item properties are set)
2. An option pre-processing step
3. The actual template-based generation
4. An option post-processing step

Author:
Heiko Erhardt
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.openbp.common.generic.Copyable
COPY_DEEP, COPY_FIRST_LEVEL, COPY_SHALLOW
 
Constructor Summary
Generator()
          Default constructor.
 
Method Summary
 void addCustomPage(GeneratorPageDescriptor customPage)
          Adds a custom page.
 void addInitialProperty(GeneratorProperty initialProperty)
          Adds an initial property.
 void addRequiredItemProperty(java.lang.String requiredItemProperty)
          Adds a required property.
 boolean checkPrecondition()
          Checks the preconditions of this generator.
 void checkRequirements(GeneratorContext context)
          Checks the requirements of the generation process for the current item.
 void clearCustomPages()
          Clears the custom page list.
 void clearRequiredItemPropertys()
          Clears the list of required properties of the item.
 int compareTo(java.lang.Object o)
          Compares this object to another object.
 void copyFrom(java.lang.Object source, int copyMode)
          Copies the values of the source object to this object.
 void copyInitialPropertiesToContext(GeneratorContext context)
          Copies the initial properties to the property table of the generator context.
protected  void createCustomizer()
          Creates a new instance of the customizer class if specified.
 void createSettings(GeneratorContext context)
          Creates a settings object for the customizer if it requires one.
 java.lang.ClassLoader getClassLoader()
          Gets the class loader used to load template and setting classes.
 java.lang.String getCondition()
          Gets the condition.
 GeneratorCustomizer getCustomizer()
          Gets the generator customizer class.
 java.util.List getCustomPageList()
          Gets the custom page list.
 java.util.Iterator getCustomPages()
          Gets the custom page list.
 java.lang.String getDefaultStartPageName()
          Gets the name of the default start page.
 java.lang.String getFunctionalGroup()
          Gets the a functional group specification that can be used as desired..
 java.lang.String getGeneratorCustomizerClassName()
          Gets the name of the process customizer class (must implement the GeneratorCustomizer interface).
 GeneratorMgr getGeneratorMgr()
          Gets the generator manager that loaded this generator.
 java.lang.String getItemType()
          Gets the item type this generation step is suitable for.
 java.util.List getRequiredItemPropertyList()
          Gets the list of required properties of the item.
 java.util.Iterator getRequiredItemPropertys()
          Gets the list of required properties of the item.
 int getSequenceNr()
          Gets the sequence number that determines the order of displayed generator options in the context menu.
 java.lang.String getTemplateName()
          Gets the name of the template class.
 XMLDriver getXmlDriver()
          Gets the xML driver for generator settings.
 int getXmlLoaderSequenceNr()
          Gets the sequence number that determines the load order for the setting and depandant XML files.
 boolean isItemGenerator()
          Gets the flag: Generator generators an item.
 boolean isShowOpenResultCheckBox()
          Gets the flag if the 'Open generated file' check box in the result page should be displayed.
 void loadSettings(GeneratorContext context)
          Loads the settings from persistent storage into the newly created settings object.
 void performProcess(GeneratorContext context)
          Performs the generation process.
 void postProcess(GeneratorContext context)
          Performs the generation post-process.
 void preProcess(GeneratorContext context)
          Performs the generation pre-processing.
 void removeInitialPropertiesToContext(GeneratorContext context)
          Removes the initial property values from the property table of the generator context.
 void runTemplateEngine(GeneratorContext context)
          Runs the template engine.
 void saveSettings(GeneratorContext context)
          Saves the settings from the settings object to persistent storage.
 void setClassLoader(java.lang.ClassLoader classLoader)
          Sets the class loader used to load template and setting classes.
 void setCondition(java.lang.String condition)
          Sets the condition.
 void setCustomPageList(java.util.List customPageList)
          Sets the custom page list.
 void setDefaultStartPageName(java.lang.String defaultStartPageName)
          Sets the name of the default start page.
 void setFunctionalGroup(java.lang.String functionalGroup)
          Sets the a functional group specification that can be used as desired..
 void setGeneratorCustomizerClassName(java.lang.String generatorCustomizerClassName)
          Sets the name of the process customizer class (must implement the GeneratorCustomizer interface).
 void setGeneratorMgr(GeneratorMgr generatorMgr)
          Sets the generator manager that loaded this generator.
 void setItemGenerator(boolean itemGenerator)
          Sets the flag: Generator generators an item.
 void setItemType(java.lang.String itemType)
          Sets the item type this generation step is suitable for.
 void setRequiredItemPropertyList(java.util.List requiredItemPropertyList)
          Sets the list of required properties of the item.
 void setSequenceNr(int sequenceNr)
          Sets the sequence number that determines the order of displayed generator options in the context menu.
 void setShowOpenResultCheckBox(boolean showOpenResultCheckBox)
          Sets the flag if the 'Open generated file' check box in the result page should be displayed.
 void setTemplateName(java.lang.String templateName)
          Sets the name of the template class.
 void setXmlDriver(XMLDriver xmlDriver)
          Sets the xML driver for generator settings.
 void setXmlLoaderSequenceNr(int xmlLoaderSequenceNr)
          Sets the sequence number that determines the load order for the setting and depandant XML files.
 
Methods inherited from class org.openbp.common.generic.description.DisplayObjectImpl
getDisplayName, getDisplayText, setDisplayName
 
Methods inherited from class org.openbp.common.generic.description.DescriptionObjectImpl
clone, getDescription, getDescriptionEscape, getDescriptionText, getName, setDescription, setDescriptionEscape, setName, toString, validate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openbp.common.generic.description.DescriptionObject
clone, getDescription, getDescriptionText, getName, setDescription, setName
 

Constructor Detail

Generator

public Generator()
Default constructor.

Method Detail

copyFrom

public void copyFrom(java.lang.Object source,
                     int copyMode)
              throws java.lang.CloneNotSupportedException
Copies the values of the source object to this object.

Specified by:
copyFrom in interface Copyable
Overrides:
copyFrom in class DisplayObjectImpl
Parameters:
source - The source object. Must be of the same type as this object.
copyMode - Determines if a deep copy, a first level copy or a shallow copy is to be performed. See the constants of the org.openbp.common.generic.description.Copyable class.
Throws:
java.lang.CloneNotSupportedException - If the cloning of one of the contained objects failed

preProcess

public void preProcess(GeneratorContext context)
                throws java.lang.Exception
Performs the generation pre-processing.

Parameters:
context - Generator context
Throws:
java.lang.Exception

performProcess

public void performProcess(GeneratorContext context)
                    throws java.lang.Exception
Performs the generation process.

Parameters:
context - Generator context
Throws:
java.lang.Exception

postProcess

public void postProcess(GeneratorContext context)
                 throws java.lang.Exception
Performs the generation post-process.

Parameters:
context - Generator context
Throws:
java.lang.Exception

runTemplateEngine

public void runTemplateEngine(GeneratorContext context)
                       throws java.lang.Exception
Runs the template engine.

Parameters:
context - Generator context
Throws:
java.lang.Exception

checkPrecondition

public boolean checkPrecondition()
Checks the preconditions of this generator.

Returns:
true: The preconditions are met, the generator can be displayed.
false: The generator should not appear in the list of generators.

checkRequirements

public void checkRequirements(GeneratorContext context)
Checks the requirements of the generation process for the current item.

Parameters:
context - Generator context
Throws:
GeneratorException - If one of the necessary requirements is not met. The exception message should describe the problem.

createSettings

public void createSettings(GeneratorContext context)
Creates a settings object for the customizer if it requires one.

Parameters:
context - Generator context

loadSettings

public void loadSettings(GeneratorContext context)
Loads the settings from persistent storage into the newly created settings object. Does nothing by default.

Parameters:
context - Generator context

saveSettings

public void saveSettings(GeneratorContext context)
Saves the settings from the settings object to persistent storage. Does nothing by default.

Parameters:
context - Generator context

getCustomizer

public GeneratorCustomizer getCustomizer()
Gets the generator customizer class.


createCustomizer

protected void createCustomizer()
Creates a new instance of the customizer class if specified.

Throws:
GeneratorException - On error

addInitialProperty

public void addInitialProperty(GeneratorProperty initialProperty)
Adds an initial property.

Parameters:
initialProperty - The initial property to add

copyInitialPropertiesToContext

public void copyInitialPropertiesToContext(GeneratorContext context)
Copies the initial properties to the property table of the generator context.

Parameters:
context - Generator context

removeInitialPropertiesToContext

public void removeInitialPropertiesToContext(GeneratorContext context)
Removes the initial property values from the property table of the generator context.

Parameters:
context - Generator context

getFunctionalGroup

public java.lang.String getFunctionalGroup()
Gets the a functional group specification that can be used as desired..


setFunctionalGroup

public void setFunctionalGroup(java.lang.String functionalGroup)
Sets the a functional group specification that can be used as desired..


isItemGenerator

public boolean isItemGenerator()
Gets the flag: Generator generators an item.


setItemGenerator

public void setItemGenerator(boolean itemGenerator)
Sets the flag: Generator generators an item.


getSequenceNr

public int getSequenceNr()
Gets the sequence number that determines the order of displayed generator options in the context menu.


setSequenceNr

public void setSequenceNr(int sequenceNr)
Sets the sequence number that determines the order of displayed generator options in the context menu.


getXmlLoaderSequenceNr

public int getXmlLoaderSequenceNr()
Gets the sequence number that determines the load order for the setting and depandant XML files.


setXmlLoaderSequenceNr

public void setXmlLoaderSequenceNr(int xmlLoaderSequenceNr)
Sets the sequence number that determines the load order for the setting and depandant XML files.


getItemType

public java.lang.String getItemType()
Gets the item type this generation step is suitable for.


setItemType

public void setItemType(java.lang.String itemType)
Sets the item type this generation step is suitable for.


getRequiredItemPropertys

public java.util.Iterator getRequiredItemPropertys()
Gets the list of required properties of the item.

Returns:
An iterator of String objects

addRequiredItemProperty

public void addRequiredItemProperty(java.lang.String requiredItemProperty)
Adds a required property.

Parameters:
requiredItemProperty - The required property to add

clearRequiredItemPropertys

public void clearRequiredItemPropertys()
Clears the list of required properties of the item.


getRequiredItemPropertyList

public java.util.List getRequiredItemPropertyList()
Gets the list of required properties of the item.

Returns:
A list of String objects

setRequiredItemPropertyList

public void setRequiredItemPropertyList(java.util.List requiredItemPropertyList)
Sets the list of required properties of the item.

Parameters:
requiredItemPropertyList - A list of String objects

getCondition

public java.lang.String getCondition()
Gets the condition.


setCondition

public void setCondition(java.lang.String condition)
Sets the condition.


getCustomPages

public java.util.Iterator getCustomPages()
Gets the custom page list.

Returns:
An iterator of GeneratorPageDescriptor objects

addCustomPage

public void addCustomPage(GeneratorPageDescriptor customPage)
Adds a custom page.

Parameters:
customPage - The custom page to add

clearCustomPages

public void clearCustomPages()
Clears the custom page list.


getCustomPageList

public java.util.List getCustomPageList()
Gets the custom page list.

Returns:
A list of GeneratorPageDescriptor objects

setCustomPageList

public void setCustomPageList(java.util.List customPageList)
Sets the custom page list.

Parameters:
customPageList - A list of GeneratorPageDescriptor objects

getTemplateName

public java.lang.String getTemplateName()
Gets the name of the template class.


setTemplateName

public void setTemplateName(java.lang.String templateName)
Sets the name of the template class.


getDefaultStartPageName

public java.lang.String getDefaultStartPageName()
Gets the name of the default start page. This page is displayed when an existing item is opened (needed for item generators only).


setDefaultStartPageName

public void setDefaultStartPageName(java.lang.String defaultStartPageName)
Sets the name of the default start page. This page is displayed when an existing item is opened (needed for item generators only).


isShowOpenResultCheckBox

public boolean isShowOpenResultCheckBox()
Gets the flag if the 'Open generated file' check box in the result page should be displayed.


setShowOpenResultCheckBox

public void setShowOpenResultCheckBox(boolean showOpenResultCheckBox)
Sets the flag if the 'Open generated file' check box in the result page should be displayed.


getGeneratorCustomizerClassName

public java.lang.String getGeneratorCustomizerClassName()
Gets the name of the process customizer class (must implement the GeneratorCustomizer interface).


setGeneratorCustomizerClassName

public void setGeneratorCustomizerClassName(java.lang.String generatorCustomizerClassName)
Sets the name of the process customizer class (must implement the GeneratorCustomizer interface).


getGeneratorMgr

public GeneratorMgr getGeneratorMgr()
Gets the generator manager that loaded this generator.


setGeneratorMgr

public void setGeneratorMgr(GeneratorMgr generatorMgr)
Sets the generator manager that loaded this generator.


getClassLoader

public java.lang.ClassLoader getClassLoader()
Gets the class loader used to load template and setting classes.


setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)
Sets the class loader used to load template and setting classes.


getXmlDriver

public XMLDriver getXmlDriver()
Gets the xML driver for generator settings.


setXmlDriver

public void setXmlDriver(XMLDriver xmlDriver)
Sets the xML driver for generator settings.


compareTo

public int compareTo(java.lang.Object o)
Compares this object to another object.

Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class DescriptionObjectImpl
Parameters:
o - Object to compare to
Returns:
see the java.lang.Comparable interface


Copyright © 2011. All Rights Reserved.