RE: [rules-users] Design Question (hashCode/equals/fact maintenance)
I just realized I could use the from CE to avoid this entire mess. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fenderbosch, Eric Sent: Tuesday, July 15, 2008 10:38 AM To: rules-users@lists.jboss.org Subject: [rules-users] Design Question (hashCode/equals/fact maintenance) I'm just looking for a bit of verification that this is a reasonable solution. This just feels like a hack and there's probably a better way that I'm just not seeing. Alternate ideas are welcome and appreciated. Thanks in advance. The objective is to find the best workers for a job: Jobs have a location. Workers have a location. Scores are calculated based on miles and minutes of a route from the worker to a job. When a job or worker location changes, then the route should be recalculated so that scores can be recalculated. It is possible for a location to get re-inserted that might be the functionally the same as a previous location for a job/worker, but a different instance. In this case, the route should not be recalculated and the old scores should remain. assert behavior = equality logical override = discard maintain tms = true remove identies = true shadow proxies are enabled public class JobLatitudeLongitude { private String jobId; private double latitude; private double longitude; private long timestamp = System.currentTimeMillis(); // getters setters omitted for brevity public int hashCode() { return jobId.hashCode(); } public boolean equals(Object obj) { // not null or type safe, just simple version for brevity JobLatitudeLongitude other = (JobLatitudeLongitude) obj; return this.jobId.equals(other.jobId) this.timestamp == other.timestamp; // would return false; work ??? } } rule retract redundant job latitude/longitude facts // if more than one lat/long with same position for a job, keep the oldest salience 600 when older : JobLatitudeLongitude() newer : JobLatitudeLongitude(jobId == older.jobId, latitude == older.latitude, longitude == older.longitude, timestamp = older.timestamp) then retract(newer); end rule retract old job latitude/longitude facts // if more than one lat/long with different position for a job, keep the newest salience 600 when older : JobLatitudeLongitude() newer : JobLatitudeLongitude(jobId == older.jobId, latitude != older.latitude, longitude != older.longitude, timestamp = older.timestamp) then retract(older); end rule add Route fact salience 450 when jobLatitudeLongitude : JobLatitudeLongitude() workerLatitudeLongitude : WorkerLatitudeLongitude() then // calculateRoute is an imported function Route route = calculateRoute(workerLatitudeLongitude, jobLatitudeLongitude); insertLogical(route); end ___ 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] Re: variable 'or' constraints with a DSL
No, dash syntax is not the answer. Clever construction of the DSL mapping will get you what you need. Allow me to take your example and modify it. [condition][File]file_name = fileName [condition][File]dir_name = dirName [condition][File]group_name = gName [condition][File]user_name = uName [condition][]file where {constraints}=$f: File(where {constraints}) [condition][]where {attr} matches {value}={attr} matches {value} [condition][]and {attr} matches {value}=,{attr} matches {value} [condition][]or {attr} matches {value}= || {attr} matches {value} Matt, I'm catching on now -- Drools can make multiple substitutions on a line. I'll see what I can do with this. Thanks for your examples and help! reid ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Mvel compilation error
Hi All, We are intermittently getting mvel compilation errors with the following: Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.mvel.optimizers.impl.refl.MethodAccessor.getValue(MethodAccessor.java:61 ) ... 148 more The rules compile ok and the application will run normally (rules processing successfully) for a few days then this error will occur. Tried to replicate but once the application is restarted the last action before the failure is repeated and always processes successfully. Any help would be appreciated. Regards JS ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Using from
I have the following class structure. Class GrandFather { ListFather fathers; public ListFather getFathers() {return fathers;} } Class Father { int age; ListSon sons; public int getAge() {return age;} public ListSon getSons() {return sons;} } Class Son { int age; public int getAge() {return age;} } I'd like to write a rule that finds all the Fathers who have age 45 and have Sons where the son's age is greater than 5. But I can't figure out how to use from to iterate over father first and then over son. Any help will be greatly appreciated. Thanks, --Aziz ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] RuleFlow Spanning Multiple Packages
Hi All, Is it possible to define a rule flow that spans multiple packages (rulesets). Currently we have the 3 packages (and we are planning on dividing them into more sub-packages): Package1: 10,000 rules Package2: 5000 rules Package3: 1000 rules And we would like to create one rule flow for all 3 packages. I have looked through the documentation and it seems that you can only create one rule flow per package. Am I right or have I missed something somewhere? We are using Drools 4.0.7 Thanks, Len ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Using from
Hi Aziz, On Thu, Jul 17, 2008 at 8:26 PM, Aziz Boxwala [EMAIL PROTECTED] wrote: I have the following class structure. Class GrandFather { ListFather fathers; public ListFather getFathers() {return fathers;} } Class Father { int age; ListSon sons; public int getAge() {return age;} public ListSon getSons() {return sons;} } Class Son { int age; public int getAge() {return age;} } I'd like to write a rule that finds all the Fathers who have age 45 and have Sons where the son's age is greater than 5. But I can't figure out how to use from to iterate over father first and then over son. Any help will be greatly appreciated. Thanks, --Aziz Something like this? rule FatherAndSon when $father : Father(age 45) $son : Son(age 5) from $father.sons then // do something end Best regards Marcus ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users