Re: [rules-users] Guvnor and drools implementation - questions

2011-03-10 Thread Eddy Hautot
Thanks your code works well (extract the name of all the rules and name 
of the package). I suppose there is nothing we ca do with guvnor. May be 
export all in guvnor so we have a 'snapshot' of guvnor when the package 
was build and deployed or archive the package.

You mean put a Map as attribute in MapPojo Class (not extending anymore 
HashMap) and in the subclass MapTest1, MapTest2... extending MapPojo put 
set and get method to access attribute of this map?

Thanks for your help


Le 8/03/2011 23:37, Vincent Legendre a écrit :
>> Yes i created rueles with guided editor and it's working with my
>> attribute. is there a way to remove "empty", "entrySet", "keySet",
>> "clone",... herited from Map. So i would have only the attribute i
>> have defined?
> Don't make the POJO extends Map, but containing a map.
>> i have always used drl file instead of package. If i deploy a
>> file.pkg, is there a way to know what's in it? If i deploy something,
>> i just want to be able later to very that all is well what i think if
>> i have a doubt (easy with drl file).
> try this (the only trick is to compact the rules that comes from a
> decision table into one main log line) :
>
>   public static void dumpKbContent(KnowledgeBase knowledgeBase) {
>   System.out.println(" " + ruleSet + "
> ");
>   // Dump content
>   for (KnowledgePackage p : knowledgeBase.getKnowledgePackages()) {
>   System.out.println("-o0o- Package " + p.getName() + " -o0o-");
>   System.out.println("Processes : ");
>   for (Process flow : p.getProcesses()) {
>   System.out.println("   - " + flow.getName());
>   }
>   System.out.println("Rules : ");
>   String lastRuleName = "";
>   for (Rule rule : p.getRules()) {
>   String ruleName = extractMainTableName(rule.getName());
>   if (!ruleName.equals(lastRuleName)) {
>   System.out.println("   - " + ruleName);
>   lastRuleName = ruleName;
>   }
>   }
>   System.out.println("-o0o- End Package " + p.getName() + "
> -o0o-");
>   }
>   System.out.println(" END " + ruleSet + "
> ");
>   }
>
>   private static String extractMainTableName(String ruleName) {
>   // tables
>   Pattern p = Pattern.compile("(.*)_[0-9]+");
>   Matcher m = p.matcher(ruleName);
>   if (m.matches()) {
>   return m.group(1) + " ... table";
>   } else {
>   return ruleName;
>   }
>   }
>
>
>
> ___
> 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] Guvnor and drools implementation - questions

2011-03-08 Thread Vincent Legendre

> Yes i created rueles with guided editor and it's working with my 
> attribute. is there a way to remove "empty", "entrySet", "keySet", 
> "clone",... herited from Map. So i would have only the attribute i 
> have defined?
Don't make the POJO extends Map, but containing a map.
>
> i have always used drl file instead of package. If i deploy a  
> file.pkg, is there a way to know what's in it? If i deploy something, 
> i just want to be able later to very that all is well what i think if 
> i have a doubt (easy with drl file).
try this (the only trick is to compact the rules that comes from a 
decision table into one main log line) :

 public static void dumpKbContent(KnowledgeBase knowledgeBase) {
 System.out.println(" " + ruleSet + " 
");
 // Dump content
 for (KnowledgePackage p : knowledgeBase.getKnowledgePackages()) {
 System.out.println("-o0o- Package " + p.getName() + " -o0o-");
 System.out.println("Processes : ");
 for (Process flow : p.getProcesses()) {
 System.out.println("   - " + flow.getName());
 }
 System.out.println("Rules : ");
 String lastRuleName = "";
 for (Rule rule : p.getRules()) {
 String ruleName = extractMainTableName(rule.getName());
 if (!ruleName.equals(lastRuleName)) {
 System.out.println("   - " + ruleName);
 lastRuleName = ruleName;
 }
 }
 System.out.println("-o0o- End Package " + p.getName() + " 
-o0o-");
 }
 System.out.println(" END " + ruleSet + " 
");
 }

 private static String extractMainTableName(String ruleName) {
 // tables
 Pattern p = Pattern.compile("(.*)_[0-9]+");
 Matcher m = p.matcher(ruleName);
 if (m.matches()) {
 return m.group(1) + " ... table";
 } else {
 return ruleName;
 }
 }



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


Re: [rules-users] Guvnor and drools implementation - questions

2011-03-08 Thread ioda100
it's working for pkg, bad library

On Tue, Mar 8, 2011 at 4:30 PM, Eddy Hautot  wrote:

> Hi Vincent,
>
> Thanks for precisions.
>
> Didn't knew only set/get are used. Get to be careful when i will have 100+
> attributes  :-)
>
> Yes i created rueles with guided editor and it's working with my attribute.
> is there a way to remove "empty", "entrySet", "keySet", "clone",... herited
> from Map. So i would have only the attribute i have defined?
>
> Ok i will do like this for testing eval($m1 != $m2) ... i have put this in
> separate line to meke it clearer at the beginning.
>
> I think i will do your first option, rules will be clearer.
>
> i have always used drl file instead of package. If i deploy a  file.pkg, is
> there a way to know what's in it? If i deploy something, i just want to be
> able later to very that all is well what i think if i have a doubt (easy
> with drl file).
>
> When i try to create my session i have problem with pkg. For know with .drl
> file i do with that :
>
> KnowledgeBase knowledgeBase = createKnowledgeBase();
> StatefulKnowledgeSession session =
> knowledgeBase.newStatefulKnowledgeSession();
>
> private static KnowledgeBase createKnowledgeBase() {
> final KnowledgeBuilder builder =
> KnowledgeBuilderFactory.newKnowledgeBuilder ();
>
>
> builder.add(ResourceFactory.newUrlResource("file:///d://basicRule.drl"),
> ResourceType.DRL);
> if (builder.hasErrors()) {
> throw new RuntimeException(builder.getErrors()
> .toString());
> }
> KnowledgeBase knowledgeBase =
> KnowledgeBaseFactory.newKnowledgeBase();
> knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages());
>
> return knowledgeBase;
> }
>
> If i replace the line :
> builder.add(ResourceFactory.newUrlResource("file:///d://basicRule.drl"),
> ResourceType.DRL);
> by :
> builder.add(ResourceFactory.newUrlResource("file:///d://PackageTest1.pkg"),
> ResourceType.PKG);
>
> but it's crashing :
> xception in thread "main" org.drools.RuntimeDroolsException: Unable to load
> dialect
> 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
> at
> org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:283)
> at
> org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:268)
> at
> org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:181)
> at
> org.drools.compiler.PackageBuilderConfiguration.(PackageBuilderConfiguration.java:154)
> at
> org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactoryServiceImpl.java:26)
> at
> org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactory.java:86)
> at TestMapPojoPackage.createKnowledgeBase(TestMapPojoPackage.java:86)
> at TestMapPojoPackage.main(TestMapPojoPackage.java:58)
> Caused by: java.lang.RuntimeException: The Janino jar is not in the
> classpath
> at
> org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:100)
> at
> org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:55)
> at
> org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:279)
> ... 7 more
>
> Is it something special to do?
>
> Thanks again for your time
>
>
>  On Mon, Mar 7, 2011 at 7:44 PM, Vincent Legendre [via Drools - Java Rules
> Engine]  wrote:
>
>>
>>
>> I've just created 2 class like you show me with some changes to fit and
>> test all (timestamp are long in fact, i have put int, double and string as
>> well)
>>
>> In the second class you don't need the attributes as members, because
>> Drools uses get / set methods to deduce them, and anyway you never use them
>> as they are stored in the map.
>>
>> Then i have imported this in Guvnor.
>>
>> I have made 2 categories. I have put the model (jar) in the 2 categories.
>>
>> That is non-sense. Jars are not linked to a category but to a package.
>>
>>  I have created 2 simple rules playing with the attributes id,
>> timestamp...
>>
>> With Guided editor ?
>>
>>
>>
>> 1) For the condition Map $m1 different then Map $m2. I suppose i have to
>> use the function define in MapPojo? I have to write it by hand using "free
>> from drl" : eval($m1 != $m2) ? or is there a better way?
>>
>> Its a way.
>> You can also test the id directly in conditions (in Guided editor, bind
>> the id of the first instance to a var, then compare it in the second
>> condition.
>>
>>
>> The same for testing that $m1 timestamp (Long) is befor $m2. I have to
>> write it by hand : eval($m1.isBefore($m2))? So they have to know it exist a
>> method isBefore if not said by the gui?
>>
>> Same. Add the test directly in the condition.
>> Another solu

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-08 Thread ioda100
Hi Vincent,

Thanks for precisions.

Didn't knew only set/get are used. Get to be careful when i will have 100+
attributes  :-)

Yes i created rueles with guided editor and it's working with my attribute.
is there a way to remove "empty", "entrySet", "keySet", "clone",... herited
from Map. So i would have only the attribute i have defined?

Ok i will do like this for testing eval($m1 != $m2) ... i have put this in
separate line to meke it clearer at the beginning.

I think i will do your first option, rules will be clearer.

i have always used drl file instead of package. If i deploy a  file.pkg, is
there a way to know what's in it? If i deploy something, i just want to be
able later to very that all is well what i think if i have a doubt (easy
with drl file).

When i try to create my session i have problem with pkg. For know with .drl
file i do with that :

KnowledgeBase knowledgeBase = createKnowledgeBase();
StatefulKnowledgeSession session =
knowledgeBase.newStatefulKnowledgeSession();

private static KnowledgeBase createKnowledgeBase() {
final KnowledgeBuilder builder =
KnowledgeBuilderFactory.newKnowledgeBuilder ();


builder.add(ResourceFactory.newUrlResource("file:///d://basicRule.drl"),
ResourceType.DRL);
if (builder.hasErrors()) {
throw new RuntimeException(builder.getErrors()
.toString());
}
KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages());

return knowledgeBase;
}

If i replace the line :
builder.add(ResourceFactory.newUrlResource("file:///d://basicRule.drl"),
ResourceType.DRL);
by :
builder.add(ResourceFactory.newUrlResource("file:///d://PackageTest1.pkg"),
ResourceType.PKG);

but it's crashing :
xception in thread "main" org.drools.RuntimeDroolsException: Unable to load
dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:283)
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:268)
at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:181)
at
org.drools.compiler.PackageBuilderConfiguration.(PackageBuilderConfiguration.java:154)
at
org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactoryServiceImpl.java:26)
at
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactory.java:86)
at TestMapPojoPackage.createKnowledgeBase(TestMapPojoPackage.java:86)
at TestMapPojoPackage.main(TestMapPojoPackage.java:58)
Caused by: java.lang.RuntimeException: The Janino jar is not in the
classpath
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:100)
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:55)
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:279)
... 7 more

Is it something special to do?

Thanks again for your time


On Mon, Mar 7, 2011 at 7:44 PM, Vincent Legendre [via Drools - Java Rules
Engine]  wrote:

>
>
> I've just created 2 class like you show me with some changes to fit and
> test all (timestamp are long in fact, i have put int, double and string as
> well)
>
> In the second class you don't need the attributes as members, because
> Drools uses get / set methods to deduce them, and anyway you never use them
> as they are stored in the map.
>
> Then i have imported this in Guvnor.
>
> I have made 2 categories. I have put the model (jar) in the 2 categories.
>
> That is non-sense. Jars are not linked to a category but to a package.
>
>  I have created 2 simple rules playing with the attributes id, timestamp...
>
> With Guided editor ?
>
>
>
> 1) For the condition Map $m1 different then Map $m2. I suppose i have to
> use the function define in MapPojo? I have to write it by hand using "free
> from drl" : eval($m1 != $m2) ? or is there a better way?
>
> Its a way.
> You can also test the id directly in conditions (in Guided editor, bind the
> id of the first instance to a var, then compare it in the second condition.
>
>
> The same for testing that $m1 timestamp (Long) is befor $m2. I have to
> write it by hand : eval($m1.isBefore($m2))? So they have to know it exist a
> method isBefore if not said by the gui?
>
> Same. Add the test directly in the condition.
> Another solution is to use a custom operator (search this mailing list for
> samples).
>
>   2) In the code It's written MapTest1(..) instead of Map(...) so i
> suppose drools has to do it with the precompiled package  .pkg to know about
> the MapPojo and MapTest1.. If i take only the .drl, drools won'

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-07 Thread Vincent Legendre


I've just created 2 class like you show me with some changes to fit 
and test all (timestamp are long in fact, i have put int, double and 
string as well)
In the second class you don't need the attributes as members, because 
Drools uses get / set methods to deduce them, and anyway you never use 
them as they are stored in the map.



Then i have imported this in Guvnor.

I have made 2 categories. I have put the model (jar) in the 2 categories.

That is non-sense. Jars are not linked to a category but to a package.


I have created 2 simple rules playing with the attributes id, timestamp...

With Guided editor ?



1) For the condition Map $m1 different then Map $m2. I suppose i have 
to use the function define in MapPojo? I have to write it by hand 
using "free from drl" : eval($m1 != $m2) ? or is there a better way?



Its a way.
You can also test the id directly in conditions (in Guided editor, bind 
the id of the first instance to a var, then compare it in the second 
condition.


The same for testing that $m1 timestamp (Long) is befor $m2. I have to 
write it by hand : eval($m1.isBefore($m2))? So they have to know it 
exist a method isBefore if not said by the gui?



Same. Add the test directly in the condition.
Another solution is to use a custom operator (search this mailing list 
for samples).


2) In the code It's written MapTest1(..) instead of Map(...) so i 
suppose drools has to do it with the precompiled package  .pkg to know 
about the MapPojo and MapTest1.. If i take only the .drl, drools won't 
know about class MapTest1.


It is MapTest1, because this is the class used  and drools knows it 
because it uses it ... You don't use Map directly anymore


Yes i can set a category to each of my rule.

Yes you can !
Do you mean create 4 categories (cat1, cat2, cat3, cat4) and for rules 
of file1.drl, put them it cat1, for file2.drl, put them in cat2... ?

Yes

Set a first condition in the rules?

Choose between categories and first condition. Don't use both
Am i obliged to create a package per file and filter by category or is 
it possible to make a package with all and filtering when creating the 
knowledgeBase or something like that?
You certainly can filter your KB afterwards, but this is not really an 
out-of-the-box function. To me you have two options. For both options, 
you have only one Guvnor package :*


First option* : categories
set categories for your rules as you said
compile by filtering one category, do a snapshot. Redo the same for 
other categories (in other snapshots).

Use these 4 snapshots in your code

*Second option *: First filtering condition
create a new POJO having only one field to handle the task asked (or 
category or group or file or whatever you call that) add a condition to 
all your rules testing this fact according to their group (as described 
in one of my previous mail)

create a single package (or use DRL) for all your rules.
when calling your rules, insert the suitable POJO according to tehexec 
you want.


The second is my favorite because it is less work to deploy, and your 
number of rules are quite small. The second option can be change to use 
a RuleFlow instead of a control fact.



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


Re: [rules-users] Guvnor and drools implementation - questions

2011-03-07 Thread Eddy Hautot
Thanks for your help Vincent.

To be sure i have understood all well.

I've just created 2 class like you show me with some changes to fit and test
all (timestamp are long in fact, i have put int, double and string as well)
:

First class :

import java.util.HashMap;

public class MapPojo extends HashMap {

 public Object getId() {
 return this.get("id");
 }

 @Override
 public boolean equals(Object o) {
 return (o instanceof MapPojo) &&
((MapPojo)o).getId().equals(getId());
 }

 public long getTimeStamp() {
 return (Long) this.get("timeStamp");
 }

 public boolean isBefore(MapPojo other) {
 if (this.getTimeStamp() < other.getTimeStamp())
 return true;
 else
 return false;
 }
}

Second class :

public class MapTest1 extends MapPojo {

private String Att1String;
private String id;
private doubleAtt2Double;
private int  Att3Int;
private long   timeStamp;

public String getId() {
return (String)this.get("id");
}
public void setId(String val) {
this.put("id",val);
}

public String getAtt1String() {
return (String)this.get("Att1String");
}
public void setAtt1String(String val) {
this.put("Att1String",val);
}

public double getAtt2Double() {
return (Double)this.get("Att2Double");
}
public void setAtt2Double(double val) {
this.put("Att2Double",val);
}

public int getAtt3Int() {
return Integer.parseInt((String)this.get("Att3Int"));
}
public void setAtt3Int(int val) {
this.put("Att3Int",val);
}

public long getTimeStamp() {
return (Long)this.get("timeStamp");
}
public void setTimeStamp(Long val) {
this.put("timeStamp",val);
}
}

Then i have imported this in Guvnor.

I have made 2 categories. I have put the model (jar) in the 2 categories. I
have created 2 simple rules playing with the attributes id, timestamp...

Then i get some code like this (when i clic on view code or get the drl
file) : 1.|rule "Rule1InCat1" 2.|dialect "mvel" 3.|when 4.|$m1
: MapTest1( att1String == "value1" ) 5.|$m2 : MapTest1( att1String
== "value1" ) 6.|MapTest1( att2Double == 3.5 )7. |then8.|
   MapTest1
fact0 = new MapTest1();9.| fact0.setId( "id4" );10.|
insert(fact0
); 11.|end
1) For the condition Map $m1 different then Map $m2. I suppose i have to use
the function define in MapPojo? I have to write it by hand using "free from
drl" : eval($m1 != $m2) ? or is there a better way?

The same for testing that $m1 timestamp (Long) is befor $m2. I have to write
it by hand : eval($m1.isBefore($m2))? So they have to know it exist a method
isBefore if not said by the gui?

2) In the code It's written MapTest1(..) instead of Map(...) so i suppose
drools has to do it with the precompiled package  .pkg to know about the
MapPojo and MapTest1.. If i take only the .drl, drools won't know about
class MapTest1.

I think it could be for the biggest file about 100+ rules. And the smallest
about 2-3 only.

I can have : MapTest1, MapTest2, MapTest3, MapTest4 for example with each
their own attributes. And For now if i have 4 drl files (file1.drl go for
MapTest1 objects, file2.drl go for MapTest2 objects...) with their own
rules, i know when to use which file.

Yes i can set a category to each of my rule. Do you mean create 4 categories
(cat1, cat2, cat3, cat4) and for rules of file1.drl, put them it cat1, for
file2.drl, put them in cat2... ? Set a first condition in the rules? Am i
obliged to create a package per file and filter by category or is it
possible to make a package with all and filtering when creating the
knowledgeBase or something like that?


Thanks again for your precious help.



On Fri, Mar 4, 2011 at 7:35 PM, Vincent Legendre <
vincent.legen...@eurodecision.com> wrote:

>
> > I just tried to make a pojo. But i will have to do a single Pojo
> > called "Map" with all the properties? Right now i had 4 Enum. Here i
> > will have to have all in the same POJO with name "Map".
> No. Don't name the Pojo "Map" ... And create as much Pojo that you have
> different enums. Make them extend a common class where are defined
> common behaviour.
> To make that clear once for all, see this code :
>
> public class MapPojo extends HashMap {
>
> public Object getId() {
> return this.get("id");
> }
>
> @Override
> public boolean equals(Object o) {
> return (o instanceof MapPojo)
> && ((MapPojo)o).getId().equals(getId());
> }
>
> public Date getTimeStamp() {
> return (Date) this.get("timeStamp");
> }
>
> public boolean isBefore(MapPojo other) {
> return this.getTimeStamp().before(other.getTimeStamp());
> }
> }
>
> // for enum 1
> public class MapPojoGroup1 extends MapPojo {
>
> public String getAtt1() {
> return (String)this.get("att1");
>

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-04 Thread Vincent Legendre

> I just tried to make a pojo. But i will have to do a single Pojo 
> called "Map" with all the properties? Right now i had 4 Enum. Here i 
> will have to have all in the same POJO with name "Map".
No. Don't name the Pojo "Map" ... And create as much Pojo that you have 
different enums. Make them extend a common class where are defined 
common behaviour.
To make that clear once for all, see this code :

public class MapPojo extends HashMap {

 public Object getId() {
 return this.get("id");
 }

 @Override
 public boolean equals(Object o) {
 return (o instanceof MapPojo)
&& ((MapPojo)o).getId().equals(getId());
 }

 public Date getTimeStamp() {
 return (Date) this.get("timeStamp");
 }

 public boolean isBefore(MapPojo other) {
 return this.getTimeStamp().before(other.getTimeStamp());
 }
}

// for enum 1
public class MapPojoGroup1 extends MapPojo {

 public String getAtt1() {
 return (String)this.get("att1");
 }
 public void setAtt1(String val) {
 this.put("att1",val);
 }

 public Long getAtt2() {
 return (Long)this.get("att2");
 }
 public void setAtt2(Long val) {
 this.put("att2",val);
 }

}

... etc etc etc for other enums
Easy to generate isn't it ?

>
> The advantage i suppose is that with the Pojo, we can directly tell 
> this attribute is a String, this one is a Integer, this one a Double 
> and this one a Long and in the rules all will be done automatically 
> without casting?
Yep. And Guided editor will work "out of the box", providing the 
suitable list of fields, and suitable operators according to the field 
type.
And if subsequent Pojo generation remove a field, compilation will warn you.


For the files, please tell how you cut them. Can you set a category ? If 
yes, you can also set a first condition. How many rules do you (plan to) 
have ?
And yes, you can compile only rules that match a given category. But you 
will have to store it in a snapshot just after that. Please refer to the 
doc for this point.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Guvnor and drools implementation - questions

2011-03-04 Thread ioda100
You make me hesitating  :-).

I just tried to make a pojo. But i will have to do a single Pojo called
"Map" with all the properties? Right now i had 4 Enum. Here i will have to
have all in the same POJO with name "Map".

The advantage i suppose is that with the Pojo, we can directly tell this
attribute is a String, this one is a Integer, this one a Double and this one
a Long and in the rules all will be done automatically without casting?

I can still assign $m1 for example to a Map found with "set variable name".

But in my example of 2 mails ago, to verify that it's not the same Map with
verifying $m1["id"]!=$m2["id"] i have to write it by hand with adding a Map
and choose formula then adding "$m1["id"]!=$m2["id"]"? Same for testing
timestamp of $m1 is before timestamp of $m2? Or is there a way to add it in
Pojo? I tried adding methods in the Pojo but i cannot call them.



I can have a look for taking the compiled package but this will mean change
a lot of code. I had to implement something that watch if the drl file was
change before creating the Knoledge base otherwise we keep the old knowledge
base. Because i do it in a multi threaded environement and it was crashing.

If i take th ecompiled one, can i easily split this in 4 compiled package
with each its rules? using Category?

The solution to do it with drl is a little too complicated.

Thanks again.


On Fri, Mar 4, 2011 at 4:42 PM, Vincent Legendre [via Drools - Java Rules
Engine]  wrote:

>
>
> I will rethink of POJO but i think, it will be more ennoying to update any
> change. I will need a reference to these maps in almost every case in the
> THEN clause so not a big problem finally.
>
> It's up to you. With a POJO you can implement Comparable using your time
> slots, and all other common behaviour that you will need later ... and don't
> be forced to set a tricky DSL ... and have validation/compilation telling
> you that you are using a non-existent field instead of getting NPE at
> runtime ... but it's up to you :)
>
>
> For the second question :
>
> In fact i have to make rules using these Enum and DSL and put rules in
> their specific files.
> For example now i am working with 4 different drl files :
>
> Files ?
> According to your DSL questions, I guess that you are working with Guvnor,
> so you are getting your file via the package URL for the generated DRL file
> ?
> You should create compiled package, because :
>- rules are compiled so the KB loading is faster
>- Guvnor (since 5.1) ca generate compiled package with only a subset of
> the rules, filtering them by category and/or status (or by a custom
> selection using rules :) ).
>
> But if you can't,or don't want to create binaries, and still want to store
> all rules inthe same package (to avoid duplicating DSL and enums), may be
> you can
>- assign your rules a 'ruleflow-group' and create a ruleflow that branch
> on the suitable group.
>- use 'agenda-group'.
>- With no rule flow, you can add to all your rules a condition that
> match a fact telling which group is executing
> rule r1
> when
>   Exec(task == "task1")
>   $m1 : ...
> then
> ...
> end
>
> It depends on how you group your rules in files.
>
>  These files have to have this specific name and the name cannot change
> because the java code use this name to load the drl file in the session.
>
> You can also access compiled binary package by a snapshot name.
> Or if you have one single set of rules, create a single KB and provide
> methods that create new session ans add the specific control fact (not sure
> of the exact syntax, just to show the idea) :
> task1() {
> session = getKb().newStatelessSession();
> session.insert(new Exec("task1")
> ...
> session.execute(...)
> }
> task2() {
> session = getKb().newStatelessSession();
> session.insert(new Exec("task2")
> ...
> session.execute(...)
> }
> and you can obviously make that generic ...
>
>
>
> To put each rule in its specific file, do i have to create a package per
> file and name the package with the name of the file i want? And copy Enum
> and DSL in each package or can i put this in global?
>
> Don't know if global can contains Enum and DSL. I think it can only contain
> rules
>
>
> To use the Test Scenario, do you know if we have to do special things? I
> tried to add Maps in the Given part and run the scenario but i get an error
> ; "unable to find constructor for java.util.Map" and the same if i put a
> boolean, string...   Is the Guvnor Test Scenario not able to find java class
> and how to make it reachable?
> I have already tried Test Scenario with adding object for which i gave a
> Pojo but never with basic java type.
>
> Don't known, sorry.
>
>  
> ___
> rules-users mailing list
> [hidden email]

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-04 Thread Vincent Legendre


I will rethink of POJO but i think, it will be more ennoying to update 
any change. I will need a reference to these maps in almost every case 
in the THEN clause so not a big problem finally.
It's up to you. With a POJO you can implement Comparable using your time 
slots, and all other common behaviour that you will need later ... and 
don't be forced to set a tricky DSL ... and have validation/compilation 
telling you that you are using a non-existent field instead of getting 
NPE at runtime ... but it's up to you :)




For the second question :

In fact i have to make rules using these Enum and DSL and put rules in 
their specific files.

For example now i am working with 4 different drl files :

Files ?
According to your DSL questions, I guess that you are working with 
Guvnor, so you are getting your file via the package URL for the 
generated DRL file ?

You should create compiled package, because :
   - rules are compiled so the KB loading is faster
   - Guvnor (since 5.1) ca generate compiled package with only a subset 
of the rules, filtering them by category and/or status (or by a custom 
selection using rules :) ).


But if you can't,or don't want to create binaries, and still want to 
store all rules inthe same package (to avoid duplicating DSL and enums), 
may be you can
   - assign your rules a 'ruleflow-group' and create a ruleflow that 
branch on the suitable group.

   - use 'agenda-group'.
   - With no rule flow, you can add to all your rules a condition that 
match a fact telling which group is executing

rule r1
when
  Exec(task == "task1")
  $m1 : ...
then
...
end

It depends on how you group your rules in files.

These files have to have this specific name and the name cannot change 
because the java code use this name to load the drl file in the session.

You can also access compiled binary package by a snapshot name.
Or if you have one single set of rules, create a single KB and provide 
methods that create new session ans add the specific control fact (not 
sure of the exact syntax, just to show the idea) :

task1() {
session = getKb().newStatelessSession();
session.insert(new Exec("task1")
...
session.execute(...)
}
task2() {
session = getKb().newStatelessSession();
session.insert(new Exec("task2")
...
session.execute(...)
}
and you can obviously make that generic ...




To put each rule in its specific file, do i have to create a package 
per file and name the package with the name of the file i want? And 
copy Enum and DSL in each package or can i put this in global?
Don't know if global can contains Enum and DSL. I think it can only 
contain rules




To use the Test Scenario, do you know if we have to do special things? 
I tried to add Maps in the Given part and run the scenario but i get 
an error ; "unable to find constructor for java.util.Map" and the same 
if i put a boolean, string...   Is the Guvnor Test Scenario not able 
to find java class and how to make it reachable?
I have already tried Test Scenario with adding object for which i gave 
a Pojo but never with basic java type.

Don't known, sorry.

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


Re: [rules-users] Guvnor and drools implementation - questions

2011-03-04 Thread Eddy Hautot

Thank you for your answer.
Yes it's what i have done as i didn't find a better idea. User will have 
to enter it but if the DSL is clear shouldn't be a problem.


In fact 1 rule will be something like :
- Find a map with properties 'prop1' = "value1" and store it in variable 
$m1 (because i will need access in the Then part also)
- Find a map with properties 'prop1' = "value1" (and different then $m1) 
and store it in variable $m2.
- And using properties 'unixTimestampInSecond' and 
'unixTimestampInMillisecond' (so complete timestamp in Millisecond = 
'unixTimestampInSecond' * 1000 + 'unixTimestampInMillisecond') of the 2 
Maps, $m1 has to be before $m2.


So i use 2 times this one to find $m1 and $m2 : [when]The property 
{key:ENUM:Map.properties} of the map *{mapVar}* is {value}=*{mapVar} *: 
Map((this["{key}"] == "{value}"))


Then this one to drop the case when the Map would be the same : 
[when]The map *{mapVar1}* is not map *{mapVar2}*=*eval ({mapVar1}*["id"] 
!= *{mapVar2}*["id"]))*

*
Then i can do something like : [when]The map *{mapVar1}* is before 
*{mapVar2}*=*eval (orderTimeStamp(*(Long) 
*{mapVar1}*["unixTimestampInSecond"], (Long) 
*{mapVar1}*["unixTimestampInMillisecond"], (Long) *{mapVar2}*[" 
unixTimestampInSecond"], (Long) *{mapVar2}*["unixTimestampInMillisecond"]))*

*
where i would have a function *:
function Boolean orderTimeStamp(Long a, Long b, Long c, Long d)*
{
Long timestamp1 = a*1000+b;
Long timestamp2 = c*1000+d;

if (timestamp1 <= timestamp2)
return true;
else
return false;
}

I will rethink of POJO but i think, it will be more ennoying to update 
any change. I will need a reference to these maps in almost every case 
in the THEN clause so not a big problem finally.



For the second question :

In fact i have to make rules using these Enum and DSL and put rules in 
their specific files.

For example now i am working with 4 different drl files :

- file1.drl which contains rule1, rule2, rule3, rule4
- file2.drl which contains rule5, rule6, rule7, rule8
- file3.drl which contains rule9, rule10, rule11, rule12
- file4.drl which contains rule13, rule14, rule15, rule16

These files have to have this specific name and the name cannot change 
because the java code use this name to load the drl file in the session.


To put each rule in its specific file, do i have to create a package per 
file and name the package with the name of the file i want? And copy 
Enum and DSL in each package or can i put this in global? Or maybe be is 
there a better way i didn't find?



To use the Test Scenario, do you know if we have to do special things? I 
tried to add Maps in the Given part and run the scenario but i get an 
error ; "unable to find constructor for java.util.Map" and the same if i 
put a boolean, string...   Is the Guvnor Test Scenario not able to find 
java class and how to make it reachable?
I have already tried Test Scenario with adding object for which i gave a 
Pojo but never with basic java type.


Thanks again


Le 4/03/2011 11:50, Vincent Legendre a écrit :
For your problem of different instances of a map : If you want to 
match 2 maps, and compare them, your have to set a placeholder in your 
DSL to set the variable's name
[when]The property {key:ENUM:Map.properties} of the map *{mapVar}* is 
{value}=*{mapVar} *: Map((this["{key}"] == "{value}"))


**And another DSL phrase to check that instances are different
[when]The map *{mapVar1}* is not map *{mapVar2}*=*eval 
({mapVar1}*["id"] != *{mapVar2}*["id"]))*

*
But it will force your users to handle variables. I can't see simpler 
way for doing that with DSL.


You may consider completely another way. If your property lists are 
constant (and they are because you can create static enums), you can 
write a simple program to generate the corresponding POJOs (which 
contains the map inside them and use it in set/get methods for 
corresponding key) and create a jar with them.
Each POJO will then have its fields listed automatically in Guided 
Editor, which will prevent you for writing complex DSL and enums, and 
provide a good way for users to edit rules. For instance, you can bind 
an object to a variable only if you need it (with DSL you are forced 
to bind a variable at each time you use the phrase), and you can use 
other operator (not only equals) without writing a new DSL phrase.



I did not understand this question :

I have to put my rules in 4 drl files separate (i know which rules go 
in which drl file), is the only way to create a different package for 
each drl file i want? And to put the Enum and DSL part in Global if i 
have to use it for the 4 files? If i want a precise name for my drl 
file, i have to give this exact name to the package?

But yes, a DSL (and enums) is specific to its package.


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

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-04 Thread Vincent Legendre
For your problem of different instances of a map : If you want to match 
2 maps, and compare them, your have to set a placeholder in your DSL to 
set the variable's name
[when]The property {key:ENUM:Map.properties} of the map *{mapVar}* is 
{value}=*{mapVar} *: Map((this["{key}"] == "{value}"))


**And another DSL phrase to check that instances are different
[when]The map *{mapVar1}* is not map *{mapVar2}*=*eval ({mapVar1}*["id"] 
!= *{mapVar2}*["id"]))*

*
But it will force your users to handle variables. I can't see simpler 
way for doing that with DSL.


You may consider completely another way. If your property lists are 
constant (and they are because you can create static enums), you can 
write a simple program to generate the corresponding POJOs (which 
contains the map inside them and use it in set/get methods for 
corresponding key) and create a jar with them.
Each POJO will then have its fields listed automatically in Guided 
Editor, which will prevent you for writing complex DSL and enums, and 
provide a good way for users to edit rules. For instance, you can bind 
an object to a variable only if you need it (with DSL you are forced to 
bind a variable at each time you use the phrase), and you can use other 
operator (not only equals) without writing a new DSL phrase.



I did not understand this question :

I have to put my rules in 4 drl files separate (i know which rules go 
in which drl file), is the only way to create a different package for 
each drl file i want? And to put the Enum and DSL part in Global if i 
have to use it for the 4 files? If i want a precise name for my drl 
file, i have to give this exact name to the package?

But yes, a DSL (and enums) is specific to its package.

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


Re: [rules-users] Guvnor and drools implementation - questions

2011-03-03 Thread ioda100
Yes thanks it's working with enum like explained previously by Esteban. I
won't do it dynamic for now i think.

It's not always of the form ., i have some in .
or . but for these i can make a separate DSL that will cast
the string to int or long. Except if there is a better solution.

Another thing is that i will have for this DSL :
*[when]The property {key:ENUM:Map.properties} of the map is
{value}=Map((this["{key}"] == "{value}"))

The property 'prop1' of the map is 'val1'

But if i want to have a second rule : **"The property 'prop1' of the map is
'val1'" and the map is different of the first map found above. Let's say i
have an attribute ID in the Maps, i could check that (ID1 != ID2)*. But with
DSL i am a little lost of how to do that. With DRL i did like this :
$m1 : Map(this["prop1"] == "val1")
$m2 : Map((this["prop1"] == "val1") && (this["id"] != $m1["id"]))
*
i could do
**[when]The property {key:ENUM:Map.properties} of the map is {value} = $m1 :
Map((this["{key}"] == "{value}"))
but it will always be stored in $m1 so if i do : **"The property 'prop1' of
the map is 'val1'*" twice, the second will override the value of $m1.


I have to put my rules in 4 drl files separate (i know which rules go in
which drl file), is the only way to create a different package for each drl
file i want? And to put the Enum and DSL part in Global if i have to use it
for the 4 files? If i want a precise name for my drl file, i have to give
this exact name to the package?


I tried to use the test scenario to test all that so i have created a simple
Test Scenario.
In the Given part, i have selected Map. Then keySet, i put prop1, prop2...
and for entrySet, i put test1, test2... and i have made a simple rules that
check that prop1 is equal to "test1" but when i run the scenario, i got :
[Error: unable to find constructor for: java.util.Map] [Near : {... new
java.util.Map( }] ^ [Line: 1, Column: 0] . Is there something special to
do to test with Map?


I tried to put some drools code in a function but it seems to not work. For
example :
WorkingMemory wm = drools.getWorkingMemory();
wm.setGlobal("resultValue", "OK");
It's not a problem since i use DSL for this but i suppose it's normal.


Sorry for all these problems, a little lost with all functionnality of this
tool and manual doesn't talk a lot about this.

thanks

On Thu, Mar 3, 2011 at 2:22 PM, Esteban [via Drools - Java Rules Engine] <
ml-node+2625046-28794131-237...@n3.nabble.com> wrote:

> "Maps.properties" is just a name I choose for the enumeration. You can use
> whatever identifier you want, but. The identifier has to be of the form
> .. It has to have a dot (.). I think this is because
> enumeration were created for bind a fact type attribute to a list of values.
>
> Best Regards,
>
> 
>
> Esteban Aliverti
> - Developer @ http://www.plugtree.com
> - Blog @ http://ilesteban.wordpress.com
>
>
> 2011/3/3 Vincent Legendre <[hidden 
> email]
> >
>
>>  I don't think that enums needs to be linked to a Pojo attribute. To me it
>> is just an identifier used in ENUM DSL constraints. The 'properties' is not
>> an attribute of a Map. I think you could set it to whatever you like
>> (something more linked to your problem).
>>
>> For making that dynamic, it is explained in the guvnor 
>> doc(chapter 
>> "1.4.2.4.8. Data enumerations (drop down list configurations)" )
>>
>> 'Person.age' : (new com.yourco.DataHelper()).getListOfAges()
>>
>>
>> But I never tried that.
>>
>>
>> Le 02/03/2011 14:06, ioda100 a écrit :
>>
>> Really thank you, it's working fine. I will see if it's working for my
>> more difficult case.
>>
>>
>> On Tue, Mar 1, 2011 at 11:28 PM, Esteban [via Drools - Java Rules Engine]
>> <[hidden 
>> email]
>> > wrote:
>>
>>>  You need to create the DSL first.
>>> Follow these steps:
>>> 1.- Add java.util.Map to package imports (I think you already did this)
>>> 2.- Create a new Enumeration with the following content:
>>> *'Map.properties': ['prop1', 'prop2', 'prop3']*
>>> 3.- Create a new DSL with this content:
>>> *[when]The property {key:ENUM:Map.properties} of the map is
>>> {value}=Map((this["{key}"] == "{value}"))*
>>> 4.- Create a new Rule and add the DSL sentence to the WHEN part. You
>>> should see the drop down.
>>>
>>> Note the name of the enumeration and how the variable {key} is defined in
>>> the DSL. I think you can also read the enumerations from a Java Enum present
>>> on your model, but I'm not sure about it. Does anyone know about this?
>>>
>>>  Best Regards,
>>>
>>> 
>>>
>>> Esteban Aliverti
>>> - Developer @ http://www.plugtree.com
>>> - Blog @ http://ilesteban.wordpress.com
>>>
>>>
>>>  2011/3/1 ioda100 <[hidden 
>>> email]

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-03 Thread Esteban Aliverti
"Maps.properties" is just a name I choose for the enumeration. You can use
whatever identifier you want, but. The identifier has to be of the form
.. It has to have a dot (.). I think this is because
enumeration were created for bind a fact type attribute to a list of values.

Best Regards,



Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


2011/3/3 Vincent Legendre 

>  I don't think that enums needs to be linked to a Pojo attribute. To me it
> is just an identifier used in ENUM DSL constraints. The 'properties' is not
> an attribute of a Map. I think you could set it to whatever you like
> (something more linked to your problem).
>
> For making that dynamic, it is explained in the guvnor 
> doc(chapter 
> "1.4.2.4.8. Data enumerations (drop down list configurations)" )
>
> 'Person.age' : (new com.yourco.DataHelper()).getListOfAges()
>
>
> But I never tried that.
>
>
> Le 02/03/2011 14:06, ioda100 a écrit :
>
> Really thank you, it's working fine. I will see if it's working for my more
> difficult case.
>
>
> On Tue, Mar 1, 2011 at 11:28 PM, Esteban [via Drools - Java Rules Engine]
> <[hidden 
> email]
> > wrote:
>
>>  You need to create the DSL first.
>> Follow these steps:
>> 1.- Add java.util.Map to package imports (I think you already did this)
>> 2.- Create a new Enumeration with the following content:
>> *'Map.properties': ['prop1', 'prop2', 'prop3']*
>> 3.- Create a new DSL with this content:
>> *[when]The property {key:ENUM:Map.properties} of the map is
>> {value}=Map((this["{key}"] == "{value}"))*
>> 4.- Create a new Rule and add the DSL sentence to the WHEN part. You
>> should see the drop down.
>>
>> Note the name of the enumeration and how the variable {key} is defined in
>> the DSL. I think you can also read the enumerations from a Java Enum present
>> on your model, but I'm not sure about it. Does anyone know about this?
>>
>>  Best Regards,
>>
>> 
>>
>> Esteban Aliverti
>> - Developer @ http://www.plugtree.com
>> - Blog @ http://ilesteban.wordpress.com
>>
>>
>>  2011/3/1 ioda100 <[hidden 
>> email]
>> >
>>
>>> Yes but for this i will be obliged to create a POJO of an object. And for
>>> attributes of that object in DSL i can define values that can take this
>>> attribute?
>>>
>>> Maybe i don't understand but i don't see how to do with this.
>>>
>>> My case :
>>> I have Maps in the session. Each Map has for example 5 properties
>>> ("prop1", "prop2", "prop3", "prop4", "prop51") and the value is a string.
>>> The Map is Map but generally Object is a String.
>>> So in the When clause i have something like that :
>>> $m  : Map((this["prop1"] == "test1"))
>>> I have included java.utils.Map in Guvnor. So when i add a when clause i
>>> can choose Map in the list but impossible to have "prop1" to "prop5" in a
>>> drop down list for attributes of the Map.
>>> Would it be possible to create a Pojo for Map or would it be in conflict
>>> with the Map of Java?
>>>
>>> Thank you for your time
>>>
>>>
>>> Le 1/03/2011 17:55, Vincent Legendre [via Drools - Java Rules Engine] a
>>> écrit :
>>>
>>>  Le 01/03/2011 15:39, ioda100 a écrit :
>>>
>>> Thanks for your quick answer Esteban.
>>>
>>> 1) Ok i will have a look at DSL. In fact in my map i know all the
>>> properties (about 200). It would be cool to be able to have a drop down list
>>> with all these attributes as when we do it with objects for which we gave
>>> Pojo to Guvnor.
>>>
>>> You can define enumerations for a particular attribute.
>>> Inside a DSL you can constrain a placeholder with that enumeration.
>>> And finally, enums can be static, or dynamic (a interface to implement
>>> that returns a list of values).
>>>
>>> search the Guvnor's doc in these chapters
>>> 1.4.2.4.8. Data enumerations (drop down list configurations)
>>>
>>>   ___
>>> rules-users mailing list
>>> [hidden 
>>> email]
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>> --
>>>   If you reply to this email, your message will be added to the
>>> discussion below:
>>>
>>> http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2604255.html
>>>  To unsubscribe from Guvnor and drools implementation - questions, click
>>> here

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-03 Thread Vincent Legendre
Title: CARTE DE VISITE


  
  
I don't think that enums needs to be linked to a Pojo attribute. To
me it is just an identifier used in ENUM DSL constraints. The
'properties' is not an attribute of a Map. I think you could set it
to whatever you like (something more linked to your problem).

For making that dynamic, it is explained in the guvnor
  doc (
  chapter "1.4.2.4.8. Data enumerations (drop down list
  configurations)" )
'Person.age' : (new com.yourco.DataHelper()).getListOfAges()

But I never tried that.


Le 02/03/2011 14:06, ioda100 a écrit :
Really thank you, it's working fine. I will see if
  it's working for my more difficult case.
  
  
  On Tue, Mar 1, 2011 at 11:28 PM, Esteban
[via Drools - Java Rules Engine] <[hidden email]>
wrote:

   You need to create the DSL first.
Follow these steps:
1.- Add java.util.Map to package imports (I think you
already did this)
2.- Create a new Enumeration with the following content:
'Map.properties': ['prop1', 'prop2', 'prop3']
3.- Create a new DSL with this content:
[when]The property {key:ENUM:Map.properties} of the map
  is {value}=Map((this["{key}"] == "{value}"))
4.- Create a new Rule and add the DSL sentence to the WHEN
part. You should see the drop down.

Note the name of the enumeration and how the variable {key}
is defined in the DSL. I think you can also read the
enumerations from a Java Enum present on your model, but I'm
not sure about it. Does anyone know about this?

  
  Best Regards,



Esteban Aliverti
- Developer @ http://www.plugtree.com 
- Blog @ http://ilesteban.wordpress.com


  
  
2011/3/1 ioda100 <[hidden
  email]>

 Yes but for
  this i will be obliged to create a POJO of an object. And
  for attributes of that object in DSL i can define values
  that can take this attribute?
  

  Maybe i don't understand but i don't see how to do
  with this.
  
  My case :
  I have Maps in the session. Each Map has for example 5
  properties ("prop1", "prop2", "prop3", "prop4",
  "prop51") and the value is a string. The Map is
  Map but generally Object is a
  String.
  So in the When clause i have something like that :
      $m  : Map((this["prop1"] ==
"test1"))
  I have included java.utils.Map in Guvnor. So when i
  add a when clause i can choose Map in the list but
  impossible to have "prop1" to "prop5" in a drop down
  list for attributes of the Map.
  Would it be possible to create a Pojo for Map or would
  it be in conflict with the Map of Java?
  
  Thank you for your time
  
  
  Le 1/03/2011 17:55, Vincent Legendre [via Drools -
  Java Rules Engine] a écrit :
  

   Le 01/03/2011 15:39, ioda100 a écrit :
 Thanks for your quick answer
  Esteban.
  
  1) Ok i will have a look at DSL. In fact in my
  map i know all the properties (about 200). It
  would be cool to be able to have a drop down
  list with all these attributes as when we do
  it with objects for which we gave Pojo to
  Guvnor. 

You can define enumerations for a particular
attribute. 
Inside a DSL you can constrain a placeholder
with that enumeration. 
And finally, enums can be static, or dynamic (a
interface to implement that returns a list of
values).

search the Guvnor's doc in these chapters
1.4.2.4.8. Data

enumerations (drop down list configurations)


  


  ___ 
  rule

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-02 Thread ioda100
Really thank you, it's working fine. I will see if it's working for my more
difficult case.


On Tue, Mar 1, 2011 at 11:28 PM, Esteban [via Drools - Java Rules Engine] <
ml-node+2607065-1249571055-237...@n3.nabble.com> wrote:

> You need to create the DSL first.
> Follow these steps:
> 1.- Add java.util.Map to package imports (I think you already did this)
> 2.- Create a new Enumeration with the following content:
> *'Map.properties': ['prop1', 'prop2', 'prop3']*
> 3.- Create a new DSL with this content:
> *[when]The property {key:ENUM:Map.properties} of the map is
> {value}=Map((this["{key}"] == "{value}"))*
> 4.- Create a new Rule and add the DSL sentence to the WHEN part. You should
> see the drop down.
>
> Note the name of the enumeration and how the variable {key} is defined in
> the DSL. I think you can also read the enumerations from a Java Enum present
> on your model, but I'm not sure about it. Does anyone know about this?
>
> Best Regards,
>
> 
>
> Esteban Aliverti
> - Developer @ http://www.plugtree.com
> - Blog @ http://ilesteban.wordpress.com
>
>
> 2011/3/1 ioda100 <[hidden 
> email]
> >
>
>> Yes but for this i will be obliged to create a POJO of an object. And for
>> attributes of that object in DSL i can define values that can take this
>> attribute?
>>
>> Maybe i don't understand but i don't see how to do with this.
>>
>> My case :
>> I have Maps in the session. Each Map has for example 5 properties
>> ("prop1", "prop2", "prop3", "prop4", "prop51") and the value is a string.
>> The Map is Map but generally Object is a String.
>> So in the When clause i have something like that :
>> $m  : Map((this["prop1"] == "test1"))
>> I have included java.utils.Map in Guvnor. So when i add a when clause i
>> can choose Map in the list but impossible to have "prop1" to "prop5" in a
>> drop down list for attributes of the Map.
>> Would it be possible to create a Pojo for Map or would it be in conflict
>> with the Map of Java?
>>
>> Thank you for your time
>>
>>
>> Le 1/03/2011 17:55, Vincent Legendre [via Drools - Java Rules Engine] a
>> écrit :
>>
>> Le 01/03/2011 15:39, ioda100 a écrit :
>>
>> Thanks for your quick answer Esteban.
>>
>> 1) Ok i will have a look at DSL. In fact in my map i know all the
>> properties (about 200). It would be cool to be able to have a drop down list
>> with all these attributes as when we do it with objects for which we gave
>> Pojo to Guvnor.
>>
>> You can define enumerations for a particular attribute.
>> Inside a DSL you can constrain a placeholder with that enumeration.
>> And finally, enums can be static, or dynamic (a interface to implement
>> that returns a list of values).
>>
>> search the Guvnor's doc in these chapters
>> 1.4.2.4.8. Data enumerations (drop down list configurations)
>>
>> ___
>> rules-users mailing list
>> [hidden 
>> email]
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>> --
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2604255.html
>>  To unsubscribe from Guvnor and drools implementation - questions, click
>> here.
>>
>>
>>
>> --
>> View this message in context: Re: Guvnor and drools implementation -
>> questions
>>
>> Sent from the Drools - User mailing list 
>> archiveat
>>  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
>
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2607065.html
>  To unsubscribe from Guvnor and drools implementation - questions, click
> here

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-01 Thread ioda100
Really thank you for your help, i am new to Guvnor and the syntax is not 
so obvious when we do something less usual.

I will try that tomorrow

Le 1/03/2011 23:28, Esteban [via Drools - Java Rules Engine] a écrit :
> You need to create the DSL first.
> Follow these steps:
> 1.- Add java.util.Map to package imports (I think you already did this)
> 2.- Create a new Enumeration with the following content:
> *'Map.properties': ['prop1', 'prop2', 'prop3']*
> 3.- Create a new DSL with this content:
> *[when]The property {key:ENUM:Map.properties} of the map is 
> {value}=Map((this["{key}"] == "{value}"))*
> 4.- Create a new Rule and add the DSL sentence to the WHEN part. You 
> should see the drop down.
>
> Note the name of the enumeration and how the variable {key} is defined 
> in the DSL. I think you can also read the enumerations from a Java 
> Enum present on your model, but I'm not sure about it. Does anyone 
> know about this?
>
> Best Regards,
>
> 
>
> Esteban Aliverti
> - Developer @ http://www.plugtree.com 
> - Blog @ http://ilesteban.wordpress.com
>
>
> 2011/3/1 ioda100 <[hidden email] 
> >
>
> Yes but for this i will be obliged to create a POJO of an object.
> And for attributes of that object in DSL i can define values that
> can take this attribute?
> Maybe i don't understand but i don't see how to do with this.
>
> My case :
> I have Maps in the session. Each Map has for example 5 properties
> ("prop1", "prop2", "prop3", "prop4", "prop51") and the value is a
> string. The Map is Map but generally Object is a
> String.
> So in the When clause i have something like that :
> $m  : Map((this["prop1"] == "test1"))
> I have included java.utils.Map in Guvnor. So when i add a when
> clause i can choose Map in the list but impossible to have "prop1"
> to "prop5" in a drop down list for attributes of the Map.
> Would it be possible to create a Pojo for Map or would it be in
> conflict with the Map of Java?
>
> Thank you for your time
>
>
> Le 1/03/2011 17:55, Vincent Legendre [via Drools - Java Rules
> Engine] a écrit :
>> Le 01/03/2011 15:39, ioda100 a écrit :
>>> Thanks for your quick answer Esteban.
>>>
>>> 1) Ok i will have a look at DSL. In fact in my map i know all
>>> the properties (about 200). It would be cool to be able to have
>>> a drop down list with all these attributes as when we do it with
>>> objects for which we gave Pojo to Guvnor.
>> You can define enumerations for a particular attribute.
>> Inside a DSL you can constrain a placeholder with that enumeration.
>> And finally, enums can be static, or dynamic (a interface to
>> implement that returns a list of values).
>>
>> search the Guvnor's doc in these chapters
>>
>>
>>   1.4.2.4.8. Data enumerations (drop down list
>>   configurations)
>>
>>
>>
>> ___
>> rules-users mailing list
>> [hidden email]
>> 
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>> 
>> If you reply to this email, your message will be added to the
>> discussion below:
>> 
>> http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2604255.html
>> 
>> 
>>
>> To unsubscribe from Guvnor and drools implementation - questions,
>> click here
>> 
>> .
>>
>
> 
> View this message in context: Re: Guvnor and drools implementation
> - questions
> 
> 
> 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
>
>
> 
> If you reply to this email, your message will be added to the 
> discussion below:
> http://drools-java-rules-engine.46999.n3.

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-01 Thread Esteban Aliverti
Even more; if you don't want to rule's authors to see the real key value of
the map in the drop down, you can use aliases in the enumeration definition:
*'Map.properties': ['prop1=Property 1', 'prop2=Property 2', 'prop3=Property
3']

*Best Regards,*

*

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


On Tue, Mar 1, 2011 at 7:24 PM, Esteban Aliverti  wrote:

> You need to create the DSL first.
> Follow these steps:
> 1.- Add java.util.Map to package imports (I think you already did this)
> 2.- Create a new Enumeration with the following content:
> *'Map.properties': ['prop1', 'prop2', 'prop3']*
> 3.- Create a new DSL with this content:
> *[when]The property {key:ENUM:Map.properties} of the map is
> {value}=Map((this["{key}"] == "{value}"))*
> 4.- Create a new Rule and add the DSL sentence to the WHEN part. You should
> see the drop down.
>
> Note the name of the enumeration and how the variable {key} is defined in
> the DSL. I think you can also read the enumerations from a Java Enum present
> on your model, but I'm not sure about it. Does anyone know about this?
>
>
> Best Regards,
>
> 
>
> Esteban Aliverti
> - Developer @ http://www.plugtree.com
> - Blog @ http://ilesteban.wordpress.com
>
>
> 2011/3/1 ioda100 
>
>> Yes but for this i will be obliged to create a POJO of an object. And for
>> attributes of that object in DSL i can define values that can take this
>> attribute?
>>
>> Maybe i don't understand but i don't see how to do with this.
>>
>> My case :
>> I have Maps in the session. Each Map has for example 5 properties
>> ("prop1", "prop2", "prop3", "prop4", "prop51") and the value is a string.
>> The Map is Map but generally Object is a String.
>> So in the When clause i have something like that :
>> $m  : Map((this["prop1"] == "test1"))
>> I have included java.utils.Map in Guvnor. So when i add a when clause i
>> can choose Map in the list but impossible to have "prop1" to "prop5" in a
>> drop down list for attributes of the Map.
>> Would it be possible to create a Pojo for Map or would it be in conflict
>> with the Map of Java?
>>
>> Thank you for your time
>>
>>
>> Le 1/03/2011 17:55, Vincent Legendre [via Drools - Java Rules Engine] a
>> écrit :
>>
>> Le 01/03/2011 15:39, ioda100 a écrit :
>>
>> Thanks for your quick answer Esteban.
>>
>> 1) Ok i will have a look at DSL. In fact in my map i know all the
>> properties (about 200). It would be cool to be able to have a drop down list
>> with all these attributes as when we do it with objects for which we gave
>> Pojo to Guvnor.
>>
>> You can define enumerations for a particular attribute.
>> Inside a DSL you can constrain a placeholder with that enumeration.
>> And finally, enums can be static, or dynamic (a interface to implement
>> that returns a list of values).
>>
>> search the Guvnor's doc in these chapters
>> 1.4.2.4.8. Data enumerations (drop down list configurations)
>>
>> ___
>> rules-users mailing list
>> [hidden 
>> email]
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>> --
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2604255.html
>>  To unsubscribe from Guvnor and drools implementation - questions, click
>> here.
>>
>>
>>
>> --
>> View this message in context: Re: Guvnor and drools implementation -
>> questions
>> Sent from the Drools - User mailing list 
>> archiveat
>>  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] Guvnor and drools implementation - questions

2011-03-01 Thread Esteban Aliverti
You need to create the DSL first.
Follow these steps:
1.- Add java.util.Map to package imports (I think you already did this)
2.- Create a new Enumeration with the following content:
*'Map.properties': ['prop1', 'prop2', 'prop3']*
3.- Create a new DSL with this content:
*[when]The property {key:ENUM:Map.properties} of the map is
{value}=Map((this["{key}"] == "{value}"))*
4.- Create a new Rule and add the DSL sentence to the WHEN part. You should
see the drop down.

Note the name of the enumeration and how the variable {key} is defined in
the DSL. I think you can also read the enumerations from a Java Enum present
on your model, but I'm not sure about it. Does anyone know about this?

Best Regards,



Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


2011/3/1 ioda100 

> Yes but for this i will be obliged to create a POJO of an object. And for
> attributes of that object in DSL i can define values that can take this
> attribute?
> Maybe i don't understand but i don't see how to do with this.
>
> My case :
> I have Maps in the session. Each Map has for example 5 properties ("prop1",
> "prop2", "prop3", "prop4", "prop51") and the value is a string. The Map is
> Map but generally Object is a String.
> So in the When clause i have something like that :
> $m  : Map((this["prop1"] == "test1"))
> I have included java.utils.Map in Guvnor. So when i add a when clause i can
> choose Map in the list but impossible to have "prop1" to "prop5" in a drop
> down list for attributes of the Map.
> Would it be possible to create a Pojo for Map or would it be in conflict
> with the Map of Java?
>
> Thank you for your time
>
>
> Le 1/03/2011 17:55, Vincent Legendre [via Drools - Java Rules Engine] a
> écrit :
>
> Le 01/03/2011 15:39, ioda100 a écrit :
>
> Thanks for your quick answer Esteban.
>
> 1) Ok i will have a look at DSL. In fact in my map i know all the
> properties (about 200). It would be cool to be able to have a drop down list
> with all these attributes as when we do it with objects for which we gave
> Pojo to Guvnor.
>
> You can define enumerations for a particular attribute.
> Inside a DSL you can constrain a placeholder with that enumeration.
> And finally, enums can be static, or dynamic (a interface to implement that
> returns a list of values).
>
> search the Guvnor's doc in these chapters
> 1.4.2.4.8. Data enumerations (drop down list configurations)
>
> ___
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2604255.html
>  To unsubscribe from Guvnor and drools implementation - questions, click
> here.
>
>
>
> --
> View this message in context: Re: Guvnor and drools implementation -
> questions
> Sent from the Drools - User mailing list 
> archiveat
>  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] Guvnor and drools implementation - questions

2011-03-01 Thread ioda100
Yes but for this i will be obliged to create a POJO of an object. And 
for attributes of that object in DSL i can define values that can take 
this attribute?
Maybe i don't understand but i don't see how to do with this.

My case :
I have Maps in the session. Each Map has for example 5 properties 
("prop1", "prop2", "prop3", "prop4", "prop51") and the value is a 
string. The Map is Map but generally Object is a String.
So in the When clause i have something like that :
$m  : Map((this["prop1"] == "test1"))
I have included java.utils.Map in Guvnor. So when i add a when clause i 
can choose Map in the list but impossible to have "prop1" to "prop5" in 
a drop down list for attributes of the Map.
Would it be possible to create a Pojo for Map or would it be in conflict 
with the Map of Java?

Thank you for your time


Le 1/03/2011 17:55, Vincent Legendre [via Drools - Java Rules Engine] a 
écrit :
> Le 01/03/2011 15:39, ioda100 a écrit :
>> Thanks for your quick answer Esteban.
>>
>> 1) Ok i will have a look at DSL. In fact in my map i know all the 
>> properties (about 200). It would be cool to be able to have a drop 
>> down list with all these attributes as when we do it with objects for 
>> which we gave Pojo to Guvnor.
> You can define enumerations for a particular attribute.
> Inside a DSL you can constrain a placeholder with that enumeration.
> And finally, enums can be static, or dynamic (a interface to implement 
> that returns a list of values).
>
> search the Guvnor's doc in these chapters
>
>
>   1.4.2.4.8. Data enumerations (drop down list configurations)
>
>
>
> ___
> rules-users mailing list
> [hidden email] 
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> 
> If you reply to this email, your message will be added to the 
> discussion below:
> http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2604255.html
>  
>
> To unsubscribe from Guvnor and drools implementation - questions, 
> click here 
> .
>  
>


-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2606843.html
Sent from the Drools - User 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] Guvnor and drools implementation - questions

2011-03-01 Thread Eddy Hautot
thank you i will try for the global constant

for the halt, i see a lot of trouble on it on google, i think i will let
like this

2011/3/1 Wolfgang Laun 

>
>
> 2011/3/1 ioda100 
>
> Thanks for your quick answer Esteban.
>>
>> 1) Ok i will have a look at DSL. In fact in my map i know all the
>> properties (about 200). It would be cool to be able to have a drop down list
>> with all these attributes as when we do it with objects for which we gave
>> Pojo to Guvnor.
>>
>>
>> 2) Yes i set the global constant i my application and put it in the
>> session. But when a rule fire, it has to send back a value "OK" for example
>> to the application. So i use the global consatnt to do that. As you say
>> guvnor don't create a working memory (needed to change the global constant),
>> i have to write by hand the lines : WorkingMemory wm =
>> drools.getWorkingMemory();
>> wm.setGlobal("resultValue", "OK"); ?
>>
>> I would not change the entire global object; I would just change a field:
>global Result result;
>...
>then
>result.setValue( "OK ");
>
>
>
>> i use version 5.1 of drools and guvnor.
>>
>> 3) ok i will stay with this solution. yes i only need to stop after the
>> end of the rule that has successfully fired. I have tried other things like
>> workingMemory.stop() or something like this but it was not working.
>>
>>
> Calling fireUntilHalt() and calling halt() from an ActivationEventListener
> would be a technique that doesn't require any messing with the rules.
> (Except, to be on the safe side, the addition of a very low-salience rule
> acting as a sentinel if nothing else fires.)
>
> -W
>
>
>> Thank you again
>>
>>
>>
>>
>> On Tue, Mar 1, 2011 at 1:55 PM, Esteban [via Drools - Java Rules Engine]
>> <[hidden email] >wrote:
>>
>>> Hi,
>>>
>>> 1) my facts are in fact java Maps, is there an easy way to deal with them
>>> in
>>> guvnor? it's not like in the example where facts are objects and we give
>>> guvnor the Pojo model to know what we can do with it
>>>
>>> for example i have :
>>> $m  : Map((this["attribute1_of_the_map"] == "test1"))
>>>
>>> How to deal with the map and have a prepopulated list of properties of
>>> the
>>> map? And to store it in the variable $m. Without using the "free from
>>> drl"
>>> where we have to write it by hand.
>>>
>>>  I think you could use DSL for achieve this. You could define your own
>>> DSL saying for example *There is a
>>> Test=Map((this["attribute1_of_the_map"] == "test1" *I would leave the
>>> variable binding to the editor. So when you add this particular pattern to a
>>> rule, you can bind it it you want to.
>>>
>>> 2) how to deal with global constant with guvnor?
>>>
>>> i have something like :
>>> WorkingMemory wm = drools.getWorkingMemory();
>>> wm.setGlobal("resultValue", "OK");
>>>
>>> Is it a direct way to play with global constant in Guvnor? Without using
>>> the
>>> "free from drl" where we have to write it by hand.
>>>
>>> The values of the globals are set in runtime. Guvnor doesn't create any
>>> ksession (or working memory) for rules authoring. There is no need to do
>>> that. So, you can declare your globals in Guvnor's package area  and then
>>> use them in your rules. When an application uses these rules, and creates a
>>> ksession from them, it must provide the value for these globals.
>>> By the way, which version of Drools are you using?
>>>
>>> 3) for stopping firing rules after one rule fire successfully, do you
>>> know
>>> if there is an option to do that?
>>> For now i insert a boolean in the session and the first condition in all
>>> my
>>> rules is that this boolean is there. When a rule fires successfully, i
>>> retract it. I suppose there is a bettre way to do it?
>>>
>>> I think the approach you have chosen is elegant enough. Of course that it
>>> will only prevents new activations to happen but it will not prevent current
>>> activations to be executed. For a cleaner implementation, you can make a
>>> super-rule with that condition and then make all your rules to inherit from
>>> it.
>>> There is actually a way to force the engine to stop (I don't remember it,
>>> but I'm pretty sure it is documented), but I don't know if that would be the
>>> best solution since I don't know if it has any collateral effect.
>>>
>>> Best Regards,
>>>
>>>
>>> 
>>>
>>> Esteban Aliverti
>>> - Developer @ http://www.plugtree.com
>>> - Blog @ http://ilesteban.wordpress.com
>>>
>>>
>>> On Tue, Mar 1, 2011 at 9:27 AM, ioda100 <[hidden 
>>> email]
>>> > wrote:
>>>
 Hi,

 i have a few questions :

 1) my facts are in fact java Maps, is there an easy way to deal with
 them in
 guvnor? it's not like in the example where facts are objects and we give
 guvnor the Pojo model to know what we can do with it

 for example i have :
 $m  : Map((this["attribute1_of_the

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-01 Thread Eddy Hautot
Thank you i will have a look to see exactly how to do.
When in the import i put import java.util.Map;  i have access to Map in the
objects in the When condition. So it's possible to have a drop-down list to
have the choice between all properties of the Map defined in a DSL file
(even dynamacally)?



2011/3/1 Vincent Legendre 

>  Le 01/03/2011 15:39, ioda100 a écrit :
>
> Thanks for your quick answer Esteban.
>
> 1) Ok i will have a look at DSL. In fact in my map i know all the
> properties (about 200). It would be cool to be able to have a drop down list
> with all these attributes as when we do it with objects for which we gave
> Pojo to Guvnor.
>
> You can define enumerations for a particular attribute.
> Inside a DSL you can constrain a placeholder with that enumeration.
> And finally, enums can be static, or dynamic (a interface to implement that
> returns a list of values).
>
> search the Guvnor's doc in these chapters
> 1.4.2.4.8. Data enumerations (drop down list configurations)
>
> ___
> 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] Guvnor and drools implementation - questions

2011-03-01 Thread Vincent Legendre

Le 01/03/2011 15:39, ioda100 a écrit :

Thanks for your quick answer Esteban.

1) Ok i will have a look at DSL. In fact in my map i know all the 
properties (about 200). It would be cool to be able to have a drop 
down list with all these attributes as when we do it with objects for 
which we gave Pojo to Guvnor.

You can define enumerations for a particular attribute.
Inside a DSL you can constrain a placeholder with that enumeration.
And finally, enums can be static, or dynamic (a interface to implement 
that returns a list of values).


search the Guvnor's doc in these chapters


 1.4.2.4.8. Data enumerations (drop down list configurations)


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


Re: [rules-users] Guvnor and drools implementation - questions

2011-03-01 Thread Wolfgang Laun
2011/3/1 ioda100 

> Thanks for your quick answer Esteban.
>
> 1) Ok i will have a look at DSL. In fact in my map i know all the
> properties (about 200). It would be cool to be able to have a drop down list
> with all these attributes as when we do it with objects for which we gave
> Pojo to Guvnor.
>
>
> 2) Yes i set the global constant i my application and put it in the
> session. But when a rule fire, it has to send back a value "OK" for example
> to the application. So i use the global consatnt to do that. As you say
> guvnor don't create a working memory (needed to change the global constant),
> i have to write by hand the lines : WorkingMemory wm =
> drools.getWorkingMemory();
> wm.setGlobal("resultValue", "OK"); ?
>
> I would not change the entire global object; I would just change a field:
   global Result result;
   ...
   then
   result.setValue( "OK ");



> i use version 5.1 of drools and guvnor.
>
> 3) ok i will stay with this solution. yes i only need to stop after the end
> of the rule that has successfully fired. I have tried other things like
> workingMemory.stop() or something like this but it was not working.
>
>
Calling fireUntilHalt() and calling halt() from an ActivationEventListener
would be a technique that doesn't require any messing with the rules.
(Except, to be on the safe side, the addition of a very low-salience rule
acting as a sentinel if nothing else fires.)

-W


> Thank you again
>
>
>
> On Tue, Mar 1, 2011 at 1:55 PM, Esteban [via Drools - Java Rules Engine] 
> <[hidden
> email] > wrote:
>
>> Hi,
>>
>> 1) my facts are in fact java Maps, is there an easy way to deal with them
>> in
>> guvnor? it's not like in the example where facts are objects and we give
>> guvnor the Pojo model to know what we can do with it
>>
>> for example i have :
>> $m  : Map((this["attribute1_of_the_map"] == "test1"))
>>
>> How to deal with the map and have a prepopulated list of properties of the
>> map? And to store it in the variable $m. Without using the "free from drl"
>> where we have to write it by hand.
>>
>>  I think you could use DSL for achieve this. You could define your own DSL
>> saying for example *There is a Test=Map((this["attribute1_of_the_map"] ==
>> "test1" *I would leave the variable binding to the editor. So when you
>> add this particular pattern to a rule, you can bind it it you want to.
>>
>> 2) how to deal with global constant with guvnor?
>>
>> i have something like :
>> WorkingMemory wm = drools.getWorkingMemory();
>> wm.setGlobal("resultValue", "OK");
>>
>> Is it a direct way to play with global constant in Guvnor? Without using
>> the
>> "free from drl" where we have to write it by hand.
>>
>> The values of the globals are set in runtime. Guvnor doesn't create any
>> ksession (or working memory) for rules authoring. There is no need to do
>> that. So, you can declare your globals in Guvnor's package area  and then
>> use them in your rules. When an application uses these rules, and creates a
>> ksession from them, it must provide the value for these globals.
>> By the way, which version of Drools are you using?
>>
>> 3) for stopping firing rules after one rule fire successfully, do you know
>> if there is an option to do that?
>> For now i insert a boolean in the session and the first condition in all
>> my
>> rules is that this boolean is there. When a rule fires successfully, i
>> retract it. I suppose there is a bettre way to do it?
>>
>> I think the approach you have chosen is elegant enough. Of course that it
>> will only prevents new activations to happen but it will not prevent current
>> activations to be executed. For a cleaner implementation, you can make a
>> super-rule with that condition and then make all your rules to inherit from
>> it.
>> There is actually a way to force the engine to stop (I don't remember it,
>> but I'm pretty sure it is documented), but I don't know if that would be the
>> best solution since I don't know if it has any collateral effect.
>>
>> Best Regards,
>>
>>
>> 
>>
>> Esteban Aliverti
>> - Developer @ http://www.plugtree.com
>> - Blog @ http://ilesteban.wordpress.com
>>
>>
>> On Tue, Mar 1, 2011 at 9:27 AM, ioda100 <[hidden 
>> email]
>> > wrote:
>>
>>> Hi,
>>>
>>> i have a few questions :
>>>
>>> 1) my facts are in fact java Maps, is there an easy way to deal with them
>>> in
>>> guvnor? it's not like in the example where facts are objects and we give
>>> guvnor the Pojo model to know what we can do with it
>>>
>>> for example i have :
>>> $m  : Map((this["attribute1_of_the_map"] == "test1"))
>>>
>>> How to deal with the map and have a prepopulated list of properties of
>>> the
>>> map? And to store it in the variable $m. Without using the "free from
>>> drl"
>>> where we have to write it by hand.
>>>
>>> 2) how to deal with global constant with guvnor?
>>>
>>> i have somethi

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-01 Thread ioda100
Thanks for your quick answer Esteban.

1) Ok i will have a look at DSL. In fact in my map i know all the properties
(about 200). It would be cool to be able to have a drop down list with all
these attributes as when we do it with objects for which we gave Pojo to
Guvnor.


2) Yes i set the global constant i my application and put it in the session.
But when a rule fire, it has to send back a value "OK" for example to the
application. So i use the global consatnt to do that. As you say guvnor
don't create a working memory (needed to change the global constant), i have
to write by hand the lines : WorkingMemory wm = drools.getWorkingMemory();
wm.setGlobal("resultValue", "OK"); ?

i use version 5.1 of drools and guvnor.

3) ok i will stay with this solution. yes i only need to stop after the end
of the rule that has successfully fired. I have tried other things like
workingMemory.stop() or something like this but it was not working.

Thank you again



On Tue, Mar 1, 2011 at 1:55 PM, Esteban [via Drools - Java Rules Engine] <
ml-node+2602877-745781886-237...@n3.nabble.com> wrote:

> Hi,
>
> 1) my facts are in fact java Maps, is there an easy way to deal with them
> in
> guvnor? it's not like in the example where facts are objects and we give
> guvnor the Pojo model to know what we can do with it
>
> for example i have :
> $m  : Map((this["attribute1_of_the_map"] == "test1"))
>
> How to deal with the map and have a prepopulated list of properties of the
> map? And to store it in the variable $m. Without using the "free from drl"
> where we have to write it by hand.
>
>  I think you could use DSL for achieve this. You could define your own DSL
> saying for example *There is a Test=Map((this["attribute1_of_the_map"] ==
> "test1" *I would leave the variable binding to the editor. So when you add
> this particular pattern to a rule, you can bind it it you want to.
>
> 2) how to deal with global constant with guvnor?
>
> i have something like :
> WorkingMemory wm = drools.getWorkingMemory();
> wm.setGlobal("resultValue", "OK");
>
> Is it a direct way to play with global constant in Guvnor? Without using
> the
> "free from drl" where we have to write it by hand.
>
> The values of the globals are set in runtime. Guvnor doesn't create any
> ksession (or working memory) for rules authoring. There is no need to do
> that. So, you can declare your globals in Guvnor's package area  and then
> use them in your rules. When an application uses these rules, and creates a
> ksession from them, it must provide the value for these globals.
> By the way, which version of Drools are you using?
>
> 3) for stopping firing rules after one rule fire successfully, do you know
> if there is an option to do that?
> For now i insert a boolean in the session and the first condition in all my
> rules is that this boolean is there. When a rule fires successfully, i
> retract it. I suppose there is a bettre way to do it?
>
> I think the approach you have chosen is elegant enough. Of course that it
> will only prevents new activations to happen but it will not prevent current
> activations to be executed. For a cleaner implementation, you can make a
> super-rule with that condition and then make all your rules to inherit from
> it.
> There is actually a way to force the engine to stop (I don't remember it,
> but I'm pretty sure it is documented), but I don't know if that would be the
> best solution since I don't know if it has any collateral effect.
>
> Best Regards,
>
>
> 
>
> Esteban Aliverti
> - Developer @ http://www.plugtree.com
> - Blog @ http://ilesteban.wordpress.com
>
>
> On Tue, Mar 1, 2011 at 9:27 AM, ioda100 <[hidden 
> email]
> > wrote:
>
>> Hi,
>>
>> i have a few questions :
>>
>> 1) my facts are in fact java Maps, is there an easy way to deal with them
>> in
>> guvnor? it's not like in the example where facts are objects and we give
>> guvnor the Pojo model to know what we can do with it
>>
>> for example i have :
>> $m  : Map((this["attribute1_of_the_map"] == "test1"))
>>
>> How to deal with the map and have a prepopulated list of properties of the
>> map? And to store it in the variable $m. Without using the "free from drl"
>> where we have to write it by hand.
>>
>> 2) how to deal with global constant with guvnor?
>>
>> i have something like :
>> WorkingMemory wm = drools.getWorkingMemory();
>> wm.setGlobal("resultValue", "OK");
>>
>> Is it a direct way to play with global constant in Guvnor? Without using
>> the
>> "free from drl" where we have to write it by hand.
>>
>> 3) for stopping firing rules after one rule fire successfully, do you know
>> if there is an option to do that?
>> For now i insert a boolean in the session and the first condition in all
>> my
>> rules is that this boolean is there. When a rule fires successfully, i
>> retract it. I suppose there is a bettre way to do it?
>>
>> Thanks in advance for your help
>>
>

Re: [rules-users] Guvnor and drools implementation - questions

2011-03-01 Thread Esteban Aliverti
Hi,

1) my facts are in fact java Maps, is there an easy way to deal with them in
guvnor? it's not like in the example where facts are objects and we give
guvnor the Pojo model to know what we can do with it

for example i have :
$m  : Map((this["attribute1_of_the_map"] == "test1"))

How to deal with the map and have a prepopulated list of properties of the
map? And to store it in the variable $m. Without using the "free from drl"
where we have to write it by hand.

I think you could use DSL for achieve this. You could define your own DSL
saying for example *There is a Test=Map((this["attribute1_of_the_map"] ==
"test1" *I would leave the variable binding to the editor. So when you add
this particular pattern to a rule, you can bind it it you want to.

2) how to deal with global constant with guvnor?

i have something like :
WorkingMemory wm = drools.getWorkingMemory();
wm.setGlobal("resultValue", "OK");

Is it a direct way to play with global constant in Guvnor? Without using the
"free from drl" where we have to write it by hand.

The values of the globals are set in runtime. Guvnor doesn't create any
ksession (or working memory) for rules authoring. There is no need to do
that. So, you can declare your globals in Guvnor's package area  and then
use them in your rules. When an application uses these rules, and creates a
ksession from them, it must provide the value for these globals.
By the way, which version of Drools are you using?

3) for stopping firing rules after one rule fire successfully, do you know
if there is an option to do that?
For now i insert a boolean in the session and the first condition in all my
rules is that this boolean is there. When a rule fires successfully, i
retract it. I suppose there is a bettre way to do it?

I think the approach you have chosen is elegant enough. Of course that it
will only prevents new activations to happen but it will not prevent current
activations to be executed. For a cleaner implementation, you can make a
super-rule with that condition and then make all your rules to inherit from
it.
There is actually a way to force the engine to stop (I don't remember it,
but I'm pretty sure it is documented), but I don't know if that would be the
best solution since I don't know if it has any collateral effect.

Best Regards,




Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


On Tue, Mar 1, 2011 at 9:27 AM, ioda100  wrote:

> Hi,
>
> i have a few questions :
>
> 1) my facts are in fact java Maps, is there an easy way to deal with them
> in
> guvnor? it's not like in the example where facts are objects and we give
> guvnor the Pojo model to know what we can do with it
>
> for example i have :
> $m  : Map((this["attribute1_of_the_map"] == "test1"))
>
> How to deal with the map and have a prepopulated list of properties of the
> map? And to store it in the variable $m. Without using the "free from drl"
> where we have to write it by hand.
>
> 2) how to deal with global constant with guvnor?
>
> i have something like :
> WorkingMemory wm = drools.getWorkingMemory();
> wm.setGlobal("resultValue", "OK");
>
> Is it a direct way to play with global constant in Guvnor? Without using
> the
> "free from drl" where we have to write it by hand.
>
> 3) for stopping firing rules after one rule fire successfully, do you know
> if there is an option to do that?
> For now i insert a boolean in the session and the first condition in all my
> rules is that this boolean is there. When a rule fires successfully, i
> retract it. I suppose there is a bettre way to do it?
>
> Thanks in advance for your help
>
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Guvnor-and-drools-implementation-questions-tp2602641p2602641.html
> Sent from the Drools - User 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