NeedsHelp
NeedsHelp

Reputation: 437

JQuery / Activiti - How can I access the XML of the .bpmn file with JQuery .ajax()?

I'm new to AJAX and Activiti so I may be missing something obvious. I'm trying to access the XML of my process diagram using .ajax(). I keep getting a 404 Not Found error. Here's my code so far:

function getData() {

    $.ajax({

        type: "GET",
        url: "src/diagrams/ChangeControl.bpmn",
        dataType: "xml",
        success: function(data){

            xmlString = (new XMLSerializer()).serializeToString(data);
            $("#wrapper").html(xmlString);

        }

    });

}

getData();

(I set the XML to a String purely for testing purposes). I know that in Activiti there is a .bpmn20.xml file type but I don't know how to access such a file. As I said I'm new to this and I don't even know if using the .bpmn file is correct.

Upvotes: 0

Views: 381

Answers (1)

Greg Harley
Greg Harley

Reputation: 3240

Yup, This one is documented but not very well.

Retrieve the process definition using the following URL:

/service/repository/process-definitions/

This will return an element called "resource"..

Example Response Below:

{
"id": "BP3CreateTimersProcess:1:180035",
"url": "http://localhost:8080/activiti-rest/service/repository/process-definitions/BP3_Rocks_Process:1:180035",
"key": "BP3CreateTimersProcess",
"version": 1,
"name": "BP3 Create timers process",
"description": "Test process to create a number of timers.",
"tenantId": "",
"deploymentId": "180032",
"deploymentUrl": "http://localhost:8080/activiti-rest/service/repository/deployments/180032",
"resource": "http://localhost:8080/activiti-rest/service/repository/deployments/180032/resources/BP3_Rocks.bpmn20.xml",
"diagramResource": "http://localhost:8080/activiti-rest/service/repository/deployments/180032/resources/BP3_Rocks.BP3_Rocks_Process.png",
"category": "Examples",
"graphicalNotationDefined": true,
"suspended": false,
"startFormDefined": false
}

Resource actually points to a JSON description of the resource, so change resource to resourcedata:

$scope.getBPMNResource = function(process) {
  if(process.resource){
    return process.resource.replace("resources", "resourcedata");
  } else return null;
}

This gives you somethign like:

http://localhost:8080/activiti-rest/service/repository/deployments/180032/resourcedata/BP3_Rocks_Process.bpmn20.xml

This will return the BPMN XML for you. P.S. The above code excerpt is angular.

Upvotes: 1

Related Questions