Apply role to whole class hierarchy
by Joerg Henne
Hi all,
we are processing events through a Fusion rule base. To be recognized as
such, model classes must be declared as @role(event). We are using a rather
extensive hierarchy of events, all derived from a single abstract class.
Unfortunately, it doesn't seem to be possible to declare just this base
class as an event and have the 'event' role for the others derived from
that.
Is there a way around having to declare each and every single event class
separately?
Thanks
Joerg
--
View this message in context: http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Re: [rules-users] [Planner] Train routing problem
by ge0ffrey
Take a look at the VRP example too: it's basically the TSP example, but with
multiple vehicles.
1) It depends, but I would add a hard constraint for this. Once 5.5.0.Final
is out, you might use move Filtering instead, so it doesn't even evaluate
those solutions (but that also blocks it from tunneling through an
infeasible solution to a new, better feasible solution, so that filtering
might be a bad thing).
2) The bigger problem is that in this design you'll be assigning an order of
StopTimes, but your goal is not to assign the StopTimes, but to assign a
trainride (from start A to destination B) to a route (through StopTimes).
The number of StopTimes depends on the route taken. This greatly influences
the design. There isn't a good example out of the box in Planner for this,
but Lukas has such a case working well for RAS2012 with Planner, which I am
hoping he'll open up after 15th August.
Note: the answer on 2) makes the answer on 1) obsolete.
--
View this message in context: http://drools.46999.n3.nabble.com/Planner-Train-routing-problem-tp4018955...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Comparison operation requires compatible types when using Date literal inside nested OR
by Eric Martineau
I'm new to drools, so hopefully I can post enough information to get some help. We are running Drools 5.3.3.Final (though we've seen the same issue with 5.4.0.Final and 5.3.0.Final)
I'm trying to test some rules created in drl format. Here's an example of a drl that executes fine – it checks a birthday field against a date literal:
------------------------------------------
package drools.rules.funnelid.two
import com.infusionsoft.bpm.services.TestRuleFact;
rule "Test Rule"
dialect "java"
when
$testRuleFact : TestRuleFact( ( contactable.contact.birthday < "29-Dec-1977" ) )
then
$testRuleFact.setTrue( );
end
-------------------------------------------
However, this drl fails compilation with the following error:
package drools.rules.funnelid.two
import com.infusionsoft.bpm.services.TestRuleFact;
rule "Test Rule"
dialect "java"
when
$testRuleFact : TestRuleFact( ( contactable.contact.title str[equals] "Owner" && contactable.contact.birthday < "01-Jan-1980" ) || ( contactable.contact.country str[equals] "USA" && contactable.contact.leadSourceIdOverride == "12" ) )
then
$testRuleFact.setTrue( );
End
------------------------------------------
Here's the error I get:
DRL contains errors, no actions will be processed: Unable to Analyse Expression str0.evaluate( contactable.contact.title, "Owner" ) && contactable.contact.birthday < "01-Jan-1980" || str1.evaluate( contactable.contact.country, "USA" ) && contactable.contact.leadSourceIdOverride == "12":
[Error: Comparison operation requires compatible types. Found class java.util.Date and class java.lang.String]
[Near : {... ) && contactable.contact.leadSourceIdOverride == "12" ....}]
^
[Line: 8, Column: 32] : [Rule name='Test Rule']
Some things that cause the error to go away:
* Removing the offending clause: contactable.contact.birthday < "01-Jan-1980"
* Changing the || to an &&
I'm at a loss and would love some help. Even if I knew which class was raising the exception would help, but I can't seem to find it anywhere.
Thanks,
Eric
12 years, 4 months
Question with Persisting Knowledge Sessions Then Upgrading Drools
by Darin Wilcox
I have been working on persisting knowledge sessions to an H2 database that
are used for long running processes. The question I have is surrounding
the following description:
- - A stateful knowledge session is created using the
JPAKnowledgeService and persisted to a database.
- - A process is started within the knowledge session.
- - The process contains a human task blocking the completion of the
process.
Because the stateful nature of the knowledge session, an instance of the
process is inserted into the processinstanceinfo table and an instance of
the human task is inserted into the task table. State is therefore
maintained until the human task is completed and the process can continue
execution.
While the knowledge session, process and human task are awaiting
completion, is it possible to upgrade the version of Drools/jBPM being
used? Will the upgrade effect the de-serialization of the objects from the
database or will they be able to be retrieved and used as before? Is there
a best practice for accomplishing upgrading drools versions with knowledge
sessions that may have been previously existing?
Thanks,
- Darin
12 years, 4 months
Drools with Gemfire
by rtella
I'm looking into integrating Drools with a system that has large (40GB+)
Gemfire Maps. The rules would need to access the Gemfire Maps, which can be
updated at any time. I understand I can't access the Gemfire Maps as
global data since they aren't immutable. Inserting the maps also doesn't
seem like a good idea either since I'd have to call modify() frequently on
Maps with as many as 1M elements. Is there any alternative for accessing
large amounts of changing data?
thanks for your help,
Rich
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-with-Gemfire-tp4019026.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Rule Fires with Null Bindings
by mark.nowicki
Hi, I'm getting duplicate rule invocations when a rule is added to the
KnowledgeBase after the facts have been inserted in the
StatefulKnowledgeSession. Very simple example, seems what I'm doing is
consistent with 5.3.0.Final Drools expert documentation. Thanks for the
assistance,
--Mark
*Running code below outputs the following (firing twice for Person A,
Relationship A-C):*
RelationshipRule Fired!
person: Person( id=A, type=parent )
relationship: Relationship( parentId=A, childId=C )
RelationshipRule Fired!
person: Person( id=A, type=parent )
relationship: Relationship( parentId=A, childId=B )
RelationshipRule Fired!
person: Person( id=A, type=parent )
relationship: Relationship( parentId=A, childId=C )
*resources/factTypes.drl:*
package testing.facttypes;
declare Person
id : String
type : String
end
declare Relationship
parentId : String
childId : String
end
*resources/rules.drl:*
package testing.rules;
import java.util.ArrayList;
import testing.facttypes.Person;
import testing.facttypes.Relationship;
rule "RelationshipRule"
no-loop true
when
person : Person(type == "parent")
relationship : Relationship(parentId == person.id)
then
System.out.println("RelationshipRule Fired!");
System.out.println("person: " + person);
System.out.println("relationship: " + relationship + "\n");
end
*public static void main snippet:*
KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase();
StatefulKnowledgeSession statefulKnowledgeSession =
knowledgeBase.newStatefulKnowledgeSession();
KnowledgeBuilder knowledgeBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(knowledgeBase);
Resource factTypes =
ResourceFactory.newClassPathResource("resources/factTypes.drl");
knowledgeBuilder.add(factTypes, ResourceType.DRL);
knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
FactType factType =
knowledgeBase.getFactType("testing.facttypes", "Person");
Object personA = factType.newInstance();
factType.set(personA, "id", "A");
factType.set(personA, "type", "parent");
statefulKnowledgeSession.insert(personA);
factType = knowledgeBase.getFactType("testing.facttypes",
"Person");
Object personB = factType.newInstance();
factType.set(personB, "id", "B");
factType.set(personB, "type", "child");
statefulKnowledgeSession.insert(personB);
factType = knowledgeBase.getFactType("testing.facttypes",
"Relationship");
Object relationshipAB = factType.newInstance();
factType.set(relationshipAB, "parentId", "A");
factType.set(relationshipAB, "childId", "B");
statefulKnowledgeSession.insert(relationshipAB);
factType = knowledgeBase.getFactType("testing.facttypes",
"Person");
Object personC = factType.newInstance();
factType.set(personC, "id", "C");
factType.set(personC, "type", "child");
statefulKnowledgeSession.insert(personC);
factType = knowledgeBase.getFactType("testing.facttypes",
"Relationship");
Object relationshipAC = factType.newInstance();
factType.set(relationshipAC, "parentId", "A");
factType.set(relationshipAC, "childId", "C");
statefulKnowledgeSession.insert(relationshipAC);
knowledgeBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(knowledgeBase);
Resource rules =
ResourceFactory.newClassPathResource("resources/rules.drl");
knowledgeBuilder.add(rules, ResourceType.DRL);
knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
statefulKnowledgeSession.fireAllRules();
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-Fires-with-Null-Bindings-tp4019021...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Avoid caching method results within non fact objects
by rogelio_sevilla1
Good day everyone, I'm having a problem here and I'm not sure if I'm using
the right approach.
Currently I have a couple of rules where I inject A LOT of objects as facts.
These objects change their states quite commonly and I have to make
decisions when the previous state has a particular value comparing it to the
current state. Something like this (just an example, sorry if there are
typos)
rule "Interesting Event"
when
$currentFact: CurrentFact(state=="somethingNew")
$previousFact: PreviousFact($currentFact.id == id && state=="somethingOld")
then
//do something
//update previousFact to reflect the state of the newFact
end
The problem that I had with this is that I had SOOO much facts within the
rules session (thousands of objects with a lot of data that I need within
the session too) that the fireAllRules method started to take too much time
to complete.
So, what I did is to store the previous facts of the objects within a
Wrapper class that contains a hashmap with all of these states.
Something like:
PreviousStateHolder{
private static HashMap<String,PreviousFact> previousFacts;
public void insertPreviousState(){
...
}
public boolean containsPreviousState(CurrentState currentState){
...
}
public boolean deletePreviousState(){
...
}
.. other management methods
}
And my new rules look like
rule "Interesting Event"
when
$currentFact: CurrentFact(state=="somethingNew")
$previousFact: PreviousFact(state=="somethingOld")
from
PreviousStateHolder.retrievePreviousState($currentFact)
then
//do something
//update previousFact to reflect the state of the newFact
end
The problem is that drools caches the result returned by the
retrievePreviousState() method, so, it does not matter if the
PreviousStateHolder member changes; drools always caches the result. I have
tried to put my invocations within eval() but I still get the same problem
(cached results).
I know they are being cached because I put a breakpoint within the methods,
and the first time the fireAllRules gets executed, they get hit. But then,
the consequence of these rules keep getting executed even if the
retrievePreviousState() does not reflect the value needed to do so.
Am I doing something wrong?? Is there another approach that does not involve
inserting all of these states as facts within my session??
Thanks a lot in advance
--
View this message in context: http://drools.46999.n3.nabble.com/Avoid-caching-method-results-within-non...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
cross products in excel decision tables
by Tom Eugelink
I need to model something similar to "when the lastname on a passport does not match the lastname on the application" in a decision table. Written in DRL:
rule "PassportValidation_24"
when
$a : Application()
$p : Passport(application == $a, lastName != $a.lastName)
then
$p.setError("Passport's last name (" + $p.getLastName() + ") does not match with application's last name (" + $a.getLastName() + ")");
end
How do I do such a cross referencing in an Excel decision table?
Tom
12 years, 4 months