TopicSubscriptionUtilOOB - 범위 지정됨
TopicSubscriptionUtilOOB 스크립트 포함은 토픽 구독 [sn_api_notif_mgmt_topic_subscription] 테이블에서 기록을 쿼리하고 조작하는 메서드를 제공합니다. 이 클래스는 서비스 계층에서 작동하며 DAO(데이터 액세스 개체) 클래스와 상호 작용합니다.
이러한 함수는 주제 구독 양식에서 등록 버튼을 선택할 때 호출됩니다. 이 스크립트 포함의 기본 기능을 변경하려면 TopicSubscriptionUtil 스크립트 포함에서 이 스크립트 포함에 포함된 기능을 재정의해야 합니다.
두 스크립트 포함은 모두 sn_api_notif_mgmt 네임스페이스에서 실행됩니다.
주제 구독에 대한 자세한 내용은 다음 문서를 참조하십시오 External event management via Telecommunications API notifications.
TopicSubscriptionUtilOOB - executeRegistrationSubflow(문자열 topicSubID)
스포크 하위 플로우를 트리거하여 전달된 주제 구독을 외부 시스템에 등록합니다.
등록 플로우를 트리거하기 전에 함수는 전달된 토픽 구독 기록에 콜백 URL이 포함되어 있는지, 토픽이 이미 등록되었는지 여부를 확인합니다. 이러한 검사에 통과하면 데모 하위 플로우가 트리거됩니다. 이 데모 하위 플로우는 스포크 선택기에서 어댑터로 정의되며 "모의" 아웃바운드 등록 호출을 수행합니다.
이 함수는 사용자가 토픽 구독 양식에서 등록 단추를 선택할 때 호출됩니다. 데모 하위 플로우의 이름은 Constants.INITIATE_REGISTRATION_PROCESS = "sn_ind_tmf642.initiate_registration_process"에 정의되어 있습니다.
주제 구독을 등록하기 위한 사용자 지정 하위 플로우를 정의하려면 TopicSubscriptionUtil 스크립트 포함에서 이 함수를 재정의해야 합니다.
이 등록 하위 플로우 내에서 REST 단계, 연결 별칭 또는 외부 시스템의 등록 엔드포인트를 호출하여 주제를 등록하는 기타 구현을 만들어야 합니다. 이 엔드포인트는 등록할 주제 이름과 콜백 URL을 전달해야 합니다. 그 대가로 외부 시스템 엔드포인트는 구독 ID, 등록 성공 여부 및 토픽 구독 테이블에 저장할 등록 정보를 반환해야 합니다. 이 정보에는 일반적으로 등록 상태, 등록 메시지 및 구독 ID 필드가 포함됩니다. 그런 다음 등록 하위 플로우는 updateRegistrationResponse() 메서드를 호출하여 주제 구독 테이블에 응답 페이로드를 저장해야 합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| topicSubID | 문자열 | 등록할 주제 구독 기록의 Sys_id입니다. |
| 유형 | 설명 |
|---|---|
| 없음 |
다음 코드 예제에서는 이 함수를 재정의하는 방법을 보여 줍니다.
var TopicSubscriptionUtil= Class.create();
TopicSubscriptionUtil.prototype =
Object.extendsObject(TopicSubscriptionUtilOOB, {
// Define overriding functions here. Pass the topicSubID of the record to be registered for subscription
executeRegistrationSubflow: function(topicSubID){
var topicSubGr = new TopicSubscriptionUtil(topicSubID).topicSubscriptionDAO.getGlideRecord();
// Customer extensible function to call their defined subflows. Here one can call their own subflow that
// will perform registration by giving an endpoint of the external env and parsing and updating the topic Sub
// record with Registered information.
var registrationFlow = ''; // Pass the subflow name that you want to override here.
var inputs = {};
inputs['topic_subscription_rec'] = topicSubGr;
try {
var flowOp = sn_fd.FlowAPI.getRunner().subflow(registrationFlow).inBackground().withInputs(inputs).run();
} catch (ex) {
gs.addErrorMessage(gs.getMessage(ex + ' Please check the subflow and inputs defined.'));
}
}
type: TopicSubscriptionUtil
});
TopicSubscriptionUtilOOB - getSubFlowName()
스포크 선택기 하위 플로우 트리거에 사용할 하위 플로우를 반환하여 주제 구독을 등록합니다.
일반적으로 이 함수는 executeRegistrationSubflow() 함수에서 호출됩니다. 이 하위 플로우는 외부 시스템에 연결하고 토픽 구독을 등록하는 작업을 담당합니다. 사용할 하위 플로우의 이름은 Constants.INITIATE_REGISTRATION_PROCESS에 정의되어 있습니다.
sn_api_notif_mgmt에서 실행할 하위 플로우의 이름을 재정의하여 자신의 하위 플로우의 이름을 포함하도록 이 기능을 변경할 수 있습니다 . 상수 스크립트 포함
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | 사용할 하위 플로우의 이름입니다. 데모 구현의 경우 이 하위 플로우는 Constants.INITIATE_REGISTRATION_PROCESS = "sn_ind_tmf642.initiate_registration_process";로 정의됩니다. |
다음 코드 예제에서는 이 함수를 재정의하는 방법을 보여 줍니다.
var TopicSubscriptionUtil= Class.create();
TopicSubscriptionUtil.prototype =
Object.extendsObject(TopicSubscriptionUtilOOB, {
// Define overriding functions here. Define a constants and return.
// That is your subflow that has the registration process. In current OOB implementation
// it’s a spoke selector implementation.
getSubFlowName: function(){
var subflowName = '' // Pass your subflow name here
return subflowName;
}
type: TopicSubscriptionUtil
});
TopicSubscriptionUtilOOB - getTopicName(topicSubRefID)
토픽 구독 [sn_api_notif_mgmt_topic_subscription] 테이블에 있는 기록의 전달된 sys_id과 관련된 토픽의 이름을 반환합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| topicSubRefID | 문자열 | 반환할 주제 이름이 포함된 주제 구독 기록의 Sys_id. 테이블: 주제 구독 [sn_api_notif_mgmt_topic_subscription] |
| 유형 | 설명 |
|---|---|
| 문자열 | 주제 이름입니다. |
다음 코드 예제에서는 이 함수를 재정의하는 방법을 보여 줍니다.
var TopicSubscriptionUtil = Class.create();
TopicSubscriptionUtil.prototype =
Object.extendsObject(TopicSubscriptionUtilOOB, {
// Define overriding functions here. Pass topicSubId or topicId and get topicname from there.
getTopicName: function(topicSubRefID){
var topicSubGr = new TopicSubscriptionUtil(topicSubRefID).topicSubscriptionDAO.getGlideRecord();
var topicRefID = topicSubGr.getValue('topic');
var topicGr = new TopicUtil(topicRefID).topicDAO.getGlideRecord();
return topicGr.getValue('topic_name');
}
type: TopicSubscriptionUtil
});
TopicSubscriptionUtilOOB - getUnregisteredTopicIds()
등록되지 않은 항목의 sys_ids 반환합니다. 등록되지 않은 주제는 주제 [sn_api_notif_mgmt_topic] 테이블에는 있지만 주제 구독 [sn_api_notif_mgmt_topic_subscription] 테이블에는 없는 주제입니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 배열 | 아직 등록되지 않은 sys_ids 주제 기록 목록입니다. |
다음 코드 예제에서는 이 함수를 업데이트하는 방법을 보여 줍니다.
var TopicSubscriptionUtil= Class.create();
TopicSubscriptionUtil.prototype =
Object.extendsObject(TopicSubscriptionUtilOOB, {
// Define overriding functions here. This method is returning all topic IDs
// that are not in the Topic Subscription table. Modify queries here to
// return other topics in Topic Subscription table to return either 'Error' or
// 'UnRegistered' status topics.
getUnregisteredTopicIds: function(){
var topicIds = [];
var topicSubscriptionGr = TopicSubscriptionDAO.getInSubscriptionTopic();
if (!gs.nil(topicSubscriptionGr)) {
while (topicSubscriptionGr.next()) {
topicIds.push(topicSubscriptionGr.getValue('topic'));
}
}
var unregisteredTopicGr = TopicDAO.getUnregisteredTopic(topicIds);
if (!gs.nil(unregisteredTopicGr)) {
var unregisterTopicIds = [];
while (unregisteredTopicGr.next()) {
unregisterTopicIds.push(unregisteredTopicGr.getValue('sys_id'));
}
}
return unregisterTopicIds;
}
type: TopicSubscriptionUtil
});
TopicSubscriptionUtilOOB - updateRegistrationResponse(객체 registrationDetails)
주제 구독 [sn_api_notif_mgmt_topic_subscription] 테이블의 주제 구독 기록을 아웃바운드 주제 등록 엔드포인트 호출의 모의 등록 응답 값으로 업데이트합니다.
TopicSubscriptionUtil 스크립트 포함에서 이 함수를 재정의하여 연결된 항목 구독 기록에 저장된 정보를 수정할 수 있습니다. 등록 상세 정보를 반환하는 하위 플로우 실행에 대한 자세한 내용은 executeRegistrationSubflow()를 참조하십시오.
| 이름 | 유형 | 설명 |
|---|---|---|
| registrationDetails | 객체 | 데모 구현의 경우 데모 등록 API 호출에서 반환되는 모의 응답입니다. 이 함수를 재정의하는 경우 응답 페이로드에는 최소한 다음 주제 구독 필드가 포함되어야 합니다.
|
| 유형 | 설명 |
|---|---|
| 오류 | 호출에 성공하면 아무 것도 반환되지 않습니다. 오류가 발생하면 다음을 반환합니다.
|
다음 코드 예제에서는 이 함수를 업데이트하는 방법을 보여 줍니다.
var TopicSubscriptionUtil= Class.create();
TopicSubscriptionUtil.prototype =
Object.extendsObject(TopicSubscriptionUtilOOB, {
// Define overriding functions here. Modify this method to parse the registration details
// output from a spoke selector flow. You can pass different parameters from the registration response
// and map them to the fields in the Topic Subscription table.
updateRegistrationResponse: function(registrationDetails){
var reqTypeId = Constants.TOPIC_SUB_REQUEST_TYPE;
var outputMap = new sn_appss.IntegrationRequestConfigAPI().outputJSONToMap(reqTypeId, registrationDetails.result);
var updateTopicSubObj = new sn_tmt_core.BaseObject();
if (Constants.REGISTRATION_RESPONSE_SUCCESS_CODES.indexOf(responseCode) != -1) {
updateTopicSubObj.setValue('registration_status', Constants.REGISTRATION_STATUS.REGISTERED);
updateTopicSubObj.setValue('registration_message', outputMap.response_body.message);
updateTopicSubObj.setValue('subscription_id', outputMap.response_body.result.id);
}
}
type: TopicSubscriptionUtil
});
TopicSubscriptionUtilOOB - updateTopicSubscriptionRec(객체 topicSubObj)
DAO 삽입을 사용하여 현재 주제 구독 기록을 주제 구독 [sn_api_notif_mgmt_topic_subscription] 테이블에 저장합니다.
일반적으로 updateRegistrationResponse() 함수 내에서 이 함수를 호출합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 주제SubObj | 객체 | 연결된 주제 구독 기록에서 업데이트할 필드입니다. 등록 하위 플로우에서 반환하는 페이로드입니다. 예: 자세한 내용은 executeRegistrationSubflow() 단원을 참조하십시오. |
| 유형 | 설명 |
|---|---|
| 문자열 | 업데이트된 주제 구독 기록의 Sys_id입니다. |
다음 코드 예제에서는 이 함수를 업데이트하는 방법을 보여 줍니다.
var TopicSubscriptionUtil= Class.create();
TopicSubscriptionUtil.prototype =
Object.extendsObject(TopicSubscriptionUtilOOB, {
// Define overriding functions here. Pass a topic subscription record object that contains
// the values to update in a record.
updateTopicSubRec: function(topicSubObj){
return this.topicSubscriptionDAO.updateTopicSubscription(topicSubObj);
}
type: TopicSubscriptionUtil
});
다음 코드 예제에서는 이 함수를 호출하는 방법을 보여 줍니다.
if (!gs.nil(outputMap) && outputMap.status_code == '1') {
var responseCode = outputMap.response_body.code;
var topicSubID = registrationDetails.topicSubID;
var topicSubGr = new TopicSubscriptionUtil(topicSubID).topicSubscriptionDAO.getGlideRecord();
var updateTopicSubObj = new sn_tmt_core.BaseObject();
if (Constants.REGISTRATION_RESPONSE_SUCCESS_CODES.indexOf(responseCode) != -1) {
updateTopicSubObj.setValue('registration_status', Constants.REGISTRATION_STATUS.REGISTERED);
updateTopicSubObj.setValue('registration_message', outputMap.response_body.message);
updateTopicSubObj.setValue('subscription_id', outputMap.response_body.result.id);
} else {
updateTopicSubObj.setValue('registration_status', Constants.REGISTRATION_STATUS.ERROR);
updateTopicSubObj.setValue('registration_message', outputMap.response_body.message);
}
new TopicSubscriptionUtil(topicSubGr).updateTopicSubscriptionRec(updateTopicSubObj);
return '';
} else if (!gs.nil(outputMap) && outputMap.status_code == '0') {
return outputMap.status_reason;
} else {
var errorMsg = 'Spoke Request Type output not set, please check request adapter flow';
return errorMsg;
}