Simple Method out parameter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Simple Method out parameter

madppiper-2
Hey,

I am trying to do the following: I want to list all Products that are currently indexed by the Entity-Engine, then return their values as a list to a service, so that i can parse them to a different service afterwards. I did that as a following

1. I created a simple-method, which is supposed to look-up all indexed products on the entity engine and return them as a list:

        <simple-method method-name="listProducts"
                short-description="list all Products" >
                <entity-condition entity-name="Product" list-name="productList" >
        </simple-method>

2. I added a corresponding service:

    <service name="listProducts" default-entity-name="SolrIndex" engine="simple"
            location="../SimpleMethodServices.xml" invoke="listProducts" auth="true">
        <description>listAll</description>
       
       
   <attribute name="productList" type="List" mode="OUT" optional="true"/>
   
   </service>


3. However, once run, I will only retrieve the success message, not the actual OUT parameter (which I was hoping would be the List containing the relevant data).

Could anybody help me point out my mistake?

Thx a bunch!
Reply | Threaded
Open this post in threaded view
|

Re: Simple Method out parameter

BJ Freeman
                <entity-condition entity-name="Product" list-name="productList" >

productList is a map of all the products.
the service you pass this to must processes that map.


madppiper sent the following on 9/30/2008 11:13 AM:

> Hey,
>
> I am trying to do the following: I want to list all Products that are
> currently indexed by the Entity-Engine, then return their values as a list
> to a service, so that i can parse them to a different service afterwards. I
> did that as a following
>
> 1. I created a simple-method, which is supposed to look-up all indexed
> products on the entity engine and return them as a list:
>
> <simple-method method-name="listProducts"
> short-description="list all Products" >
> <entity-condition entity-name="Product" list-name="productList" >
> </simple-method>
>
> 2. I added a corresponding service:
>
>     <service name="listProducts" default-entity-name="SolrIndex"
> engine="simple"
>             location="../SimpleMethodServices.xml" invoke="listProducts"
> auth="true">
>         <description>listAll</description>
>        
>        
>    <attribute name="productList" type="List" mode="OUT" optional="true"/>
>    
>    </service>
>
>
> 3. However, once run, I will only retrieve the success message, not the
> actual OUT parameter (which I was hoping would be the List containing the
> relevant data).
>
> Could anybody help me point out my mistake?
>
> Thx a bunch!

Reply | Threaded
Open this post in threaded view
|

Re: Simple Method out parameter

ian tabangay
In reply to this post by madppiper-2
You forgot one line in your service.

<simple-method method-name="listProducts" short-description="list all
Products" >
    <entity-condition entity-name="Product" list-name="productList" >
<!-- this line will return the productList from this service -->
    <field-to-result field-name="productList"/>
</simple-method>

Ian

On Wed, Oct 1, 2008 at 2:13 AM, madppiper <[hidden email]> wrote:

>
> Hey,
>
> I am trying to do the following: I want to list all Products that are
> currently indexed by the Entity-Engine, then return their values as a list
> to a service, so that i can parse them to a different service afterwards. I
> did that as a following
>
> 1. I created a simple-method, which is supposed to look-up all indexed
> products on the entity engine and return them as a list:
>
>        <simple-method method-name="listProducts"
>                short-description="list all Products" >
>                <entity-condition entity-name="Product"
> list-name="productList" >
>        </simple-method>
>
> 2. I added a corresponding service:
>
>    <service name="listProducts" default-entity-name="SolrIndex"
> engine="simple"
>            location="../SimpleMethodServices.xml" invoke="listProducts"
> auth="true">
>        <description>listAll</description>
>
>
>   <attribute name="productList" type="List" mode="OUT" optional="true"/>
>
>   </service>
>
>
> 3. However, once run, I will only retrieve the success message, not the
> actual OUT parameter (which I was hoping would be the List containing the
> relevant data).
>
> Could anybody help me point out my mistake?
>
> Thx a bunch!
> --
> View this message in context:
> http://www.nabble.com/Simple-Method-out-parameter-tp19747551p19747551.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Simple Method out parameter

madppiper-2
This post was updated on .
In reply to this post by madppiper-2
Alright, thanks a bunch! That was absolutely it...



As a follow up question: how do I iterate through a list? Ultimately my goal is to iterate through the fields and parse each row as parameters to a different service.

I tried using the <iterate> method, but am somehow stuck in between. The following should output each Product (database row), correct?

        <iterate entry-name="Product" list-name="productList">
                <log level="warning" message="${Product}"></log>       
        </iterate>



Update:

My question aims exactly what this guy wanted to accomplish:
http://www.nabble.com/convert-list-of-Generic-value-to-Map-td16021464.html#a16023838


Update 2:

It was much simpler to work with the Entity directly, so I ditched the original idea of accessing the entity through a service and voila - it works ;)