Ok, do not mind about the second question. Found an answer here:
http://community.jboss.org/thread/163523
Hi Julio,
If you want to upload a knowledge base which includes the process definitions from guvnor repository the code you require is the following:
ProcessBuilderFactory.setProcessBuilderFactoryService(new ProcessBuilderFactoryServiceImpl());
ProcessMarshallerFactory.setProcessMarshallerFactoryService(new ProcessMarshallerFactoryServiceImpl()); ProcessRuntimeFactory.setProcessRuntimeFactoryService(new ProcessRuntimeFactoryServiceImpl());
BPMN2ProcessFactory.setBPMN2ProcessProvider(new BPMN2ProcessProviderImpl());
KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("testKAgent", aconf);
kagent.applyChangeSet(
ResourceFactory.newUrlResource(
"http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor"
+ "/package/defaultPackage/LATEST/ChangeSet.xml"));
And then you take the knowledgeBase from the KnowledgeAgent like this :
KnowledgeBase kbase = kagent.getKnowledgeBase();
In order to take the process you want from within the knowledgeBase you create a knowledgeSession :
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(kbase, config, env);
And finally something like "ksession.getProcessInstances()" will gine you the collection of all the processes that lie inside the guvnor repository.
Regards,
Vasiliki.