8.7 Workflow Java API
The reference documentation of the Daisy workflow Java API is available as javadocs, see the following package:
org.outerj.daisy.workflow
Using the workflow API it is simple to automate everything workflow-related. In contrast to the API of the core repository server, the workflow API is "flatter", that is, there is one service interface (WorkflowManager) through which all operations are performed. The returned objects are pure value objects without active behavior.
As an example, here is a bit of code I used to fill up the workflow system with some process instances for testing purposes.
This code is written as Javascript,
importPackage(Packages.org.outerj.daisy.repository);
importPackage(Packages.org.outerj.daisy.workflow);
importClass(Packages.org.outerj.daisy.repository.clientimpl.RemoteRepositoryManager);
var repositoryManager = new RemoteRepositoryManager("http://localhost:9263",
new Credentials("guest", "guest"));
// Add the WorkflowManager extension
repositoryManager.registerExtension("WorkflowManager",
new Packages.org.outerj.daisy.workflow.clientimpl.RemoteWorkflowManagerProvider());
var repository = repositoryManager.getRepository(new Credentials("testuser", "testuser"));
var wfManager = repository.getExtension("WorkflowManager");
var locale = java.util.Locale.US;
var userId = repository.getUserManager().getPublicUserInfo("testuser").getId();
var processDef = wfManager.getLatestProcessDefinition("review", locale);
var taskUpdateData = new TaskUpdateData();
taskUpdateData.setVariable("daisy_document", VariableScope.GLOBAL,
WfValueType.DAISY_LINK, new WfVersionKey("1-DSY", 1, 1, "last"));
taskUpdateData.setVariable("reviewer", VariableScope.GLOBAL,
WfValueType.ACTOR, new WfActorKey(userId));
taskUpdateData.setVariable("taskPriority", VariableScope.GLOBAL,
WfValueType.LONG, new java.lang.Long(3)); // 3 is 'normal'
for (var i = 0; i < 100; i++) {
java.lang.System.out.println(i);
taskUpdateData.setVariable("daisy_description", VariableScope.GLOBAL,
WfValueType.STRING, "review process " + i);
wfManager.startProcess(processDef.getId(), taskUpdateData,
null /* default transition */, locale);
}
Previous