Skip to content

Commit

Permalink
WFPREV-107 Handle empty string for ancillaryFundingSourceGuid
Browse files Browse the repository at this point in the history
  • Loading branch information
ssylver93 committed Feb 1, 2025
1 parent 5022588 commit bf3e5a4
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ public ProjectFiscalEntity toEntity(ProjectFiscalModel model, ProjectEntity proj
entity.setFiscalYear(model.getFiscalYear() != null
? BigDecimal.valueOf(model.getFiscalYear())
: null);
if (model.getAncillaryFundingSourceGuid() != null) {
if (model.getAncillaryFundingSourceGuid() != null && !model.getAncillaryFundingSourceGuid().trim().isEmpty()) {
entity.setAncillaryFundingSourceGuid(UUID.fromString(model.getAncillaryFundingSourceGuid()));
}
}else entity.setAncillaryFundingSourceGuid(null);
entity.setProjectPlanStatusCode(model.getProjectPlanStatusCode());
entity.setPlanFiscalStatusCode(model.getPlanFiscalStatusCode());
entity.setEndorsementCode(model.getEndorsementCode());
Expand Down Expand Up @@ -182,10 +182,14 @@ public ProjectFiscalEntity updateEntity(ProjectFiscalModel projectFiscalModel, P
projectFiscalModel.getFiscalYear() != null
? BigDecimal.valueOf(projectFiscalModel.getFiscalYear())
: existingEntity.getFiscalYear());
existingEntity.setAncillaryFundingSourceGuid(nonNullOrDefault(
projectFiscalModel.getAncillaryFundingSourceGuid() != null ? UUID.fromString(projectFiscalModel.getAncillaryFundingSourceGuid()) : null,
existingEntity.getAncillaryFundingSourceGuid()
));
existingEntity.setAncillaryFundingSourceGuid(
nonNullOrDefault(
isValidUuid(projectFiscalModel.getAncillaryFundingSourceGuid())
? UUID.fromString(projectFiscalModel.getAncillaryFundingSourceGuid())
: null,
existingEntity.getAncillaryFundingSourceGuid()
)
);
existingEntity.setProjectPlanStatusCode(
nonNullOrDefault(projectFiscalModel.getProjectPlanStatusCode(), existingEntity.getProjectPlanStatusCode()));
existingEntity.setPlanFiscalStatusCode(
Expand Down Expand Up @@ -281,4 +285,8 @@ public ProjectFiscalEntity updateEntity(ProjectFiscalModel projectFiscalModel, P
private <T> T nonNullOrDefault(T newValue, T existingValue) {
return newValue != null ? newValue : existingValue;
}

private boolean isValidUuid(String uuid) {
return uuid != null && !uuid.trim().isEmpty();
}
}

0 comments on commit bf3e5a4

Please sign in to comment.