[midPoint] In template, mapping, return multiple assignments

HURTEVENT VINCENT vincent.hurtevent at univ-lyon1.fr
Thu Apr 27 18:14:15 CEST 2017


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>


More information about the midPoint mailing list