Package com.orchestranetworks.workflow
Provides classes and interfaces for implementing workflow processes and
invoking them.
See:
Description
Package com.orchestranetworks.workflow Description
Provides classes and interfaces for implementing workflow processes and
invoking them.
Developer Guide
Workflow provides types of steps: library or specific.
Library is a bean defined in module.xml and reusable. Using library bean improves ergonomics: parameters are dynamically displayed in definition screens.
Specific object is a bean defined only by its class name.In this case, display is not dynamic.
| Step |
Library |
Specific |
| Scripts |
ScriptTaskBean |
ScriptTask |
| Conditions |
ConditionBean |
Condition |
| User task |
UserTask |
|
Sample of ScriptTask
Java Code
A script task has to override the method execute as in the following
example:
public class NppScriptTask_CreateWorkingBranch extends ScriptTask
{
public void executeScript(ScriptTaskContext aContext) throws OperationException
{
Repository repository = aContext.getRepository();
String initialBranchString = aContext.getVariableString("initialBranch");
AdaptationHome initialBranch = repository.lookupHome(HomeKey.forBranchName(initialBranchString));
if (initialBranch == null)
throw OperationException.createError("Null value for initialBranch");
HomeCreationSpec spec = new HomeCreationSpec();
spec.setParent(initialBranch);
spec.setKey(HomeKey.forBranchName("Name"));
spec.setOwner(Profile.EVERYONE);
spec.setHomeToCopyPermissionsFrom(initialBranch);
AdaptationHome newHome = repository.createHome(spec, aContext.getSession());
//feeds dataContext
aContext.setVariableString("workingBranch", newHome.getKey().getName());
}
}
Configuration through UI
The configuration UI is quite simple :
Sample of ScriptTaskBean
Java Code
A script task bean has to override the method executeScript as in the following example.
public class ScriptTaskBean_CreateBranch extends ScriptTaskBean
{
private String initialBranchName;
private String newBranch;
public String getInitialBranchName()
{
return this.initialBranchName;
}
public void setInitialBranchName(String initialBranchName)
{
this.initialBranchName = initialBranchName;
}
public String getNewBranch()
{
return this.newBranch;
}
public void setNewBranch(String newBranch)
{
this.newBranch = newBranch;
}
public void executeScript(ScriptTaskBeanContext aContext) throws OperationException
{
final Repository repository = aContext.getRepository();
String initialBranchName = this.getInitialBranchName();
final AdaptationHome initialBranch = repository.lookupHome(HomeKey.forBranchName(initialBranchName));
final HomeCreationSpec spec = new HomeCreationSpec();
spec.setParent(initialBranch);
spec.setKey(HomeKey.forBranchName(XsFormats.SINGLETON.formatDateTime(new Date())));
spec.setOwner(Profile.EVERYONE);
spec.setHomeToCopyPermissionsFrom(initialBranch);
final AdaptationHome branchCreate = repository.createHome(spec, aContext.getSession());
this.setNewBranch(branchCreate.getKey().getName());
}
}
Configuration through module.xml
Script task bean must be declared in module.xml :
<module>
<beans>
<bean className="com.orchestranetworks.workflow.genericScriptTask.ScriptTaskBean_CreateBranch">
<documentation xml:lang="fr-FR">
<label>Créer une branche</label>
<description>
Ce script permet de créer une branche
</description>
</documentation>
<documentation xml:lang="en-US">
<label>Create a branch</label>
<description>
This script allows to create a branch
</description>
</documentation>
<properties>
<property name="initialBranchName" input="true">
<documentation xml:lang="fr-FR">
<label>Branche initiale</label>
<description>
Nom de la branche initiale.
</description>
</documentation>
<documentation xml:lang="en-US">
<label>Initial branch</label>
<description>
Initial branch name.
</description>
</documentation>
</property>
<property name="newBranch" output="true">
<documentation xml:lang="fr-FR">
<label>Nouvelle branche</label>
<description>
Nom de la branche créée
</description>
</documentation>
<documentation xml:lang="en-US">
<label>New branch</label>
<description>
Created branch name.
</description>
</documentation>
</property>
</properties>
</bean>
</beans>
</module>
Configuration through UI
The configuration UI is quite simple :
Samples of UserTask
Simple task without any code
It is not necessary to develop any code to call an UI Service
within a workflow. The following example will offer a work item to
profile PValidator. All users with this profile will be notified
by email.
This work item will be the Creation UI Service and the XPath
predicate of the record created will be put into the DataContext
under the variable code.
It is possible to use a data context variable for the label of the user task. This variable can be changed in handleCreate method, for example.

Service declaration via module.xml : no built-in service must be declared in module.xml to be used in user task definition.
<services>
<service name="ServiceModule">
<resourcePath>/service.jsp</resourcePath>
<type>branch</type>
<documentation xml:lang="fr-FR">
<label>Workflow service</label>
<description>
Ce service permet de ...
</description>
</documentation>
<documentation xml:lang="en-US">
<label>Service workflow</label>
<description>
This service allows to ...
</description>
</documentation>
<properties>
<property name="param1" input="true">
<documentation xml:lang="fr-FR">
<label>Param1</label>
<description>Param1 ...</description>
</documentation>
</property>
<property name="param2" output="true">
</property>
</properties>
</service>
<serviceLink serviceName="adaptationService">
<importFromSchema>
/WEB-INF/ebx/schema/schema.xsd
</importFromSchema>
</serviceLink>
</services>
A more complex UserTask
The GUI is quite the same as in the simple case above. The field "Rule"
must be filled to define the class extending UserTask to invoke.
public class NppUserTask_ValidateProduct extends UserTask
{
public void handleWorkItemCompletion(UserTaskWorkItemCompletionContext context)
throws OperationException
{
if (context.getCompletedWorkItem().isRejected())
{
context.setVariableString(NppConstants.VAR_VALIDATION, "KO");
context.completeUserTask();
}
else if (context.checkAllWorkItemMatchStrategy())
{
context.setVariableString(NppConstants.VAR_VALIDATION, "OK");
context.completeUserTask();
}
}
public void handleCreate(UserTaskCreationContext context) throws OperationException
{
CreationWorkItemSpec spec = CreationWorkItemSpec.forOfferring(NppConstants.ROLE_PVALIDATOR);
spec.setNotificationMail("1");
context.createWorkItem(spec);
context.setVariableString(NppConstants.VAR_VALIDATION, "validating");
}
}
Sample of Condition
Java Code
The method evaluate has to be overridden:
public class NppCondition_IsValidationOK extends Condition
{
public boolean evaluateCondition(ConditionContext context) throws OperationException
{
String validation = context.getVariableString("validationResult");
boolean hasError = "KO".equals(validation);
return !hasError;
}
}
Configuration through UI
Sample of ConditionBean
Java Code
Methods evaluateCondition has to be overridden as the following sample :
public class ConditionBean_IsBranchValid extends ConditionBean
{
private String branchName;
public String getBranchName()
{
return this.branchName;
}
public void setBranchName(String branchName)
{
this.branchName = branchName;
}
public boolean evaluateCondition(ConditionBeanContext aContext) throws OperationException
{
final Repository repository = aContext.getRepository();
Severity severityForValidation = Severity.ERROR;
String branchToTestName = this.getBranchName();
final AdaptationHome branchToTest = repository.lookupHome(HomeKey.forBranchName(branchToTestName));
if (branchToTest.getValidationReportsMap(severityForValidation) != null
&& branchToTest.getValidationReportsMap(severityForValidation).size() > 0)
{
return false;
}
return true;
}
}
Configuration through module.xml
Condition bean must be declared in module.xml :
<module>
<beans>
<bean className="com.orchestranetworks.workflow.genericScriptTask.ConditionBean_IsBranchValid">
<documentation xml:lang="fr-FR">
<label>Branche valide ?</label>
<description>
Ce script permet de tester si une branche est valide.
</description>
</documentation>
<documentation xml:lang="en-US">
<label>Branch valid ?</label>
<description>
This script allows to check if a branch is valid.
</description>
</documentation>
<properties>
<property name="branchName" input="true">
<documentation xml:lang="fr-FR">
<label>Branche à contrôler</label>
<description>
Nom de la branche à valider.
</description>
</documentation>
<documentation xml:lang="en-US">
<label>Branch to check</label>
<description>
Branch name to check.
</description>
</documentation>
</property>
</properties>
</bean>
</beans>
</module>
Configuration through UI
Sample of trigger starting a process instance
public class TriggerWorkflow extends TableTrigger
{
public void handleAfterModify(AfterModifyOccurrenceContext aContext) throws OperationException
{
ValueContext currentRecord = aContext.getOccurrenceContext();
String code = (String) currentRecord.getValue(Path.parse("/code"));
//Get published process
PublishedProcessKey processPublishedKey = PublishedProcessKey.forName("productProcess");
//Defines process instance
ProcessLauncher launcher = ProcessLauncherHelper.createLauncher(
processPublishedKey,
aContext.getProcedureContext());
//initialize Data Context
launcher.setInputParameter("code", "/root/Client[./code=\"" + code + "\"]");
launcher.setInputParameter("workingBranch", aContext.getAdaptationHome().getKey().getName());
//Starts process
launcher.launchProcess();
}
//...
}
(report a bug)
EBX.Platform 4.8.4 [0722]
Copyright Orchestra Networks 2000-2010. All rights reserved.