Hey Jonathon,
while I'm sure there are other uses of iterate-map, it's generally used
when your keys have become variables themselves. Like if you wanted to
group certain data by partyId and you were iterating through several
different lists: ie

Iterate through List of Invoices
<iterate entry-name="invoice" list-name="invoices">
<field-to-list field-name="invoice"
list-name="myMap.${invoice.partyId}.invoices"/>
</iterate>
Then iterate through List of orders
<iterate entry-name="order" list-name="orders">
<field-to-list field-name="order"
list-name="myMap.${order.partyId}.orders"/>
</iterate>
Then iterate through list of payments
<iterate entry-name="payment" list-name="payments">
<field-to-list field-name="payment"
list-name="myMap.${payment.partyId}.payments"/>
</iterate>

This will result in the following 
myMap.100.invoices
myMap.100.orders
myMap.100.payments
myMap.101.invoices
myMap.101.orders
myMap.101.payments
myMap.102.invoices
myMap.102.orders
myMap.102.payments
myMap.103.invoices
myMap.103.orders
myMap.103.payments

So, now if you iterate-map through myMap
<iterate-map map-name="myMap" key-name="key" value-name="value">
 <set field="result.partyId" from-field="key"/>
 <set field="result.invoices" from-field="value.invoices"/>
 <set field="result.orders" from-field="value.orders"/>
 <set field="result.payments" from-field="value.payments"/>
 <field-to-list field-name="result" list-name="resultList"/>
<clear-field field-name="result"/>
<clear-field field-name="key"/>
<clear-field field-name="value"/>
</iterate-map>



I'm not sure exactly what you're trying to do because what you put will
always return the same result unless your map named "parameter"
contains only 2 or less keys and one equals mySpecialCase1 and the
other equals mySpecialCase2, that's likely not what you're trying to
do.  If you could describe the real case instead of a hypothetical
case, it might be easier to offer assistance.



--- Jonathon -- Improov <[EMAIL PROTECTED]> wrote:

> Chri,s
> 
> Ok, here goes.
> 
> I've deleted my <iterate-map> chunk, so the below is roughly from
> memory, untested.
> 
> <iterate-map map-name="parameters" key-name="paramKey"
> value-name="paramValue">
>   <if>
>    <condition>
>     <and>
>      <if-compare field-name="paramKey" operator="not-equals"
> value="mySpecialCase1"/>
>      <if-compare field-name="paramKey" operator="not-equals"
> value="mySpecialCase2"/>
>     </and>
>    <then>
>     <!-- This somehow gives me all Strings in myOwnMap. -->
>     <set from-field="parameters.${paramKey}"
> field="myOwnMap.${paramKey}"/>
>     <!-- This somehow retains the correct data types in myCorrectMap.
> -->
>     <field-to-field map-name="parameters" field-name="${paramKey}"
> to-map-name="myCorrectMap"/>
>    </then>
> </iterate-map>
> 
> Here's what I really want audited. I'm trying to "extend" an existing
> service. I change the 
> controller.xml to point to my "super service", which in turn calls
> the original service and also 
> performs its own stuff. Pattern correct? I'm trying to achieve
> maximum separation of my 
> customizations from core OFBiz.
> 
> <simple-method method-name="myown.updateWorkEffort"
>    short-description="Update Work Effort and then Work Instruction">
>      <set-service-fields map-name="parameters"
> service-name="updateWorkEffort" 
> to-map-name="updateWorkEffortParams"/>
>      <call-service service-name="updateWorkEffort"
> in-map-name="updateWorkEffortParams">
>          <default-message>Work Effort successfully
> updated.</default-message>
>      </call-service>
>      <check-errors/>
> 
>      <!-- Do my own stuff here. Like updating entity NoteData, for
> eg. -->
> </simple-method>
> 
> Jonathon
> 
> Chris Howe wrote:
> > I'm sorry, again I'm not reading everything first.  You weren't
> asking
> > how to do it, just if we should add the element.
> > 
> > I would say that it's not generally needed as it's not a difficult
> > operation, but I'm sure if someone went through the trouble of
> adding
> > the logic, it would get added.
> > 
> > 
> > --- Chris Howe <[EMAIL PROTECTED]> wrote:
> > 
> >> Yes, that snippet, I want to verify that you're using it
> correctly.
> >>
> >> Moving target:
> >> to do a create or store you'll need to do an entity-one or
> >> find-by-primary key and if it returns empty then create, otherwise
> >> update the parameters and store
> >>
> >> --- Jonathon -- Improov <[EMAIL PROTECTED]> wrote:
> >>
> >>> Chris,
> >>>
> >>>  > Send the code snippet that you're working on and I'll tweak
> it.
> >>>
> >>> Which snippet? You mean the <iterate-map> thing? Just create any
> >> map
> >>> with types other than String, 
> >>> then try to use <set> within <iterate-map> to copy fields to a
> new
> >>> map.
> >>>
> >>> Sorry another question! Sorry for moving target.
> >>>
> >>> I noticed there's no usage of delegator.createOrStore() in
> >> Minilang.
> >>> Is the true? Should we add 
> >>> something like <create-or-store-value>?
> >>>
> >>> Jonathon
> >>>
> >>> Chris Howe wrote:
> >>>> Send the code snippet that you're working on and I'll tweak it.
> >>>>
> >>>> --- Jonathon -- Improov <[EMAIL PROTECTED]> wrote:
> >>>>
> >>>>> Chris,
> >>>>>
> >>>>> Never mind the conjecture. Your recommendation works! Thanks!
> >> And
> >>> the
> >>>>> title is possibly 
> >>>>> irrelevant, since I can't find any reason now to change
> >>> <clear-field>
> >>>>> after reading your 
> >>>>> recommendation.
> >>>>>
> >>>>> A question here about <iterate-map>, small digression. You can
> >>> ignore
> >>>>> it and ask for a new thread 
> >>>>> if you want.
> >>>>>
> >>>>> I was doing it via <iterate-map>, <if>, <field-to-field>, so
> >> that
> >>> I
> >>>>> could simply copy over from 
> >>>>> map "parameters" those fields that are not in my own service.
> >>>>>
> >>>>> Using <set> instead of <field-to-field> doesn't work, because I
> >>>>> couldn't get the fields' types 
> >>>>> (String, Double, etc) from <iterate-map>.
> >>>>>
> >>>>> There's a warning about <field-to-field> being deprecated. Is
> >>> there a
> >>>>> need to enhance 
> >>>>> <iterate-map> to include "field type" in it's results?
> >>>>>
> >>>>> Jonathon
> >>>>>
> >>>>> Chris Howe wrote:
> >>>>>> sorry about the conjecture on screens/java...didn't read the
> >>> title
> >>>>> :-)
> >>>>>> --- Chris Howe <[EMAIL PROTECTED]> wrote:
> >>>>>>
> >>>>>>> I'm not quite sure I'm following you as to which has the
> extra
> >>>>>>> fields,
> >>>>>>> your input map or the interface.
> >>>>>>>
> >>>>>>> I'm thinking your input map has the extra fields otherwise
> the
> >>>>> extra
> >>>>>>> fields in the interface would be optional, or you would
> likely
> >>> end
> >>>>> up
> >>>>>>> with inconsistent result from the interface.
> >>>>>>>
> >>>>>>> So, assuming it's your input map and you would only be coming
> >>>>> across
> >>>>>>> this situation in simple-method because the screens->service
> >>> picks
> >>>>>>> the
> >>>>>>> fields from context and java->service has you specify the map
> >>>>>>> specifically.
> >>>>>>>
> >>>>>>>
> >>>>>>> So, if you're running this from simple-methods...you're
> >>> solution,
> >>>>> I
> >>>>>>> believe, is the following
> >>>>>>>
> >>>>>>> <set-service-fields map-name="myInputMap"
> >>> service-name="myService"
> >>>>>>> to-map-name="inputMap"/>
> >>>>>>> <call-service service-name="myService"
> >> in-map-name="inputMap"/>
> >>>>>>> Does that help?
> >>>>>>>
> >>>>>>> --- Jonathon -- Improov <[EMAIL PROTECTED]> wrote:
> >>>>>>>
> >>>>>>>> I can't find any usage of
> >> ContextAccessor.remove(MethodContext)
> >>>>> in
> >>>>>>>> Minilang's source codes at 
> >>>>>>>> src/org/ofbiz/minilang/method/envops .
> >>>>>>>>
> >>>>>>>> Shall I add an option to <clear-field> that will trigger a
> >>>>>>>> ContextAccessor.remove() rather than a 
> >>>>>>>> ContextAccessor.put() that merely replaces a field with
> null?
> >>>>>>>>
> >>>>>>>> I'm doing a custom service that <implements> an existing
> >>> service
> >>>>> in
> >>>>>>>> OFBiz, and I need to trim away 
> >>>>>>>> the extra input fields before putting them to the existing
> >>>>> service.
> >>>>>>>> Jonathon
> >>>>>>>>
> >>>
> >>
> > 
> 
=== message truncated ===

Reply via email to