Skip to content

Commit

Permalink
🔧 chore(shfrm Contribution): Update validations in shfrm save process…
Browse files Browse the repository at this point in the history
… when question change
  • Loading branch information
kenjitm committed Feb 16, 2024
1 parent 89d9f75 commit 6d4623f
Showing 1 changed file with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,42 @@ public Boolean candEditYear(long deliverableID) {

}

public void deleteAllActionsAndSubActions() {
try {
deliverable.getDeliverableInfo().setShfrmContributionNarrative(null);
List<DeliverableShfrmPriorityAction> actionPrev = deliverableShfrmPriorityActionManager
.findByDeliverableAndPhase(deliverable.getId(), this.getActualPhase().getId());

List<DeliverableShfrmSubAction> deliverableSubActions = new ArrayList<>();

if (actionPrev != null) {
for (DeliverableShfrmPriorityAction priorityAction : actionPrev) {
if (priorityAction != null && priorityAction.getId() != null) {

deliverableSubActions = deliverableShfrmSubActionManager
.findByPriorityActionAndPhase(priorityAction.getId(), this.getActualPhase().getId());

if (deliverableSubActions != null && !deliverableSubActions.isEmpty()) {

// delete sub actions
for (DeliverableShfrmSubAction deliverableSubActionDelete : deliverableSubActions) {
if (deliverableSubActionDelete != null && deliverableSubActionDelete.getId() != null) {
deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(deliverableSubActionDelete.getId());
}
}
}

// delete actions
deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(priorityAction.getId());
}
}
}

} catch (Exception e) {
logger.error("unable to delete priority action", e);
}
}

private void deleteDeliverableLocations(List<DeliverableLocation> locationsDB) {
if (locationsDB != null) {
for (DeliverableLocation deliverableLocation : locationsDB) {
Expand Down Expand Up @@ -726,6 +762,7 @@ public List<Activity> getActivities() {
return activities;
}


/**
* Get the ID of the clusterParticipantObject for this cluster in actual phase
*
Expand All @@ -752,7 +789,6 @@ public List<DeliverableQualityAnswer> getAnswers() {
return answers;
}


public List<DeliverableQualityAnswer> getAnswersDataDic() {
return answersDataDic;
}
Expand Down Expand Up @@ -894,6 +930,7 @@ public GlobalUnit getLoggedCrp() {
return loggedCrp;
}


public List<Project> getMyProjects() {
return myProjects;
}
Expand All @@ -903,7 +940,6 @@ public List<Institution> getPartnerInstitutions() {
return partnerInstitutions;
}


public List<ProjectPartnerPerson> getPartnerPersons() {
return partnerPersons;
}
Expand Down Expand Up @@ -2444,6 +2480,10 @@ public String save() {
if (this.hasSpecificities(APConstants.SHFRM_CONTRIBUTION_ACTIVE)) {
this.savePriorityActions(false);
this.saveSubActions();
if (deliverable.getDeliverableInfo() != null && (deliverable.getDeliverableInfo().getContributingShfrm() != null
&& deliverable.getDeliverableInfo().getContributingShfrm() == false)) {
this.deleteAllActionsAndSubActions();
}
}

/*
Expand Down

0 comments on commit 6d4623f

Please sign in to comment.