Edit activiti model (json) from bpmn-js

Hi,

We are using activiti-rest to create model and retrieve the editor source which come as JSON string.
Is there a way to edit this BPMN json format with the bpmn-js ? Or to convert the JSON format to XML ?

Here is the format provided by activiti-rest while calling /activiti-rest/service/repository/models/{modelID}/source

{
    "bounds": {
        "lowerRight": {
            "x": 1485.0,
            "y": 700.0
        },
        "upperLeft": {
            "x": 0.0,
            "y": 0.0
        }
    },
    "resourceId": "canvas",
    "stencil": {
        "id": "BPMNDiagram"
    },
    "stencilset": {
        "namespace": "http://b3mn.org/stencilset/bpmn2.0#",
        "url": "../editor/stencilsets/bpmn2.0/bpmn2.0.json"
    },
    "properties": {
        "process_id": "process",
        "process_namespace": "http://www.activiti.org/processdef",
        "messages": [],
        "executionlisteners": {
            "executionListeners": []
        },
        "eventlisteners": {
            "eventListeners": []
        },
        "signaldefinitions": [],
        "messagedefinitions": []
    },
    "childShapes": [
        {
            "bounds": {
                "lowerRight": {
                    "x": 169.0,
                    "y": 134.5
                },
                "upperLeft": {
                    "x": 138.0,
                    "y": 103.5
                }
            },
            "resourceId": "sid-00E949EE-E48A-4406-A558-290C0EDB3018",
            "childShapes": [],
            "stencil": {
                "id": "StartTimerEvent"
            },
            "properties": {
                "overrideid": "sid-00E949EE-E48A-4406-A558-290C0EDB3018"
            },
            "outgoing": [
                {
                    "resourceId": "sid-154F08A3-7BB1-4F8F-965E-93C4B922B32A"
                }
            ]
        },
        {
            "bounds": {
                "lowerRight": {
                    "x": 355.0,
                    "y": 159.0
                },
                "upperLeft": {
                    "x": 255.0,
                    "y": 79.0
                }
            },
            "resourceId": "sid-C0402D61-E2FD-4975-849B-DB1AA5DC2C0C",
            "childShapes": [],
            "stencil": {
                "id": "UserTask"
            },
            "properties": {
                "overrideid": "sid-C0402D61-E2FD-4975-849B-DB1AA5DC2C0C",
                "name": "Etape 2 ",
                "asynchronousdefinition": false,
                "exclusivedefinition": true,
                "tasklisteners": {
                    "taskListeners": []
                },
                "executionlisteners": {
                    "executionListeners": []
                }
            },
            "outgoing": [
                {
                    "resourceId": "sid-CC3FF232-9362-452C-A310-40DCCE71BC79"
                }
            ]
        },
        {
            "bounds": {
                "lowerRight": {
                    "x": 625.0,
                    "y": 170.0
                },
                "upperLeft": {
                    "x": 525.0,
                    "y": 90.0
                }
            },
            "resourceId": "sid-1EAAC56A-C4F1-43E3-8539-53F7C49AA748",
            "childShapes": [],
            "stencil": {
                "id": "ReceiveTask"
            },
            "properties": {
                "overrideid": "sid-1EAAC56A-C4F1-43E3-8539-53F7C49AA748",
                "asynchronousdefinition": false,
                "exclusivedefinition": true,
                "executionlisteners": {
                    "executionListeners": []
                }
            },
            "outgoing": [
                {
                    "resourceId": "sid-AFE557F0-7BA9-4B17-BF5B-A15FF6CFBAFA"
                }
            ]
        },
        {
            "bounds": {
                "lowerRight": {
                    "x": 172.0,
                    "y": 212.0
                },
                "upperLeft": {
                    "x": 128.0,
                    "y": 212.0
                }
            },
            "resourceId": "sid-154F08A3-7BB1-4F8F-965E-93C4B922B32A",
            "childShapes": [],
            "stencil": {
                "id": "SequenceFlow"
            },
            "dockers": [
                {
                    "x": 15.5,
                    "y": 15.5
                },
                {
                    "x": 50.0,
                    "y": 40.0
                }
            ],
            "outgoing": [
                {
                    "resourceId": "sid-C0402D61-E2FD-4975-849B-DB1AA5DC2C0C"
                }
            ],
            "target": {
                "resourceId": "sid-C0402D61-E2FD-4975-849B-DB1AA5DC2C0C"
            },
            "properties": {
                "overrideid": "sid-154F08A3-7BB1-4F8F-965E-93C4B922B32A"
            }
        },
        {
            "bounds": {
                "lowerRight": {
                    "x": 793.0,
                    "y": 147.0
                },
                "upperLeft": {
                    "x": 765.0,
                    "y": 119.0
                }
            },
            "resourceId": "sid-EE64FFF2-CE0F-49FE-95E1-E5A07514767D",
            "childShapes": [],
            "stencil": {
                "id": "EndTerminateEvent"
            },
            "properties": {
                "overrideid": "sid-EE64FFF2-CE0F-49FE-95E1-E5A07514767D"
            },
            "outgoing": []
        },
        {
            "bounds": {
                "lowerRight": {
                    "x": 172.0,
                    "y": 212.0
                },
                "upperLeft": {
                    "x": 128.0,
                    "y": 212.0
                }
            },
            "resourceId": "sid-AFE557F0-7BA9-4B17-BF5B-A15FF6CFBAFA",
            "childShapes": [],
            "stencil": {
                "id": "SequenceFlow"
            },
            "dockers": [
                {
                    "x": 50.0,
                    "y": 40.0
                },
                {
                    "x": 14.0,
                    "y": 14.0
                }
            ],
            "outgoing": [
                {
                    "resourceId": "sid-EE64FFF2-CE0F-49FE-95E1-E5A07514767D"
                }
            ],
            "target": {
                "resourceId": "sid-EE64FFF2-CE0F-49FE-95E1-E5A07514767D"
            },
            "properties": {
                "overrideid": "sid-AFE557F0-7BA9-4B17-BF5B-A15FF6CFBAFA"
            }
        },
        {
            "bounds": {
                "lowerRight": {
                    "x": 431.0,
                    "y": 134.5
                },
                "upperLeft": {
                    "x": 400.0,
                    "y": 103.5
                }
            },
            "resourceId": "sid-67EFD61B-61B7-4352-BE3E-A8AD92C1DB3F",
            "childShapes": [],
            "stencil": {
                "id": "CatchTimerEvent"
            },
            "properties": {
                "overrideid": "sid-67EFD61B-61B7-4352-BE3E-A8AD92C1DB3F",
                "timercycledefinition": "2"
            },
            "outgoing": [
                {
                    "resourceId": "sid-07A744D6-F6DF-4150-94D5-1D895BD0F31E"
                }
            ]
        },
        {
            "bounds": {
                "lowerRight": {
                    "x": 172.0,
                    "y": 212.0
                },
                "upperLeft": {
                    "x": 128.0,
                    "y": 212.0
                }
            },
            "resourceId": "sid-CC3FF232-9362-452C-A310-40DCCE71BC79",
            "childShapes": [],
            "stencil": {
                "id": "SequenceFlow"
            },
            "dockers": [
                {
                    "x": 50.0,
                    "y": 40.0
                },
                {
                    "x": 15.5,
                    "y": 15.5
                }
            ],
            "outgoing": [
                {
                    "resourceId": "sid-67EFD61B-61B7-4352-BE3E-A8AD92C1DB3F"
                }
            ],
            "target": {
                "resourceId": "sid-67EFD61B-61B7-4352-BE3E-A8AD92C1DB3F"
            },
            "properties": {
                "overrideid": "sid-CC3FF232-9362-452C-A310-40DCCE71BC79"
            }
        },
        {
            "bounds": {
                "lowerRight": {
                    "x": 172.0,
                    "y": 212.0
                },
                "upperLeft": {
                    "x": 128.0,
                    "y": 212.0
                }
            },
            "resourceId": "sid-07A744D6-F6DF-4150-94D5-1D895BD0F31E",
            "childShapes": [],
            "stencil": {
                "id": "SequenceFlow"
            },
            "dockers": [
                {
                    "x": 15.5,
                    "y": 15.5
                },
                {
                    "x": 50.0,
                    "y": 40.0
                }
            ],
            "outgoing": [
                {
                    "resourceId": "sid-1EAAC56A-C4F1-43E3-8539-53F7C49AA748"
                }
            ],
            "target": {
                "resourceId": "sid-1EAAC56A-C4F1-43E3-8539-53F7C49AA748"
            },
            "properties": {
                "overrideid": "sid-07A744D6-F6DF-4150-94D5-1D895BD0F31E"
            }
        }
    ]
}

Best.

This is not a valid BPMN XML. If you convert this JSON to a valid BPMN XML you can edit it with bpmn-js.

1 Like