Merge Mapping
Introduction
Penrose supports merging multiple sources which may not be related at all into a single subtree in Penrose.
This feature works in a limited way in version 1.0 but only fully supported in 1.1.
Goal
Suppose we have 2 tables "users1" and "users2" which contain the the full user information (username, first name, last name, password), but they contain different set of data. We want to combine these tables and display them as if they are coming from the same source.
dn: uid=<users1's username>,ou=Users,dc=Example,dc=com objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson uid: <users1's username> cn: <users1'sf ull name> sn: <users1's last name> userPassword: <users1's password> dn: uid=<users2's username>,ou=Users,dc=Example,dc=com objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson uid: <users2's username> cn: <users2's full name> sn: <users2's last name> userPassword: <users2's password>
Solution
The solution is very simple, you just need to create a separate mapping for each source and assign them the same DN's.
<entry dn="uid=...,ou=Users,dc=Example,dc=com"> <oc>person</oc> <oc>organizationalPerson</oc> <oc>inetOrgPerson</oc> <at name="uid" rdn="true"> <variable>u1.username</variable> </at> <at name="cn"> <expression> if (u1 == void || u1 == null) return null; return u1.firstName+" "+u1.lastName; </expression> </at> <at name="sn"> <variable>u1.lastName</variable> </at> <at name="userPassword"> <variable>u1.password</variable> </at> <source name="u1"> <source-name>users1</source-name> <field name="username"> <variable>uid</variable> </field> <field name="firstName"> <expression> if (cn == void || cn == null) return null; int i = cn.lastIndexOf(" "); return cn.substring(0, i); </expression> </field> <field name="lastName"> <expression> if (sn != void && sn != null) return sn; if (cn == void || cn == null) return null; int i = cn.lastIndexOf(" "); return cn.substring(i+1); </expression> </field> <field name="password"> <variable>userPassword</variable> </field> </source> </entry> <entry dn="uid=...,ou=Users,dc=Example,dc=com"> <oc>person</oc> <oc>organizationalPerson</oc> <oc>inetOrgPerson</oc> <at name="uid" rdn="true"> <variable>u2.username</variable> </at> <at name="cn"> <expression> if (u2 == void || u2 == null) return null; return u2.firstName+" "+u2.lastName; </expression> </at> <at name="sn"> <variable>u2.lastName</variable> </at> <at name="userPassword"> <variable>u2.password</variable> </at> <source name="u2"> <source-name>users2</source-name> <field name="username"> <variable>uid</variable> </field> <field name="firstName"> <expression> if (cn == void || cn == null) return null; int i = cn.lastIndexOf(" "); return cn.substring(0, i); </expression> </field> <field name="lastName"> <expression> if (sn != void && sn != null) return sn; if (cn == void || cn == null) return null; int i = cn.lastIndexOf(" "); return cn.substring(i+1); </expression> </field> <field name="password"> <variable>userPassword</variable> </field> </source> </entry>