[midPoint] Populating parentOrgRef in an Org from a database resource
Andrew Brock
Andrew.Brock at sahmri.com
Thu Jul 28 08:38:35 CEST 2016
Hi,
I have a database resource that gives me the following organisation info in its columns:
1.) An ID (an integer)
2.) A Name (a string)
3.) 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.
This resource can be considered the definitive authority for this data (i.e. it's not present in LDAP).
I currently have a schemaHandling like so:
<schemaHandling>
<objectType>
<kind>account</kind>
<intent>HRM</intent>
<default>true</default>
<objectClass>ri:AccountObjectClass</objectClass>
<attribute>
<c:ref>icfs:uid</c:ref>
<tolerant>true</tolerant>
<exclusiveStrong>false</exclusiveStrong>
<inbound>
<authoritative>true</authoritative>
<exclusive>false</exclusive>
<strength>normal</strength>
<target>
<c:path>identifier</c:path>
</target>
</inbound>
</attribute>
<attribute>
<c:ref>ri:name</c:ref>
<tolerant>true</tolerant>
<exclusiveStrong>false</exclusiveStrong>
<inbound>
<authoritative>true</authoritative>
<exclusive>false</exclusive>
<strength>normal</strength>
<target>
<c:path>name</c:path>
</target>
</inbound>
</attribute>
</objectType>
</schemaHandling>
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.
I now want to put them into their proper hierarchy!
My understanding is that an org-to-org relationship shouldn't be an assignment, but a population of the parentOrgRef (see https://wiki.evolveum.com/display/midPoint/Organizational+Structure) 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.
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:
<attribute>
<c:ref>ri:parent_id</c:ref>
<matchingRule xmlns:gen426="http://prism.evolveum.com/xml/ns/public/matching-rule-3">gen426:default</matchingRule>
<tolerant>true</tolerant>
<exclusiveStrong>false</exclusiveStrong>
<fetchStrategy>implicit</fetchStrategy>
<inbound>
<authoritative>true</authoritative>
<exclusive>false</exclusive>
<strength>normal</strength>
<expression>
<referenceSearch>
<targetType>c:OrgType</targetType>
<filter>
<q:equal>
<!-- Property from OrgType -->
<q:path>identifier</q:path>
<expression>
<!-- database column -->
<c:path>$c:account/c:attributes/parent_id</c:path>
</expression>
</q:equal>
</filter>
</referenceSearch>
</expression>
<target>
<!-- Field on the organisation that is being created -->
<c:path>parentOrgRef</c:path>
</target>
</inbound>
</attribute>
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.
Any clues?
Thanks,
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20160728/77c73399/attachment.htm>
More information about the midPoint
mailing list