Hibernate session and 'from'
by Gareth Evans
Hello,
I am using Hibernate lazy loading in the facts I am inserting and am
noticing some odd behaviour when I use 'from'.
Here is a simplified example of my problem. In the first rule I just
want to populate the working memory with the Child objects, it uses
Hibernate lazy loading fine and inserts the facts, however in the
second rule I get an exception when accessing the GrandGrandChild
saying that the object does not have a session. If I add some debug
code to the first rule to access the GrandGrandChild I get the same
error.
This is using session-per-request and the Parent object was inserted
in the current session.
rule "get children - broken"
when
$parent : Parent( )
$child : Child( ) from $parent.children
then
insert($child);
end
rule "do stuff"
when
$child : Child( )
then
GrandChild grandChild = $child.getGrandChild();
# it blows up on the next line
GrandGrandChild grandGrandChild =
grandChild.getGrandGrandChild();
end
If I replace the first rule with the following everything works as
expected and I can match on Child objects and access whatever I wish,
so I know there should be a session available in the "do stuff" rule.
rule "get children - working"
when
$parent : Parent( )
then
for(Child child : $parent.getChildren()) {
insert(child);
}
end
I am able to use the "working" version in my code however the "broken"
version seems like the more correct way to do this in Drools. I'd like
to understand what is going on in case it is my fault or an issue I
need to be aware of. Could it be something to do with the from keyword
or the "cast" to Child( )? Is there some "magic" done in Drools which
could remove/invalidate the Hibernate proxy?
Thanks,
Gareth
15 years, 2 months
Re: [rules-users] Combination of conditions doesn't work
by FrankVhh
Hi Sariman,
The trick with "from entry-point", is quite unfamiliar to me. There might be
some problem with that, but I cannot tell by looking at it.
However, there are a few problems with the rules that you have printed out
for us.
1) The way I understand it, they do not do what they should be doing. You
said you do NOT want an action when all sensors evaluate to true. In your
case, you are evaluateing whether all sensors are false. This is pretty
useless if you already have a rule which evaluates the existence of at least
1 "true" sensor. The way I would put this is like this:
rule "Myrule"
when
#conditions
sensorEvent1: SensorEvent(booleanValue == true)
exists( SensorEvent(booleanValue == false) )
then
#actions
end
2) There are some errors in your rule. No idea whether this is a copy/paste
or a read/type, so I will just point them out.
- ";" is usually not needed in a LHS, I am not familiar with the from
entry-point syntax, but I assume it wouldn't be needed
- There is a ")" in excess in one of your conditions
3) I don't think it makes sense to put your rules as you did in the second
example. Even if you are trying to examine whether those three sensors are
false.
On a personal note: what does from entry-point do? I must have overlooked it
in the documentation.
Regards,
Frank
sariman wrote:
>
> To keep it short, I have three sensors providing me some values every x
> seconds. I am running an algorithm over those values and getting at the
> end a single value for each sensor. Next I check if this value is
> greater/less than a threshold value and creating an object and setting its
> booelan value to true/false. The last part looks like this:
>
> SensorEvent sensorEvent = new SensorEvent ();
> sensorEvent.setBoolean(booleanValue);
> sensorEvent.setSensorID(sensorID);
>
> I want to do some actions if one of the sensors has "true" and this works.
> But I want no action if all sensors have "true". And this part doens't
> work. If I only check one of the sensors if it is "false" it is ok but the
> combination doesn't work. It means this case seems naver to happen. No
> exception or error but no system print either. Here is the code snippet
> from my rules file:
>
> declare SensorEvent
> @role(event)
> end
>
>
> rule "All false"
>
> when
> #conditions
> sensorEvent1 : SensorEvent(sensorID == 1 , booleanValue == false) from
> entry-point "Default";
> sensorEvent2 : SensorEvent(sensorID == 5 , booleanValue == false) ) from
> entry-point "Default";
> sensorEvent3 : SensorEvent(sensorID == 6 , booleanValue == false) from
> entry-point "Default";
>
> then
> #actions
> System.out.println(" All false!! -> ");
>
> end
>
>
> I run the engine in stream mode and every single value (or object) is
> being inserted after I receieved the value. I also tried this variant but
> it didn't work either:
>
> rule "All false"
>
> when
> #conditions
> sensorEvent1 : SensorEvent(sensorID == 1 ) from entry-point "Default";
> sensorEvent2 : SensorEvent(sensorID == 5 ) from entry-point "Default";
> sensorEvent3 : SensorEvent(sensorID == 6 , booleanValue == false &&
> sensorEvent1.booleanValue == false && sensorEvent2.booleanValue == false))
> from entry-point "Default";
>
> then
> #actions
> System.out.println(" All false!! -> ");
>
> end
>
> Any suggestions?
>
--
View this message in context: http://drools-drools-expert-drools-fusion-guvnor-drools-planner.46999.n3....
Sent from the Drools: User forum mailing list archive at Nabble.com.
15 years, 2 months
Help with Accumulate function
by dwipin
Hi,
I am having trouble implementing this rule with the accumulate function.
My rule requirement is -
Aggregate all PnlAttributionAmounts with a type of "UNEXPLAINED" for all
Positions for a given day.
Below is the code I have for this -
$position : Position(date == $currDate)
$posScn : PositionScenario(scenario == 'SCEN-EOD', position == $position )
$posScnGrp : PositionScenarioCurrencyGroup(positionScenario == $posScn,
currencyType == CurrencyTypes.TRANSACTIONAL)
$posPnlAmt : PositionPnlAmount(pnlAmountType == "DTD",
positionScenarioCurrencyGroup == $posScnGrp)
$attibAmtType : AttributionAmountType(attributionAmountType ==
"UNEXPLAINED/RESIDUALPNL")
$totalPnlAttibAmt : BigDecimal()
from accumulate(
PositionPnlAttributionAmount(positionPnlAmount ==
$posPnlAmt, attributionAmountType == $attibAmtType, $pnlAttibAmt :
financialValue)
,sum($pnlAttibAmt)
)
eval ($totalPnlAttibAmt > 1000)
When I do it this way, the rule gets executed 6 times, basically for every
fact that evaluated to true. How do I restrict this? The rule should be
executed only if the final eval results in true.
Thanks for any help,
Dwipin.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Help-with-Accumulate-...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 2 months
mvn failed to install under drools-5.1.1-examples.zip
by Aman
When I tried to run mvn install, it gave me following error-
[INFO] Scanning for projects...
Downloading:
http://repo1.maven.org/maven2/org/drools/drools/5.1.1/drools-5.1.1.pom
[INFO] Unable to find resource 'org.drools:drools:pom:5.1.1' in repository
central (http://repo1.maven.org/maven2)
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: null:drools-examples:pom:null
Reason: Cannot find parent: org.drools:drools for project:
null:drools-examples:pom:null for project null:drools-examples:pom:null
[INFO]
------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Cannot find parent:
org.drools:drools for project: null:drools-examples:pom:null for project
null:drools-examples:pom:null
at
org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
at
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at
org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
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:597)
at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at
org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.ProjectBuildingException: Cannot find
parent: org.drools:drools for project: null:drools-examples:pom:null for
project null:drools-examples:pom:null
at
org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultM
avenProjectBuilder.java:1396)
at
org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMav
enProjectBuilder.java:823)
at
org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInter
nal(DefaultMavenProjectBuilder.java:508)
at
org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjec
tBuilder.java:200)
at
org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
at
org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
at
org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
... 12 more
Caused by: org.apache.maven.project.ProjectBuildingException: POM
'org.drools:drools' not found in repository: Unable to download the artifact
from any repository
org.drools:drools:pom:5.1.1
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.drools:drools
at
org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(
DefaultMavenProjectBuilder.java:605)
at
org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultM
avenProjectBuilder.java:1392)
... 18 more
Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException:
Unable to download the artifact from any repository
org.drools:drools:pom:5.1.1
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultAr
tifactResolver.java:228)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultAr
tifactResolver.java:90)
at
org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(
DefaultMavenProjectBuilder.java:558)
... 19 more
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to
download the artifact from any repository
at
org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWag
onManager.java:404)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultAr
tifactResolver.java:216)
... 21 more
[INFO]
------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sat Oct 02 16:37:04 EDT 2010
[INFO] Final Memory: 1M/4M
[INFO]
------------------------------------------------------------------------
15 years, 2 months
Question
by Heng hh
Hi all
I would like to ask how drools run . I found that they can run in two
different drl file. What is salience for ?.
rule " Teting 571"
salience 4200
when
root:AdjudicationDTO(type=="PRIORAPPROVAL_LINE",t:type);
pa:PriorApproval();
pal:PriorApprovalLine($pb:productBenefit);
cct:PriorApprovalTreatment(id!=null,$c:clinical);
then
System.out.println( "571= PASS ");
if(
root.getAppliedUcr($pb.getBenefit(),pa.getProposedDateOfTreatment(),pal.getClinicalUcrs(),$c)!=null&&
root.getAppliedUcr($pb.getBenefit(),pa.getProposedDateOfTreatment(),pal.getClinicalUcrs(),$c).getUcrType()!=null&&
(
root.getAppliedUcr($pb.getBenefit(),pa.getProposedDateOfTreatment(),pal.getClinicalUcrs(),$c).getMinChargeLimit()!=null&&
root.getAppliedUcr($pb.getBenefit(),pa.getProposedDateOfTreatment(),pal.getClinicalUcrs(),$c).getMinChargeLimit().compareTo(pal.getRequestedAmount())<0
||
root.getAppliedUcr($pb.getBenefit(),pa.getProposedDateOfTreatment(),pal.getClinicalUcrs(),$c).getMinChargeLimit()!=null&&
root.getAppliedUcr($pb.getBenefit(),pa.getProposedDateOfTreatment(),pal.getClinicalUcrs(),$c).getMinChargeLimit().compareTo(pal.getAllocatedAmount())<0
)
){
registerPALineStepStr(pal,571+cct.getId().toString(),
"571 Clinical treatment UCR validation",
AdjudicationConstants.RESULT_FAIL,
"The requested amount is more than the treatment UCR charge limit",
"PA line requested amt ["+pal.getRequestedAmount()+"] "+
" Allocated amt ["+pal.getAllocatedAmount()+"] "+
" benefit["+pal.getProductBenefit().getBenefit().getCode()+"]"+
"UCR["+root.getUcrDetailsMsg(root.getAppliedUcr($pb.getBenefit(),pa.getProposedDateOfTreatment(),pal.getClinicalUcrs(),$c))+"]"
);
}
else{
registerPALineStepStr(pal,571+cct.getId().toString(),
"571 Clinical treatment UCR validation",
AdjudicationConstants.RESULT_PASS,
"The requested amount is more than the treatment UCR charge limit",
"PA line requested amt ["+pal.getRequestedAmount()+"] "+
" Allocated amt ["+pal.getAllocatedAmount()+"] "+
" benefit["+pal.getProductBenefit().getBenefit().getCode()+"]"+
root.getUcrDetailsMsg(root.getAppliedUcr($pb.getBenefit(),pa.getProposedDateOfTreatment(),pal.getClinicalUcrs(),$c))
);
}
end
15 years, 2 months
whern to remove persistent stateful drools session
by Stephan.Koops@We4IT.com
Hi,
I use drools with JPA peristence. It also persists the sessions. If I want
to load them back, I got an exception. So I create a new session every
time a need one. Is this a bad (or not good) strategy?
When can I remove the persisted session from the database? Directly after
closing it? Or can I disable the persistence of session, so only the other
things are persisted?
Thanks in advance.
Mit freundlichen Grüssen/Best regards
i. A.
Stephan Koops
Software Engineer
We4IT GmbH
***************************************************
Sie wollen aktuelle Informationen zu Lotus-Produkten? Dann besuchen Sie unseren Blog:
http://www.lotus-notes-domino-blog.de
***************************************************
We4IT GmbH
Technologiepark 11
33100 Paderborn
Tel: +49 5251 / 70993 - 24
Fax: +49 5251 / 70993 - 01
Mobil:
E-Mail: stephan.koops(a)we4it.com
Internet: http://www.we4it.com
HRB 20740, Amtsgericht Bremen
Geschäftsführer: Stefan Sucker, Vicente Diaz Fernandez
USt.-ID.-Nr. DE 220 859 831
Diese Nachricht ist vertraulich und ausschließlich für die adressierte Person und/oder Organisation bestimmt. Vertrauliche und/oder spezifische Informationen können hierin enthalten sein. Falls Sie ein nicht beabsichtigter Empfänger dieser Nachricht sind, sind das Kopieren, Verteilen und/oder das Aufnehmen aus dem Inhalt resultierender Handlungen untersagt. Haben Sie diese Nachricht fehlerhaft und/oder unvollständig erhalten, benachrichtigen Sie uns bitte umgehend unter unseren oben genannten Kontaktmöglichkeiten.
This message is confidential and intended solely for the person or organization to which it is addressed. It may contain privileged and confidential information. If you are not the intended recipient, you should not copy, distribute or take any action on reliance on it. If you have received this transmission in error, please notify us immediately by e-mail at the above address.
15 years, 2 months
Ruleflow "stalling" in stateless session - no events, workitems, etc
by drdaveg
I apologize if this is covered elsewhere, but I am not sure of the keywords
to search that would not return 1000 posts.
I have ruleflow running from a rule that starts it in a
StatelessKnowledgeSession. I am doing this to avoid inferencing, which is
present in the stateful version of this application. I am starting the
ruleflow from a rule with no ruleflow-group.
The ruleflow seems to run until it executes a rule in the first rule
RuleflowGroup node. The subsequent node, included for debugging, just
displays a message to the console and is never reached. There are no
parameters to the ruleflow, no events in the ruleflow, no workitems (as this
is simply a ruleflow) so I am wondering how processing has stalled before a
node with no conditions for entry.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Ruleflow-stalling-in-...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 2 months
drools flow - why after reloading some process previously completed workItems gets executed once again?
by gs76pl
hi,
i've a simple drools flow process with one workItem (its execute method
simply prints some text) and one human task. I'm using
drools-persistence-jpa to save my process status and load it when
process/server crashes.
What i've noticed is that:
1. after starting process my processinfo table gets updated with a new
process status (P1)
2. my workItem (W1) runs correctly and prints a text
3. a human task gets created
----- when i stop my server at this point and restart my server executing
below steps
1. load the session using
JPAKnowledgeService.loadStatefulKnowledgeSession(myPreviousSessionId,....)
2. start the process
At this point previously completed workItem (W1) gets executed once again
and the same human task gets created !!
I thought that perhaps the issue is with my transactionManager not
committing steps but since i'm using local transaction (commit happens after
any process step) its very unlikely.
Is it a bug that the same workItem gets executed or is it intentional and
it's up to the developer to check somewhere else whether specific step has
been already finished or not..?
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/drools-flow-why-after...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 2 months