How to execute a Process API result?

19 messages Options
Embed this post
Permalink
Scott Stevenson-6

How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
I'm trying to execute the result of the Process API and running into
problems most likely stemming from my ignorance. I'm creating a new
process following the sample code from section 3.1.3.2 of the User
Guide. My sample process consists of:
1. StartNode
2. ActionNode that prints Hello World
3. EndNode

What I don't understand is how to get my new process into a
KnowledgeBase and KnowledgeSession for execution. I've tried the
following (Drools 4 method, I believe) as well:

        AbstractRuleBase ruleBase = (AbstractRuleBase)
RuleBaseFactory.newRuleBase();
        ruleBase.addProcess(createProcess());
        InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1,
ruleBase);
       
workingMemory.startProcess("org.drools.sample.workflow.dynamic");

The result of the previous code is a RuntimeException (unable to execute
Action). Inner exception is null pointer from inside the
ActionNodeInstance class. Where am going wrong in implementing the
Process API?

Thank you,
Scott Stevenson

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
salaboy

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
Are you working just with the Drools 4 version?
Or you can jump to the Drools 5 version?

On Mon, Nov 2, 2009 at 5:41 PM, Scott Stevenson <[hidden email]> wrote:
I'm trying to execute the result of the Process API and running into
problems most likely stemming from my ignorance. I'm creating a new
process following the sample code from section 3.1.3.2 of the User
Guide. My sample process consists of:
1. StartNode
2. ActionNode that prints Hello World
3. EndNode

What I don't understand is how to get my new process into a
KnowledgeBase and KnowledgeSession for execution. I've tried the
following (Drools 4 method, I believe) as well:

       AbstractRuleBase ruleBase = (AbstractRuleBase)
RuleBaseFactory.newRuleBase();
       ruleBase.addProcess(createProcess());
       InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1,
ruleBase);

workingMemory.startProcess("org.drools.sample.workflow.dynamic");

The result of the previous code is a RuntimeException (unable to execute
Action). Inner exception is null pointer from inside the
ActionNodeInstance class. Where am going wrong in implementing the
Process API?

Thank you,
Scott Stevenson

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users



--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Scott Stevenson-6

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

I’m working with Drools 5.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 1:45 PM
To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

Are you working just with the Drools 4 version?
Or you can jump to the Drools 5 version?

On Mon, Nov 2, 2009 at 5:41 PM, Scott Stevenson <[hidden email]> wrote:

I'm trying to execute the result of the Process API and running into
problems most likely stemming from my ignorance. I'm creating a new
process following the sample code from section 3.1.3.2 of the User
Guide. My sample process consists of:
1. StartNode
2. ActionNode that prints Hello World
3. EndNode

What I don't understand is how to get my new process into a
KnowledgeBase and KnowledgeSession for execution. I've tried the
following (Drools 4 method, I believe) as well:

       AbstractRuleBase ruleBase = (AbstractRuleBase)
RuleBaseFactory.newRuleBase();
       ruleBase.addProcess(createProcess());
       InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1,
ruleBase);

workingMemory.startProcess("org.drools.sample.workflow.dynamic");

The result of the previous code is a RuntimeException (unable to execute
Action). Inner exception is null pointer from inside the
ActionNodeInstance class. Where am going wrong in implementing the
Process API?

Thank you,
Scott Stevenson

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
salaboy

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
Ok, so you need to start using the Drools 5 APIs.
Please take a look at the Drools 5 documentation:
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-flow/html_single/index.html#d0e1375

In the section 3.2

Using a Process in Your Application


you will find the correct api's.
Greetings.

2009/11/2 Scott Stevenson <[hidden email]>

I’m working with Drools 5.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 1:45 PM
To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

Are you working just with the Drools 4 version?
Or you can jump to the Drools 5 version?

On Mon, Nov 2, 2009 at 5:41 PM, Scott Stevenson <[hidden email]> wrote:

I'm trying to execute the result of the Process API and running into
problems most likely stemming from my ignorance. I'm creating a new
process following the sample code from section 3.1.3.2 of the User
Guide. My sample process consists of:
1. StartNode
2. ActionNode that prints Hello World
3. EndNode

What I don't understand is how to get my new process into a
KnowledgeBase and KnowledgeSession for execution. I've tried the
following (Drools 4 method, I believe) as well:

       AbstractRuleBase ruleBase = (AbstractRuleBase)
RuleBaseFactory.newRuleBase();
       ruleBase.addProcess(createProcess());
       InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1,
ruleBase);

workingMemory.startProcess("org.drools.sample.workflow.dynamic");

The result of the previous code is a RuntimeException (unable to execute
Action). Inner exception is null pointer from inside the
ActionNodeInstance class. Where am going wrong in implementing the
Process API?

Thank you,
Scott Stevenson

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Scott Stevenson-6

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

I read that section but I’m still not clear how to add my process (created like the section just before) to the KnowledgeBase. Section 3.2 shows adding an existing .rf file.  I have this code:

 

RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess("org.drools.sample.workflow.dynamic");

                factory

                    .name("HelloWorldRuleSet")

                    .version("1.0")

                    .packageName("org.drools")

                    .startNode(1).name("Start").done()

                    .actionNode(2)

                        .name("Action")

                        .action("java", "System.out.println(\"Inside Action 1\");").done()

                    .endNode(3).name("End").done()

                    .connection(1, 2)

                    .connection(2, 3);

                factory.validate().getProcess();

 

How does the getProcess() result get added to a KnowledgeBase?

 

Thanks,

Scott

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 1:57 PM
To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

Ok, so you need to start using the Drools 5 APIs.
Please take a look at the Drools 5 documentation:
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-flow/html_single/index.html#d0e1375

In the section 3.2

Using a Process in Your Application


you will find the correct api's.
Greetings.

2009/11/2 Scott Stevenson <[hidden email]>

I’m working with Drools 5.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 1:45 PM
To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

Are you working just with the Drools 4 version?
Or you can jump to the Drools 5 version?

On Mon, Nov 2, 2009 at 5:41 PM, Scott Stevenson <[hidden email]> wrote:

I'm trying to execute the result of the Process API and running into
problems most likely stemming from my ignorance. I'm creating a new
process following the sample code from section 3.1.3.2 of the User
Guide. My sample process consists of:
1. StartNode
2. ActionNode that prints Hello World
3. EndNode

What I don't understand is how to get my new process into a
KnowledgeBase and KnowledgeSession for execution. I've tried the
following (Drools 4 method, I believe) as well:

       AbstractRuleBase ruleBase = (AbstractRuleBase)
RuleBaseFactory.newRuleBase();
       ruleBase.addProcess(createProcess());
       InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1,
ruleBase);

workingMemory.startProcess("org.drools.sample.workflow.dynamic");

The result of the previous code is a RuntimeException (unable to execute
Action). Inner exception is null pointer from inside the
ActionNodeInstance class. Where am going wrong in implementing the
Process API?

Thank you,
Scott Stevenson

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
salaboy

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
That are only the fluent api to create processes. I recommend you the other approach:

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource("MyProcess.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());

StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();


ksession.startProcess("com.sample.MyProcess");


If you need the reference to the process instance you can do:
WorkFlowProcessInstance processInstance = ksession.startProcess(...);



Work
2009/11/2 Scott Stevenson <[hidden email]>

I read that section but I’m still not clear how to add my process (created like the section just before) to the KnowledgeBase. Section 3.2 shows adding an existing .rf file.  I have this code:

 

RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess("org.drools.sample.workflow.dynamic");

                factory

                    .name("HelloWorldRuleSet")

                    .version("1.0")

                    .packageName("org.drools")

                    .startNode(1).name("Start").done()

                    .actionNode(2)

                        .name("Action")

                        .action("java", "System.out.println(\"Inside Action 1\");").done()

                    .endNode(3).name("End").done()

                    .connection(1, 2)

                    .connection(2, 3);

                factory.validate().getProcess();

 

How does the getProcess() result get added to a KnowledgeBase?

 

Thanks,

Scott

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 1:57 PM


To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

Ok, so you need to start using the Drools 5 APIs.
Please take a look at the Drools 5 documentation:
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-flow/html_single/index.html#d0e1375

In the section 3.2

Using a Process in Your Application


you will find the correct api's.
Greetings.

2009/11/2 Scott Stevenson <[hidden email]>

I’m working with Drools 5.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 1:45 PM
To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

Are you working just with the Drools 4 version?
Or you can jump to the Drools 5 version?

On Mon, Nov 2, 2009 at 5:41 PM, Scott Stevenson <[hidden email]> wrote:

I'm trying to execute the result of the Process API and running into
problems most likely stemming from my ignorance. I'm creating a new
process following the sample code from section 3.1.3.2 of the User
Guide. My sample process consists of:
1. StartNode
2. ActionNode that prints Hello World
3. EndNode

What I don't understand is how to get my new process into a
KnowledgeBase and KnowledgeSession for execution. I've tried the
following (Drools 4 method, I believe) as well:

       AbstractRuleBase ruleBase = (AbstractRuleBase)
RuleBaseFactory.newRuleBase();
       ruleBase.addProcess(createProcess());
       InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1,
ruleBase);

workingMemory.startProcess("org.drools.sample.workflow.dynamic");

The result of the previous code is a RuntimeException (unable to execute
Action). Inner exception is null pointer from inside the
ActionNodeInstance class. Where am going wrong in implementing the
Process API?

Thank you,
Scott Stevenson

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Vijay K Pandey

Drools Flow BAM Module(5.1.0.M1) - Why primary key's are of string/varchar type

Reply Threaded More More options
Print post
Permalink
In reply to this post by salaboy
Some javascript/style in this post has been disabled (why?)

I am using Drools Flow BAM (5.1.0.M1) module to store the processes instances for audit purpose. I generated the DDL with the help of Hibernate Tools against the MYSQL 5.1(INNODB)

 

DDL for the 2 tables are given below -- the interesting part is the “id” column as “varchar” ---- this gives error when we try to execute the DDL against the mysql.

 

   create table AUDIT_NODE_INSTANCE_LOG (

        id varchar(255) not null auto_increment,

        type integer,

        nodeInstanceId varchar(255),

        nodeId varchar(255),

        processInstanceId bigint,

        processId varchar(255),

        DATE datetime,

        primary key (id)

    ) ENGINE=InnoDB;

 

    create table AUDIT_PROCESS_INSTANCE_LOG (

        id varchar(255) not null auto_increment,

        processInstanceId bigint,

        processId varchar(255),

        START_DATE datetime,

        END_DATE datetime,

        primary key (id)

    ) ENGINE=InnoDB;

 

The error we get is

 

Error: Incorrect column specifier for column 'id'

SQLState:  42000

ErrorCode: 1063

Error occured in:

create table AUDIT_NODE_INSTANCE_LOG (

        id varchar(255) not null auto_increment,

        type integer,

        nodeInstanceId varchar(255),

        nodeId varchar(255),

        processInstanceId bigint,

        processId varchar(255),

        DATE datetime,

        primary key (id)

    ) ENGINE=InnoDB

 

I used a naming strategy for the hibernate that’s why the above table names.

 

My question is when the primary key generation is “native” why not let these columns be of  type ‘long’ and get generated as “bigint” for the sql type.

 

If they can’t be changed – should we just extend the above classes and have these fields as long/bigint.

 

Any suggestion will be appreciated.

 

Thanks

Vijay


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Scott Stevenson-6

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
In reply to this post by salaboy
Some javascript/style in this post has been disabled (why?)

Right, I want to use the Fluent API to create dynamic processes.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 2:14 PM
To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

That are only the fluent api to create processes. I recommend you the other approach:

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource("MyProcess.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());

StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();


ksession.startProcess("com.sample.MyProcess");


If you need the reference to the process instance you can do:
WorkFlowProcessInstance processInstance = ksession.startProcess(...);



Work

2009/11/2 Scott Stevenson <[hidden email]>

I read that section but I’m still not clear how to add my process (created like the section just before) to the KnowledgeBase. Section 3.2 shows adding an existing .rf file.  I have this code:

 

RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess("org.drools.sample.workflow.dynamic");

                factory

                    .name("HelloWorldRuleSet")

                    .version("1.0")

                    .packageName("org.drools")

                    .startNode(1).name("Start").done()

                    .actionNode(2)

                        .name("Action")

                        .action("java", "System.out.println(\"Inside Action 1\");").done()

                    .endNode(3).name("End").done()

                    .connection(1, 2)

                    .connection(2, 3);

                factory.validate().getProcess();

 

How does the getProcess() result get added to a KnowledgeBase?

 

Thanks,

Scott

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 1:57 PM


To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

Ok, so you need to start using the Drools 5 APIs.
Please take a look at the Drools 5 documentation:
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-flow/html_single/index.html#d0e1375

In the section 3.2

Using a Process in Your Application


you will find the correct api's.
Greetings.

2009/11/2 Scott Stevenson <[hidden email]>

I’m working with Drools 5.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 1:45 PM
To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

Are you working just with the Drools 4 version?
Or you can jump to the Drools 5 version?

On Mon, Nov 2, 2009 at 5:41 PM, Scott Stevenson <[hidden email]> wrote:

I'm trying to execute the result of the Process API and running into
problems most likely stemming from my ignorance. I'm creating a new
process following the sample code from section 3.1.3.2 of the User
Guide. My sample process consists of:
1. StartNode
2. ActionNode that prints Hello World
3. EndNode

What I don't understand is how to get my new process into a
KnowledgeBase and KnowledgeSession for execution. I've tried the
following (Drools 4 method, I believe) as well:

       AbstractRuleBase ruleBase = (AbstractRuleBase)
RuleBaseFactory.newRuleBase();
       ruleBase.addProcess(createProcess());
       InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1,
ruleBase);

workingMemory.startProcess("org.drools.sample.workflow.dynamic");

The result of the previous code is a RuntimeException (unable to execute
Action). Inner exception is null pointer from inside the
ActionNodeInstance class. Where am going wrong in implementing the
Process API?

Thank you,
Scott Stevenson

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Scott Stevenson-6

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
In reply to this post by salaboy
Some javascript/style in this post has been disabled (why?)

Here is my attempt at using the Drools 5 API to execute my dynamically created Process:

 

KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

                org.drools.rule.Package p = new org.drools.rule.Package("sample");

                p.addProcess(createProcess());

                KnowledgePackageImp kpi = new KnowledgePackageImp();

                kpi.pkg = p;

                List<KnowledgePackage> list = new ArrayList<KnowledgePackage>();

                list.add(kpi);

                kbase.addKnowledgePackages(list);

                StatefulKnowledgeSession ksess = kbase.newStatefulKnowledgeSession();

                ksess.startProcess("org.drools.sample.workflow.dynamic");

 

I still get the same null pointer error.  Perhaps the problem is in my implementation of the Process API? The code under createProcess is this:

 

RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess("com.datacert.workflow.dynamic");

                factory

                    .name("HelloWorldRuleSet")

                    .version("1.0")

                    .packageName("org.drools")

                    .startNode(1).name("Start").done()

                    .actionNode(2)

                        .name("Action")

                        .action("java", "System.out.println(\"Inside Action 1\");").done()

                    .endNode(3).name("End").done()

                    .connection(1, 2)

                    .connection(2, 3);

                return factory.validate().getProcess();

 

Thanks,

Scott

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 2:14 PM
To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

That are only the fluent api to create processes. I recommend you the other approach:

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource("MyProcess.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());

StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();


ksession.startProcess("com.sample.MyProcess");


If you need the reference to the process instance you can do:
WorkFlowProcessInstance processInstance = ksession.startProcess(...);



Work

2009/11/2 Scott Stevenson <[hidden email]>

I read that section but I’m still not clear how to add my process (created like the section just before) to the KnowledgeBase. Section 3.2 shows adding an existing .rf file.  I have this code:

 

RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess("org.drools.sample.workflow.dynamic");

                factory

                    .name("HelloWorldRuleSet")

                    .version("1.0")

                    .packageName("org.drools")

                    .startNode(1).name("Start").done()

                    .actionNode(2)

                        .name("Action")

                        .action("java", "System.out.println(\"Inside Action 1\");").done()

                    .endNode(3).name("End").done()

                    .connection(1, 2)

                    .connection(2, 3);

                factory.validate().getProcess();

 

How does the getProcess() result get added to a KnowledgeBase?

 

Thanks,

Scott

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 1:57 PM


To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

Ok, so you need to start using the Drools 5 APIs.
Please take a look at the Drools 5 documentation:
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-flow/html_single/index.html#d0e1375

In the section 3.2

Using a Process in Your Application


you will find the correct api's.
Greetings.

2009/11/2 Scott Stevenson <[hidden email]>

I’m working with Drools 5.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mauricio Salatino
Sent: Monday, November 02, 2009 1:45 PM
To: Rules Users List
Subject: Re: [rules-users] How to execute a Process API result?

 

Are you working just with the Drools 4 version?
Or you can jump to the Drools 5 version?

On Mon, Nov 2, 2009 at 5:41 PM, Scott Stevenson <[hidden email]> wrote:

I'm trying to execute the result of the Process API and running into
problems most likely stemming from my ignorance. I'm creating a new
process following the sample code from section 3.1.3.2 of the User
Guide. My sample process consists of:
1. StartNode
2. ActionNode that prints Hello World
3. EndNode

What I don't understand is how to get my new process into a
KnowledgeBase and KnowledgeSession for execution. I've tried the
following (Drools 4 method, I believe) as well:

       AbstractRuleBase ruleBase = (AbstractRuleBase)
RuleBaseFactory.newRuleBase();
       ruleBase.addProcess(createProcess());
       InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1,
ruleBase);

workingMemory.startProcess("org.drools.sample.workflow.dynamic");

The result of the previous code is a RuntimeException (unable to execute
Action). Inner exception is null pointer from inside the
ActionNodeInstance class. Where am going wrong in implementing the
Process API?

Thank you,
Scott Stevenson

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users




--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Kris Verlaenen

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Scott Stevenson-6
Scott,

A process is also "compiled" before it is executable.  To load a process
constructed using the API, either:

 * load it as any other process by transforming it to XML first using
the XmlRuleFlowProcessDumper

 * compile the process before adding it to your rulebase, using
ProcessBuilder.buildProcess(..)

Kris

Quoting Scott Stevenson <[hidden email]>:

> I'm trying to execute the result of the Process API and running into
> problems most likely stemming from my ignorance. I'm creating a new
> process following the sample code from section 3.1.3.2 of the User
> Guide. My sample process consists of:
> 1. StartNode
> 2. ActionNode that prints Hello World
> 3. EndNode
>
> What I don't understand is how to get my new process into a
> KnowledgeBase and KnowledgeSession for execution. I've tried the
> following (Drools 4 method, I believe) as well:
>
> AbstractRuleBase ruleBase = (AbstractRuleBase)
> RuleBaseFactory.newRuleBase();
> ruleBase.addProcess(createProcess());
> InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1,
> ruleBase);
>
> workingMemory.startProcess("org.drools.sample.workflow.dynamic");
>
> The result of the previous code is a RuntimeException (unable to
> execute
> Action). Inner exception is null pointer from inside the
> ActionNodeInstance class. Where am going wrong in implementing the
> Process API?
>
> Thank you,
> Scott Stevenson
>
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>




Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Kris Verlaenen

Re: Drools Flow BAM Module(5.1.0.M1) - Why primary key's are of string/varchar type

Reply Threaded More More options
Print post
Permalink
In reply to this post by Vijay K Pandey
Does changing the type of the id field from String to long fix your
issue?  Because to me it seems that MySQL is not accepting the name "id"
as a valid column name?  I guess changing the mapping so that it uses a
different column name could fix the issue?

Kris

Quoting Vijay K Pandey <[hidden email]>:

> I am using Drools Flow BAM (5.1.0.M1) module to store the processes
> instances for audit purpose. I generated the DDL with the help of
> Hibernate Tools against the MYSQL 5.1(INNODB)
>
> DDL for the 2 tables are given below -- the interesting part is the
> "id" column as "varchar" ---- this gives error when we try to execute
> the DDL against the mysql.
>
>    create table AUDIT_NODE_INSTANCE_LOG (
>         id varchar(255) not null auto_increment,
>         type integer,
>         nodeInstanceId varchar(255),
>         nodeId varchar(255),
>         processInstanceId bigint,
>         processId varchar(255),
>         DATE datetime,
>         primary key (id)
>     ) ENGINE=InnoDB;
>
>     create table AUDIT_PROCESS_INSTANCE_LOG (
>         id varchar(255) not null auto_increment,
>         processInstanceId bigint,
>         processId varchar(255),
>         START_DATE datetime,
>         END_DATE datetime,
>         primary key (id)
>     ) ENGINE=InnoDB;
>
> The error we get is
>
> Error: Incorrect column specifier for column 'id'
> SQLState:  42000
> ErrorCode: 1063
> Error occured in:
> create table AUDIT_NODE_INSTANCE_LOG (
>         id varchar(255) not null auto_increment,
>         type integer,
>         nodeInstanceId varchar(255),
>         nodeId varchar(255),
>         processInstanceId bigint,
>         processId varchar(255),
>         DATE datetime,
>         primary key (id)
>     ) ENGINE=InnoDB
>
> I used a naming strategy for the hibernate that's why the above table
> names.
>
> My question is when the primary key generation is "native" why not
> let these columns be of  type 'long' and get generated as "bigint"
> for the sql type.
>
> If they can't be changed - should we just extend the above classes
> and have these fields as long/bigint.
>
> Any suggestion will be appreciated.
>
> Thanks
> Vijay
>




Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Vijay K Pandey

Re: Drools Flow BAM Module(5.1.0.M1) - Why primary key's are of string/varchar type

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Thanks for the reply Kris.

 

Before posting to the forum I tested with different name of “id” column such as “primaryid”. The name “id” is not a problem as I have already generated the DDL for the tables of WSHT task and all the tables got created fine with “id” as the primary key column with ‘bigint’ as the column type.

 

So just to test it again I changed the ‘id’ column name to ‘primaryid’ – the error is same

 

Error: Incorrect column specifier for column 'primaryid'

SQLState:  42000

ErrorCode: 1063

 

When i converted the varchar to bigint for the ‘id’ column – tables got created fine.

 

Do let me know what do you think and how should I approach this issue?

 

Vijay

 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Kris Verlaenen
Sent: Monday, November 02, 2009 6:11 PM
To: Rules Users List; Vijay K Pandey
Subject: Re: [rules-users] Drools Flow BAM Module(5.1.0.M1) - Why primary key's are of string/varchar type

 

Does changing the type of the id field from String to long fix your

issue?  Because to me it seems that MySQL is not accepting the name "id"

as a valid column name?  I guess changing the mapping so that it uses a

different column name could fix the issue?

 

Kris

 

Quoting Vijay K Pandey <[hidden email]>:

 

> I am using Drools Flow BAM (5.1.0.M1) module to store the processes

> instances for audit purpose. I generated the DDL with the help of

> Hibernate Tools against the MYSQL 5.1(INNODB)

> 

> DDL for the 2 tables are given below -- the interesting part is the

> "id" column as "varchar" ---- this gives error when we try to execute

> the DDL against the mysql.

> 

>    create table AUDIT_NODE_INSTANCE_LOG (

>         id varchar(255) not null auto_increment,

>         type integer,

>         nodeInstanceId varchar(255),

>         nodeId varchar(255),

>         processInstanceId bigint,

>         processId varchar(255),

>         DATE datetime,

>         primary key (id)

>     ) ENGINE=InnoDB;

> 

>     create table AUDIT_PROCESS_INSTANCE_LOG (

>         id varchar(255) not null auto_increment,

>         processInstanceId bigint,

>         processId varchar(255),

>         START_DATE datetime,

>         END_DATE datetime,

>         primary key (id)

>     ) ENGINE=InnoDB;

> 

> The error we get is

> 

> Error: Incorrect column specifier for column 'id'

> SQLState:  42000

> ErrorCode: 1063

> Error occured in:

> create table AUDIT_NODE_INSTANCE_LOG (

>         id varchar(255) not null auto_increment,

>         type integer,

>         nodeInstanceId varchar(255),

>         nodeId varchar(255),

>         processInstanceId bigint,

>         processId varchar(255),

>         DATE datetime,

>         primary key (id)

>     ) ENGINE=InnoDB

> 

> I used a naming strategy for the hibernate that's why the above table

> names.

> 

> My question is when the primary key generation is "native" why not

> let these columns be of  type 'long' and get generated as "bigint"

> for the sql type.

> 

> If they can't be changed - should we just extend the above classes

> and have these fields as long/bigint.

> 

> Any suggestion will be appreciated.

> 

> Thanks

> Vijay

> 

 

 

 

 

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

_______________________________________________

rules-users mailing list

[hidden email]

https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Kris Verlaenen

Re: Drools Flow BAM Module(5.1.0.M1) - Why primary key's are of string/varchar type

Reply Threaded More More options
Print post
Permalink
Best might indeed be to update the id to a long instead of a String.
Also check out
http://opensource.atlassian.com/projects/hibernate/browse/HB-1113

Could you open a JIRA for this?

Kris

Quoting Vijay K Pandey <[hidden email]>:

> Thanks for the reply Kris.
>
>
>
> Before posting to the forum I tested with different name of "id"
> column such as "primaryid". The name "id" is not a problem as I have
> already generated the DDL for the tables of WSHT task and all the
> tables got created fine with "id" as the primary key column with
> 'bigint' as the column type.
>
>
>
> So just to test it again I changed the 'id' column name to
> 'primaryid' - the error is same
>
>
>
> Error: Incorrect column specifier for column 'primaryid'
>
> SQLState:  42000
>
> ErrorCode: 1063
>
>
>
> When i converted the varchar to bigint for the 'id' column - tables
> got created fine.
>
>
>
> Do let me know what do you think and how should I approach this
> issue?
>
>
>
> Vijay
>
>
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Kris
> Verlaenen
> Sent: Monday, November 02, 2009 6:11 PM
> To: Rules Users List; Vijay K Pandey
> Subject: Re: [rules-users] Drools Flow BAM Module(5.1.0.M1) - Why
> primary key's are of string/varchar type
>
>
>
> Does changing the type of the id field from String to long fix your
>
> issue?  Because to me it seems that MySQL is not accepting the name
> "id"
>
> as a valid column name?  I guess changing the mapping so that it uses
> a
>
> different column name could fix the issue?
>
>
>
> Kris
>
>
>
> Quoting Vijay K Pandey <[hidden email]>:
>
>
>
> > I am using Drools Flow BAM (5.1.0.M1) module to store the
> processes
>
> > instances for audit purpose. I generated the DDL with the help of
>
> > Hibernate Tools against the MYSQL 5.1(INNODB)
>
> >
>
> > DDL for the 2 tables are given below -- the interesting part is
> the
>
> > "id" column as "varchar" ---- this gives error when we try to
> execute
>
> > the DDL against the mysql.
>
> >
>
> >    create table AUDIT_NODE_INSTANCE_LOG (
>
> >         id varchar(255) not null auto_increment,
>
> >         type integer,
>
> >         nodeInstanceId varchar(255),
>
> >         nodeId varchar(255),
>
> >         processInstanceId bigint,
>
> >         processId varchar(255),
>
> >         DATE datetime,
>
> >         primary key (id)
>
> >     ) ENGINE=InnoDB;
>
> >
>
> >     create table AUDIT_PROCESS_INSTANCE_LOG (
>
> >         id varchar(255) not null auto_increment,
>
> >         processInstanceId bigint,
>
> >         processId varchar(255),
>
> >         START_DATE datetime,
>
> >         END_DATE datetime,
>
> >         primary key (id)
>
> >     ) ENGINE=InnoDB;
>
> >
>
> > The error we get is
>
> >
>
> > Error: Incorrect column specifier for column 'id'
>
> > SQLState:  42000
>
> > ErrorCode: 1063
>
> > Error occured in:
>
> > create table AUDIT_NODE_INSTANCE_LOG (
>
> >         id varchar(255) not null auto_increment,
>
> >         type integer,
>
> >         nodeInstanceId varchar(255),
>
> >         nodeId varchar(255),
>
> >         processInstanceId bigint,
>
> >         processId varchar(255),
>
> >         DATE datetime,
>
> >         primary key (id)
>
> >     ) ENGINE=InnoDB
>
> >
>
> > I used a naming strategy for the hibernate that's why the above
> table
>
> > names.
>
> >
>
> > My question is when the primary key generation is "native" why not
>
> > let these columns be of  type 'long' and get generated as "bigint"
>
> > for the sql type.
>
> >
>
> > If they can't be changed - should we just extend the above classes
>
> > and have these fields as long/bigint.
>
> >
>
> > Any suggestion will be appreciated.
>
> >
>
> > Thanks
>
> > Vijay
>
> >
>
>
>
>
>
>
>
>
>
> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
>
> _______________________________________________
>
> rules-users mailing list
>
> [hidden email]
>
> https://lists.jboss.org/mailman/listinfo/rules-users
>




Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Scott Stevenson-6

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Kris Verlaenen
Got it! Thanks Kris and Mauricio for your guidance on this.

-----Original Message-----
From: Kris Verlaenen [mailto:[hidden email]]
Sent: Monday, November 02, 2009 6:01 PM
To: Rules Users List; Scott Stevenson
Subject: Re: [rules-users] How to execute a Process API result?

Scott,

A process is also "compiled" before it is executable.  To load a process
constructed using the API, either:

 * load it as any other process by transforming it to XML first using
the XmlRuleFlowProcessDumper

 * compile the process before adding it to your rulebase, using
ProcessBuilder.buildProcess(..)

Kris

Quoting Scott Stevenson <[hidden email]>:

> I'm trying to execute the result of the Process API and running into
> problems most likely stemming from my ignorance. I'm creating a new
> process following the sample code from section 3.1.3.2 of the User
> Guide. My sample process consists of:
> 1. StartNode
> 2. ActionNode that prints Hello World
> 3. EndNode
>
> What I don't understand is how to get my new process into a
> KnowledgeBase and KnowledgeSession for execution. I've tried the
> following (Drools 4 method, I believe) as well:
>
> AbstractRuleBase ruleBase = (AbstractRuleBase)
> RuleBaseFactory.newRuleBase();
> ruleBase.addProcess(createProcess());
> InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1,
> ruleBase);
>
> workingMemory.startProcess("org.drools.sample.workflow.dynamic");
>
> The result of the previous code is a RuntimeException (unable to
> execute
> Action). Inner exception is null pointer from inside the
> ActionNodeInstance class. Where am going wrong in implementing the
> Process API?
>
> Thank you,
> Scott Stevenson
>
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>




Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Vijay K Pandey

Re: Drools Flow BAM Module(5.1.0.M1) - Why primary key's are of string/varchar type

Reply Threaded More More options
Print post
Permalink
In reply to this post by Kris Verlaenen
Some javascript/style in this post has been disabled (why?)

Created a JIRA

 

https://jira.jboss.org/jira/browse/JBRULES-2325

 

Vijay

 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Kris Verlaenen
Sent: Tuesday, November 03, 2009 4:44 AM
To: Rules Users List; Vijay K Pandey
Subject: Re: [rules-users] Drools Flow BAM Module(5.1.0.M1) - Why primary key's are of string/varchar type

 

Best might indeed be to update the id to a long instead of a String.

Also check out

http://opensource.atlassian.com/projects/hibernate/browse/HB-1113

 

Could you open a JIRA for this?

 

Kris

 

Quoting Vijay K Pandey <[hidden email]>:

 

> Thanks for the reply Kris.

> 

> 

> 

> Before posting to the forum I tested with different name of "id"

> column such as "primaryid". The name "id" is not a problem as I have

> already generated the DDL for the tables of WSHT task and all the

> tables got created fine with "id" as the primary key column with

> 'bigint' as the column type.

> 

> 

> 

> So just to test it again I changed the 'id' column name to

> 'primaryid' - the error is same

> 

> 

> 

> Error: Incorrect column specifier for column 'primaryid'

> 

> SQLState:  42000

> 

> ErrorCode: 1063

> 

> 

> 

> When i converted the varchar to bigint for the 'id' column - tables

> got created fine.

> 

> 

> 

> Do let me know what do you think and how should I approach this

> issue?

> 

> 

> 

> Vijay

> 

> 

> 

> -----Original Message-----

> From: [hidden email]

> [mailto:[hidden email]] On Behalf Of Kris

> Verlaenen

> Sent: Monday, November 02, 2009 6:11 PM

> To: Rules Users List; Vijay K Pandey

> Subject: Re: [rules-users] Drools Flow BAM Module(5.1.0.M1) - Why

> primary key's are of string/varchar type

> 

> 

> 

> Does changing the type of the id field from String to long fix your

> 

> issue?  Because to me it seems that MySQL is not accepting the name

> "id"

> 

> as a valid column name?  I guess changing the mapping so that it uses

> a

> 

> different column name could fix the issue?

> 

> 

> 

> Kris

> 

> 

> 

> Quoting Vijay K Pandey <[hidden email]>:

> 

> 

> 

> > I am using Drools Flow BAM (5.1.0.M1) module to store the

> processes

> 

> > instances for audit purpose. I generated the DDL with the help of

> 

> > Hibernate Tools against the MYSQL 5.1(INNODB)

> 

> >

> 

> > DDL for the 2 tables are given below -- the interesting part is

> the

> 

> > "id" column as "varchar" ---- this gives error when we try to

> execute

> 

> > the DDL against the mysql.

> 

> >

> 

> >    create table AUDIT_NODE_INSTANCE_LOG (

> 

> >         id varchar(255) not null auto_increment,

> 

> >         type integer,

> 

> >         nodeInstanceId varchar(255),

> 

> >         nodeId varchar(255),

> 

> >         processInstanceId bigint,

> 

> >         processId varchar(255),

> 

> >         DATE datetime,

> 

> >         primary key (id)

> 

> >     ) ENGINE=InnoDB;

> 

> >

> 

> >     create table AUDIT_PROCESS_INSTANCE_LOG (

> 

> >         id varchar(255) not null auto_increment,

> 

> >         processInstanceId bigint,

> 

> >         processId varchar(255),

> 

> >         START_DATE datetime,

> 

> >         END_DATE datetime,

> 

> >         primary key (id)

> 

> >     ) ENGINE=InnoDB;

> 

> >

> 

> > The error we get is

> 

> >

> 

> > Error: Incorrect column specifier for column 'id'

> 

> > SQLState:  42000

> 

> > ErrorCode: 1063

> 

> > Error occured in:

> 

> > create table AUDIT_NODE_INSTANCE_LOG (

> 

> >         id varchar(255) not null auto_increment,

> 

> >         type integer,

> 

> >         nodeInstanceId varchar(255),

> 

> >         nodeId varchar(255),

> 

> >         processInstanceId bigint,

> 

> >         processId varchar(255),

> 

> >         DATE datetime,

> 

> >         primary key (id)

> 

> >     ) ENGINE=InnoDB

> 

> >

> 

> > I used a naming strategy for the hibernate that's why the above

> table

> 

> > names.

> 

> >

> 

> > My question is when the primary key generation is "native" why not

> 

> > let these columns be of  type 'long' and get generated as "bigint"

> 

> > for the sql type.

> 

> >

> 

> > If they can't be changed - should we just extend the above classes

> 

> > and have these fields as long/bigint.

> 

> >

> 

> > Any suggestion will be appreciated.

> 

> >

> 

> > Thanks

> 

> > Vijay

> 

> >

> 

> 

> 

> 

> 

> 

> 

> 

> 

> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

> 

> _______________________________________________

> 

> rules-users mailing list

> 

> [hidden email]

> 

> https://lists.jboss.org/mailman/listinfo/rules-users

> 

 

 

 

 

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

_______________________________________________

rules-users mailing list

[hidden email]

https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
ramram

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Scott Stevenson-6
Hi All

I am also trying to build a dynamic process to be used. I am having some difficulties in the build where I having this exception below is the sample code that I am using:

java.lang.NoClassDefFoundError: sample/Process_sample_0
        at sample.Process_sample_0Action0Invoker.execute(Process_sample_0Action0Invoker.java:20)


Also I have a question can I use this dynamic process inside the GWT web console? and How?

Please help in this issue

public static final void main(String[] args)
        {
                try
                {
                        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

            org.drools.rule.Package p = new org.drools.rule.Package("sample");
            RuleFlowProcess process = createProcess();
            p.addProcess(process);

            KnowledgePackageImp kpi = new KnowledgePackageImp();
            kpi.pkg = p;

            List<KnowledgePackage> list = new ArrayList<KnowledgePackage>();
            list.add(kpi);

            org.drools.compiler.PackageBuilder pbuilder = new PackageBuilder();
            pbuilder.addPackage(p);
            org.drools.compiler.ProcessBuilder builder = new ProcessBuilder(pbuilder);
            builder.buildProcess(process, null);
           
            kbase.addKnowledgePackages(list);

            StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

            System.out.println("=======>>> process.getId() ["+process.getId()+"]");

                        // starting the process
                        ksession.startProcess( process.getId() );
                        ksession.fireAllRules();
                }
                catch (Throwable t)
                {
                        t.printStackTrace();
                }
        }
       
       
        public static RuleFlowProcess createProcess()
        {
                String processName = "org.drools.HelloWorldJoinSplit";
                RuleFlowProcessFactory factory =
                    RuleFlowProcessFactory.createProcess(processName);
                factory
                    // Header
                    .name("HelloWorldJoinSplit")
                    .version("1.0")
                    .packageName("sample")
                    // Nodes
                    .startNode(1).name("Start").done()
                    .actionNode(2).name("Action 1")
                        .action("java", "System.out.println(\"Inside Action 1\")").done()
                    .endNode(3).name("End").done()
                    // Connections
                    .connection(1, 2)
                    .connection(2, 3);
                RuleFlowProcess process = factory.validate().getProcess();
               
                System.out.println(" ====== >> ["+process.getId()+"]");
                return process;
        }
Scott Stevenson-6

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
This is how I ran my dynamic process:

Public static final void main(String[] args) {
        String xml =
XmlRuleFlowProcessDumper.INSTANCE.dump(createProcess());
        System.out.println(xml);
        KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
        kbuilder.add(
ResourceFactory.newByteArrayResource(xml.getBytes()), 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());
               
        StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
       
        WorkflowProcessInstance pi = (WorkflowProcessInstance)
ksession.startProcess("com.datacert.workflow.dynamic");
}

-Scott



-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of ramram8
Sent: Friday, November 20, 2009 3:19 AM
To: [hidden email]
Subject: Re: [rules-users] How to execute a Process API result?


Hi All

I am also trying to build a dynamic process to be used. I am having some
difficulties in the build where I having this exception below is the
sample
code that I am using:

java.lang.NoClassDefFoundError: sample/Process_sample_0
        at
sample.Process_sample_0Action0Invoker.execute(Process_sample_0Action0Inv
oker.java:20)

Also I have a question can I use this dynamic process inside the GWT web
console? and How?

Please help in this issue

public static final void main(String[] args)
        {
                try
                {
                        KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase();

            org.drools.rule.Package p = new
org.drools.rule.Package("sample");
            RuleFlowProcess process = createProcess();
            p.addProcess(process);

            KnowledgePackageImp kpi = new KnowledgePackageImp();
            kpi.pkg = p;

            List<KnowledgePackage> list = new
ArrayList<KnowledgePackage>();
            list.add(kpi);

            org.drools.compiler.PackageBuilder pbuilder = new
PackageBuilder();
            pbuilder.addPackage(p);
            org.drools.compiler.ProcessBuilder builder = new
ProcessBuilder(pbuilder);
            builder.buildProcess(process, null);
           
            kbase.addKnowledgePackages(list);

            StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();

            System.out.println("=======>>> process.getId()
["+process.getId()+"]");

                        // starting the process
                        ksession.startProcess( process.getId() );
                        ksession.fireAllRules();
                }
                catch (Throwable t)
                {
                        t.printStackTrace();
                }
        }
       
       
        public static RuleFlowProcess createProcess()
        {
                String processName = "org.drools.HelloWorldJoinSplit";
                RuleFlowProcessFactory factory =
                    RuleFlowProcessFactory.createProcess(processName);
                factory
                    // Header
                    .name("HelloWorldJoinSplit")
                    .version("1.0")
                    .packageName("sample")
                    // Nodes
                    .startNode(1).name("Start").done()
                    .actionNode(2).name("Action 1")
                        .action("java", "System.out.println(\"Inside
Action 1\")").done()
                    .endNode(3).name("End").done()
                    // Connections
                    .connection(1, 2)
                    .connection(2, 3);
                RuleFlowProcess process =
factory.validate().getProcess();
               
                System.out.println(" ====== >> ["+process.getId()+"]");
                return process;
        }
--
View this message in context:
http://old.nabble.com/How-to-execute-a-Process-API-result--tp26169577p26
433405.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
ramram

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
Thanks Scott for the help
After using the code you provided the process worked fine.
I just have another question :
1-Can we use the Dynamic process with the GWT web console?
2-If we can, How? and If we cant, Is there an alternative to use dynamic process with GWT web console?
Scott Stevenson-6

Re: How to execute a Process API result?

Reply Threaded More More options
Print post
Permalink
Sorry, can't help you there. I don't have any experience with GWT.

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of ramram8
Sent: Friday, November 20, 2009 2:07 PM
To: [hidden email]
Subject: Re: [rules-users] How to execute a Process API result?


Thanks Scott for the help
After using the code you provided the process worked fine.
I just have another question :
1-Can we use the Dynamic process with the GWT web console?
2-If we can, How? and If we cant, Is there an alternative to use dynamic
process with GWT web console?
--
View this message in context:
http://old.nabble.com/How-to-execute-a-Process-API-result--tp26169577p26
446500.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users