[rules-users] External Jar/Pojo in Drools Workbench.

2014-04-10 Thread Leonard93
Hello everyone, I have a small question/problem.

I have created a class (POJO) in Eclipse and I want to be able to write
rules over this class in the Drools Workbench, thus I exported the class and
the classes it depends on (1 other class) to a Jar and imported it in the
Drools workbench.

Now what I did next is I added the jar dependency to my workbench project,
created a new datamodel and set its super class to the external class from
the jar and left the rest empty.

When I then try to use this datamodel in a guided rule or anything I can
access the variables defined in the external class fine when using the rule
editor. But when I save I get various compiler errors.

Currently I tried to make a rule template and I got these errors (I am using
the standard example project to test it out):

Unable to create Field Extractor for *'Destination'Field/method
'destination'* not found for class '*org.mortgages.Test' *

Unable to Analyse Expression *Destination ==
GenericDataObject$Country.Germany*: [Error: unable to resolve method using
strict-mode: *org.mortgages.Test.GenericDataObject$Country()]* [Near : {...*
Destination == GenericDataObject$Country.Germ }]* ^ [Line: 9, Column: 2]


The class from the jar looks like this:
public class GenericDataObject {

public enum Country
{
Egypt,
Germany,
Turkey,
France,
Unknown
}

public GenericDataObject()
{
result = new Result();
}

public Result result;
public Country Destination;

public void setDiscount(int amount)
{
result.discount = amount;
}
}

public class Result
{
public int discount;

public Result()
{
discount = 0;
}
}



--
View this message in context: 
http://drools.46999.n3.nabble.com/External-Jar-Pojo-in-Drools-Workbench-tp4029190.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] External Jar/Pojo in Drools Workbench.

2014-04-10 Thread Michael Anstis
There should be no need to extend the classes in the JAR using the Data
Modeller (unless you really want to of course).

Did you import all the classes your rule needs - if they are in different
packages - with the Config tab?

Can you please provide your JAR and a screen-shot of the rule you're trying
to author?




On 10 April 2014 12:58, Leonard93 leonardlinde...@hotmail.com wrote:

 Hello everyone, I have a small question/problem.

 I have created a class (POJO) in Eclipse and I want to be able to write
 rules over this class in the Drools Workbench, thus I exported the class
 and
 the classes it depends on (1 other class) to a Jar and imported it in the
 Drools workbench.

 Now what I did next is I added the jar dependency to my workbench project,
 created a new datamodel and set its super class to the external class from
 the jar and left the rest empty.

 When I then try to use this datamodel in a guided rule or anything I can
 access the variables defined in the external class fine when using the rule
 editor. But when I save I get various compiler errors.

 Currently I tried to make a rule template and I got these errors (I am
 using
 the standard example project to test it out):

 Unable to create Field Extractor for *'Destination'Field/method
 'destination'* not found for class '*org.mortgages.Test' *

 Unable to Analyse Expression *Destination ==
 GenericDataObject$Country.Germany*: [Error: unable to resolve method using
 strict-mode: *org.mortgages.Test.GenericDataObject$Country()]* [Near :
 {...*
 Destination == GenericDataObject$Country.Germ }]* ^ [Line: 9, Column:
 2]


 The class from the jar looks like this:
 public class GenericDataObject {

 public enum Country
 {
 Egypt,
 Germany,
 Turkey,
 France,
 Unknown
 }

 public GenericDataObject()
 {
 result = new Result();
 }

 public Result result;
 public Country Destination;

 public void setDiscount(int amount)
 {
 result.discount = amount;
 }
 }

 public class Result
 {
 public int discount;

 public Result()
 {
 discount = 0;
 }
 }



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/External-Jar-Pojo-in-Drools-Workbench-tp4029190.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] External Jar/Pojo in Drools Workbench.

2014-04-10 Thread Leonard93
I did not realize you could import them in the config and then reference them
right away in the rule without doing the data modelling step. Although I did
that and it still has the same problems.

GenericDataObject.jar
http://drools.46999.n3.nabble.com/file/n4029192/GenericDataObject.jar  

is the jar I am using, The rule I am using for it now is:
http://drools.46999.n3.nabble.com/file/n4029192/IGlG0CB.png 

I added the two classes in the config imports aswell as the enum that is
used for the country value.




--
View this message in context: 
http://drools.46999.n3.nabble.com/External-Jar-Pojo-in-Drools-Workbench-tp4029190p4029192.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] External Jar/Pojo in Drools Workbench.

2014-04-10 Thread Michael Anstis
OK, I imported your JAR and created a rule as shown below.

The Guided Rule Editor had the option to select the enums for Country.

Theonly issue I had was with Destination itself - as it should be a lower
case d. Drools Compiler did report an error that  is was ...Unable to
create Field Extractor for 'Destination'Field/method 'destination' not
found for class 'com.sample.GenericDataObject'. I suspect if you change
the field name to destination it would work OK.

This was with the latest code @master in github.

1.|package org.anstis.p1;2.|3.|import java.lang.Number;4.|import
 com.sample.GenericDataObject;5.|import
 com.sample.GenericDataObject.Airline;6.|import
 com.sample.GenericDataObject.Country;7.|import com.sample.Result;8.|9.|rule
 r110.|dialect mvel11.|when12.|GenericDataObject(
Destination == Country.Egypt )13.|then14.|end


On 10 April 2014 12:58, Leonard93 leonardlinde...@hotmail.com wrote:

 Hello everyone, I have a small question/problem.

 I have created a class (POJO) in Eclipse and I want to be able to write
 rules over this class in the Drools Workbench, thus I exported the class
 and
 the classes it depends on (1 other class) to a Jar and imported it in the
 Drools workbench.

 Now what I did next is I added the jar dependency to my workbench project,
 created a new datamodel and set its super class to the external class from
 the jar and left the rest empty.

 When I then try to use this datamodel in a guided rule or anything I can
 access the variables defined in the external class fine when using the rule
 editor. But when I save I get various compiler errors.

 Currently I tried to make a rule template and I got these errors (I am
 using
 the standard example project to test it out):

 Unable to create Field Extractor for *'Destination'Field/method
 'destination'* not found for class '*org.mortgages.Test' *

 Unable to Analyse Expression *Destination ==
 GenericDataObject$Country.Germany*: [Error: unable to resolve method using
 strict-mode: *org.mortgages.Test.GenericDataObject$Country()]* [Near :
 {...*
 Destination == GenericDataObject$Country.Germ }]* ^ [Line: 9, Column:
 2]


 The class from the jar looks like this:
 public class GenericDataObject {

 public enum Country
 {
 Egypt,
 Germany,
 Turkey,
 France,
 Unknown
 }

 public GenericDataObject()
 {
 result = new Result();
 }

 public Result result;
 public Country Destination;

 public void setDiscount(int amount)
 {
 result.discount = amount;
 }
 }

 public class Result
 {
 public int discount;

 public Result()
 {
 discount = 0;
 }
 }



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/External-Jar-Pojo-in-Drools-Workbench-tp4029190.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] External Jar/Pojo in Drools Workbench.

2014-04-10 Thread Leonard93
Ah thank you, I will look into that and try :) It seems like that would be
indeed the problem.




--
View this message in context: 
http://drools.46999.n3.nabble.com/External-Jar-Pojo-in-Drools-Workbench-tp4029190p4029194.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users