Re: [rules-users] Persistence in Drools 6

2014-05-28 Thread Steinmetz, Jean-Philippe
Hi Charles,

Yes I am using a KieScanner to look for updates. Since I am using Spring I
had to wrap it so that it could be properly initialized and started as a
bean. I didn't include that bit in my original post as it didn't seem
relevant to the problem at hand.

The other reason why I decided to use the bean notation instead of the kie
namespace is so that I could reference the created session as a bean that
could be injected as a property to another bean (the thread class that sets
up the session for my application and actually calls fireAllRules). Perhaps
I was not doing it right but Spring wasn't recognizing anything in the
 tags as a bean I could reference.

In any case, my approach should be identical to setting up the session in
Java directly as follows.

KieServices kieServices = KieServices.Factory.get();
ReleaseId releaseId = kieServices.newReleaseId("mygroup", "myartifact",
"version");
KieContainer kContainer = kieServices.newKieContainer(releaseId);
Environment env = kieServices.newEnvironment();
env.set(ENTITY_MANAGER_FACTORY, entityManagerFactory);
env.set(TRANSACTION_MANAGER, transactionManager);
KieSession kSession = kContainer.newKieSession(env);

This as far as I've read is exactly how the documentation recommends it be
done. It just doesn't actually work for some reason or another.

Jean-Philippe


On Tue, May 27, 2014 at 11:42 PM, Charles Moulliard wrote:

> Hi Jean-Philippe,
>
> To pickup new updates, then you should use KieScanner (part of kie-ci
> project) which allows you to do incremental build if a new kjar has been
> published/released. Here is an example :
> https://github.com/droolsjbpm/drools/blob/master/kie-ci/src/test/java/org/kie/scanner/KieScannerIncrementalCompilationTest.java
>
> Regards,
>
>
>
> On Tue, May 27, 2014 at 7:38 PM, Steinmetz, Jean-Philippe <
> jpsteinm...@theworkshop.us.com> wrote:
>
>> Hi Charles,
>>
>> Thanks for your reference. I had tried using kie-spring but was unable to
>> use it as it currently does not support creating sessions from a release id
>> and container. I did this in order to be able to pick up on updates to the
>> kjar from maven while the application is running the same way it used to
>> work in Drools 5. Has anyone else with similar needs to mine gotten
>> persistence working?
>>
>> Jean-Philippe
>>
>>
>> On Thu, May 22, 2014 at 11:23 PM, Charles Moulliard wrote:
>>
>>> Hi Jean Philippe,
>>>
>>> I have recently created a project to persist bpmn process using Spring &
>>> JPA / Hibernate. This config is working using kie-spring
>>>
>>>
>>> https://github.com/cmoulliard/droolsjbpm-osgi-examples/blob/master/spring-jbpm-persistence/src/main/resources/META-INF/spring/context.xml
>>>
>>> Regards,
>>>
>>> Charles
>>>
>>>
>>> On Thu, May 22, 2014 at 8:00 PM, Steinmetz, Jean-Philippe <
>>> jpsteinm...@theworkshop.us.com> wrote:
>>>
 Hello All,

 I am trying to set up persistence for a standalone Drools (6.0.1.Final)
 application that uses JPA, Hibernate (4.3.5.Final) and Bitronix (2.1.4) via
 Spring (4.0.3.RELEASE).

 On the persistence side everything appears to be set up correctly. For
 my Drools session I use a KieContainer to create a new stateful session
 using an environment set up with the EntityManagerFactory and
 TransactionManager set. The problem that I am experiencing however is that
 nothing is getting persisted to the database. I have poured over the docs
 at least two dozen times and searched the net for anything related.

 Here is what my Spring context file looks like when creating the Drools
 session...

 >>> factory-method="newReleaseId">
 
 
 
 
 >>> factory-method="newKieContainer">
 
 
 >>> factory-method="newEnvironment">
 
 
 
 >>> static-field="org.kie.api.runtime.EnvironmentName.ENTITY_MANAGER_FACTORY"/>
 
 
 
 >>> static-field="org.kie.api.runtime.EnvironmentName.TRANSACTION_MANAGER"/>
 
 
 
 
 
 >>> factory-method="newKieSession">
 
  

 Since the application is standalone I execute fireAllRules on the
 session at a regular interval (I use this instead of fireUntilHalt as it
 dramatically reduces the CPU load on the machine). With each call I wrap it
 in a transaction. Thus, the code looks as follows:

 while (!Thread.currentThread().isInterrupted()) {
 // Start a new transaction
 UserTransaction utx = utx = (UserTransaction)new
 InitialContext().lookup("java:comp/UserTransaction");
utx.begin();

 // Tick the session
 kSession.fireAllRules();

 // Close the transaction
 utx.comm

[rules-users] Workbench: Error after cloning repository

2014-05-28 Thread Steinmetz, Jean-Philippe
Hello,

I have successfully cloned an existing repository containing a maven
kmodule project. Unfortunately when I attempt to open any of the DRL files
in the workbench (6.0.1.Final) I get the following error:

Unable to complete your request. The following exception occurred:
java.lang.ClassNotFoundException:org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes.CTArray
from [Module "deployment.kie-drools-wb.war:main" from Service Module
Loader].

This error does not happen if I load any of the files in the demo project.
The DRL files range from complex to very simple. They all use the mvel
dialect and import the following globals.


/** The Camel context used when handling input/output. */
global CamelContext camelContext;
/** The application configuration. */
global Config config;
/** A reference to the current knowledge base. */
global KieBase kBase;
/** A reference to the current session. */
global KieSession kSession;
/** The common logging utility. */
global org.slf4j.Logger logger;

Outside of this there is nothing special to them. Has anyone seen this?

Thanks,

Jean-Philippe
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] Syntax Question on an or condition

2014-05-28 Thread Wolfgang Laun
On 28/05/2014, Chidambaran Subramanian  wrote:
> rule "Test"
>   dialect "mvel"
>   when
> ( Customer( age == 50 ) or Deal( amount == 30 ) )
>   then
> Customer.setAge( "40" );
> update( Customer );
> Customer.setPlace( "Test" );
> update( Customer );
>
> end

The rule uses invalid syntax: Customer is a class name, and you cannot
update a class. Check the Expert manual on how to write rules.

Besides, the logic doesn't make sense, because you'd not even need a
Customer for the condition to be true, and then you can't do anything
with a Customer object.
>
>
> How to do I tag both Customer and Deal on the 1st condition , to enable me
> to
>

What?

-W
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How do I access objects in a top level or condition?

2014-05-28 Thread Mauricio Salatino
Hi, you can't because you don't know which is true.
You can create two rules one for each condition
and then you can access by binding the Conditaional Element to a variable:
Like for example:

when
$c: Customer( age == 50 )
  then
$c.setAge( "40" );


On Wed, May 28, 2014 at 3:39 PM, Chidambaran Subramanian
wrote:

> rule "Test"
>   dialect "mvel"
>   when
> ( Customer( age == 50 ) or Deal( amount == 30 ) )
>   then
> Customer.setAge( "40" );
> update( Customer );
> Customer.setPlace( "Test" );
> update( Customer );
> end
>
>
>
> Appreciate any help in this regard.
>
> Regards
> Chiddu
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
 - MyJourney @ http://salaboy.com 
 - Co-Founder @ http://www.jugargentina.org
 - Co-Founder @ http://www.jbug.com.ar

 - Salatino "Salaboy" Mauricio -
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

[rules-users] How do I access objects in a top level or condition?

2014-05-28 Thread Chidambaran Subramanian
rule "Test"
  dialect "mvel"
  when
( Customer( age == 50 ) or Deal( amount == 30 ) )
  then
Customer.setAge( "40" );
update( Customer );
Customer.setPlace( "Test" );
update( Customer );
end



Appreciate any help in this regard.

Regards
Chiddu
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

[rules-users] Syntax Question on an or condition

2014-05-28 Thread Chidambaran Subramanian
rule "Test"
  dialect "mvel"
  when
( Customer( age == 50 ) or Deal( amount == 30 ) )
  then
Customer.setAge( "40" );
update( Customer );
Customer.setPlace( "Test" );
update( Customer );

end


How to do I tag both Customer and Deal on the 1st condition , to enable me
to
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] Cannot issue fireUntilHalt when using persisted session

2014-05-28 Thread rogerL
Open ticket https://issues.jboss.org/browse/DROOLS-507.
I didn't provide any persist and reload code as the system hasn't ever
reached the point of saving a session.
I tried working around the issue by using fireAllRules and an interval rule.
I was able to persist; however, the reload is failed with an exception that
I believe may be related to 
https://issues.jboss.org/browse/DROOLS-422.
As such, I added a comment therein with the stack trace.




--
View this message in context: 
http://drools.46999.n3.nabble.com/Cannot-issue-fireUntilHalt-when-using-persisted-session-tp4029656p4029738.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] mvn deploy to workbench fails: Return code is: 405, ReasonPhrase:Method Not Allowed.

2014-05-28 Thread jmterrettaz
Hi
I have installed the Drools Workbench
kie-drools-wb-distribution-wars-6.0.1.Final-jboss-as7.0.war on JBoss EAP
6.2. When I try to do a mvn deploy to the workbench it fails with "Return
code is: 405, ReasonPhrase:Method Not Allowed."
Here the distributionManagement section of the POM:



guvnor-m2-repo
http://localhost:8080/kie-drools-wb/maven2/



I also defined the server as follow in my settings.xml :



guvnor-m2-repo



Authorization

Basic xxxoffuscatedx 
=






If I give a wrong Authorization value there I get a 401 non authorized, so I
think the server is correctly configured. 

In wireshark I see that an HTTP PUT call is made and the answer is:

HTTP/1.1 405 Method Not Allowed
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 01:00:00 CET
Content-Type: text/html;charset=utf-8
Content-Length: 1176
Date: Wed, 28 May 2014 12:00:44 GMT

JBoss Web/7.2.2.Final-redhat-1 - JBWEB64: Error
report 
JBWEB65: HTTP Status 405 - HTTP method PUT is not supported by this URL
*JBWEB000309: type* JBWEB67: Status
report*JBWEB68: message* HTTP method PUT is not supported by
this URL*JBWEB69: description* JBWEB000125: The specified
HTTP method is not allowed for the requested resource.
JBoss Web/7.2.2.Final-redhat-1


in a more readable format: 

JBWEB65: HTTP Status 405 - HTTP method PUT is not supported by this URL

JBWEB000309: type JBWEB67: Status report
JBWEB68: message HTTP method PUT is not supported by this URL
JBWEB69: description JBWEB000125: The specified HTTP method is not
allowed for the requested resource.

JBoss Web/7.2.2.Final-redhat-1

Can someone help? Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/mvn-deploy-to-workbench-fails-Return-code-is-405-ReasonPhrase-Method-Not-Allowed-tp4029737.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Excel Syntax in Decision Tables

2014-05-28 Thread crosbis2
Thanks Wolfgang!!



--
View this message in context: 
http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029735.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] how to create kbases with useful names for JMX

2014-05-28 Thread Edson Tirelli
   Christopher,

   Thanks for reporting this. The public API does not currently allows
users to set the ID of the KieBase unfortunately. I will fix this for
6.1. With 6.0, it is only possible to do it using the internal APIs.

   Edson



On Tue, May 27, 2014 at 4:37 PM, cjohns13
 wrote:
> How can I create new container / knowledgebases so that the names as shown in
> JMX are not random UUID() strings?
>
> Something like this currently:
> KieContainer container =
> KieServices.Factory.get().newKieContainer(releaseId);
> container.newKieSession("myName");
>
> When you enable mbeans via Kie.mbeans.enabled=true
>
> Yields, in JMX:
>
> objectName: org.drools.kbases:type=2d4ffdab-2aca-4d5d-8c44-a5031c4d4094
>
> but, would rather have it be
> org.drools.kbases:type=myName
>
> How can I create the container/kbase/session so it gets a good name, as it
> stands now?  I can see in KnowledgeBaseFactoryServiceImpl.java that there is
> a way to set this kbaseId, but can't figure out a way to actually set this
> at the high level.
>
>
>
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/how-to-create-kbases-with-useful-names-for-JMX-tp4029719.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users



-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Abstraction between rules and data model?

2014-05-28 Thread Péter Gergely , Horváth
Thanks for the explanation, I was a bit confused because of the
terminology; "virtual" is not mentioned in the docs. ;)

Is there any plan for the public release of Trait property binding to a
nested path? We would definitely need something like that in our
environment. Or do you see any way we could hook into the property look-up
mechanism? Based on what I know, I don't see any official extension point
for that.

My only idea would be using some Java proxy voodoo-magic to wrap objects
before they are inserted to the session, but my gut feeling is that it
would be a way to debug hell...

What do you think?

Cheers,
Peter



2014-05-27 19:42 GMT+02:00 Davide Sottara :

>  Consider that a trait is an interface applied to some class. In the
> context of the pair:
> A "hard" field is a property (get/set) exposed by the interface AND the
> underlying class
> A "soft" (or "virtual") field is a property exposed by the interface BUT
> NOT by the underlying class
> A "hidden" field is a field of the underlying class NOT exposed by the
> interface
>
> Hard and Soft fields can be accessed using the interface, hidden fields
> are accessible using the map-like
> construct fields[ "fieldName" ].
>
> This said,
> the mapping is by default done using the property name and (then) the
> property type.
> However, this mapping can be decoupled using the annotation @Alias() on
> either the class OR the trait.
> E.g.
> declare Core
>   name : String @Alias( "any-Id-or-even-an-IRI-here" )
> end
>
> declare trait SomeTrait
> label : String @Alias( "..." )  // if two "aliases" match, this will
> be considered a hard field
> end
>
> The "accessor", i.e. the ability to bind a trait property to a (possibly
> deeply) nested path is what I'm working
> on these days, I have the same requirement from another urgent use case
>
> For the time being, you can probably create a "shortcut" accessor pair in
> your implementation class,
> to execute the complex expression, and @Alias it to the trait field.
>
> Please let me know if you find any issue/bugs and any feature request you
> may have!
> Best
> Davide
>
>
>
> On 05/27/2014 07:57 AM, Horváth Péter Gergely wrote:
>
> Hi Davide,
>
>  Drools trait functionality is one of the powerful concepts which makes
> Drools a good candidate for the project. So keep up the good work! :)
> However I'm not sure if its current level of flexibility would be
> sufficient for our use case. I've checked the documentation, but haven't
> really found the term virtual field -- could you please elaborate on this?
>
>  Do you think we could somehow hook into the evaluation of the aliases or
> the "fields" Map? Sometimes you would need slightly more than merely
> aliasing fields to something else; e.g. calculating values for the purpose
> of rule processing or extracting a value from a more complex object tree
> etc. Citing the example -- GoldenCustomer( fields[ "age" ] > 18 ) -- being
> able to get a reference to the target object and the field map expression
> "age" would be quite close to what I imagined. Our custom code could then
> perform the appropriate translation and return the requested value, hiding
> the fact whether "age" is an actual field in the Customer object
> itself/retrieved from an encapsulated complex object e.g. replacing
> expression "customer.personalInformation.birthData.age"/calculated on the
> flight.
>
>  What do you think?
>
>  Cheers,
> Peter
>
>
>
> 2014-05-26 17:58 GMT+02:00 Davide Sottara :
>
>> We are working on the trait framework for cases like this. Essentially,
>> it allows to use
>> interfaces when writing rules AND to inject the interfaces dynamically
>> at runtime,
>> at the instance level. It relies on transparent proxies which wrap the
>> data classes
>> and implement the required interfaces. A simple field aliasing mechanism
>> is provided
>> (work in progress). For more complex transformations, "virtual" fields
>> can be added.
>> See section 7.7.8 of the manual for more details and let me know if it
>> can help
>> with your use case.
>> Best,
>> Davide
>>
>> On 05/26/2014 09:55 AM, Wolfgang Laun wrote:
>> > Even a relatively sophisticated transformation would be easier to
>> implement
>> > and most certainly safer from changes in the unstable Drools API than
>> some
>> > hook-and-intercept mechanism built into Drools.
>> >
>> > Notice that violent structural departure of the model the BUs see from
>> what
>> > you call "persistence model" might make it impossible for the BUs to
>> come
>> > up with rules that can be transformed to match the other model at all;
>> > if it is possible, rules might still incur a heavy performance penalty.
>> >
>> > It is (IMHO) a myth that "Rules" is a foolproof way of establishing
>> > business logic
>> > independent from the data model and application environment with which
>> > this logic should be able to cooperate. As long as everything is kept
>> in the
>> > abstract (i.e., formulated in terms of mathematics) it will look  good,