-
1. Re: jBPM and semantic web
jocelyn.duc Feb 10, 2014 5:00 AM (in response to jocelyn.duc)Hello,
How and where are saved the task in/output? Any hints that may help?
Thanks
Jocelyn
-
2. Re: jBPM and semantic web
swiderski.maciej Feb 11, 2014 1:20 AM (in response to jocelyn.duc)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.
HTH
-
3. Re: jBPM and semantic web
jocelyn.duc Feb 11, 2014 3:47 AM (in response to swiderski.maciej)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 Feb 14, 2014 9:53 AM (in response to jocelyn.duc)Hello,
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 Feb 17, 2014 6:15 AM (in response to jocelyn.duc)Problem solved using a custom ResolverStrategy,
@Before public void prepare() { cleanupSingletonSessionId(); EntityManagerFactory emf = Persistence.createEntityManagerFactory("semantic"); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory .get() .newDefaultBuilder() .entityManagerFactory(emf) .userGroupCallback( new JBossUserGroupCallbackImpl("classpath:/usergroup.properties")) .addEnvironmentEntry( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, 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 Apr 7, 2014 6:39 AM (in response to jocelyn.duc)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 ?