Developing a Regulatory Submission Acknowledgement Interpreter
This topic explains how to extend the out-of-the-box regulatory submission processor classes and override the acknowledgment processing method with the agency-specific processing method.
Solution
Create a custom class that extends an out-of-the-box regulatory submission processor.
Create an xconf entry to register your custom class.
Solution Elements
The table below describes the solution element.
Element
Type
Description
processAcknowledgement(String transmissionName, String transmissionContent)
API
Used to process acknowledgments received from a regulatory agency for a regulatory submission.
Default Behavior
The default implementation is intended only for the demonstrational and instructional purposes only. It is expected that each regulatory agency will provide documentation on the number and format of acknowledgments for each regulatory submission type. As required, the implementors can create a submission-specific processor that matches the provided documentation.
Acknowledgement 1 contains a JSON string with the format:
{
"ackNumber": 1,
"typeName": "<typeName>"
"name": "<regulatorySubmissionName>",
"number": "<regulatorySubmissionNumber>",
"remoteIdentifier": "<remoteIdentifier>"
}
Acknowledgement 2 contains a JSON string with the format:
{
"ackNumber": 2,
"typeName": "<typeName>"
"remoteIdentifier": "<remoteIdentifier>"
"certificationNumber": "<certificateNumber>"
"expirationDate": "<exirationDate>"
"result": "SUCCESS|FAILURE"
}
Based on theRegulatory Submission Processor Interface, the acknowledgment events are only dispatched when Acknowledgement 2 is received. The typename is included, as this is a sample generic acknowledgment processor. In the regulatory submission type-specific processors, the typename is known because there is a one-to-one relationship between the regulatory submission processor and the type against which it is registered.
Creating Custom Classes
To customize acknowledgement processing, create a Java class (your processor) that extends the SimpleRegulatorySubmissionProcessor or the appropriate revisable subtype preocessor, then override the processAcknowledgment method. The revisable subtype populators can be AERSubmissionProcessor, ERSubmissionProcessor, RPSSubmissionProcessor, and UDISubmissionProcessor.
The next example shows a new custom class with the out-of-the-box requirements of the overridden processAcknowledgment method. ConditionalCheckoutRunner is used to prevent multiple iterations by disallowing an automatic checkout when multiple service calls are made.
@Override
public boolean processAcknowledgement(String transmissionName, String transmissionContent) throws Exception {

new TransactionRunner() {
@Override
public void performBusinessProcess() throws Exception {
JSONObject jsonContent = new JSONObject(transmissionContent);

switch (jsonContent.getInt("ackNumber")) {
case 1:
String typeName = jsonContent.getString("typeName");
String number = jsonContent.getString("number");

RegulatorySubmission regulatorySubmission = RegulatorySubmissionHelper.service
.findRegulatorySubmissionByTypeAndAttribute(typeName, "number", number);

new ConditionalAutoCheckoutRunner<RegulatorySubmission>(regulatorySubmission) {
@Override
public RegulatorySubmission performBusinessProcess(RegulatorySubmission coRegSub)
throws Exception {
RegulatoryContentHelper.getService().storeRegulatoryContent(coRegSub,
RegulatoryContentCategory.ACKNOWLEDGEMENT1, transmissionName, transmissionContent);

return RegulatorySubmissionHelper.service.modifyRegulatorySubmission(coRegSub,
Map.of("remoteIdentifier", jsonContent.getString("remoteIdentifier")));
}
}.invoke();
break;
case 2:
String remoteIdentifier = jsonContent.getString("remoteIdentifier");
typeName = jsonContent.getString("typeName");

regulatorySubmission = RegulatorySubmissionHelper.service
.findRegulatorySubmissionByTypeAndAttribute(typeName, "remoteIdentifier", remoteIdentifier);

new ConditionalAutoCheckoutRunner<RegulatorySubmission>(regulatorySubmission) {
@Override
public RegulatorySubmission performBusinessProcess(RegulatorySubmission coRegSub)
throws Exception {
RegulatoryContentHelper.getService().storeRegulatoryContent(coRegSub,
RegulatoryContentCategory.ACKNOWLEDGEMENT2, transmissionName, transmissionContent);

if ("SUCCESS".equals(jsonContent.get("result"))) {
String expDateString = jsonContent.getString("expirationDate");
Timestamp expDate = Timestamp.valueOf(expDateString);

coRegSub = RegulatorySubmissionHelper.service.modifyRegulatorySubmission(coRegSub,
Map.of("certificateNumber", jsonContent.getString("certificateNumber"),
"expirationDate", expDate));

RegulatorySubmissionProcessorHelper.dispatchAcknowledgmentSuccessfulEvent(coRegSub);
}
else {
RegulatorySubmissionProcessorHelper.dispatchAcknowledgmentFailedEvent(coRegSub);
}

return coRegSub;
}
}.invoke();

break;
default:
break;
}
}
}.invoke();

return true;
}
Was this helpful?