Re: [rules-users] Drools Activation Group
You misunderstood the term "fire", which is commonly used to say that a rule's consequence is executed. This means that you can't use activation-group to achieve what you want. What you mean when you write "fire" is the rule condition's evaluation. This is not a process that can be controlled easily. Moreover, it (generally) isn't a process that happens in one go: evaluation begins with the insertion (or update or retraction) of a fact, may be halted due to the absences of some other fact, and continue when that fact appears, and so on. The general advice is to write your conditions so that evaluation is safe in any case. In your case, "safe" means that the DB lookup must not be done for empty keys. To do so, omit the activation-group and write your second rule like so: rule "r2" when SomeObject($s: someStringKey) eval( ! sEmpty($s) && checkWithDB($s) ) then log("doSomething"); end -W 2011/11/29 Java Bean : > Hello Drools Experts, > > I have a question on activation group and trying to understand the > mechanism. > > I have the following rules in a .drl file : > > import function com.test.utils.StringUtil.isEmpty; > import function com.test.utils.Logger.log; > > rule "r1" > salience 10 > activation-group "fireOnlyOnce" > when > SomeObject($s: someStringKey) > eval(isEmpty($s) // static java method imported as function > then > log("doSomething"); > end > > rule "r2" > activation-group "fireOnlyOnce" > when > SomeObject($s: someStringKey) > eval(checkWithDB($s) // Make a call to the DB to validate > someStringKeyis valid > then > log("doSomething"); > end > > In "r1" I am checking for 'someStringKey' is not null or empty. In "r2" , I > am making a call to the DB to check 'someStringKey' is a valid id. During > the debug, I found out that both "r1" and "r2" is fired but only one > consequence is executed depending on the outcome of the r1. I want "r2" to > fire only when "r1" evaluates to false. How can I achieve this in Drools? > > Thanks for your time and appreciate your help. > > > ___ > 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] Dynamic Fact(field) Generation in Declarative Model
Really Thanks for your valuable answers and support Davidde.The context where I'm struggling is,I will explain you clearly. I have a Declarative Model named Person with two Fact fields Age,Amount.Now,I can add another fact field Gender here(By opening console,Add fact field).But,I need it as dynamically.It means,Whenever name of the attribute and type (gender-String)is passed to Eclipse drools Project,that class must be executed and that gender with datatype String must be inserted into Model Present in Drools Guvnor console. Which Predefined Classes I must use to achieve this..Can you please guide me in this to get rid of this issue.. Thanks in Advance Davidde.. -- View this message in context: http://drools.46999.n3.nabble.com/Dynamic-Fact-field-Generation-in-Declarative-Model-tp3545088p3547351.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] Retrieving all Packages that are present in Drools Guvnor console
Yes Mansits,I need to display the four packages which are present in the drools guvnor console.Suppose,these four packages are(Package1,Package2,Package3,Package4) having 4 rules respectively, In my POJO Class,I should retrieve all 4 package names along with the rules present in it.(present in guvnor console).So,the output must be Package1-Rule1 Package2-Rule2 Package3-Rule3 Package4-Rule4 How i can acheive this..Can you please say me..Thanks for your reply Manstis..Please help me out in solving this.. -- View this message in context: http://drools.46999.n3.nabble.com/Retrieving-all-Packages-that-are-present-in-Drools-Guvnor-console-tp3545186p3547330.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] JMS with drools expert
Is drools pipeline supported in drools5.2? can I use drools pipeline/smoke for JMS integration? (my use case=drools engine getting facts from JMS) I hope Edson Tirelli/Salaboy Mauricio Salatino may help this. thanks, - with kind regards, -- View this message in context: http://drools.46999.n3.nabble.com/JMS-with-drools-expert-tp3547129p3547129.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] Planner 5.3.Final - "presumedScore is corrupted" when using "update" on the rules working memory
I am looking into Planner for a schedule assignment business case. I created a move factory, got the local search phase set up and quicly ran into a "presumedScore is corrupted because it is not the realScore" error. As a work around, I changed my Move::doMove(..) implementation to "retract" then "insert" rather than "update" the new updated planning entity and the issue went away. Then I worked on setting a construction heuristic and I again ran into the same error. By applying a local code patch to the PlanningValueWalker::changeWorkingValue(..) method to also "retract" and "insert" rather than "update" also fixed the issue. I also tried to correctly implement the hashCode() and equals(..) methods on my planning entity (as mentioned in Drools Expert documentation) as well as use the default implementation of those methods (as in the nurse rostering example) with the same unsuccessful results. I must mention than I am able to run the nurse rostering example without any issues. Could someone maybe point me to the right direction on why "update" does not work for me? I can provide detailed information if needed. Thanks, Guy -- View this message in context: http://drools.46999.n3.nabble.com/Planner-5-3-Final-presumedScore-is-corrupted-when-using-update-on-the-rules-working-memory-tp3546932p3546932.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] Call query from other query
did this work for you? I'm hoping users can start to tell others how they are using backward chaining, we need some successs "how to" stories out there, maybe a tutorial or two :) Mark On Mon, Nov 28, 2011 at 10:48 PM, Mark Proctor wrote: > The query is treated just like a pattern. ? indicates whether the query > should be materialised or not. In general if you aren't sure, then don't > include the ? and let it materialise. > > The queries do not return any results, they are not functions. Like > patterns the resuls are returned from out variable bindings in the > parameters. The work in the same way that prolog predicates work, and you > can find tuns of literatore on that. > > see 2.2.2.8 has a fair overview of this: > > http://docs.jboss.org/drools/release/5.3.0.Final/droolsjbpm-introduction-docs/html/releaseNotes.html#d0e50 > > see 5.9 here: > > http://docs.jboss.org/drools/release/5.3.0.Final/drools-expert-docs/html/ch05.html#d0e6233 > > This should work for your example: > query query1(List $facts) >$facts := List() from collect( Fact( name == "name1" ) ) > end > > query query2 >query1($l;) > end > > The above $l should join with the results of query1, as it's unbound and > thus an output variable. > > Mark > > > On Mon, Nov 28, 2011 at 12:41 PM, Syargey wrote: > >> I read in Drools guide, that queries can now call other queries. >> >> But the guide doesn't give much details, mostly paying attention to a >> rather >> specific case. >> >> I have two queries having common parts and try to figure out how to get >> rid >> of duplicate code. >> >> Here is the simplified form of queries I'd like to have: >> - >> >> query query1 >>$facts: List() >>from collect( Fact( name == "name1" ) ) >> end >> >> query query2 >>$l: List() >>from collect( Fact( value == "1" ) from ?query1() ) >> end >> >> - >> >> query2 syntax is invalid and and it is not clear for me how $facts from >> query1 can be accessed in query2. >> >> >> -- >> View this message in context: >> http://drools.46999.n3.nabble.com/Call-query-from-other-query-tp3542082p3542082.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
[rules-users] Drools Activation Group
Hello Drools Experts, I have a question on activation group and trying to understand the mechanism. I have the following rules in a .drl file : import function com.test.utils.StringUtil.isEmpty; import function com.test.utils.Logger.log; rule "r1" salience 10 activation-group "fireOnlyOnce" when SomeObject($s: someStringKey) eval(isEmpty($s) // static java method imported as function then log("doSomething"); end rule "r2" activation-group "fireOnlyOnce" when SomeObject($s: someStringKey) eval(checkWithDB($s) // Make a call to the DB to validate someStringKeyis valid then log("doSomething"); end In "r1" I am checking for 'someStringKey' is not null or empty. In "r2" , I am making a call to the DB to check 'someStringKey' is a valid id. During the debug, I found out that both "r1" and "r2" is fired but only one consequence is executed depending on the outcome of the r1. I want "r2" to fire only when "r1" evaluates to false. How can I achieve this in Drools? Thanks for your time and appreciate your help. -- View this message in context: http://drools.46999.n3.nabble.com/Drools-Activation-Group-tp3546607p3546607.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] Drools Activation Group
Hello Drools Experts, I have a question on activation group and trying to understand the mechanism. I have the following rules in a .drl file : import function com.test.utils.StringUtil.isEmpty; import function com.test.utils.Logger.log; rule "r1" salience 10 activation-group "fireOnlyOnce" when SomeObject($s: someStringKey) eval(isEmpty($s) // static java method imported as function then log("doSomething"); end rule "r2" activation-group "fireOnlyOnce" when SomeObject($s: someStringKey) eval(checkWithDB($s) // Make a call to the DB to validate someStringKeyis valid then log("doSomething"); end In "r1" I am checking for 'someStringKey' is not null or empty. In "r2" , I am making a call to the DB to check 'someStringKey' is a valid id. During the debug, I found out that both "r1" and "r2" is fired but only one consequence is executed depending on the outcome of the r1. I want "r2" to fire only when "r1" evaluates to false. How can I achieve this in Drools? Thanks for your time and appreciate your help. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] drools5.2 integrate with JMS
Hi, I would like to integrate JMS with drools 5.2. I have a confusion over selecting right approach. I noticed from the mailing list drools pipeline is depricated so I assume that not recomended now. So ignored it than look for another option but not using spring? when i check the user forum I not getting any right direction insted more confusion selecting rigt tool. Can some one help me to provide me some info about integration JMS with drools without using spring?i am using drools5.2 thanks lot, - with kind regards, -- View this message in context: http://drools.46999.n3.nabble.com/drools5-2-integrate-with-JMS-tp3546100p3546100.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] Dynamic Fact(field) Generation in Declarative Model
The main issue here is whether you need to "hot-swap" the class definition or not. In the best scenario, you have two independent sub-applications: one is managing the fact type, the other is using it, and the two never run together. In this case, you could just declare your datatype in a separate DRL file, created programmatically. The syntax is trivial enough: package myPackage; declare YourClass field1 : type1 ... fieldN : typeN end Then, you can upload/update the resource in Guvnor: the next time your package is compiled, you will see the latest version of the fact type. (sorry, but I dont' remember DroolsGuvnor 5.0 APIs, so this is all I can tell you) --- IF, instead, you have to modify the class AS YOU ARE using it, e.g.: when Person( name == "x" ) then /* add field gender to Person */ end then let me know, but the drawbacks might be more than the benefits. Instances of the "old" version will not be compatible with instances of the "new" one... Rules will likely be updated as well, so they would no longer work with the "old" facts. You'd have to manage the migration manually. You might as well opt for a completely dynamic data model? Uglier and you lose strict typing, I know... declare Person attributes : Map end you'd have to change the way you write your rules, and I'm not sure that 5.0 already supported this: Person( name == "x" ) > Person( attributes["name"] == "x" ) Consider also that 5.0 is a quite old version, many features related to this functionality have been corrected and added in later versions Btw, what's exactly the point in adding a field? Are you also adding rules using that additional field? Could you please provide more details on your app and requirements? Thanks D -- View this message in context: http://drools.46999.n3.nabble.com/Dynamic-Fact-field-Generation-in-Declarative-Model-tp3545088p3545400.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] inconsistent behavior with the eclipse IDE and the Drools compiler
Inside parentheses, the getTimelineDescriptor calls need an object. Without parentheses, the implied object is this. But 5.2.0 did not implement "free form expressions" fully. -W 2011/11/29 Hezi Stern : > > > Hi all, > > > > I encountered the following strange inconsistent behavior with the eclipse > IDE and the Drools compiler. > > > > I have the following test rule which should fire if a specific time > condition is present. The time condition is evaluated by a function called > getTimelineDescriptor() which is imported using import function. > > > > rule "ScheduleTime: request for explicit time arrived" > > > > when > > ConditionMatrix(descriptors.times.timeline contains > getTimelineDescriptor(EButtonID.TIME_SPECIFIC) || > > descriptors.times.timeline contains > getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME) || > > descriptors.times.timeline contains > getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME), > > $srcAlt: > srcWorkingAlternative, > > > ) > > > > then > > //something... > > > > end > > > > the IDE indicates an error on the conditionMatrix line with the following > description: > > Multiple markers at this line > > - [ERR 101] Line 123:77 no viable alternative at input '(' in rule > "ScheduleTime: request for explicit time arrived" in pattern ConditionMatrix > > - [ERR 102] Line 123:103 mismatched input '||' expecting 'then' in rule > "ScheduleTime: request for explicit time arrived" > > - [ERR 101] Line 123:101 no viable alternative at input ')' in rule > "ScheduleTime: request for explicit time arrived" in pattern > getTimelineDescriptor > > > > BUT it compiles ok and runs properly. > > > > When I wrap the function with brackets (as I thought it should be) like this > > > > rule "ScheduleTime: request for explicit time arrived" > > > > when > > ConditionMatrix(descriptors.times.timeline contains > (getTimelineDescriptor(EButtonID.TIME_SPECIFIC)) || > > descriptors.times.timeline contains > (getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME)) || > > descriptors.times.timeline contains > (getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME)), > > $srcAlt: > srcWorkingAlternative, > > > ) > > > > then > > //something... > > > > end > > > > the IDE shows no error but the compilation fails with the following error: > > 16:19:14,734 [ERROR] [LoggerStream]: Unable to Analyse Expression > descriptors.times.timeline contains > (getTimelineDescriptor(EButtonID.TIME_SPECIFIC)) || > descriptors.times.timeline contains > (getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME)) || > descriptors.times.timeline contains > (getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME)): > > [Error: unable to resolve method using strict-mode: > com.delegatecom.rules.ConditionMatrix.contains(com.delegatecom.nlp.api.TimelineDescriptor)] > > [Near : {... tors.times.timeline contains (getTimelineDescripto }] > > > > I am using Drools 5.2 with Helios (Eclipse). > > Any ideas why this is so? Although I have a working option it is impossible > to maintain code when there are error indications. > > > > Thanks, > > Hezi > > > > > ___ > 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] Retrieving all Packages that are present in Drools Guvnor console
Can you explain more what you want to achieve? Do you mean you want to show the content of four packages in Guvnor at once, or you have your own application? If you have your own application I'd recommend looking into the REST API available in Guvnor to retrieve a list of packages and their content. With kind regards, Mike On 29 November 2011 13:31, srinivasasanda wrote: > In Drools Guvnor Console,I'm having 4 packages..I need to display all 4 > packages in the console through a POJO class..How can i access all > packages..Please help me...How can i do it..I was strucked here..Please > help > me out...Please. > > Thanks in Advance. > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Retrieving-all-Packages-that-are-present-in-Drools-Guvnor-console-tp3545186p3545186.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
[rules-users] inconsistent behavior with the eclipse IDE and the Drools compiler
Hi all, I encountered the following strange inconsistent behavior with the eclipse IDE and the Drools compiler. I have the following test rule which should fire if a specific time condition is present. The time condition is evaluated by a function called getTimelineDescriptor() which is imported using import function. rule "ScheduleTime: request for explicit time arrived" when ConditionMatrix(descriptors.times.timeline contains getTimelineDescriptor(EButtonID.TIME_SPECIFIC) || descriptors.times.timeline contains getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME) || descriptors.times.timeline contains getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME), $srcAlt: srcWorkingAlternative, ) then //something... end the IDE indicates an error on the conditionMatrix line with the following description: Multiple markers at this line - [ERR 101] Line 123:77 no viable alternative at input '(' in rule "ScheduleTime: request for explicit time arrived" in pattern ConditionMatrix - [ERR 102] Line 123:103 mismatched input '||' expecting 'then' in rule "ScheduleTime: request for explicit time arrived" - [ERR 101] Line 123:101 no viable alternative at input ')' in rule "ScheduleTime: request for explicit time arrived" in pattern getTimelineDescriptor BUT it compiles ok and runs properly. When I wrap the function with brackets (as I thought it should be) like this rule "ScheduleTime: request for explicit time arrived" when ConditionMatrix(descriptors.times.timeline contains (getTimelineDescriptor(EButtonID.TIME_SPECIFIC)) || descriptors.times.timeline contains (getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME)) || descriptors.times.timeline contains (getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME)), $srcAlt: srcWorkingAlternative, ) then //something... end the IDE shows no error but the compilation fails with the following error: 16:19:14,734 [ERROR] [LoggerStream]: Unable to Analyse Expression descriptors.times.timeline contains (getTimelineDescriptor(EButtonID.TIME_SPECIFIC)) || descriptors.times.timeline contains (getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME)) || descriptors.times.timeline contains (getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME)): [Error: unable to resolve method using strict-mode: com.delegatecom.rules.ConditionMatrix.contains(com.delegatecom.nlp.api.Timel ineDescriptor)] [Near : {... tors.times.timeline contains (getTimelineDescripto }] I am using Drools 5.2 with Helios (Eclipse). Any ideas why this is so? Although I have a working option it is impossible to maintain code when there are error indications. Thanks, Hezi ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Retrieving rule name
Davide Thanks - you hit the nail on the head. Ron ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Dynamic Fact(field) Generation in Declarative Model
Really Thank you Davidde for your reply.Yes,As you said,I can go to declarative model and i can add the fields..But,I need it as dynamically.For example,when user enters the field and Datatype it must be inserted into FactModel. By your reply,I came to know that it is not correct way to do it.How can i insert that field to Declarative Model..Is it possible???in Drools5.0..Please help me..Once again Thank you for your reply..Really Thanks -- View this message in context: http://drools.46999.n3.nabble.com/Dynamic-Fact-field-Generation-in-Declarative-Model-tp3545088p3545242.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] Dynamic Fact(field) Generation in Declarative Model
Hi, what you are trying to do is potentially very dangerous. When you declare a type, Drools (re)creates a class on the fly whenever the package is compiled to be added to a knowledge base. Adding a field and reloading the class implies that any previously instantiated object (or even rule pattern!) will no longer be compatible with the new instances. So, I wonder if you must do it online at all... can't you just go and modify the declared model? Moreover, the way you are trying to apply the modifications to the ClassDefinition is wrong. Indeed you have added a field definition to the definition, but the engine will not be aware of this change by simply inserting the definition in some session. You should either use very low level APIs to "patch" the knowledgebase or pass a Resource containing the updated definition to the knowledge agent. But again, I would not recommend it unless you absolutely must do it -- View this message in context: http://drools.46999.n3.nabble.com/Dynamic-Fact-field-Generation-in-Declarative-Model-tp3545088p3545208.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] Retrieving all Packages that are present in Drools Guvnor console
In Drools Guvnor Console,I'm having 4 packages..I need to display all 4 packages in the console through a POJO class..How can i access all packages..Please help me...How can i do it..I was strucked here..Please help me out...Please. Thanks in Advance. -- View this message in context: http://drools.46999.n3.nabble.com/Retrieving-all-Packages-that-are-present-in-Drools-Guvnor-console-tp3545186p3545186.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] duration attribute & other rule language features issue
I see you are using a pseudo-clock. Do you advance the clock using the appropriate API call? Updating and retracting a fact inserted through an entry point should be done with methods called on this object. -W On 29 November 2011 13:56, prashant.badhe wrote: > Hi, > > Tried your rule with the code below, but no luck. > > I am using only one rule, so the fact remains in drools session for > sufficient time (> 5 s). Even if I uncomment the /thread.sleep(6)/ line > below, the rule does not trigger. > > ~~ > public class DroolsTest { > > static StatefulKnowledgeSession ksession = null; > static KnowledgeRuntimeLogger logger = null; > > public static final void main(String[] args) { > try { > initSession(); > testTimerAttribute(); > } catch (Throwable t) { > t.printStackTrace(); > } > } > > private static void testTimerAttribute() { > > Alert alert = new Alert(); > alert.setId(12345L); > alert.setType("TYPE"); > alert.setComponentId("XXX"); > WorkingMemoryEntryPoint entryPoint = > ksession.getWorkingMemoryEntryPoint("EventStream"); > entryPoint.insert(alert); > > System.out.println("inserted...Count: " + > entryPoint.getFactCount()); > //Count returned = 1 > > try { > //Thread.sleep(6); > } catch (Exception ex) { > System.out.println("Exception..."); > } > > Alert alert1 = new Alert(); > alert1.setId(1L); > alert1.setType("LINK_UP"); > alert1.setComponentId("ZZZ"); > entry.insert(alert1); > System.out.println("inserted again...Count: " + > entry.getFactCount()); > //Count returned = 2 > > logger.close(); > > } > > private static void initSession() { > > new Thread(new Runnable() { > public void run() { > try { > System.out.println("Inside > initSession()..."); > KnowledgeBase kbase = > readKnowledgeBase(); > KnowledgeSessionConfiguration conf = > KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); > conf.setOption( ClockTypeOption.get( > "pseudo" ) ); > ksession = > kbase.newStatefulKnowledgeSession(conf, null); > logger = > KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, > "test"); > ksession.fireUntilHalt(); > } catch (Exception t) { > System.out.println("Inside thread > init() error..." + > t.getMessage() + "#" + t.getStackTrace()); > } > } > }).start(); > > } > > } > > > And the rule is: > > rule "check timer attribute" > agenda-group "enrichment" > auto-focus true > no-loop > salience 140 > //timer (int: 5s 1s) > > when > $alertObj : Object( eval($alertObj instanceof Alert)) from > entry-point > "EventStream" > $alert : Alert( componentId == "XXX" ) from entry-point > "EventStream" > then > try { > System.out.println("[enrichment] nullify empty component id > [alert=" + > ((Alert)$alertObj).getId() + "] [Time: " + > (Calendar.getInstance().getTimeInMillis())); > //$alert.setType("test type"); > //$alert.setComponentId("YYY"); > //update($alert); > } catch (Throwable e) { > System.out.println("[enrichment] ## ERROR: > nullify empty > component id [alertId="); // + $alert.getId() + "][error=" + > e.toString() + > "]"); > } > end > > > ~~ > > Please suggest us some solution on timer() issue . > > One more thing I observed today is (without timer() off course), when I put > following 3 lines in RHS of rule: > /$alert.setType("test type"); > $alert.setComponentId("YYY"); > update($alert);/ > > then sometimes I get following exception at /update($alert)/: > *java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be > cast to org.drools.common.EventFactHandle* > org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:201) > org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145) > org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:251) > org.drools.base.DefaultKnowledgeHelper.up
[rules-users] Dynamic Fact(field) Generation in Declarative Model
Hi All, Please help on this issue I created a declarative model Person in personDetails package in Drools Gunvor with 2 fields(age,amount).Now,I need to insert one field with name gender and datatype String into that declarative model through POJO class..Here is my code RuleAgent agent = RuleAgent.newRuleAgent("/Guvnor.properties"); RuleBase rb = agent.getRuleBase(); WorkingMemory workingMemory = rb.newStatefulSession(); PackageBuilder pkgBuilder=new PackageBuilder(rb); FactType personType = rb.getFactType( "persondetails.Person" ); ClassDefinition cDefinition=(ClassDefinition) rb.getFactType("persondetails.Person"); FieldDefinition gen = new FieldDefinition( "gender", "java.lang.String" ); product.setKey(true); cDefinition.addField(product); workingMemory.insert(cDefinition); FactHandle fc=workingMemory.getFactHandle(cDefinition); workingMemory.update(fc, cDefinition); rb.newStatelessSession().execute(new Object[] {cDefinition}); } String s1=cDefinition.getField(0).getTypeName(); String name1=cDefinition.getField(0).getName(); System.out.println(s1); System.out.println(name1); String s2=cDefinition.getField(1).getTypeName(); String name2=cDefinition.getField(1).getName(); System.out.println(s2); System.out.println(name2); String s3=cDefinition.getField(2).getTypeName(); String name3=cDefinition.getField(2).getName(); System.out.println(s3); System.out.println(name3); Output as Age---Java.lang.Integer Amount-java.lang.Integer Gender--Java.lang.String.. And when i am printing It is executing successfuly first time without errors.but i could not find gender in declarative model.It is failed to inserting.Can anyone help me in this..plZz...I was struggling with this When Iam executing second time it is displaying as Exception:couldnot find gender in declarative model..It means iam unable to commit Data into Server..(Drools guvnor Model) Please help on this -- View this message in context: http://drools.46999.n3.nabble.com/Dynamic-Fact-field-Generation-in-Declarative-Model-tp3545088p3545088.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] duration attribute & other rule language features issue
Hi, Tried your rule with the code below, but no luck. I am using only one rule, so the fact remains in drools session for sufficient time (> 5 s). Even if I uncomment the /thread.sleep(6)/ line below, the rule does not trigger. ~~ public class DroolsTest { static StatefulKnowledgeSession ksession = null; static KnowledgeRuntimeLogger logger = null; public static final void main(String[] args) { try { initSession(); testTimerAttribute(); } catch (Throwable t) { t.printStackTrace(); } } private static void testTimerAttribute() { Alert alert = new Alert(); alert.setId(12345L); alert.setType("TYPE"); alert.setComponentId("XXX"); WorkingMemoryEntryPoint entryPoint = ksession.getWorkingMemoryEntryPoint("EventStream"); entryPoint.insert(alert); System.out.println("inserted...Count: " + entryPoint.getFactCount()); //Count returned = 1 try { //Thread.sleep(6); } catch (Exception ex) { System.out.println("Exception..."); } Alert alert1 = new Alert(); alert1.setId(1L); alert1.setType("LINK_UP"); alert1.setComponentId("ZZZ"); entry.insert(alert1); System.out.println("inserted again...Count: " + entry.getFactCount()); //Count returned = 2 logger.close(); } private static void initSession() { new Thread(new Runnable() { public void run() { try { System.out.println("Inside initSession()..."); KnowledgeBase kbase = readKnowledgeBase(); KnowledgeSessionConfiguration conf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); conf.setOption( ClockTypeOption.get( "pseudo" ) ); ksession = kbase.newStatefulKnowledgeSession(conf, null); logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test"); ksession.fireUntilHalt(); } catch (Exception t) { System.out.println("Inside thread init() error..." + t.getMessage() + "#" + t.getStackTrace()); } } }).start(); } } And the rule is: rule "check timer attribute" agenda-group "enrichment" auto-focus true no-loop salience 140 //timer (int: 5s 1s) when $alertObj : Object( eval($alertObj instanceof Alert)) from entry-point "EventStream" $alert : Alert( componentId == "XXX" ) from entry-point "EventStream" then try { System.out.println("[enrichment] nullify empty component id [alert=" + ((Alert)$alertObj).getId() + "] [Time: " + (Calendar.getInstance().getTimeInMillis())); //$alert.setType("test type"); //$alert.setComponentId("YYY"); //update($alert); } catch (Throwable e) { System.out.println("[enrichment] ## ERROR: nullify empty component id [alertId="); // + $alert.getId() + "][error=" + e.toString() + "]"); } end ~~ Please suggest us some solution on timer() issue . One more thing I observed today is (without timer() off course), when I put following 3 lines in RHS of rule: /$alert.setType("test type"); $alert.setComponentId("YYY"); update($alert);/ then sometimes I get following exception at /update($alert)/: *java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be cast to org.drools.common.EventFactHandle* org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:201) org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145) org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:251) org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:183) org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:196) abc.xyz.alertProcessor.Rule_check_timer_attribute_0.defaultConsequence(Rule_check_timer_attribute_0.java:27) abc.xyz.alertProcessor.Rule_check_timer_attribute_0DefaultConsequenceInvoker.evaluate(R
Re: [rules-users] guvnor restful api problem
That's the old REST api, we're going to remove that. Use the new REST api, at http://localhost:8081/guvnor-5.3.0.Final-tomcat-6.0/org.drools.guvnor.Guvnor/rest/packages/... Op 29-11-11 11:53, gcautiero schreef: > Hello to everyone, > > i'm trying to upload a .drl file using guvnor's restFul service. But im not > able to get a POST call working. > > what i'm trying to do is: > > make a call first to get a content of .drl file already stored in Guvnon: > > here the working code using cxf client (as the example in the guvnor doc): > > WebClient c = WebClient.create("http://127.0.0.1:8081/";); > String authorizationHeader = "Basic " + > org.apache.cxf.common.util.Base64Utility.encode("guest:".getBytes()); > c.header("Authorization", authorizationHeader); > String content = > c.path("http://localhost:8081/guvnor-5.3.0.Final-tomcat-6.0/org.drools.guvnor.Guvnor/api/packages/com.truvo.price/PRICERULE";).accept("text/plain").get(String.class); > > then i try to upload the content in another asset > Here the code that DOSEN'T work: > > Response response = > client.path("http://localhost:8081/guvnor-5.3.0.Final-tomcat-6.0/org.drools.guvnor.Guvnor/api/packages/com.truvo.price/price/";).accept("application/xml").post(content); > > for this call i get the following error: > > > Nov 29, 2011 11:23:12 AM org.apache.catalina.core.StandardWrapperValve > invoke > SEVERE: Servlet.service() for servlet RestAPIServlet threw exception > java.lang.ArrayIndexOutOfBoundsException: 1 > at org.drools.repository.remoteapi.RestAPI.post(RestAPI.java:235) > at > org.drools.guvnor.server.files.RestAPIServlet$1.execute(RestAPIServlet.java:56) > at > org.drools.guvnor.server.files.RepositoryServlet.doAuthorizedAction(RepositoryServlet.java:75) > at > org.drools.guvnor.server.files.RestAPIServlet.doPost(RestAPIServlet.java:49) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42) > at > org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:65) > at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291) > at > org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877) > at > org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594) > at > org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675) > at java.lang.Thread.run(Thread.java:662) > > > someone have a suggestion? or a working example? > > tnx > > Gianfranco > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/guvnor-restful-api-problem-tp3544799p3544799.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 > -- With kind regards, Geoffrey De Smet ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] guvnor restful api problem
Hello to everyone, i'm trying to upload a .drl file using guvnor's restFul service. But im not able to get a POST call working. what i'm trying to do is: make a call first to get a content of .drl file already stored in Guvnon: here the working code using cxf client (as the example in the guvnor doc): WebClient c = WebClient.create("http://127.0.0.1:8081/";); String authorizationHeader = "Basic " + org.apache.cxf.common.util.Base64Utility.encode("guest:".getBytes()); c.header("Authorization", authorizationHeader); String content = c.path("http://localhost:8081/guvnor-5.3.0.Final-tomcat-6.0/org.drools.guvnor.Guvnor/api/packages/com.truvo.price/PRICERULE";).accept("text/plain").get(String.class); then i try to upload the content in another asset Here the code that DOSEN'T work: Response response = client.path("http://localhost:8081/guvnor-5.3.0.Final-tomcat-6.0/org.drools.guvnor.Guvnor/api/packages/com.truvo.price/price/";).accept("application/xml").post(content); for this call i get the following error: Nov 29, 2011 11:23:12 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet RestAPIServlet threw exception java.lang.ArrayIndexOutOfBoundsException: 1 at org.drools.repository.remoteapi.RestAPI.post(RestAPI.java:235) at org.drools.guvnor.server.files.RestAPIServlet$1.execute(RestAPIServlet.java:56) at org.drools.guvnor.server.files.RepositoryServlet.doAuthorizedAction(RepositoryServlet.java:75) at org.drools.guvnor.server.files.RestAPIServlet.doPost(RestAPIServlet.java:49) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42) at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:65) at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675) at java.lang.Thread.run(Thread.java:662) someone have a suggestion? or a working example? tnx Gianfranco -- View this message in context: http://drools.46999.n3.nabble.com/guvnor-restful-api-problem-tp3544799p3544799.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