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/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/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/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/DeliverableMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableMySQLDAO.java index 20f78be49a..c23db1815d 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 @@ -243,6 +243,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 +396,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/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/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/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/DeliverableManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableManager.java index 91c8b2bb12..7e3d8ff4ab 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,15 @@ 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/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/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/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/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-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/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-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..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 @@ -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; @@ -4985,33 +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<>(); } + // 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()); - 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 (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")); @@ -5028,6 +5073,7 @@ public boolean getProjectSectionStatus(String section, long projectID) { * status.setMissingFields("missingDeliverableActivity"); * sectionStatusManager.saveSectionStatus(status); */ + return false; } } @@ -5073,7 +5119,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 +5134,6 @@ public boolean getProjectSectionStatus(String section, long projectID) { break; case EXPECTEDSTUDIES: - project = this.projectManager.getProjectById(projectID); List allProjectStudies = new ArrayList(); @@ -5134,7 +5178,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 +5204,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 +5226,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/DeliverableListAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableListAction.java index 490468cbb2..23453fc125 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()); + } } } } @@ -1226,4 +1228,4 @@ public void setProject(Project project) { public void setProjectID(long projectID) { this.projectID = projectID; } -} +} \ No newline at end of file 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 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..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 @@ -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,55 @@ 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()); + + if (projectStudies != null && !projectStudies.isEmpty()) { + 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 +363,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 +496,10 @@ public void prepare() throws Exception { } } if (this.hasSpecificities(this.feedbackModule())) { - this.getCommentStatuses(); + // this.getCommentStatuses(); + this.getCommentStatusesNew(); } + } 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..9b1ddf3434 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 @@ -515,4 +515,4 @@ public void setProjectOutcomeID(long projectOutcomeID) { public void setStatus(Map status) { this.status = status; } -} +} \ No newline at end of file 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 @@
-