高度なカスタマイズ > サービスおよびインフラストラクチャのカスタマイズ > インポートとエクスポートのフレームワーク > IX アプリケーションの作成方法 > Exporter クラス
  
Exporter クラス
exporter クラスの詳細を以下に示します。
定義:
public class Exporter extends ExpImporter{…};
コンストラクタ:
Exporter (ApplicationExportHandler _applicationExportHandler,
WTContainerRef _sourceContainer,
String targetDTD,
File localMappingRuleFile,
File policyRuleFile,
String actionName)
throws WTException {
super ("export", ( localMappingRuleFile==null?null:
localMappingRuleFile.getAbsolutePath() ));
//assign Container
sourceContainer = _sourceContainer;
// -- init expActionTuner --
applicationExportHandler = _applicationExportHandler;
dtd = targetDTD;
this.expImpContextData = new ExportContextData();
expActionTuner = new ExportActionTuner (policyRuleFile, actionName);
}
引数の説明は、以下のとおりです。
_applicationExportHandler - インタフェース ApplicationExportHandler の実装、抽象クラス ApplicationExportHandlerTemplate の拡張、または抽象クラス ApplicationExportHandlerForJar の拡張のいずれかを行う任意のクラスのインスタンスです。
クラス ApplicationExportHandlerForJar はクラス ApplicationExportHandlerTemplate を拡張します。ApplicationExportHandlerForJar クラスは、XML およびコンテンツファイルをエクスポート jar ファイルに保存するためのメソッドを提供します。このクラスは、ApplicationData コンテンツおよびローカルファイルシステムに常駐するコンテンツの両方を処理します。
_applicationExportHandler は、結果として生じた XML のコレクション (エクスポートされたオブジェクト) の Jar ファイルを作成します (または、ほかのいずれかの方法で保存します)。以下の 2 つのメソッドを実装する必要があります。
storeContent (ApplicationData);
storeDocument (IxbElement );
sourceContainer: Reference of container.
targetDTD: エクスポート処理で使用する DTD を指定する文字列です。IX フレームワークは、この DTD 文字列に基づいて、オブジェクトに適切なハンドラおよびオブジェクトのドキュメントタイプ定義を見つけます。Windchill リリース 10.X の DTD 文字列は standard20.dtd です。
この目的は一般に、任意の DTD でオブジェクトをエクスポートできるようにすることでした。以下に示すように、クラスのエクスポートハンドラは、DTD 識別子を使用して解決されます。string targetDTD は、エクスポートされるオブジェクトの XML ファイルにも書き込まれるので、インポート処理でオブジェクトのインポートに使用する DTD を判断できます。
localMapppingRules: エクスポート処理の発生時、特定の属性オブジェクトをオーバーライド、変更、または除外するために使用する XML ファイルまたは XSL ファイルです。
以下の XML 規則ファイルは、Team Template 属性をオーバーライドし、エクスポート時にオブジェクトが属していたチームに関係なく、"/System" ドメインの Team Template 属性を "Change Team" にします。
<?xml version="1.0" encoding="UTF-8"?>
<userSettings>
<mappingRules>
<COPY_AS>
<tag>teamIdentity</tag>
<value>*</value>
<newValue>Change Team (/System)</newValue>
</COPY_AS>
</mappingRules>
</userSettings>
XSL 規則ファイルは、テストを実行してエクスポートオブジェクトの名前が "part_c" の場合は Team Template 属性とバージョン情報をオーバーライドし、エクスポートオブジェクトの名前が "PART_B" の場合は Team Template 属性をオーバーライドします。
オーバーライドしない場合は、引数 localMapppingRules で Null を渡します。
policyRuleFile: エクスポート処理の発生時、特定の属性オブジェクトをオーバーライド、変更、または除外するために使用する XSL ファイルです。
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@* | node()" priority="-9">
</xsl:template>
<xsl:template match="WTPart">
<xsl:choose>
<xsl:when test="name='part_c'">
<newInfo>
<teamIdentity>Default (/System)</teamIdentity>
<folderPath>/Design</folderPath>
<versionInfo>
<versionId>B</versionId>
<iterationId>2</iterationId>
<versionLevel>1</versionLevel>
</versionInfo>
</newInfo>
</xsl:when>
<xsl:when test="number='PART_B'">
<newInfo>
<teamIdentity>Default (/System)</teamIdentity>
<folderPath>/Design</folderPath>
</newInfo>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
たとえば、ポリシー規則ファイルでは、エクスポート後にデータベース内のエクスポート済み WTPart オブジェクトをチェックアウトするように指定します。エクスポート済み WTDocument オブジェクトの番号が "TESTDOC-1" の場合は、エクスポート後にチェックアウトします。ほかのエクスポート済み WTDocuments については、エクスポート後にデータベースにロックします。
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform
version="2.0">
<xsl:output method="xml" indent="no" encoding="UTF-8"/>
<!--
The syntax of Export Policy is standard XSL syntax. The output of
XSLT using the XSL policy file
must only have at most one element of the form:
<actionInfo>
<action>...</action>
</actionInfo>
-->
The following is a sample of a well-formed xsl. In the cases, where
there are no specific actions to be performed, nothing needs to be
done, which is the default action that would transpire as shown in
the uncommented section below.
-->
<xsl:template match="@* | node()" priority="-9">
</xsl:template>
<xsl:template match="WTPart">
<actionInfo>
<action>Checkout</action>
</actionInfo>
</xsl:template>
<xsl:template match="WTDocument">
<actionInfo>
<xsl:choose>
<xsl:when test="number='TESTDOC-1">
<action>Checkout</action>
</xsl:when>
<xsl:otherwise>
<action>Lock</action>
</xsl:otherwise>
</xsl:choose>
</actionInfo>
</xsl:template>
-->
<!-- Do nothing by default -->
<xsl:template match="@* | node()" priority="-9">
</xsl:template>
</xsl:stylesheet>
オーバーライドしない場合は、引数 policyRuleFile で Null を渡します。
actionName : Action name
IxbHelper クラスのファクトリメソッド newExporter() を通じて、Exporter のインスタンスを作成する必要があります。例:
IxbHelper.newExporter (…..);