TopicUtilOOB: スコープ指定
TopicUtilOOB スクリプトインクルードには、トピック [sn_api_notif_mgmt_topic] テーブル内のレコードを照会および操作できるようにする関数が含まれています。このクラスは、データアクセスオブジェクト (DAO) クラスとやり取りするサービスレイヤーで動作します。
これらの関数は、[トピック] フォームで [ トピックを取得 ] ボタンが選択されているときに呼び出されます。このスクリプトインクルードのデフォルト機能を変更する場合は、このスクリプトインクルードに含まれる関数を TopicUtil スクリプトインクルードで上書きする必要があります。
どちらのスクリプトインクルードも sn_api_notif_mgmt 名前空間で実行されます。
トピックの詳細については、「 External event management via Telecommunications API notifications」を参照してください。
TopicUtilOOB:createTopic(オブジェクト topicObj)
DAO 挿入を使用してトピック [sn_api_notif_mgmt_topic] テーブルにレコードを作成します。
通常、この関数は、コンテンツに対してさまざまな検証も実行する validateAndInsertTopic 関数内で呼び出します。
| 名前 | タイプ | 説明 |
|---|---|---|
| トピックオブジェクト | オブジェクト | トピックレコードに格納するフィールドを含むオブジェクト。基本実装の場合、オブジェクトの形式は次のとおりです。トピックテーブルを変更または拡張する場合、このオブジェクトにはその構造が反映されます。必須フィールドが含まれていることを確認してください。 |
| タイプ | 説明 |
|---|---|
| 文字列 | 作成されたトピックレコードのSys_id。 |
次のコード例は、この関数を呼び出す方法を示しています。
validateAndInsertTopics: function(topicsResponse) {
if (!gs.nil(topicsResponse)) {
var topicsArr = topicsResponse.response;
for (var i = 0; i < topicsArr.length; i++) {
var name = topicsArr[i].name;
var headerQuery = topicsArr[i].headerQuery;
var contentQuery = topicsArr[i].contentQuery;
var namespace = topicsArr[i].namespace;
var id = topicsArr[i].id;
var description = topicsArr[i].description;
var topicGr = TopicDAO.getTopicByNameHeaderContentNamespace(name, headerQuery, contentQuery, namespace,'');
if (topicGr && !topicGr.hasNext()) {
var topicObj = new sn_tmt_core.BaseObject();
topicObj.setValue('topic_name', name);
topicObj.setValue('header_query', headerQuery);
topicObj.setValue('content_query', contentQuery);
topicObj.setValue('namespace', namespace);
topicObj.setValue('description', description);
topicObj.setValue('topic_id', id);
topicObj.setValue('type', Constants.TYPE_INGRESS);
this.createTopic(topicObj);
}
}
}
}
次のコード例は、この関数をオーバーライドする方法を示しています。
var TopicUtil = Class.create();
TopicUtil.prototype =
Object.extendsObject(TopicUtilOOB, {
// Define overriding functions here. Pass a topic record object with
// values for a single Topic table record.
createTopic: function(topicObj){
return this.topicDAO.create(topicObj);
}
type: TopicUtil
});
TopicUtilOOB:getSubFlowName()
外部システムからトピックを取得するために呼び出すサブフローの名前を返します。
通常、この関数は triggerSubflow() 関数から呼び出されます。このサブフローは、外部システムに接続し、トピック [sn_api_notif_mgmt_topic] テーブルに挿入する必要があるトピックレコードを取得する役割を果たします。
サブフローの名前は Constants.GET_TOPICS_SUBFLOW で定義されます。デモ実装の場合、このサブフローは sn_ind_tmf642.event_alarm_notifications_api で、エンドツーエンドの処理を示す「モック」応答を生成します (外部システムを呼び出さない)。
sn_api_notif_mgmtで実行するサブフローの名前を上書きすることで、この機能を変更して独自のサブフローの名前を含めることができます 。定数 スクリプトインクルード。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 文字列 | 外部システムからトピックを取得するために使用するサブフローの名前。 |
次のコード例は、この関数をオーバーライドする方法を示しています。
var TopicUtil= Class.create();
TopicUtil.prototype =
Object.extendsObject(TopicUtilOOB, {
// Define overriding function here. In TopicUtilOOB it returns the flow name of a GET outbound API call that mocks the GET call.
// Override this function to return a flow that returns topics from an external system.
getSubflowName: function(){
return <flow_name>; // Return the name here
}
type: TopicUtil
});
TopicUtilOOB:triggerSubflow()
外部システムからトピックレコードを取得するサブフローをトリガーします。
この関数は、ユーザーが [トピック] フォームで [ トピックを取得 ] ボタンを選択したときに呼び出されます。
トリガーされるサブフローの名前は Constants.GET_TOPICS_SUBFLOW で定義されます。デモ実装の場合、このサブフローは sn_ind_tmf642.event_alarm_notifications_api で、エンドツーエンドの処理を示す「モック」応答を生成します (外部システムを呼び出さない)。
sn_api_notif_mgmtで実行するサブフローの名前を上書きして、独自のサブフローの名前を含めるようにこの関数を変更する必要があります 。定数 スクリプトインクルード。
サブフロー内で、REST ステップ、接続エイリアス、またはその他の実装を作成して、外部ネットワークからトピックを取得するエンドポイント URL を提供する必要があります。そのサブフローによってトピックが返されたら、 validateAndInsertTopics 関数を呼び出して、返されたトピックペイロードを検証し、トピックテーブルのレコードを挿入/更新します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| なし |
次のコード例は、この関数をオーバーライドする方法を示しています。
var TopicUtil = Class.create();
TopicUtil.prototype =
Object.extendsObject(TopicUtilOOB, {
// Define overriding functions here. Override this function to call your own GET API outbound call subflow.
triggerSubflow: function(){
var result =''; // Pass the subflow here
try {
var flowOp = sn_fd.FlowAPI.getRunner().subflow(result).inBackground().withInputs().run();
if (flowOp) {
gs.addInfoMessage(gs.getMessage('Please refresh the list to see new Topics.'));
}
} catch (ex) {
gs.addInfoMessage(gs.getMessage(ex + ' Please check if the trigger is defined and passed correctly'));
}
}
type: TopicUtil
});
TopicUtilOOB:validateAndInsertTopics(アレイ topicsResponse)
渡されたトピックレコードペイロードを検証し、このデータを含むトピック [sn_api_notif_mgmt_topic} テーブルにレコードを挿入します。
渡されたトピックペイロードは、外部システムからトピックを取得するために使用される「GET API エンドポイント」から取得されます。この GET API のトリガーの詳細については、「 triggerSubflow()」を参照してください。
TopicUtil スクリプトインクルードでこの関数を上書きすることで、この機能を変更して独自の検証ルールとトピックレコードフィールドを含めることができます。
| 名前 | タイプ | 説明 |
|---|---|---|
| トピック応答 | オブジェクトのアレイ | サブフロー内の GET API エンドポイントを介して外部システムから返されるトピックレコードペイロード。このペイロードは、トピック [sn_api_notif_mgmt_topic] テーブルの構造と一致する必要があります。アレイ内の各オブジェクトは個別のトピックです。たとえば、デモ実装では次のようになります。 |
| タイプ | 説明 |
|---|---|
| なし |
次のコード例は、この関数をオーバーライドする方法を示しています。
var TopicUtil= Class.create();
TopicUtil.prototype =
Object.extendsObject(TopicUtilOOB, {
// Define overriding functions here. Override this function to include custom
// validations on topic payload parameters and insert the record into the Topics table.
validateInsertTopics: function(topicsResponse){
// Provide validation on the passed payload.
this.createTopic(topicObj);
}
type: TopicUtil
});
TopicUtilOOB - verifyTopics(文字列 topicname, 文字列 headerQuery, 文字列 contentQuery, 文字列 namespace, 文字列 previousSysId)
トピック [sn_api_notif_mgmt_topic] テーブル内の他のトピックレコードに、指定されたフィールドの組み合わせが複合キーとして含まれているかどうか (トピックの重複) を示します。
| 名前 | タイプ | 説明 |
|---|---|---|
| トピック名 | 文字列 | トピックの名前。 |
| ヘッダークエリ | 文字列 | イベントヘッダープロパティのコンテンツに適用するフィルター。このクエリーは、関連付けられたトピックについてリッスンするイベントのタイプを定義します。このパラメーターは、ネストされたクエリとして渡すことができます。 例:" 詳細については、「 TMF688 Event Management API ユーザーガイド」を参照してください。 |
| contentQuery | 文字列 | イベントのコンテンツに適用するフィルター。このクエリーは、イベントの重大度や考えられる原因などの情報を検索するために使用される、より詳細なイベントフィルターです。このパラメーターは、ネストされたクエリとして渡すことができます。 例:" 詳細については、「 TMF688 Event Management API ユーザーガイド」を参照してください。 |
| 名前空間 | 文字列 | 関連するトピックが存在する名前空間。トピックはドメイン内で重複することはできませんが、複数のドメインに含めることができます。 |
| 前の SysID | 文字列 | オプション。更新するトピックのSys_id。既存のトピックを更新する場合にのみ、この値を渡します。 |
| タイプ | 説明 |
|---|---|
| ブーリアン | トピックテーブル内の別のレコードに、指定されたフィールドの組み合わせが含まれているかどうかを示すフラグ。 可能な値:
|
次のコード例は、この関数をオーバーライドする方法を示しています。
var TopicUtil= Class.create();
TopicUtil.prototype =
Object.extendsObject(TopicUtilOOB, {
// Define overriding functions here. Override this function to provide custom validations on
// the passed parameters and to verify whether an insert is possible or not.
verifyTopics: function(topicname, headerQuery, contentQuery, namespace, previousSysId) {
// Write modified code here to get any combination of records present in the current Topic table.
// In the current implementation, the function checks if there is a duplicate topic record that contains the
// passed parameters.
},
type: TopicUtil
});