エンティティーの祖先の取得

get(DataObject) メソッドと AncestorControl を使用すると、エンティティーの祖先を表示できます。

このタスクについて

以下に SalesPerson1 の階層構造を示します。
  • cn=users,dc=yourco,dc=com
    • o=Sales
      • ou=CA
        • uid=SalesPerson1
      • ou=US
      • ou=Europe

この例では、要求とは SalesPerson1 のすべてのレベルの祖先を表示することです。

SalesPerson1 のすべてのレベルの祖先を要求するには、ご使用のアプリケーション・コードにこのサンプル・コードを追加し、変数 をこの要求で使用する実際の値で置き換えます。
DataObject root = SDOHelper.createRootDataObject();
DataObject entity = SDOHelper.createEntityDataObject(root, null, DO_PERSON_ACCOUNT);
entity.createDataObject(DO_IDENTIFIER).setString(PROP_UNIQUE_NAME, 
               "uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com");			
DataObject ancesCtrl = SDOHelper.createControlDataObject(root, null, DO_ANCESTOR_CONTROL);
// 0 means all ancestors
ancesCtrl.setInt(PROP_LEVEL, 0); 
ancesCtrl.getList(PROP_PROPERTIES).add("uid");
ancesCtrl.getList(PROP_PROPERTIES).add("cn");
ancesCtrl.getList(PROP_PROPERTIES).add("o");
ancesCtrl.getList(PROP_PROPERTIES).add("ou");			
		
root = service.get(root);

入出力データ・グラフのサンプル

この例では、入力データ・グラフは次のようになります。
<?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:PersonAccount">
      <wim:identifier uniqueName="uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/>
    </wim:entities>
    <wim:controls xsi:type="wim:AncestorControl" level="0">
      <wim:properties>uid</wim:properties>
      <wim:properties>cn</wim:properties>
      <wim:properties>o</wim:properties>
      <wim:properties>ou</wim:properties>
    </wim:controls>
  </wim:Root>
</sdo:datagraph>
この例で作成される出力データ・グラフは次のようになります。
<?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:PersonAccount">
      <wim:identifier externalName="uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"
                      repositoryId="LDAP1" 
                      uniqueId="e7db8c0e-d2b3-43fe-be14-1475125606f4" 
                      uniqueName="uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/>
      <wim:parent 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:parent xsi:type="wim:OrgContainer">
          <wim:identifier externalId="eab85abb-9d29-40f1-b502-36c051d3ee96" 
                          externalName="o=Sales,cn=users,dc=yourco,dc=com"
                          repositoryId="LDAP1" 
                          uniqueName="o=Sales,cn=users,dc=yourco,dc=com"/>
          <wim:parent xsi:type="wim:OrgContainer">
            <wim:identifier externalId="93fde597-b628-4952-90cc-d6b178a05235" 
                            externalName="cn=users,dc=yourco,dc=com"
                            repositoryId="LDAP1" 
                            uniqueName="cn=users,dc=yourco,dc=com"/>
            <wim:cn>users</wim:cn>
          </wim:parent>
          <wim:o>Sales</wim:o>
        </wim:parent>
        <wim:ou>CA</wim:ou>
      </wim:parent>
    </wim:entities>
  </wim:Root>
</sdo:datagraph>
CA、Sales、users、および dc=yourco.dc=com が SalesPerson1 の祖先として戻されます。

エンティティーを階層構造で作成し、子孫と祖先を取得するためのサンプル・コード」トピックも参照してください。



利用条件 | フィードバック