Getting the descendants of an entity
Use the get(DataObject) method and the DescendantControl to show the children of an entity.
About this task
This is the hierarchical structure for SalesPerson 1 and
SalesPerson2:
- dc=yourco,dc=com
- cn=users
- o=Sales
- ou=CA
- uid=SalesPerson1
- uid=SalesPeson2
- ou=US
- uid=SalesPerson3
- uid=SalesPeson4
- ou=Europe
- ou=CA
- o=Sales
- cn=users
In this example, the request is to show all the children of OrgContainer Sales.
To request the descendents of OrgContainer
Sales, add this sample code to your application code and replace the variable with
the actual values that you want to use for this request:
DataObject root = SDOHelper.createRootDataObject();
DataObject entity = SDOHelper.createEntityDataObject(root, null, DO_ENTITY);
entity.createDataObject(DO_IDENTIFIER).setString(PROP_UNIQUE_NAME,
"o=Sales,cn=users,dc=yourco,dc=com");
DataObject descCtrl = SDOHelper.createControlDataObject(root, null, DO_DESCENDANT_CONTROL);
// 0 means all descendants
descCtrl.setInt(PROP_LEVEL, 0);
descCtrl.getList(PROP_PROPERTIES).add("uid");
descCtrl.getList(PROP_PROPERTIES).add("cn");
descCtrl.getList(PROP_PROPERTIES).add("o");
descCtrl.getList(PROP_PROPERTIES).add("ou");
descCtrl.getList(PROP_PROPERTIES).add("manager");
root = service.get(root);
Sample input and output data graphs
For
this particular example the input data graph is:
<?xml version="1.0" encoding="UTF-8"?>
<sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sdo="commonj.sdo"
xmlns:wim="http://www.ibm.com/websphere/wim">
<wim:Root>
<wim:entities>
<wim:identifier uniqueName="o=Sales,cn=users,dc=yourco,dc=com"/>
</wim:entities>
<wim:controls xsi:type="wim:DescendantControl" level="0">
<wim:properties>uid</wim:properties>
<wim:properties>cn</wim:properties>
<wim:properties>o</wim:properties>
<wim:properties>ou</wim:properties>
<wim:properties>manager</wim:properties>
</wim:controls>
</wim:Root>
</sdo:datagraph>
The resulting output data graph for this example
is:
<?xml version="1.0" encoding="UTF-8"?>
<sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sdo="commonj.sdo"
xmlns:wim="http://www.ibm.com/websphere/wim">
<wim:Root>
<wim:entities xsi:type="wim:OrgContainer">
<wim:identifier externalName="o=Sales,cn=users,dc=yourco,dc=com"
repositoryId="LDAP1"
uniqueId="eab85abb-9d29-40f1-b502-36c051d3ee96"
uniqueName="o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:children xsi:type="wim:OrgContainer">
<wim:identifier externalId="0dfcccf7-9fb9-4b25-a0f4-ff4b6b33068e"
externalName="ou=CA,o=Sales,cn=users,dc=yourco,dc=com"
repositoryId="LDAP1"
uniqueName="ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:ou>CA</wim:ou>
</wim:children>
<wim:children xsi:type="wim:PersonAccount">
<wim:identifier externalId="e7db8c0e-d2b3-43fe-be14-1475125606f4"
externalName="uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"
repositoryId="LDAP1"
uniqueName="uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:uid>SalesPerson1</wim:uid>
<wim:cn>Sales Person1</wim:cn>
<wim:manager externalId="5e846c20-a1b4-4bfc-bce2-1f841d762f9a"
externalName="uid=SalesManager,cn=users,dc=yourco,dc=com"
repositoryId="LDAP1"
uniqueName="uid=SalesManager,cn=users,dc=yourco,dc=com"/>
</wim:children>
<wim:children xsi:type="wim:OrgContainer">
<wim:identifier externalId="70dd624d-6eb0-4fdf-8338-3ae4090b1c6f"
externalName="ou=US,o=Sales,cn=users,dc=yourco,dc=com"
repositoryId="LDAP1"
uniqueName="ou=US,o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:ou>US</wim:ou>
</wim:children>
<wim:children xsi:type="wim:PersonAccount">
<wim:identifier externalId="13ae346f-1e4c-40cd-8896-1c7f0b2b3079"
externalName="uid=SalesPerson3,ou=US,o=Sales,cn=users,dc=yourco,dc=com"
repositoryId="LDAP1"
uniqueName="uid=SalesPerson3,ou=US,o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:uid>SalesPerson3</wim:uid>
<wim:cn>Sales Person3</wim:cn>
<wim:manager externalId="5e846c20-a1b4-4bfc-bce2-1f841d762f9a"
externalName="uid=SalesManager,cn=users,dc=yourco,dc=com"
repositoryId="LDAP1"
uniqueName="uid=SalesManager,cn=users,dc=yourco,dc=com"/>
</wim:children>
<wim:children xsi:type="wim:PersonAccount">
<wim:identifier externalId="a2d1be42-212e-44f0-8396-0bfc2d7d346d"
externalName="uid=SalesPerson4,ou=US,o=Sales,cn=users,dc=yourco,dc=com"
repositoryId="LDAP1"
uniqueName="uid=SalesPerson4,ou=US,o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:uid>SalesPerson4</wim:uid>
<wim:cn>Sales Person4</wim:cn>
</wim:children>
<wim:children xsi:type="wim:PersonAccount">
<wim:identifier externalId="a3f9e8a1-117a-4252-840f-6d0cb079a7fb"
externalName="uid=SalesPerson2,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"
repositoryId="LDAP1"
uniqueName="uid=SalesPerson2,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:uid>SalesPerson2</wim:uid>
<wim:cn>Sales Person2</wim:cn>
<wim:manager externalId="5e846c20-a1b4-4bfc-bce2-1f841d762f9a"
externalName="uid=SalesManager,cn=users,dc=yourco,dc=com"
repositoryId="LDAP1"
uniqueName="uid=SalesManager,cn=users,dc=yourco,dc=com"/>
</wim:children>
</wim:entities>
</wim:Root>
</sdo:datagraph>
OrganizationUnit CA and its children SalesPerson1 and
SalesPerson2, OrganizationUnit US and its children, SalesPerson3 and
SalesPerson4, and OrganizationUnit Europe are returned as the descendants
of OrgContainer Sales.Also see the topic, Sample code for creating an entity in a hierarchy and getting descendants and ancestors.