高度なカスタマイズ > ビジネスロジックのカスタマイズ > 変更管理のカスタマイズ > 必要に応じたビジネス規則評価 > ソリューション > 手順 - カスタムビジネス規則の結果操作の作成
  
手順 - カスタムビジネス規則の結果操作の作成
次の手順は、変更通知の結果オブジェクトに対してビジネス規則セットを実行し、その結果を表示するカスタム操作の作成方法を例示しています。ビジネス規則結果を評価する操作は、変更通知の操作メニューから使用できます。
ビジネス規則の結果テーブルの拡張
AbstractBusinessRulesResultsTable クラスを拡張し、getRuleValidationResultSet API をオーバーライドして必要な規則セットを実行します。ビジネス規則の実行の詳細については、ビジネス規則のカスタマイズを参照してください。変更通知の結果オブジェクトに対してビジネス規則を実行する、カスタムビジネス規則の結果テーブルビルダーの例を次に示します。
package com.custom.businessRules.mvc.builders;
@ComponentBuilder("CustomBusinessRulesResultsTable")
public class CustomBusinessRulesResultsTable extends
AbstractBusinessRulesResultsTable {

private static final Logger logger =
LogR.getLogger(CustomBusinessRulesResultsTable.
class.getName());
/**
* {@inheritDoc}
*/
@Override
public RuleValidationResultSet
getRuleValidationResultSet(NmCommandBean commandBean)
throws WTException {
RuleValidationResultSet resultSet = new RuleValidationResultSet();
logger.debug("Get context object.");
NmOid contextOid = commandBean.getActionOid();
if(contextOid.isA(WTChangeOrder2.class)) {
logger.debug("Context object is a change notice.");

BusinessRuleSetBean[] ruleSetBeans = new BusinessRuleSetBean[] {
BusinessRuleSetBean.newBusinessRuleSetBean
("CHANGEABLE_PRE_RELEASE",
ChangeRecord2.class.getName())
};
logger.debug("Executing the CHANGEABLE_PRE_RELEASE rule
set for the change notice resulting objects.");
resultSet = BusinessRulesHelper.
engine.execute(contextOid.getRefObject(),
ruleSetBeans);
}

return resultSet;
}
}
カスタムテーブルビルダーを登録します。
このビルダーを登録するには、/<windchill>/codebase/config/mvc/custom.xml に次の行を追加します。
<mvc:builder-scan base-package="com.custom.businessRules.mvc.builders"/>
操作の定義
ビジネス規則の結果操作の定義
ポップアップウィンドウを起動してビジネス規則の結果を表示するための新規操作を <Windchill>/codebase/config/actions/custom-actions.xml に定義します。
<objecttype name="customBusinessRules"
resourceBundle="com.custom.customClientActionsRB">
<action name="customBusinessRulesResultWizard">
<command windowType="popup"/>
</action>
</objecttype>
この新規操作では、カスタムリソースファイルに新しい操作のプロパティが定義されている必要があります。新規操作の定義方法については、Windchill クライアントアーキテクチャ操作フレームワークの概要を参照してください。次に、カスタム操作用に設定するプロパティの例を示します。
@RBEntry("View Rule Conflicts")
@RBComment("Title of the wizard that displays business rules results")
public static final String PRIVATE_CONSTANT_0 =
"customBusinessRules.customBusinessRulesResultWizard.description";

@RBEntry("View Rule Conflicts")
@RBComment("Title of the wizard that displays business rules results")
public static final String PRIVATE_CONSTANT_1 =
"customBusinessRules.customBusinessRulesResultWizard.title";

@RBEntry("View Rule Conflicts")
@RBComment("Title of the wizard that displays business rules results")
public static final String PRIVATE_CONSTANT_2 =
"customBusinessRules.customBusinessRulesResultWizard.tooltip";
@RBEntry("width=940,height=600")
@RBPseudo(false)
@RBComment("DO NOT TRANSLATE")
public static final String VIEW_CONFLICTS_MOREURLINFO =
"customBusinessRules.customBusinessRulesResultWizard.moreurlinfo";
ビジネス規則の結果テーブルステップ操作の定義
前述の「ビジネス規則の結果操作の定義」セクションのカスタムテーブルビルダーで定義した ComponentId を使用して、/<windchill>/codebase/config/actions/custom-actions.xml に、ビジネス結果テーブルを表示するための新規操作を定義します。
<objecttype name="customBusinessRules" resourceBundle=
"com.custom.customClientActionsRB">
<action name="customBusinessRulesResultStep">
<component name="CustomBusinessRulesResultsTable"/>
</action>
</objecttype>
ビジネス規則の結果操作の JSP の定義
カスタムビジネス規則操作の起動時にテーブルを表示するには、JSP ファイルを使用して単一ステップのウィザードを定義する必要があります。JSP の名前は操作名と一致し、ディレクトリ <Windchill>/codebase/netmarkets/jsp の下の、操作オブジェクトタイプと同じ名前のパッケージ内に存在する必要があります。前述の「ビジネス規則の結果操作の定義」セクションで定義した操作の場合、パッケージと名前は次のようになります。
<Windchill>/codebase/netmarkets/jsp/customBusinessRules/customBusinessRulesResultWizard.jsp
次の JSP のサンプルは、「ビジネス規則の結果テーブルステップ操作の定義」セクションで定義した操作を含む単一ステップのウィザードを作成するものです。ウィザードの作成の詳細については、Windchill クライアントアーキテクチャウィザードを参照してください。
<%@ taglib prefix="jca"
uri="http://www.ptc.com/windchill/taglib/components"%>
<%@ include file="/netmarkets/jsp/components/beginWizard.jspf"%>
<!-- Need to set isWizard and popupWindow to false in
order to display links on number and the info
page action icon. -->
<% request.setAttribute("isWizard","false"); %>
<script src="netmarkets/javascript/businessRules/
businessRulesResultsPlugin.js"></script>
<script type="text/javascript">
<!-- Converts all links to open in new window -->
PTC.onReady(function() {
JCAappendFormHiddenInput(getMainForm(), "popupWindow", "false");
});
</script>
<jca:wizard buttonList="OkCancelWizardButtons">
<jca:wizardStep action="customBusinessRulesResultStep"
type="customBusinessRules"/>
</jca:wizard>
<%@include file="/netmarkets/jsp/util/end.jspf"%>
ビジネス規則の結果操作のメニューへの追加
新規カスタム操作は、オブジェクト操作モデルに追加する必要があります。操作モデルの追加またはオーバーライドには、/<windchill>/codebase/config/actions/custom-actionModels.xml が使用できます。次の例は、変更通知の既存の操作モデルにカスタム操作を追加する方法を示しています。
<actionmodels resourceBundle="com.ptc.windchill.enterprise.
change2.changeManagementActionsRB">
<model name="more change notice row actions"
menufor="wt.change2.WTChangeOrder2">
<description>Change notice row actions</description>
<action name="customBusinessRulesResultWizard"
type="customBusinessRules"/>
.
.
<!-- Existing Actions -->
.
.
</model>
</actionmodels>