[midPoint] Apply a bulk action to a specific object type and subtype

Paul Caskey pcaskey at internet2.edu
Mon Jul 17 02:01:41 CEST 2023


Hi-

I'm working with Keith (the OP) and our use case for this is trying to remove old assignments.  These are assignments on user objects to orgs that have already been deleted.

The code below selects exactly the assignments I need to remove, but I can't figure out how to remove or unassign the assignments.

Does anyone know how to remove/unassign an assignment inside a bulk action of type 'execute-script'?

Here's what selects the assignments I need to delete:

<s:executeScript xmlns:s=http://midpoint.evolveum.com/xml/ns/public/model/scripting-3 xmlns:c=http://midpoint.evolveum.com/xml/ns/public/common/common-3 xmlns:icfs=http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3 xmlns:org=http://midpoint.evolveum.com/xml/ns/public/common/org-3 xmlns:q=http://prism.evolveum.com/xml/ns/public/query-3 xmlns:ri=http://midpoint.evolveum.com/xml/ns/public/resource/instance-3 xmlns:t=http://prism.evolveum.com/xml/ns/public/types-3 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance>
    <s:search>
        <s:type>c:UserType</s:type>
        <s:query>
            <q:filter>
                <q:equal>
                    <q:path>assignment/subtype</q:path>
                    <q:value>test-assignment</q:value>
                </q:equal>
            </q:filter>
        </s:query>
        <s:action>
            <s:type>execute-script</s:type>
            <s:parameter>
                <s:name>script</s:name>
                <s:value>
                    <code xmlns=http://midpoint.evolveum.com/xml/ns/public/common/common-3>
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.model.api.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;

for (a in input.assignment) {
  if (a.subtype[0] == "test-assignment") {
    OrgType org = midpoint.resolveReferenceIfExists(a.targetRef);
    log.info ("Found test-assignment to Org: {}", org.oid)

    //need to delete/unassign this assignment (a)

  }
}
</code>
                </s:value>
            </s:parameter>
        </s:action>
    </s:search>
</s:executeScript>



Thanks in advance for any help and insight!
-Paul


From: midPoint <midpoint-bounces at lists.evolveum.com> On Behalf Of Paul Caskey via midPoint
Sent: Thursday, July 13, 2023 5:32 PM
To: martin.spanik at evolveum.com; midPoint General Discussion <midpoint at lists.evolveum.com>
Cc: Paul Caskey <pcaskey at internet2.edu>
Subject: Re: [midPoint] Apply a bulk action to a specific object type and subtype

Thanks, Martin!

In our case, it's the assignment itself that has the subtype, not the role (or org).

Like this (taken from a user object):
    <assignment>
        <subtype>groupRole</subtype>
        <targetRef oid="c0053265-dd8f-496f-92bc-72209ee61eb4" relation="org:default" type="c:OrgType"/>
        <activation>
            <effectiveStatus>enabled</effectiveStatus>
        </activation>
    </assignment>

It seems like a bulk action should be able to do it. But I can't figure it out yet.  :)

Thanks again!
-Paul

From: midPoint <midpoint-bounces at lists.evolveum.com<mailto:midpoint-bounces at lists.evolveum.com>> On Behalf Of Martin Spanik via midPoint
Sent: Thursday, July 13, 2023 3:18 AM
To: 'midPoint General Discussion' <midpoint at lists.evolveum.com<mailto:midpoint at lists.evolveum.com>>
Cc: Martin Spanik <martin.spanik at evolveum.com<mailto:martin.spanik at evolveum.com>>
Subject: Re: [midPoint] Apply a bulk action to a specific object type and subtype

Hello Keith

Yes it is possible. I prepared example of such task - you can use and tune it.
It's tested on 4.7 and 4.4. I don't know which version you are using.

Let's assume that your groups are represented by roles in midPoint and you have set of roles having attribute subtype with value 'groupRole'. The role has 'Internal' service assigned. You want to modify these roles.
Example of the role is attached too.

Let's get to the task:

You filter the objects in <objects> element of task/activity/work/iteractiveScripting.

<objects>
    <type>RoleType</type>
    <query>
        <q:filter>
            <q:text>subtype = 'groupRole'</q:text>
        </q:filter>
    </query>
</objects>

Then you just run action on this set of objects.  This action applies defined modification delta on the objects you selected in the filter.

The example task removes the assigned service. Commented part modifies just description attribute - just as an example.

I hope it will help you.

Best regards,

Martin Spanik
Senior Identity Engineer

+421 905 334 507
martin.spanik at evolveum.com<mailto:martin.spanik at evolveum.com>
https://evolveum.com<https://www.evolveum.com/>


From: midPoint [mailto:midpoint-bounces at lists.evolveum.com] On Behalf Of Keith Hazelton via midPoint
Sent: streda 12. júla 2023 22:01
To: midpoint at lists.evolveum.com<mailto:midpoint at lists.evolveum.com>
Cc: Keith Hazelton <hazelton at internet2.edu<mailto:hazelton at internet2.edu>>
Subject: [midPoint] Apply a bulk action to a specific object type and subtype

Is it possible to use a filter to perform a bulk action on a specific object type and subtype?

I know pt can be done, for example, for user subtypes, but we want to remove assignments for a specific subtype of group.

        Thanks in advance,   --Keith Hazelton


_________________________
hazelton at internet2.edu<mailto:hazelton at internet2.edu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20230717/38bb4bc5/attachment-0001.htm>


More information about the midPoint mailing list