Skip to content

Commit

Permalink
Added fix for ASCII characters. (#171)
Browse files Browse the repository at this point in the history
Added null safety for missing property.
Code cleanup.

Co-authored-by: weskubo-cgi <[email protected]>
  • Loading branch information
weskubo-cgi and weskubo-cgi authored Feb 5, 2025
1 parent 3081680 commit c7c4631
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ca.bc.gov.chefs.etl.forms.ltc.budget.processor;

import java.util.ArrayList;

import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -36,7 +35,6 @@
import ca.bc.gov.chefs.etl.forms.ltc.budget.model.LtcBudgetRevTotals;
import ca.bc.gov.chefs.etl.forms.ltc.budget.model.LtcBudgetSubmission;
import ca.bc.gov.chefs.etl.forms.ltc.budget.model.LtcBudgetSumTotals;
import ca.bc.gov.chefs.etl.forms.ltc.quarterly.model.LtcYtdCompHrs;
import ca.bc.gov.chefs.etl.util.CSVUtil;
import ca.bc.gov.chefs.etl.util.FileUtil;
import ca.bc.gov.chefs.etl.util.JsonUtil;
Expand All @@ -49,6 +47,7 @@ public class LtcAnnualBudgetApiResponseProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
String payload = exchange.getIn().getBody(String.class);
payload = JsonUtil.preProcess(payload);
payload = JsonUtil.fixUnicodeCharacters(payload);
payload = JsonUtil.roundDigitsNumber(payload);
ObjectMapper mapper = new ObjectMapper();
List<Root> ltcBudgetForms = mapper.readValue(payload, new TypeReference<List<Root>>() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package ca.bc.gov.chefs.etl.forms.ltc.facility.processor;
import java.util.Map;

import ca.bc.gov.chefs.etl.constant.Constants;
import ca.bc.gov.chefs.etl.core.processor.BaseApiProcessor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class FacilityInfoFormApiResponseProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
String payload = exchange.getIn().getBody(String.class);
payload = JsonUtil.fixUnicodeCharacters(payload);
payload = JsonUtil.roundDigitsNumber(payload);
payload = JsonUtil.ltcFacilityBackwardCompatibility(payload);
ObjectMapper mapper = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class LtcQuarterlyYtdApiResponseProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
String payload = exchange.getIn().getBody(String.class);
payload = JsonUtil.preProcess(payload);
payload = JsonUtil.fixUnicodeCharacters(payload);
payload = JsonUtil.roundDigitsNumber(payload);
payload = JsonUtil.ltcYTDBackwardCompatibility(payload);
ObjectMapper mapper = new ObjectMapper();
Expand Down Expand Up @@ -158,7 +159,7 @@ private String resolveOperatingSurplusBeforeDepreciation(Root root) {
String submissionsNeedRecalculation = getValue(YTD_SUBMISSIONS_NEEDS_RECALCULATIONS_EX);

// If the form confirmation id in list of error forms, recalculate
if (submissionsNeedRecalculation.contains(root.getForm().getConfirmationId())){
if (StringUtils.contains(submissionsNeedRecalculation, root.getForm().getConfirmationId())){
Double opEx_sum14 = calculateOpExSum14(root);
// Due to incorrect sum14, the total needs to be recalculated
Double opEx_YTD_total = parseDoubleHandleNull(root.getOpRev_YTD6()) + parseDoubleHandleNull(root.getOpEx_sum11())
Expand Down Expand Up @@ -192,7 +193,7 @@ private String resolveTotalOperatingSurplus(Root root) {
String submissionsNeedRecalculation = getValue(YTD_SUBMISSIONS_NEEDS_RECALCULATIONS_EX);

// If the form confirmation id in list of error forms, recalculate
if (submissionsNeedRecalculation.contains(root.getForm().getConfirmationId())){
if (StringUtils.contains(submissionsNeedRecalculation, root.getForm().getConfirmationId())){
Double opEx_sum14 = calculateOpExSum14(root);
// Due to incorrect sum14, the total needs to be recalculated
Double opEx_YTD_total = parseDoubleHandleNull(root.getOpRev_YTD6()) + parseDoubleHandleNull(root.getOpEx_sum11())
Expand Down Expand Up @@ -227,7 +228,7 @@ private String resolveTotalOperatingSurplus(Root root) {
private String calculateTotalCompHrsStaff(Root root, List<LtcYtdCompHrs> ltcYtdCompHrs) {
String submissionsNeedRecalculation = getValue(YTD_SUBMISSIONS_NEEDS_RECALCULATIONS_COMP);

if (submissionsNeedRecalculation.contains(root.getForm().getConfirmationId())){
if (StringUtils.contains(submissionsNeedRecalculation, root.getForm().getConfirmationId())){
Double total = 0.0;
for (LtcYtdCompHrs ltcYtdCompHr : ltcYtdCompHrs) {
total += parseDoubleHandleNull(ltcYtdCompHr.getCompHrsStaffYtd());
Expand All @@ -241,7 +242,7 @@ private String calculateTotalCompHrsStaff(Root root, List<LtcYtdCompHrs> ltcYtdC
private String calculateTotalCompHrsContracted(Root root, List<LtcYtdCompHrs> ltcYtdCompHrs) {
String submissionsNeedRecalculation = getValue(YTD_SUBMISSIONS_NEEDS_RECALCULATIONS_COMP);

if (submissionsNeedRecalculation.contains(root.getForm().getConfirmationId())){
if (StringUtils.contains(submissionsNeedRecalculation, root.getForm().getConfirmationId())){
Double total = 0.0;
for (LtcYtdCompHrs ltcYtdCompHr : ltcYtdCompHrs) {
total += parseDoubleHandleNull(ltcYtdCompHr.getCompHrsContractServicesYtd());
Expand All @@ -255,7 +256,7 @@ private String calculateTotalCompHrsContracted(Root root, List<LtcYtdCompHrs> lt
private String calculateTotalCompHrsTotal(Root root, List<LtcYtdCompHrs> ltcYtdCompHrs) {
String submissionsNeedRecalculation = getValue(YTD_SUBMISSIONS_NEEDS_RECALCULATIONS_COMP);

if (submissionsNeedRecalculation.contains(root.getForm().getConfirmationId())){
if (StringUtils.contains(submissionsNeedRecalculation, root.getForm().getConfirmationId())){
Double total = 0.0;
for (LtcYtdCompHrs ltcYtdCompHr : ltcYtdCompHrs) {
total += parseDoubleHandleNull(ltcYtdCompHr.getCompTotalWorkedHrsYtd());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class LTCStaffingPlanApiResponseProcessor implements Processor {
@SuppressWarnings("unchecked")
public void process(Exchange exchange) throws Exception {
String payload = exchange.getIn().getBody(String.class);
payload = JsonUtil.fixUnicodeCharacters(payload);
payload = JsonUtil.roundDigitsNumber(payload);
payload = StaffingPlanUtil.normaliseDoesTheStaffingPatternProvide(payload);
ObjectMapper mapper = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package ca.bc.gov.chefs.etl.forms.ltc.staffing.processor;

import java.util.Map;

import ca.bc.gov.chefs.etl.constant.Constants;
import ca.bc.gov.chefs.etl.core.processor.BaseApiProcessor;

Expand Down

0 comments on commit c7c4631

Please sign in to comment.