problem with deletePartyRole

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

problem with deletePartyRole

ryan-116
I'm trying to invoke deletePartyRole (simple method defined in
PartyServices.xml) to remove roles from a Party:

            roles =
delegator.findListIteratorByCondition("RoleTypeAndParty",
                        new EntityExpr("roleTypeId",
EntityOperator.LIKE, "ACCT_TYPE%"),
                    UtilMisc.toList("roleTypeId"),
                    null);

            if (roles == null) {
                roles.close();
            } else {
                GenericValue nextRole;
                while ((nextRole = (GenericValue) roles.next()) != null) {
                    String roleTypeId = (String) nextRole.get("roleTypeId");
                    if (roleTypeId != null) {
                        // delete this role
                        dispatcher.runSync("deletePartyRole",
UtilMisc.toMap("login.username", userLoginId, "login.password",
currentPassword, "roleTypeId",roleTypeId));
                    }
                }
                roles.close();
            }

On the first pass through, one role is matched by the EntityListIterator
and roleTypeId is set correctly to the roleTypeId of a role belonging to
that Party, and passed into "deletePartyRole".

"deletePartyRole" comes back with "Error in simple-method [Delete a  
PartyRole
[file:/Users/ryan/svn/website/trunk/ofbiz/applications/party/script/org/ofbiz/party/party/PartyServices.xml#deletePartyRole]]:
In remove-value a value was not found with the specified valueAcsr:
partyRole, not removing"

which is because in RemoveValue.java, line 49,
     GenericValue value = (GenericValue) valueAcsr.get(methodContext);
is returning null.

What I can't work out is why?

any thoughts?

regards,
-Ryan
Reply | Threaded
Open this post in threaded view
|

Re: problem with deletePartyRole

ryan-116
I also tried changing the query to the more correct
            EntityConditionList query = new
EntityConditionList(UtilMisc.toList(
                    new EntityExpr("roleTypeId", EntityOperator.LIKE,
"ACCT_TYPE%"),
                    new EntityExpr("partyId", EntityOperator.LIKE,
partyId)), EntityOperator.AND);
            roles = delegator.findListIteratorByCondition("PartyRole",
                    query,
                    UtilMisc.toList("roleTypeId"),
                    null);

            if (roles == null) {
                roles.close();
            } else {
                GenericValue nextRole;
                while ((nextRole = (GenericValue) roles.next()) != null) {
                    String roleTypeId = (String) nextRole.get("roleTypeId");
                    if (roleTypeId != null) {
                        // delte this role
                        dispatcher.runSync("deletePartyRole",
UtilMisc.toMap("login.username", userLoginId, "login.password",
currentPassword, "roleTypeId",roleTypeId));
                    }
                }
                roles.close();
            }

but that yields the same problem.


Ryan Sweet wrote:

> I'm trying to invoke deletePartyRole (simple method defined in
> PartyServices.xml) to remove roles from a Party:
>
>            roles =
> delegator.findListIteratorByCondition("RoleTypeAndParty",
>                        new EntityExpr("roleTypeId",
> EntityOperator.LIKE, "ACCT_TYPE%"),
>                    UtilMisc.toList("roleTypeId"),
>                    null);
>
>            if (roles == null) {
>                roles.close();
>            } else {
>                GenericValue nextRole;
>                while ((nextRole = (GenericValue) roles.next()) != null) {
>                    String roleTypeId = (String)
> nextRole.get("roleTypeId");
>                    if (roleTypeId != null) {
>                        // delete this role
>                        dispatcher.runSync("deletePartyRole",
> UtilMisc.toMap("login.username", userLoginId, "login.password",
> currentPassword, "roleTypeId",roleTypeId));
>                    }
>                }
>                roles.close();
>            }
>
> On the first pass through, one role is matched by the
> EntityListIterator and roleTypeId is set correctly to the roleTypeId
> of a role belonging to that Party, and passed into "deletePartyRole".
>
> "deletePartyRole" comes back with "Error in simple-method [Delete a  
> PartyRole
> [file:/Users/ryan/svn/website/trunk/ofbiz/applications/party/script/org/ofbiz/party/party/PartyServices.xml#deletePartyRole]]:
> In remove-value a value was not found with the specified valueAcsr:
> partyRole, not removing"
>
> which is because in RemoveValue.java, line 49,
>     GenericValue value = (GenericValue) valueAcsr.get(methodContext);
> is returning null.
>
> What I can't work out is why?
>
> any thoughts?
>
> regards,
> -Ryan