Skip to content

Commit

Permalink
MAT-6487 refactored the code
Browse files Browse the repository at this point in the history
  • Loading branch information
sb-prateekkeerthi committed Sep 18, 2024
1 parent c2046b9 commit 7bba303
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ public ResponseEntity<Measure> correctMeasureVersion(
measureToCorrectVersion.setVersion(newDraftVersion);
measureToCorrectVersion.getMeasureMetaData().setDraft(true);

deleteRelevantPackageData(id, measureToCorrectVersion);

Measure correctedVersionMeasure = measureRepository.save(measureToCorrectVersion);
actionLogService.logAction(id, Measure.class, ActionType.UPDATED, principal.getName());
return ResponseEntity.ok(correctedVersionMeasure);
}

private void deleteRelevantPackageData(String id, Measure measureToCorrectVersion) {
// QI-Core measure: delete the export
// QDM Measures: delete the export and cqmMeasure
Export export = exportRepository.findByMeasureId(id).orElse(null);
Expand All @@ -252,10 +260,6 @@ public ResponseEntity<Measure> correctMeasureVersion(
cqmMeasureRepository.delete(cqmMeasure);
}
}

Measure correctedVersionMeasure = measureRepository.save(measureToCorrectVersion);
actionLogService.logAction(id, Measure.class, ActionType.UPDATED, principal.getName());
return ResponseEntity.ok(correctedVersionMeasure);
}

private boolean checkIfVersionIsAlreadyAssociated(
Expand Down

0 comments on commit 7bba303

Please sign in to comment.