Skip to content

Commit

Permalink
Merge pull request #154 from bcgov/hr-records-hot-fix
Browse files Browse the repository at this point in the history
HR Records fix for UAT load
npham49 authored Dec 17, 2024

Verified

This commit was signed with the committer’s verified signature.
infeo Armin Schrenk
2 parents 6153c10 + 682ff18 commit 537fc4a
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import ca.bc.gov.chefs.etl.forms.pcd.hrRecords.model.HRRecordsSubmission;
import ca.bc.gov.chefs.etl.util.CSVUtil;
import ca.bc.gov.chefs.etl.util.FileUtil;
import ca.bc.gov.chefs.etl.util.JsonUtil;

public class PcdHRRecordsApiResponseProcessor extends BaseApiResponseProcessor {

@@ -32,6 +33,8 @@ public void process(Exchange exchange) throws Exception {
String payload = exchange.getIn().getBody(String.class);
ObjectMapper mapper = new ObjectMapper();

payload = JsonUtil.fixPcnNameObject(payload);

List<Root> hrRecordsModels = mapper.readValue(payload, new TypeReference<List<Root>>() {
});

9 changes: 9 additions & 0 deletions src/main/java/ca/bc/gov/chefs/etl/util/JsonUtil.java
Original file line number Diff line number Diff line change
@@ -133,6 +133,15 @@ public static String fixPcnName(String payload) {
return result;
}

public static String fixPcnNameObject(String payload) {
// The following code aims to replace occurrences of "pcnName":"{}" with "pcnName": "", as "pcnName" is
// expected to be a String and not an object
String pcnPattern = "\"pcnName\":\\{\\}";
String pcnReplacement = "\"pcnName\": \"\"";

return payload.replaceAll(pcnPattern, pcnReplacement);
}

/**
* Does some basic cleanup/conversion of common Unicode characters which aren't allowed in the
* target ASCII database.

0 comments on commit 537fc4a

Please sign in to comment.