camunda / camunda-modeler

An integrated modeling solution for BPMN, DMN and Forms based on bpmn.io.
https://camunda.com/products/modeler
MIT License
1.49k stars 475 forks source link

The editor is able to distinguish Zeebe and Camunda diagrams #2029

Closed nikku closed 3 years ago

nikku commented 3 years ago

What should we do?

In order to have a unified modeler, we must find a robust way to tell apart Zeebe and Camunda diagrams. That mechanism SHALL be independent of whether an implementation property/namespace exists on the document.

Why should we do it?

This is a core capability needed for a unified Camunda / Zeebe modeler

Things to investigate

Context child of https://github.com/bpmn-io/internal-docs/issues/216

pinussilvestrus commented 3 years ago

Things that came into my mind when thinking about this topic

I'm not 100% sure but I can remember that from the BPMN spec it would be allowed that multiple processes in a diagram could differ in that aspect. But I'm pretty sure that our Engines would never support it so we might ignore it and can save this metadata on the definitions level

Is there any generic BPMN elements that we can use for storing version information? Or do we have to invent a new XML namespace + extension to do it?

What we always could do is to misuse the documentation element

<bpmn:definitions>
  <documentation id="executionMetadata">CamundaBPM,7.15</documentation>
  <bpmn:process id="Process_0pt2xzy" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" />
  </bpmn:process>
</bpmn:definitions>
<bpmn:definitions>
  <documentation id="executionPlatform">CamundaBPM</documentation>
  <documentation id="executionPlatformVersion">7.15</documentation>
  <bpmn:process id="Process_0pt2xzy" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" />
  </bpmn:process>
</bpmn:definitions>
nikku commented 3 years ago

Are we assuming diagrams with multiple processes (BPMN) are always deploying to the same execution context?

Yes, we should. Everything else will become super hard to reason about by anyone, the app, the user.

pinussilvestrus commented 3 years ago

Simple CodeSandbox on how to use our existing namespace util to detect Zeebe diagrams: https://codesandbox.io/s/detect-namespace-d7cn9?file=/src/index.js (the same way we do to detect DMN 1.1 & DMN 1.2 files)

import { findUsages } from '../util/namespace';

const ZEEBE_NS = 'http://camunda.org/schema/zeebe/1.0';

const isZeebe = findUsages(xml, ZEEBE_NS);
nikku commented 3 years ago

As you look into this issue, please keep in mind that detection via the namespace may not be enough. These do not allow us to deduce a specific Camunda platform or Zeebe or Cloud version:

Resources (BPMN, DMN, CMMN, Form) contain meta-data about the execution platform and version targeted (i.e. Camunda BPM, v7.15, Camunda Cloud, xxx, Zeebe, v0.21.0)

pinussilvestrus commented 3 years ago

please keep in mind that detection via the namespace may not be enough

Yeah absolutely. I am just playing around with namespace detection due to the fallback scenario

Old diagrams without profile meta-data continue to open and are categorized on a best effort basis (i.e. by examining the used implementation namespaces; we could assume that diagrams with the camunda namespace are likely targeting a current (or previous) version of Camunda BPM. 3️⃣

barmac commented 3 years ago

Summary of decisions taken during the meeting with @pinussilvestrus and @nikku:

Thank you for your help.

barmac commented 3 years ago

When you open a file with no contents but with a known extension (e.g. file.bpmn), we use the same diagram as if you were to create a new diagram of that type. As part of this issue, I'd say we can safely use Camunda diagram per default, just like we want to use it as a fallback for missing executionPlatform.

barmac commented 3 years ago

What I've accomplished so far:

What is missing:

We also need to make a decision what namespace prefix we want to use: https://github.com/camunda/modeling-moddle.

pinussilvestrus commented 3 years ago

Some (quick) investigations regarding

Zeebe tab (currently I re-use Camunda without changes)

Since the camunda-modeler#BpmnEditor and zeebe-modeler#BpmnEditor only differ in some parts, but share a common code base, I wanted to figure out whether we can have a base BpmnEditor component, which both (Platform & Cloud) tab can rely on (cf. Diff Check).

Experiments went into: https://github.com/camunda/camunda-modeler/tree/base-bpmn-editor

tldr: It's doable, but needs a bit of refactoring. Generally, it seems okay if we would go with separate/independent editors for the first iteration, and live with the duplicated code.

One another point that makes it difficult to re-use the same BpmnEditor: We decided to ignore plugins for the Zeebe Tab completely.

Let's discuss this next week with @barmac and others.

pinussilvestrus commented 3 years ago

Summary of my work on top of https://github.com/camunda/camunda-modeler/issues/2029#issuecomment-778059880

Pull Request https://github.com/camunda/camunda-modeler/pull/2099

https://github.com/camunda/camunda-modeler/compare/2029-distinguish-camunda-and-zeebe-diagrams...2029-cloud-bpmn-tab

https://github.com/camunda/camunda-modeler/tree/2029-distinguish-camunda-and-zeebe-diagrams

Let's sync with @barmac and do the handover once he's back :+1: