Hi Kris
I am new to Drools. I didn't perform a test case from eclipse by using a
knowledge agent to load them from guvnor. Well I have a question after I
build the application on Guvnor should I do something like copythe .pkg to a
specific location or just restart the server and Launch the GWT console.
What I did is the following:
1- I uploaded a jar file of my process into Guvnor below is the sample java
file that i am using:
package com.fp;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.process.instance.impl.demo.SystemOutWorkItemHandler;
import org.drools.process.workitem.wsht.WSHumanTaskHandler;
import org.drools.runtime.StatefulKnowledgeSession;
public class TestDrools
{
public static final void main(String[] args)
{
try
{
System.out.println("\n\n\n ======== i am here ");
KnowledgeBase kbase = readKnowledgeBase();
// // create the entity manager factory and register it in the environment
// EntityManagerFactory emf =
// Persistence.createEntityManagerFactory(
"org.drools.persistence.jpa" );
// Environment env = KnowledgeBaseFactory.newEnvironment();
// env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
// env.set( EnvironmentName.TRANSACTION_MANAGER,
// TransactionManagerServices.getTransactionManager() );
//
// // create a new knowledge session that uses JPA to store the runtime
state
// StatefulKnowledgeSession ksession =
// JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env
);
final StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
// start the transaction
// UserTransaction ut =
// (UserTransaction) new InitialContext().lookup(
"java:comp/UserTransaction" );
// ut.begin();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new
WSHumanTaskHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Log", new
SystemOutWorkItemHandler());
// perform multiple commands inside one transaction
ksession.startProcess("testDroolsFlow");
//ksession.fireAllRules();
// commit the transaction
// ut.commit();
} catch (Throwable t)
{
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception
{
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("testDroolsFlow.rf"),
ResourceType.DRF);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0)
{
for (KnowledgeBuilderError error: errors)
{
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
}
2- uploading the process rule flow below is the .rf file that i am using:
<?xml version="1.0" encoding="UTF-8"?>
<process
xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process
drools-processes-5.0.xsd"
type="RuleFlow" name="testDroolsFlow"
id="testDroolsFlow"
package-name="default" >
<header>
</header>
<nodes>
<start id="1" name="Start" x="16" y="181"
width="80" height="40" />
<end id="3" name="End" x="527" y="173"
width="80" height="40" />
<humanTask id="4" name="Task1" x="95"
y="184" width="100" height="48" >
<work name="Human Task" >
<parameter name="ActorId" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>admin</value>
</parameter>
<parameter name="Comment" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>Confirm the Automation of the ToDo</value>
</parameter>
<parameter name="Content" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>Confirm the Automation of the ToDo</value>
</parameter>
<parameter name="Priority" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>1</value>
</parameter>
<parameter name="Skippable" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>false</value>
</parameter>
<parameter name="TaskName" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>Perform TODO</value>
</parameter>
</work>
</humanTask>
<workItem id="5" name="Log" x="397" y="176"
width="100" height="48" >
<work name="Log" >
<parameter name="Message" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>Test</value>
</parameter>
</work>
</workItem>
<humanTask id="6" name="Task2" x="242"
y="181" width="100" height="48" >
<work name="Human Task" >
<parameter name="ActorId" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>rami</value>
</parameter>
<parameter name="Comment" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>Start Procedure</value>
</parameter>
<parameter name="Content" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>Start Procedure</value>
</parameter>
<parameter name="Priority" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value></value>
</parameter>
<parameter name="Skippable" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>false</value>
</parameter>
<parameter name="TaskName" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>Activate Proc</value>
</parameter>
</work>
</humanTask>
</nodes>
<connections>
<connection from="5" to="3" />
<connection from="1" to="4" />
<connection from="6" to="5" />
<connection from="4" to="6" />
</connections>
</process>
3- building the default package and creating a snapshot.
4- restarting the JBOSS server and launching the console.
Are the steps that i am performing correct or is there something missing??
--
View this message in context:
http://old.nabble.com/Working-in-the-GWT-console-tp26387553p26388152.html
Sent from the drools - user mailing list archive at
Nabble.com.