Guvnor - Loading enums programatically using rule metadata
by GPatel@tsys.com
The Guvnor manual specifies how to load enum data programtically but it
seems like only other fields on the same Fact can be used to filter the
values that can show up in the drop-down fields, as shown below:
'Fact.field[dependentField1, dependentField2]' : '(new
com.yourco.DataHelper()).getListOfAges("@{dependentField1}",
"@{dependentField2}")'
Is it possible to somehow use other rule attributes, like package name or
rule metadata to filter the list? Something like the following:
'Fact.field[dependentField1]' : '(new
com.yourco.DataHelper()).getListOfAges("@{dependentField1}",
drools.getRule().getMetaData().get("ID"))'
Thanks
G. Patel
-----------------------------------------
The information contained in this communication (including any
attachments hereto) is confidential and is intended solely for the
personal and confidential use of the individual or entity to whom
it is addressed. If the reader of this message is not the intended
recipient or an agent responsible for delivering it to the intended
recipient, you are hereby notified that you have received this
communication in error and that any review, dissemination, copying,
or unauthorized use of this information, or the taking of any
action in reliance on the contents of this information is strictly
prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original
message. Thank you
12 years, 6 months
Guvnor in Reselliency environment : Assets stored in DB not visible in Secondary server
by Zahid Ahmed
I am working in Drools-Guvnor-5.5.0.Final version and have configured repository.xml to save all assets + indexes in Oracle 11 database.
I am deploying Guvnor in a resilient environment which has two servers. Guvnor deployed in both the servers is pointing to the same database.
Step 1
For this I generated the repository.xml from the administration panel of Guvnor and replaced in both primary and secondary Guvnor instance. And when I started the server and imported assets into primary guvnor, I was able to see the following tables in database,
1. FS_FSENTRY;
2. FS_WS_DEFAULT_FSENTRY;
3. PM_WS_DEFAULT_FSENTRY;
4. PM_WS_DEFAULT_BINVAL;
5. PM_WS_DEFAULT_BUNDLE;
6. PM_WS_DEFAULT_REFS;
7. PM_WS_DEFAULT_NAMES;
8. REPOSITORY_FS_FSENTRY;
9. VERSIONING_FS_FSENTRY;
10. VERSIONING_PM_BINVAL;
11. VERSIONING_PM_BUNDLE;
12. VERSIONING_PM_NAMES;
13. VERSIONING_PM_REFS;
I also configured workspace.xml files in
1. jboss-eap-6.0/bin/repository/workspaces/default
2. jboss-eap-6.0/bin/repository/workspaces/security
Step 2
Now started secondary guvnor, configured similar to primary Guvnor. But secondary server did not displayed the packages and assets from DB. Instead asked me to install sample packages.
Step 3
I configured DataStore in repository.xml. Restarted primary Guvnor server and found one more table is created in database with the assets init.
Table name : DS_DATASTORE
Step 4
Configured secondary Guvnor with DataStore and restarted it. Now I could see the packages of primary Guvnor, But the assets in packages were not available.
I am attaching the repository.xml file from both the servers.
Thanks and Best Regards,
Zahid Ahmed
Senior Software Engineer | Emirates Group IT
P.O. Box 686 | Dubai, United Arab Emirates
T +971 4 245 2551| M +971 55 124 9171
12 years, 7 months
PMML - Exception excuting consequence for rule xxx in yyy: java.lang.NullPointerException : using KnowledgeAgent
by smilk
Hi. I'm trying to test pmml "decision trees"
(https://github.com/droolsjbpm/drools-chance/tree/master/drools-pmml)
on Drools 5.5.0.Final.
The two test environment's outcome are not same.
1) I got a test on Eclipse. The results are fine. Test source is as below.
public class PMMLTestFromLocal {
public static final void main(String[] args) {
try {
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "LocalPmmlTest");
FactType CHK_YN_Type = kbase.getFactType(
"Meritz_ModelRule_01","CHK_YN" );
CHK_YN_Type.newInstance();
ksession.getWorkingMemoryEntryPoint( "in_AC_CSE_TYP_RE"
).insert( "group0" );
ksession.getWorkingMemoryEntryPoint( "in_AC_TYP_RE" ).insert(
"Caution" );
ksession.getWorkingMemoryEntryPoint( "in_COV_CD_RE" ).insert(
"group2" );
ksession.getWorkingMemoryEntryPoint( "in_AC_STAT_CD_RE"
).insert( "group1" );
ksession.getWorkingMemoryEntryPoint( "in_HDCAP_RATE_RE"
).insert( "0" );
ksession.getWorkingMemoryEntryPoint( "in_FDS_AC_YN" ).insert(
"0" );
ksession.getWorkingMemoryEntryPoint( "in_AGE_GRD" ).insert(
"10대" );
ksession.getWorkingMemoryEntryPoint( "in_AC_COT_DAY" ).insert(
0.0 );
ksession.fireAllRules();
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("pmml2.drl"),
ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse
knowledge.");
}
KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase("Meritz");
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
}
2) The Second environment which is excuting Exception is Tomcat.
I got a test using same drools engine on Tomcat. But NullpointerException
occured.
Test source is as below.
public class PMMLTestFromServer {
public static void main(String[] args) {
StatefulKnowledgeSession kSession = getSKSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(kSession, "ServerPmmlTest");
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
kSession.getWorkingMemoryEntryPoint( "in_AC_CSE_TYP_RE" ).insert( "group0"
);
kSession.getWorkingMemoryEntryPoint( "in_AC_TYP_RE" ).insert( "Caution" );
kSession.getWorkingMemoryEntryPoint( "in_COV_CD_RE" ).insert( "group2" );
kSession.getWorkingMemoryEntryPoint( "in_AC_STAT_CD_RE" ).insert( "group1"
);
kSession.getWorkingMemoryEntryPoint( "in_HDCAP_RATE_RE" ).insert( "0" );
kSession.getWorkingMemoryEntryPoint( "in_FDS_AC_YN" ).insert( "0" );
kSession.getWorkingMemoryEntryPoint( "in_AGE_GRD" ).insert( "10대" );
kSession.getWorkingMemoryEntryPoint( "in_AC_COT_DAY" ).insert( 0.0 );
kSession.fireAllRules();
logger.close();
}
public static StatefulKnowledgeSession getSKSession() {
KnowledgeAgent agent = KnowledgeAgentFactory.newKnowledgeAgent("Meritz");
agent.applyChangeSet(ResourceFactory.newClassPathResource("change-set_model.xml"));
KnowledgeBase ruleBase = agent.getKnowledgeBase();
System.out.println(ruleBase.getKnowledgePackages());
return ruleBase.newStatefulKnowledgeSession();
}
}
The differences in two test source is using KnowledgeAgent.
Exception stack trace follows -
Exception executing consequence for rule
"outputFeature_CHK_YN_to_Probability_N_probability" in Meritz_ModelRule_01:
java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at com.meritzfis.test.PMMLTestFromServer.main(PMMLTestFromServer.java:43)
Caused by: java.lang.NullPointerException
at
org.drools.base.evaluators.BeforeEvaluatorDefinition$BeforeEvaluator.evaluateCachedRight(BeforeEvaluatorDefinition.java:318)
at
org.drools.rule.constraint.EvaluatorConstraint.isAllowedCachedRight(EvaluatorConstraint.java:80)
at
org.drools.common.DoubleBetaConstraints.isAllowedCachedRight(DoubleBetaConstraints.java:97)
at org.drools.reteoo.JoinNode.propagateFromRight(JoinNode.java:156)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:148)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.SimpleBeliefSystem.insert(SimpleBeliefSystem.java:38)
at
org.drools.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:204)
at
org.drools.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:176)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:231)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:245)
at
org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:210)
at
org.drools.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:205)
at
Meritz_ModelRule_01.Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fc.defaultConsequence(Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fc.java:14)
at
Meritz_ModelRule_01.Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fcDefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
Meritz_ModelRule_01.Rule_outputFeature_CHK_YN_to_Probability_N_probability_a4a43fe942664fe0b31e45a29a6d99fcDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
... 6 more
I'm attaching a drl file.
--
View this message in context: http://drools.46999.n3.nabble.com/PMML-Exception-excuting-consequence-for...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
java.lang.ClassCastException: org.drools.reteoo.BetaMemory cannot be cast to org.drools.reteoo.AlphaNode$AlphaMemory
by dcrissman
Does this mean anything to anyone?
I found this, but I am using 5.5.0.Final:
http://drools.46999.n3.nabble.com/org-drools-reteoo-AlphaNode-AlphaMemory...
java.lang.ClassCastException: org.drools.reteoo.BetaMemory cannot be cast to
org.drools.reteoo.AlphaNode$AlphaMemory
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:136)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
...
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-ClassCastException-org-drools...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Timer and AgendaFilter
by Kai Ruddies
Hi,
I have a rule with a timer and call fireAllRules(AgendaFilter agendaFilter) with an AgendaFilter. I can see the Activation is fired after the delay but accept(Activation activation) in my AgendaFilter isn't invoked. My AgendaFilter is working well for other rules without timers.
Is this a bug or wanted that ScheduledActivations aren't passed to the AgendaFilter?
I'm using drools expert 5.5.0.Final.
Thanks,
Kai
12 years, 7 months
RightTupleIndexHashTable
by Ming Fang
What is the purpose of RightTupleIndexHashTable?
We are getting the exception below but unable to come up with a self contained unit test to demonstrate the problem.
Caused by: java.lang.NullPointerException: null
at org.drools.core.util.index.RightTupleIndexHashTable.removeAdd(RightTupleIndexHashTable.java:344) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.JoinNode.modifyRightTuple(JoinNode.java:224) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.PropagationQueuingNode$ModifyToSinkAction.execute(PropagationQueuingNode.java:513) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.PropagationQueuingNode.propagateActions(PropagationQueuingNode.java:280) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.PropagationQueuingNode$PropagateAction.execute(PropagationQueuingNode.java:588) ~[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:993) [drools-core-5.5.0.Final.jar:5.5.0.Final]
12 years, 7 months
OptaPlanner: score corruption when using insertLogical with custom objects
by pvandenbrink
Hi,
I've been using Drools Planner with success for a while for our Conversation
planning tool. It's used by schools to plan conversations between teachers
and parents of schoolgoing children.
Recently I checked on the new developments on Drools (the current version
we're using in production is 5.4.0.FINAL) and started to upgrade to
OptaPlanner 6.0.0.Beta5.
Everything looked fine, and seeing how it's now easier to check which
constraints are broken in a given solution, I decided to have a look at that
as well.
And that's where I noticed that we actually had an issue with score
corruption in one of our rules...
The goal of the rule in case is to minimize the amount of timeslots between
the first and last Conversation of a family (they can have conversations for
multiple children.)
The rule uses custom helper objects, like in the NurseRostering example,
which are added with insertLogical.
Conversation is the planning entity, which has the planning variable:
timeslot. FamilyStart and FamilyEnd are custom helper objects to register
the timeslot of the first and last conversation for a family.
The relevant rules are as follows:
rule "familyStart"
salience 1
when
Conversation(
family != null, $family: family,
timeslot != null, $timeslot: timeslot);
not Conversation(
family == $family,
timeslot < $timeslot);
then
insertLogical(new FamilyStart($family, $timeslot));
end
rule "familyEnd"
salience 1
when
Conversation(
family != null, $family: family,
timeslot != null, $timeslot: timeslot);
not Conversation(
family == $family,
timeslot > $timeslot);
then
insertLogical(new FamilyEnd($family, $timeslot));
end
rule "familyCompact"
when
$start: FamilyStart(
family != null, $family: family,
timeslot != null, $timeslotBegin: timeslot);
$end: FamilyEnd(
family == $family,
(timeslot.id - $timeslotBegin.id > family.minimumTimeslotsRequired),
timeslot != null, $timeslotEnd: timeslot);
then
scoreHolder.addSoftConstraintMatch(kcontext, -(($timeslotEnd.getId() -
$timeslotBegin.getId()) - $family.getMinimumTimeslotsRequired()));
end
When running one of my example schedules in FULL_ASSERT mode, the following
error appears during the LocalSearch phase:
Exception in thread "main" java.lang.IllegalStateException: Score
corruption: the workingScore (-2hard/-119soft) is not the uncorruptedScore
(-2hard/-118soft) after completedAction (Teacher 3 family 11 timeslot 2 =>
12):
The corrupted scoreDirector has 1 ConstraintMatch(s) which are in excess
(and should not be there):
defaultpkg/familyCompact/level1/[FamilyEnd Family 11, Timeslot 12,
FamilyStart Family 11, Timeslot 7]=-1
The corrupted scoreDirector has no ConstraintMatch(s) which are missing.
Check your score constraints.
I use a custom ChangeMove and SwapMove implementation. I've also tried using
the new generic Moves, these have the same problem.
It seems like when a move happens that should update an inserted FamilyStart
or FamilyEnd because of a change in timeslot, this change isn't properly
reflected in the scoreDirector.
Do you have any idea what could cause this corruption? The moves do call
beforeVariableChanged and afterVariableChanged on the scoreDirector, and the
FamilyStart and FamilyEnd classes implement an equals and hashcode based on
the Family and Timeslot fields.
(Actually, I've also tried using the default equals and hashcode of Object
for these 2 classes, which causes corruption much faster and with more
ConstraintOccurrences.)
Thanks for any insights,
Pieter
--
View this message in context: http://drools.46999.n3.nabble.com/OptaPlanner-score-corruption-when-using...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Guvnor seems to copy assets across External RDBMS and file system
by Yuri
I set up SQL Server as the external repository, and left everything else in
guvnor and jboss AS7 configured pretty much according to defaults.
When I create assets in guvnor, I see that changes are being made in the
MSSQL db. Despite changes to the db, however, I'm still seeing changes to
the Repository and Workspace folders. It gets more interesting when I
truncate the tables in the external guvnor db, and restart guvnor, it seems
to get all of its assets back from those two folders.
Am I doing something wrong? Is it reconstructing the assets from lucene
indexes? If MSSQL is already indexing things, is the lucene index still
necessary? Are these basic JCR concepts that I am not grasping?
Thanks, Yuri
12 years, 7 months