Jacopo,
> 1) define a service eca (event-condition-action), there are many
> examples of ecas in the servicedef/secas.xml files of many components)
> attached to the updateWorkEffort service, to run your custom service
> after it
I tried this. But I had to modify the service input params for the original
service updateWorkEffort.
The reason is because the input params for my custom service is a larger superset of that for
updateWorkEffort.
> 2) in the controller, create a chain of requests (where the first one
> calls the updateWorkEffort, then the control is passed to a second one
> that calls your custom service)
This could be the best way I can see so far. Thanks!
Oh wait. What about database transactional integrity? Say the 1st service succeeds, and the 2nd
one fails, I would want the first one rolled back.
Jonathon
Jacopo Cappellato wrote:
It really depends on the specificity of what you are doing but, in
general, there are probably simpler ways of doing this, such as:
1) define a service eca (event-condition-action), there are many
examples of ecas in the servicedef/secas.xml files of many components)
attached to the updateWorkEffort service, to run your custom service
after it
2) in the controller, create a chain of requests (where the first one
calls the updateWorkEffort, then the control is passed to a second one
that calls your custom service)
etc...
Jacopo
Jonathon -- Improov 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