[rules-users] Drools Flow: Variable Persistence Strategies

Dale Wyttenbach dale.wyttenbach at gmail.com
Fri Feb 19 13:59:58 EST 2010


Here's another idea to bounce off of you: Given StringVariablePersister, you
can easily persist things other than Strings, so long as you can construct
them from a String.  (Boolean, Integer, etc).  In the attached patch, I
abstracted your StringVariablePersister and created a
BooleanVariablePersister.  What do you think?

2010/2/18 Mauricio Salatino <salaboy at gmail.com>

> Yes, of course, I add the VPS feature into drools so, I'm glad to see that
> it's useful, I will add that persister, and if you are interested in do some
> contributions with JCR will be nice too!
> Thanks a lot for your contributions!
>
>
> 2010/2/18 Dale Wyttenbach <dale.wyttenbach at gmail.com>
>
>> Excellent, I have attached a unit test that demonstrates a query made
>> possible by the first patch, in case you are interested.  The unit test is
>> designed to run in your example DroolsFlowVPS project,
>> since StringVariablePersister is not part of drools-persistence-jpa.
>>  (Could StringVariablePersister be contributed to drools?)
>>
>> 2010/2/18 Mauricio Salatino <salaboy at gmail.com>
>>
>>> The first patch is already in the trunk.
>>> About the second problem, we are trying to remove the
>>> @CollectionOfElements annotation, (because it's hibernate specific) that's
>>> why you see the other one commented out. I will try fix it asap, to be able
>>> to use toplink as persistence provider as well. Probably that will fix your
>>> problem too.
>>>
>>>
>>>
>>> 2010/2/18 Dale Wyttenbach <dale.wyttenbach at gmail.com>
>>>
>>>> That's correct, it works fine using h2.  Thanks.
>>>>
>>>> 2010/2/18 Mauricio Salatino <salaboy at gmail.com>
>>>>
>>>> Let me take a look at that too.. probably it's an oracle problem right?
>>>>> I mean, probably it just happen with oracle.. we can create a fix for that
>>>>> too
>>>>>
>>>>>
>>>>> 2010/2/18 Dale Wyttenbach <dale.wyttenbach at gmail.com>
>>>>>
>>>>> My pleasure.
>>>>>>
>>>>>> Within ProcessInstanceInfo, I've got a similar observation about the
>>>>>> eventTypes member.  'private Set<EventType>' is currently commented out in
>>>>>> favor of 'private Set<String>'.  When using an Oracle hibernate dialect,
>>>>>> this results in the DDL 'create table ProcessInstanceInfo_eventTypes' which
>>>>>> yields the error 'ORA-00972: identifier is too long'.  I imagine this will
>>>>>> be resolved when the String is promoted to EventType but I thought you might
>>>>>> want to know.
>>>>>>
>>>>>> 2010/2/13 Mauricio Salatino <salaboy at gmail.com>
>>>>>>
>>>>>> done.. I will apply the patch into the trunk.. it seems to be correct.
>>>>>>> Thanks a lot!
>>>>>>>
>>>>>>> 2010/2/13 Dale Wyttenbach <dale.wyttenbach at gmail.com>
>>>>>>>
>>>>>>> Please see attached.
>>>>>>>>
>>>>>>>>
>>>>>>>> 2010/2/12 Mauricio Salatino <salaboy at gmail.com>
>>>>>>>>
>>>>>>>>> I just want to make sure before apply the patch that the change
>>>>>>>>> will not impact in other places.
>>>>>>>>> Thanks
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Feb 12, 2010 at 5:38 PM, Mauricio Salatino <
>>>>>>>>> salaboy at gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> can you post both, previous and new, sql schema generated for the
>>>>>>>>>> VariableInstanceInfo and ProcessInstanceInfo tables?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 2010/2/12 Dale Wyttenbach <dale.wyttenbach at gmail.com>
>>>>>>>>>>
>>>>>>>>>>> If you try to write a query that
>>>>>>>>>>> requires VariableInstanceInfo.processId, it won't work because that class
>>>>>>>>>>> has no processId member.
>>>>>>>>>>> I guessed that processInstanceId would be a better join column,
>>>>>>>>>>> and that worked (patch attached)
>>>>>>>>>>>
>>>>>>>>>>> Thanks for the reply.
>>>>>>>>>>>
>>>>>>>>>>> 2010/2/12 Mauricio Salatino <salaboy at gmail.com>
>>>>>>>>>>>
>>>>>>>>>>> Hmm..
>>>>>>>>>>>> I'm looking at the source and I see the following mapping:
>>>>>>>>>>>>
>>>>>>>>>>>> @OneToMany(cascade = CascadeType.ALL)
>>>>>>>>>>>>     @JoinColumn(name = "processId")
>>>>>>>>>>>>     @MapKey(name = "name")
>>>>>>>>>>>>     private Map<String, VariableInstanceInfo> variables
>>>>>>>>>>>> = new HashMap<String, VariableInstanceInfo>();
>>>>>>>>>>>>
>>>>>>>>>>>> That makes me think that there is a join column called processId
>>>>>>>>>>>> between VariableInstanceInfo and ProcessInstanceInfo.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> 2010/2/12 Dale Wyttenbach <dale.wyttenbach at gmail.com>
>>>>>>>>>>>>
>>>>>>>>>>>>> I have a patch for drools-persistence-jpa should anyone agree
>>>>>>>>>>>>> with me that ProcessInstanceInfo and VariableInstanceInfo should be joined
>>>>>>>>>>>>> by processInstanceId.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Feb 12, 2010 at 10:52 AM, Dale Wyttenbach <
>>>>>>>>>>>>> dale.wyttenbach at gmail.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> I'm trying to adapt the StringVariablePersister presented in
>>>>>>>>>>>>>> http://blog.athico.com/2009/09/drools-flow-variable-persistence.html
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> <http://blog.athico.com/2009/09/drools-flow-variable-persistence.html>I
>>>>>>>>>>>>>> can create process instances with variable "color":
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>   private static WorkflowProcessInstance
>>>>>>>>>>>>>> startProcess(StatefulKnowledgeSession ksession, String color) {
>>>>>>>>>>>>>>     Map<String, Object> vars = new HashMap<String, Object>();
>>>>>>>>>>>>>>     vars.put("color", color);
>>>>>>>>>>>>>>     WorkflowProcessInstance p1 = (WorkflowProcessInstance)
>>>>>>>>>>>>>> ksession.startProcess("com.sample.ruleflow", vars);
>>>>>>>>>>>>>>     return p1;
>>>>>>>>>>>>>>   }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I can count them:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> select
>>>>>>>>>>>>>>     count(*)
>>>>>>>>>>>>>> from
>>>>>>>>>>>>>>     ProcessInstanceInfo
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> However I'm stymied as to counting process instances with a
>>>>>>>>>>>>>> given color, as there appears to be no join column between
>>>>>>>>>>>>>> ProcessInstanceInfo and VariableInstanceInfo.
>>>>>>>>>>>>>> Can such a query be written?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>>> rules-users mailing list
>>>>>>>>>>>>> rules-users at lists.jboss.org
>>>>>>>>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> - http://salaboy.wordpress.com
>>>>>>>>>>>> - http://www.jbug.com.ar
>>>>>>>>>>>> - Salatino "Salaboy" Mauricio -
>>>>>>>>>>>>
>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>> rules-users mailing list
>>>>>>>>>>>> rules-users at lists.jboss.org
>>>>>>>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> rules-users mailing list
>>>>>>>>>>> rules-users at lists.jboss.org
>>>>>>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> - http://salaboy.wordpress.com
>>>>>>>>>> - http://www.jbug.com.ar
>>>>>>>>>> - Salatino "Salaboy" Mauricio -
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> - http://salaboy.wordpress.com
>>>>>>>>> - http://www.jbug.com.ar
>>>>>>>>> - Salatino "Salaboy" Mauricio -
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> rules-users mailing list
>>>>>>>>> rules-users at lists.jboss.org
>>>>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> rules-users mailing list
>>>>>>>> rules-users at lists.jboss.org
>>>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> - http://salaboy.wordpress.com
>>>>>>> - http://www.jbug.com.ar
>>>>>>> - Salatino "Salaboy" Mauricio -
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> rules-users mailing list
>>>>>>> rules-users at lists.jboss.org
>>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> rules-users mailing list
>>>>>> rules-users at lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> - http://salaboy.wordpress.com
>>>>> - http://www.jbug.com.ar
>>>>> - Salatino "Salaboy" Mauricio -
>>>>>
>>>>> _______________________________________________
>>>>> rules-users mailing list
>>>>> rules-users at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>
>>>
>>> --
>>> - http://salaboy.wordpress.com
>>> - http://www.jbug.com.ar
>>> - Salatino "Salaboy" Mauricio -
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> - http://salaboy.wordpress.com
> - http://www.jbug.com.ar
> - Salatino "Salaboy" Mauricio -
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100219/a909bd12/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt.gz
Type: application/x-gzip
Size: 3681 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20100219/a909bd12/attachment.gz 


More information about the rules-users mailing list