[jboss-user] [jBPM] - Re: How to save history of the process in a database

Ashish Kumar do-not-reply at jboss.com
Wed Jun 20 07:03:14 EDT 2012


Ashish Kumar [https://community.jboss.org/people/ashish_kumar] created the discussion

"Re: How to save history of the process in a database"

To view the discussion, visit: https://community.jboss.org/message/743033#743033

--------------------------------------------------------------
I added that but it was asking to define getkbase().So I manupulated the code.Kindly have a look and advice me that how can I correct it.
Also tell me how can I test this concept.Where to find out the database in which the details are stored.

For your reference the code is as below:


package sample;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.persistence.jpa.JPAKnowledgeService;
import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.process.audit.JPAWorkingMemoryDbLogger;
import org.jbpm.test.JBPMHelper;

public class historyLog  {
 /**
  * @param args
  */
 public static void main(String[] args)  throws Exception {
  // TODO Auto-generated method stub
  //JBPMHelper.startH2Server();
  //JBPMHelper.setupDataSource();
  
  //EntityManagerFactory emf =
  //    Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" );

  org.drools.runtime.Environment env = KnowledgeBaseFactory.newEnvironment();
  KnowledgeBase kbase = readKnowledgeBase();
  
  //StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); 
  //JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);

  StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
  JPAWorkingMemoryDbLogger jbpmLogger = new JPAWorkingMemoryDbLogger(ksession);
  ksession.startProcess("sample.bpmn.hh");  
  jbpmLogger.dispose();
 
 }

 private static KnowledgeBase readKnowledgeBase() throws Exception {
  KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
  kbuilder.add(ResourceFactory.newClassPathResource("demo2.bpmn"), ResourceType.BPMN2);
  return kbuilder.newKnowledgeBase();
 }
 
}


--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/743033#743033]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120620/12fc6cbd/attachment.html 


More information about the jboss-user mailing list