Con't upload POJO Model.jar via HTTP POST, not even with Curl
by Mark Bennett
After having trouble getting Guvnor to accept my .jar via Java sockets, I decided to do some tests with curl.
But I can't get Curl to upload the JAR either. The error I get is:
HTTP Status 501 -
type status report
description The server does not support the functionality needed to fulfill this request ()
Details:
My package: "rules"
My jar file: Model.jar (in current directory)
Version: Guvnor 5.5.0.Final under JBoss
Main URL: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/Guvnor.html
Login with admin/admin
Script 1:
#!/bin/bash
# My package is "rules"
URL=http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/webdav/packages/rules/
FILE=Model.jar
AUTH=admin:admin
curl -X POST --verbose --user "$AUTH" --data-binary @$FILE $URL
Tried some variations:
Tweak URL (add slash, add file name)
URL=http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/webdav/packages/rules/
URL=http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/webdav/packages/rules/Model.jar
Mime type:
MIME=application/java-archive
curl -X POST --verbose --user "$AUTH" --header "Content-Type:$MIME" --data-binary @$FILE $URL
I'd appreciate any advice / examples.
Thanks
--
Mark Bennett / LucidWorks: Search & Big Data / mark.bennett(a)lucidworks.com<mailto:mark.bennett@lucidworks.com>
Office: 408-898-4201 / Telecommute: 408-733-0387 / Cell: 408-829-6513
11 years, 3 months
Binding a variable with an OR pattern
by Joe Ammann
Hi all
Trying to do the following: as one pattern of a rule, I want to bind a
variable to a fact with code "7001", or (if such a fact does not exist)
to one with the value "7000".
Until now, I haven't been able to formulate this in one single rule, as
simple as it sounds - probably I'm just overlooking something basic ...
Currently I have 2 rules:
rule "R7012: UpdateInstrumentsIssuerFrom7001"
agenda-group "TRANSFER_TO_LIVE"
salience 100
when
sirole : SourcingInstitutionRole(sourcing_Status ==
SourcingStatus.IMPORTED,
roleCd == "7001" )
insti : Institution ( ids != null, ids.sspFI ==
sirole.institutionProviderId )
instr : Instrument ( ids != null, ids.sspFI == sirole.providerId,
issuer.issuerId != insti.id )
then
tlog.info("Modify issuer of {} to {} (from role code 7001)", instr,
insti);
modify (instr) {
issuer.issuerId = insti.id
}
end
rule "R7012: UpdateInstrumentsIssuerFrom7000"
agenda-group "TRANSFER_TO_LIVE"
salience 100
when
sirole : SourcingInstitutionRole(sourcing_Status ==
SourcingStatus.IMPORTED, roleCd == "7000" )
insti : Institution ( ids != null, ids.sspFI ==
sirole.institutionProviderId )
instr : Instrument ( ids != null, ids.sspFI == sirole.providerId,
issuer.issuerId != insti.id )
not SourcingInstitutionRole(sourcing_Status == SourcingStatus.IMPORTED,
providerId == instr.ids.sspFI,
institutionProviderId == instr.ids.sspFI,
roleCd == "7001" )
then
tlog.info("Modify issuer of {} to {} (from role code 7000)", instr,
insti);
modify (instr) {
issuer.issuerId = insti.id
}
end
This seems to work, but I would have expected that it should be easy to
do this in one single rule !? But I just can't come up with a rule that
does what I want...
How would I formulate such as rule?
--
CU, Joe
11 years, 3 months
timer in stateless kbsession?
by Markus Schneider
Hi list,
short question regarding timers. Are they available in stateless sessions?
Regards,
-markus
11 years, 3 months
KIE-WB, Drools-WB Authoring REST api
by Alexander Herwix
Hey guys,
I really love the new wb-apps, but documentation is really pretty sparse right now, so maybe you guys can help me out :)
Is there any documentation on the authoring REST-Api? I have already asked on the jbpm forum, where they said that there should be one but that it's not documented yet. I have found some repository, group stuff exposed (drools-wb-rest), process-execution (jbpm) but no real asset authoring.
The reason I need this access, is to use the kie-wb in parallel to my own gui with the kie-wb as admin interface. I know there have been improvements with user-extendable editors via uberfire and GWT but with the level of documentation as it is right now, I can't make that dive now. But with my data already in the wb it should be trivial to port my user-facing gui in the future if the need should arise.
What do you guys think? Is this possible with the upcoming droolsjbpm 6 release? Could anyone provide at least rudimentary documentation of (all) the REST APIs? It would really help if there would be at least a unified feature list of what to expect in open APIs of the kie-wb (so for jbpm as well as drools).
Thanks for any help on advance!
Cheers, Alex
11 years, 3 months
JUnit Test, Mockito, AgendaEventListener Problem.
by droolster
Hello,
Please can the community help me.
I am setting up a JUnit test case. I am using Mockito to mock an
AgendaEventListener as follows:
* AgendaEventListener ael = mock(AgendaEventListener.class);
ksession.addEventListener(ael);*
However, Eclipse keeps complaining that
*The method addEventListener(WorkingMemoryEventListener) in the type
WorkingMemoryEventManager is not applicable for the arguments
(AgendaEventListener).*
According to the 5.5.0.Final API, it should infer that I am using:
*addEventListener(AgendaEventListener listener) *
but it doesn't. Can anyone help please. I am stuck on this.
Regards.
--
View this message in context: http://drools.46999.n3.nabble.com/JUnit-Test-Mockito-AgendaEventListener-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
Mapping complex objects info Guvnor compatible shim classes?
by Mark Bennett
We want our domain experts to be able to create Guided Rules in Guvnor (5.5)
But Guvnor seems pretty limited about what it will accept, and how it will render it.
We're attempting to create adapter classes that will:
* Allow us to expose a rich set of fields and methods in UI
* Use as injected facts into the engine
Main issues we're having:
* Native objects are nested, but Guvnor seems to want shallow
* Our native objects can have different attributes (different schemas)
- And you can't say getField( fieldName )
* Some returned items can be multivalued, vs. singular
Our idea is:
* Have admin send a prototypical request & schema event into our native system
* Scrape and flatten that into a java class that exposes Guvnor friendly methods
* Send that class into Guvnor
* Keep a copy of that class to create instances of when injecting facts into the engine
Is there some type of easy way to map complex objects to/from the simpler Guvnor/Drools model? Some type of reflection based mapper with some simple rules or a template? We're wondering what others have done in this situation?
Thanks,
Mark
--
Mark Bennett / LucidWorks: Search & Big Data / mark.bennett(a)lucidworks.com
Office: 408-898-4201 / Telecommute: 408-733-0387 / Cell: 408-829-6513
11 years, 3 months
Re: [rules-users] Mapping complex objects info Guvnor compatible shim classes?
by Michael Anstis
Drools Workbench (replacement for Guvnor) in 6.0 offers the ability to
easily add your own custom editors so you could provide your own UI to suit
your needs exactly.
It is much more difficult to add or replace editors in Guvnor 5.5 and early.
That said Rule Templates provide a means to define a rule, erm template for
want of a better word, that could be defined by more technically minded
users with others filling in the blanks.
Sent on the move
On 11 Aug 2013 21:11, "Mark Bennett" <mark.bennett(a)lucidworks.com> wrote:
Thanks Steve.
I'll check out dozer.
I did look at DSL's, but the emphasis is really on putting a UI on things.
Your advice on hold off baking in every single field also mirrors a point
that was raised on the team recently. Advanced users can always drop into
DRL mode, etc.
Actually, Guvnor's guided rules isn't our ideal UI either. I think we
were hoping for more of a "wizard" toolkit where users select from a list
of pre-existing rules and fill in templates, at least as an option for new
users. Then more advanced users could jump out to the guided rules or even
the expert / DRL rules mode. But Guvnor's guided rules are still a pretty
advanced UI for newcomers. It's kind of funny, I think people assume that
anything that has a "UI" is easy/obvious to use, even for new users; I'm
pretty sure we could all rattle off many counter-examples from the software
world. ;-)
Any thoughts on conjuring a simpler UI for truly "guided" rules creation?
I read that Guvnor could be embedded, but not sure that really helps
either.
--
Mark Bennett / LucidWorks: Search & Big Data / mark.bennett(a)lucidworks.com
Office: 408-898-4201 / Telecommute: 408-733-0387 / Cell: 408-829-6513
On Aug 10, 2013, at 2:14 AM, Stephen Masters <stephen.masters(a)me.com>
wrote:
Your plan seems about right to me. When working in pure Drools, you don't
always need to do this. However, when working in Guvnor, I have always
found it necessary to create a simplified domain model for facts.
In Guvnor, you can bind variables to fields and drill in, but it's fiddly.
Guided rules are much more readable when they are dealing with matching
bean-style facts with key attributes available through simple getX()
accessor methods. And of course you definitely need the bean-style getX()
methods.
The other thing to think about, is that when working with Guvnor, you
should be avoiding any dependencies on external classes from within your
facts. Otherwise, you will need to put everything on your Guvnor web
server's class path, which totally messes with your ability to upload fact
model updates. Yet another reason to keep them simple.
So given that you're going with that plan, here are my tips for the lazy
(like me)...
To help with simplifying your transformations, it may be worth looking at
Dozer or similar: http://dozer.sourceforge.net/
Personally, because I have often found that I'm doing things like mapping
multiple objects into a single fact, I tend to just do the mapping in
straight Java code. It tends not to be too painful, as I rarely find the
need for bi-directional mappings. I don't often need to get a fact back out
of working memory. So although it feels a bit naughty, I often avoid the
fact-to-domain-object transform. :)
Think about what properties you really might want to write rules about.
It's easy to spend a huge amount of time writing a huge fact model, and
transforms for every single property of every class in your domain model.
Truth is you probably won't write rules that look at all of it. So have a
think about whether you do need to map everything or not. My tip here would
be to follow a TDD approach. Look at what rules your users want to write.
You should find that the rules mostly follow certain stereotypes, so create
rule tests covering a representative selection of such stereotype (ensure
coverage of all unique fact attributes which are examined). Create a fact
model which can satisfy those tests. Create tests for transforming from
your domain model to your fact model. Create transforms to that fact model.
Assuming you have a reasonably iterative environment, you can add
transforms for additional attributes when users have tried out the
application and come up with new rule stereotypes they would like to work
with.
As an alternative (or to complement the above), take a look at DSLs. Each
DSL phrase becomes available in your guided editor, so you can have simple
rule phrases which the users can understand, but underneath, you can have
code which is drilling into nested objects.
I do hope that's helpful… :)
Steve
On 10 Aug 2013, at 00:47, Mark Bennett <mark.bennett(a)lucidworks.com> wrote:
We want our domain experts to be able to create Guided Rules in Guvnor (5.5)
But Guvnor seems pretty limited about what it will accept, and how it will
render it.
We're attempting to create adapter classes that will:
* Allow us to expose a rich set of fields and methods in UI
* Use as injected facts into the engine
Main issues we're having:
* Native objects are nested, but Guvnor seems to want shallow
* Our native objects can have different attributes (different schemas)
- And you can't say getField( fieldName )
* Some returned items can be multivalued, vs. singular
Our idea is:
* Have admin send a prototypical request & schema event into our native
system
* Scrape and flatten that into a java class that exposes Guvnor friendly
methods
* Send that class into Guvnor
* Keep a copy of that class to create instances of when injecting facts
into the engine
Is there some type of easy way to map complex objects to/from the simpler
Guvnor/Drools model? Some type of reflection based mapper with some simple
rules or a template? We're wondering what others have done in this
situation?
Thanks,
Mark
--
Mark Bennett / LucidWorks: Search & Big Data / mark.bennett(a)lucidworks.com
Office: 408-898-4201 / Telecommute: 408-733-0387 / Cell: 408-829-6513
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
11 years, 3 months
Snapshot of drools engine's state
by IK81
Hi,
I am looking for a solution to make the engine's state persistent in regular
intervals. I do not want to persist the engine's state at every event
insertion for performance reasons. Instead I am thinking of making a
snapshot of the engine's state let's say every X seconds. The events I have
are always stored to a database. In case of a crash or reboot I'd like to
recover the engine's state from the snapshot + reinserting the events that
happened after the timestamp of my snapshot.
Are there any hints or caveats regarding this approach?
Best regards,
Ingo
--
View this message in context: http://drools.46999.n3.nabble.com/Snapshot-of-drools-engine-s-state-tp402...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
Runing Rules in Two Phases ( using AgendaFilters ) with inference
by viraj
Hi all,
I have problem with using AgendaFilters to select rules when rules written
to use inference. First I will try to explain the situation. In my project I
have two sets of rules. First set is eligible rules which run to evaluate
eligibility of products and second phase is selection rules which run on
results of eligible products.
Ex : Eligible Rule
package rule.eligible
rule "Eligible Rule 1 - 3 "
no-loop true
when
$evaluationResults : EvaluationResults( validProducts not contains "3" );
UserProfile( status == 1 ) // other conditions
then
modify( $evaluationResults ) { addIntoEvaluatedProducts(3 + "" ) } ; //
Add into validProducts HashSet
end
Ex: Selection Rule
package rule.selection
rule "Selection Rule - 1"
no-loop true
when
$evaluationResults : EvaluationResults( validOffers.keySet not contains
"1" , validProducts contains "3" ) // Other conditions
then
modify( $evaluationResults ){ addIntoEvaluatedOffers("1", "3")} //Add into
validOffers Map
end;
when i use fireAllRule() the above rules run correctly. Now I want to run
only eligible rules and later selection rules since in some scenarios I need
only valid products. So I tried using following code
Run only eligible rules which rule name start with "Eligible Rule"
statefulKnowledgeSession.fireAllRules(DroolsHelper.getActivatedRulesFromRuleStartWith("Eligible
Rule"));
Run only selection rules which rule name start with "Selection Rule"
statefulKnowledgeSession.fireAllRules(DroolsHelper.getActivatedRulesFromRuleStartWith("Selection
Rule"));
Method DroolsHelper.getActivatedRulesFromRuleStartWith
public static AgendaFilter getActivatedRulesFromRuleStartWith(final
String startWith) {
AgendaFilter filter = new AgendaFilter() {
public boolean accept(Activation activation) {
FactHandle objects =
activation.getPropagationContext().getFactHandle() ;
if (activation.getRule().getName().startsWith(startWith)) {
return true;
}
return false;
}
};
return filter;
}
I checked rule execution using KnowledgeRuntimeLogger. It shows eligible
rules correctly activate selection rules but when I run selection rules
only, it does not get executed. Is there a way do this kind of task ?
--
View this message in context: http://drools.46999.n3.nabble.com/Runing-Rules-in-Two-Phases-using-Agenda...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months