org.pentaho.platform.engine.services.solution
Class ComponentBase

java.lang.Object
  extended by org.pentaho.platform.engine.core.system.PentahoBase
      extended by org.pentaho.platform.engine.services.PentahoMessenger
          extended by org.pentaho.platform.engine.services.solution.ComponentBase
All Implemented Interfaces:
Serializable, IAuditable, IComponent, ILogger, IParameterResolver
Direct Known Subclasses:
AbstractJFreeReportComponent, BIRTReportComponent, ChartComponent, ContentOutputComponent, ContentRepositoryCleaner, EmailComponent, HelloWorldComponent, HQLBaseComponent, InstanceEnd, JasperReportsComponent, JavascriptRule, JFreeReportGeneratorComponent, JobSchedulerComponent, KettleComponent, MDXBaseComponent, MondrianModelComponent, PentahoVersionCheckComponent, PivotViewComponent, PojoComponent, PojoComponent, PrintComponent, ResultSetCompareComponent, ResultSetCrosstabComponent, ResultSetExportComponent, ResultSetFlattenerComponent, SchedulerAdminComponent, SecureFilterComponent, SQLBaseComponent, SubActionComponent, TemplateComponent, TestComponent, UtilityComponent, XMLABaseComponent, XQueryBaseComponent

public abstract class ComponentBase
extends PentahoMessenger
implements IComponent, IParameterResolver

See Also:
Serialized Form

Field Summary
static String COMPONENT_EXECUTE_FAIL
           
static String MISSING_SESSION
           
 
Fields inherited from class org.pentaho.platform.engine.core.system.PentahoBase
EMPTYLOGID, LOGID_MASK1, LOGID_MASK2, LOGID_SEPARATOR
 
Fields inherited from interface org.pentaho.platform.api.engine.ILogger
ACTIVITY_LOG, DEBUG, ERROR, FATAL, INFO, INSTANCE_LOG, SESSION_LOG, SOLUTION_LOG, TRACE, UNKNOWN, WARN
 
Constructor Summary
ComponentBase()
           
 
Method Summary
 void createFeedbackParameter(String fieldName, String displayName, String hint, Object defaultValues, List values, Map dispNames, String displayStyle)
           
 void createFeedbackParameter(String fieldName, String displayName, String hint, Object defaultValues, List values, Map dispNames, String displayStyle, boolean optional)
           
 String createNewInstance(boolean persisted, Map parameters, boolean forceImmediateWrite)
           
abstract  void done()
          Allows the component to perform any cleanup after the execution of the action.
 int execute()
          Perform the Component execution; logic for what this Component does goes here.
 IActionDefinition getActionDefinition()
           
 String getActionName()
          Return the name of the action sequence.
 String getActionTitle()
           
 Node getComponentDefinition()
           
 Node getComponentDefinition(boolean process)
          Return the xml Node containing the component's definition.
 String getId()
          Returns a unique id (across classes and instances) for this auditable object.
 String getInitFailMessage()
           
 boolean getInitOk()
           
 String getInstanceId()
           
 String getLogId()
           
 String getObjectName()
          Returns the Java class name for this object.
 String getProcessId()
          Return the id for the execution of a given action sequence document.
 String getResourceAsString(IActionSequenceResource resource)
           
 IRuntimeContext getRuntimeContext()
           
 IPentahoSession getSession()
           
abstract  boolean init()
          Initialize the Component.
 void inputMissingError(String paramName)
           
 void outputMissingError(String paramName)
           
 void promptNeeded()
           
 void promptNow()
           
 int resolveParameter(String template, String parameterName, Matcher parameterMatcher, int copyStart, StringBuffer result)
          Provides a way for components to inject their own replacements of parameter markers in the provided template.
 void resourceComponentSettingError(String paramName)
           
 void resourceMissingError(String paramName)
           
 void setActionDefinition(IActionDefinition actionDefinition)
           
 void setActionName(String actionName)
           
 void setComponentDefinition(Node componentDefinition)
           
 void setComponentDefinitionMap(Map<String,String> componentDefinitionMap)
           
 void setInstanceId(String instanceId)
           
 void setProcessId(String processId)
           
 void setRuntimeContext(IRuntimeContext runtimeContext)
           
 void setSession(IPentahoSession session)
           
 int validate()
          Validate that the Component has all the necessary inputs, outputs and resources it needs to execute successfully.
 
Methods inherited from class org.pentaho.platform.engine.services.PentahoMessenger
debug, debug, error, error, fatal, fatal, getMessages, getUserString, info, info, setMessages, trace, trace, warn, warn
 
Methods inherited from class org.pentaho.platform.engine.core.system.PentahoBase
genLogIdFromInfo, genLogIdFromInfo, genLogIdFromSession, getLogger, getLoggingLevel, setLoggingLevel, setLogId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.pentaho.platform.api.engine.IComponent
getMessages, setMessages
 
Methods inherited from interface org.pentaho.platform.api.engine.ILogger
debug, debug, error, error, fatal, fatal, getLoggingLevel, info, info, setLoggingLevel, trace, trace, warn, warn
 

Field Detail

MISSING_SESSION

public static final String MISSING_SESSION
See Also:
Constant Field Values

COMPONENT_EXECUTE_FAIL

public static final String COMPONENT_EXECUTE_FAIL
See Also:
Constant Field Values
Constructor Detail

ComponentBase

public ComponentBase()
Method Detail

setInstanceId

public void setInstanceId(String instanceId)
Specified by:
setInstanceId in interface IComponent

getInstanceId

public String getInstanceId()
Specified by:
getInstanceId in interface IComponent

setActionName

public void setActionName(String actionName)
Specified by:
setActionName in interface IComponent

getActionName

public String getActionName()
Description copied from interface: IAuditable
Return the name of the action sequence. Today, that name is synonymous with the name of the action sequence document in the solution repository.

Specified by:
getActionName in interface IAuditable
Specified by:
getActionName in interface IComponent
Returns:
the name of the action sequence

setProcessId

public void setProcessId(String processId)
Specified by:
setProcessId in interface IComponent

getProcessId

public String getProcessId()
Description copied from interface: IAuditable
Return the id for the execution of a given action sequence document.

Specified by:
getProcessId in interface IAuditable
Specified by:
getProcessId in interface IComponent
Returns:
the process id

setComponentDefinition

public void setComponentDefinition(Node componentDefinition)
Specified by:
setComponentDefinition in interface IComponent

setComponentDefinitionMap

public void setComponentDefinitionMap(Map<String,String> componentDefinitionMap)
Specified by:
setComponentDefinitionMap in interface IComponent

getComponentDefinition

public Node getComponentDefinition()
Specified by:
getComponentDefinition in interface IComponent

getComponentDefinition

public Node getComponentDefinition(boolean process)
Return the xml Node containing the component's definition. If process is true, visit every child node in the tree, and if the child node's text is an action parameter convert it to it's value. (See doc for applyInputsToFormat())

Parameters:
process - if true, if the node's text represents a parameter, convert the parameter to it's value, and assign the value to the node's text.
Returns:
Node containing this component's definition.

setRuntimeContext

public void setRuntimeContext(IRuntimeContext runtimeContext)
Specified by:
setRuntimeContext in interface IComponent

getRuntimeContext

public IRuntimeContext getRuntimeContext()
Specified by:
getRuntimeContext in interface IComponent

setSession

public void setSession(IPentahoSession session)
Specified by:
setSession in interface IComponent

getSession

public IPentahoSession getSession()
Specified by:
getSession in interface IComponent

done

public abstract void done()
Description copied from interface: IComponent
Allows the component to perform any cleanup after the execution of the action.

Specified by:
done in interface IComponent

init

public abstract boolean init()
Description copied from interface: IComponent
Initialize the Component. This method is typically called on construction.

Specified by:
init in interface IComponent
Returns:
returns true if the Component initialized successfully, otherwise returns false

getLogId

public String getLogId()
Overrides:
getLogId in class PentahoBase

validate

public final int validate()
Description copied from interface: IComponent
Validate that the Component has all the necessary inputs, outputs and resources it needs to execute successfully. Also may validate a schema here.

Specified by:
validate in interface IComponent
Returns:
one of IRuntimeContext validation conditions
See Also:
IRuntimeContext

resolveParameter

public int resolveParameter(String template,
                            String parameterName,
                            Matcher parameterMatcher,
                            int copyStart,
                            StringBuffer result)
Description copied from interface: IParameterResolver
Provides a way for components to inject their own replacements of parameter markers in the provided template. This currently exposes too much of the internals of TemplateUtil IMO, but without serious surgery on the TemplateUtil, this is about the only way to accomplish the task.

Specified by:
resolveParameter in interface IParameterResolver
Parameters:
template - The string containing replacement parameters
parameterName - The name of the located parameter in the template
parameterMatcher - The Regex matcher that located the parameter
copyStart - The current start to copy from the template
result - The final string with the parameter replacements inlined
Returns:
integer indicating the new copyStart to be used in the TemplateUtil in the event that the component handled the parameter. If negative, then no processing was done in the component. Any value greater than or equal to zero indicates processing happened in the component. TODO: Change this interface to make it easier to do things without exposing the internals of TemplateUtil.

getInitOk

public boolean getInitOk()

promptNeeded

public void promptNeeded()

promptNow

public void promptNow()

getResourceAsString

public String getResourceAsString(IActionSequenceResource resource)

getInitFailMessage

public String getInitFailMessage()

createNewInstance

public String createNewInstance(boolean persisted,
                                Map parameters,
                                boolean forceImmediateWrite)

inputMissingError

public void inputMissingError(String paramName)

outputMissingError

public void outputMissingError(String paramName)

resourceMissingError

public void resourceMissingError(String paramName)

resourceComponentSettingError

public void resourceComponentSettingError(String paramName)

execute

public int execute()
Description copied from interface: IComponent
Perform the Component execution; logic for what this Component does goes here.

Specified by:
execute in interface IComponent
Returns:
one of IRuntimeContext execution conditions
See Also:
IRuntimeContext

getObjectName

public String getObjectName()
Description copied from interface: IAuditable
Returns the Java class name for this object.

Specified by:
getObjectName in interface IAuditable
Overrides:
getObjectName in class PentahoBase
Returns:
the name of the object (the Java class name)

getId

public String getId()
Description copied from interface: IAuditable
Returns a unique id (across classes and instances) for this auditable object.

Specified by:
getId in interface IAuditable
Returns:
the auditable's id

getActionTitle

public String getActionTitle()

createFeedbackParameter

public void createFeedbackParameter(String fieldName,
                                    String displayName,
                                    String hint,
                                    Object defaultValues,
                                    List values,
                                    Map dispNames,
                                    String displayStyle)

createFeedbackParameter

public void createFeedbackParameter(String fieldName,
                                    String displayName,
                                    String hint,
                                    Object defaultValues,
                                    List values,
                                    Map dispNames,
                                    String displayStyle,
                                    boolean optional)

setActionDefinition

public void setActionDefinition(IActionDefinition actionDefinition)
Specified by:
setActionDefinition in interface IComponent

getActionDefinition

public IActionDefinition getActionDefinition()
Specified by:
getActionDefinition in interface IComponent