<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1905874838;
        mso-list-type:hybrid;
        mso-list-template-ids:-681262894 -1474414958 201916441 201916443 201916431 201916441 201916443 201916431 201916441 201916443;}
@list l0:level1
        {mso-level-text:"%1\.\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-AU" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I have a database resource that gives me the following organisation info in its columns:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="mso-list:Ignore">1.)<span style="font:7.0pt "Times New Roman"">   
</span></span><![endif]>An ID (an integer)<o:p></o:p></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="mso-list:Ignore">2.)<span style="font:7.0pt "Times New Roman"">   
</span></span><![endif]>A Name (a string)<o:p></o:p></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="mso-list:Ignore">3.)<span style="font:7.0pt "Times New Roman"">   
</span></span><![endif]>The ID of the parent organisation in a column called parent_id (an integer). This value is present for all organisations except for the top parent one.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This resource can be considered the definitive authority for this data (i.e. it’s not present in LDAP).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I currently have a schemaHandling like so:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><schemaHandling><o:p></o:p></p>
<p class="MsoNormal">      <objectType><o:p></o:p></p>
<p class="MsoNormal">         <kind>account</kind><o:p></o:p></p>
<p class="MsoNormal">         <intent>HRM</intent><o:p></o:p></p>
<p class="MsoNormal">         <default>true</default><o:p></o:p></p>
<p class="MsoNormal">         <objectClass>ri:AccountObjectClass</objectClass><o:p></o:p></p>
<p class="MsoNormal">         <attribute><o:p></o:p></p>
<p class="MsoNormal">            <c:ref>icfs:uid</c:ref><o:p></o:p></p>
<p class="MsoNormal">            <tolerant>true</tolerant><o:p></o:p></p>
<p class="MsoNormal">            <exclusiveStrong>false</exclusiveStrong><o:p></o:p></p>
<p class="MsoNormal">            <inbound><o:p></o:p></p>
<p class="MsoNormal">               <authoritative>true</authoritative><o:p></o:p></p>
<p class="MsoNormal">               <exclusive>false</exclusive><o:p></o:p></p>
<p class="MsoNormal">               <strength>normal</strength><o:p></o:p></p>
<p class="MsoNormal">               <target><o:p></o:p></p>
<p class="MsoNormal">                  <c:path>identifier</c:path><o:p></o:p></p>
<p class="MsoNormal">               </target><o:p></o:p></p>
<p class="MsoNormal">            </inbound><o:p></o:p></p>
<p class="MsoNormal">         </attribute><o:p></o:p></p>
<p class="MsoNormal">         <attribute><o:p></o:p></p>
<p class="MsoNormal">            <c:ref>ri:name</c:ref><o:p></o:p></p>
<p class="MsoNormal">            <tolerant>true</tolerant><o:p></o:p></p>
<p class="MsoNormal">            <exclusiveStrong>false</exclusiveStrong><o:p></o:p></p>
<p class="MsoNormal">            <inbound><o:p></o:p></p>
<p class="MsoNormal">               <authoritative>true</authoritative><o:p></o:p></p>
<p class="MsoNormal">               <exclusive>false</exclusive><o:p></o:p></p>
<p class="MsoNormal">               <strength>normal</strength><o:p></o:p></p>
<p class="MsoNormal">               <target><o:p></o:p></p>
<p class="MsoNormal">                  <c:path>name</c:path><o:p></o:p></p>
<p class="MsoNormal">               </target><o:p></o:p></p>
<p class="MsoNormal">            </inbound><o:p></o:p></p>
<p class="MsoNormal">         </attribute><o:p></o:p></p>
<p class="MsoNormal">      </objectType><o:p></o:p></p>
<p class="MsoNormal">   </schemaHandling><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The current behaviour when I sync from this resource is all the Organisations are being created with the correct name and unique ID that is copied to the OrgType “Identifier” field, but they are all at the same (top) level in the Org. structure.<o:p></o:p></p>
<p class="MsoNormal">I now want to put them into their proper hierarchy!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">My understanding is that an org-to-org relationship shouldn’t be an assignment, but a population of the parentOrgRef (see
<a href="https://wiki.evolveum.com/display/midPoint/Organizational+Structure">https://wiki.evolveum.com/display/midPoint/Organizational+Structure</a>) and then midpoint handles the rest. What do I need to do to my current configuration to populate the parentOrgRef
 property using the value of the parent_id column from my database? I can’t assign the parent_id value directly to parentOrgRef as it’s an integer, so I need to get a reference to the parent organisation.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’ve seen some references to a referenceSearch expression on Github, which I think may be what I need, but I haven’t seen an example of this in action. This is what I’ve got so far (which goes just above the </objectType> tag in my first
 example), but it doesn’t appear to do anything when I sync:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">         <attribute><o:p></o:p></p>
<p class="MsoNormal">            <c:ref>ri:parent_id</c:ref><o:p></o:p></p>
<p class="MsoNormal">            <matchingRule xmlns:gen426="http://prism.evolveum.com/xml/ns/public/matching-rule-3">gen426:default</matchingRule><o:p></o:p></p>
<p class="MsoNormal">            <tolerant>true</tolerant><o:p></o:p></p>
<p class="MsoNormal">            <exclusiveStrong>false</exclusiveStrong><o:p></o:p></p>
<p class="MsoNormal">            <fetchStrategy>implicit</fetchStrategy><o:p></o:p></p>
<p class="MsoNormal">            <inbound><o:p></o:p></p>
<p class="MsoNormal">               <authoritative>true</authoritative><o:p></o:p></p>
<p class="MsoNormal">               <exclusive>false</exclusive><o:p></o:p></p>
<p class="MsoNormal">               <strength>normal</strength><o:p></o:p></p>
<p class="MsoNormal">               <expression><o:p></o:p></p>
<p class="MsoNormal">                  <referenceSearch><o:p></o:p></p>
<p class="MsoNormal">                     <targetType>c:OrgType</targetType><o:p></o:p></p>
<p class="MsoNormal">                     <filter><o:p></o:p></p>
<p class="MsoNormal">                        <q:equal><o:p></o:p></p>
<p class="MsoNormal">                         <!-- Property from OrgType --> <o:p>
</o:p></p>
<p class="MsoNormal">                           <q:path>identifier</q:path><o:p></o:p></p>
<p class="MsoNormal">                           <expression><o:p></o:p></p>
<p class="MsoNormal">                              <!-- database column --><o:p></o:p></p>
<p class="MsoNormal">                              <c:path>$c:account/c:attributes/parent_id</c:path><o:p></o:p></p>
<p class="MsoNormal">                           </expression><o:p></o:p></p>
<p class="MsoNormal">                        </q:equal><o:p></o:p></p>
<p class="MsoNormal">                     </filter><o:p></o:p></p>
<p class="MsoNormal">                  </referenceSearch><o:p></o:p></p>
<p class="MsoNormal">               </expression><o:p></o:p></p>
<p class="MsoNormal">               <target><o:p></o:p></p>
<p class="MsoNormal">                  <!-- Field on the organisation that is being created --><o:p></o:p></p>
<p class="MsoNormal">                  <c:path>parentOrgRef</c:path><o:p></o:p></p>
<p class="MsoNormal">               </target><o:p></o:p></p>
<p class="MsoNormal">            </inbound><o:p></o:p></p>
<p class="MsoNormal">         </attribute><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The database table is sorted in such a way that the organisations at level 1 are first, then level 2, then level 3, etc. so I don’t think it’s trying to create or update organisations before their parent organisation has already been created.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Any clues?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Andrew<o:p></o:p></p>
</div>
</body>
</html>