[midPoint] In template, mapping, return multiple assignments
Oskar Butovič - AMI Praha a.s.
oskar.butovic at ami.cz
Fri Apr 28 09:42:55 CEST 2017
Hello Vincent,
you can do something like this:
<mapping>
<!-- TODO sources -->
<expression>
<script>
<relativityMode>absolute</relativityMode>
<code>
def resultAssignments = [];
//TODO create assignments and put them to resultAssignments
return resultAssignments;
</code>
</script>
</expression>
<target>
<path>assignment</path>
</target>
</mapping>
important is to use <relativityMode>absolute</relativityMode> which tells
mapping to treat all multivalue attributes (assignment is internaly just
multivalue attribute) and return array.
Best Regards
Oskar Butovič
2017-04-27 18:14 GMT+02:00 HURTEVENT VINCENT <
vincent.hurtevent at univ-lyon1.fr>:
> Hello,
>
> We have a ressource for users in database table, a specific column
> contains concatenated organization IDs, separated by commas, like
> "DA,D64,BHU"
>
> We would like, in one single sync, to map multiple assignments between our
> user and organizations.
>
> How could we return multiple assignments ? We know how to do it with one,
> but we can’t figure out to do with multiple.
> We tried to build and return a assignment list, but with the syntax above,
> we get an XML parsing error due to
>
> "List<assignmentType> assignments = new ArrayList<assignmentType>(); »
>
>
> How could we handle this ?
> Is there a better way to map multiple assignment ?
>
> Thank you !
>
>
> <code>
> import
> com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
> import
> com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
> import
> com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
> import
> com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType;
> import
> com.evolveum.midpoint.util.exception.SystemException;
> import
> java.util.*;
>
> if (affectations
> != null)
> {
> List
> liste_affectations = Arrays.asList(affectations.split("\\s*,\\s*"));
>
>
> List<assignmentType> assignments = new ArrayList<assignmentType>();
>
> for
> (String org_name : liste_affectations) {
>
>
> org = midpoint.searchObjectByName(OrgType.class, org_name);
>
>
> log.info("org {}" , org)
>
> orgOrt = new ObjectReferenceType();
>
> orgOrt.setOid(org.getOid());
>
> orgOrt.setType(OrgType.COMPLEX_TYPE);
>
>
> AssignmentType assignment = new AssignmentType();
>
> assignment.asPrismContainerValue()
>
> assignment.setTargetRef(orgOrt);
>
>
> assignments.add(assignment);
> }
>
>
> return assignments;
> }
> </code>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint
>
--
Oskar Butovič
solution architect
gsm: [+420] 774 480 101
e-mail: oskar.butovic at ami.cz
AMI Praha a.s.
Pláničkova 11
162 00 Praha 6
tel.: [+420] 274 783 239
web: www.ami.cz
[image: AMI Praha a.s.]
[image: 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/20170428/d427b3a0/attachment.htm>
More information about the midPoint
mailing list