Skip to content

Commit

Permalink
feat(deliverables): Map to IPI 2.3 when sub category is selected #2415
Browse files Browse the repository at this point in the history
Map deliverables to IPI 2.3 when:
- Capdev sub category is selected
- The deliverable has trainees
  • Loading branch information
kenjitm committed Aug 2, 2022
1 parent 3b4e72a commit e62252c
Showing 1 changed file with 58 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,11 @@ public void prepare() throws Exception {
.collect(Collectors.toList());

if (deList != null && !deList.isEmpty()) {
Collections.sort(deList, (p1, p2) -> p1.getInstitution().getId().compareTo(p2.getInstitution().getId()));
try {
Collections.sort(deList, (p1, p2) -> p1.getInstitution().getId().compareTo(p2.getInstitution().getId()));
} catch (Exception e) {
logger.error("unable to sort dlist", e);
}
deliverable.setResponsiblePartnership(new ArrayList<>());
for (DeliverableUserPartnership deliverableUserPartnership : deList) {

Expand Down Expand Up @@ -1401,7 +1405,11 @@ public void prepare() throws Exception {
.collect(Collectors.toList());

if (deList != null && !deList.isEmpty()) {
Collections.sort(deList, (p1, p2) -> p1.getInstitution().getId().compareTo(p2.getInstitution().getId()));
try {
Collections.sort(deList, (p1, p2) -> p1.getInstitution().getId().compareTo(p2.getInstitution().getId()));
} catch (Exception e) {
logger.error("unable to sort dlist", e);
}
deliverable.setOtherPartnerships(new ArrayList<>());
for (DeliverableUserPartnership deliverableUserPartnership : deList) {

Expand Down Expand Up @@ -2153,9 +2161,48 @@ public void saveCrossCutting() {
* @param phase
*/
public void saveCrpOutcomes(Deliverable deliverable, Phase phase) {
// Get the IPI 2.3 object
CrpProgramOutcome crpProgramOutcomeIPI = new CrpProgramOutcome();
boolean uniqueIPI = true;
boolean addIPI = false;
try {

// Check deliverable type
if ((deliverable.getDeliverableInfo() != null && deliverable.getDeliverableInfo().getDeliverableType() != null
&& deliverable.getDeliverableInfo().getDeliverableType().getId() == 145)
|| (deliverable.getDeliverableParticipant() != null
&& deliverable.getDeliverableParticipant().getHasParticipants() != null
&& deliverable.getDeliverableParticipant().getHasParticipants())) {
addIPI = true;
}

if (addIPI) {

if (programOutcomes != null && !programOutcomes.isEmpty()) {
crpProgramOutcomeIPI =
programOutcomes.stream().filter(o -> o.getAcronym() != null && o.getAcronym().equals("IPI 2.3"))
.collect(Collectors.toList()).get(0);
}

// Check if deliverable is already mapped to IPI 2.3 object
if (deliverable.getCrpOutcomes() != null && !deliverable.getCrpOutcomes().isEmpty()) {
for (DeliverableCrpOutcome deliverableOutcome : deliverable.getCrpOutcomes()) {
if (crpProgramOutcomeIPI != null && crpProgramOutcomeIPI.getId() != null
&& deliverableOutcome.getCrpProgramOutcome() != null
&& deliverableOutcome.getCrpProgramOutcome().getId() != null
&& deliverableOutcome.getCrpProgramOutcome().getId().equals(crpProgramOutcomeIPI.getId())) {
uniqueIPI = false;
}
}
}
}
} catch (Exception e) {
logger.error("unable to map IPI 2.3", e);
}


// Search and deleted form Information
if (deliverable.getDeliverableCrpOutcomes() != null && deliverable.getDeliverableCrpOutcomes().size() > 0) {
if (deliverable.getDeliverableCrpOutcomes() != null && !deliverable.getDeliverableCrpOutcomes().isEmpty()) {

List<DeliverableCrpOutcome> outcomePrev = new ArrayList<>(deliverable.getDeliverableCrpOutcomes().stream()
.filter(nu -> nu.getPhase().getId().equals(phase.getId())).collect(Collectors.toList()));
Expand All @@ -2171,6 +2218,14 @@ public void saveCrpOutcomes(Deliverable deliverable, Phase phase) {

// Save form Information
if (this.deliverable.getCrpOutcomes() != null) {

if (uniqueIPI && addIPI) {
DeliverableCrpOutcome deliverableCrpOutcome = new DeliverableCrpOutcome();
deliverableCrpOutcome.setDeliverable(deliverable);
deliverableCrpOutcome.setCrpProgramOutcome(crpProgramOutcomeIPI);
this.deliverable.getCrpOutcomes().add(deliverableCrpOutcome);
}

for (DeliverableCrpOutcome deliverableOutcome : this.deliverable.getCrpOutcomes()) {
if (deliverableOutcome != null && deliverableOutcome.getId() == null) {
DeliverableCrpOutcome deliverableOutcomeSave = new DeliverableCrpOutcome();
Expand Down

0 comments on commit e62252c

Please sign in to comment.