6 Replies Latest reply on Apr 7, 2014 6:39 AM by Jocelyn Duc

    jBPM and semantic web

    Jocelyn Duc Novice



      I have to evaluate the possibilities of using jBPM 6 in a web semantic project. We have some users and data stored in an OpenRDF Sesame database (http://www.openrdf.org/). Currently, we use SparQL queries to CRUD the data.


      In our project, the main goal is to interact with the RDF database. So, the users will have to be able to do some request on jBPM powered business processes and the input/output of tasks must be read and written in the RDF database. The decisions concerning business rules will also have to be taken according to the data in the database RDF. In fact, I will use the jBPM engine with extern data.


      I am quite new in jBPM and I don't know the whole architecture of it yet. Till now, I only used the "demo" configuration. So, I need advice of experienced users. I don't know what is the best way to achieve this. What jBPM main component shall be modified?


      My question is still very vague, but I hope that you understood.





        • 1. Re: jBPM and semantic web
          Jocelyn Duc Novice



          How and where are saved the task in/output? Any hints that may help?





          • 2. Re: jBPM and semantic web
            Maciej Swiderski Master

            take a look here as it describes pluggable variable persistence in jBPM and I believe this is exactly what you're looking for. The example there shows how to use CMS/ECM over CMIS to store and retrieve any kind of documents so similar implementation could be provided by you that would store and retrieve data to and from openrdf data base.



            • 3. Re: jBPM and semantic web
              Jocelyn Duc Novice

              Thank you Maciej!


              Yes, it will help! Your blog post covers what I need. So, if I understand, the big job is to marshall/unmarshall object for my triplestore database.


              And how to import this new persistance strategy in an existing project? I understand the job it makes, but no how to use it... Remember, i am new on jBPM


              Is that solution applicable to the whole jBPM project? Or only process variable? My project specifications are not well defined yet, so maybe I will have to store ALL data in RDF format instead of the current H2 format.

              • 4. Re: jBPM and semantic web
                Jocelyn Duc Novice



                I had a meeting this morning and now I know what I have to do! In fact, I have to read and store only process variables form/in the triplestore database. Actually, only data that are used in UserTasks. So marshalling/unmarchalling external data as Maciej says is the best idea, IMHO.


                I registered a  custom SesameWorkItemHandler for Human Tasks. This new class seems to handle user tasks.


                KieSession ksession = createKnowledgeSession("basic.bpmn2");
                TaskService taskService = getTaskService();
                String serverURL = "http://localhost/openrdf-sesame";
                String repositoryName = "test";
                ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SesameWorkItemHandler(serverURL, repositoryName));
                Map<String, Object> params = new HashMap<String, Object>();
                // initialize variables here if necessary
                // params.put("variable1", value); // type String
                 ProcessInstance processInstance = ksession.startProcess("basic", params);
                // execute task
                String actorId = "krisv";
                List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner(actorId, "en-UK");
                TaskSummary task = list.get(0);
                taskService.start(task.getId(), actorId);
                Map<String, Object> results = new HashMap<String, Object>();
                // add results here
                // results.put("variable1_out", value); // type String
                taskService.complete(task.getId(), actorId, results);


                Unfortunately, line 16 gives me an IndexOutOfBoundsException because taskService returns an empty list.


                public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
                     System.out.println("SesameWorkItemHandler executeWorkItem()");
                     if (manager != null) {
                          Map<String, Object> results = new HashMap<String, Object>();
                          results.put("Result", "Sesame!");
                          manager.completeWorkItem(workItem.getId(), results);


                The user task is assigned to krisv. The following task is a simple hello world script task. Referring to Maciej's post, is there any job to do on the taskService or other class?


                And where/how to integrate/register my custom PlaceholderResolverStrategy?

                • 5. Re: Re: jBPM and semantic web
                  Jocelyn Duc Novice

                  Problem solved using a custom ResolverStrategy,


                  public void prepare() {
                       EntityManagerFactory emf = Persistence.createEntityManagerFactory("semantic");
                       RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory
                                 new JBossUserGroupCallbackImpl("classpath:/usergroup.properties"))
                                 new ObjectMarshallingStrategy[] {
                                      new SesamePlaceholderResolverStrategy(serverURL, repositoryName),
                                      new SerializablePlaceholderResolverStrategy(ClassObjectMarshallingStrategyAcceptor.DEFAULT) })
                            .addAsset(ResourceFactory.newClassPathResource("basic.bpmn2"), ResourceType.BPMN2).get();
                       manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);


                  Thank you Maciej.


                  I am currently not sure if I need to implement ManageVariablesProcessEventListener.beforeProcessCompleted(), for now, I can run my test without any problem.

                  • 6. Re: jBPM and semantic web
                    Jocelyn Duc Novice

                    I packaged my stragegy into a JAR, to add it in the dependencies folder, to prepare a ready to install solution.


                    This way works well for workitemhandlers and custom fields, but does this work for marshaling strategies? It seems my semantic strategy is not used/loaded. Where to register it into the jbpm-console runtime environment ?