AnsweredAssumed Answered

Versioning bpmn file independently of VCS

Question asked by zze_one on Mar 3, 2014
Latest reply on Jun 17, 2014 by jbarrez

I would like to share with you guys part of a proof of concept I implemented, in order to have your point of view.

The final goal :
Pairing a set of rules to a workflow while being able to modify the workflow without redeploying the application.

I have been focusing on the versioning of the bpmn file so far (so I'm not talking about the deployed version).
I know that the normal way of managing the version of the file is to rely on the Version Control System, but one of the requirement is for the bpmn file to know about its version number. Meaning that the file should contain the manually added version.

So this is my implementation :
In the bpmn file I added a textAnnotation element identified by "versionNumber", that contains our customized value :

   <textAnnotation id="versionNumber">

Before each deployment I'm parsing the file in order to make sure that the value is there and is correct.   
The deployment won't happen if it's not the case.

This value is easily stored and can be retrieved thanks to the following method.

   @RequestMapping(value = "/artifactVersion", method = RequestMethod.GET, produces = "application/json")
   public ResponseEntity<Object> getArtifactVersion(String key){
      StringBuilder response = new StringBuilder();
      try {
         ProcessEngine processEngine = getProcessEngine(); //private method
         RepositoryService repositoryService = processEngine.getRepositoryService();
         String lastDeployedId = getLatestDeployedProcessId(key);
         BpmnModel model = repositoryService.getBpmnModel(lastDeployedId);
         TextAnnotation versionArtifact = (TextAnnotation) model.getArtifact("versionNumber");
         response.append("Artifact version of bpmn file: " + versionArtifact.getText());
         return new ResponseEntity<Object>(response.toString(), HttpStatus.OK);
      } catch (Exception t) {
         return new ResponseEntity<Object>(response.toString(), HttpStatus.BAD_REQUEST);
      } catch (Throwable t) {
         return new ResponseEntity<Object>(response.toString(), HttpStatus.INTERNAL_SERVER_ERROR);

I don't think this is a practice that you recommend but it's in my mind a good enough solution.
I would like to hear from more experienced developers about the limits of this solution and of course about any alternatives to this implementation.

Thanks a lot in advance,