From 6b1a8ec5d338c95122282ba6ca5c05f367424325 Mon Sep 17 00:00:00 2001 From: Cristian Gamboa Date: Wed, 22 May 2024 11:50:32 -0500 Subject: [PATCH 1/5] :recycle: refactor(ProjectPartner): Improve performance of queries related to saving process of the section of partner .A2-569 --- .../ccafs/marlo/data/dao/DeliverableDAO.java | 6 + .../data/dao/mysql/DeliverableMySQLDAO.java | 121 ++++++++++++++++++ .../data/manager/DeliverableManager.java | 8 ++ .../manager/impl/DeliverableManagerImpl.java | 14 ++ .../marlo/data/model/DeliverableDTO.java | 52 ++++++++ .../action/projects/ProjectPartnerAction.java | 21 ++- .../crp/views/projects/projectPartners.ftl | 2 +- 7 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableDTO.java diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableDAO.java index 0d8165d887..31339f183e 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableDAO.java @@ -17,6 +17,7 @@ package org.cgiar.ccafs.marlo.data.dao; import org.cgiar.ccafs.marlo.data.model.Deliverable; +import org.cgiar.ccafs.marlo.data.model.DeliverableDTO; import org.cgiar.ccafs.marlo.data.model.DeliverableHomeDTO; import org.cgiar.ccafs.marlo.data.model.Phase; @@ -120,6 +121,11 @@ List getDeliverablesByPhaseAndUrlAndDoiAndHandel(long phase, String */ List getDeliverablesLeadByUserAndProject(long userId, long phaseId, long projectId); + List getDeliverablesLeadByUserAndProjectWithConditions(long userId, long phaseId, long projectId); + + List getDeliverablesLeadByUserAndProjectWithSimpleConditions(long userId, long phaseId, + long projectId); + List getDuplicatesDeliverablesByPhase(long phase); public List getPublicationsByPhase(long phase); diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableMySQLDAO.java index a1d49d4db6..2b15ba34c5 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableMySQLDAO.java @@ -18,6 +18,7 @@ import org.cgiar.ccafs.marlo.data.dao.DeliverableDAO; import org.cgiar.ccafs.marlo.data.model.Deliverable; +import org.cgiar.ccafs.marlo.data.model.DeliverableDTO; import org.cgiar.ccafs.marlo.data.model.DeliverableHomeDTO; import org.cgiar.ccafs.marlo.data.model.Phase; import org.cgiar.ccafs.marlo.data.model.ProjectStatusEnum; @@ -438,6 +439,126 @@ public List getDeliverablesLeadByUserAndProject(long userId, long p return deliverables; } + + @Override + public List getDeliverablesLeadByUserAndProjectWithConditions(long userId, long phaseId, + long projectId) { + StringBuilder query = new StringBuilder(); + query.append("SELECT DISTINCT "); + query.append("dup.deliverable_id as id "); + query.append("FROM "); + query.append("deliverable_user_partnerships AS dup "); + query.append("INNER JOIN deliverable_user_partnership_persons AS dupp ON dupp.user_partnership_id = dup.id "); + query.append(" inner join deliverables as d on dup.deliverable_id = d.id "); + query.append(" inner join deliverables_info di on di.deliverable_id = d.id "); + query.append(" inner join phases p on p.id = d.id_phase "); + query.append("WHERE "); + query.append("dupp.user_id =" + userId + " AND "); + query.append("dup.is_active = 1 AND "); + query.append("dupp.is_active = 1 AND "); + query.append(" dup.id_phase = d.id_phase AND "); + query.append("d.id_phase = di.id_phase AND "); + query.append("dup.id_phase =" + phaseId); + query.append(" and d.project_id =" + projectId); + query.append(" and di.status in (2,4) "); + query.append(" and d.is_active =1 "); + query.append(" and di.year >= p.year "); + query.append(" union "); + query.append("SELECT DISTINCT "); + query.append("dup.deliverable_id as id "); + query.append("FROM "); + query.append("deliverable_user_partnerships AS dup "); + query.append("INNER JOIN deliverable_user_partnership_persons AS dupp ON dupp.user_partnership_id = dup.id "); + query.append(" inner join deliverables as d on dup.deliverable_id = d.id "); + query.append(" inner join deliverables_info di on di.deliverable_id = d.id "); + query.append(" inner join phases p on p.id = d.id_phase "); + query.append("WHERE "); + query.append("dupp.user_id =" + userId + " AND "); + query.append("dup.is_active = 1 AND "); + query.append("dupp.is_active = 1 AND "); + query.append(" dup.id_phase = d.id_phase AND "); + query.append("d.id_phase = di.id_phase AND "); + query.append("dup.id_phase =" + phaseId); + query.append(" and d.project_id =" + projectId); + query.append(" and di.status in (4) "); + query.append(" and d.is_active =1 "); + query.append(" and di.new_expected_year >= p.year "); + + List> rList = super.findCustomQuery(query.toString()); + List deliverables = new ArrayList<>(); + + if (rList != null) { + for (Map map : rList) { + Deliverable deliverable = this.find(Long.parseLong(map.get("id").toString())); + deliverables.add(deliverable); + } + } + + return deliverables; + } + + + @Override + public List getDeliverablesLeadByUserAndProjectWithSimpleConditions(long userId, long phaseId, + long projectId) { + StringBuilder query = new StringBuilder(); + query.append("SELECT DISTINCT "); + query.append("dup.deliverable_id as id "); + query.append(",di.title as tittle "); + query.append("FROM "); + query.append("deliverable_user_partnerships AS dup "); + query.append("INNER JOIN deliverable_user_partnership_persons AS dupp ON dupp.user_partnership_id = dup.id "); + query.append(" inner join deliverables as d on dup.deliverable_id = d.id "); + query.append(" inner join deliverables_info di on di.deliverable_id = d.id "); + query.append(" inner join phases p on p.id = d.id_phase "); + query.append("WHERE "); + query.append("dupp.user_id =" + userId + " AND "); + query.append("dup.is_active = 1 AND "); + query.append("dupp.is_active = 1 AND "); + query.append(" dup.id_phase = d.id_phase AND "); + query.append("d.id_phase = di.id_phase AND "); + query.append("dup.id_phase =" + phaseId); + query.append(" and d.project_id =" + projectId); + query.append(" and di.status in (2,4) "); + query.append(" and d.is_active =1 "); + query.append(" and di.year >= p.year "); + query.append(" union "); + query.append("SELECT DISTINCT "); + query.append("dup.deliverable_id as id "); + query.append(",di.title as tittle "); + query.append("FROM "); + query.append("deliverable_user_partnerships AS dup "); + query.append("INNER JOIN deliverable_user_partnership_persons AS dupp ON dupp.user_partnership_id = dup.id "); + query.append(" inner join deliverables as d on dup.deliverable_id = d.id "); + query.append(" inner join deliverables_info di on di.deliverable_id = d.id "); + query.append(" inner join phases p on p.id = d.id_phase "); + query.append("WHERE "); + query.append("dupp.user_id =" + userId + " AND "); + query.append("dup.is_active = 1 AND "); + query.append("dupp.is_active = 1 AND "); + query.append(" dup.id_phase = d.id_phase AND "); + query.append("d.id_phase = di.id_phase AND "); + query.append("dup.id_phase =" + phaseId); + query.append(" and d.project_id =" + projectId); + query.append(" and di.status in (4) "); + query.append(" and d.is_active =1 "); + query.append(" and di.new_expected_year >= p.year "); + + List> rList = super.findCustomQuery(query.toString()); + List deliverables = new ArrayList<>(); + + if (rList != null) { + for (Map map : rList) { + DeliverableDTO deliverable = new DeliverableDTO(); + deliverable.setId(Long.parseLong(map.get("id").toString())); + deliverable.setTitle(map.get("tittle").toString()); + deliverables.add(deliverable); + } + } + + return deliverables; + } + /** * Get listing to validate duplicate information (dissemination_URL,DIO, handle) * diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableManager.java index d86745abd1..14a37630f2 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableManager.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableManager.java @@ -15,6 +15,7 @@ package org.cgiar.ccafs.marlo.data.manager; import org.cgiar.ccafs.marlo.data.model.Deliverable; +import org.cgiar.ccafs.marlo.data.model.DeliverableDTO; import org.cgiar.ccafs.marlo.data.model.DeliverableHomeDTO; import org.cgiar.ccafs.marlo.data.model.LiaisonInstitution; import org.cgiar.ccafs.marlo.data.model.Phase; @@ -130,6 +131,12 @@ List getDeliverablesByPhaseAndUrlAndDoiAndHandel(long phase, String List getDeliverablesLeadByUserAndProject(long userId, long phaseId, long projectId); + List getDeliverablesLeadByUserAndProjectWithConditions(long userId, long phaseId, long projectId); + + List getDeliverablesLeadByUserAndProjectWithSimpleConditions(long userId, long phaseId, + long projectId); + + /** * This method gets a list of deliverables that are active for an specific liaisonInstitution * Flagship: Get the list of projects that have project_focus equal to the liaisonInstitution @@ -146,6 +153,7 @@ List getDeliverablesByPhaseAndUrlAndDoiAndHandel(long phase, String public List getNotPublicationsList(LiaisonInstitution liaisonInstitution, Phase phase); + /** * This method gets a list of publications that are active by a given phase * diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableManagerImpl.java index a4eb33c7ed..30150abf69 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableManagerImpl.java @@ -29,6 +29,7 @@ import org.cgiar.ccafs.marlo.data.model.CrpClusterKeyOutput; import org.cgiar.ccafs.marlo.data.model.CrpClusterOfActivity; import org.cgiar.ccafs.marlo.data.model.Deliverable; +import org.cgiar.ccafs.marlo.data.model.DeliverableDTO; import org.cgiar.ccafs.marlo.data.model.DeliverableHomeDTO; import org.cgiar.ccafs.marlo.data.model.DeliverableInfo; import org.cgiar.ccafs.marlo.data.model.DeliverableProgram; @@ -214,6 +215,19 @@ public List getDeliverablesLeadByUserAndProject(long userId, long p return deliverableDAO.getDeliverablesLeadByUserAndProject(userId, phaseId, projectId); } + @Override + public List getDeliverablesLeadByUserAndProjectWithConditions(long userId, long phaseId, + long projectId) { + return deliverableDAO.getDeliverablesLeadByUserAndProjectWithConditions(userId, phaseId, projectId); + } + + @Override + public List getDeliverablesLeadByUserAndProjectWithSimpleConditions(long userId, long phaseId, + long projectId) { + return deliverableDAO.getDeliverablesLeadByUserAndProjectWithSimpleConditions(userId, phaseId, projectId); + } + + @Override public List getDeliverablesList(LiaisonInstitution liaisonInstitution, Phase phase) { Phase phaseDB = phaseManager.getPhaseById(phase.getId()); diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableDTO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableDTO.java new file mode 100644 index 0000000000..3c7649c1e4 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableDTO.java @@ -0,0 +1,52 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + +package org.cgiar.ccafs.marlo.data.model; + + +public class DeliverableDTO { + + Long id; + + private String title; + + + public Long getId() { + return id; + } + + + public String getTitle() { + return title; + } + + + public void setId(Long id) { + this.id = id; + } + + + public void setTitle(String title) { + this.title = title; + } + + + @Override + public String toString() { + return "DeliverableDTO [id=" + id + ", title=" + title + "]"; + } + + +} diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java index 1e01359b0e..a636cef902 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java @@ -58,6 +58,7 @@ import org.cgiar.ccafs.marlo.data.model.CrpProgramLeader; import org.cgiar.ccafs.marlo.data.model.CrpUser; import org.cgiar.ccafs.marlo.data.model.Deliverable; +import org.cgiar.ccafs.marlo.data.model.DeliverableDTO; import org.cgiar.ccafs.marlo.data.model.GlobalUnit; import org.cgiar.ccafs.marlo.data.model.GlobalUnitProject; import org.cgiar.ccafs.marlo.data.model.Institution; @@ -462,6 +463,7 @@ public List getCountries() { } public List getDeliverablesLedByPartner(Long projectPartnerID) { + LOG.info(" ProjectPartnerAction linea 465 projectID " + projectID); List deliverablesLeads = new ArrayList<>(); if (projectPartnerID != null && projectPartnerID != 0) { ProjectPartner projectPartner = projectPartnerManager.getProjectPartnerById(projectPartnerID); @@ -501,11 +503,28 @@ public List getDeliverablesLedByPartner(Long projectPartnerID) { } } + LOG.info(" ProjectPartnerAction linea 505 projectID " + deliverablesLeads.size()); return deliverablesLeads; } + public List getDeliverablesLedByUser(long userID) { + List deliverablesLeadsTmp = new ArrayList<>(); + try { + + deliverablesLeadsTmp = deliverableManager.getDeliverablesLeadByUserAndProjectWithSimpleConditions(userID, + this.getActualPhase().getId(), projectID); + for (DeliverableDTO deliverable : deliverablesLeadsTmp) { + LOG.info(" ProjectPartnerAction linea 519 deliverable " + deliverable.toString()); + } + } catch (Exception e) { + LOG.error(" unable to get deliverables - getDeliverablesLedByUser function "); + } + return deliverablesLeadsTmp; + + } + - public List getDeliverablesLedByUser(long userID) { + public List getDeliverablesLedByUserOld(long userID) { List deliverablesLeads = new ArrayList<>(); List deliverables = // cgamboa 16/05/2024 getDeliverablesLeadByUser was changed by getDeliverablesLeadByUser diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectPartners.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectPartners.ftl index 294f0f2558..2db457f796 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectPartners.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectPartners.ftl @@ -547,7 +547,7 @@

Deliverables

    [#list deliverablesLedByUserList as deliverable] -
  • ${deliverable.deliverableInfo.title}
  • +
  • ${deliverable.title}
  • [/#list]
From e51dcbac7f7f29cea40808ee0cb33830d2907465 Mon Sep 17 00:00:00 2001 From: Cristian Gamboa Date: Wed, 22 May 2024 14:08:58 -0500 Subject: [PATCH 2/5] :recycle: refactor(ProjectPartner): Reduce the number of queries used to get activities of the section of partners .A2-569 --- .../marlo/data/dao/mysql/ActivityMySQLDAO.java | 2 +- .../marlo/data/dao/mysql/DeliverableMySQLDAO.java | 1 + .../action/projects/ProjectPartnerAction.java | 15 +++++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ActivityMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ActivityMySQLDAO.java index 3855740fc1..01f1580e0b 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ActivityMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ActivityMySQLDAO.java @@ -74,7 +74,7 @@ public List findAll() { @Override public List getActivitiesByProject(long projectId, long phaseId) { String query = "from " + Activity.class.getName() + " where project_id=" + projectId + " and id_phase=" + phaseId - + " and is_active=1"; + + " and is_active=1 and activityStatus=2"; List list = super.findAll(query); if (!list.isEmpty()) { return list; diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableMySQLDAO.java index 2b15ba34c5..6665b2c4e5 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableMySQLDAO.java @@ -362,6 +362,7 @@ public List getDeliverablesLeadByInstitutionAndProject(long institu query.append("dup.is_active = 1 AND "); query.append("dupp.is_active = 1 AND "); query.append("dup.institution_id =" + institutionId + " AND "); + query.append("dup.id_phase = d.id_phase and "); query.append("dup.id_phase = " + phaseId); query.append(" and d.is_active =1 "); query.append(" and d.project_id = " + projectId); diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java index a636cef902..75ba6ee9e5 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java @@ -463,10 +463,13 @@ public List getCountries() { } public List getDeliverablesLedByPartner(Long projectPartnerID) { - LOG.info(" ProjectPartnerAction linea 465 projectID " + projectID); + LOG.info(" ProjectPartnerAction linea 466 projectID " + projectID); + LOG.info(" ProjectPartnerAction linea 467 this.getActualPhase().getId() " + this.getActualPhase().getId()); List deliverablesLeads = new ArrayList<>(); if (projectPartnerID != null && projectPartnerID != 0) { ProjectPartner projectPartner = projectPartnerManager.getProjectPartnerById(projectPartnerID); + LOG.info(" ProjectPartnerAction linea 471 projectPartner.getInstitution().getId() " + + projectPartner.getInstitution().getId()); if (projectPartner != null) { /// cgamboa 17/05/2024 getDeliverablesLeadByInstitution was changed by /// getDeliverablesLeadByInstitutionAndProject @@ -474,7 +477,7 @@ public List getDeliverablesLedByPartner(Long projectPartnerID) { // .getDeliverablesLeadByInstitution(projectPartner.getInstitution().getId(), this.getActualPhase().getId()); .getDeliverablesLeadByInstitutionAndProject(projectPartner.getInstitution().getId(), this.getActualPhase().getId(), projectID); - + LOG.info(" ProjectPartnerAction linea 480 deliverables.size() " + deliverables.size()); for (Deliverable deliverable : deliverables) { if (deliverable.getProject() != null && deliverable.getProject().getId().equals(projectID)) { deliverable.setDeliverableInfo(deliverable.getDeliverableInfo(this.getActualPhase())); @@ -503,7 +506,7 @@ public List getDeliverablesLedByPartner(Long projectPartnerID) { } } - LOG.info(" ProjectPartnerAction linea 505 projectID " + deliverablesLeads.size()); + LOG.info(" ProjectPartnerAction linea 505 deliverablesLeads.size() " + deliverablesLeads.size()); return deliverablesLeads; } @@ -513,9 +516,7 @@ public List getDeliverablesLedByUser(long userID) { deliverablesLeadsTmp = deliverableManager.getDeliverablesLeadByUserAndProjectWithSimpleConditions(userID, this.getActualPhase().getId(), projectID); - for (DeliverableDTO deliverable : deliverablesLeadsTmp) { - LOG.info(" ProjectPartnerAction linea 519 deliverable " + deliverable.toString()); - } + } catch (Exception e) { LOG.error(" unable to get deliverables - getDeliverablesLedByUser function "); } @@ -1512,7 +1513,9 @@ public void prepare() throws Exception { project.getPartners().clear(); } + LOG.info(" ProjectPartnerAction linea 1516"); this.setCustomDataToPartnerShipPerson(project); + LOG.info(" ProjectPartnerAction linea 1518"); } From 19d0d5ddc892ae52169b5fccd15a4ea869ed310c Mon Sep 17 00:00:00 2001 From: Cristian Gamboa Date: Wed, 22 May 2024 16:03:09 -0500 Subject: [PATCH 3/5] :recycle: refactor(ProjectPartner): Delete review comments related to the section of partners .A2-569 --- .../ccafs/marlo/data/dao/DeliverableDAO.java | 9 +++++++++ .../manager/impl/DeliverableManagerImpl.java | 9 +++++++++ .../action/projects/ProjectPartnerAction.java | 17 ++++++++--------- .../crp/views/projects/projectPartners.ftl | 12 +++++++----- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableDAO.java index 31339f183e..e147d84680 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableDAO.java @@ -123,6 +123,15 @@ List getDeliverablesByPhaseAndUrlAndDoiAndHandel(long phase, String List getDeliverablesLeadByUserAndProjectWithConditions(long userId, long phaseId, long projectId); + /** + * get deliverables list by user, phase and project + * + * @author IBD + * @param phaseId phase id + * @param projectId project id + * @param userId user id + * @return deliverables (DTO) list + */ List getDeliverablesLeadByUserAndProjectWithSimpleConditions(long userId, long phaseId, long projectId); diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableManagerImpl.java index 30150abf69..41b8b6159a 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableManagerImpl.java @@ -221,6 +221,15 @@ public List getDeliverablesLeadByUserAndProjectWithConditions(long return deliverableDAO.getDeliverablesLeadByUserAndProjectWithConditions(userId, phaseId, projectId); } + /** + * get deliverables list by user, phase and project + * + * @author IBD + * @param phaseId phase id + * @param projectId project id + * @param userId user id + * @return deliverables (DTO) list + */ @Override public List getDeliverablesLeadByUserAndProjectWithSimpleConditions(long userId, long phaseId, long projectId) { diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java index 75ba6ee9e5..fff0397782 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectPartnerAction.java @@ -463,13 +463,10 @@ public List getCountries() { } public List getDeliverablesLedByPartner(Long projectPartnerID) { - LOG.info(" ProjectPartnerAction linea 466 projectID " + projectID); - LOG.info(" ProjectPartnerAction linea 467 this.getActualPhase().getId() " + this.getActualPhase().getId()); List deliverablesLeads = new ArrayList<>(); if (projectPartnerID != null && projectPartnerID != 0) { ProjectPartner projectPartner = projectPartnerManager.getProjectPartnerById(projectPartnerID); - LOG.info(" ProjectPartnerAction linea 471 projectPartner.getInstitution().getId() " - + projectPartner.getInstitution().getId()); + if (projectPartner != null) { /// cgamboa 17/05/2024 getDeliverablesLeadByInstitution was changed by /// getDeliverablesLeadByInstitutionAndProject @@ -477,7 +474,6 @@ public List getDeliverablesLedByPartner(Long projectPartnerID) { // .getDeliverablesLeadByInstitution(projectPartner.getInstitution().getId(), this.getActualPhase().getId()); .getDeliverablesLeadByInstitutionAndProject(projectPartner.getInstitution().getId(), this.getActualPhase().getId(), projectID); - LOG.info(" ProjectPartnerAction linea 480 deliverables.size() " + deliverables.size()); for (Deliverable deliverable : deliverables) { if (deliverable.getProject() != null && deliverable.getProject().getId().equals(projectID)) { deliverable.setDeliverableInfo(deliverable.getDeliverableInfo(this.getActualPhase())); @@ -506,10 +502,16 @@ public List getDeliverablesLedByPartner(Long projectPartnerID) { } } - LOG.info(" ProjectPartnerAction linea 505 deliverablesLeads.size() " + deliverablesLeads.size()); return deliverablesLeads; } + /** + * get deliverables list by user + * + * @author IBD + * @param userId user id + * @return deliverables (DTO) list + */ public List getDeliverablesLedByUser(long userID) { List deliverablesLeadsTmp = new ArrayList<>(); try { @@ -1513,9 +1515,7 @@ public void prepare() throws Exception { project.getPartners().clear(); } - LOG.info(" ProjectPartnerAction linea 1516"); this.setCustomDataToPartnerShipPerson(project); - LOG.info(" ProjectPartnerAction linea 1518"); } @@ -1830,7 +1830,6 @@ public String save() { } else { this.addActionMessage("message:" + this.getText("saving.saved")); } - return SUCCESS; } else { this.addActionMessage(""); diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectPartners.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectPartners.ftl index 2db457f796..788c937f32 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectPartners.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectPartners.ftl @@ -418,7 +418,9 @@ [/#if] - + + [#assign permissionLeader = action.hasPermission("leader")] + [#assign permissionCoordinator = action.hasPermission("coordinator")] [#-- Contacts person(s) --]
[@s.text name="projectPartners.projectPartnerContacts" /] [@customForm.req required=isPPA /]
@@ -462,16 +464,16 @@
- [#local canEditLeader=(editable && action.hasPermission("leader"))!false /] - [#local canEditCoordinator=(editable && action.hasPermission("coordinator"))!false /] + [#local canEditLeader=(editable && permissionLeader)!false /] + [#local canEditCoordinator=(editable && permissionCoordinator)!false /] [#local isPPA = (action.isPPA(element.projectPartner.institution))!false /] [#if (element.contactType == "PL")!false] - [#local canEditContactType = (editable && action.hasPermission("leader"))!false /] + [#local canEditContactType = (editable && permissionLeader)!false /] [#elseif (element.contactType == "PC")!false] - [#local canEditContactType = (editable && action.hasPermission("coordinator"))!false /] + [#local canEditContactType = (editable && permissionCoordinator)!false /] [#else] [#local canEditContactType = editable || isTemplate /] [/#if] From 2831ebf4ae1f24844c372267b2893d4563dea199 Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Thu, 13 Jun 2024 09:39:53 -0500 Subject: [PATCH 4/5] :bug: fix(Reporting summary): Validate report generation --- .../ccafs/marlo/action/summaries/ReportingSummaryAction.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ReportingSummaryAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ReportingSummaryAction.java index 31c438a7b8..b51f43a040 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ReportingSummaryAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ReportingSummaryAction.java @@ -7668,7 +7668,8 @@ public void prepare() { } catch (Exception e) { LOG.error("Failed to get project. Exception: " + e.getMessage()); } - if (this.getSelectedPhase() != null && project.getProjecInfoPhase(this.getSelectedPhase()) != null) { + if (this.getSelectedPhase() != null && project != null + && project.getProjecInfoPhase(this.getSelectedPhase()) != null) { this.setProjectInfo(project.getProjecInfoPhase(this.getSelectedPhase())); } } From 3997f8d733f0b09599d843def66c3bf5a5802edd Mon Sep 17 00:00:00 2001 From: Kenji Tanaka Date: Fri, 14 Jun 2024 09:51:54 -0500 Subject: [PATCH 5/5] :wrench: chore(institutions): Filter active institutions in hibernate query --- .../cgiar/ccafs/marlo/data/dao/mysql/InstitutionMySQLDAO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/InstitutionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/InstitutionMySQLDAO.java index cc8cee436d..7ddf5eecc2 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/InstitutionMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/InstitutionMySQLDAO.java @@ -64,7 +64,7 @@ public Institution find(long id) { @Override public List findAll() { - String query = "from " + Institution.class.getName(); + String query = "from " + Institution.class.getName() + " where is_active=1"; List list = super.findAll(query); if (list.size() > 0) { return list;