Query taskButtons from Workflow RouteNode

Hi,

I've created a simple Workflow with a Node and two buttons (accept/reject). I try to request my node information specifically the availables buttons from a query automation but thoses params don't appear.

The NXQL query is “Select * from RouteNode where rnode:nodeId = 'Task7a0' and ecm:currentLifeCycleState = 'suspended'

The result from nxshell is the one below with properties task:Buttons available

 RouteNode -- Validation
    UID: b4243650-33f7-4de8-88fa-fe67145a84c0
    Path: /document-route-instances-root/2015/01/13/validation/Task7a0
    Type: RouteNode
    State: suspended
    Lock: none

DESCRIPTION
    Thank you for validating the document

PROPERTIES
    dc:contributors = []
    [...]
    rnode:taskAssigneesPermission = ReadWrite
    rnode:taskButtons = [name=reject label=reject filter= , name=validate label=validate filter= ]**
    rnode:taskDirective = Have a look and moderate this document
    [...]

I would like to get this rnode:taskButtons parameter in my automation request but only simple parameters are returns while taskButton is a list.

Is there a way to get these variables back?

Thanks in advance

1 votes

1 answers

2069 views

ANSWER



The way I use is now working so I can share my experience with you:

1/ Get the open tasks for my document with automation Context.GetOpenTasks

2/ for the TaskDocId just retrieved I fetch the document service.getDocument(new IdRef(taskDocId), true);

3/ Get the RouteNode declaration

  • get JSON from http://my.nuxe.server/nuxeo/site/api/v1/id/” + taskDocId
  • extract document.routing.step
  • get JSON from http://my.nuxe.server/nuxeo/site/api/v1/id/” + routingStepId
  • extract taskButtons from “properties”

this is my getRouteNode function with ugly exception management :(

   public RouteNode getRouteNode(String docId) {
    RouteNode node = null;
    try {
        DefaultSession session = (DefaultSession) getNuxeoClient().getSession();
        DocumentManager service = session.getAdapter(DocumentManager.class);
        String json = GET("http://my.nuxeo.server/nuxeo/site/api/v1/id/" + docId, session);

        JSONObject x = new JSONObject(json);
        try {
            JSONObject properties = x.getJSONObject("properties");
            JSONArray array = properties.getJSONArray("nt:task_variables");
            String routeNodeId = null;
            for (int i = 0; i < array.length(); i++) {
                JSONObject object = array.getJSONObject(i);
                if ("document.routing.step".equals(object.getString("key"))) {
                    routeNodeId = object.getString("value");
                    break;
                }

            }
            if (routeNodeId != null) {
                String routeNodeString = GET("http://my.nuxeo.server/nuxeo/site/api/v1/id/" + routeNodeId,
                        session);
                JSONObject routeNodeJson = new JSONObject(routeNodeString);
                JSONObject nodeProperties = routeNodeJson.getJSONObject("properties");

                Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create();
                node = gson.fromJson(nodeProperties.toString(), RouteNode.class);

            }
        } catch (Exception e) {
            Log.e(TAG, e.getMessage(), e);
        }
        ;

    } catch (Exception e) {
        e.printStackTrace();
    }
    return node;
}
0 votes