DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Retrieval Augmented Generation With Spring AI 2.0, Claude, and PGvector
  • Building High‑Precision Vector Search for Document Retrieval on Databricks
  • How to Detect Spam Content in Documents Using C#
  • Responsible AI Is an Engineering Problem, not a Policy Document

Trending

  • AGENTS.md Makes Your Java Codebase AI-Agent Ready
  • Why SQL Server Applications Break on PostgreSQL and How Compatibility Layers Fix It
  • Lift-and-Shift vs. Modernize: A Decision Framework for Enterprise Workloads
  • The Invisible OOMKill: Why Your Java Pod Keeps Restarting in Kubernetes

How to Attach a Document to BPMN Process In jBPM 7

There are multiple cases where we have to attached a document to BPMN process in the process execution. Here are the steps for doing so in jBPM 7.

By 
Abhijit Humbe user avatar
Abhijit Humbe
·
Jul. 27, 20 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
3.5K Views

Join the DZone community and get the full member experience.

Join For Free

Multiple times we have to attach docuemnt to BPMN process which is part of process execution or if its required to perform HumanTask operation. Here are the steps for attaching Document to BPMN process in jBPM 7. 

  • In the kie-workbench, in project settings goto  deployment-descriptor file(kie-deployment-descriptor.xml)  and define the marshalling strategy for document
    • XML
       




      xxxxxxxxxx
      1


       
      1
      <marshalling-strategies>
      2
        <marshalling-strategy>
      3
        <resolver>mvel</resolver>
      4
        <identifier>new  org.jbpm.document.marshalling.DocumentCollectionImplMarshallingStrategy(new org.jbpm.document.marshalling.DocumentMarshallingStrategy())</identifier>
      5
         <parameters/>
      6
         </marshalling-strategy>
      7
      </marshalling-strategies>


  • Define process variable of type org.jbpm.document.DocumentCollection.

'DocumentCollectionImplMarshallingStrategy' and process variable of type 'org.jbpm.document.DocumentCollection'  support use of multiple documents in BPMN process, i.e at a time you can upload multiple documents while starting process/case execution or while performing task operation. For single document, we can use process variable of type 'org.jbpm.document.Document' with marshalling strategy 'org.jbpm.document.marshalling.DocumentMarshallingStrategy'.   

How to Pass a Document While Starting Process Execution

  • If you are using kie-workbench/business-central console to start process then you can create process form where you will have to browse through the system and upload the document while starting process instance.
  • If you want to use JAVA code to start it then you can use DocumentInstance API's for same, like as:
    • Java
       




      xxxxxxxxxx
      1
      14


       
      1
      DocumentInstance documentInstance = new DocumentInstance();
      2
      documentInstance.setIdentifier("myDoc");
      3
      documentInstance.setName("doc.pdf");
      4
      java.net.URL docURL = new java.net.URL("file:///path/to/uploadDoc.pdf");
      5
      documentInstance.setLink(String.valueOf(docURL));
      6
      documentInstance.setLastModified(java.util.Calendar.getInstance().getTime());
      7
      final InputStream inputStream = new java.io.FileInputStream("path/to/uploadDoc.pdf");
      8
      byte[] content = org.apache.commons.io.IOUtils.toByteArray(inputStream);
      9
      documentInstance.setContent(content);
      10
      
                    
      11
      Map<String, Object> processVars = new HashMap<String, Object>();
      12
      processVars.put("document_ProcessVariable", documentInstance);
      13
      
                    
      14
      long pid = processClient.startProcess(ContainerId, "DocuemntTest", processVars);


  •  When we send request to start process payload will look like as:
    • JSON
       




      x


       
      1
      {
      2
        "document" : {
      3
          "org.jbpm.document.service.impl.DocumentImpl":{
      4
             "identifier":"myDoc.pdf",
      5
             "name":"Doc.pdf",
      6
             "link":"",
      7
             "size": 53,
      8
             "lastModified" : 45,
      9
             "content":"......."
      10
          }
      11
        },
      12
      "docName":"uploadDoc.pdf",
      13
      "comments": "your comments"
      14
      }
      15
      `


Document

Opinions expressed by DZone contributors are their own.

Related

  • Retrieval Augmented Generation With Spring AI 2.0, Claude, and PGvector
  • Building High‑Precision Vector Search for Document Retrieval on Databricks
  • How to Detect Spam Content in Documents Using C#
  • Responsible AI Is an Engineering Problem, not a Policy Document

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook