Skip to content

Commit

Permalink
Merge branch 'aiccra-shfrm-contribution-functionality' into aiccra-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Feb 16, 2024
2 parents e782c63 + 6d4623f commit 067df4e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 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 @@ -2448,6 +2484,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
Original file line number Diff line number Diff line change
Expand Up @@ -2469,15 +2469,17 @@ private void saveReferences(ProjectExpectedStudy projectExpectedStudy, Phase pha
// auditlog.
this.expectedStudy.getProjectExpectedStudyReferences().add(studyReferenceSave);
} else {
ProjectExpectedStudyReference studyReferenceSave =
this.projectExpectedStudyReferenceManager.getProjectExpectedStudyReferenceById(studyReference.getId());
studyReferenceSave.setProjectExpectedStudy(projectExpectedStudy);
studyReferenceSave.setPhase(phase);
studyReferenceSave.setReference(studyReference.getReference());
studyReferenceSave.setLink(studyReference.getLink());
studyReferenceSave.setExternalAuthor(studyReference.getExternalAuthor());

try {
ProjectExpectedStudyReference studyReferenceSave =
this.projectExpectedStudyReferenceManager.getProjectExpectedStudyReferenceById(studyReference.getId());
if (studyReferenceSave != null && projectExpectedStudy != null) {
studyReferenceSave.setProjectExpectedStudy(projectExpectedStudy);
studyReferenceSave.setPhase(phase);
studyReferenceSave.setReference(studyReference.getReference());
studyReferenceSave.setLink(studyReference.getLink());
studyReferenceSave.setExternalAuthor(studyReference.getExternalAuthor());
}

this.projectExpectedStudyReferenceManager.saveProjectExpectedStudyReference(studyReferenceSave);
// This is to add studyReferenceSave to generate correct
// auditlog.
Expand Down

0 comments on commit 067df4e

Please sign in to comment.