best grammar app

Savvion Document Dataslot – Add Documents Programmatically (Free Download Code)

Submitted by Abhishek on Sun, 2012-05-20 15:40
Progress SAvvion

Savvion Business Manager is a leading Business Process Management (BPM) Product. BPM Products provide several Data fields to store data values. One such happens to be Document Dataslots. Document Dataslots in Savvion can store one single document or multiple documents.  Adding document dataslots is very simple. You just add a dataslot from Designer which has type, document and add it as a field in your worktep. That’s it the document is available.

 

Problem comes in if you have a business case to add a document to this dataslot programmatically. This could be a case if you want some documents to be available by default for each submitted request.

 

This post will help you do that. Note this post assumes you are familiar with creating a process, adding performers, adding dataslots, deploying etc. If you are not, Please refer to other posts on the same.

 

What are we planning to do?

We are planning to put together a process which will four dataslots

  • First Name (Text)
  • Last Name (Text)
  • ID Proof (Single Document)
  • Other Documents (Multiple Documents)

The process starts with user providing First Name and Last Name.

After that there will be an adapter which will add a document “One.png” stored in “C:/documents”) folder on my server to the ID Proof Dataslot and documents “Two.png” and “Three.png” to the Other Documents Dataslot. After that there is a review workstep where you can verify if the documents got attached.

 

Lets get started.

 

Step 1: Define a Business Process

For the test we will define a simple Business Process.

  • Start Step
  • Document Manager Adapter
  • Review Workstep

  

Make creator the performer for the Review Workstep.

 

 

Now Add a performer  of type Adapter and add it to the workflow. Make sure you have clicked on “Generate java Code ”

 

Step 2: Add Dataslots

Now Add the required Dataslots one by one. First Add the Two Text Dataslots by clicking the Tab “Dataslots”  and then “New”

 

Similarly Add Last Name as a Text Dataslot. These are just there for dummy reasons, not really required.

Now Add the IDProof Dataslot which will be Single Document by clicking the Tab “Dataslots”  and then “New”

Now Add the Other Document dataslot as a Document Bundle

 

If you want to store a single document you choose "Single" If you want to store multiple documents in a single dataslot you will need to put it as a document bundle.

Step 3: Add Dataslots to Workstep/Adapters

Now we will add these fields to the various worksteps.

  • In the Start Step add First Name and Last Name
  • In the Adapter add All four Dataslots
  • In the review workstep Add all four Dataslots

Your Adapter property screen should look like:

 

Step 4: Work with the Adapter

Lets Start work with the adapter. Right click the adapter and click open. You will see Java Code. Since you have selected the various dataslots your Setters and Getters will be generated automatically.

public class DocumentManager {

      private String firstName;

      private DocumentDS iDProof;

      private String lastName;

      private DocumentDS otherDocuments;

 

      public String getFirstName() {

            return this.firstName;

      }

 

      public DocumentDS getIDProof() {

            return this.iDProof;

      }

 

      public String getLastName() {

            return this.lastName;

      }

 

      public DocumentDS getOtherDocuments() {

            return this.otherDocuments;

      }

 

      public void setFirstName(String firstName) {

            this.firstName= firstName;

      }

 

      public void setIDProof(DocumentDS iDProof) {

            this.iDProof= iDProof;

      }

You will need to write code in the manager() method as this

public void manage() throwsException{

            // Lets add a document to the ID Proof

            System.out.println("Adding Documents ..");

            File f1=new File("c:\\documents\\One.png");

            File f2=new File("c:\\documents\\Two.png");

            File f3=new File("c:\\documents\\Three.png");

           

            File[] idProof={f1};

            this.iDProof.create("ebms", idProof);

           

            File[] otherdocs={f2,f3};

            this.otherDocuments.create("ebms", otherdocs);

            System.out.println("Done");

           

      }

Here we are doing the following

  • Creating three java.io.File Object to access the three files
  • Creating an Array to store One.png
  • Adding the File to the Dataslot by calling the create method. Please note the first parameter is the user. For testing I have put it as ebms. You can actually pass @creator to the adapter and use that.
  • Add one more Array that stores two files Two.png and Three.png
  • Add this array to the “otherDocuments” Dataslots

You will need to add “sdms.jar” to your classpath from the SBM_HOME/libs to compile this code. You can do that by

  • copying sdms.jar to the libs folder of you project
  • Right click > Properties on your Project
  • In the Libraries Tab click on “Add Jar” and choose the sdms.jar

You Screen should look something like this

   

NOTE: Make sure you have created a folder called “documents” in the C: of your Server. Feel free to modify the path passed in the file parameter to any place where the document is.

A Closer look at the API Docs will reveal that the following are supported

 

Array Of Files

create(java.lang.String user, java.io.File[] files)

 

Single File with a Document Name and Attributes

create(java.lang.String user, java.lang.String docName, java.io.File file, java.util.Map<java.lang.String,java.lang.Object> attributes)

 

An Input Stream with Document Name and Attributes

create(java.lang.String user, java.lang.String docName, java.io.InputStream is, java.util.Map<java.lang.String,java.lang.Object> attributes)

 

A URL With Document Name and Attributes

create(java.lang.String user, java.lang.String docName, java.net.URL srcURL, java.util.Map<java.lang.String,java.lang.Object> attributes)

 

Step 5: Deploy the Process

Lets Deploy the Process. Click on the Deploy Button, Provide you username, password, Deploy URL and Follow the Wizard

Also make sure you have created a Folder called documents in your C: and added the three JPG Files.

 

Step 6: Test the Process

To Test the Process, Login to Savvion Business Manager and go to the Applications Tab and Choose “DocumentExample” process. You will see the first Screen like

Fill in the First Name, Last Name and hit create. A Task should get Created.

Now go to the task list and choose the Document Example task item

 

The Task Opens like the screen below

 

 

Click on File(s) button next to the ID Proof and you will see the file attached in Popup. Bingo!!

 

 

Now Click on File(s) button next to the Supporting Documents dataslot and you will see a popup like the one below

TroubleShooting

If your results were different or not coming at all, try some of these pointers

  • Make sure you have copied the files to the right location
  • Make sure the file Names are correct
  • Make sure you have added the right libraries and deployed correctly

Make sure you have assigned  “creator” as the performer and created the request as “ebms”. If you created as someone else, you will need to pass that name as the first parameter in the “create” call in your adapter

 

If you still face issues, feel free to reach out to me.

You can download the source code of this project Here

Questions and Suggestions are welcome

If you like this post, You may also like


Abhishek Mishra
Good experience in working with BPM technologies like Savvion, JBPM. Founder and Chief Editor of BPMGeek.com. Founder of Savvion Business Manager Mobility Framework Savmobify| View my BPMGeek Profile
|
best grammar app

About BPMGeek

BPMGeek is an initiative to collaborate and communicate with the growing Business process management community out there. The goal is to help developers connect with experts, ask questions, post their learning and get understanding of BPM Concepts. Often tool specific knowledge of niche areas end up developers perplexed and confused - especially when there are very less number of resources available. We will be coming up several several new features. Have a look at our Roadmap here

BPMGeek is an independent entity not associated with any Product. All BPM product professionals are invited to contribute. The Logos and Names used across the site belong to their respective owners. The viewpoints mentioned by Individual contributors are their own. BPMgeek cannot be held liable for any issues arising out of it.


BPMgeek is promoting the Nounshoun English Grammar App - developed by Constellation Software.