pt.digitalis.dif.codegen.templates
Class StageInstanceCGTemplate

java.lang.Object
  extended by pt.digitalis.dif.codegen.templates.StageInstanceCGTemplate
All Implemented Interfaces:
ICallback, IEntity, IMessage, IRegistrable, IStage, IStageInstance

public class StageInstanceCGTemplate
extends Object
implements IStageInstance

This class is a template for the IStageInstance interface method implementations. The CodeGen will copy these methods to a new Instance class for each stage. Some methods will be copied "as is", others will be tweaked.

Author:
Pedro Viegas pviegas@digitalis.pt, Rodrigo Gonçalves rgoncalves@digitalis.pt
Created on:
2007/07/12

Constructor Summary
StageInstanceCGTemplate()
           
 
Method Summary
 void __Stage__InjectedAttributesInitMethod__(IDIFContext difContext)
          This method will be used by the code gen module to set the annotated attributes.
 void __Stage__PostProcessingMethod__(IDIFContext difContext)
          This method will be used by the framework to do some post processing work.
 ViewObject _CG_execute(IDIFContext context)
          The business logic executing method.
 boolean _CG_finalize(IDIFContext context)
          The finalization method.
 boolean _CG_init(IDIFContext context)
          The initialization method.
 Object callEventMethod(IDIFContext context, EventType type, String eventName)
          The method that will be enhanced with the call to the correct event method.
 ViewObject callExecuteMethod(IDIFContext context)
          The method that will be enhanced with the call to the method annotated with @Execute.
 ViewObject callExecuteOnEventMethod(IDIFContext context, EventType type, String eventName)
          The method that will be enhanced with the call to the method annotated with @Execute.
protected  boolean callFinalizeMethod(IDIFContext context)
          The method that will be enhanced with the call to the method annotated with @Finalize.
protected  void callInitCustomParametersMethod(IParameters parameters)
          The method that will be enhanced with the users custom parameters (call to the method annotated with @CustomParameters.
protected  boolean callInitMethod(IDIFContext context)
          The method that will be enhanced with the call to the method annotated with @DIFInitializer.
protected  ViewObject createView(String engine, String type, String target, boolean isDefault)
          Creates a new view object.
 void declareFeatureActive(String featureID)
          Declares for the current stage instance that a given feature is enabled
 ControllerException getAuthenticationError()
          Gets the authentication error after an initialization has occurred
 CallbackType getCallbackType()
          Returns the Entity's callback type.
 IDIFContext getContext()
          Returns the execution context.
 IStage getDefaultErrorStage()
          The default error stage is constant and common to all instances and as such can be placed on the _CG_proxy.
 ViewObject getDefaultErrorView()
          The default error view is constant and common to all instances and as such can be placed on the _CG_proxy.
 ViewObject getDefaultView()
          The default view is constant and common to all instances and as such can be placed on the _CG_proxy.
 Map<EventType,List<String>> getEventHandlers()
          Returns the list of all the Stages submit handlers.
 String getID()
          The ID is constant and common to all instances and as such can be placed on the _CG_proxy.
 Map<String,String> getInjectedErrorStages()
          Returns the list of all the error Stages injected in this Stage.
 Map<String,ViewObject> getInjectedErrorViews()
          Returns the list of all the error views injected in this Stage.
 List<String> getInjectedStages()
          The injected stages are constant and common to all instances and as such can be placed on the _CG_proxy.
 List<ViewObject> getInjectedViews()
          The injected views are constant and common to all instances and as such can be placed on the _CG_proxy.
 IStageInstance getInstance()
          Return an instance of the stage for execution
 LicenseEditionType getLicenseEdition()
          Get the License Edition.
 String getMessage(String messageID)
          Returns a message associated with a given ID
 String getMessageForLanguage(String language, String messageID)
          Returns a message associated with a given ID
 Map<String,String> getMessages()
          Returns all messages associated with the Entity.
 Map<String,String> getMessagesForLanguage(String language)
          Returns all messages associated with the Entity.
 String getName()
          The name is constant and common to all instances and as such can be placed on the _CG_proxy.
 String getOriginalClassName()
          Returns the original entity class name
 String getOverridesStageID()
           
 ParameterErrors getParameterErrors()
          Gets the parameter errors after a initialization has occurred
 IParameters getParameters()
          Returns the parameters for the current stage
 IService getService()
          The service is constant and common to all instances and as such can be placed on the _CG_proxy.
 String getStageInstanceClassName()
          Obtains the original stage class name
protected  TemplateResources getTemplateResources()
          For usage of the CG methods
 String getUID()
          Returns the entity's unique ID.
 boolean hasAuthentication()
          Defines if the stage has authentication.
 boolean hasAuthenticationErrorInjection()
          Registers if the stage has injected the authentication errors.
 boolean hasAuthorization()
          Defines if the stage has authorization.
 boolean hasCallbackEnabled()
          Returns information about the Entity's callback state.
 boolean hasInjectedContributions()
           
 boolean hasParameterErrorInjection()
          Registers if the stage has injected the parameter errors.
 boolean hasValidationLogicForForm(String formName)
          Checks if the current form has a validation logic handler for the given form
 boolean isFeatureEnabled(String featureID)
          Validates if a given feature is active/present
 boolean isInitialized()
           
 boolean isRegistered()
          Returns information about if the Entity is registered.
 boolean isRegistrable()
          Returns information about if the Entity can be registered.
 boolean register(String name, String key)
          Registers the Entity with a given key.
 void setAuthenticationError(ControllerException exception)
          Sets the authentication error
 void setContext(IDIFContext newContext)
          Sets the execution context on the Stage.
 void setParameterErrors(ParameterErrors errors)
          Sets the parameter errors
 void setProxy(IStage _CG_proxy)
          Sets the associated proxy to call info upon
 void unregister()
          Unregisters the Entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StageInstanceCGTemplate

public StageInstanceCGTemplate()
Method Detail

__Stage__InjectedAttributesInitMethod__

public void __Stage__InjectedAttributesInitMethod__(IDIFContext difContext)
This method will be used by the code gen module to set the annotated attributes.

Parameters:
difContext - the context

__Stage__PostProcessingMethod__

public void __Stage__PostProcessingMethod__(IDIFContext difContext)
This method will be used by the framework to do some post processing work.

Parameters:
difContext - the context

_CG_execute

public ViewObject _CG_execute(IDIFContext context)
                       throws BusinessFlowException
Description copied from interface: IStageInstance
The business logic executing method.

This method should define the Stage business logic.

Specified by:
_CG_execute in interface IStageInstance
Parameters:
context - the execution context
Returns:
a view
Throws:
BusinessFlowException - when an exception is thrown by the stage's init/execute steps
See Also:
IStageInstance._CG_execute(IDIFContext)

_CG_finalize

public boolean _CG_finalize(IDIFContext context)
                     throws BusinessFlowException
Description copied from interface: IStageInstance
The finalization method.

This method should perform any tasks related to the Stage initialization.

Not to be confused with Java's own protected void finalize() throws Throwable.

Specified by:
_CG_finalize in interface IStageInstance
Parameters:
context - the execution context
Returns:
T if finalization was successful, F otherwise
Throws:
BusinessFlowException - when an exception is thrown by the stage's init/execute steps
See Also:
IStageInstance._CG_finalize(IDIFContext)

_CG_init

public boolean _CG_init(IDIFContext context)
                 throws BusinessFlowException
Description copied from interface: IStageInstance
The initialization method.

This method should perform any tasks related to the Stage initialization.

Specified by:
_CG_init in interface IStageInstance
Parameters:
context - the execution context
Returns:
T if initialization went ok, F otherwise
Throws:
BusinessFlowException - when an exception is thrown by the stage's init/execute steps
See Also:
IStageInstance._CG_init(IDIFContext)

callEventMethod

public Object callEventMethod(IDIFContext context,
                              EventType type,
                              String eventName)
Description copied from interface: IStageInstance
The method that will be enhanced with the call to the correct event method.

Specified by:
callEventMethod in interface IStageInstance
Parameters:
context - the execution context
type - the type of the fired event
eventName - the name of the event
Returns:
the object to return
See Also:
IStageInstance.callEventMethod(pt.digitalis.dif.controller.interfaces.IDIFContext, pt.digitalis.dif.dem.objects.EventType, java.lang.String)

callExecuteMethod

public ViewObject callExecuteMethod(IDIFContext context)
Description copied from interface: IStageInstance
The method that will be enhanced with the call to the method annotated with @Execute.

Specified by:
callExecuteMethod in interface IStageInstance
Parameters:
context - the execution context
Returns:
the view to return
See Also:
IStageInstance.callExecuteMethod(pt.digitalis.dif.controller.interfaces.IDIFContext)

callExecuteOnEventMethod

public ViewObject callExecuteOnEventMethod(IDIFContext context,
                                           EventType type,
                                           String eventName)
Description copied from interface: IStageInstance
The method that will be enhanced with the call to the method annotated with @Execute.

Specified by:
callExecuteOnEventMethod in interface IStageInstance
Parameters:
context - the execution context
type - the type of the fired event
eventName - the name of the event
Returns:
the view to return
See Also:
IStageInstance.callExecuteOnEventMethod(pt.digitalis.dif.controller.interfaces.IDIFContext, pt.digitalis.dif.dem.objects.EventType, java.lang.String)

callFinalizeMethod

protected boolean callFinalizeMethod(IDIFContext context)
The method that will be enhanced with the call to the method annotated with @Finalize.

Parameters:
context - the execution context
Returns:
as defined on the user-defined @Finalize-annotated method

callInitCustomParametersMethod

protected void callInitCustomParametersMethod(IParameters parameters)
The method that will be enhanced with the users custom parameters (call to the method annotated with @CustomParameters.

Parameters:
parameters - the stage parameters to be customized

callInitMethod

protected boolean callInitMethod(IDIFContext context)
The method that will be enhanced with the call to the method annotated with @DIFInitializer.

Parameters:
context - the execution context
Returns:
as defined on the user-defined @DIFInitializer-annotated method

createView

protected ViewObject createView(String engine,
                                String type,
                                String target,
                                boolean isDefault)
Creates a new view object. For usage of the CG methods

Parameters:
engine - the engine of the view
type - the type of the view
target - the target resource/template of the view
isDefault - T if the view is the default view
Returns:
the created view object

declareFeatureActive

public void declareFeatureActive(String featureID)
Description copied from interface: IStageInstance
Declares for the current stage instance that a given feature is enabled

Specified by:
declareFeatureActive in interface IStageInstance
Parameters:
featureID - the feature Id to declare active
See Also:
IStageInstance.declareFeatureActive(java.lang.String)

getAuthenticationError

public ControllerException getAuthenticationError()
Description copied from interface: IStageInstance
Gets the authentication error after an initialization has occurred

Specified by:
getAuthenticationError in interface IStageInstance
Returns:
the controller error exception object
See Also:
IStageInstance.getAuthenticationError()

getCallbackType

public CallbackType getCallbackType()
Description copied from interface: ICallback
Returns the Entity's callback type. The default value is OFF.

Specified by:
getCallbackType in interface ICallback
Returns:
the callback type defined for the Entity.
See Also:
ICallback.getCallbackType()

getContext

public IDIFContext getContext()
Description copied from interface: IStageInstance
Returns the execution context.

Specified by:
getContext in interface IStageInstance
Returns:
the execution context
See Also:
IStageInstance.getContext()

getDefaultErrorStage

public IStage getDefaultErrorStage()
The default error stage is constant and common to all instances and as such can be placed on the _CG_proxy. This method simply delegates the default error stage fetching to the _CG_proxy.

Specified by:
getDefaultErrorStage in interface IStage
Returns:
the default error Stage
See Also:
IStage.getDefaultErrorStage()

getDefaultErrorView

public ViewObject getDefaultErrorView()
The default error view is constant and common to all instances and as such can be placed on the _CG_proxy. This method simply delegates the default error view fetching to the _CG_proxy.

Specified by:
getDefaultErrorView in interface IStage
Returns:
the default error view
See Also:
IStage.getDefaultErrorView()

getDefaultView

public ViewObject getDefaultView()
The default view is constant and common to all instances and as such can be placed on the _CG_proxy. This method simply delegates the default view fetching to the _CG_proxy.

Specified by:
getDefaultView in interface IStage
Returns:
the default view
See Also:
IStage.getDefaultView()

getEventHandlers

public Map<EventType,List<String>> getEventHandlers()
Description copied from interface: IStage
Returns the list of all the Stages submit handlers.

Specified by:
getEventHandlers in interface IStage
Returns:
the list
See Also:
IStage.getEventHandlers()

getID

public String getID()
The ID is constant and common to all instances and as such can be placed on the _CG_proxy. This method simply delegates the ID fetching to the _CG_proxy.

Specified by:
getID in interface IEntity
Returns:
the Entity ID
See Also:
IEntity.getID()

getInjectedErrorStages

public Map<String,String> getInjectedErrorStages()
Description copied from interface: IStage
Returns the list of all the error Stages injected in this Stage.

Specified by:
getInjectedErrorStages in interface IStage
Returns:
the list of all the injected Stages
See Also:
IStage.getInjectedErrorStages()

getInjectedErrorViews

public Map<String,ViewObject> getInjectedErrorViews()
Description copied from interface: IStage
Returns the list of all the error views injected in this Stage.

Specified by:
getInjectedErrorViews in interface IStage
Returns:
the list of all the injected ViewObject
See Also:
IStage.getInjectedErrorViews()

getInjectedStages

public List<String> getInjectedStages()
The injected stages are constant and common to all instances and as such can be placed on the _CG_proxy. This method simply delegates the injected stages fetching to the _CG_proxy.

Specified by:
getInjectedStages in interface IStage
Returns:
the list of all the injected Stages
See Also:
IStage.getInjectedStages()

getInjectedViews

public List<ViewObject> getInjectedViews()
The injected views are constant and common to all instances and as such can be placed on the _CG_proxy. This method simply delegates the injected views fetching to the _CG_proxy.

Specified by:
getInjectedViews in interface IStage
Returns:
the list of all the injected ViewObject
See Also:
IStage.getInjectedViews()

getInstance

public IStageInstance getInstance()
Description copied from interface: IStage
Return an instance of the stage for execution

Specified by:
getInstance in interface IStage
Returns:
the stage instance
See Also:
IStage.getInstance()

getLicenseEdition

public LicenseEditionType getLicenseEdition()
Description copied from interface: IRegistrable
Get the License Edition.

Specified by:
getLicenseEdition in interface IRegistrable
Returns:
LicenseEditionType
See Also:
IRegistrable.getLicenseEdition()

getMessage

public String getMessage(String messageID)
Description copied from interface: IMessage
Returns a message associated with a given ID

Specified by:
getMessage in interface IMessage
Parameters:
messageID - the message ID
Returns:
the message with the given id
See Also:
IMessage.getMessage(java.lang.String)

getMessageForLanguage

public String getMessageForLanguage(String language,
                                    String messageID)
Description copied from interface: IStage
Returns a message associated with a given ID

Specified by:
getMessageForLanguage in interface IStage
Parameters:
language - the language to get the messages in
messageID - the message ID
Returns:
the message with the given id
See Also:
IStage.getMessageForLanguage(java.lang.String, java.lang.String)

getMessages

public Map<String,String> getMessages()
Description copied from interface: IMessage
Returns all messages associated with the Entity.

Specified by:
getMessages in interface IMessage
Returns:
a map with all the messages related to the Entity
See Also:
IMessage.getMessages()

getMessagesForLanguage

public Map<String,String> getMessagesForLanguage(String language)
Description copied from interface: IStage
Returns all messages associated with the Entity.

Specified by:
getMessagesForLanguage in interface IStage
Parameters:
language - the language to get the messages in
Returns:
a map with all the messages related to the Entity
See Also:
IStage.getMessagesForLanguage(java.lang.String)

getName

public String getName()
The name is constant and common to all instances and as such can be placed on the _CG_proxy. This method simply delegates the name fetching to the _CG_proxy.

Specified by:
getName in interface IEntity
Returns:
the Entity name
See Also:
IEntity.getName()

getOriginalClassName

public String getOriginalClassName()
Description copied from interface: IEntity
Returns the original entity class name

Specified by:
getOriginalClassName in interface IEntity
Returns:
the class name
See Also:
IEntity.getOriginalClassName()

getOverridesStageID

public String getOverridesStageID()
Specified by:
getOverridesStageID in interface IStage
Returns:
the stage id of the stage that the present one overrides. Null otherwise.
See Also:
IStage.getOverridesStageID()

getParameterErrors

public ParameterErrors getParameterErrors()
Description copied from interface: IStageInstance
Gets the parameter errors after a initialization has occurred

Specified by:
getParameterErrors in interface IStageInstance
Returns:
the parameter errors object
See Also:
IStageInstance.getParameterErrors()

getParameters

public IParameters getParameters()
Description copied from interface: IStage
Returns the parameters for the current stage

Specified by:
getParameters in interface IStage
Returns:
the parameters
See Also:
IStage.getParameters()

getService

public IService getService()
The service is constant and common to all instances and as such can be placed on the _CG_proxy. This method simply delegates the service fetching to the _CG_proxy.

Specified by:
getService in interface IStage
Returns:
the Stage service
See Also:
IStage.getService()

getStageInstanceClassName

public String getStageInstanceClassName()
Description copied from interface: IStage
Obtains the original stage class name

Specified by:
getStageInstanceClassName in interface IStage
Returns:
the class name
See Also:
IStage.getStageInstanceClassName()

getTemplateResources

protected TemplateResources getTemplateResources()
For usage of the CG methods

Returns:
an instance of template resources

getUID

public String getUID()
Description copied from interface: IEntity
Returns the entity's unique ID. The unique ID has the form ":".

Specified by:
getUID in interface IEntity
Returns:
the entity's UID
See Also:
IEntity.getUID()

hasAuthentication

public boolean hasAuthentication()
Description copied from interface: IStage
Defines if the stage has authentication.

Specified by:
hasAuthentication in interface IStage
Returns:
T if the stage has , F otherwise
See Also:
IStage.hasAuthentication()

hasAuthenticationErrorInjection

public boolean hasAuthenticationErrorInjection()
Description copied from interface: IStage
Registers if the stage has injected the authentication errors. If so the dispatcher will not fail on authentication errors and instead inject them so the stage may process them.

Specified by:
hasAuthenticationErrorInjection in interface IStage
Returns:
T if the stage has injected the authentication errors onto an attribute
See Also:
IStage.hasAuthenticationErrorInjection()

hasAuthorization

public boolean hasAuthorization()
Description copied from interface: IStage
Defines if the stage has authorization.

Specified by:
hasAuthorization in interface IStage
Returns:
T if the stage has , F otherwise
See Also:
IStage.hasAuthorization()

hasCallbackEnabled

public boolean hasCallbackEnabled()
Description copied from interface: ICallback
Returns information about the Entity's callback state. The default value is F.

Specified by:
hasCallbackEnabled in interface ICallback
Returns:
T if Entity has Callback enabled, F otherwise
See Also:
ICallback.hasCallbackEnabled()

hasInjectedContributions

public boolean hasInjectedContributions()
Specified by:
hasInjectedContributions in interface IStage
Returns:
T if any attribute or method in annotated with Inject
See Also:
IStage.hasInjectedContributions()

hasParameterErrorInjection

public boolean hasParameterErrorInjection()
Description copied from interface: IStage
Registers if the stage has injected the parameter errors. If not the framework must provide extra reporting of the errors. Else it is delegated to the business stage implementation.

Specified by:
hasParameterErrorInjection in interface IStage
Returns:
T if the stage has injected the errors onto an attribute
See Also:
IStage.hasParameterErrorInjection()

hasValidationLogicForForm

public boolean hasValidationLogicForForm(String formName)
Description copied from interface: IStage
Checks if the current form has a validation logic handler for the given form

Specified by:
hasValidationLogicForForm in interface IStage
Parameters:
formName - the form name
Returns:
T if present
See Also:
IStage.hasValidationLogicForForm(java.lang.String)

isFeatureEnabled

public boolean isFeatureEnabled(String featureID)
Description copied from interface: IStageInstance
Validates if a given feature is active/present

Specified by:
isFeatureEnabled in interface IStageInstance
Parameters:
featureID - the Id of the feature do validate is is present/active
Returns:
true if it is active/present
See Also:
IStageInstance.isFeatureEnabled(java.lang.String)

isInitialized

public boolean isInitialized()
Specified by:
isInitialized in interface IStageInstance
Returns:
T if the stage has already been initialized by calling the "_CG_init" method
See Also:
IStageInstance.isInitialized()

isRegistered

public boolean isRegistered()
Description copied from interface: IRegistrable
Returns information about if the Entity is registered.

Specified by:
isRegistered in interface IRegistrable
Returns:
T if the Entity is registered, F otherwise
See Also:
IRegistrable.isRegistered()

isRegistrable

public boolean isRegistrable()
Description copied from interface: IRegistrable
Returns information about if the Entity can be registered.

Specified by:
isRegistrable in interface IRegistrable
Returns:
T if the Entity is registrable, F otherwise
See Also:
IRegistrable.isRegistrable()

register

public boolean register(String name,
                        String key)
Description copied from interface: IRegistrable
Registers the Entity with a given key.

Specified by:
register in interface IRegistrable
Parameters:
name - the name to register to
key - the encripted registration key
Returns:
T if the Entity was successfully registered, F otherwise
See Also:
IRegistrable.register(java.lang.String, java.lang.String)

setAuthenticationError

public void setAuthenticationError(ControllerException exception)
Description copied from interface: IStageInstance
Sets the authentication error

Specified by:
setAuthenticationError in interface IStageInstance
Parameters:
exception - the authentication exception
See Also:
IStageInstance.setAuthenticationError(pt.digitalis.dif.exception.controller.ControllerException)

setContext

public void setContext(IDIFContext newContext)
Description copied from interface: IStageInstance
Sets the execution context on the Stage.

Specified by:
setContext in interface IStageInstance
Parameters:
newContext - the execution context
See Also:
IStageInstance.setContext(IDIFContext)

setParameterErrors

public void setParameterErrors(ParameterErrors errors)
Description copied from interface: IStageInstance
Sets the parameter errors

Specified by:
setParameterErrors in interface IStageInstance
Parameters:
errors - the errors object to set
See Also:
IStageInstance.setParameterErrors(pt.digitalis.dif.dem.objects.parameters.errors.ParameterErrors)

setProxy

public void setProxy(IStage _CG_proxy)
Description copied from interface: IStageInstance
Sets the associated proxy to call info upon

Specified by:
setProxy in interface IStageInstance
Parameters:
_CG_proxy - the proxy to set
See Also:
IStageInstance.setProxy(pt.digitalis.dif.dem.interfaces.IStage)

unregister

public void unregister()
Description copied from interface: IRegistrable
Unregisters the Entity.

Specified by:
unregister in interface IRegistrable
See Also:
IRegistrable.unregister()


Copyright © 2014 Digitalis Informática Lda. All Rights Reserved.