Hi Weixue,
I also have noticed that such feature would be really handy. Recently
I had a problem with group services. I wanted to create group service
that consists of two existing ofbiz services, but the second one was
expecting a parameter with different name than the first one was
passing as out parameter.
Actually I resolved the problem by implementing third service that was
just renaming the parameter, but this was just a trick.
Actually for solving your problem you can try similar thing - to use
ensurePartyRole service for partyId and roleTypeIdTo and then to
create small wrapper service(something like ensureFromPartyRole) that
will just change parameter names and then will call ensurePartyRole
service.
It will be good to have an functionality that renames out parameters
or looks for parameter with different name in such specific
situations(secas, group services, ecas).
Something like:
<eca service="createPartyRelationship" event="invoke">
<action service="ensurePartyRoleTo" mode="sync">
<field-map attribute="partyId" from-field="partyIdFrom"/>
<field-map attribute="roleTypeId" from-field="roleTypeIdFrom"/>
</action>
</eca>
Regards,
Rashko Rejmer
On 20 Oct 2009, at 15:08, Weixue Zhang wrote:
I want to implement below business logic which is a little different
from
current partymgr implementation:
1.Setup below relationship between two parties:
partyIdFrom: party1
partyIdTo: party2
roleTypeIdFrom: EMPLOYEE
roleTypeIdTo: ORGANIZATION_ROLE
2. before doing above, the system need to AUTOMATICALLY set EMPLOYEE
role to
party1 and ORGANIZATION_ROLE to party2 if they are not set.
I attempted to set createPartyRole service as an action of
createPartyRelationship service in seca, but it doesn't work because
there
are no parameters partyId and roleTypeId for createPartyRole services.
Above business logic is just for an example, actually I have met
many other
similar cases in development. When writing services, we are not quite
certain which services will be chained through SECA later, and it's
hard to
make possible chained services have same parameter names (e.g. one
service
needs a parameter named partyId, other services may need the same
parameter
but named partyIdFrom). So I think a mechanism that can set
parameters again
before calling will provide more flexibility and improve reuse of
existing
services.
Could someone tell me if such mechanism exists in Ofbiz or how I can
resolve
above problem?
Many thanks,
-Weixue.