From 8df4dcd27dcdb2c02b8874f5a24594c3c7c0eed1 Mon Sep 17 00:00:00 2001 From: Gamboa Date: Tue, 2 Apr 2024 14:09:39 -0500 Subject: [PATCH 1/6] changes to review the project --- .../projects/DeliverableListAction.java | 200 +++++++++++++++++- .../projects/ProjectOutcomeListAction.java | 14 +- 2 files changed, 206 insertions(+), 8 deletions(-) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableListAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableListAction.java index 646f7b1d97..b82e2b8c6e 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableListAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableListAction.java @@ -71,6 +71,8 @@ public class DeliverableListAction extends BaseAction { private static final long serialVersionUID = -823169163612346982L; + + // Logger private final Logger logger = LoggerFactory.getLogger(DeliverableListAction.class); @@ -84,8 +86,8 @@ public class DeliverableListAction extends BaseAction { private SectionStatusManager sectionStatusManager; private ProjectDeliverableSharedManager projectDeliverableSharedManager; private FeedbackQACommentableFieldsManager feedbackQACommentableFieldsManager; - private FeedbackQACommentManager commentManager; + private FeedbackQACommentManager commentManager; // Front-end private List allYears; private long deliverableID; @@ -95,9 +97,10 @@ public class DeliverableListAction extends BaseAction { private List deliverablesType; private GlobalUnit loggedCrp; private Project project; - private long projectID; + private long projectID; + @Inject public DeliverableListAction(APConfig config, ProjectManager projectManager, GlobalUnitManager crpManager, DeliverableTypeManager deliverableTypeManager, DeliverableManager deliverableManager, PhaseManager phaseManager, @@ -115,6 +118,8 @@ public DeliverableListAction(APConfig config, ProjectManager projectManager, Glo this.projectDeliverableSharedManager = projectDeliverableSharedManager; this.feedbackQACommentableFieldsManager = feedbackQACommentableFieldsManager; this.commentManager = commentManager; + + System.out.println(" test mayor"); } @Override @@ -160,7 +165,6 @@ public void addDeliverablePhase(Phase phase, Deliverable deliverable) { } } - public boolean canEdit(long deliverableID) { Deliverable deliverable = deliverableManager.getDeliverableById(deliverableID); if (this.isPlanningActive() && !this.isUpKeepActive()) { @@ -207,17 +211,40 @@ public void getCommentStatuses() { try { List commentableFields = new ArrayList<>(); + System.out.println(" comment 1 "); // get the commentable fields by sectionName if (feedbackQACommentableFieldsManager.findAll() != null) { + System.out.println(" comment 2 "); commentableFields = feedbackQACommentableFieldsManager.findAll().stream() .filter(f -> f != null && f.getSectionName().equals("deliverable")).collect(Collectors.toList()); + System.out.println(" comment 3 "); } + + System.out.println(" comment 4 "); if (project.getDeliverables() != null && !project.getDeliverables().isEmpty() && commentableFields != null && !commentableFields.isEmpty()) { + System.out.println(" comment 5 "); + System.out.println(" this.getActualPhase() " + this.getActualPhase()); - // Set the comment status in each project outcome + List comments1 = commentManager.findAll().stream() + .filter(f -> f != null && f.getPhase() != null && f.getPhase().getId() != null + && f.getPhase().getId().equals(this.getActualPhase().getId()) + && (f.getFeedbackStatus() != null && f.getFeedbackStatus().getId() != null + && (!f.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Dismissed.getStatusId())) + // && + // !f.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Draft.getStatusId())) + )) + + // && f.getField() != null && f.getField().getId().equals(commentableField.getId()) + ).collect(Collectors.toList()); + + System.out.println(" this.getActualPhase() FASE 2" + this.getActualPhase()); + + + // Set the comment status in each project outcome + // cgamboa -there is the problem for (Deliverable deliverable : project.getDeliverables()) { int answeredComments = 0; int totalComments = 0; @@ -226,8 +253,10 @@ public void getCommentStatuses() { for (FeedbackQACommentableFields commentableField : commentableFields) { if (commentableField != null && commentableField.getId() != null) { + if (deliverable != null && deliverable.getId() != null && commentableField != null && commentableField.getId() != null) { + List comments = commentManager.findAll().stream() .filter(f -> f != null && f.getPhase() != null && f.getPhase().getId() != null && f.getPhase().getId().equals(this.getActualPhase().getId()) @@ -257,6 +286,141 @@ public void getCommentStatuses() { } } } + if (answeredComments != 0 || totalComments != 0) { + System.out.println(" -----------------[start]------------------------ "); + System.out.println(" deliverable " + deliverable.getId()); + System.out.println(" answeredComments " + answeredComments); + System.out.println(" totalComments " + totalComments); + System.out.println(" -----------------[end]------------------------ "); + } + deliverable.setCommentStatus(answeredComments + "/" + totalComments); + + if (deliverable.getCommentStatus() == null + || (deliverable.getCommentStatus() != null && deliverable.getCommentStatus().isEmpty())) { + deliverable.setCommentStatus(0 + "/" + 0); + } + } catch (Exception e) { + deliverable.setCommentStatus(0 + "/" + 0); + + } + } + + } + } catch (Exception e) { + logger.error("unable to get feedbackcomments info", e); + e.printStackTrace(); + } + } + + + public void getCommentStatusesNew() { + + try { + List commentableFields = new ArrayList<>(); + + System.out.println(" comment 1 "); + // get the commentable fields by sectionName + if (feedbackQACommentableFieldsManager.findAll() != null) { + System.out.println(" comment 2 "); + commentableFields = feedbackQACommentableFieldsManager.findAll().stream() + .filter(f -> f != null && f.getSectionName().equals("deliverable")).collect(Collectors.toList()); + System.out.println(" comment 3 "); + } + + System.out.println(" comment 4 "); + if (project.getDeliverables() != null && !project.getDeliverables().isEmpty() && commentableFields != null + && !commentableFields.isEmpty()) { + + System.out.println(" comment 5 "); + System.out.println(" this.getActualPhase() " + this.getActualPhase()); + + + List comments1 = commentManager.findAll().stream() + .filter(f -> f != null && f.getPhase() != null && f.getPhase().getId() != null + && f.getPhase().getId().equals(this.getActualPhase().getId()) + && (f.getFeedbackStatus() != null && f.getFeedbackStatus().getId() != null + && (!f.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Dismissed.getStatusId())))) + + // && f.getField() != null && f.getField().getId().equals(commentableField.getId()) + ).collect(Collectors.toList()); + + System.out.println(" this.getActualPhase() FASE 2" + this.getActualPhase()); + + + // Set the comment status in each project outcome + // cgamboa -there is the problem + for (Deliverable deliverable : project.getDeliverables()) { + int answeredComments = 0; + int totalComments = 0; + try { + + for (FeedbackQACommentableFields commentableField : commentableFields) { + if (commentableField != null && commentableField.getId() != null) { + + + if (deliverable != null && deliverable.getId() != null && commentableField != null + && commentableField.getId() != null) { + + // System.out.println("Inicia for x "+deliverable.getId()); + + for (FeedbackQAComment feedbackQAComment : comments1) { + + if (feedbackQAComment.getParentId() == deliverable.getId() + && feedbackQAComment.getField().getId().equals(commentableField.getId())) { + System.out.println("entra 1 " + feedbackQAComment.getParentId()); + totalComments += 1; + } + + if (feedbackQAComment.getParentId() == deliverable.getId() + && feedbackQAComment.getField().getId().equals(commentableField.getId()) + && ((feedbackQAComment.getFeedbackStatus() != null && feedbackQAComment.getFeedbackStatus() + .getId().equals(Long.parseLong(FeedbackStatusEnum.Agreed.getStatusId()))) + || (feedbackQAComment.getFeedbackStatus() != null && feedbackQAComment.getReply() != null))) { + System.out.println("entra 2 " + feedbackQAComment.getParentId()); + answeredComments += 1; + } + } + + // System.out.println("Finaliza for x "+deliverable.getId()); + + /* + * List comments = commentManager.findAll().stream() + * .filter(f -> f != null && f.getPhase() != null && f.getPhase().getId() != null + * && f.getPhase().getId().equals(this.getActualPhase().getId()) + * && f.getParentId() == deliverable.getId() + * && (f.getFeedbackStatus() != null && f.getFeedbackStatus().getId() != null && (!f + * .getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Dismissed.getStatusId())) + * // && + * // !f.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Draft.getStatusId())) + * )) + * && f.getField() != null && f.getField().getId().equals(commentableField.getId())) + * .collect(Collectors.toList()); + */ + /* + * if (comments != null && !comments.isEmpty()) { + * totalComments += comments.size(); + * comments = comments.stream() + * .filter(f -> f != null && f.getPhase() != null && f.getPhase().getId() != null + * && f.getPhase().getId().equals(this.getActualPhase().getId()) + * && ((f.getFeedbackStatus() != null && f.getFeedbackStatus().getId() + * .equals(Long.parseLong(FeedbackStatusEnum.Agreed.getStatusId()))) + * || (f.getFeedbackStatus() != null && f.getReply() != null))) + * .collect(Collectors.toList()); + * if (comments != null) { + * answeredComments += comments.size(); + * } + * } + */ + } + } + } + if (answeredComments != 0 || totalComments != 0) { + System.out.println(" -----------------[start]------------------------ "); + System.out.println(" deliverable " + deliverable.getId()); + System.out.println(" answeredComments " + answeredComments); + System.out.println(" totalComments " + totalComments); + System.out.println(" -----------------[end]------------------------ "); + } deliverable.setCommentStatus(answeredComments + "/" + totalComments); if (deliverable.getCommentStatus() == null @@ -270,6 +434,8 @@ public void getCommentStatuses() { } } + System.out.println(" --------------------------------ENTRA A FASE 2------------------------------------"); + // this.getCommentStatusesOld(); } catch (Exception e) { logger.error("unable to get feedbackcomments info", e); e.printStackTrace(); @@ -433,6 +599,7 @@ public List getDeliverablesType() { return deliverablesType; } + public int getIndexDeliverables(long id) { Deliverable activity = new Deliverable(); activity.setId(id); @@ -440,7 +607,6 @@ public int getIndexDeliverables(long id) { } - public GlobalUnit getLoggedCrp() { return loggedCrp; } @@ -453,11 +619,11 @@ public Project getProject() { return project; } + public long getProjectID() { return projectID; } - /* * Copy method from project.getCurrentDeliverables to allow add the shared deliverables to list */ @@ -757,26 +923,35 @@ public void prepare() throws Exception { loggedCrp = crpManager.getGlobalUnitById(loggedCrp.getId()); Phase phase = this.getActualPhase(); phase = phaseManager.getPhaseById(phase.getId()); + System.out.println(" phase " + phase.getId()); try { projectID = Long.parseLong(StringUtils.trim(this.getRequest().getParameter(APConstants.PROJECT_REQUEST_ID))); project = projectManager.getProjectById(projectID); + System.out.println(" projectID " + projectID); + if (project != null) { allYears = project.getProjecInfoPhase(this.getActualPhase()).getAllYears(); + System.out.println(" etapa 1 " + projectID); if (deliverableTypeManager.findAll() != null) { + System.out.println(" etapa 2 " + projectID); deliverablesType = new ArrayList<>(deliverableTypeManager.findAll()); } + System.out.println(" etapa 3 " + projectID); if (project.getDeliverables() != null) { - + System.out.println(" etapa 4 " + projectID); List infos = deliverableInfoManager.getDeliverablesInfoByProjectAndPhase(phase, project); + System.out.println(" etapa 5 " + projectID); deliverables = new ArrayList<>(); if (infos != null && !infos.isEmpty()) { for (DeliverableInfo deliverableInfo : infos) { + Deliverable deliverable = deliverableInfo.getDeliverable(); deliverable.setDeliverableInfo(deliverableInfo); + System.out.println(" etapa 6 " + deliverableInfo + " deliverable " + deliverable.getId()); deliverables.add(deliverable); } } @@ -791,20 +966,30 @@ public void prepare() throws Exception { for (DeliverableFundingSource deliverableFundingSource : fundingSources) { deliverableFundingSource.getFundingSource().setFundingSourceInfo( deliverableFundingSource.getFundingSource().getFundingSourceInfo(this.getActualPhase())); + System.out.println(" etapa 7 " + this.getActualPhase()); } deliverable.setFundingSources(fundingSources); } + System.out.println(" etapa 8 " + this.getActualPhase()); } + System.out.println(" etapa 9 " + this.getActualPhase()); this.loadCurrentDeliverables(); + System.out.println(" etapa 10 " + this.getActualPhase()); } + System.out.println(" etapa 11 " + this.getActualPhase()); if (this.hasSpecificities(this.feedbackModule())) { + System.out.println(" etapa 12 " + this.getActualPhase()); this.getCommentStatuses(); } + System.out.println(" etapa 13 " + this.getActualPhase()); + System.out.println(" this.isReportingActive() " + this.isReportingActive()); + System.out.println(" this.isUpKeepActive() " + this.isUpKeepActive()); if (this.isReportingActive() || this.isUpKeepActive()) { + System.out.println(" TEST this.isUpKeepActive() " + this.isUpKeepActive()); deliverables.sort((p1, p2) -> this.isDeliverableComplete(p1.getId(), this.getActualPhase().getId()) .compareTo(this.isDeliverableComplete(p2.getId(), this.getActualPhase().getId()))); @@ -866,6 +1051,7 @@ public void setProject(Project project) { this.project = project; } + public void setProjectID(long projectID) { this.projectID = projectID; } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectOutcomeListAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectOutcomeListAction.java index e76611d0ae..6019374062 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectOutcomeListAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectOutcomeListAction.java @@ -433,30 +433,39 @@ public void prepare() throws Exception { project.setFlagships(programs); if (this.hasSpecificities(this.feedbackModule())) { + System.out.println(" INICIO -------------"); this.getCommentStatuses(); + System.out.println(" FIN -------------"); } String params[] = {gp.getGlobalUnit().getAcronym(), project.getId() + ""}; this.setBasePermission(this.getText(Permission.PROJECT_CONTRIBRUTIONCRP_BASE_PERMISSION, params)); + System.out.println(" etapa 1 -------------"); if (this.hasSpecificities(APConstants.CRP_LP6_ACTIVE)) { + System.out.println(" etapa 2 -------------"); if (this.getActualPhase() != null && projectID != 0) { - + System.out.println(" etapa 3 -------------"); if (projectLp6ContributionManager.findAll() != null) { List projectLp6Contributions = projectLp6ContributionManager.findAll().stream() .filter(c -> c.isActive() && c.getProject().getId().equals(projectID) && c.getPhase().equals(this.getActualPhase())) .collect(Collectors.toList()); + System.out.println(" etapa 4 -------------"); if (projectLp6Contributions != null && !projectLp6Contributions.isEmpty()) { + System.out.println(" etapa 5 -------------"); this.setProjectLp6Contribution(projectLp6Contributions.get(0)); + System.out.println(" etapa 6 -------------"); } else { if (contributionValue) { + System.out.println(" etapa 7 -------------"); ProjectLp6Contribution newContribution = new ProjectLp6Contribution(); newContribution.setProject(project); newContribution.setPhase(this.getActualPhase()); newContribution.setContribution(contributionValue); projectLp6ContributionManager.saveProjectLp6Contribution(newContribution); + System.out.println(" etapa 8 -------------"); } } } @@ -465,9 +474,12 @@ public void prepare() throws Exception { if (project.getOutcomes() != null) { for (ProjectOutcome projectOutcome : project.getOutcomes()) { + System.out.println(" etapa 9 -------------"); this.defineProjectOutcomeOrder(projectOutcome); + System.out.println(" etapa 10 -------------"); } } + System.out.println(" etapa 11 -------------"); } From b506512be4bcb997417faa00730cc61294dd98f6 Mon Sep 17 00:00:00 2001 From: Gamboa Date: Tue, 16 Apr 2024 17:06:34 -0500 Subject: [PATCH 2/6] :recycle: refactor(ProjectExpectedStudiesList): Improve performance of comments queries related to the OICRs & MELIAs section. A2-466 --- .../dao/FeedbackQACommentableFieldsDAO.java | 20 ++++++ .../FeedbackQACommentableFieldsMySQLDAO.java | 67 +++++++++++++++++++ .../FeedbackQACommentableFieldsManager.java | 20 ++++++ ...eedbackQACommentableFieldsManagerImpl.java | 25 +++++++ .../ProjectExpectedStudiesListAction.java | 58 ++++++++++++++-- 5 files changed, 185 insertions(+), 5 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/FeedbackQACommentableFieldsDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/FeedbackQACommentableFieldsDAO.java index a532388668..a7bf20e777 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/FeedbackQACommentableFieldsDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/FeedbackQACommentableFieldsDAO.java @@ -63,6 +63,24 @@ public interface FeedbackQACommentableFieldsDAO { public List findBySectionName(String sectionName); + /** + * Get the answered comment by phase + * + * @author IBD + * @param phase phase of the project + * @return deliverable list with the comment count. olny coment with answer + */ + List getAnsweredCommentByPhaseToStudy(long phase); + + /** + * Get the commentstatus by phase + * + * @author IBD + * @param phase phase of the project + * @return deliverable list with the comment count + */ + List getCommentStatusByPhaseToStudy(long phase); + /** * This method saves the information of the given internalQaCommentableFields * @@ -74,4 +92,6 @@ public interface FeedbackQACommentableFieldsDAO { * or -1 is some error occurred. */ public FeedbackQACommentableFields save(FeedbackQACommentableFields feedbackQACommentableFields); + + } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/FeedbackQACommentableFieldsMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/FeedbackQACommentableFieldsMySQLDAO.java index 2155a52afb..1f7dad74e9 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/FeedbackQACommentableFieldsMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/FeedbackQACommentableFieldsMySQLDAO.java @@ -19,8 +19,10 @@ import org.cgiar.ccafs.marlo.data.dao.FeedbackQACommentableFieldsDAO; import org.cgiar.ccafs.marlo.data.model.FeedbackQACommentableFields; +import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Map; import javax.inject.Inject; import javax.inject.Named; @@ -81,6 +83,71 @@ public List findBySectionName(String sectionName) { return Collections.emptyList(); } + /** + * Get the answered comment by phase + * + * @author IBD + * @param phase phase of the project + * @return deliverable list with the comment count. olny coment with answer + */ + @Override + public List getAnsweredCommentByPhaseToStudy(long phase) { + StringBuilder query = new StringBuilder(); + query.append("SELECT parent_id as parent_id,count(*) as count "); + query.append("FROM feedback_qa_comments fqc"); + query.append(" WHERE id_phase=" + phase); + query.append(" and status_id = 1 "); + query.append(" and field_id in (select id from feedback_qa_commentable_fields fqcf "); + query.append(" where section_name = 'study') "); + query.append(" and reply_id is not null "); + query.append(" group by parent_id "); + + List> rList = super.findCustomQuery(query.toString()); + List comments = new ArrayList<>(); + + if (rList != null) { + for (Map map : rList) { + String tmp = map.get("parent_id").toString() + "|" + map.get("count").toString(); + comments.add(tmp); + } + } + + return comments; + } + + + /** + * Get the commentstatus by phase + * + * @author IBD + * @param phase phase of the project + * @return deliverable list with the comment count + */ + @Override + public List getCommentStatusByPhaseToStudy(long phase) { + StringBuilder query = new StringBuilder(); + query.append("SELECT parent_id as parent_id,count(*) as count "); + query.append("FROM feedback_qa_comments fqc"); + query.append(" WHERE id_phase=" + phase); + query.append(" and status_id <> 6 "); + query.append(" and field_id in (select id from feedback_qa_commentable_fields fqcf "); + query.append(" where section_name = 'study') "); + query.append(" group by parent_id "); + + List> rList = super.findCustomQuery(query.toString()); + List comments = new ArrayList<>(); + + if (rList != null) { + for (Map map : rList) { + String tmp = map.get("parent_id").toString() + "|" + map.get("count").toString(); + comments.add(tmp); + } + } + + return comments; + } + + @Override public FeedbackQACommentableFields save(FeedbackQACommentableFields feedbackQACommentableFields) { if (feedbackQACommentableFields.getId() == null) { diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/FeedbackQACommentableFieldsManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/FeedbackQACommentableFieldsManager.java index 6856899595..623fc5a50c 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/FeedbackQACommentableFieldsManager.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/FeedbackQACommentableFieldsManager.java @@ -60,6 +60,25 @@ public interface FeedbackQACommentableFieldsManager { public List findBySectionName(String sectionName); + /** + * Get the commentstatus by phase + * + * @author IBD + * @param phase phase of the project + * @return deliverable list with the comment count + */ + List getAnsweredCommentByPhaseToStudy(long phase); + + /** + * Get the commentstatus by phase + * + * @author IBD + * @param phase phase of the project + * @return deliverable list with the comment count + */ + List getCommentStatusByPhaseToStudy(long phase); + + /** * This method gets a internalQaCommentableFields object by a given internalQaCommentableFields identifier. * @@ -68,6 +87,7 @@ public interface FeedbackQACommentableFieldsManager { */ public FeedbackQACommentableFields getInternalQaCommentableFieldsById(long internalQaCommentableFieldsID); + /** * This method saves the information of the given internalQaCommentableFields * diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/FeedbackQACommentableFieldsManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/FeedbackQACommentableFieldsManagerImpl.java index 39fc487b24..685661eb74 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/FeedbackQACommentableFieldsManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/FeedbackQACommentableFieldsManagerImpl.java @@ -68,12 +68,37 @@ public List findBySectionName(String sectionName) { } + /** + * Get the commentstatus by phase + * + * @author IBD + * @param phase phase of the project + * @return deliverable list with the comment count + */ + @Override + public List getAnsweredCommentByPhaseToStudy(long phase) { + return feedbackQACommentableFieldsDAO.getAnsweredCommentByPhaseToStudy(phase); + } + + /** + * Get the commentstatus by phase + * + * @author IBD + * @param phase phase of the project + * @return deliverable list with the comment count + */ + @Override + public List getCommentStatusByPhaseToStudy(long phase) { + return feedbackQACommentableFieldsDAO.getCommentStatusByPhaseToStudy(phase); + } + @Override public FeedbackQACommentableFields getInternalQaCommentableFieldsById(long internalQaCommentableFieldsID) { return feedbackQACommentableFieldsDAO.find(internalQaCommentableFieldsID); } + @Override public FeedbackQACommentableFields saveInternalQaCommentableFields(FeedbackQACommentableFields feedbackQACommentableFields) { diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesListAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesListAction.java index 83dd1f5d5f..5c32f931cf 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesListAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesListAction.java @@ -54,7 +54,6 @@ */ public class ProjectExpectedStudiesListAction extends BaseAction { - private static final long serialVersionUID = 5533305942651533875L; @@ -204,11 +203,11 @@ public List getAllYears() { return allYears; } + public void getCommentStatuses() { try { - List commentableFields = new ArrayList<>(); // get the commentable fields by sectionName @@ -221,7 +220,6 @@ public void getCommentStatuses() { // Set the comment status in each project outcome - for (ProjectExpectedStudy study : projectStudies) { int answeredComments = 0, totalComments = 0; try { @@ -257,6 +255,7 @@ public void getCommentStatuses() { } } } + study.setCommentStatus(answeredComments + "/" + totalComments); if (study.getCommentStatus() == null @@ -275,6 +274,54 @@ public void getCommentStatuses() { } } + public void getCommentStatusesNew() { + try { + + List commentList = null; + commentList = feedbackQACommentableFieldsManager.getCommentStatusByPhaseToStudy(this.getActualPhase().getId()); + + List commentAnsweredList = null; + commentAnsweredList = + feedbackQACommentableFieldsManager.getAnsweredCommentByPhaseToStudy(this.getActualPhase().getId()); + + + for (ProjectExpectedStudy study : projectStudies) { + int answeredComments = 0; + int totalComments = 0; + try { + + for (String string : commentList) { + String test = string.replace("|", ";"); + + if (test.split(";")[0].equals(study.getId() + "")) { + totalComments = Integer.parseInt(test.split(";")[1]); + } + } + + for (String string : commentAnsweredList) { + String test = string.replace("|", ";"); + + if (test.split(";")[0].equals(study.getId() + "")) { + answeredComments = Integer.parseInt(test.split(";")[1]); + } + } + + study.setCommentStatus(answeredComments + "/" + totalComments); + if (study.getCommentStatus() == null + || (study.getCommentStatus() != null && study.getCommentStatus().isEmpty())) { + study.setCommentStatus(0 + "/" + 0); + } + + } catch (Exception e) { + study.setCommentStatus(0 + "/" + 0); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + public long getExpectedID() { return expectedID; @@ -315,7 +362,6 @@ public List getProjectStudies() { @Override public void prepare() throws Exception { - loggedCrp = (GlobalUnit) this.getSession().get(APConstants.SESSION_CRP); this.setPhaseID(this.getActualPhase().getId()); @@ -449,8 +495,10 @@ public void prepare() throws Exception { } } if (this.hasSpecificities(this.feedbackModule())) { - this.getCommentStatuses(); + // this.getCommentStatuses(); + this.getCommentStatusesNew(); } + } From b8699d3ee691558a0a1722999c2e29dbee956f81 Mon Sep 17 00:00:00 2001 From: Gamboa Date: Fri, 19 Apr 2024 17:31:01 -0500 Subject: [PATCH 3/6] :recycle: refactor(ProjectExpectedStudiesAction): Improve performance of comments queries related to the OICRs MELIAs section. A2-467 --- .../marlo/data/dao/FeedbackQACommentDAO.java | 6 + .../ccafs/marlo/data/dao/LocElementDAO.java | 132 +++++++------ .../dao/mysql/FeedbackQACommentMySQLDAO.java | 11 ++ .../data/dao/mysql/LocElementMySQLDAO.java | 180 ++++++++++-------- .../manager/FeedbackQACommentManager.java | 10 +- .../marlo/data/manager/LocElementManager.java | 147 +++++++------- .../impl/FeedbackQACommentManagerImpl.java | 7 + .../manager/impl/LocElementManagerImpl.java | 91 +++++---- .../cgiar/ccafs/marlo/action/BaseAction.java | 49 +++-- .../FeedbackQACommentsMultipleAction.java | 9 +- .../ProjectExpectedStudiesAction.java | 35 +++- 11 files changed, 414 insertions(+), 263 deletions(-) diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/FeedbackQACommentDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/FeedbackQACommentDAO.java index 142b5383fc..c34098f2fe 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/FeedbackQACommentDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/FeedbackQACommentDAO.java @@ -54,6 +54,12 @@ public interface FeedbackQACommentDAO { */ public List findAll(); + /** + * This method gets a list of feedbackQAComment by phase, that are active + * + * @return a list from FeedbackQAComment null if no exist records + */ + List findAllByPhase(long phaseId); /** * This method gets a list of feedbackQAComment that are active by Parent id diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/LocElementDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/LocElementDAO.java index 13af61a4fc..2c084e3d6d 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/LocElementDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/LocElementDAO.java @@ -21,71 +21,85 @@ public interface LocElementDAO { - /** - * This method removes a specific locElement value from the database. - * - * @param locElementId is the locElement identifier. - * @return true if the locElement was successfully deleted, false otherwise. - */ - public void deleteLocElement(long locElementId); + /** + * This method removes a specific locElement value from the database. + * + * @param locElementId is the locElement identifier. + * @return true if the locElement was successfully deleted, false otherwise. + */ + public void deleteLocElement(long locElementId); - /** - * This method validate if the locElement identify with the given id exists - * in the system. - * - * @param locElementID is a locElement identifier. - * @return true if the locElement exists, false otherwise. - */ - public boolean existLocElement(long locElementID); + /** + * This method validate if the locElement identify with the given id exists + * in the system. + * + * @param locElementID is a locElement identifier. + * @return true if the locElement exists, false otherwise. + */ + public boolean existLocElement(long locElementID); - /** - * This method gets a locElement object by a given locElement identifier. - * - * @param locElementID is the locElement identifier. - * @return a LocElement object. - */ - public LocElement find(long id); + /** + * This method gets a locElement object by a given locElement identifier. + * + * @param locElementID is the locElement identifier. + * @return a LocElement object. + */ + public LocElement find(long id); - /** - * This method gets a list of locElement that are active - * - * @return a list from LocElement null if no exist records - */ - public List findAll(); + /** + * This method gets a list of locElement that are active + * + * @return a list from LocElement null if no exist records + */ + public List findAll(); - /** - * This method gets a locElement object by a given locElement IsoCode. - * - * @param ISOCode of the LocElement. - * @return a LocElement object. - */ - public LocElement findISOCode(String ISOcode); + /** + * This method gets a list of locElement that are active, only conutries + * + * @return a list from LocElement null if no exist records + */ + List findAllToCountries(); - /** - * This method gets a locElement object by a parent locElement. - * - * @param parentId is the locElement parent id. - * @return a LocElement object. - */ - public List findLocElementByParent(Long parentId); + /** + * This method gets a list of locElement that are active, only regions + * + * @return a list from LocElement null if no exist records + */ + List findAllToRegions(); - /** - * This method gets a locElement object by a given locElement numeric - * IsoCode. - * - * @param numeric ISOCode of the LocElement. - * @return a LocElement object. - */ - LocElement findNumericISOCode(Long ISOcode); + /** + * This method gets a locElement object by a given locElement IsoCode. + * + * @param ISOCode of the LocElement. + * @return a LocElement object. + */ + public LocElement findISOCode(String ISOcode); - /** - * This method saves the information of the given locElement - * - * @param locElement - is the locElement object with the new information to - * be added/updated. - * @return a number greater than 0 representing the new ID assigned by the - * database, 0 if the locElement was updated or -1 is some error occurred. - */ - public LocElement save(LocElement locElement); + /** + * This method gets a locElement object by a parent locElement. + * + * @param parentId is the locElement parent id. + * @return a LocElement object. + */ + public List findLocElementByParent(Long parentId); + + /** + * This method gets a locElement object by a given locElement numeric + * IsoCode. + * + * @param numeric ISOCode of the LocElement. + * @return a LocElement object. + */ + LocElement findNumericISOCode(Long ISOcode); + + /** + * This method saves the information of the given locElement + * + * @param locElement - is the locElement object with the new information to + * be added/updated. + * @return a number greater than 0 representing the new ID assigned by the + * database, 0 if the locElement was updated or -1 is some error occurred. + */ + public LocElement save(LocElement locElement); } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/FeedbackQACommentMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/FeedbackQACommentMySQLDAO.java index 2a40cf9aff..2cfcdfe24d 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/FeedbackQACommentMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/FeedbackQACommentMySQLDAO.java @@ -69,6 +69,17 @@ public List findAll() { } + @Override + public List findAllByPhase(long phaseId) { + String query = "from " + FeedbackQAComment.class.getName() + " where id_phase = " + phaseId; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + @Override public List getFeedbackQACommentsByParentId(long parentID) { String query = "from " + FeedbackQAComment.class.getName() + " where parent_id=" + parentID; diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/LocElementMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/LocElementMySQLDAO.java index 26dc737810..5ea853a6a6 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/LocElementMySQLDAO.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/LocElementMySQLDAO.java @@ -28,83 +28,107 @@ @Named public class LocElementMySQLDAO extends AbstractMarloDAO implements LocElementDAO { - @Inject - public LocElementMySQLDAO(SessionFactory sessionFactory) { - super(sessionFactory); - } - - @Override - public void deleteLocElement(long locElementId) { - LocElement locElement = this.find(locElementId); - locElement.setActive(false); - this.save(locElement); - } - - @Override - public boolean existLocElement(long locElementID) { - LocElement locElement = this.find(locElementID); - if (locElement == null) { - return false; - } - return true; - - } - - @Override - public LocElement find(long id) { - return super.find(LocElement.class, id); - - } - - @Override - public List findAll() { - String query = "from " + LocElement.class.getName() + " where is_active=1"; - List list = super.findAll(query); - if (list.size() > 0) { - return list; - } - return null; - - } - - @Override - public LocElement findISOCode(String ISOcode) { - String query = "from " + LocElement.class.getName() + " where iso_alpha_2='" + ISOcode + "'"; - List list = super.findAll(query); - if (list.size() > 0) { - return list.get(0); - } - return null; - } - - @Override - public List findLocElementByParent(Long parentId) { - String query = "from " + LocElement.class.getName() + " where parent_id='" + parentId + "'"; - List list = super.findAll(query); - if (list.size() > 0) { - return list; - } - return null; - } - - @Override - public LocElement findNumericISOCode(Long ISOcode) { - String query = "from " + LocElement.class.getName() + " where iso_numeric=" + ISOcode; - List list = super.findAll(query); - if (list.size() > 0) { - return list.get(0); - } - return null; - } - - @Override - public LocElement save(LocElement locElement) { - if (locElement.getId() == null) { - super.saveEntity(locElement); - } else { - locElement = super.update(locElement); - } - return locElement; - } + @Inject + public LocElementMySQLDAO(SessionFactory sessionFactory) { + super(sessionFactory); + } + + @Override + public void deleteLocElement(long locElementId) { + LocElement locElement = this.find(locElementId); + locElement.setActive(false); + this.save(locElement); + } + + @Override + public boolean existLocElement(long locElementID) { + LocElement locElement = this.find(locElementID); + if (locElement == null) { + return false; + } + return true; + + } + + @Override + public LocElement find(long id) { + return super.find(LocElement.class, id); + + } + + @Override + public List findAll() { + String query = "from " + LocElement.class.getName() + " where is_active=1"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + + @Override + public List findAllToCountries() { + String query = "from " + LocElement.class.getName() + " where is_active=1 and element_type_id = 2"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public List findAllToRegions() { + String query = + "from " + LocElement.class.getName() + " where is_active=1 and element_type_id = 1 and iso_numeric is not null"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public LocElement findISOCode(String ISOcode) { + String query = "from " + LocElement.class.getName() + " where iso_alpha_2='" + ISOcode + "'"; + List list = super.findAll(query); + if (list.size() > 0) { + return list.get(0); + } + return null; + } + + @Override + public List findLocElementByParent(Long parentId) { + String query = "from " + LocElement.class.getName() + " where parent_id='" + parentId + "'"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + } + + @Override + public LocElement findNumericISOCode(Long ISOcode) { + String query = "from " + LocElement.class.getName() + " where iso_numeric=" + ISOcode; + List list = super.findAll(query); + if (list.size() > 0) { + return list.get(0); + } + return null; + } + + @Override + public LocElement save(LocElement locElement) { + if (locElement.getId() == null) { + super.saveEntity(locElement); + } else { + locElement = super.update(locElement); + } + return locElement; + } } \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/FeedbackQACommentManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/FeedbackQACommentManager.java index 6359bb6f03..c34f63eec1 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/FeedbackQACommentManager.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/FeedbackQACommentManager.java @@ -51,6 +51,14 @@ public interface FeedbackQACommentManager { */ public List findAll(); + /** + * This method gets a list of feedbackQAComment by phase, that are active + * + * @return a list from FeedbackQAComment null if no exist records + */ + List findAllByPhase(long phaseId); + + /** * This method gets a feedbackQAComment object by a given feedbackQAComment identifier. * @@ -59,7 +67,6 @@ public interface FeedbackQACommentManager { */ public FeedbackQAComment getFeedbackQACommentById(long feedbackQACommentID); - /** * This method gets a list of feedbackQAComment that are active by Parent id * @@ -68,6 +75,7 @@ public interface FeedbackQACommentManager { */ public List getFeedbackQACommentsByParentId(long parentID); + /** * This method saves the information of the given feedbackQAComment * diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/LocElementManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/LocElementManager.java index 8d4aacc7c5..8b684322c6 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/LocElementManager.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/LocElementManager.java @@ -24,71 +24,86 @@ public interface LocElementManager { - /** - * This method removes a specific locElement value from the database. - * - * @param locElementId is the locElement identifier. - * @return true if the locElement was successfully deleted, false otherwise. - */ - public void deleteLocElement(long locElementId); - - /** - * This method validate if the locElement identify with the given id exists - * in the system. - * - * @param locElementID is a locElement identifier. - * @return true if the locElement exists, false otherwise. - */ - public boolean existLocElement(long locElementID); - - /** - * This method gets a list of locElement that are active - * - * @return a list from LocElement null if no exist records - */ - public List findAll(); - - /** - * This method gets a locElement object by a parent locElement. - * - * @param parentId is the locElement parent id. - * @return a LocElement object. - */ - public List findLocElementByParent(long parentId); - - /** - * This method gets a locElement object by a given locElement identifier. - * - * @param locElementID is the locElement identifier. - * @return a LocElement object. - */ - public LocElement getLocElementById(long locElementID); - - /** - * This method gets a locElement object by a given iso code identfier. - * - * @param ISOCode is the iso code identifier. - * @return a LocElement object. - */ - public LocElement getLocElementByISOCode(String ISOCode); - - /** - * This method gets a locElement object by a given numeric iso code - * identfier. - * - * @param ISOCode is the numeric iso code identifier. - * @return a LocElement object. - */ - public LocElement getLocElementByNumericISOCode(Long ISOCode); - - /** - * This method saves the information of the given locElement - * - * @param locElement - is the locElement object with the new information to - * be added/updated. - * @return a number greater than 0 representing the new ID assigned by the - * database, 0 if the locElement was updated or -1 is some error occurred. - */ - public LocElement saveLocElement(LocElement locElement); + /** + * This method removes a specific locElement value from the database. + * + * @param locElementId is the locElement identifier. + * @return true if the locElement was successfully deleted, false otherwise. + */ + public void deleteLocElement(long locElementId); + + /** + * This method validate if the locElement identify with the given id exists + * in the system. + * + * @param locElementID is a locElement identifier. + * @return true if the locElement exists, false otherwise. + */ + public boolean existLocElement(long locElementID); + + /** + * This method gets a list of locElement that are active + * + * @return a list from LocElement null if no exist records + */ + public List findAll(); + + /** + * This method gets a list of locElement that are active, only conutries + * + * @return a list from LocElement null if no exist records + */ + List findAllToCountries(); + + + /** + * This method gets a list of locElement that are active, only regions + * + * @return a list from LocElement null if no exist records + */ + List findAllToRegions(); + + /** + * This method gets a locElement object by a parent locElement. + * + * @param parentId is the locElement parent id. + * @return a LocElement object. + */ + public List findLocElementByParent(long parentId); + + /** + * This method gets a locElement object by a given locElement identifier. + * + * @param locElementID is the locElement identifier. + * @return a LocElement object. + */ + public LocElement getLocElementById(long locElementID); + + /** + * This method gets a locElement object by a given iso code identfier. + * + * @param ISOCode is the iso code identifier. + * @return a LocElement object. + */ + public LocElement getLocElementByISOCode(String ISOCode); + + /** + * This method gets a locElement object by a given numeric iso code + * identfier. + * + * @param ISOCode is the numeric iso code identifier. + * @return a LocElement object. + */ + public LocElement getLocElementByNumericISOCode(Long ISOCode); + + /** + * This method saves the information of the given locElement + * + * @param locElement - is the locElement object with the new information to + * be added/updated. + * @return a number greater than 0 representing the new ID assigned by the + * database, 0 if the locElement was updated or -1 is some error occurred. + */ + public LocElement saveLocElement(LocElement locElement); } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/FeedbackQACommentManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/FeedbackQACommentManagerImpl.java index f4c5449458..b0d4445f21 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/FeedbackQACommentManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/FeedbackQACommentManagerImpl.java @@ -61,6 +61,13 @@ public List findAll() { } + @Override + public List findAllByPhase(long phaseId) { + + return feedbackQACommentDAO.findAllByPhase(phaseId); + + } + @Override public FeedbackQAComment getFeedbackQACommentById(long feedbackQACommentID) { diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/LocElementManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/LocElementManagerImpl.java index 99ac2d54fb..1839fe0056 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/LocElementManagerImpl.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/LocElementManagerImpl.java @@ -29,62 +29,77 @@ @Named public class LocElementManagerImpl implements LocElementManager { - private LocElementDAO locElementDAO; - // Managers + private LocElementDAO locElementDAO; + // Managers - @Inject - public LocElementManagerImpl(LocElementDAO locElementDAO) { - this.locElementDAO = locElementDAO; + @Inject + public LocElementManagerImpl(LocElementDAO locElementDAO) { + this.locElementDAO = locElementDAO; - } + } - @Override - public void deleteLocElement(long locElementId) { + @Override + public void deleteLocElement(long locElementId) { - this.locElementDAO.deleteLocElement(locElementId); - } + this.locElementDAO.deleteLocElement(locElementId); + } - @Override - public boolean existLocElement(long locElementID) { + @Override + public boolean existLocElement(long locElementID) { - return this.locElementDAO.existLocElement(locElementID); - } + return this.locElementDAO.existLocElement(locElementID); + } - @Override - public List findAll() { + @Override + public List findAll() { - return this.locElementDAO.findAll(); + return this.locElementDAO.findAll(); - } + } - @Override - public List findLocElementByParent(long parentId) { - return this.locElementDAO.findLocElementByParent(parentId); - } + @Override + public List findAllToCountries() { - @Override - public LocElement getLocElementById(long locElementID) { + return this.locElementDAO.findAllToCountries(); - return this.locElementDAO.find(locElementID); - } + } - @Override - public LocElement getLocElementByISOCode(String ISOCode) { + @Override + public List findAllToRegions() { - return this.locElementDAO.findISOCode(ISOCode); - } + return this.locElementDAO.findAllToRegions(); - @Override - public LocElement getLocElementByNumericISOCode(Long ISOCode) { + } - return this.locElementDAO.findNumericISOCode(ISOCode); - } + @Override + public List findLocElementByParent(long parentId) { - @Override - public LocElement saveLocElement(LocElement locElement) { + return this.locElementDAO.findLocElementByParent(parentId); + } - return this.locElementDAO.save(locElement); - } + @Override + public LocElement getLocElementById(long locElementID) { + + return this.locElementDAO.find(locElementID); + } + + @Override + public LocElement getLocElementByISOCode(String ISOCode) { + + return this.locElementDAO.findISOCode(ISOCode); + } + + @Override + public LocElement getLocElementByNumericISOCode(Long ISOCode) { + + return this.locElementDAO.findNumericISOCode(ISOCode); + } + + @Override + public LocElement saveLocElement(LocElement locElement) { + + return this.locElementDAO.save(locElement); + } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java index 3dbe80280d..de3012314c 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java @@ -1277,8 +1277,11 @@ public boolean canLeaveComments() { response = true; } - if (this.getRolesList() != null && !this.getRolesList().isEmpty()) { - for (Role role : this.getRolesList()) { + // cagmboa 19/04/2024 this.getRolesList() function is called once and it is reused + List roles = new ArrayList<>(); + roles = this.getRolesList(); + if (roles != null && !roles.isEmpty()) { + for (Role role : roles) { if (role != null && role.getAcronym() != null) { // FPL & FPM roles can comment @@ -1294,6 +1297,9 @@ public boolean canLeaveComments() { /** * Validate the user permission to replay or react to a comment + * note: The difference with the function canManageFeedbackOld is that the code block + * that starts with the conditional if (projectID != null && response) is eliminated. + * This conditional was not intervening in the function * * @param projectID * @return true if the current user rol is PL or PC @@ -1306,6 +1312,35 @@ public boolean canManageFeedback(Long projectID) { response = true; } + if (this.getRolesList() != null && !this.getRolesList().isEmpty()) { + for (Role role : this.getRolesList()) { + if (role != null && role.getAcronym() != null) { + // FPL & FPM roles can comment + + if (role.getAcronym().equals("PL") || role.getAcronym().equals("PC")) { + response = true; + } + } + } + } + return response; + } + + + /** + * Validate the user permission to replay or react to a comment + * + * @param projectID + * @return true if the current user rol is PL or PC + */ + public boolean canManageFeedbackOld(Long projectID) { + boolean response = false; + + // TODO: Update the permissions for manage feedback comments + if (this.canAccessSuperAdmin()) { + response = true; + } + if (this.getRolesList() != null && !this.getRolesList().isEmpty()) { for (Role role : this.getRolesList()) { if (role != null && role.getAcronym() != null) { @@ -1327,7 +1362,6 @@ public boolean canManageFeedback(Long projectID) { for (ProjectPartner projectPartner : projectPartners) { if (projectPartner != null && projectPartner.getId() != null) { projectParnerPersons = projectPartnerPersonManager.findAllActiveForProjectPartner(projectPartner.getId()); - if (projectParnerPersons != null) { projectParnerPersons = projectParnerPersons.stream() .filter(pp -> pp != null && pp.getUser() != null && pp.getUser().getId() != null @@ -4901,7 +4935,6 @@ public boolean getProjectSectionStatus(String section, long projectID) { } } - returnValue = true; break; case DELIVERABLES: @@ -4962,7 +4995,6 @@ public boolean getProjectSectionStatus(String section, long projectID) { // return false; // } } - returnValue = true; break; @@ -4999,7 +5031,6 @@ public boolean getProjectSectionStatus(String section, long projectID) { prevMissingActivity = new ArrayList<>(); } - prevMissingActivity.stream() .filter((deliverable) -> (deliverable.getDeliverableActivities().isEmpty() || deliverable.getDeliverableActivities().stream().filter(da -> da.isActive()) @@ -5012,7 +5043,6 @@ public boolean getProjectSectionStatus(String section, long projectID) { deliverablesMissingActivity.add(_item); }); - if (deliverablesMissingActivity != null && !deliverablesMissingActivity.isEmpty()) { // this.addMessage(this.getText("missingDeliverableActivity", "deliverable.missing.activity")); // this.getInvalidFields().put("list-deliverable.missing.activity.alert", @@ -5073,7 +5103,6 @@ public boolean getProjectSectionStatus(String section, long projectID) { case DESCRIPTION: case LOCATIONS: - sectionStatus = this.sectionStatusManager.getSectionStatusByProject(projectID, this.getCurrentCycle(), this.getCurrentCycleYear(), this.isUpKeepActive(), section); if (sectionStatus != null) { @@ -5089,7 +5118,6 @@ public boolean getProjectSectionStatus(String section, long projectID) { break; case EXPECTEDSTUDIES: - project = this.projectManager.getProjectById(projectID); List allProjectStudies = new ArrayList(); @@ -5134,7 +5162,6 @@ public boolean getProjectSectionStatus(String section, long projectID) { break; case INNOVATIONS: - project = this.projectManager.getProjectById(projectID); List innovations = project.getProjectInnovations().stream() .filter(c -> c.getProjectInnovationInfo(this.getActualPhase()) != null && c.isActive() @@ -5161,7 +5188,6 @@ public boolean getProjectSectionStatus(String section, long projectID) { break; case POLICIES: - project = this.projectManager.getProjectById(projectID); List policies = project.getProjectPolicies().stream() .filter(c -> c.getProjectPolicyInfo(this.getActualPhase()) != null && c.isActive() @@ -5184,7 +5210,6 @@ public boolean getProjectSectionStatus(String section, long projectID) { break; case LEVERAGES: - sectionStatus = this.sectionStatusManager.getSectionStatusByProject(projectID, this.getCurrentCycle(), this.getCurrentCycleYear(), this.isUpKeepActive(), section); if (sectionStatus != null) { diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/FeedbackQACommentsMultipleAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/FeedbackQACommentsMultipleAction.java index 3aa0d4492b..bcaf98b031 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/FeedbackQACommentsMultipleAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/FeedbackQACommentsMultipleAction.java @@ -85,6 +85,8 @@ public String execute() throws Exception { qa -> qa != null && qa.isActive() && qa.getSectionName() != null && qa.getSectionName().equals(sectionName)) .collect(Collectors.toList()); + // cgamboa 19/04/2024 comments.findAll function has been changed by commentManager.findAllByPhase function + List allfeedbackQAComment = commentManager.findAllByPhase(phaseId); if (fields != null && !fields.isEmpty()) { int countField = 0; for (FeedbackQACommentableFields field : fields) { @@ -97,10 +99,11 @@ public String execute() throws Exception { long fieldIdLocal = fieldId; // Get comments for field - if (fieldId != null && commentManager.findAll() != null) { + // cgamboa 19/04/2024 comments.findAll function has been changed by commentManager.findAllByPhase function + if (fieldId != null && allfeedbackQAComment != null) { if (frontName != null) { - feedbackComments = (commentManager.findAll().stream() + feedbackComments = (allfeedbackQAComment.stream() .filter(c -> c.getField() != null && c.getField().getId() != null && c.getField().getId().equals(fieldIdLocal) && c.getField().getFieldName() != null && c.getField().getFieldName().equals(frontName) && c.getPhase() != null @@ -108,7 +111,7 @@ public String execute() throws Exception { && c.getParentId() == parentId) .collect(Collectors.toList())); } else { - feedbackComments = (commentManager.findAll().stream() + feedbackComments = (allfeedbackQAComment.stream() .filter(c -> c.getField() != null && c.getField().getId() != null && c.getField().getId().equals(fieldIdLocal) && c.getPhase() != null && c.getPhase().getId() != null && c.getPhase().getId().equals(phaseId) && c.getParentId() == parentId) diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesAction.java index b1fe05bc4e..61bcfcdf3c 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesAction.java @@ -549,6 +549,7 @@ public String getTransaction() { @Override public void prepare() throws Exception { + this.loggedCrp = (GlobalUnit) this.getSession().get(APConstants.SESSION_CRP); this.loggedCrp = this.crpManager.getGlobalUnitById(this.loggedCrp.getId()); this.setPhaseID(this.getActualPhase().getId()); @@ -1018,6 +1019,7 @@ public void prepare() throws Exception { } + if (!this.isDraft()) { if (this.expectedStudy.getCountries() != null) { for (ProjectExpectedStudyCountry country : this.expectedStudy.getCountries()) { @@ -1026,16 +1028,29 @@ public void prepare() throws Exception { } } + // Getting The list this.statuses = this.generalStatusManager.findByTable(APConstants.PROJECT_EXPECTED_STUDIES_TABLE); - this.countries = this.locElementManager.findAll().stream() - .filter(c -> c.getLocElementType().getId().intValue() == 2 && c.isActive()).collect(Collectors.toList()); + + this.countries = this.locElementManager.findAllToCountries(); + + // cgamboa 17/04/2024 the query has been optimized to get fewer records + // this.countries = this.locElementManager.findAll().stream().filter(c -> c.getLocElementType().getId().intValue() + // == 2 && + // c.isActive()).collect(Collectors.toList()); + this.geographicScopes = this.geographicScopeManager.findAll(); - this.regions = this.locElementManager.findAll().stream() - .filter(c -> c.getLocElementType().getId().intValue() == 1 && c.isActive() && c.getIsoNumeric() != null) - .collect(Collectors.toList()); + this.regions = this.locElementManager.findAllToRegions(); + + // cgamboa 17/04/2024 the query has been optimized to get fewer records + /* + * this.regions = this.locElementManager.findAll().stream() + * .filter(c -> c.getLocElementType().getId().intValue() == 1 && c.isActive() && c.getIsoNumeric() != null) + * .collect(Collectors.toList()); + */ + this.organizationTypes = this.organizationTypeManager.findAll(); // Focus levels and Too early to tell was removed this.focusLevels = this.focusLevelManager.findAll().stream().collect(Collectors.toList()); @@ -1051,6 +1066,7 @@ public void prepare() throws Exception { this.subIdos = this.srfSubIdoManager.findAll(); this.targets = this.srfSloIndicatorManager.findAll(); + // institutions Project projectTemp = null; if (this.expectedStudy.getProject() != null) { @@ -1079,7 +1095,6 @@ public void prepare() throws Exception { centers = centersTemp; } - this.tags = this.evidenceTagManager.findAll(); this.innovationsList = new ArrayList<>(); this.policyList = new ArrayList<>(); @@ -1115,6 +1130,7 @@ public void prepare() throws Exception { } } + this.myProjects = new ArrayList<>(); for (ProjectPhase projectPhase : phase.getProjectPhases()) { if (projectPhase.getProject().getProjecInfoPhase(this.getActualPhase()) != null) { @@ -1134,6 +1150,7 @@ public void prepare() throws Exception { .filter(gu -> gu.isActive() && (gu.getGlobalUnitType().getId() == 1 || gu.getGlobalUnitType().getId() == 3)) .collect(Collectors.toList()); + List tempPcrp = null; // Update crp list - Delete the actual crp from the list except if this crp was @@ -1148,6 +1165,7 @@ public void prepare() throws Exception { crps.remove(this.getCurrentGlobalUnit()); } + this.flagshipList = this.crpProgramManager.findAll().stream() .filter(p -> p.isActive() && p.getCrp() != null && p.getCrp().getId() == this.loggedCrp.getId() && p.getProgramType() == ProgramType.FLAGSHIP_PROGRAM_TYPE.getValue()) @@ -1158,9 +1176,11 @@ public void prepare() throws Exception { && p.getProgramType() == ProgramType.REGIONAL_PROGRAM_TYPE.getValue()) .collect(Collectors.toList()); + this.institutions = this.institutionManager.findAll().stream().filter(i -> i.isActive()).collect(Collectors.toList()); + this.expectedStudyDB = this.projectExpectedStudyManager.getProjectExpectedStudyById(this.expectedID); if (this.expectedStudyDB.getProject() != null) { @@ -1169,6 +1189,7 @@ public void prepare() throws Exception { this.project.getProjecInfoPhase(phase); } + if (this.project != null) { Project projectL = this.projectManager.getProjectById(this.projectID); @@ -1181,6 +1202,7 @@ public void prepare() throws Exception { milestones = new ArrayList<>(); projectOutcomes = new ArrayList<>(); + // Get outcomes list List projectOutcomesList = new ArrayList<>(); projectOutcomesList = projectL.getProjectOutcomes().stream() @@ -1440,6 +1462,7 @@ public void prepare() throws Exception { } + } @Override From 5d696af382dcfdde752184e93a0bfc1f2555d171 Mon Sep 17 00:00:00 2001 From: Gamboa Date: Mon, 22 Apr 2024 17:46:30 -0500 Subject: [PATCH 4/6] :recycle: refactor(BaseAction): Improve performance of activities queries related to the OICRs MELIAs section. A2-467 --- .../ccafs/marlo/data/dao/DeliverableDAO.java | 10 ++++ .../data/dao/mysql/DeliverableMySQLDAO.java | 40 ++++++++++++- .../data/manager/DeliverableManager.java | 10 ++++ .../manager/impl/DeliverableManagerImpl.java | 15 +++++ .../cgiar/ccafs/marlo/action/BaseAction.java | 56 ++++++++++++------- .../projects/DeliverableListAction.java | 28 +++++----- .../ProjectExpectedStudiesListAction.java | 43 +++++++------- 7 files changed, 147 insertions(+), 55 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 9695f3e0a4..8054997260 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 @@ -98,6 +98,16 @@ public List getDeliverablesByParameters(Phase phase, boolean filter public List getPublicationsByPhase(long phase); + /** + * get deliverables without activities + * + * @author IBD + * @param phase phase of the project + * @param projectId project id + * @return quantity deliverables without activities + */ + int getQuantityDeliverablesWithActivities(long phase, long projectId); + public Boolean isDeliverableExcluded(Long deliverableId, Long phaseId); /** 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 20f78be49a..36cecf1dc4 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 @@ -199,7 +199,6 @@ public List getDeliverablesByParameters(Phase phase, boolean filter return deliverables; } - @Override public List getDeliverablesByPhase(long phase) { StringBuilder query = new StringBuilder(); @@ -243,6 +242,7 @@ public List getDeliverablesByProjectAndPhase(long phaseId, long pro return deliverables; } + @Override public List getDeliverablesByProjectAndPhaseHome(long phaseId, long projectId) { String query = "select d.id as deliverableId, coalesce(di.newExpectedYear, -1) as newExpectedYear, " @@ -395,6 +395,44 @@ public List getPublicationsByPhase(long phase) { return deliverables; } + /** + * get deliverables without activities + * + * @author IBD + * @param phase phase of the project + * @param projectId project id + * @return quantity deliverables without activities + */ + @Override + public int getQuantityDeliverablesWithActivities(long phase, long projectId) { + StringBuilder query = new StringBuilder(); + query.append("SELECT count(*) as count FROM deliverables d "); + query.append("join deliverables_info di on d.id = di.deliverable_id "); + query.append("join phases p on p.id = d.id_phase"); + query.append(" WHERE d.id_phase=" + phase); + query.append(" and d.id_phase = di.id_phase "); + query.append(" and d.is_active = 1 and d.is_active =di.is_active "); + query.append(" and d.project_id=" + projectId); + query.append( + " and (d.id not in (select da.deliverable_id from deliverable_activities da where da.deliverable_id = d.id and da.is_active =1 ) "); + query.append( + " or d.id not in (select da.deliverable_id from deliverable_activities da where deliverable_id = d.id and da.is_active =1 and da.id_phase =p.id) "); + query.append( + " or d.id not in (select da.deliverable_id from deliverable_activities da join activities a on da.activity_id = a.id where deliverable_id = d.id and da.is_active =1 and a.is_active =1 and da.id_phase =p.id)) "); + + + List> rList = super.findCustomQuery(query.toString()); + int deliverable = 0; + + if (rList != null) { + for (Map map : rList) { + deliverable = Integer.parseInt(map.get("count").toString()); + } + } + + return deliverable; + } + @Override public Boolean isDeliverableExcluded(Long deliverableId, Long phaseId) { StringBuilder query = new StringBuilder(); 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 91c8b2bb12..375ac142f7 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 @@ -138,6 +138,16 @@ public List getDeliverablesByParameters(Phase phase, boolean filter */ public List getPublicationsList(LiaisonInstitution liaisonInstitution, Phase phase); + /** + * get deliverables without activities + * + * @author IBD + * @param phase phase of the project + * @param projectId project id + * @return quantity deliverables without activities + */ + int getQuantityDeliverablesWithActivities(long phase, long projectId); + public Boolean isDeliverableExcluded(Long deliverableId, Long phaseId); 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 a4f1c10c84..e6ac067777 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 @@ -169,6 +169,7 @@ public List getDeliverablesByParameters(Phase phase, boolean filter return deliverableDAO.getDeliverablesByParameters(phase, filterPhaseYear, filterParticipants, filterPublications); } + @Override public List getDeliverablesByPhase(long phase) { return deliverableDAO.getDeliverablesByPhase(phase); @@ -614,6 +615,20 @@ public List getPublicationsList(LiaisonInstitution liaisonInstituti return deliverables; } + /** + * get deliverables without activities + * + * @author IBD + * @param phase phase of the project + * @param projectId project id + * @return quantity deliverables without activities + */ + @Override + public int getQuantityDeliverablesWithActivities(long phase, long projectId) { + + return deliverableDAO.getQuantityDeliverablesWithActivities(phase, projectId); + } + @Override public Boolean isDeliverableExcluded(Long deliverableId, Long phaseId) { diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java index de3012314c..36be62cf5c 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/BaseAction.java @@ -5017,31 +5017,46 @@ public boolean getProjectSectionStatus(String section, long projectID) { List deliverablesMissingActivity = new ArrayList<>(); List prevMissingActivity = new ArrayList<>(); + int quantityMissingDeliverables = 0; try { - prevMissingActivity = project.getCurrentDeliverables(this.getActualPhase()); - - if (prevMissingActivity != null && !prevMissingActivity.isEmpty()) { - prevMissingActivity = prevMissingActivity.stream() - .filter(d -> d != null && d.getDeliverableInfo(this.getActualPhase()).getStatus() != null - && d.getDeliverableInfo(this.getActualPhase()).getStatus() != 5) - .collect(Collectors.toList()); - } + quantityMissingDeliverables = deliverableManager + .getQuantityDeliverablesWithActivities(this.getActualPhase().getId(), project.getId()); } catch (Exception e) { - LOG.error("unable to get deliverables without activities", e); + LOG.error("unable to get deliverables without activities Quantity", e); prevMissingActivity = new ArrayList<>(); } - prevMissingActivity.stream() - .filter((deliverable) -> (deliverable.getDeliverableActivities().isEmpty() - || deliverable.getDeliverableActivities().stream().filter(da -> da.isActive()) - .collect(Collectors.toList()).isEmpty() - || deliverable.getDeliverableActivities().stream() - .filter(da -> da.getPhase().getId().equals(this.getActualPhase().getId()) - && da.getActivity().isActive() && da.isActive()) - .collect(Collectors.toList()).isEmpty())) - .forEachOrdered((_item) -> { - deliverablesMissingActivity.add(_item); - }); + // cgamboa 22/04/2024 query is added to get quantity deliverables without activities, before to do the + // validations + if (quantityMissingDeliverables > 0) { + try { + prevMissingActivity = project.getCurrentDeliverables(this.getActualPhase()); + + + if (prevMissingActivity != null && !prevMissingActivity.isEmpty()) { + prevMissingActivity = prevMissingActivity.stream() + .filter(d -> d != null && d.getDeliverableInfo(this.getActualPhase()).getStatus() != null + && d.getDeliverableInfo(this.getActualPhase()).getStatus() != 5) + .collect(Collectors.toList()); + } + } catch (Exception e) { + LOG.error("unable to get deliverables without activities", e); + prevMissingActivity = new ArrayList<>(); + } + + prevMissingActivity.stream() + .filter((deliverable) -> (deliverable.getDeliverableActivities().isEmpty() + || deliverable.getDeliverableActivities().stream().filter(da -> da.isActive()) + .collect(Collectors.toList()).isEmpty() + || deliverable.getDeliverableActivities().stream() + .filter(da -> da.getPhase().getId().equals(this.getActualPhase().getId()) + && da.getActivity().isActive() && da.isActive()) + .collect(Collectors.toList()).isEmpty())) + .forEachOrdered((_item) -> { + deliverablesMissingActivity.add(_item); + }); + + } if (deliverablesMissingActivity != null && !deliverablesMissingActivity.isEmpty()) { // this.addMessage(this.getText("missingDeliverableActivity", "deliverable.missing.activity")); @@ -5058,6 +5073,7 @@ public boolean getProjectSectionStatus(String section, long projectID) { * status.setMissingFields("missingDeliverableActivity"); * sectionStatusManager.saveSectionStatus(status); */ + return false; } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableListAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableListAction.java index 490468cbb2..6d1b8e9a16 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableListAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableListAction.java @@ -776,19 +776,21 @@ public void loadCurrentDeliverables() { } // Shared with others - for (ProjectDeliverableShared deliverableShared : deliverablesShared) { - if (deliverableShared.getDeliverable().getSharedWithProjects() == null) { - deliverableShared.getDeliverable().setSharedWithProjects( - "" + deliverableShared.getProject().getProjecInfoPhase(this.getActualPhase()).getAcronym()); - } else { - if (deliverableShared.getDeliverable() != null - && deliverableShared.getDeliverable().getSharedWithProjects() != null - && deliverableShared.getProject().getProjecInfoPhase(this.getActualPhase()).getAcronym() != null - && !deliverableShared.getDeliverable().getSharedWithProjects() - .contains(deliverableShared.getProject().getProjecInfoPhase(this.getActualPhase()).getAcronym())) { - deliverableShared.getDeliverable() - .setSharedWithProjects(deliverableShared.getDeliverable().getSharedWithProjects() + "; " - + deliverableShared.getProject().getProjecInfoPhase(this.getActualPhase()).getAcronym()); + if (deliverablesShared != null && !deliverablesShared.isEmpty()) { + for (ProjectDeliverableShared deliverableShared : deliverablesShared) { + if (deliverableShared.getDeliverable().getSharedWithProjects() == null) { + deliverableShared.getDeliverable().setSharedWithProjects( + "" + deliverableShared.getProject().getProjecInfoPhase(this.getActualPhase()).getAcronym()); + } else { + if (deliverableShared.getDeliverable() != null + && deliverableShared.getDeliverable().getSharedWithProjects() != null + && deliverableShared.getProject().getProjecInfoPhase(this.getActualPhase()).getAcronym() != null + && !deliverableShared.getDeliverable().getSharedWithProjects().contains( + deliverableShared.getProject().getProjecInfoPhase(this.getActualPhase()).getAcronym())) { + deliverableShared.getDeliverable() + .setSharedWithProjects(deliverableShared.getDeliverable().getSharedWithProjects() + "; " + + deliverableShared.getProject().getProjecInfoPhase(this.getActualPhase()).getAcronym()); + } } } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesListAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesListAction.java index 5c32f931cf..d6a626335f 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesListAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/ProjectExpectedStudiesListAction.java @@ -284,36 +284,37 @@ public void getCommentStatusesNew() { commentAnsweredList = feedbackQACommentableFieldsManager.getAnsweredCommentByPhaseToStudy(this.getActualPhase().getId()); + if (projectStudies != null && !projectStudies.isEmpty()) { + for (ProjectExpectedStudy study : projectStudies) { + int answeredComments = 0; + int totalComments = 0; + try { - for (ProjectExpectedStudy study : projectStudies) { - int answeredComments = 0; - int totalComments = 0; - try { - - for (String string : commentList) { - String test = string.replace("|", ";"); + for (String string : commentList) { + String test = string.replace("|", ";"); - if (test.split(";")[0].equals(study.getId() + "")) { - totalComments = Integer.parseInt(test.split(";")[1]); + if (test.split(";")[0].equals(study.getId() + "")) { + totalComments = Integer.parseInt(test.split(";")[1]); + } } - } - for (String string : commentAnsweredList) { - String test = string.replace("|", ";"); + for (String string : commentAnsweredList) { + String test = string.replace("|", ";"); - if (test.split(";")[0].equals(study.getId() + "")) { - answeredComments = Integer.parseInt(test.split(";")[1]); + if (test.split(";")[0].equals(study.getId() + "")) { + answeredComments = Integer.parseInt(test.split(";")[1]); + } } - } - study.setCommentStatus(answeredComments + "/" + totalComments); - if (study.getCommentStatus() == null - || (study.getCommentStatus() != null && study.getCommentStatus().isEmpty())) { + study.setCommentStatus(answeredComments + "/" + totalComments); + if (study.getCommentStatus() == null + || (study.getCommentStatus() != null && study.getCommentStatus().isEmpty())) { + study.setCommentStatus(0 + "/" + 0); + } + + } catch (Exception e) { study.setCommentStatus(0 + "/" + 0); } - - } catch (Exception e) { - study.setCommentStatus(0 + "/" + 0); } } From bb639c0f5c9bb795db710c42be5c4601de3abddf Mon Sep 17 00:00:00 2001 From: JhonSGIzquierdo Date: Fri, 26 Apr 2024 09:26:27 -0500 Subject: [PATCH 5/6] :wrench: chore(IPI-2.3): overlay visualization --- .../WEB-INF/crp/views/projects/projectDeliverable.ftl | 4 ++-- .../main/webapp/crp/css/projects/projectDeliverable.css | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl index 6cd34f676c..f491454bd8 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/projects/projectDeliverable.ftl @@ -101,7 +101,7 @@
-