public class JDBCWorkflowFactory extends XMLWorkflowFactory implements FunctionProvider
Also required is a database table called OS_WORKFLOWDEFS with two columns, WF_NAME which contains the workflow name, and WF_DEFINITION which will contain the xml workflow descriptor, the latter can be either a TEXT or BINARY type.
Note that this class is provided as an example, and users are encouraged to use their own implementations that are more suited to their particular needs.
Modifier and Type | Field and Description |
---|---|
protected DataSource |
ds |
protected boolean |
reload |
protected Map |
workflows |
properties
Constructor and Description |
---|
JDBCWorkflowFactory() |
Modifier and Type | Method and Description |
---|---|
void |
execute(Map transientVars,
Map args,
com.opensymphony.module.propertyset.PropertySet ps)
Execute this function
|
WorkflowDescriptor |
getWorkflow(String name,
boolean validate)
Get a workflow descriptor given a workflow name.
|
String[] |
getWorkflowNames()
Get all workflow names in the current factory
|
void |
initDone()
Invoked after the properties of the factory have been set.
|
byte[] |
read(String workflowname) |
boolean |
removeWorkflow(String name) |
boolean |
saveWorkflow(String name,
WorkflowDescriptor descriptor,
boolean replace)
Save the workflow.
|
boolean |
write(String workflowname,
byte[] wf) |
createWorkflow, getBaseDir, getInputStream, getLayout, getName, isModifiable, renameWorkflow, save, setLayout, writeXML
getProperties, getWorkflow, init
protected DataSource ds
protected Map workflows
protected boolean reload
public WorkflowDescriptor getWorkflow(String name, boolean validate) throws FactoryException
WorkflowFactory
getWorkflow
in interface WorkflowFactory
getWorkflow
in class XMLWorkflowFactory
name
- The name of the workflow to get.FactoryException
- if the specified workflow name does not exist or cannot be located.public String[] getWorkflowNames()
WorkflowFactory
getWorkflowNames
in interface WorkflowFactory
getWorkflowNames
in class XMLWorkflowFactory
public void execute(Map transientVars, Map args, com.opensymphony.module.propertyset.PropertySet ps)
FunctionProvider
execute
in interface FunctionProvider
transientVars
- Variables that will not be persisted. These include inputs
given in the Workflow.initialize(java.lang.String, int, java.util.Map)
and Workflow.doAction(long, int, java.util.Map)
method calls.
There are a number of special variable names:
entry
: (object type: WorkflowEntry
)
The workflow instance
context
:
(object type: WorkflowContext
). The workflow context.
actionId
: The Integer ID of the current action that was take (if applicable).
currentSteps
: A Collection of the current steps in the workflow instance.
store
: The WorkflowStore
.
descriptor
: The WorkflowDescriptor
.
Register
), will also be
available in the transient map, no matter what. These transient variables only last through
the method call that they were invoked in, such as Workflow.initialize(java.lang.String, int, java.util.Map)
and Workflow.doAction(long, int, java.util.Map)
.args
- The properties for this function invocation. Properties are created
from arg nested elements within the xml, an arg element takes in a name attribute
which is the properties key, and the CDATA text contents of the element map to
the property value.ps
- The persistent variables that are associated with the current
instance of the workflow. Any change made to the propertyset are persisted to
the propertyset implementation's persistent store.public void initDone() throws FactoryException
AbstractWorkflowFactory
initDone
in interface WorkflowFactory
initDone
in class XMLWorkflowFactory
FactoryException
- if there was an error during initialization.public byte[] read(String workflowname) throws SQLException
SQLException
public boolean removeWorkflow(String name) throws FactoryException
removeWorkflow
in interface WorkflowFactory
removeWorkflow
in class XMLWorkflowFactory
FactoryException
public boolean saveWorkflow(String name, WorkflowDescriptor descriptor, boolean replace) throws FactoryException
WorkflowFactory
WorkflowDescriptor.validate()
method. Invalid workflows will
be saved without being checked.saveWorkflow
in interface WorkflowFactory
saveWorkflow
in class XMLWorkflowFactory
name
- The name of the workflow to same.descriptor
- The descriptor for the workflow.replace
- true if an existing workflow with this name should be replaced.FactoryException
- if there was an error saving the workflowInvalidWorkflowDescriptorException
- if the descriptor specified is invalidpublic boolean write(String workflowname, byte[] wf) throws SQLException
SQLException
Copyright © 2021 catworkx GmbH. All rights reserved.