Skip to content

Commit

Permalink
Merge pull request #345 from alexjoybc/fix-default-values
Browse files Browse the repository at this point in the history
Set some default values for ids
  • Loading branch information
alexjoybc authored Jun 16, 2020
2 parents 871ff54 + 5efa486 commit d440cc4
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import ca.bc.gov.open.pssg.rsbc.dps.spd.notification.worker.generated.models.Data;
import ca.bc.gov.open.pssg.rsbc.figaro.ords.client.document.*;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
Expand Down Expand Up @@ -37,7 +38,7 @@ public class OutputNotificationConsumer {
private static final int SUCCESS_CODE = 0;
private static final String DPS_FILE_ID_KEY = "dps.fileId";
private static final String DPS_BUSINESS_AREA_CD_KEY = "dps.businessAreaCd";
;
private static final String DEFAULT_VALUE = "0";

private final FileService fileService;
private final SftpProperties sftpProperties;
Expand Down Expand Up @@ -100,9 +101,8 @@ public void receiveMessage(OutputNotificationMessage message) {
.withApplicationPaymentId(documentData.getPvApplicationPaymentId())
.withApplicationIncompleteReason(documentData.getPvApplicationIncompleteReason())
.withApplicationValidateUsername(documentData.getPvValidationUser())
// ?? document is not referenced ?
.withApplicationDocumentGuid(documentResponse.getGuid())
.withApplPartyId(documentData.getPnApplPartyId())
.withApplPartyId(defaultValue(documentData.getPnApplPartyId()))
.withApplSurname(documentData.getPvApplSurname())
.withApplFirstName(documentData.getPvApplFirstName())
.withApplSecondName(documentData.getPvApplSecondName())
Expand All @@ -126,15 +126,18 @@ public void receiveMessage(OutputNotificationMessage message) {
.withApplDriversLicence(documentData.getPvApplDriversLicence())
.withApplPhoneNumber(documentData.getPvApplPhoneNumber())
.withApplEmailAddress(documentData.getPvApplEmailAddress())
.withApplOrgPartyId(documentData.getPnOrgPartyId())
.withApplOrgFacilityPartyId(documentData.getPnOrgFacilityPartyId())
.withApplOrgPartyId(defaultValue(documentData.getPnOrgPartyId()))
.withApplOrgFacilityPartyId(defaultValue(documentData.getPnOrgFacilityPartyId()))
.withApplOrgFacilityName(documentData.getPvOrgFacilityName())
.withApplOrgContactPartyId(documentData.getPnOrgContactPartyId())
.withApplOrgContactPartyId(defaultValue(documentData.getPnOrgContactPartyId()))
.build();

logger.debug("figaro request: {}");

DpsDataIntoFigaroResponse figaroResponse =
documentService.dpsDataIntoFigaro(dpsDataIntoFigaroRequestBody);


if (figaroResponse.getRespCode() == SUCCESS_CODE) {
logger.info("success: {} with {}", figaroResponse, fileInfo);
fileService.moveFilesToArchive(fileInfo);
Expand Down Expand Up @@ -189,4 +192,10 @@ private void signalSuccess(OutputNotificationMessage message) {

NotificationService.notify(success);
}

private String defaultValue(String value) {
if(StringUtils.isBlank(value)) return DEFAULT_VALUE;
return value;
}

}

0 comments on commit d440cc4

Please sign in to comment.