[midPoint] In template, mapping, return multiple assignments

HURTEVENT VINCENT vincent.hurtevent at univ-lyon1.fr
Fri Apr 28 10:17:26 CEST 2017


Hello Oskar !

Thank you so much, it’s working great !


Le 28 avr. 2017 à 09:42, Oskar Butovič - AMI Praha a.s. <oskar.butovic at ami.cz<mailto:oskar.butovic at ami.cz>> a écrit :

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<mailto: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<http://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<mailto: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<mailto: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<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.


_______________________________________________
midPoint mailing list
midPoint at lists.evolveum.com<mailto:midPoint at lists.evolveum.com>
http://lists.evolveum.com/mailman/listinfo/midpoint

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170428/4dbf6f98/attachment.htm>


More information about the midPoint mailing list