[midPoint] bulk action task for removing assignment

Pavol Mederly mederly at evolveum.com
Fri Aug 18 19:25:18 CEST 2023


> Thank you, Pavol!!
>
You're welcome :-)

> When I grow up, I want to know midPoint as well as you do (or maybe 
> even half as well)!  :)
>
Certainly you will! :)

BTW, I am very happy to see the community of people like you and your 
colleagues at the universities. I hope this spirit of cooperation will 
endure and will continue to grow.

With best wishes,
Pavol

>
> *From:* midPoint <midpoint-bounces at lists.evolveum.com> *On Behalf Of 
> *Pavol Mederly via midPoint
> *Sent:* Friday, August 18, 2023 9:48 AM
> *To:* midpoint at lists.evolveum.com
> *Cc:* Pavol Mederly <mederly at evolveum.com>
> *Subject:* Re: [midPoint] bulk action task for removing assignment
>
> Hello Paul,
>
> just to propagate new features of midPoint, let me improve your 
> solution a little bit :)
>
> <task 
> xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" 
> <http://midpoint.evolveum.com/xml/ns/public/common/common-3>
>       xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" 
> <http://prism.evolveum.com/xml/ns/public/query-3>
>       
> xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3" 
> <http://midpoint.evolveum.com/xml/ns/public/model/scripting-3>
>       oid="41d8abfc-df45-4d6d-a44a-2fecd84e2813">
>     <name>removing-org-assignments</name>
>     <executionState>runnable</executionState>
>     <activity>
>         <work>
>             <iterativeScripting>
>                 <objects>
>                     <type>UserType</type>
>                     <query> <!-- to process only relevant users -->
>                         <q:filter>
>                             <q:text>assignment/targetRef matches 
> (targetType = OrgType)</q:text>
>                         </q:filter>
>                     </query>
>                 </objects>
>                 <scriptExecutionRequest>
>                     <s:unassign>
>                         <s:filter>
>                             <q:text>targetRef matches (targetType = 
> OrgType)</q:text>
>                         </s:filter>
>                     </s:unassign>
>                 </scriptExecutionRequest>
>             </iterativeScripting>
>         </work>
>     </activity>
> </task>
>
> Note the textual representation of filters, see MidPoint Query 
> Language 
> <https://docs.evolveum.com/midpoint/reference/concepts/query/axiom-query-language/> 
> page. I am not sure about whether this would run on 4.4.x, but 
> definitely this is the future of queries in midPoint. No more 
> q:ref/q:equals troubles...
>
> Also, note the <iterativeScripting> that provides less memory usage 
> (in some cases), multi-node/multithreading ability, reporting, error 
> control, and many many others ...
>
> All the best,
>
> -- 
> Pavol Mederly
> Software developer
> evolveum.com
>
> On 18/08/2023 16:24, Paul Caskey via midPoint wrote:
>
>     I was able to get the user filter to work and you are correct –
>     the task is performing much better now and hasn’t crashed midpoint
>     yet.  Thank you, Pavol!
>
>     For the record, here is the complete <activity> section of the
>     iterative task:
>
>        <activity>
>
>             <work>
>
>     <nonIterativeScripting>
>
>     <scriptExecutionRequest
>     xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3"
>     <http://midpoint.evolveum.com/xml/ns/public/model/scripting-3>>
>
>                         <s:search>
>
>     <s:type>UserType</s:type>
>
>                             <s:query>
>
>     <q:filter>
>
>     <q:ref>
>
>     <q:path>assignment/targetRef</q:path>
>
>     <q:value type="OrgType" />
>
>     </q:ref>
>
>     </q:filter>
>
>     </s:query>
>
>                           <s:unassign>
>
>     <s:filter>
>
>     <q:ref>
>
>     <q:path>targetRef</q:path>
>
>     <q:value xmlns="">
>
>                     <type>OrgType</type>
>
>     </q:value>
>
>     </q:ref>
>
>     </s:filter>
>
>     </s:unassign>
>
>                         </s:search>
>
>     </scriptExecutionRequest>
>
>     </nonIterativeScripting>
>
>             </work>
>
>         </activity>
>
>     *From:* midPoint <midpoint-bounces at lists.evolveum.com>
>     <mailto:midpoint-bounces at lists.evolveum.com> *On Behalf Of *Paul
>     Caskey via midPoint
>     *Sent:* Friday, August 18, 2023 8:18 AM
>     *To:* midPoint General Discussion <midpoint at lists.evolveum.com>
>     <mailto:midpoint at lists.evolveum.com>
>     *Cc:* Paul Caskey <pcaskey at internet2.edu>
>     <mailto:pcaskey at internet2.edu>; Pavol Mederly
>     <mederly at evolveum.com> <mailto:mederly at evolveum.com>
>     *Subject:* Re: [midPoint] bulk action task for removing assignment
>
>     I was not able to get the user filter to work.  Tips or an example
>     would be much appreciated!
>
>     Also, I was running this in an iterative task.  This latest crash
>     happen after only 3 minutes, but I asked the UI to do something
>     and that caused it to crash.
>
>     *From:* midPoint <midpoint-bounces at lists.evolveum.com> *On Behalf
>     Of *Pavol Mederly via midPoint
>     *Sent:* Friday, August 18, 2023 8:15 AM
>     *To:* midpoint at lists.evolveum.com
>     *Cc:* Pavol Mederly <mederly at evolveum.com>
>     *Subject:* Re: [midPoint] bulk action task for removing assignment
>
>     Hello Paul,
>
>     actually I wanted to write you about this, but I didn't want to
>     bother you with details. :)
>
>     You need two filters here:
>
>      1. one to select the users with relevant assignments to be deleted
>      2. second to select relevant assignments from each user found
>
>     The first filter is more or less the one you originally wrote
>     (except for equals vs ref issue).
>
>     The second one is OK in your update.
>
>     Two more comments:
>
>      1. In modern midPoint versions the filters could be written using
>         midPoint query language (aka Axiom).
>      2. The bulk action is best to be run within iterative scripting
>         task; that would prevent heap space problems even if
>         unoptimized (second-query-only) action would be written.
>
>     Hope this helps. :)
>
>     -- 
>
>     Pavol Mederly
>
>     Software developer
>
>     evolveum.com
>
>     On 18/08/2023 15:05, Paul Caskey via midPoint wrote:
>
>         Is there anyway to place limits on the bulk action task below?
>
>         It crashes midpoint completely within about an hour, forcing a
>         hard reboot (version 4.7.1).
>
>         This was the error:
>
>         Couldn't execute script:
>         com.evolveum.midpoint.util.exception.ScriptExecutionException:
>         Couldn't execute action 'unassign' on
>         POV:user:1fb687f6-028e-4758-a877-3a6b932b1097(someone at somedomain.com):
>         Java heap space
>
>         *From:* midPoint <midpoint-bounces at lists.evolveum.com>
>         <mailto:midpoint-bounces at lists.evolveum.com> *On Behalf Of
>         *Paul Caskey via midPoint
>         *Sent:* Thursday, August 17, 2023 2:03 PM
>         *To:* midPoint General Discussion
>         <midpoint at lists.evolveum.com> <mailto:midpoint at lists.evolveum.com>
>         *Cc:* Paul Caskey <pcaskey at internet2.edu>
>         <mailto:pcaskey at internet2.edu>; Pavol Mederly
>         <mederly at evolveum.com> <mailto:mederly at evolveum.com>
>         *Subject:* Re: [midPoint] bulk action task for removing assignment
>
>         Thanks, Pavol!
>
>         For the benefit of the list, here is the bulk action script
>         which will remove all OrgType assignments from all users:
>
>         <s:search
>         xmlns:s=http://midpoint.evolveum.com/xml/ns/public/model/scripting-3
>
>                   xmlns:q=http://prism.evolveum.com/xml/ns/public/query-3>
>
>         <s:type>UserType</s:type>
>
>             <s:unassign>
>
>                 <s:filter>
>
>                     <q:ref>
>
>         <q:path>targetRef</q:path>
>
>                         <q:value type="OrgType"/>
>
>                     </q:ref>
>
>                 </s:filter>
>
>             </s:unassign>
>
>         </s:search>
>
>         *From:* midPoint <midpoint-bounces at lists.evolveum.com> *On
>         Behalf Of *Pavol Mederly via midPoint
>         *Sent:* Thursday, August 17, 2023 1:35 PM
>         *To:* midpoint at lists.evolveum.com
>         *Cc:* Pavol Mederly <mederly at evolveum.com>
>         *Subject:* Re: [midPoint] bulk action task for removing assignment
>
>         Hello Paul,
>
>         this is a quirk from the prehistory of midPoint: references
>         are not filtered using q:equal but using q:ref.
>
>         Furthermore, you may eliminate custom coding by using
>         "unassign" action that provides a filter for assigments to be
>         removed.
>
>         See e.g.
>         https://github.com/Evolveum/midpoint/blob/75e549f2e5ce52ab4b008c18e2e7ba8b2072e151/model/model-intest/src/test/resources/scripting/unassign-captain-from-jack.xml#L18-L26
>         for an example.
>
>         Hope this helps. No guarantees, though. :)
>
>         -- 
>
>         Pavol Mederly
>
>         Software developer
>
>         evolveum.com
>
>         On 17/08/2023 17:03, Paul Caskey via midPoint wrote:
>
>             I am trying to remove all user assignments to OrgType
>             objects in a bulk action task but am having trouble.
>
>             I think I have the filter correct, but I’m having trouble
>             with the script when it tries to examine the type on a
>             given assignment (to prepare it for deletion).
>
>             This is the filter:
>
>             <q:filter>
>
>             <q:equal>
>
>             <q:path>assignment/targetRef</q:path>
>
>             <q:value type="OrgType" />
>
>             </q:equal>
>
>             </q:filter>
>
>             And this is the first part of the script that checks the
>             assignment for a user:
>
>             UserType user = input as UserType
>
>             for (AssignmentType assignment : user.getAssignment()) {
>
>             if (aassignment.targetRef.type == 'OrgType') {
>
>             The error I am getting is:
>
>             class
>             com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl
>             cannot be cast to class
>             com.evolveum.midpoint.prism.PrismPropertyValue
>             (com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl
>             and com.evolveum.midpoint.prism.PrismPropertyValue are in
>             unnamed module of loader
>             org.springframework.boot.loader.LaunchedURLClassLoader
>             @2e0fa5d3)
>
>             Thanks in advance for any help!
>
>             -Paul
>
>             _______________________________________________
>
>             midPoint mailing list
>
>             midPoint at lists.evolveum.com
>
>             https://lists.evolveum.com/mailman/listinfo/midpoint
>
>         _______________________________________________
>
>         midPoint mailing list
>
>         midPoint at lists.evolveum.com
>
>         https://lists.evolveum.com/mailman/listinfo/midpoint
>
>
>
>     _______________________________________________
>
>     midPoint mailing list
>
>     midPoint at lists.evolveum.com
>
>     https://lists.evolveum.com/mailman/listinfo/midpoint
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> https://lists.evolveum.com/mailman/listinfo/midpoint
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20230818/99f57216/attachment-0001.htm>


More information about the midPoint mailing list