Archive for September, 2013

workflow system

Posted: 5 September 2013 in Uncategorized

Today, I made a breakthough in my custom workflow system. I have implemented a remote security proxy to my objects using JAAS.  This means that now, users need to be authenticated to perform workflow operations.  Below is the code I use to connect to the Lapis Serser (a server that does a few things), get a client, obtain a workflow engine and start a workflow.

        Registry registry = LocateRegistry.getRegistry("localhost", 12345);
        LapisClientFactory factory = (LapisClientFactory)registry.lookup("lapisClientFactory");
        LapisClient client = factory.getClient("laurent", "xxxxxxxxx");

        WorkflowEngine workflowEngine = client.getWorkflowEngine();
        File workflowFile = new File(workflowFilePath);
        GraphExecution graphExecution = workflowEngine.instantiate(workflowFile, wfMapEnv);
        graphExecution.start();

snapshot1

I have created three command line tools to interact with the system.

  • wfstart.sh, which starts a given workflow,
  • wflist.sh, which list started workflows and their activation tokens and their tasks,
  • wfcomplete.sh, to complete a node token (an active task if you will) and choose a transition arc to the next task.

The workflow allows for automated tasks (which decide how to transition to the next task) and also for user tasks (which do nothing until a user indicates they have completed their tasks). A series of events get triggered whenever a workflow is started or a task gets activated, which later could be used for user notification [via email or JMS or whatever else you want to plug in].

Below is an example custom task definition and the java code that gets executed:

 

  <node name="task1" start="true">
    <arc name="toTask3" to="task3"/>
    <arc name="toEnd" to="end"/>
    <parameter name="onSuccess" value="toTask3" />
    <parameter name="onFailure" value="toEnd" />
    <lapis:extension qname="NODESET" xpath="/parameters/parameter" />
  </node>



    @Override
    public void execute(NodeToken token, Map<String, String> parameters) throws RemoteException {
        String who = null;
        try {
            who = token.getNode().getProperties().getProperty("who");
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        System.out.println("Hello " + who);
        try {
            token.complete(token.getNode().getProperties().getProperty("onSuccess")); // follow the successful route
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Hello world! There is still so much to do but this is making real progress.