org.openbp.cockpit.generator
Class GeneratorCustomizer

java.lang.Object
  extended by org.openbp.cockpit.generator.GeneratorCustomizer
Direct Known Subclasses:
ActivityCustomizer, ProcessCustomizer, TypeCustomizer

public abstract class GeneratorCustomizer
extends java.lang.Object

Customizer class used to customize a template generation process described by the Generator class. The customizer class can access the item the generation process is to be performed upon using the context.getItem() method. It may also add or modify generation properties (see GeneratorContext.setProperty(java.lang.String, java.lang.Object)) that will be used as property table for the template-based generation process.

Author:
Heiko Erhardt

Constructor Summary
GeneratorCustomizer()
          Default constructor.
 
Method Summary
 void afterPageSequenceUpdate(GeneratorContext context, GeneratorWizard wizard)
          Template method that is called after the page sequence has been updated.
 void beforePageSequenceUpdate(GeneratorContext context, GeneratorWizard wizard)
          Template method that is called before the page sequence has been updated.
 void checkRequirements(GeneratorContext context)
          This method is executed after the generation process has been selected in order to check any conditions that need to be fullfilled for the process to work.
 java.lang.Object createSettings(GeneratorContext context)
          Creates a settings object for this customizer if it requires one.
 java.lang.String determineUniqueSuffix(Item item, java.lang.String name)
          Determines a unique suffix for the given name that will make the item name unique.
 java.lang.String evaluateFormat(GeneratorContext context, java.lang.String format)
          Evaluates a format descrition.
 java.lang.Class[] getDependentSettingsClasses()
          Returns the class of any dependent objects of the generator settings class that must be serialized to the generator info of an edited item.
 Generator getGenerator()
          Gets the generator that owns this customizer instance.
 java.lang.Class getSettingsClass()
          Returns the class of the generator settings used by this generator.
 java.lang.String getTemplateName(GeneratorContext context)
          Gets template name.
 boolean hasResultPage(GeneratorContext context)
          Determines if the generator should display a result page.
 void loadSettings(GeneratorContext context)
          Loads the settings from persistent storage into the newly created settings object.
 void performProcess(GeneratorContext context)
          Main processing step.
 void postProcess(GeneratorContext context)
          Post-process step that is executed after the actual generation step.
 void preProcess(GeneratorContext context)
          Pre-process step that is executed before the actual generation step.
 void processWizardEvent(GeneratorContext context, WizardEvent event)
          Processes a wizard event caused by a generator wizard page.
 void saveSettings(GeneratorContext context)
          Saves the settings from the settings object to persistent storage.
 void setGenerator(Generator generator)
          Sets the generator that owns this customizer instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneratorCustomizer

public GeneratorCustomizer()
Default constructor.

Method Detail

createSettings

public java.lang.Object createSettings(GeneratorContext context)
Creates a settings object for this customizer if it requires one.

Parameters:
context - Generator context
Returns:
The new settings object or null if a settings class is not defined by the customizer

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

getSettingsClass

public java.lang.Class getSettingsClass()
Returns the class of the generator settings used by this generator.

Returns:
The class or null if the generator does not require a settings object
The default implementation returns null.

getDependentSettingsClasses

public java.lang.Class[] getDependentSettingsClasses()
Returns the class of any dependent objects of the generator settings class that must be serialized to the generator info of an edited item.

Returns:
An array of classes or null if there are not dependent classes.
The default implementation returns null.

getTemplateName

public java.lang.String getTemplateName(GeneratorContext context)
Gets template name.

Parameters:
context - Generator context
Returns:
By default, the method returns the template name read from the generator XML file

hasResultPage

public boolean hasResultPage(GeneratorContext context)
Determines if the generator should display a result page.

Parameters:
context - Generator context
Returns:
true by default

checkRequirements

public void checkRequirements(GeneratorContext context)
This method is executed after the generation process has been selected in order to check any conditions that need to be fullfilled for the process to work. The method will throw an exception describing the error if a precondition is not met. This method can also be used to initialize generator properties.

Parameters:
context - Generator context
Throws:
GeneratorException - On error

beforePageSequenceUpdate

public void beforePageSequenceUpdate(GeneratorContext context,
                                     GeneratorWizard wizard)
Template method that is called before the page sequence has been updated.

Parameters:
context - Context
wizard - Generator wizard

afterPageSequenceUpdate

public void afterPageSequenceUpdate(GeneratorContext context,
                                    GeneratorWizard wizard)
Template method that is called after the page sequence has been updated.

Parameters:
context - Context
wizard - Generator wizard

preProcess

public void preProcess(GeneratorContext context)
                throws java.lang.Exception
Pre-process step that is executed before the actual generation step. The default implementation runs the template engine.

Parameters:
context - Generator context
Throws:
GeneratorException - On error
java.lang.Exception

performProcess

public void performProcess(GeneratorContext context)
                    throws java.lang.Exception
Main processing step.

Parameters:
context - Generator context
Throws:
GeneratorException - On error
java.lang.Exception

postProcess

public void postProcess(GeneratorContext context)
                 throws java.lang.Exception
Post-process step that is executed after the actual generation step.

Parameters:
context - Generator context
Throws:
GeneratorException - On error
java.lang.Exception

processWizardEvent

public void processWizardEvent(GeneratorContext context,
                               WizardEvent event)
Processes a wizard event caused by a generator wizard page.

Parameters:
context - Generator context
event - Event to handle

getGenerator

public Generator getGenerator()
Gets the generator that owns this customizer instance.


setGenerator

public void setGenerator(Generator generator)
Sets the generator that owns this customizer instance.


evaluateFormat

public java.lang.String evaluateFormat(GeneratorContext context,
                                       java.lang.String format)
Evaluates a format descrition.

Parameters:
format - Format
The format consists of arbitrary text, which may contain "$identifier$" placeholders. These placeholders will be substituted against generator properties. If the property does not exist, nothing will be inserted.
context - Generator context
Returns:
The evaluated string or null if the format is null, the trimmed result of the evaluation is empty or if a placeholder doesn't exist.

determineUniqueSuffix

public java.lang.String determineUniqueSuffix(Item item,
                                              java.lang.String name)
Determines a unique suffix for the given name that will make the item name unique.

Parameters:
item - Item to generate a name for
name - Name to use as base for the new name
Returns:
The suffix ("1", "2", ... according to names like "name", "name2", ...) or null if the supplied name is already unique


Copyright © 2011. All Rights Reserved.