[midPoint] Scripting Hook | delete attribute values after changing organization
Marco Benucci
m.benucci at nsr.it
Fri Oct 27 15:57:19 CEST 2017
Hi,
I had some scratches since my customAttribute is a multivalued one. By
the way, I have succesfully made this using the following code:
import com.evolveum.midpoint.prism.delta.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.prism.path.ItemPath;
import javax.xml.namespace.QName;
import com.evolveum.midpoint.prism.PrismConstants;
UserType user = (UserType) focus;
def attributeName = "documentalVisibility"
def NameSpace = "http://my.custom.namespace/xml/ns/mise";
def attributeQName = new QName(NS, attr_name)
def attributeItemPath = new
ItemPath(PrismConstants.EXTENSION_LOCAL_NAME, attr_QNAME);
def attributeValues = basic.getExtensionPropertyValues(user, NameSpace,
attributeName).toArray();
def mod = ObjectDelta.createModificationDeleteProperty(UserType.class,
user.getOid(), attributeItemPath, prismContext, attributeValues);
modelContext.getFocusContext().addPrimaryDelta(mod)
modelContext.rot();
Thank you Arnost,
Marco
On 10/26/2017 07:46 PM, Arnošt Starosta - AMI Praha a.s. wrote:
> You can use an ItemPath like this
>
> new ItemPath(PrismConstants.EXTENSION_LOCAL_NAME, new
> QName('http://your extension namespace', attributeName))
>
> If you added your extension attribute in the example xsd provided with
> the overlay project and didn't change the namespace, the default
> namespace is 'http://example.com/xml/ns/midpoint/schema/extension-3'.
>
> arnost
>
> 2017-10-26 18:31 GMT+02:00 Marco Benucci <m.benucci at nsr.it
> <mailto:m.benucci at nsr.it>>:
>
> Thank you for your reply.
>
> I'm doing this right now!
>
> How can I add the modificationDeleteProperty of a customAttribute?
> I'm having troubles with it ItemPath and QNames...
>
>
>
> Il 26 ott 2017 6:21 PM, Arnošt Starosta - AMI Praha a.s.
> <arnost.starosta at ami.cz <mailto:arnost.starosta at ami.cz>> ha scritto:
>
> Hi Marco,
>
> i sometimes inject changes in the primary delta. is that a
> good practice? don't know, but it works
>
> mod = ObjectDelta.createModificationDeleteProperty(...)
> primary.swallow(mod)
>
> ?
>
> if this does not work, try to tell midpoint to recompute the
> context with
>
> modelContext.rot()
>
> hope this helps
>
> arnost
>
> 2017-10-26 15:42 GMT+02:00 Marco Benucci <m.benucci at nsr.it
> <mailto:m.benucci at nsr.it>>:
>
> Hi,
>
> we are running midPoint 3.6 and we'd like to remove the
> value of a multi-valued extion-attribute named
> "documentalVisibility" when another extension-attribute
> (named primaryOrganization) is changed.
>
> I thought that we could use
> https://wiki.evolveum.com/display/midPoint/Scripting+Hooks
> <https://wiki.evolveum.com/display/midPoint/Scripting+Hooks>.
>
> We can check if the attribute primaryOrganization is
> changed looking in
> modelContext.getPrimaryChanges(),
> but we cannot recreate a delete delta that can be used in the
> modelContext.getFocusContext().swallowToSecondaryDelta()...
>
> Can you help me?
>
> Thank you,
> Marco
>
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> <mailto:midPoint at lists.evolveum.com>
> http://lists.evolveum.com/mailman/listinfo/midpoint
> <http://lists.evolveum.com/mailman/listinfo/midpoint>
>
>
>
>
> --
>
> Arnošt Starosta
> solution architect
>
> gsm: [+420] 603 794 932 <tel:+420%20603%20794%20932>
> e-mail: arnost.starosta at ami.cz <mailto:arnost.starosta at ami.cz>
>
>
>
> AMI Praha a.s.
> Pláničkova 11
> 162 00 Praha 6
> tel.: [+420] 274 783 239 <tel:+420%20274%20783%20239>
> web: www.ami.cz <http://www.ami.cz/>
>
>
>
> AMI Praha a.s.
>
>
> AMI Praha a.s.
> <http://www.ami.cz/reseni-a-sluzby/bezpecnost-dat/identity-management>
>
>
> Textem tohoto e-mailu podepisující neslibuje uzavřít ani
> neuzavírá za společnost AMI Praha a.s.
> jakoukoliv smlouvu. Každá smlouva, pokud bude uzavřena, musí
> mít výhradně písemnou formu.
>
>
>
>
> --
>
> Arnošt Starosta
> solution architect
>
> gsm: [+420] 603 794 932
> e-mail: arnost.starosta at ami.cz <mailto:arnost.starosta at ami.cz>
>
>
>
> AMI Praha a.s.
> Pláničkova 11
> 162 00 Praha 6
> tel.: [+420] 274 783 239
> web: www.ami.cz <http://www.ami.cz/>
>
>
>
> AMI Praha a.s.
>
>
> AMI Praha a.s.
> <http://www.ami.cz/reseni-a-sluzby/bezpecnost-dat/identity-management>
>
> Textem tohoto e-mailu podepisující neslibuje uzavřít ani neuzavírá za
> společnost AMI Praha a.s.
> jakoukoliv smlouvu. Každá smlouva, pokud bude uzavřena, musí mít
> výhradně písemnou formu.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20171027/7f5e0ff6/attachment.htm>
More information about the midPoint
mailing list