Windchill のその他の機能 > サービス情報管理 > Customizing Windchill Service Information Manager and Windchill Service Parts > 新規の部品構造を生成または再生成するフックのカスタマイズ
  
新規の部品構造を生成または再生成するフックのカスタマイズ
バックグラウンド
サービス構造をテンプレート構造から生成または再生成するときは、構築されるサービス構造に対して、テンプレート構造に含まれているどのノードを除去、再利用、またはコピーするのかが既成のビジネスロジックによって決定されます。ノードの除去、再利用、またはコピーを決定する既成のビジネスロジックは、以下のとおりです。
サービス構造をテンプレート構造から生成または再生成するときは、構築されるサービス構造に対して、テンプレート構造に含まれているどのノードを除去、再利用、またはコピーするのかが既成のビジネスロジックによって決定されます。ノードの除去、再利用、またはコピーを決定する既成のビジネスロジックは、以下のとおりです。
ノードがテンプレート構造から除去された。
ノードがフィルタによってテンプレート構造から除外された。
ノードは空のグループまたはセクションであり、"Include Empty Nodes" プリファレンスが「偽」に設定されている。
テンプレート構造内の部品リストが空であるか、フィルタの適用後に空になる。この場合、ほかに兄弟が存在していなければ、親も除去されます。
テンプレート構造内の部品リストがジェネリックであり、フィルタに一致する実際の部品がない。この場合、ほかに兄弟が存在していなければ、親も除去されます。
再利用 - 以下のタイプのノードは、テンプレート構造から再利用されます。構築されるサービス構造内に新規のコピーは作成されません。
情報エレメント
コンテンツホルダー
ジェネリック情報エレメント
コピー - 以下のタイプのノードはテンプレート構造からコピーされ、構築されるサービス構造に新規のオブジェクトとして挿入されます。
情報グループ
パブリッシングセクション
ネストされた情報構造
ネストされたパブリッシング構造
目的
既成のビジネスロジックをオーバーライドし、除去、再利用、またはコピーするノードを決定するためのカスタムアルゴリズム規則を追加します。
ソリューション
サービス構造を生成または再生成するときに、除去、再利用、またはコピーされるノードを決定する、独自のビジネスロジックを作成できるようにするため、カスタマイズフックを作成します。デフォルトでは、これは既成のロジックに従って行われます。このサービスは、既成のビジネスロジックをオーバーライドするカスタム実装によって拡張できます。サービスのデフォルトインタフェースとパブリック API を以下に示します。
インタフェース
NodeResolutionService インタフェースでは、除去、再利用、またはコピーするノードを、ノードの比較によって決定できます。StandardNodeResolutionService サービスは、サービスを拡張した上で、xconfmanager ユーティリティを使用して wt.properties ファイルにサービスのカスタム実装をフックすることによってカスタマイズできます。
オーバーライドすることでカスタムロジックの実装を可能にするメソッドは 2 つあり、1 つはサービス構造の生成用、もう 1 つは再生成用です。メソッドを以下に示します。
resolveNodeForGeneration
/**
* This method is called when processing nodes during structure generation to determine which child nodes should be copied, reused or omitted from the generated structure.
*
*@param sourceNode the child node which should be resolved
* @return A map of the nodes stored against the relevant resolution key (COPY, REUSE, REMOVE, UNRESOLVED)
*/
Map<NavigationUnit, ResolutionKey> resolveNodeForGeneration(NavigationUnit sourceNode)
resolveNodeForRegeneration
/**
* This method is called when processing nodes during structure generation to determine which child nodes should be copied, reused or omitted from the generated structure. It is expected that this method will call the service helper methods to retrieve the child nodes for testing against custom logic
*
* @param isNew true if the node is a new source node being added to the structure
* @param sourceNodes the child nodes which should be resolved in the source structure
* @return A map of the nodes stored against the relevant resolution key (COPY, REUSE, REMOVE, UNRESOLVED)
*/
Map<NavigationUnit, ResolutionKey> resolveNodeForRegeneration(boolean isNew, NavigationUnit sourceNode)
ノード自体、その親、およびノードと親の UsageLink が含まれている NavigationUnit を介して、ソース構造内の各ノードがメソッドに渡されます。
ResolutionKey は、サービスから返されるオブジェクトの解決を識別するための列挙です。ResolutionKey で有効になるキーは以下のとおりです。
REMOVE - 新規生成または再生成されるサービス構造から除去される、ターゲット構造のノードのリスト。
REUSE - 新規の情報エレメントなど、ターゲット構造で再利用する必要のある新規ノードのリストまたは範囲。構造を再生成する場合、このキーには、除去またはコピーの対象として指定されていないかぎりデフォルトで再利用されることからこれまでに生成されなかった、新規のノードまたはエレメントのみがリストされます。
COPY - ターゲット構造に新規のコピーを作成する必要のある、ソース構造のノードのリストまたは範囲。
UNRESOLVED - このノードはカスタマイズフックロジックによって解決されておらず、システムへと返されて、既成のロジックによって解決されます。
レジストリ
1. xconfmanager ユーティリティを使用して site.xconf を編集します。xconfmanager ユーティリティの使用方法については、xconfmanager ユーティリティについてを参照してください。
2. 次のプロパティを追加します。
Property name=" wt.services.service.10399"
overridable="true"
targetFile="codebase/wt.properties"
value="com.ptc.arbortext.windchill.siscore.services.NodeResolutionService/<完全修飾カスタムクラス"/>
この <完全修飾カスタムクラス> は、完全修飾パッケージアドレス (com.ptc.arbortext.sis.MyServiceImplementation) です。
3. ファイルを保存します。
4. xconfmanager ユーティリティを使用して変更を適用します。<Windchill>\bin ディレクトリで、以下のコマンドを入力します。
xconfmanager -pF
5. メソッドサーバーを再起動します。
ヘルパーメソッド
提供されているいくつかの保護ヘルパーメソッドを使用すると、関連ノードを読み込み、ノードの解決を支援できます。これらのヘルパーメソッドは、ヘルパーメソッドにパラメータを渡すことによって、resolveNodeForGeneration メソッドおよび resolveNodeForRegeneration メソッドから呼び出すことができます。super キーワードを使用することで、新しいクラスでこれらのヘルパーメソッドにアクセスできます。
これらのヘルパーメソッドは、テンプレート構造に含まれている所定のノードの親と子の関係を表現した、ナビゲーションユニットの配列を返します。ナビゲーションユニットには、親、子、および親子間リンクが含まれています。
getChildren
/**
* Retrieves an Array of Navigation units representing the relationship between the parent and child nodes
*
* @param parent the node to find the children for.
* @return the NavigationUnits containing the children.
*/
protected NavigationUnit [] getChildren(Persistable parent, boolean sourceNodes);
getParents
/**
* Retrieves an Array of Navigation units for the nodes parent/s
*
* @param child the child node to find the parents of.
* @return the NavigationUnits containing the parents.
*/
protected NavigationUnit [] getParents(Persistable child, boolean sourceNodes);
/**
findPreviousGeneratedTargetNode
* Attempts to retrieve a previously generated element and its parent for the given source node, N.B for IEs
* this will be a navigation unit containing itself since it would have been reused on any previous generation.
*
* @param sourceUnit The source element to find the target node for.
* @return The target navigation unit containing the previously generated element (or itself if an IE) as the end node
*/
protected NavigationUnit findPreviousGeneratedTargetNode(NavigationUnit sourceUnit) {
getGeneratedPartList
/**
* Checks if the PartList param was resolved by the partlist service i.e. has changes and/or contains parts
*
* @param pList The part list to locate the generated part list for.
* @return a generated partlist, the same partlist (if reused) or null if the partlist was not resolved (is empty/filtered)
*/
protected PartList getGeneratedPartList(PartList pList)
外部ヘルパーメソッド: SisCoreHelper.getContentFromHolders(holders);
getContentFromHolders
/**
* A multi object api version of getContentFromHolder to reduce number of jdbc calls.
*
* @param holders
* A WTCollection of content holders.
* @return
*/ A WTKeyedMap of content holders to a WTCollection of content.
public static WTKeyedMap getContentFromHolders(WTCollection holders);