diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java index 9f0b60f7be..0466512173 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java @@ -794,6 +794,7 @@ public final class APConstants { public static final String IGNORE_NEWER_YEARS = "ignoreNewer"; public static final String DELIVERABLE_CRP_PROGRAM_OUTCOME_DEPRECATED = "DEPRECATED"; + public static final String CRP_PROGRAM_OUTCOME_DEPRECATED = "DEPRECATED"; public static final int EXPECTED_OTHER_ALLIANCE_LEVER_ID = 9; diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableInfoDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableInfoDAO.java index ededd96694..31aab0d658 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableInfoDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableInfoDAO.java @@ -62,6 +62,13 @@ public interface DeliverableInfoDAO { public List getDeliverablesInfoByPhase(Phase phase); + /** + * This method gets a list of DeliverableInfo that are active by a given phase, project and status + * + * @return a list from DeliverableInfo null if no exist records + */ + public List getDeliverablesInfoByPhaseProjectAndStatus(Phase phase, long projectId, long statusId); + /** * This method gets a list of DeliverableInfo that are active by a given phase and project * diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableInfoMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableInfoMySQLDAO.java index ace6be6828..5194b3eab6 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableInfoMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableInfoMySQLDAO.java @@ -126,6 +126,36 @@ public List getDeliverablesInfoByPhase(Phase phase) { return deliverableInfos; } + @Override + public List getDeliverablesInfoByPhaseProjectAndStatus(Phase phase, long projectId, long statusId) { + + StringBuilder query = new StringBuilder(); + query.append("SELECT DISTINCT "); + query.append("di.id as id "); + query.append("FROM "); + query.append("deliverables_info AS di "); + query.append("INNER JOIN deliverables AS d ON d.id = di.deliverable_id "); + query.append("WHERE d.is_active = 1 AND "); + query.append("d.project_id IS NOT NULL AND "); + query.append("di.is_active = 1 AND "); + query.append("di.`id_phase` =" + phase.getId()); + query.append(" AND d.project_id =" + projectId); + query.append(" AND di.status !=" + statusId); + + List> rList = super.findCustomQuery(query.toString()); + List deliverableInfos = new ArrayList<>(); + + if (rList != null) { + for (Map map : rList) { + DeliverableInfo deliverableInfo = this.find(Long.parseLong(map.get("id").toString())); + deliverableInfos.add(deliverableInfo); + } + } + + return deliverableInfos; + } + + @Override public List getDeliverablesInfoByProjectAndPhase(Phase phase, Project project) { StringBuilder query = new StringBuilder(); diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableInfoManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableInfoManager.java index 0073db0017..2917346f62 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableInfoManager.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableInfoManager.java @@ -66,6 +66,13 @@ public interface DeliverableInfoManager { public List getDeliverablesInfoByPhase(Phase phase); + /** + * This method gets a list of DeliverableInfo that are active by a given phase, project and status + * + * @return a list from DeliverableInfo null if no exist records + */ + public List getDeliverablesInfoByPhaseProjectAndStatus(Phase phase, long projectId, long statusId); + /** * This method gets a list of DeliverableInfo that are active by a given phase and type * @@ -80,6 +87,7 @@ public interface DeliverableInfoManager { */ List getDeliverablesInfoByProjectAndPhaseWithSharedProjects(Phase phase, Project project); + /** * This method gets a list of DeliverableInfo that are active by a given phase and type * @@ -87,7 +95,6 @@ public interface DeliverableInfoManager { */ public List getDeliverablesInfoByType(Phase phase, DeliverableType deliverableType); - public boolean isDeliverableSubcategoryIncludedWebsite(long deliverableID, Phase phase); diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableActivityManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableActivityManagerImpl.java index 74c4ded77f..dac200b3c1 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableActivityManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableActivityManagerImpl.java @@ -15,11 +15,15 @@ package org.cgiar.ccafs.marlo.data.manager.impl; +import org.cgiar.ccafs.marlo.config.APConstants; import org.cgiar.ccafs.marlo.data.dao.DeliverableActivityDAO; +import org.cgiar.ccafs.marlo.data.dao.PhaseDAO; import org.cgiar.ccafs.marlo.data.manager.DeliverableActivityManager; import org.cgiar.ccafs.marlo.data.model.DeliverableActivity; +import org.cgiar.ccafs.marlo.data.model.Phase; import java.util.List; +import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Named; @@ -32,20 +36,60 @@ public class DeliverableActivityManagerImpl implements DeliverableActivityManage private DeliverableActivityDAO deliverableActivityDAO; + private PhaseDAO phaseDAO; // Managers @Inject - public DeliverableActivityManagerImpl(DeliverableActivityDAO deliverableActivityDAO) { + public DeliverableActivityManagerImpl(DeliverableActivityDAO deliverableActivityDAO, PhaseDAO phaseDAO) { this.deliverableActivityDAO = deliverableActivityDAO; + this.phaseDAO = phaseDAO; } @Override public void deleteDeliverableActivity(long deliverableActivityId) { + DeliverableActivity deliverableActivity = this.getDeliverableActivityById(deliverableActivityId); + + // Conditions to Project Innovation Works In AR phase and Upkeep Phase + if (deliverableActivity.getPhase().getDescription().equals(APConstants.PLANNING) + && deliverableActivity.getPhase().getNext() != null) { + this.deleteDeliverableActivityPhase(deliverableActivity.getPhase().getNext(), + deliverableActivity.getDeliverable().getId(), deliverableActivity); + } + + if (deliverableActivity.getPhase().getDescription().equals(APConstants.REPORTING) + && deliverableActivity.getPhase().getNext() != null + && deliverableActivity.getPhase().getNext().getNext() != null) { + Phase upkeepPhase = deliverableActivity.getPhase().getNext().getNext(); + if (upkeepPhase != null) { + this.deleteDeliverableActivityPhase(upkeepPhase, deliverableActivity.getDeliverable().getId(), + deliverableActivity); + } + } + deliverableActivityDAO.deleteDeliverableActivity(deliverableActivityId); } + public void deleteDeliverableActivityPhase(Phase next, long deliverableID, DeliverableActivity deliverableActivity) { + Phase phase = phaseDAO.find(next.getId()); + + List activityPrev = + deliverableActivityDAO.getDeliverableActivitiesByDeliverableIDAndPhase(deliverableID, phase.getId()).stream() + .filter( + r -> r.getActivity() != null && r.getActivity().getId() != null && deliverableActivity.getActivity() != null + && r.getActivity().getId().equals(deliverableActivity.getActivity().getId())) + .collect(Collectors.toList()); + + for (DeliverableActivity deliverableActivityDB : activityPrev) { + deliverableActivityDAO.deleteDeliverableActivity(deliverableActivityDB.getId()); + } + + if (phase.getNext() != null) { + this.deleteDeliverableActivityPhase(phase.getNext(), deliverableID, deliverableActivity); + } + } + @Override public boolean existDeliverableActivity(long deliverableActivityID) { @@ -84,7 +128,47 @@ public DeliverableActivity getDeliverableActivityById(long deliverableActivityID @Override public DeliverableActivity saveDeliverableActivity(DeliverableActivity deliverableActivity) { - return deliverableActivityDAO.save(deliverableActivity); + DeliverableActivity activity = deliverableActivityDAO.save(deliverableActivity); + Phase phase = phaseDAO.find(activity.getPhase().getId()); + + // Conditions to Project Innovation Works In AR phase and Upkeep Phase + if (phase.getDescription().equals(APConstants.PLANNING) && phase.getNext() != null) { + this.saveDeliverableActivityPhase(activity.getPhase().getNext(), activity.getDeliverable().getId(), + deliverableActivity); + } + + if (phase.getDescription().equals(APConstants.REPORTING)) { + if (phase.getNext() != null && phase.getNext().getNext() != null) { + Phase upkeepPhase = phase.getNext().getNext(); + if (upkeepPhase != null) { + this.saveDeliverableActivityPhase(upkeepPhase, activity.getDeliverable().getId(), deliverableActivity); + } + } + } + return activity; + } + + private void saveDeliverableActivityPhase(Phase next, Long deliverableID, DeliverableActivity deliverableActivity) { + Phase phase = phaseDAO.find(next.getId()); + + List deliverableActivityPrev = + deliverableActivityDAO.getDeliverableActivitiesByDeliverableIDAndPhase(deliverableID, phase.getId()).stream() + .filter( + r -> r.getActivity() != null && r.getActivity().getId() != null && deliverableActivity.getActivity() != null + && r.getActivity().getId().equals(deliverableActivity.getActivity().getId())) + .collect(Collectors.toList()); + + if (deliverableActivityPrev.isEmpty()) { + DeliverableActivity deliverableActivitysAdd = new DeliverableActivity(); + deliverableActivitysAdd.setDeliverable(deliverableActivity.getDeliverable()); + deliverableActivitysAdd.setPhase(phase); + deliverableActivitysAdd.setActivity(deliverableActivity.getActivity()); + deliverableActivitysAdd.setId(null); + deliverableActivityDAO.save(deliverableActivitysAdd); + } + if (phase.getNext() != null) { + this.saveDeliverableActivityPhase(phase.getNext(), deliverableID, deliverableActivity); + } } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableInfoManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableInfoManagerImpl.java index 5d53786d96..c6a381dd7b 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableInfoManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableInfoManagerImpl.java @@ -99,6 +99,12 @@ public List getDeliverablesInfoByPhase(Phase phase) { return deliverableInfoDAO.getDeliverablesInfoByPhase(phase); } + @Override + public List getDeliverablesInfoByPhaseProjectAndStatus(Phase phase, long projectId, long statusId) { + return deliverableInfoDAO.getDeliverablesInfoByPhaseProjectAndStatus(phase, projectId, statusId); + } + + @Override public List getDeliverablesInfoByProjectAndPhase(Phase phase, Project project) { return deliverableInfoDAO.getDeliverablesInfoByProjectAndPhase(phase, project); @@ -116,7 +122,6 @@ public List getDeliverablesInfoByType(Phase phase, DeliverableT return deliverableInfoDAO.getDeliverablesInfoByType(phase, deliverableType); } - @Override public boolean isDeliverableSubcategoryIncludedWebsite(long deliverableID, Phase phase) { diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java index 658dbd48bb..2816c31d2b 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java @@ -658,22 +658,40 @@ public String getInnovationsComposedName() { } try { - handle = deliverableTemp.getDeliverableMetadataElements().stream() - .filter(me -> me != null && me.getMetadataElement() != null && me.getMetadataElement().getId() != null - && me.getMetadataElement().getId().longValue() == 35L && me.getDeliverable().getId().equals(this.getId()) - && !StringUtils.isBlank(me.getElementValue())) - .findFirst().orElse(null).getElementValue(); - if (handle == null || handle.isEmpty()) { - handle = "Not defined"; + if (deliverableTemp.getDeliverableMetadataElements() != null && this.getDeliverableInfo().getPhase() != null) { + deliverableTemp.setMetadataElements(new ArrayList<>(deliverableTemp.getDeliverableMetadataElements().stream() + .filter(c -> c.isActive() && c.getPhase().equals(this.getDeliverableInfo().getPhase()) + && c.getMetadataElement() != null && c.getMetadataElement().getId() != null + && c.getMetadataElement().getId().longValue() == 35L && c.getDeliverable().getId().equals(this.getId()) + && !StringUtils.isBlank(c.getElementValue())) + .collect(Collectors.toList()))); + if (deliverableTemp.getMetadataElements() != null && deliverableTemp.getMetadataElements().get(0) != null + && deliverableTemp.getMetadataElements().get(0).getElementValue() != null + && !deliverableTemp.getMetadataElements().get(0).getElementValue().isEmpty()) { + handle = "

Handle: " + + deliverableTemp.getMetadataElements().get(0).getElementValue(); + } } - } catch (Exception e) { // error } try { + + if (deliverableTemp.getDeliverableDisseminations() != null) { + deliverableTemp.setDisseminations(new ArrayList<>(deliverableTemp.getDeliverableDisseminations().stream() + .filter(c -> c.isActive() && c.getPhase().equals(this.getDeliverableInfo().getPhase())) + .collect(Collectors.toList()))); + if (!deliverableTemp.getDisseminations().isEmpty()) { + deliverableTemp.setDissemination(deliverableTemp.getDisseminations().get(0)); + } else { + deliverableTemp.setDissemination(new DeliverableDissemination()); + } + } if (deliverableTemp.getDissemination() != null - && deliverableTemp.getDissemination().getDisseminationChannelName() != null) { - disseminationChannel = deliverableTemp.getDissemination().getDisseminationChannelName(); + && deliverableTemp.getDissemination().getDisseminationChannelName() != null + && !deliverableTemp.getDissemination().getDisseminationChannelName().isEmpty()) { + disseminationChannel = " (" + deliverableTemp.getDissemination().getDisseminationChannelName() + ")"; } } catch (Exception e) { // error @@ -735,9 +753,8 @@ public String getInnovationsComposedName() { statusInfo = statusInfo.trim(); } return "

"; + + this.getDeliverableInfo().getTitle() + disseminationChannel + "

" + handle + "

" + + "Type: " + deliverableType + "" + ""; } catch (Exception e) { return " (D" + this.getId() + ") - " + this.getDeliverableInfo().getTitle(); diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index a1d32fa411..bcf1dd2319 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -3052,9 +3052,13 @@ public void saveDataSharing() { private void saveDeliverableActivities(Deliverable deliverablePrew) { if (deliverable.getActivities() != null) { if (deliverablePrew.getDeliverableActivities() != null && !deliverablePrew.getDeliverableActivities().isEmpty()) { - List activityPrew = deliverablePrew.getDeliverableActivities().stream() - .filter(dp -> dp.isActive() && dp.getPhase() != null && dp.getPhase().equals(this.getActualPhase())) - .collect(Collectors.toList()); + /* + * List activityPrew = deliverablePrew.getDeliverableActivities().stream() + * .filter(dp -> dp.isActive() && dp.getPhase() != null && dp.getPhase().equals(this.getActualPhase())) + * .collect(Collectors.toList()); + */ + List activityPrew = deliverableActivityManager + .getDeliverableActivitiesByDeliverableIDAndPhase(deliverableID, this.getActualPhase().getId()); for (DeliverableActivity deliverableActivity : activityPrew) { if (!deliverable.getActivities().contains(deliverableActivity)) { @@ -3064,15 +3068,17 @@ private void saveDeliverableActivities(Deliverable deliverablePrew) { } for (DeliverableActivity deliverableActivity : deliverable.getActivities()) { - if (deliverableActivity.getId() == null || deliverableActivity.getId() == -1) { - - deliverableActivity.setDeliverable(deliverableManager.getDeliverableById(deliverableID)); - deliverableActivity.setPhase(this.getActualPhase()); - deliverableActivityManager.saveDeliverableActivity(deliverableActivity); - // This add projectFocus to generate correct auditlog. - deliverablePrew.getDeliverableActivities().add(deliverableActivity); + if (deliverableActivity.getId() != null && deliverableActivity.getId() != -1) { + deliverableActivity = deliverableActivityManager.getDeliverableActivityById(deliverableActivity.getId()); } + + deliverableActivity.setDeliverable(deliverableManager.getDeliverableById(deliverableID)); + deliverableActivity.setPhase(this.getActualPhase()); + deliverableActivityManager.saveDeliverableActivity(deliverableActivity); + // This add projectFocus to generate correct auditlog. + deliverablePrew.getDeliverableActivities().add(deliverableActivity); } + } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectInnovationAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectInnovationAction.java index da2b7283ee..980d41eb71 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectInnovationAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectInnovationAction.java @@ -22,6 +22,7 @@ import org.cgiar.ccafs.marlo.data.manager.AuditLogManager; import org.cgiar.ccafs.marlo.data.manager.CrpMilestoneManager; import org.cgiar.ccafs.marlo.data.manager.CrpProgramOutcomeManager; +import org.cgiar.ccafs.marlo.data.manager.DeliverableInfoManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableTypeManager; import org.cgiar.ccafs.marlo.data.manager.FeedbackQACommentManager; @@ -170,6 +171,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import javax.inject.Inject; @@ -270,6 +272,7 @@ public static void setIsSaving(HashMap isSaving) { private ProjectInnovationToolCategoryManager projectInnovationToolCategoryManager; private ToolFunctionCategoryManager toolFunctionCategoryManager; private DeliverableTypeManager deliverableTypeManager; + private DeliverableInfoManager deliverableInfoManager; // Variables private long projectID; private long innovationID; @@ -382,7 +385,8 @@ public ProjectInnovationAction(APConfig config, GlobalUnitManager globalUnitMana ProjectInnovationActorManager projectInnovationActorManager, ToolFunctionCategoryManager toolFunctionCategoryManager, ProjectInnovationToolCategoryManager projectInnovationToolCategoryManager, - DeliverableTypeManager deliverableTypeManager, InstitutionLocationManager institutionLocationManager) { + DeliverableTypeManager deliverableTypeManager, InstitutionLocationManager institutionLocationManager, + DeliverableInfoManager deliverableInfoManager) { super(config); this.projectInnovationManager = projectInnovationManager; this.globalUnitManager = globalUnitManager; @@ -453,6 +457,7 @@ public ProjectInnovationAction(APConfig config, GlobalUnitManager globalUnitMana this.projectInnovationToolCategoryManager = projectInnovationToolCategoryManager; this.deliverableTypeManager = deliverableTypeManager; this.institutionLocationManager = institutionLocationManager; + this.deliverableInfoManager = deliverableInfoManager; } @@ -1523,6 +1528,9 @@ public void prepare() throws Exception { // Default name (only the institution name) String defaultName = contributingPartner.getName(); + if (contributingPartner.getAcronym() != null && !contributingPartner.getAcronym().isEmpty()) { + defaultName = contributingPartner.getAcronym() + " - " + defaultName; + } // Assign nameWithCountry if it is null or does not contain the country name if (contributingPartner.getName() != null || !contributingPartner.getName().contains(tempName)) { @@ -1557,25 +1565,29 @@ public void prepare() throws Exception { } } + + // cgamboa 15/12/2024 function locElementManager.findAll() will be used once time + List listLocElementPrevious = locElementManager.findAll(); + // Getting The list of countries - countries = locElementManager.findAll().stream().filter(c -> c.getLocElementType().getId().intValue() == 2) + countries = listLocElementPrevious.stream().filter(c -> c.getLocElementType().getId().intValue() == 2) .collect(Collectors.toList()); // Getting the list of institution institutions = institutionManager.findAll().stream().collect(Collectors.toList()); // Regions for Geographic Scope Regional Selection - regions = locElementManager.findAll().stream() + regions = listLocElementPrevious.stream() .filter(c -> c.getLocElementType().getId().intValue() == 1 && c.isActive() && c.getIsoNumeric() != null) .collect(Collectors.toList()); phaseResearchList = repIndPhaseResearchPartnershipManager.findAll(); stageInnovationList = repIndStageInnovationManager.findAll(); geographicScopeList = repIndGeographicScopeManager.findAll(); + try { if (geographicScopeList != null && !geographicScopeList.isEmpty()) { - geographicScopeList = geographicScopeList.stream().sorted(Comparator.comparing(RepIndGeographicScope::getId)) - .collect(Collectors.toList()); + RepIndGeographicScope geographicDelete; // Remove multi-national geographicDelete = repIndGeographicScopeManager.getRepIndGeographicScopeById(3); @@ -1583,14 +1595,18 @@ public void prepare() throws Exception { geographicScopeList.remove(geographicDelete); } // Remove sub-national - geographicDelete = repIndGeographicScopeManager.getRepIndGeographicScopeById(6); + geographicDelete = repIndGeographicScopeManager.getRepIndGeographicScopeById(5); if (geographicDelete != null) { geographicScopeList.remove(geographicDelete); } + + geographicScopeList = geographicScopeList.stream().sorted(Comparator.comparing(RepIndGeographicScope::getId)) + .collect(Collectors.toList()); } } catch (Exception e) { Log.error("error deleting elements from " + e); } + innovationTypeList = repIndInnovationTypeManager.findAll(); innovationNatureList = repIndInnovationNatureManager.findAll(); focusLevelList = focusLevelManager.findAll(); @@ -1669,15 +1685,27 @@ public void prepare() throws Exception { } } - if (phase != null && phase.getDeliverableInfos() != null && project != null - && !phase.getDeliverableInfos().isEmpty()) { - List infos = phase.getDeliverableInfos().stream() - .filter(c -> c != null && c.getDeliverable() != null && c.getDeliverable().getProject() != null - && c.getDeliverable().getProject().equals(project) && c.getDeliverable().isActive() - && c.getDeliverable().getDeliverableInfo(this.getActualPhase()) != null - && c.getDeliverable().getDeliverableInfo(this.getActualPhase()).getStatus() != null - && c.getDeliverable().getDeliverableInfo(this.getActualPhase()).getStatus() != 5) - .collect(Collectors.toList()); + Set deliverableInfos = phase.getDeliverableInfos(); + if (phase != null && deliverableInfos != null && project != null && !deliverableInfos.isEmpty()) { + /* + * List infos = phase.getDeliverableInfos().stream() + * .filter(c -> c != null && c.getDeliverable() != null && c.getDeliverable().getProject() != null + * && c.getDeliverable().getProject().equals(project) && c.getDeliverable().isActive() + * && c.getDeliverable().getDeliverableInfo(this.getActualPhase()) != null + * && c.getDeliverable().getDeliverableInfo(this.getActualPhase()).getStatus() != null + * && c.getDeliverable().getDeliverableInfo(this.getActualPhase()).getStatus() != 5) + * .collect(Collectors.toList()); + */ + // 16/12/2024 cgamboa the query was reduced + List infos = new ArrayList<>(); + try { + + infos = this.deliverableInfoManager.getDeliverablesInfoByPhaseProjectAndStatus(phase, project.getId(), 5L) + .stream().filter(c -> c != null).collect(Collectors.toList()); + } catch (Exception e) { + logger.error(" unable to get deliverable info " + e.getMessage()); + } + deliverableList = new ArrayList<>(); for (DeliverableInfo deliverableInfo : infos) { Deliverable deliverable = deliverableInfo.getDeliverable(); @@ -1734,20 +1762,31 @@ public void prepare() throws Exception { } } - + Set deliverableInfosShared = phase.getDeliverableInfos(); // Get deliverable list for shared innovations projects if (projectSharedList != null && !projectSharedList.isEmpty()) { for (Project projectInnovationShared : projectSharedList) { - if (phase != null && phase.getDeliverableInfos() != null && projectInnovationShared != null - && !phase.getDeliverableInfos().isEmpty()) { - List infos = phase.getDeliverableInfos().stream() - .filter(c -> c != null && c.getDeliverable() != null && c.getDeliverable().getProject() != null - && c.getDeliverable().getProject().equals(projectInnovationShared) && c.getDeliverable().isActive() - && c.getDeliverable().getDeliverableInfo(this.getActualPhase()) != null - && c.getDeliverable().getDeliverableInfo(this.getActualPhase()).getStatus() != null - && c.getDeliverable().getDeliverableInfo(this.getActualPhase()).getStatus() != 5) - .collect(Collectors.toList()); - + if (phase != null && deliverableInfosShared != null && projectInnovationShared != null + && !deliverableInfosShared.isEmpty()) { + /* + * 16/12/2024 cgamboa the query was reduced + * List infos = phase.getDeliverableInfos().stream() + * .filter(c -> c != null && c.getDeliverable() != null && c.getDeliverable().getProject() != null + * && c.getDeliverable().getProject().equals(projectInnovationShared) && c.getDeliverable().isActive() + * && c.getDeliverable().getDeliverableInfo(this.getActualPhase()) != null + * && c.getDeliverable().getDeliverableInfo(this.getActualPhase()).getStatus() != null + * && c.getDeliverable().getDeliverableInfo(this.getActualPhase()).getStatus() != 5) + * .collect(Collectors.toList()); + */ + List infos = new ArrayList<>(); + try { + + infos = this.deliverableInfoManager + .getDeliverablesInfoByPhaseProjectAndStatus(phase, projectInnovationShared.getId(), 5L).stream() + .filter(c -> c != null).collect(Collectors.toList()); + } catch (Exception e) { + logger.error(" unable to get deliverable info " + e.getMessage()); + } for (DeliverableInfo deliverableInfo : infos) { Deliverable deliverable = deliverableInfo.getDeliverable(); deliverable.setDeliverableInfo(deliverableInfo); @@ -1841,7 +1880,9 @@ public void prepare() throws Exception { m -> m != null && m.isActive() && m.getYear() != 0 && m.getYear() <= this.getActualPhase().getYear()) .collect(Collectors.toList())); - if (!this.crpOutcomes.contains(projectOutcome.getCrpProgramOutcome())) { + if (!this.crpOutcomes.contains(projectOutcome.getCrpProgramOutcome()) + && projectOutcome.getCrpProgramOutcome().getDescription() != null && !projectOutcome.getCrpProgramOutcome() + .getDescription().contains(APConstants.CRP_PROGRAM_OUTCOME_DEPRECATED)) { this.crpOutcomes.add(projectOutcome.getCrpProgramOutcome()); } @@ -1918,13 +1959,6 @@ public void prepare() throws Exception { && f.getField().getId() != null && f.getField().getId().equals(field.getId())) .collect(Collectors.toList()); - /* - * comments = feedbackQACommentManager.findAll().stream() - * .filter(f -> f != null && f.getPhase() != null && f.getPhase().getId() != null - * && f.getPhase().getId().equals(this.getActualPhase().getId()) && f.getParentId() == innovation.getId() - * && f.getField() != null && f.getField().getId() != null && f.getField().getId().equals(field.getId())) - * .collect(Collectors.toList()); - */ field.setQaComments(comments); } } @@ -3997,6 +4031,7 @@ public void validate() { validator.validate(this, project, innovation, clearLead, true, true, this.getActualPhase().getYear(), this.getActualPhase().getUpkeep()); } + } public void validateTabs() { diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java index ba19074ce1..ce0120c7c7 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java @@ -869,6 +869,7 @@ public final class APConstants { public static final String IGNORE_NEWER_YEARS = "ignoreNewer"; public static final String DELIVERABLE_CRP_PROGRAM_OUTCOME_DEPRECATED = "DEPRECATED"; + public static final String CRP_PROGRAM_OUTCOME_DEPRECATED = "DEPRECATED"; public static final int EXPECTED_OTHER_ALLIANCE_LEVER_ID = 9; diff --git a/marlo-web/src/main/resources/custom/aicrra.properties b/marlo-web/src/main/resources/custom/aicrra.properties index 7d5610a2e0..2d7a37c463 100644 --- a/marlo-web/src/main/resources/custom/aicrra.properties +++ b/marlo-web/src/main/resources/custom/aicrra.properties @@ -4358,7 +4358,7 @@ projectInnovations.stage=Stage of innovation projectInnovations.contributingCenters=Contributing Centers/Managing partners projectInnovations.geographicScope=Geographic Scope projectInnovations.geographicImpact=Select the countries/regions that falls within the Innovation's scope -projectInnovations.geographicScopeTopic=Select the is the main geographic focus of the output. +projectInnovations.geographicScopeTopic=Select the is the main geographic focus of the output projectInnovations.innovationType=Innovation type projectInnovations.innovationType.helpText=Select one of the options from the available drop-down list and follow their description to better categorize the innovation that is being reported projectInnovations.innovationNature=Innovation nature @@ -4396,6 +4396,7 @@ projectInnovations.stageDescription=Description of Stage reached projectInnovations.adaptativeResearch=Novel or adaptive research projectInnovations.leadOrganization=Name of lead organization/entity to take innovation to this stage projectInnovations.contributingOrganizations=Contributing external partners +projectInnovations.contributingOrganizations.help=Please select the key external partners who have significantly contributed to the reported outcome or impact. Include the affiliation for individuals, if known. projectInnovations.contributingCenters=Contributing Centers/Managing partners projectInnovations.stageDescription.readText=Description of Stage reached projectInnovations.stageDescription.help=Please provide a short description/explanation of the completed Stage diff --git a/marlo-web/src/main/resources/global.properties b/marlo-web/src/main/resources/global.properties index 70282cd16b..e0ea1146b6 100644 --- a/marlo-web/src/main/resources/global.properties +++ b/marlo-web/src/main/resources/global.properties @@ -4448,7 +4448,7 @@ projectInnovations.stage=Stage of innovation projectInnovations.contributingCenters=Contributing Centers/Managing partners projectInnovations.geographicScope=Geographic Scope projectInnovations.geographicImpact=Select the countries/regions that falls within the Innovation's scope -projectInnovations.geographicScopeTopic=Select the is the main geographic focus of the output. +projectInnovations.geographicScopeTopic=Select the is the main geographic focus of the output projectInnovations.innovationType=Innovation type projectInnovations.innovationType.helpText=Select one of the options from the available drop-down list and follow their description to better categorize the innovation that is being reported projectInnovations.innovationNature=Innovation nature @@ -4486,6 +4486,7 @@ projectInnovations.stageDescription=Description of Stage reached projectInnovations.adaptativeResearch=Novel or adaptive research projectInnovations.leadOrganization=Name of lead organization/entity to take innovation to this stage projectInnovations.contributingOrganizations=Contributing external partners +projectInnovations.contributingOrganizations.help=Please select the key external partners who have significantly contributed to the reported outcome or impact. Include the affiliation for individuals, if known. projectInnovations.contributingCenters=Contributing Centers/Managing partners projectInnovations.stageDescription.readText=Description of Stage reached projectInnovations.stageDescription.help=Please provide a short description/explanation of the completed Stage diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectInnovation.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectInnovation.ftl index ef12881553..90002a6134 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectInnovation.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectInnovation.ftl @@ -177,15 +177,6 @@ -[#include "/WEB-INF/global/pages/footer.ftl"] - -[#function findElementID list id] - [#list (list)![] as item] - [#if (item.repIndGeographicScope.id == id)!false][#return true][/#if] - [/#list] - [#return false] -[/#function] - [#-- Partner users TEMPLATE --] [/#list] - \ No newline at end of file + + +[#include "/WEB-INF/global/pages/footer.ftl"] + +[#function findElementID list id] + [#list (list)![] as item] + [#if (item.repIndGeographicScope.id == id)!false][#return true][/#if] + [/#list] + [#return false] +[/#function] \ No newline at end of file diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/forms.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/forms.ftl index 42d65ced62..b245efb84b 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/forms.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/forms.ftl @@ -568,7 +568,7 @@ [#macro checkBoxFlat id name label="" help="" paramText="" helpIcon=true disabled=false editable=true value="" checked=true cssClass="" cssClassLabel="" columns=0 ]
[#if editable] - +