Runtime tools : Core components : Importing predefined elements : Using predefined reusable elements after importing
  
Using predefined reusable elements after importing
In UNICOM® Digital Transformation Toolkit (UDTT™) definition files, you can use an <import> tag to reuse the elements defined in reusable UDTT definition files.
Prerequisite
You need to have a reusable UDTT definition file that contains reusable elements. And you have a new UDTT definition file that imported the reusable file by using the <import> tag.
Example 1: Direct importing
First, define a reusable definition file the following. Then import this file:
<data-import.xml>
<bColl id="customerBean" bean="com.ibm.btt.bean.test.Customer"></bColl>
<kColl id="account">
<field id="loan" value=""></field>
<field id="money" value=""></field>
</kColl>
</data-import.xml>
This example instantiates a context with an inner context containing a bean collection and assigns value to one of the inner collection's elements. Use the following code in data-import.xml to define the data element customerBean:
<bColl id="customerBean" bean="com.ibm.btt.bean.test.Customer"/>
Use the following code to import file data-import.xml in to file data.xml:
<import file="data-import.xml"/>
Context definition in file context.xml:
<context id="customerCtx" type="test"><refKColl refId="customerBean"/></context>
Then you can using the following code to use the element customerBean:
Context ctx = ContextFactory.createContext("CustomerCtx");
ctx.setValueAt("name", "Steven");
Example 2: Sequential importing
Instantiate a context with an inner context contained a set of hierarchical reusable elements and assign value to one of the inner collection's elements.
Address definition in address.xml, the definition is as following:
<address.xml>
<bColl id="address" bean="com.ibm.btt.importsupport.Address"/>
</address.xml>
Customer definition in customer.xml, the definition is as following:
<customer.xml>
  <import file="address.xml"/>
  <kColl id="customer" dynamic="true">
    <refData refId="address"/>
    <field id="customerID" value="customer12345"/>
  </kColl>
</customer.xml>
Account definition in account.xml, the definition is as following:
<account.xml>
  <importfile="customer.xml"/>
  <kColl id="account" dynamic="true">
    <refData refId="customer"/>
    <field id="accountID" value="account12345"/>
  </kColl>
</account.xml>
Loan definition in loan.xml, the definition is as following:
<loan.xml>
  <import file="account.xml"/>
  <kColl id="loan" dynamic="true">
    <refData refId="account"/>
    <field id="loanID" value="loan12345"/>
  </kColl>
</loan.xml>
Data definition in data.xml, the file loan.xml is imported into data.xml file,add the following code into data.xml:
<import file="loan.xml"/>
Context definition in context.xml:
<context id="loanCtx" type="test">
  <refKColl refId="loan"/>
</context>
Then you can using the following code to use the element loanCtx:
Context ctx = ContextFactory.createContext("loanCtx");
ctx.setValueAt("account.customer.address.city", "Beijing");
ctx.setValueAt("account.customer.address.region", "AP-GCG");
ctx.setValueAt("account.customer.customerID ", "CUS00247");
ctx.setValueAt("account.accountID ", "ACC00369");
ctx.setValueAt("loanID ", "LOA00158");
Go up to
Importing predefined elements