高度なカスタマイズ > ビジネスロジックのカスタマイズ > ビジネスロジックのカスタマイズ > 構造比較用ロジックのカスタマイズ
  
構造比較用ロジックのカスタマイズ
* 
構造比較の一般的な概要については、構造の比較を参照してください。
この情報は次の用途に適用されます。
部品構造と比較
部品コンフィギュレーション構造と比較
部品インスタンス構造と比較
これらの用途では、比較プロセスを用いて、2 つのオブジェクトが同じ行に並んで表示されるかどうかが判別されます。この比較は、通常、親子間のリンクオブジェクトのプロパティに基づいて行われます。親または子に対してプロパティを使用することも可能です。
左側と右側の 2 つの親が一致している場合、左側の親の下にある各リンクを右側の親の下にある各リンクと比較することによって比較の優先順位が調べられます。優先順位の値が小さいほど一致の度合いが高くなります。優先順位 "0" はリンクが完全に一致していることを意味し、負の優先順位はリンクが一致していないことを意味します。
1 つのリンクオブジェクトタイプで比較するようにマッチャーが設定されています。したがって、リンクオブジェクトタイプごとに比較ロジックをカスタマイズできます。
matchEdges() メソッドは比較プロセス中に何度も呼び出されるため、パフォーマンスが高くなければなりません。そうでない場合、重大なパフォーマンス低下が生じます。
比較ロジックのカスタマイズは 2 つのステップからなります。
1. カスタムマッチャーを実装します。次に例を示します。
public class DSBCustomMatcherWTPartUsageLink extends DSBAbstractMatcher {
@Override
public int matchEdges(DSBEdge sourceEdge, DSBEdge targetEdge) {
// Custom matching logic
...
// Example of gathering required attributes
Object sourceFindNumber = sourceEdge.getEdgeInfo()
.getAttribute(PLMEntity.FIND_NUMBER.getAttribute());
Object targetQuantityAmount = targetEdge.getEdgeInfo()
.getAttribute(PLMEntity.QUANTITY_AMOUNT.getAttribute());
Object sourceVersion = sourceEdge.getChild()
.getNodeInfo().getAttribute(PLMEntity.VERSION.getAttribute());
...
}
@Override
public List<Attribute> initRequiredEdgeAttributes() {
// Edge attributes required for matching
// If no attributes are required for matching, return null
return Arrays.asList(new Attribute[]{
PLMEntity.FIND_NUMBER,
PLMEntity.QUANTITY_AMOUNT
});
}
@Override
public List<Attribute> initRequiredNodeAttributes() {
// Node attributes required for matching
// If no attributes are required for matching, return null
return Arrays.asList(new Attribute[]{
PLMEntity.VERSION
});
}
}
2. 適切な xconf ファイルに、カスタムマッチャーをリンクタイプにリンクするエントリを追加します。次に例を示します。
<Service context="default" name="com.ptc.windchill.enterprise.dsb.server
.graph.matcher.DSBAbstractMatcher">
<Option cardinality="singleton" selector="wt.part.WTPartUsageLink"
requestor="null" serviceClass="com.ptc.windchill.enterprise.dsb.server
.graph.matcher.DSBCustomMatcherWTPartUsageLink"/>
</Service>