Newbie question on how to use drools with seam
by Rex Na
Hi,
I'm new to drools and having troubles in using drools with seam framework.
Specifically speaking,
I have the following tables(namely entities):
User table:
Long id,
String name,
List<AccountPermission> permissions
AccountPermission table:
Long id,
User user,
Account account
Account table:
Long id,
Long name,
Set<Comment> comments
Comment table:
Long id,
Account account
and my drl file:
rule "insertCommentRule"
no-loop
when
$check: PermissionCheck(target == "commentHome", action ==
"insertComment")
Principal($username: name)
<...........more rules should be put here>
then
$check.grant();
end
Lastly, I have an action in CommentHome, a seam component with name
"commentHome" and this action is used to insert a comment.
As above, I understand some rules can be put there to control whether the
current user is authorised to insert a comment. However, I have failed in
many different ways.
I looked through seam books and reference as well. Nothing really explained
clearly on how to do a process control with seam components.
All I wanna do is to check whether a user who just log in with valid
credentials have permissions to insert comments. It's really hard for me to
get to that point. So could anybody show me how to do it with seam? I really
appreciate it. Thanks in advance.
15 years, 1 month
Writing a pattern in which each constraint for an event depends on the previous event
by OlliSee
Hello everyone.
Lets say we have StockTicks...
Is it possible to detect a monotonically decreasing StockTick stream over a
window?
If I knew the number of events I want to check on, I'd do it this way
$a : StockTick() over window:time(20s)
$b : StockTick(this after $a, price < $a.price) over window:time(20s)
...
But I don't know for how long the StockTick prices continue to decrease..
I imagine doing something like that
$list : List(size > 0) from collect(StockTick() over window:time(20s))
forall($a : StockTick() from $list
$b : StockTick(this after $a, price < $a.price from $list
)
That results in a nice exception.
Any idea how to do this work? And more efficiently than my approach?
Thanks
Oliver
Exception in thread "Thread-1" java.lang.ClassCastException:
org.drools.common.DefaultFactHandle cannot be cast to
org.drools.common.EventFactHandle
at
org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:336)
at
org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestriction.java:110)
at
org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstraint.java:115)
at
org.drools.common.DoubleBetaConstraints.isAllowedCachedLeft(DoubleBetaConstraints.java:166)
at
org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:274)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:220)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:81)
at
org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:279)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:220)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:81)
at
org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:662)
at org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:270)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:378)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1187)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1089)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:893)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:238)
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Writing-a-pattern-in-...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 1 month
Drools Flow persistence to HBase
by Daniel Nathanson
Has anyone ever tried to persist Drools Flow processes to HBase (or
some other NoSQL DB)? We are working on a cloud-based system sitting
with HDFS and HBase for storage. We would rather not introduce a
RDBMS into the architecture simply to support Drools Flow's JPA
requirement for persistence.
I've looked at datanucleus' JPA implementation which can talk to
HBase, but from my limited knowledge of JPA, it doesn't look like
their JPA for HBase implementation supports the Drools JPA
requirements. Specifically, HBase does not support generation of
record IDs, joins, or inner selects. Similarly, it doesn't look like
the Hadoop JDBC driver (with Hibernate) will work for the same reasons.
Regards,
Dan Nathanson
15 years, 1 month
Error using multiple evals
by Ayush
Hi All,
When I'm trying to execute multiple evals I'm getting errors. Below is what
I'm trying to do
MyEvent(prop1="XYZ") over window:time(1m) from entry-point
MyStream
or
(MyEvent() over window:time(1m) from entry-point MyStream
and
Number($i1 : doubleValue)
from accumulate(
MyEvent(
prop1 == "CONNECT",
prop2 == 3,
eval((prop3 matches ("match "+getFirstNameRegex()+" Connect")) == true)
) over window:time(1m) from entry-point MyStream, count()
)
and
eval($i1 > getNodeCount()*0.35))
or
(MyEvent() over window:time(1m) from entry-point MyStream
and
Number($i2 : doubleValue)
from accumulate(
MyEvent(
prop1 matches "(second|Third{1}_CONNECT",
prop2 == 1,
eval((prop3 matches ("MatchOne|MatchTwo){1}::"+getMMSCNameRegex()+",
failure")) == true)
) over window:time(1m) from entry-point MyStream, count()
)
and
eval($i2 > getConnectionCount()*0.4))
or
(MyEvent() over window:time(1m) from entry-point MyStream
and
Number($i3 : doubleValue)
from accumulate(
MyEvent(
prop1 matches "(E1|E2){1}_CONNECT",
prop2 == 3,
eval((prop3 matches ("REPT (one|five|seven){1}:: "+getServerID()+" is
down")) == true)
) over window:time(1m) from entry-point MyStream, count()
)
and
eval($i3 > getThirdNodeCount()*0.5))
When I'm trying to execute the above LHS I get
org.drools.rule.InvalidPatternException: Required Declarations not bound:
'$i1'.
Please help it's urgent
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-using-multiple-...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 1 month
Question about Drools accessing a global HashMap and comparing it to an object value
by mviens
MyObj is a Java object that contains:
String state;
String code;
public void addError(String message);
myObjList is an ArrayList<MyObj> containing from 2 to 20,000 objects
state2CodeMap is a HashMap<String, ArrayList<String>> containing an entry
for each US state. The associated ArrayList contains a minimum of 1 entry,
up to 200 entries.
I need to create a rule that checks all of the MyObj objects in myObjList,
gets the appropriate ArrayList from state2CodeMap based on myObj.state and
then if myObj.code not memberOf $codeList, run the "then" portion of the
rule.
I have created about 60 fairly simple rules, that are working just fine, but
this one is a little too complex for me to userstand how to write it in
Drools. Looking at this page (
http://blog.athico.com/2007/06/chained-from-accumulate-collect.html
http://blog.athico.com/2007/06/chained-from-accumulate-collect.html ), I can
see that nested "from" seems to be supported, but the page seems to be for
Drools 4. Plus, I have had to teach myself Drools in the past week. I could
really use some help with this. Any assistance is greatly appreciated!
Mike V.
global List myObjList;
global HashMap state2CodeMap;
# this rule is working just fine!
rule "Check for null State"
when
$objs : ArrayList() from collect(MyObj(state == null || state ==
"") from myObjList)
then
for (MyObj myObj : (ArrayList<MyObj>)$objs)
{
myObj.addError("State must have a value");
}
end
# I really have no idea how to write this rule
rule "Check for valid code"
when
$objs : ArrayList() from collect(MyObj())
then
for (MyObj myObj : (ArrayList<MyObj>)$objs)
{
myObj.addError("Code is not valid for the State");
}
end
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Question-about-Drools...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 1 month
Templates(without spreadsheet) with DSL
by Bala
Hi,
Is that possible to use templates with dsl without converting the dsl and
dslr to drl?
I have opted the below way to support templates with DSL and dslr.
But want to know is there a way to use the templates in dsl without
converting it to drl for ObjectDataCompiler.compile method call? Or am i
missing something?
ObjectDataCompiler compiler = new ObjectDataCompiler();
InputStream dslResource =
ResourceFactory.newClassPathResource("Rules.dsl",
DroolsValidator.class).getInputStream();
dsl = convertStreamToString(dslResource);
DrlParser parser = new DrlParser();
String resultDrl = parser.getExpandedDRL( subRuleDesc, new
StringReader(dsl));
drl = compiler.compile(rulesData, getInputStream(resultDrl));
Thanks,
Bala
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Templates-without-spr...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 1 month
Drools Flow - Python how?
by jinsthomas
Hi all,
I recently joined this group. We are using Drools flow to create some
workflows to automate some of the tasks. Would like to have some advice on
how we can use python instead of Java or Mvel. Do we have some good
tutorials/articles on this. In Drools flow we have nodes like 'Script' ,
'Converge', 'Diverge' etc. Currently i could we can either use MVEL or Java,
but from the internet we are getting a feel like we can use even python for
this.
Would some body please advice
Cheers
J Thomas
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-Python-ho...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 1 month
Looking for smart way to import huge amount of rules into BRMS
by Benson Fung
Hi,
I need to import a drl file with 9000 rules inside into BRMS. However, I
found that it takes very long time to import and it also takes long time to
get downloaded into the application to build the ruleBase. Is there any
smart way or faster way to manage this procedure? Please advise
Thanks
15 years, 1 month
large rulebase load time
by Joe White
For a large rulebase (200k+ rules) will the call to
addPackageFromDrl(drlString) run faster if the number of rules is
smaller but the rules include more || statements between predicates?
There is only one type of object ever inserted in working memory and I
have many rules with the same RHS. I can collapse those rules into one
LHS with ors between the predicates in the object, but I would only go
through the effort of optimizing if it would improve load time.
Thanks for your help.
Joe
This message is confidential. It may also be privileged or otherwise
protected by work product immunity or other legal rules. If you have
received it by mistake, please let us know by e-mail reply and delete it
from your system. You may not copy this message or disclose its contents
to anyone. The integrity and security of this message cannot be
guaranteed on the Internet.
15 years, 1 month