Re: [scxml] passing datamodel elements into method call

2014-10-26 Thread Ate Douma

Hi Rinke,

I've been diving into the datamodel handling, the Data() function and supporting 
Builtin Java class the last several days.


I've now come to the conclusion that what you are asking for *should* be 
supported by Commons SCXML, and actually *is* supported through the SCXML 
specification.


The current implementation of this functionality in Commons SCXML however is 
very problematic, not just for your use-case but overall, and I've created issue 
SCXML-213 to address this.


I'm working on the SCXML 2.0 Milestone 2 goal and trying to execute (and pass) 
the SCXML IPR tests, which is pretty much blocked because of this issue.


Anyway, once I've solved this, I expect your requirement will be covered 
automatically as well!


Note though that the scope of SCXML-213 is pretty extensive and will take large 
scale (breaking) changes, for which I also just send out a separate heads-up to 
the list...


This will take a while to complete, so intermediately implementing a custom 
action to cover your requirements probably is still worthwhile.


Kind regards,

Ate


On 08-10-14 20:54, Ate Douma wrote:

On 08-10-14 11:31, R.C. Hoekstra wrote:

Hi Rinke, I think you would get a node if you used DataNode function
instead:  Could you
try that?

Regards, Woonsan



Hi Woonsan,

thanks for your answer. But are you sure about that? If I use it like that, I
get an "unknown, ambiguous or inaccessible method dataNode" error.


Correct, DataNode() is not a function available (registered) within the context
of the expression evaluator.



I found the dataNode method in Builtin.java. Its javadoc says:

"Manifests within location attribute of  element, for Commons JEXL
and Commons EL based documents."

So what I get from it, is that dataNode can only be used to assign something
to a dataNode via .

That is not what I want. I want to pass a dataNode including subElements to
some java object via the cond attribute, so I can write a java method which
is able to check conditions with use of the passed dataNode.


So: is there a way in which I can pass a dataNode to a java object in the
context which is used in a cond attribute? Data obviously doesn't work, as I
can see in the Builtin code that it always is parsed to Double or String.


Not by the SCXML spec, and neither (directly) through Commons SCXML extensions.

However, it should be trivial to add such functionality yourself through a
custom Action. Then you can access and use the Builtin#dataNode method and do
whatever you like with a data node element.

For a quick intro in writing a custom Action (for Commons SCXML 2.0), see for
example slides 12,13 of my presentation at the ApacheCon earlier this year:


http://events.linuxfoundation.org/sites/events/files/slides/ApacheConUS2014%20-%20Apache%20Commons%20SCXML%202.0.pdf


and I suggest looking at the Commons SCXML Var action as simply example.

HTH, Ate




best regards, Rinke






On Thursday, October 2, 2014 3:53 AM, R.C. Hoekstra
 wrote:



Hi list, Hi people @ scxml commons,

Can I pass datamodel nodes to a rootContext var, in order to process it
in java?

like this: , where: * agent is an object of a java class made available to the
RootContext, having a check method returning Boolean. I want this check
method to evaluate the datamodelNode, in order to return true or false
depending on elements. * datamodelNodeRef is a reference to some node in
the datamodel.

I managed to pass final nodes as string here, like this:

, 







-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Re: [scxml] passing datamodel elements into method call

2014-10-17 Thread R.C. Hoekstra
Thanks Woonsan, Ate, 

I think I can work that out. 

best regards, Rinke
-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [scxml] passing datamodel elements into method call

2014-10-08 Thread Ate Douma

On 08-10-14 11:31, R.C. Hoekstra wrote:

Hi Rinke, I think you would get a node if you used DataNode function
instead:  Could you
try that?

Regards, Woonsan



Hi Woonsan,

thanks for your answer. But are you sure about that? If I use it like that, I
get an "unknown, ambiguous or inaccessible method dataNode" error.


Correct, DataNode() is not a function available (registered) within the context 
of the expression evaluator.




I found the dataNode method in Builtin.java. Its javadoc says:

"Manifests within location attribute of  element, for Commons JEXL
and Commons EL based documents."

So what I get from it, is that dataNode can only be used to assign something
to a dataNode via .

That is not what I want. I want to pass a dataNode including subElements to
some java object via the cond attribute, so I can write a java method which
is able to check conditions with use of the passed dataNode.


So: is there a way in which I can pass a dataNode to a java object in the
context which is used in a cond attribute? Data obviously doesn't work, as I
can see in the Builtin code that it always is parsed to Double or String.


Not by the SCXML spec, and neither (directly) through Commons SCXML extensions.

However, it should be trivial to add such functionality yourself through a 
custom Action. Then you can access and use the Builtin#dataNode method and do 
whatever you like with a data node element.


For a quick intro in writing a custom Action (for Commons SCXML 2.0), see for 
example slides 12,13 of my presentation at the ApacheCon earlier this year:



http://events.linuxfoundation.org/sites/events/files/slides/ApacheConUS2014%20-%20Apache%20Commons%20SCXML%202.0.pdf 



and I suggest looking at the Commons SCXML Var action as simply example.

HTH, Ate




best regards, Rinke






On Thursday, October 2, 2014 3:53 AM, R.C. Hoekstra
 wrote:



Hi list, Hi people @ scxml commons,

Can I pass datamodel nodes to a rootContext var, in order to process it
in java?

like this: , where: * agent is an object of a java class made available to the
RootContext, having a check method returning Boolean. I want this check
method to evaluate the datamodelNode, in order to return true or false
depending on elements. * datamodelNodeRef is a reference to some node in
the datamodel.

I managed to pass final nodes as string here, like this:

, 





-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Re: [scxml] passing datamodel elements into method call

2014-10-08 Thread Woonsan Ko
Hi Rinke,

Sorry for my confusion. Indeed, DataNode function seems to exist only for 
assign element.

Regarding other possible options, I think you can set a holder object (named 
"treatmentDataHolder" for instance) in the root context before execution, and 
you can invoke the holder's method to set the data object. For example,
  
treatmentDataHolder.setData(treatementData);
treatmentDataHolder.setLocation('treatments/treatment[1]/name');
  

After execution, you can invoke treatmentDataHolder#getData() and 
treatmentDataHolder#getLocation() to read what was set during execution.


Regards,

Woonsan



On Wednesday, October 8, 2014 5:31 AM, R.C. Hoekstra 
 wrote:
 

>
>
>> Hi Rinke,
>> I think you would get a node if you used DataNode function instead:
>> > expr="DataNode(treatmentData,'treatments/treatment[1]/name')" />
>> Could you try that?
>>
>> Regards, Woonsan
>>
>
>Hi Woonsan,
>
>thanks for your answer. But are you sure about that?
>If I use it like that, I get an "unknown, ambiguous or inaccessible method 
>dataNode" error.
>
>I found the dataNode method in Builtin.java. Its javadoc says:
>
>"Manifests within location attribute of  element, for Commons JEXL and 
>Commons EL based documents."
>
>So what I get from it, is that dataNode can only be used to assign something 
>to a dataNode via .
>
>That is not what I want. I want to pass a dataNode including subElements to 
>some java object via the cond attribute, so I can write a java method which is 
>able to check conditions with use of the passed dataNode.
>
>
>So: is there a way in which I can pass a dataNode to a java object in the 
>context which is used in a cond attribute? Data obviously doesn't work, as I 
>can see in the Builtin code that it always is parsed to Double or String.
>
>best regards, Rinke
>
>
>
>
>
>> On Thursday, October 2, 2014 3:53 AM, R.C. Hoekstra 
>>  wrote:
>
>> > Hi list, Hi people @ scxml commons,
>> >
>> > Can I pass datamodel nodes to a rootContext var, in order to process it in 
>> > java?
>> >
>> > like this:
>> > ,
>> > where:
>> > * agent is an object of a java class made available to the RootContext, 
>> > having a check method returning Boolean. I want this check method to 
>> > evaluate the
>> > datamodelNode, in order to return true or false depending on elements.
>> > * datamodelNodeRef is a reference to some node in the datamodel.
>> >
>> > I managed to pass final nodes as string here, like this:
>> >
>> > > > expr="Data(treatmentData,'treatments/treatment[1]/name')" />,
>> > > >
>> > where the treatments/treatment[1]/name is a final node.
>> >
>> >
>> > However, I would like to pass non final nodes of the datamodel, but 
>> > everything seems to be evaluated as strings first, before it is passed 
>> > into the method of the context
>> > var.
>> >
>> > Hope you can give me a clue.
>> >
>> > And, if these kind of constructions are possible, how would they do in 
>> > terms of performance?
>> >
>> > thanks, Rinke
>
>
>

Re: Re: [scxml] passing datamodel elements into method call

2014-10-08 Thread R.C. Hoekstra
> Hi Rinke,
> I think you would get a node if you used DataNode function instead:
>  expr="DataNode(treatmentData,'treatments/treatment[1]/name')" />
> Could you try that?
>
> Regards, Woonsan
>

Hi Woonsan,

thanks for your answer. But are you sure about that?
If I use it like that, I get an "unknown, ambiguous or inaccessible method 
dataNode" error.

I found the dataNode method in Builtin.java. Its javadoc says:

"Manifests within location attribute of  element, for Commons JEXL and 
Commons EL based documents."

So what I get from it, is that dataNode can only be used to assign something to 
a dataNode via .

That is not what I want. I want to pass a dataNode including subElements to 
some java object via the cond attribute, so I can write a java method which is 
able to check conditions with use of the passed dataNode.


So: is there a way in which I can pass a dataNode to a java object in the 
context which is used in a cond attribute? Data obviously doesn't work, as I 
can see in the Builtin code that it always is parsed to Double or String.

best regards, Rinke





> On Thursday, October 2, 2014 3:53 AM, R.C. Hoekstra 
>  wrote:

> > Hi list, Hi people @ scxml commons,
> >
> > Can I pass datamodel nodes to a rootContext var, in order to process it in 
> > java?
> >
> > like this:
> > ,
> > where:
> > * agent is an object of a java class made available to the RootContext, 
> > having a check method returning Boolean. I want this check method to 
> > evaluate the
> > datamodelNode, in order to return true or false depending on elements.
> > * datamodelNodeRef is a reference to some node in the datamodel.
> >
> > I managed to pass final nodes as string here, like this:
> >
> >  > expr="Data(treatmentData,'treatments/treatment[1]/name')" />,
> >  >
> > where the treatments/treatment[1]/name is a final node.
> >
> >
> > However, I would like to pass non final nodes of the datamodel, but 
> > everything seems to be evaluated as strings first, before it is passed into 
> > the method of the context
> > var.
> >
> > Hope you can give me a clue.
> >
> > And, if these kind of constructions are possible, how would they do in 
> > terms of performance?
> >
> > thanks, Rinke



Re: [scxml] passing datamodel elements into method call

2014-10-06 Thread Woonsan Ko
Hi Rinke,

I think you would get a node if you used DataNode function instead:



Could you try that?

Regards,

Woonsan



On Thursday, October 2, 2014 3:53 AM, R.C. Hoekstra  
wrote:
 

>
>
>Hi list, Hi people @ scxml commons,
>
>Can I pass datamodel nodes to a rootContext var, in order to process it in 
>java?
>
>like this:
>,
>where:
>* agent is an object of a java class made available to the RootContext, having 
>a check method returning Boolean. I want this check method to evaluate the 
>datamodelNode, in order to return true or false depending on elements.
>* datamodelNodeRef is a reference to some node in the datamodel.
>
>I managed to pass final nodes as string here, like this:
>
>expr="Data(treatmentData,'treatments/treatment[1]/name')" />,
>
>where the treatments/treatment[1]/name is a final node.
>
>
>However, I would like to pass non final nodes of the datamodel, but everything 
>seems to be evaluated as strings first, before it is passed into the method of 
>the context var.
>
>Hope you can give me a clue.
>
>And, if these kind of constructions are possible, how would they do in terms 
>of performance?
>
>thanks, Rinke
>
>
>
>

[scxml] passing datamodel elements into method call

2014-10-02 Thread R.C. Hoekstra
Hi list, Hi people @ scxml commons,

Can I pass datamodel nodes to a rootContext var, in order to process it in java?

like this:
,
where:
* agent is an object of a java class made available to the RootContext, having 
a check method returning Boolean. I want this check method to evaluate the 
datamodelNode, in order to return true or false depending on elements.
* datamodelNodeRef is a reference to some node in the datamodel.

I managed to pass final nodes as string here, like this:

,