diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java index 1573156562..d7c56425cc 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java @@ -155,6 +155,7 @@ public final class APConstants { public static final String HIGHLIGHT_COMMENTS_ACTIVE = "highlight_comments_active"; public static final String TIP_SECTION_ACTIVE = "tip_section_active"; + public static final String SHFRM_CONTRIBUTION_ACTIVE = "shfrm_contribution_active"; public static final String IS_EXPECTED_DELIVERABLE_REPORT_All_YEARS_VISIBLE = "is_expected_deliverable_report_all_years_visible"; @@ -175,6 +176,8 @@ public final class APConstants { public static final String DELIVERABLE_FILE_LOCALLY_HOSTED_STR = "Locally"; public static final String DELIVERABLE_ID = "deliverableId"; + public static final String PRIORITY_ACTION_ID = "priorityActionId"; + public static final String SUB_ACTION_ID = "subActionId"; public static final int DELIVERABLE_QUALITY_ANSWER_NO = 3; public static final int DELIVERABLE_QUALITY_ANSWER_YES = 2; public static final int DELIVERABLE_QUALITY_ANSWER_YES_BUT_NO = 1; diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmPriorityActionDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmPriorityActionDAO.java new file mode 100644 index 0000000000..59e77d918d --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmPriorityActionDAO.java @@ -0,0 +1,72 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao; + +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; + +import java.util.List; + + +public interface DeliverableShfrmPriorityActionDAO { + + /** + * This method removes a specific deliverableShfrmPriorityAction value from the database. + * + * @param deliverableShfrmPriorityActionId is the deliverableShfrmPriorityAction identifier. + * @return true if the deliverableShfrmPriorityAction was successfully deleted, false otherwise. + */ + public void deleteDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionId); + + /** + * This method validate if the deliverableShfrmPriorityAction identify with the given id exists in the system. + * + * @param deliverableShfrmPriorityActionID is a deliverableShfrmPriorityAction identifier. + * @return true if the deliverableShfrmPriorityAction exists, false otherwise. + */ + public boolean existDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionID); + + /** + * This method gets a deliverableShfrmPriorityAction object by a given deliverableShfrmPriorityAction identifier. + * + * @param deliverableShfrmPriorityActionID is the deliverableShfrmPriorityAction identifier. + * @return a DeliverableShfrmPriorityAction object. + */ + public DeliverableShfrmPriorityAction find(long id); + + /** + * This method gets a list of deliverableShfrmPriorityAction that are active + * + * @return a list from DeliverableShfrmPriorityAction null if no exist records + */ + public List findAll(); + + + public List findByDeliverableAndPhase(long deliverableId, long phaseId); + + + /** + * This method saves the information of the given deliverableShfrmPriorityAction + * + * @param deliverableShfrmPriorityAction - is the deliverableShfrmPriorityAction 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 + * deliverableShfrmPriorityAction was + * updated + * or -1 is some error occurred. + */ + public DeliverableShfrmPriorityAction save(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction); +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java new file mode 100644 index 0000000000..0f0b1979df --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/DeliverableShfrmSubActionDAO.java @@ -0,0 +1,75 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao; + +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; + +import java.util.List; + + +public interface DeliverableShfrmSubActionDAO { + + /** + * This method removes a specific deliverableShfrmSubAction value from the database. + * + * @param deliverableShfrmSubActionId is the deliverableShfrmSubAction identifier. + * @return true if the deliverableShfrmSubAction was successfully deleted, false otherwise. + */ + public void deleteDeliverableShfrmSubAction(long deliverableShfrmSubActionId); + + /** + * This method validate if the deliverableShfrmSubAction identify with the given id exists in the system. + * + * @param deliverableShfrmSubActionID is a deliverableShfrmSubAction identifier. + * @return true if the deliverableShfrmSubAction exists, false otherwise. + */ + public boolean existDeliverableShfrmSubAction(long deliverableShfrmSubActionID); + + /** + * This method gets a deliverableShfrmSubAction object by a given deliverableShfrmSubAction identifier. + * + * @param deliverableShfrmSubActionID is the deliverableShfrmSubAction identifier. + * @return a DeliverableShfrmSubAction object. + */ + public DeliverableShfrmSubAction find(long id); + + /** + * This method gets a list of deliverableShfrmSubAction that are active + * + * @return a list from DeliverableShfrmSubAction null if no exist records + */ + public List findAll(); + + + public List findByPriorityActionAndPhase(long priorityActionId, long phaseId); + + public List findByPriorityActionPhaseAndSubAction(long priorityActionId, long phaseId, + long shfrmSubActionId); + + + /** + * This method saves the information of the given deliverableShfrmSubAction + * + * @param deliverableShfrmSubAction - is the deliverableShfrmSubAction 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 + * deliverableShfrmSubAction was + * updated + * or -1 is some error occurred. + */ + public DeliverableShfrmSubAction save(DeliverableShfrmSubAction deliverableShfrmSubAction); +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmPriorityActionDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmPriorityActionDAO.java new file mode 100644 index 0000000000..5f03fe1b24 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmPriorityActionDAO.java @@ -0,0 +1,67 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao; + +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; + +import java.util.List; + + +public interface ShfrmPriorityActionDAO { + + /** + * This method removes a specific shfrmPriorityAction value from the database. + * + * @param shfrmPriorityActionId is the shfrmPriorityAction identifier. + * @return true if the shfrmPriorityAction was successfully deleted, false otherwise. + */ + public void deleteShfrmPriorityAction(long shfrmPriorityActionId); + + /** + * This method validate if the shfrmPriorityAction identify with the given id exists in the system. + * + * @param shfrmPriorityActionID is a shfrmPriorityAction identifier. + * @return true if the shfrmPriorityAction exists, false otherwise. + */ + public boolean existShfrmPriorityAction(long shfrmPriorityActionID); + + /** + * This method gets a shfrmPriorityAction object by a given shfrmPriorityAction identifier. + * + * @param shfrmPriorityActionID is the shfrmPriorityAction identifier. + * @return a ShfrmPriorityAction object. + */ + public ShfrmPriorityAction find(long id); + + /** + * This method gets a list of shfrmPriorityAction that are active + * + * @return a list from ShfrmPriorityAction null if no exist records + */ + public List findAll(); + + + /** + * This method saves the information of the given shfrmPriorityAction + * + * @param shfrmPriorityAction - is the shfrmPriorityAction 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 shfrmPriorityAction was + * updated + * or -1 is some error occurred. + */ + public ShfrmPriorityAction save(ShfrmPriorityAction shfrmPriorityAction); +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmSubActionDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmSubActionDAO.java new file mode 100644 index 0000000000..b1713c1bd6 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/ShfrmSubActionDAO.java @@ -0,0 +1,67 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao; + +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; + +import java.util.List; + + +public interface ShfrmSubActionDAO { + + /** + * This method removes a specific shfrmSubAction value from the database. + * + * @param shfrmSubActionId is the shfrmSubAction identifier. + * @return true if the shfrmSubAction was successfully deleted, false otherwise. + */ + public void deleteShfrmSubAction(long shfrmSubActionId); + + /** + * This method validate if the shfrmSubAction identify with the given id exists in the system. + * + * @param shfrmSubActionID is a shfrmSubAction identifier. + * @return true if the shfrmSubAction exists, false otherwise. + */ + public boolean existShfrmSubAction(long shfrmSubActionID); + + /** + * This method gets a shfrmSubAction object by a given shfrmSubAction identifier. + * + * @param shfrmSubActionID is the shfrmSubAction identifier. + * @return a ShfrmSubAction object. + */ + public ShfrmSubAction find(long id); + + /** + * This method gets a list of shfrmSubAction that are active + * + * @return a list from ShfrmSubAction null if no exist records + */ + public List findAll(); + + + /** + * This method saves the information of the given shfrmSubAction + * + * @param shfrmSubAction - is the shfrmSubAction 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 shfrmSubAction was + * updated + * or -1 is some error occurred. + */ + public ShfrmSubAction save(ShfrmSubAction shfrmSubAction); +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/SoilIndicatorDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/SoilIndicatorDAO.java new file mode 100644 index 0000000000..f6e8bc75fd --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/SoilIndicatorDAO.java @@ -0,0 +1,67 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao; + +import org.cgiar.ccafs.marlo.data.model.SoilIndicator; + +import java.util.List; + + +public interface SoilIndicatorDAO { + + /** + * This method removes a specific soilIndicator value from the database. + * + * @param soilIndicatorId is the soilIndicator identifier. + * @return true if the soilIndicator was successfully deleted, false otherwise. + */ + public void deleteSoilIndicator(long soilIndicatorId); + + /** + * This method validate if the soilIndicator identify with the given id exists in the system. + * + * @param soilIndicatorID is a soilIndicator identifier. + * @return true if the soilIndicator exists, false otherwise. + */ + public boolean existSoilIndicator(long soilIndicatorID); + + /** + * This method gets a soilIndicator object by a given soilIndicator identifier. + * + * @param soilIndicatorID is the soilIndicator identifier. + * @return a SoilIndicator object. + */ + public SoilIndicator find(long id); + + /** + * This method gets a list of soilIndicator that are active + * + * @return a list from SoilIndicator null if no exist records + */ + public List findAll(); + + + /** + * This method saves the information of the given soilIndicator + * + * @param soilIndicator - is the soilIndicator 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 soilIndicator was + * updated + * or -1 is some error occurred. + */ + public SoilIndicator save(SoilIndicator soilIndicator); +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java new file mode 100644 index 0000000000..b9f8064b03 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmPriorityActionMySQLDAO.java @@ -0,0 +1,101 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao.mysql; + +import org.cgiar.ccafs.marlo.data.dao.DeliverableShfrmPriorityActionDAO; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.hibernate.SessionFactory; + +@Named +public class DeliverableShfrmPriorityActionMySQLDAO extends AbstractMarloDAO + implements DeliverableShfrmPriorityActionDAO { + + + @Inject + public DeliverableShfrmPriorityActionMySQLDAO(SessionFactory sessionFactory) { + super(sessionFactory); + } + + @Override + public void deleteDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionId) { + DeliverableShfrmPriorityAction deliverableShfrmPriorityAction = this.find(deliverableShfrmPriorityActionId); + /* + * deliverableShfrmPriorityAction.setActive(false); + * this.update(deliverableShfrmPriorityAction); + */ + this.delete(deliverableShfrmPriorityAction); + + } + + @Override + public boolean existDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionID) { + DeliverableShfrmPriorityAction deliverableShfrmPriorityAction = this.find(deliverableShfrmPriorityActionID); + if (deliverableShfrmPriorityAction == null) { + return false; + } + return true; + + } + + @Override + public DeliverableShfrmPriorityAction find(long id) { + return super.find(DeliverableShfrmPriorityAction.class, id); + + } + + @Override + public List findAll() { + String query = "from " + DeliverableShfrmPriorityAction.class.getName() + " where is_active=1"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public List findByDeliverableAndPhase(long deliverableId, long phaseId) { + String query = "from " + DeliverableShfrmPriorityAction.class.getName() + " where is_active=1 and deliverable_id=" + + deliverableId + " and id_phase=" + phaseId; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + } + + @Override + public DeliverableShfrmPriorityAction save(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + if (deliverableShfrmPriorityAction.getId() == null) { + super.saveEntity(deliverableShfrmPriorityAction); + } else { + deliverableShfrmPriorityAction = super.update(deliverableShfrmPriorityAction); + } + + + return deliverableShfrmPriorityAction; + } + + +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java new file mode 100644 index 0000000000..3c87150e4a --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/DeliverableShfrmSubActionMySQLDAO.java @@ -0,0 +1,117 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao.mysql; + +import org.cgiar.ccafs.marlo.data.dao.DeliverableShfrmSubActionDAO; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.hibernate.SessionFactory; + +@Named +public class DeliverableShfrmSubActionMySQLDAO extends AbstractMarloDAO + implements DeliverableShfrmSubActionDAO { + + + @Inject + public DeliverableShfrmSubActionMySQLDAO(SessionFactory sessionFactory) { + super(sessionFactory); + } + + @Override + public void deleteDeliverableShfrmSubAction(long deliverableShfrmSubActionId) { + DeliverableShfrmSubAction deliverableShfrmSubAction = this.find(deliverableShfrmSubActionId); + /* + * deliverableShfrmSubAction.setActive(false); + * this.update(deliverableShfrmSubAction); + */ + this.delete(deliverableShfrmSubAction); + + } + + @Override + public boolean existDeliverableShfrmSubAction(long deliverableShfrmSubActionID) { + DeliverableShfrmSubAction deliverableShfrmSubAction = this.find(deliverableShfrmSubActionID); + if (deliverableShfrmSubAction == null) { + return false; + } + return true; + + } + + @Override + public DeliverableShfrmSubAction find(long id) { + return super.find(DeliverableShfrmSubAction.class, id); + + } + + @Override + public List findAll() { + String query = "from " + DeliverableShfrmSubAction.class.getName() + " where is_active=1"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + + @Override + public List findByPriorityActionAndPhase(long priorityActionId, long phaseId) { + String query = "from " + DeliverableShfrmSubAction.class.getName() + + " where is_active=1 and deliverable_shfrm_priority_action_id=" + priorityActionId + " and id_phase=" + phaseId; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public List findByPriorityActionPhaseAndSubAction(long priorityActionId, long phaseId, + long shfrmSubActionId) { + String query = "from " + DeliverableShfrmSubAction.class.getName() + + " where is_active=1 and deliverable_shfrm_priority_action_id=" + priorityActionId + " and id_phase=" + phaseId + + " and shfrm_sub_action_id=" + shfrmSubActionId; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public DeliverableShfrmSubAction save(DeliverableShfrmSubAction deliverableShfrmSubAction) { + if (deliverableShfrmSubAction.getId() == null) { + super.saveEntity(deliverableShfrmSubAction); + } else { + deliverableShfrmSubAction = super.update(deliverableShfrmSubAction); + } + + + return deliverableShfrmSubAction; + } + + +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmPriorityActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmPriorityActionMySQLDAO.java new file mode 100644 index 0000000000..796cf45d58 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmPriorityActionMySQLDAO.java @@ -0,0 +1,89 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao.mysql; + +import org.cgiar.ccafs.marlo.data.dao.ShfrmPriorityActionDAO; +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.hibernate.SessionFactory; + +@Named +public class ShfrmPriorityActionMySQLDAO extends AbstractMarloDAO + implements ShfrmPriorityActionDAO { + + + @Inject + public ShfrmPriorityActionMySQLDAO(SessionFactory sessionFactory) { + super(sessionFactory); + } + + @Override + public void deleteShfrmPriorityAction(long shfrmPriorityActionId) { + ShfrmPriorityAction shfrmPriorityAction = this.find(shfrmPriorityActionId); + /* + * shfrmPriorityAction.setActive(false); + * this.update(shfrmPriorityAction); + */ + this.delete(shfrmPriorityAction); + } + + @Override + public boolean existShfrmPriorityAction(long shfrmPriorityActionID) { + ShfrmPriorityAction shfrmPriorityAction = this.find(shfrmPriorityActionID); + if (shfrmPriorityAction == null) { + return false; + } + return true; + + } + + @Override + public ShfrmPriorityAction find(long id) { + return super.find(ShfrmPriorityAction.class, id); + + } + + @Override + public List findAll() { + String query = "from " + ShfrmPriorityAction.class.getName() + " where is_active=1"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public ShfrmPriorityAction save(ShfrmPriorityAction shfrmPriorityAction) { + if (shfrmPriorityAction.getId() == null) { + super.saveEntity(shfrmPriorityAction); + } else { + shfrmPriorityAction = super.update(shfrmPriorityAction); + } + + + return shfrmPriorityAction; + } + + +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java new file mode 100644 index 0000000000..aabe72299e --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/ShfrmSubActionMySQLDAO.java @@ -0,0 +1,88 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao.mysql; + +import org.cgiar.ccafs.marlo.data.dao.ShfrmSubActionDAO; +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.hibernate.SessionFactory; + +@Named +public class ShfrmSubActionMySQLDAO extends AbstractMarloDAO implements ShfrmSubActionDAO { + + + @Inject + public ShfrmSubActionMySQLDAO(SessionFactory sessionFactory) { + super(sessionFactory); + } + + @Override + public void deleteShfrmSubAction(long shfrmSubActionId) { + ShfrmSubAction shfrmSubAction = this.find(shfrmSubActionId); + /* + * shfrmSubAction.setActive(false); + * this.update(shfrmSubAction); + */ + this.delete(shfrmSubAction); + } + + @Override + public boolean existShfrmSubAction(long shfrmSubActionID) { + ShfrmSubAction shfrmSubAction = this.find(shfrmSubActionID); + if (shfrmSubAction == null) { + return false; + } + return true; + + } + + @Override + public ShfrmSubAction find(long id) { + return super.find(ShfrmSubAction.class, id); + + } + + @Override + public List findAll() { + String query = "from " + ShfrmSubAction.class.getName() + " where is_active=1"; + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public ShfrmSubAction save(ShfrmSubAction shfrmSubAction) { + if (shfrmSubAction.getId() == null) { + super.saveEntity(shfrmSubAction); + } else { + shfrmSubAction = super.update(shfrmSubAction); + } + + + return shfrmSubAction; + } + + +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java new file mode 100644 index 0000000000..04f9275ac2 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/dao/mysql/SoilIndicatorMySQLDAO.java @@ -0,0 +1,84 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + + +package org.cgiar.ccafs.marlo.data.dao.mysql; + +import org.cgiar.ccafs.marlo.data.dao.SoilIndicatorDAO; +import org.cgiar.ccafs.marlo.data.model.SoilIndicator; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.hibernate.SessionFactory; + +@Named +public class SoilIndicatorMySQLDAO extends AbstractMarloDAO implements SoilIndicatorDAO { + + + @Inject + public SoilIndicatorMySQLDAO(SessionFactory sessionFactory) { + super(sessionFactory); + } + + @Override + public void deleteSoilIndicator(long soilIndicatorId) { + SoilIndicator soilIndicator = this.find(soilIndicatorId); + this.delete(soilIndicator); + } + + @Override + public boolean existSoilIndicator(long soilIndicatorID) { + SoilIndicator soilIndicator = this.find(soilIndicatorID); + if (soilIndicator == null) { + return false; + } + return true; + + } + + @Override + public SoilIndicator find(long id) { + return super.find(SoilIndicator.class, id); + + } + + @Override + public List findAll() { + String query = "from " + SoilIndicator.class.getName(); + List list = super.findAll(query); + if (list.size() > 0) { + return list; + } + return null; + + } + + @Override + public SoilIndicator save(SoilIndicator soilIndicator) { + if (soilIndicator.getId() == null) { + super.saveEntity(soilIndicator); + } else { + soilIndicator = super.update(soilIndicator); + } + + + return soilIndicator; + } + + +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmPriorityActionManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmPriorityActionManager.java new file mode 100644 index 0000000000..217e982ac2 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmPriorityActionManager.java @@ -0,0 +1,79 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager; + +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; + +import java.util.List; + + +/** + * @author CCAFS + */ + +public interface DeliverableShfrmPriorityActionManager { + + + /** + * This method removes a specific deliverableShfrmPriorityAction value from the database. + * + * @param deliverableShfrmPriorityActionId is the deliverableShfrmPriorityAction identifier. + * @return true if the deliverableShfrmPriorityAction was successfully deleted, false otherwise. + */ + public void deleteDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionId); + + + /** + * This method validate if the deliverableShfrmPriorityAction identify with the given id exists in the system. + * + * @param deliverableShfrmPriorityActionID is a deliverableShfrmPriorityAction identifier. + * @return true if the deliverableShfrmPriorityAction exists, false otherwise. + */ + public boolean existDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionID); + + + /** + * This method gets a list of deliverableShfrmPriorityAction that are active + * + * @return a list from DeliverableShfrmPriorityAction null if no exist records + */ + public List findAll(); + + public List findByDeliverableAndPhase(long deliverableId, long phaseId); + + + /** + * This method gets a deliverableShfrmPriorityAction object by a given deliverableShfrmPriorityAction identifier. + * + * @param deliverableShfrmPriorityActionID is the deliverableShfrmPriorityAction identifier. + * @return a DeliverableShfrmPriorityAction object. + */ + public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityActionById(long deliverableShfrmPriorityActionID); + + /** + * This method saves the information of the given deliverableShfrmPriorityAction + * + * @param deliverableShfrmPriorityAction - is the deliverableShfrmPriorityAction 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 + * deliverableShfrmPriorityAction was + * updated + * or -1 is some error occurred. + */ + public DeliverableShfrmPriorityAction + saveDeliverableShfrmPriorityAction(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction); + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java new file mode 100644 index 0000000000..7b5e69a8a5 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/DeliverableShfrmSubActionManager.java @@ -0,0 +1,80 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager; + +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; + +import java.util.List; + + +/** + * @author CCAFS + */ + +public interface DeliverableShfrmSubActionManager { + + + /** + * This method removes a specific deliverableShfrmSubAction value from the database. + * + * @param deliverableShfrmSubActionId is the deliverableShfrmSubAction identifier. + * @return true if the deliverableShfrmSubAction was successfully deleted, false otherwise. + */ + public void deleteDeliverableShfrmSubAction(long deliverableShfrmSubActionId); + + + /** + * This method validate if the deliverableShfrmSubAction identify with the given id exists in the system. + * + * @param deliverableShfrmSubActionID is a deliverableShfrmSubAction identifier. + * @return true if the deliverableShfrmSubAction exists, false otherwise. + */ + public boolean existDeliverableShfrmSubAction(long deliverableShfrmSubActionID); + + + /** + * This method gets a list of deliverableShfrmSubAction that are active + * + * @return a list from DeliverableShfrmSubAction null if no exist records + */ + public List findAll(); + + + public List findByPriorityActionAndPhase(long priorityActionId, long phaseId); + + public List findByPriorityActionPhaseAndSubAction(long priorityActionId, long phaseId, + long shfrmSubActionId); + + /** + * This method gets a deliverableShfrmSubAction object by a given deliverableShfrmSubAction identifier. + * + * @param deliverableShfrmSubActionID is the deliverableShfrmSubAction identifier. + * @return a DeliverableShfrmSubAction object. + */ + public DeliverableShfrmSubAction getDeliverableShfrmSubActionById(long deliverableShfrmSubActionID); + + /** + * This method saves the information of the given deliverableShfrmSubAction + * + * @param deliverableShfrmSubAction - is the deliverableShfrmSubAction 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 + * deliverableShfrmSubAction was + * updated + * or -1 is some error occurred. + */ + public DeliverableShfrmSubAction saveDeliverableShfrmSubAction(DeliverableShfrmSubAction deliverableShfrmSubAction); + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmPriorityActionManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmPriorityActionManager.java new file mode 100644 index 0000000000..d66307f022 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmPriorityActionManager.java @@ -0,0 +1,74 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager; + +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; + +import java.util.List; + + +/** + * @author CCAFS + */ + +public interface ShfrmPriorityActionManager { + + + /** + * This method removes a specific shfrmPriorityAction value from the database. + * + * @param shfrmPriorityActionId is the shfrmPriorityAction identifier. + * @return true if the shfrmPriorityAction was successfully deleted, false otherwise. + */ + public void deleteShfrmPriorityAction(long shfrmPriorityActionId); + + + /** + * This method validate if the shfrmPriorityAction identify with the given id exists in the system. + * + * @param shfrmPriorityActionID is a shfrmPriorityAction identifier. + * @return true if the shfrmPriorityAction exists, false otherwise. + */ + public boolean existShfrmPriorityAction(long shfrmPriorityActionID); + + + /** + * This method gets a list of shfrmPriorityAction that are active + * + * @return a list from ShfrmPriorityAction null if no exist records + */ + public List findAll(); + + + /** + * This method gets a shfrmPriorityAction object by a given shfrmPriorityAction identifier. + * + * @param shfrmPriorityActionID is the shfrmPriorityAction identifier. + * @return a ShfrmPriorityAction object. + */ + public ShfrmPriorityAction getShfrmPriorityActionById(long shfrmPriorityActionID); + + /** + * This method saves the information of the given shfrmPriorityAction + * + * @param shfrmPriorityAction - is the shfrmPriorityAction 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 shfrmPriorityAction was + * updated + * or -1 is some error occurred. + */ + public ShfrmPriorityAction saveShfrmPriorityAction(ShfrmPriorityAction shfrmPriorityAction); + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmSubActionManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmSubActionManager.java new file mode 100644 index 0000000000..e9817bd989 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/ShfrmSubActionManager.java @@ -0,0 +1,74 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager; + +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; + +import java.util.List; + + +/** + * @author CCAFS + */ + +public interface ShfrmSubActionManager { + + + /** + * This method removes a specific shfrmSubAction value from the database. + * + * @param shfrmSubActionId is the shfrmSubAction identifier. + * @return true if the shfrmSubAction was successfully deleted, false otherwise. + */ + public void deleteShfrmSubAction(long shfrmSubActionId); + + + /** + * This method validate if the shfrmSubAction identify with the given id exists in the system. + * + * @param shfrmSubActionID is a shfrmSubAction identifier. + * @return true if the shfrmSubAction exists, false otherwise. + */ + public boolean existShfrmSubAction(long shfrmSubActionID); + + + /** + * This method gets a list of shfrmSubAction that are active + * + * @return a list from ShfrmSubAction null if no exist records + */ + public List findAll(); + + + /** + * This method gets a shfrmSubAction object by a given shfrmSubAction identifier. + * + * @param shfrmSubActionID is the shfrmSubAction identifier. + * @return a ShfrmSubAction object. + */ + public ShfrmSubAction getShfrmSubActionById(long shfrmSubActionID); + + /** + * This method saves the information of the given shfrmSubAction + * + * @param shfrmSubAction - is the shfrmSubAction 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 shfrmSubAction was + * updated + * or -1 is some error occurred. + */ + public ShfrmSubAction saveShfrmSubAction(ShfrmSubAction shfrmSubAction); + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/SoilIndicatorManager.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/SoilIndicatorManager.java new file mode 100644 index 0000000000..64000356a1 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/SoilIndicatorManager.java @@ -0,0 +1,74 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager; + +import org.cgiar.ccafs.marlo.data.model.SoilIndicator; + +import java.util.List; + + +/** + * @author CCAFS + */ + +public interface SoilIndicatorManager { + + + /** + * This method removes a specific soilIndicator value from the database. + * + * @param soilIndicatorId is the soilIndicator identifier. + * @return true if the soilIndicator was successfully deleted, false otherwise. + */ + public void deleteSoilIndicator(long soilIndicatorId); + + + /** + * This method validate if the soilIndicator identify with the given id exists in the system. + * + * @param soilIndicatorID is a soilIndicator identifier. + * @return true if the soilIndicator exists, false otherwise. + */ + public boolean existSoilIndicator(long soilIndicatorID); + + + /** + * This method gets a list of soilIndicator that are active + * + * @return a list from SoilIndicator null if no exist records + */ + public List findAll(); + + + /** + * This method gets a soilIndicator object by a given soilIndicator identifier. + * + * @param soilIndicatorID is the soilIndicator identifier. + * @return a SoilIndicator object. + */ + public SoilIndicator getSoilIndicatorById(long soilIndicatorID); + + /** + * This method saves the information of the given soilIndicator + * + * @param soilIndicator - is the soilIndicator 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 soilIndicator was + * updated + * or -1 is some error occurred. + */ + public SoilIndicator saveSoilIndicator(SoilIndicator soilIndicator); + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java new file mode 100644 index 0000000000..b3147077b7 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmPriorityActionManagerImpl.java @@ -0,0 +1,169 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager.impl; + + +import org.cgiar.ccafs.marlo.data.dao.DeliverableShfrmPriorityActionDAO; +import org.cgiar.ccafs.marlo.data.dao.PhaseDAO; +import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmPriorityActionManager; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; +import org.cgiar.ccafs.marlo.data.model.Phase; + +import java.util.List; +import java.util.stream.Collectors; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author CCAFS + */ +@Named +public class DeliverableShfrmPriorityActionManagerImpl implements DeliverableShfrmPriorityActionManager { + + private final Logger logger = LoggerFactory.getLogger(DeliverableShfrmPriorityActionManagerImpl.class); + + // Managers + private DeliverableShfrmPriorityActionDAO deliverableShfrmPriorityActionDAO; + private PhaseDAO phaseDAO; + + + @Inject + public DeliverableShfrmPriorityActionManagerImpl(DeliverableShfrmPriorityActionDAO deliverableShfrmPriorityActionDAO, + PhaseDAO phaseDAO) { + this.deliverableShfrmPriorityActionDAO = deliverableShfrmPriorityActionDAO; + this.phaseDAO = phaseDAO; + } + + @Override + public void deleteDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionId) { + + DeliverableShfrmPriorityAction deliverableShfrmPriorityAction = + this.getDeliverableShfrmPriorityActionById(deliverableShfrmPriorityActionId); + Phase currentPhase = phaseDAO.find(deliverableShfrmPriorityAction.getPhase().getId()); + + if (currentPhase.getNext() != null && currentPhase.getNext().getNext() != null) { + + this.deleteDeliverableShfrmPriorityActionPhase(currentPhase.getNext(), + deliverableShfrmPriorityAction.getDeliverable().getId(), deliverableShfrmPriorityAction); + } + + deliverableShfrmPriorityActionDAO.deleteDeliverableShfrmPriorityAction(deliverableShfrmPriorityActionId); + } + + public void deleteDeliverableShfrmPriorityActionPhase(Phase next, long deliverableId, + DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + Phase phase = phaseDAO.find(next.getId()); + + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionDelete = new DeliverableShfrmPriorityAction(); + deliverableShfrmPriorityActionDelete = + deliverableShfrmPriorityActionDAO.findByDeliverableAndPhase(deliverableId, phase.getId()).stream() + .filter(d -> d != null && deliverableShfrmPriorityAction != null + && deliverableShfrmPriorityAction.getShfrmPriorityAction() != null + && deliverableShfrmPriorityAction.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction() != null && d.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction().getId().equals(deliverableShfrmPriorityAction.getShfrmPriorityAction().getId())) + .collect(Collectors.toList()).get(0); + + if (deliverableShfrmPriorityActionDelete != null) { + deliverableShfrmPriorityActionDAO + .deleteDeliverableShfrmPriorityAction(deliverableShfrmPriorityActionDelete.getId()); + } + if (phase.getNext() != null) { + this.deleteDeliverableShfrmPriorityActionPhase(phase.getNext(), deliverableId, deliverableShfrmPriorityAction); + } + } + + @Override + public boolean existDeliverableShfrmPriorityAction(long deliverableShfrmPriorityActionID) { + + return deliverableShfrmPriorityActionDAO.existDeliverableShfrmPriorityAction(deliverableShfrmPriorityActionID); + } + + @Override + public List findAll() { + + return deliverableShfrmPriorityActionDAO.findAll(); + + } + + @Override + public List findByDeliverableAndPhase(long deliverableId, long phaseId) { + + return deliverableShfrmPriorityActionDAO.findByDeliverableAndPhase(deliverableId, phaseId); + + } + + @Override + public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityActionById(long deliverableShfrmPriorityActionID) { + + return deliverableShfrmPriorityActionDAO.find(deliverableShfrmPriorityActionID); + } + + @Override + public DeliverableShfrmPriorityAction + saveDeliverableShfrmPriorityAction(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionResult = + deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityAction); + Phase currentPhase = phaseDAO.find(deliverableShfrmPriorityActionResult.getPhase().getId()); + + if (currentPhase.getNext() != null && currentPhase.getNext().getNext() != null) { + + this.saveDeliverableShfrmPriorityActionPhase(currentPhase.getNext(), + deliverableShfrmPriorityActionResult.getDeliverable().getId(), deliverableShfrmPriorityActionResult); + } + return deliverableShfrmPriorityActionResult; + } + + public void saveDeliverableShfrmPriorityActionPhase(Phase next, long deliverableId, + DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + Phase phase = phaseDAO.find(next.getId()); + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionPhase = new DeliverableShfrmPriorityAction(); + try { + deliverableShfrmPriorityActionPhase = deliverableShfrmPriorityActionDAO + .findByDeliverableAndPhase(deliverableId, phase.getId()).stream() + .filter(d -> d != null && deliverableShfrmPriorityAction != null + && deliverableShfrmPriorityAction.getShfrmPriorityAction() != null + && deliverableShfrmPriorityAction.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction() != null && d.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction().getId().equals(deliverableShfrmPriorityAction.getShfrmPriorityAction().getId())) + .collect(Collectors.toList()).get(0); + } catch (Exception e) { + logger.error("error getting deliverableShfrmPriorityActionPhase: " + e); + } + + if (deliverableShfrmPriorityActionPhase != null) { + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionAdd = deliverableShfrmPriorityActionPhase; + deliverableShfrmPriorityActionAdd.setDeliverable(deliverableShfrmPriorityAction.getDeliverable()); + deliverableShfrmPriorityActionAdd.setPhase(phase); + deliverableShfrmPriorityActionAdd.setShfrmPriorityAction(deliverableShfrmPriorityAction.getShfrmPriorityAction()); + deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityActionAdd); + } else { + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionAdd = new DeliverableShfrmPriorityAction(); + deliverableShfrmPriorityActionAdd.setDeliverable(deliverableShfrmPriorityAction.getDeliverable()); + deliverableShfrmPriorityActionAdd.setPhase(phase); + deliverableShfrmPriorityActionAdd.setShfrmPriorityAction(deliverableShfrmPriorityAction.getShfrmPriorityAction()); + deliverableShfrmPriorityActionDAO.save(deliverableShfrmPriorityActionAdd); + } + if (phase.getNext() != null) { + this.saveDeliverableShfrmPriorityActionPhase(phase.getNext(), deliverableId, deliverableShfrmPriorityAction); + } + } + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java new file mode 100644 index 0000000000..4811696bd4 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/DeliverableShfrmSubActionManagerImpl.java @@ -0,0 +1,162 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager.impl; + + +import org.cgiar.ccafs.marlo.data.dao.DeliverableShfrmSubActionDAO; +import org.cgiar.ccafs.marlo.data.dao.PhaseDAO; +import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmSubActionManager; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; +import org.cgiar.ccafs.marlo.data.model.Phase; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author CCAFS + */ +@Named +public class DeliverableShfrmSubActionManagerImpl implements DeliverableShfrmSubActionManager { + + private final Logger logger = LoggerFactory.getLogger(DeliverableShfrmSubActionManagerImpl.class); + + // Managers + private DeliverableShfrmSubActionDAO deliverableShfrmSubActionDAO; + private PhaseDAO phaseDAO; + + @Inject + public DeliverableShfrmSubActionManagerImpl(DeliverableShfrmSubActionDAO deliverableShfrmSubActionDAO, + PhaseDAO phaseDAO) { + this.deliverableShfrmSubActionDAO = deliverableShfrmSubActionDAO; + this.phaseDAO = phaseDAO; + } + + @Override + public void deleteDeliverableShfrmSubAction(long deliverableShfrmSubActionId) { + + DeliverableShfrmSubAction deliverableShfrmSubAction = + this.getDeliverableShfrmSubActionById(deliverableShfrmSubActionId); + Phase currentPhase = phaseDAO.find(deliverableShfrmSubAction.getPhase().getId()); + + if (currentPhase.getNext() != null && currentPhase.getNext().getNext() != null) { + this.deleteDeliverableShfrmSubActionPhase(currentPhase.getNext(), deliverableShfrmSubAction); + } + + deliverableShfrmSubActionDAO.deleteDeliverableShfrmSubAction(deliverableShfrmSubActionId); + } + + public void deleteDeliverableShfrmSubActionPhase(Phase next, DeliverableShfrmSubAction deliverableShfrmSubAction) { + Phase phase = phaseDAO.find(next.getId()); + + DeliverableShfrmSubAction deliverableShfrmSubActionDelete = new DeliverableShfrmSubAction(); + deliverableShfrmSubActionDelete = deliverableShfrmSubActionDAO + .findByPriorityActionPhaseAndSubAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), + phase.getId(), deliverableShfrmSubAction.getShfrmSubAction().getId()) + .get(0); + + if (deliverableShfrmSubActionDelete != null) { + deliverableShfrmSubActionDAO.deleteDeliverableShfrmSubAction(deliverableShfrmSubActionDelete.getId()); + } + if (phase.getNext() != null) { + this.deleteDeliverableShfrmSubActionPhase(phase.getNext(), deliverableShfrmSubAction); + } + } + + @Override + public boolean existDeliverableShfrmSubAction(long deliverableShfrmSubActionID) { + + return deliverableShfrmSubActionDAO.existDeliverableShfrmSubAction(deliverableShfrmSubActionID); + } + + @Override + public List findAll() { + + return deliverableShfrmSubActionDAO.findAll(); + + } + + @Override + public List findByPriorityActionAndPhase(long priorityActionId, long phaseId) { + + return deliverableShfrmSubActionDAO.findByPriorityActionAndPhase(priorityActionId, phaseId); + + } + + @Override + public List findByPriorityActionPhaseAndSubAction(long priorityActionId, long phaseId, + long shfrmSubActionId) { + return deliverableShfrmSubActionDAO.findByPriorityActionPhaseAndSubAction(priorityActionId, phaseId, + shfrmSubActionId); + } + + @Override + public DeliverableShfrmSubAction getDeliverableShfrmSubActionById(long deliverableShfrmSubActionID) { + + return deliverableShfrmSubActionDAO.find(deliverableShfrmSubActionID); + } + + @Override + public DeliverableShfrmSubAction saveDeliverableShfrmSubAction(DeliverableShfrmSubAction deliverableShfrmSubAction) { + + DeliverableShfrmSubAction deliverableShfrmSubActionResult = + deliverableShfrmSubActionDAO.save(deliverableShfrmSubAction); + Phase currentPhase = phaseDAO.find(deliverableShfrmSubActionResult.getPhase().getId()); + + if (currentPhase.getNext() != null && currentPhase.getNext().getNext() != null) { + + this.saveDeliverableShfrmSubActionPhase(currentPhase.getNext(), deliverableShfrmSubActionResult); + } + return deliverableShfrmSubActionResult; + } + + public void saveDeliverableShfrmSubActionPhase(Phase next, DeliverableShfrmSubAction deliverableShfrmSubAction) { + Phase phase = phaseDAO.find(next.getId()); + DeliverableShfrmSubAction deliverableShfrmSubActionPhase = new DeliverableShfrmSubAction(); + try { + deliverableShfrmSubActionPhase = deliverableShfrmSubActionDAO + .findByPriorityActionPhaseAndSubAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), + phase.getId(), deliverableShfrmSubAction.getShfrmSubAction().getId()) + .get(0); + } catch (Exception e) { + logger.error("error getting deliverableShfrmSubActionPhase: " + e); + } + + if (deliverableShfrmSubActionPhase != null) { + DeliverableShfrmSubAction deliverableShfrmSubActionAdd = deliverableShfrmSubActionPhase; + deliverableShfrmSubActionAdd.setPhase(phase); + deliverableShfrmSubActionAdd.setShfrmSubAction(deliverableShfrmSubAction.getShfrmSubAction()); + deliverableShfrmSubActionAdd + .setDeliverableShfrmPriorityAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction()); + deliverableShfrmSubActionDAO.save(deliverableShfrmSubActionAdd); + } else { + DeliverableShfrmSubAction deliverableShfrmSubActionAdd = new DeliverableShfrmSubAction(); + deliverableShfrmSubActionAdd.setPhase(phase); + deliverableShfrmSubActionAdd.setShfrmSubAction(deliverableShfrmSubAction.getShfrmSubAction()); + deliverableShfrmSubActionAdd + .setDeliverableShfrmPriorityAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction()); + deliverableShfrmSubActionDAO.save(deliverableShfrmSubActionAdd); + } + + if (phase.getNext() != null) { + this.saveDeliverableShfrmSubActionPhase(phase.getNext(), deliverableShfrmSubAction); + } + } + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmPriorityActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmPriorityActionManagerImpl.java new file mode 100644 index 0000000000..f0d833da7a --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmPriorityActionManagerImpl.java @@ -0,0 +1,77 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager.impl; + + +import org.cgiar.ccafs.marlo.data.dao.ShfrmPriorityActionDAO; +import org.cgiar.ccafs.marlo.data.manager.ShfrmPriorityActionManager; +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +/** + * @author CCAFS + */ +@Named +public class ShfrmPriorityActionManagerImpl implements ShfrmPriorityActionManager { + + + private ShfrmPriorityActionDAO shfrmPriorityActionDAO; + // Managers + + + @Inject + public ShfrmPriorityActionManagerImpl(ShfrmPriorityActionDAO shfrmPriorityActionDAO) { + this.shfrmPriorityActionDAO = shfrmPriorityActionDAO; + + + } + + @Override + public void deleteShfrmPriorityAction(long shfrmPriorityActionId) { + + shfrmPriorityActionDAO.deleteShfrmPriorityAction(shfrmPriorityActionId); + } + + @Override + public boolean existShfrmPriorityAction(long shfrmPriorityActionID) { + + return shfrmPriorityActionDAO.existShfrmPriorityAction(shfrmPriorityActionID); + } + + @Override + public List findAll() { + + return shfrmPriorityActionDAO.findAll(); + + } + + @Override + public ShfrmPriorityAction getShfrmPriorityActionById(long shfrmPriorityActionID) { + + return shfrmPriorityActionDAO.find(shfrmPriorityActionID); + } + + @Override + public ShfrmPriorityAction saveShfrmPriorityAction(ShfrmPriorityAction shfrmPriorityAction) { + + return shfrmPriorityActionDAO.save(shfrmPriorityAction); + } + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmSubActionManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmSubActionManagerImpl.java new file mode 100644 index 0000000000..f1e5e9e89d --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/ShfrmSubActionManagerImpl.java @@ -0,0 +1,77 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager.impl; + + +import org.cgiar.ccafs.marlo.data.dao.ShfrmSubActionDAO; +import org.cgiar.ccafs.marlo.data.manager.ShfrmSubActionManager; +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +/** + * @author CCAFS + */ +@Named +public class ShfrmSubActionManagerImpl implements ShfrmSubActionManager { + + + private ShfrmSubActionDAO shfrmSubActionDAO; + // Managers + + + @Inject + public ShfrmSubActionManagerImpl(ShfrmSubActionDAO shfrmSubActionDAO) { + this.shfrmSubActionDAO = shfrmSubActionDAO; + + + } + + @Override + public void deleteShfrmSubAction(long shfrmSubActionId) { + + shfrmSubActionDAO.deleteShfrmSubAction(shfrmSubActionId); + } + + @Override + public boolean existShfrmSubAction(long shfrmSubActionID) { + + return shfrmSubActionDAO.existShfrmSubAction(shfrmSubActionID); + } + + @Override + public List findAll() { + + return shfrmSubActionDAO.findAll(); + + } + + @Override + public ShfrmSubAction getShfrmSubActionById(long shfrmSubActionID) { + + return shfrmSubActionDAO.find(shfrmSubActionID); + } + + @Override + public ShfrmSubAction saveShfrmSubAction(ShfrmSubAction shfrmSubAction) { + + return shfrmSubActionDAO.save(shfrmSubAction); + } + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/SoilIndicatorManagerImpl.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/SoilIndicatorManagerImpl.java new file mode 100644 index 0000000000..f1508bc6b0 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/manager/impl/SoilIndicatorManagerImpl.java @@ -0,0 +1,77 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ +package org.cgiar.ccafs.marlo.data.manager.impl; + + +import org.cgiar.ccafs.marlo.data.dao.SoilIndicatorDAO; +import org.cgiar.ccafs.marlo.data.manager.SoilIndicatorManager; +import org.cgiar.ccafs.marlo.data.model.SoilIndicator; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; + +/** + * @author CCAFS + */ +@Named +public class SoilIndicatorManagerImpl implements SoilIndicatorManager { + + + private SoilIndicatorDAO soilIndicatorDAO; + // Managers + + + @Inject + public SoilIndicatorManagerImpl(SoilIndicatorDAO soilIndicatorDAO) { + this.soilIndicatorDAO = soilIndicatorDAO; + + + } + + @Override + public void deleteSoilIndicator(long soilIndicatorId) { + + soilIndicatorDAO.deleteSoilIndicator(soilIndicatorId); + } + + @Override + public boolean existSoilIndicator(long soilIndicatorID) { + + return soilIndicatorDAO.existSoilIndicator(soilIndicatorID); + } + + @Override + public List findAll() { + + return soilIndicatorDAO.findAll(); + + } + + @Override + public SoilIndicator getSoilIndicatorById(long soilIndicatorID) { + + return soilIndicatorDAO.find(soilIndicatorID); + } + + @Override + public SoilIndicator saveSoilIndicator(SoilIndicator soilIndicator) { + + return soilIndicatorDAO.save(soilIndicator); + } + + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java index c2a70348cb..71540e959a 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Deliverable.java @@ -134,6 +134,12 @@ public class Deliverable extends MarloAuditableEntity implements java.io.Seriali private List crpOutcomes; private Set deliverableCrpOutcomes = new HashSet(0); + private Set deliverableShfrmPriorityAction = + new HashSet(0); + private List shfrmPriorityActions; + private Set deliverableShfrmSubAction = new HashSet(0); + private List shfrmSubActions; + private String sharedWithProjects; private String sharedWithMe; private String owner; @@ -490,10 +496,19 @@ public List getDeliverableRegions() { return deliverableRegions; } + public Set getDeliverableShfrmPriorityAction() { + return deliverableShfrmPriorityAction; + } + + public Set getDeliverableShfrmSubAction() { + return deliverableShfrmSubAction; + } + public Set getDeliverableUserPartnerships() { return deliverableUserPartnerships; } + public Set getDeliverableUsers() { return deliverableUsers; } @@ -502,7 +517,6 @@ public DeliverableDissemination getDissemination() { return dissemination; } - public DeliverableDissemination getDissemination(Phase phase) { List deliverableDisseminations = this.getDeliverableDisseminations().stream() .filter(dd -> dd.isActive() && dd.getPhase().equals(phase)).collect(Collectors.toList()); @@ -520,6 +534,7 @@ public DeliverableMetadataExternalSources getExternalSource() { return externalSource; } + public DeliverableMetadataExternalSources getExternalSource(Phase phase) { DeliverableMetadataExternalSources externalSourceFound = this.getExternalSource(); if (externalSourceFound == null) { @@ -539,7 +554,6 @@ public List getFiles() { return files; } - public String getFlagshipValue() { return flagshipValue; } @@ -584,6 +598,7 @@ public Boolean getIsFindable() { return isFindable; } + public Boolean getIsInteroperable() { return isInteroperable; } @@ -597,11 +612,11 @@ public Boolean getIsReusable() { return isReusable; } + public List getLeaders() { return leaders; } - @Override public String getLogDeatil() { StringBuilder sb = new StringBuilder(); @@ -609,7 +624,6 @@ public String getLogDeatil() { return sb.toString(); } - public long getMElementID(int metadataID) { if (metadataElements != null) { for (DeliverableMetadataElement dmetadata : metadataElements) { @@ -625,6 +639,7 @@ public long getMElementID(int metadataID) { return -1; } + public List getMetadata() { return metadata; } @@ -647,7 +662,6 @@ public DeliverableMetadataElement getMetadata(long metadataID) { return null; } - public List getMetadataElements() { return metadataElements; } @@ -793,6 +807,7 @@ public List getRegions() { return regions; } + public String getRegionsValue() { return regionsValue; } @@ -801,15 +816,16 @@ public String getResponsible() { return responsible; } - public List getResponsiblePartnership() { return responsiblePartnership; } + public Set getSectionStatuses() { return sectionStatuses; } + public List getSelectedFlahsgips() { return selectedFlahsgips; } @@ -830,6 +846,15 @@ public String getSharedWithProjects() { } + public List getShfrmPriorityActions() { + return shfrmPriorityActions; + } + + public List getShfrmSubActions() { + return shfrmSubActions; + } + + public String getTagTitle() { return tagTitle; } @@ -853,12 +878,10 @@ public int hashCode() { return result; } - public void setActivities(List activities) { this.activities = activities; } - public void setAltmetricInfos(List altmetricInfos) { this.altmetricInfos = altmetricInfos; } @@ -868,6 +891,7 @@ public void setClusterParticipant(List clusterPar this.clusterParticipant = clusterParticipant; } + public void setCommentStatus(String commentStatus) { this.commentStatus = commentStatus; } @@ -876,6 +900,7 @@ public void setContribution(Boolean contribution) { this.contribution = contribution; } + public void setCountries(List countries) { this.countries = countries; } @@ -894,17 +919,14 @@ public void setCreateDate(Date createDate) { this.createDate = createDate; } - public void setCrossCuttingMarkers(List crossCuttingMarkers) { this.crossCuttingMarkers = crossCuttingMarkers; } - public void setCrp(GlobalUnit crp) { this.crp = crp; } - public void setCrpOutcomes(List crpOutcomes) { this.crpOutcomes = crpOutcomes; } @@ -929,6 +951,7 @@ public void setDeliverableAltmetricInfo(DeliverableAltmetricInfo deliverableAltm this.deliverableAltmetricInfo = deliverableAltmetricInfo; } + public void setDeliverableAltmetricInfos(Set deliverableAltmetricInfos) { this.deliverableAltmetricInfos = deliverableAltmetricInfos; } @@ -945,7 +968,6 @@ public void setDeliverableCrpOutcomes(Set deliverableCrpO this.deliverableCrpOutcomes = deliverableCrpOutcomes; } - public void setDeliverableCrps(Set deliverableCrps) { this.deliverableCrps = deliverableCrps; } @@ -978,6 +1000,7 @@ public void setDeliverableGeographicScopes(Set deliv this.deliverableGeographicScopes = deliverableGeographicScopes; } + public void setDeliverableInfo(DeliverableInfo deliverableInfo) { this.deliverableInfo = deliverableInfo; } @@ -990,11 +1013,11 @@ public void setDeliverableIntellectualAssets(Set d this.deliverableIntellectualAssets = deliverableIntellectualAssets; } + public void setDeliverableLeaders(Set deliverableLeaders) { this.deliverableLeaders = deliverableLeaders; } - public void setDeliverableLocations(Set deliverableLocations) { this.deliverableLocations = deliverableLocations; } @@ -1007,7 +1030,6 @@ public void setDeliverableMetadataElements(Set deliv this.deliverableMetadataElements = deliverableMetadataElements; } - public void setDeliverableMetadataExternalSources(Set deliverableMetadataExternalSources) { this.deliverableMetadataExternalSources = deliverableMetadataExternalSources; @@ -1041,6 +1063,14 @@ public void setDeliverableRegions(List deliverableR this.deliverableRegions = deliverableRegions; } + public void setDeliverableShfrmPriorityAction(Set deliverableShfrmPriorityAction) { + this.deliverableShfrmPriorityAction = deliverableShfrmPriorityAction; + } + + public void setDeliverableShfrmSubAction(Set deliverableShfrmSubAction) { + this.deliverableShfrmSubAction = deliverableShfrmSubAction; + } + public void setDeliverableUserPartnerships(Set deliverableUserPartnerships) { this.deliverableUserPartnerships = deliverableUserPartnerships; } @@ -1061,26 +1091,32 @@ public void setExternalSource(DeliverableMetadataExternalSources externalSource) this.externalSource = externalSource; } + public void setFiles(List files) { this.files = files; } + public void setFlagshipValue(String flagshipValue) { this.flagshipValue = flagshipValue; } + public void setFundingSources(List fundingSources) { this.fundingSources = fundingSources; } + public void setGenderLevels(List genderLevels) { this.genderLevels = genderLevels; } + public void setGeographicScopes(List geographicScopes) { this.geographicScopes = geographicScopes; } + public void setIsAccesible(Boolean isAccesible) { this.isAccesible = isAccesible; } @@ -1100,7 +1136,6 @@ public void setIsPublication(Boolean isPublication) { this.isPublication = isPublication; } - public void setIsReusable(Boolean isReusable) { this.isReusable = isReusable; } @@ -1115,7 +1150,6 @@ public void setMetadata(List metadata) { this.metadata = metadata; } - public void setMetadataElements(List metadataElements) { this.metadataElements = metadataElements; } @@ -1130,6 +1164,7 @@ public void setOtherPartnerships(List otherPartnersh this.otherPartnerships = otherPartnerships; } + public void setOwner(String owner) { this.owner = owner; } @@ -1139,7 +1174,6 @@ public void setPhase(Phase phase) { this.phase = phase; } - public void setPrograms(List programs) { this.programs = programs; } @@ -1148,22 +1182,18 @@ public void setProject(Project project) { this.project = project; } - public void setProjectDeliverableShareds(Set projectDeliverableShareds) { this.projectDeliverableShareds = projectDeliverableShareds; } - public void setProjectOutcomes(List projectOutcomes) { this.projectOutcomes = projectOutcomes; } - public void setPublication(DeliverablePublicationMetadata publication) { this.publication = publication; } - public void setPublicationMetadatas(List publicationMetadatas) { this.publicationMetadatas = publicationMetadatas; } @@ -1208,6 +1238,14 @@ public void setSharedWithProjects(String sharedWithProjects) { this.sharedWithProjects = sharedWithProjects; } + public void setShfrmPriorityActions(List shfrmPriorityActions) { + this.shfrmPriorityActions = shfrmPriorityActions; + } + + public void setShfrmSubActions(List shfrmSubActions) { + this.shfrmSubActions = shfrmSubActions; + } + public void setTagTitle(String tagTitle) { this.tagTitle = tagTitle; } @@ -1221,5 +1259,4 @@ public String toString() { return "Deliverable [id=" + this.getId() + ", project=" + project + ", active=" + this.isActive() + ", phase=" + phase + ", isPublication=" + isPublication + ", deliverableInfo=" + deliverableInfo + "]"; } - -} +} \ No newline at end of file diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java index d3dceffe12..3bb1db091c 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java @@ -47,6 +47,10 @@ public class DeliverableInfo extends MarloAuditableEntity implements java.io.Ser private Boolean duplicated; @Expose private Boolean remainingPending; + @Expose + private Boolean contributingShfrm; + @Expose + private String shfrmContributionNarrative; public DeliverableInfo() { } @@ -55,11 +59,14 @@ public Boolean getAdoptedLicense() { return adoptedLicense; } + public Boolean getContributingShfrm() { + return contributingShfrm; + } + public CrpClusterKeyOutput getCrpClusterKeyOutput() { return crpClusterKeyOutput; } - public CrpProgramOutcome getCrpProgramOutcome() { return crpProgramOutcome; } @@ -68,7 +75,6 @@ public Deliverable getDeliverable() { return deliverable; } - public DeliverableType getDeliverableType() { return deliverableType; } @@ -77,12 +83,10 @@ public String getDescription() { return description; } - public Boolean getDuplicated() { return duplicated; } - public RepIndGeographicScope getGeographicScope() { return geographicScope; } @@ -91,7 +95,6 @@ public Boolean getIsLocationGlobal() { return isLocationGlobal; } - @Override public String getLogDeatil() { StringBuilder sb = new StringBuilder(); @@ -104,7 +107,6 @@ public Integer getNewExpectedYear() { return newExpectedYear; } - public Phase getPhase() { return phase; } @@ -119,16 +121,18 @@ public Boolean getRemainingPending() { } + public String getShfrmContributionNarrative() { + return shfrmContributionNarrative; + } + public Integer getStatus() { return status; } - public String getStatusDescription() { return statusDescription; } - public String getStatusName(Phase phase) { @@ -228,6 +232,7 @@ public Boolean isPrevious() { return false; } + public Boolean isRequiredToBeReported() { if (this.getStatus() == null) { return true; @@ -371,12 +376,15 @@ public void setAdoptedLicense(Boolean adoptedLicense) { this.adoptedLicense = adoptedLicense; } + public void setContributingShfrm(Boolean contributingShfrm) { + this.contributingShfrm = contributingShfrm; + } + public void setCrpClusterKeyOutput(CrpClusterKeyOutput crpClusterKeyOutput) { this.crpClusterKeyOutput = crpClusterKeyOutput; } - public void setCrpProgramOutcome(CrpProgramOutcome crpProgramOutcome) { this.crpProgramOutcome = crpProgramOutcome; } @@ -386,12 +394,10 @@ public void setDeliverable(Deliverable deliverable) { this.deliverable = deliverable; } - public void setDeliverableType(DeliverableType deliverableType) { this.deliverableType = deliverableType; } - public void setDescription(String description) { this.description = description; } @@ -400,7 +406,6 @@ public void setDuplicated(Boolean duplicated) { this.duplicated = duplicated; } - public void setGeographicScope(RepIndGeographicScope geographicScope) { this.geographicScope = geographicScope; } @@ -425,6 +430,10 @@ public void setRemainingPending(Boolean remainingPending) { this.remainingPending = remainingPending; } + public void setShfrmContributionNarrative(String shfrmContributionNarrative) { + this.shfrmContributionNarrative = shfrmContributionNarrative; + } + public void setStatus(Integer status) { this.status = status; } @@ -460,7 +469,8 @@ public void updateDeliverableInfo(DeliverableInfo update) { this.setStatusDescription(update.getStatusDescription()); this.setGeographicScope(update.getGeographicScope()); this.setRegion(update.getRegion()); + this.setContributingShfrm(update.getContributingShfrm()); + this.setShfrmContributionNarrative(update.getShfrmContributionNarrative()); } - } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java new file mode 100644 index 0000000000..46ad8193ef --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmPriorityAction.java @@ -0,0 +1,84 @@ +package org.cgiar.ccafs.marlo.data.model; +// Generated Jun 27, 2017 2:55:00 PM by Hibernate Tools 4.3.1.Final + +import org.cgiar.ccafs.marlo.data.IAuditLog; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.google.gson.annotations.Expose; + +/** + * ProjectInfo generated by hbm2java + */ +public class DeliverableShfrmPriorityAction extends MarloAuditableEntity implements java.io.Serializable, IAuditLog { + + private static final long serialVersionUID = -3820243690705823369L; + + @Expose + private Deliverable deliverable; + @Expose + private ShfrmPriorityAction shfrmPriorityAction; + @Expose + private Phase phase; + + private List shfrmSubActions; + + private Set deliverableShfrmSubAction = new HashSet(0); + + public DeliverableShfrmPriorityAction() { + } + + public Deliverable getDeliverable() { + return deliverable; + } + + public Set getDeliverableShfrmSubAction() { + return deliverableShfrmSubAction; + } + + @Override + public String getLogDeatil() { + StringBuilder sb = new StringBuilder(); + sb.append("Id : ").append(this.getId()); + return sb.toString(); + } + + public Phase getPhase() { + return phase; + } + + public ShfrmPriorityAction getShfrmPriorityAction() { + return shfrmPriorityAction; + } + + public List getShfrmSubActions() { + return shfrmSubActions; + } + + @Override + public boolean isActive() { + return true; + } + + public void setDeliverable(Deliverable deliverable) { + this.deliverable = deliverable; + } + + public void setDeliverableShfrmSubAction(Set deliverableShfrmSubAction) { + this.deliverableShfrmSubAction = deliverableShfrmSubAction; + } + + public void setPhase(Phase phase) { + this.phase = phase; + } + + public void setShfrmPriorityAction(ShfrmPriorityAction shfrmPriorityAction) { + this.shfrmPriorityAction = shfrmPriorityAction; + } + + public void setShfrmSubActions(List shfrmSubActions) { + this.shfrmSubActions = shfrmSubActions; + } +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmSubAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmSubAction.java new file mode 100644 index 0000000000..af1726ca80 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableShfrmSubAction.java @@ -0,0 +1,60 @@ +package org.cgiar.ccafs.marlo.data.model; +// Generated Jun 27, 2017 2:55:00 PM by Hibernate Tools 4.3.1.Final + +import org.cgiar.ccafs.marlo.data.IAuditLog; + +import com.google.gson.annotations.Expose; + +/** + * ProjectInfo generated by hbm2java + */ +public class DeliverableShfrmSubAction extends MarloAuditableEntity implements java.io.Serializable, IAuditLog { + + private static final long serialVersionUID = -3820243690705823369L; + + @Expose + private DeliverableShfrmPriorityAction deliverableShfrmPriorityAction; + @Expose + private ShfrmSubAction shfrmSubAction; + @Expose + private Phase phase; + + public DeliverableShfrmSubAction() { + } + + public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityAction() { + return deliverableShfrmPriorityAction; + } + + @Override + public String getLogDeatil() { + StringBuilder sb = new StringBuilder(); + sb.append("Id : ").append(this.getId()); + return sb.toString(); + } + + public Phase getPhase() { + return phase; + } + + public ShfrmSubAction getShfrmSubAction() { + return shfrmSubAction; + } + + @Override + public boolean isActive() { + return true; + } + + public void setDeliverableShfrmPriorityAction(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { + this.deliverableShfrmPriorityAction = deliverableShfrmPriorityAction; + } + + public void setPhase(Phase phase) { + this.phase = phase; + } + + public void setShfrmSubAction(ShfrmSubAction shfrmSubAction) { + this.shfrmSubAction = shfrmSubAction; + } +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java index 87bef972e7..470a6cdc3c 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/Phase.java @@ -44,6 +44,9 @@ public class Phase extends MarloBaseEntity implements java.io.Serializable, IAud private Set projectPhases = new HashSet(0); private Set projectInfos = new HashSet(0); + private Set deliverableShfrmPriorityActions = + new HashSet(0); + private Set deliverableShfrmSubActions = new HashSet(0); private Set projectFocuses = new HashSet(0); @@ -226,7 +229,6 @@ public Set getDeliverableGeographicScopes() { return deliverableGeographicScopes; } - public Set getDeliverableInfos() { return deliverableInfos; } @@ -235,42 +237,42 @@ public Set getDeliverableIntellectualAssets() { return deliverableIntellectualAssets; } - public Set getDeliverableLocations() { return deliverableLocations; } + public Set getDeliverableShfrmPriorityActions() { + return deliverableShfrmPriorityActions; + } + + public Set getDeliverableShfrmSubActions() { + return deliverableShfrmSubActions; + } public Set getDeliverableUserPartnerships() { return deliverableUserPartnerships; } - public Set getDeliverableUsers() { return deliverableUsers; } - public String getDescription() { return this.description; } - public Boolean getEditable() { return editable; } - public Date getEndDate() { return endDate; } - public Set getExpectedStudyProjects() { return expectedStudyProjects; } - public Set getFeedbackQAComments() { return feedbackQAComments; } @@ -339,6 +341,7 @@ public Set getPowbSynthesis() { return powbSynthesis; } + public Set getProgramOutcomeIndicators() { return programOutcomeIndicators; } @@ -353,12 +356,10 @@ public Set getProjectBudgetExecutions() { return projectBudgetExecutions; } - public Set getProjectBudgets() { return projectBudgets; } - public Set getProjectBudgetsFlagships() { return projectBudgetsFlagships; } @@ -367,7 +368,6 @@ public Set getProjectClusters() { return projectClusters; } - public Set getProjectDeliverableShareds() { return projectDeliverableShareds; } @@ -388,7 +388,6 @@ public Set getProjectExpectedStudyFlagships() { return projectExpectedStudyFlagships; } - public Set getProjectExpectedStudyGeographicScopes() { return projectExpectedStudyGeographicScopes; } @@ -469,7 +468,6 @@ public Set getProjectInnovationGeographicScope return projectInnovationGeographicScopes; } - public Set getProjectInnovationInfos() { return projectInnovationInfos; } @@ -490,6 +488,7 @@ public Set getProjectLeverages() { return projectLeverages; } + public Set getProjectLocations() { return projectLocations; } @@ -498,7 +497,6 @@ public Set getProjectLp6ContributionDeliverab return projectLp6ContributionDeliverables; } - public Set getProjectLp6Contributions() { return projectLp6Contributions; } @@ -583,6 +581,7 @@ public int hashCode() { return result; } + @Override public boolean isActive() { return true; @@ -592,7 +591,6 @@ public Boolean isReporting() { return description.equals(APConstants.REPORTING); } - public void setClusters(Set clusters) { this.clusters = clusters; } @@ -641,11 +639,18 @@ public void setDeliverableLocations(Set deliverableLocation this.deliverableLocations = deliverableLocations; } + public void setDeliverableShfrmPriorityActions(Set deliverableShfrmPriorityActions) { + this.deliverableShfrmPriorityActions = deliverableShfrmPriorityActions; + } + + public void setDeliverableShfrmSubActions(Set deliverableShfrmSubActions) { + this.deliverableShfrmSubActions = deliverableShfrmSubActions; + } + public void setDeliverableUserPartnerships(Set deliverableUserPartnerships) { this.deliverableUserPartnerships = deliverableUserPartnerships; } - public void setDeliverableUsers(Set deliverableUsers) { this.deliverableUsers = deliverableUsers; } @@ -719,7 +724,6 @@ public void setPowbSynthesis(Set powbSynthesis) { this.powbSynthesis = powbSynthesis; } - public void setProgramOutcomeIndicators(Set programOutcomeIndicators) { this.programOutcomeIndicators = programOutcomeIndicators; } @@ -795,7 +799,6 @@ public void setProjectExpectedStudyQuantifications( this.projectExpectedStudyQuantifications = projectExpectedStudyQuantifications; } - public void setProjectExpectedStudyRegions(Set projectExpectedStudyRegions) { this.projectExpectedStudyRegions = projectExpectedStudyRegions; } @@ -816,12 +819,10 @@ public void setProjectHighlightCountries(Set projectHig this.projectHighlightCountries = projectHighlightCountries; } - public void setProjectHighlightInfos(Set projectHighlightInfos) { this.projectHighlightInfos = projectHighlightInfos; } - public void setProjectHighligthsTypes(Set projectHighligthsTypes) { this.projectHighligthsTypes = projectHighligthsTypes; } @@ -847,13 +848,11 @@ public void setProjectInnovationDeliverables(Set p this.projectInnovationDeliverables = projectInnovationDeliverables; } - public void setProjectInnovationGeographicScopes(Set projectInnovationGeographicScopes) { this.projectInnovationGeographicScopes = projectInnovationGeographicScopes; } - public void setProjectInnovationInfos(Set projectInnovationInfos) { this.projectInnovationInfos = projectInnovationInfos; } @@ -920,7 +919,6 @@ public void setProjectPolicyGeographicScopes(Set p this.projectPolicyGeographicScopes = projectPolicyGeographicScopes; } - public void setProjectPolicyInfos(Set projectPolicyInfos) { this.projectPolicyInfos = projectPolicyInfos; } diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java new file mode 100644 index 0000000000..10b3291e19 --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmPriorityAction.java @@ -0,0 +1,87 @@ +package org.cgiar.ccafs.marlo.data.model; +// Generated Jun 27, 2017 2:55:00 PM by Hibernate Tools 4.3.1.Final + +import org.cgiar.ccafs.marlo.data.IAuditLog; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.Expose; + +/** + * ProjectInfo generated by hbm2java + */ +public class ShfrmPriorityAction extends MarloAuditableEntity implements java.io.Serializable, IAuditLog { + + private static final long serialVersionUID = -3820243690705823369L; + + @Expose + private String name; + @Expose + private String description; + + private String composedName; + + // private Set shfrmSubAction = new HashSet(0); + private List shfrmSubActions = new ArrayList(); + + public ShfrmPriorityAction() { + } + + public String getComposedName() { + if (composedName == null) { + if (this.getName() != null) { + composedName = "" + name + ": "; + } + if (this.getDescription() != null) { + composedName = composedName.concat(description); + } + + if (composedName != null && !composedName.isEmpty()) { + return composedName; + } + } + return composedName; + } + + public String getDescription() { + return description; + } + + @Override + public String getLogDeatil() { + StringBuilder sb = new StringBuilder(); + sb.append("Id : ").append(this.getId()); + return sb.toString(); + } + + public String getName() { + return name; + } + + public List getShfrmSubActions() { + return shfrmSubActions; + } + + @Override + public boolean isActive() { + return true; + } + + public void setComposedName(String composedName) { + this.composedName = composedName; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setName(String name) { + this.name = name; + } + + public void setShfrmSubActions(List shfrmSubActions) { + this.shfrmSubActions = shfrmSubActions; + } + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java new file mode 100644 index 0000000000..de0c15b8ab --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/ShfrmSubAction.java @@ -0,0 +1,83 @@ +package org.cgiar.ccafs.marlo.data.model; +// Generated Jun 27, 2017 2:55:00 PM by Hibernate Tools 4.3.1.Final + +import org.cgiar.ccafs.marlo.data.IAuditLog; + +import com.google.gson.annotations.Expose; + +/** + * ProjectInfo generated by hbm2java + */ +public class ShfrmSubAction extends MarloAuditableEntity implements java.io.Serializable, IAuditLog { + + private static final long serialVersionUID = -3820243690705823369L; + + @Expose + private String name; + @Expose + private String description; + @Expose + private ShfrmPriorityAction shfrmPriorityAction; + + private String composedName; + + public ShfrmSubAction() { + } + + public String getComposedName() { + if (composedName == null) { + if (this.getName() != null) { + composedName = "" + name + ": "; + } + if (this.getDescription() != null) { + composedName = composedName.concat(description); + } + + if (composedName != null && !composedName.isEmpty()) { + return composedName; + } + } + return composedName; + } + + public String getDescription() { + return description; + } + + @Override + public String getLogDeatil() { + StringBuilder sb = new StringBuilder(); + sb.append("Id : ").append(this.getId()); + return sb.toString(); + } + + public String getName() { + return name; + } + + public ShfrmPriorityAction getShfrmPriorityAction() { + return shfrmPriorityAction; + } + + @Override + public boolean isActive() { + return true; + } + + public void setComposedName(String composedName) { + this.composedName = composedName; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setName(String name) { + this.name = name; + } + + public void setShfrmPriorityAction(ShfrmPriorityAction shfrmPriorityAction) { + this.shfrmPriorityAction = shfrmPriorityAction; + } + +} diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/SoilIndicator.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/SoilIndicator.java new file mode 100644 index 0000000000..2f6b39452e --- /dev/null +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/SoilIndicator.java @@ -0,0 +1,86 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + +package org.cgiar.ccafs.marlo.data.model; + +import org.cgiar.ccafs.marlo.data.IAuditLog; + +import com.google.gson.annotations.Expose; + +public class SoilIndicator extends MarloBaseEntity implements java.io.Serializable, IAuditLog { + + private static final long serialVersionUID = -963914989396761020L; + + @Expose + private String indicatorName; + @Expose + private long indicatorId; + @Expose + private Phase phase; + + public long getIndicatorId() { + return indicatorId; + } + + public String getIndicatorName() { + return indicatorName; + } + + @Override + public String getLogDeatil() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getModificationJustification() { + // TODO Auto-generated method stub + return null; + } + + @Override + public User getModifiedBy() { + // TODO Auto-generated method stub + return null; + } + + public Phase getPhase() { + return phase; + } + + @Override + public boolean isActive() { + // TODO Auto-generated method stub + return false; + } + + public void setIndicatorId(long indicatorId) { + this.indicatorId = indicatorId; + } + + public void setIndicatorName(String indicatorName) { + this.indicatorName = indicatorName; + } + + @Override + public void setModifiedBy(User modifiedBy) { + // TODO Auto-generated method stub + } + + public void setPhase(Phase phase) { + this.phase = phase; + } +} + diff --git a/marlo-data/src/main/resources/hibernate.cfg.xml b/marlo-data/src/main/resources/hibernate.cfg.xml index a4113699c1..037211c1bf 100644 --- a/marlo-data/src/main/resources/hibernate.cfg.xml +++ b/marlo-data/src/main/resources/hibernate.cfg.xml @@ -429,7 +429,15 @@ +<<<<<<< HEAD +======= + + + + + +>>>>>>> aiccra-shfrm-contribution-functionality diff --git a/marlo-data/src/main/resources/xmls/DeliverableShfrmPriorityActions.hbm.xml b/marlo-data/src/main/resources/xmls/DeliverableShfrmPriorityActions.hbm.xml new file mode 100644 index 0000000000..4a02494a66 --- /dev/null +++ b/marlo-data/src/main/resources/xmls/DeliverableShfrmPriorityActions.hbm.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/marlo-data/src/main/resources/xmls/DeliverableShfrmSubActions.hbm.xml b/marlo-data/src/main/resources/xmls/DeliverableShfrmSubActions.hbm.xml new file mode 100644 index 0000000000..a9f4a2563a --- /dev/null +++ b/marlo-data/src/main/resources/xmls/DeliverableShfrmSubActions.hbm.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml b/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml index ff853db886..f7b7f8998f 100644 --- a/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml +++ b/marlo-data/src/main/resources/xmls/Deliverables.hbm.xml @@ -278,6 +278,14 @@ + + + + + + diff --git a/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml b/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml index 18bf38c1eb..abcc2c7770 100644 --- a/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml +++ b/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml @@ -81,6 +81,12 @@ + + + + + + diff --git a/marlo-data/src/main/resources/xmls/Phases.hbm.xml b/marlo-data/src/main/resources/xmls/Phases.hbm.xml index 51d4fe4c9b..035ad9c8ac 100644 --- a/marlo-data/src/main/resources/xmls/Phases.hbm.xml +++ b/marlo-data/src/main/resources/xmls/Phases.hbm.xml @@ -106,6 +106,22 @@ + + + + + + + + + + + + diff --git a/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml b/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml new file mode 100644 index 0000000000..1c1b75ea6a --- /dev/null +++ b/marlo-data/src/main/resources/xmls/ShfrmPriorityActions.hbm.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/marlo-data/src/main/resources/xmls/ShfrmSubActions.hbm.xml b/marlo-data/src/main/resources/xmls/ShfrmSubActions.hbm.xml new file mode 100644 index 0000000000..ed6bf768e9 --- /dev/null +++ b/marlo-data/src/main/resources/xmls/ShfrmSubActions.hbm.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml b/marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml new file mode 100644 index 0000000000..ff77d7c3dd --- /dev/null +++ b/marlo-data/src/main/resources/xmls/SoilIndicators.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 9c2543c9d5..0ae0209948 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 @@ -37,6 +37,7 @@ import org.cgiar.ccafs.marlo.data.manager.DeliverableCrpOutcomeManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableInfoManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableManager; +import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmPriorityActionManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableTraineesIndicatorManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableTypeManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableTypeRuleManager; @@ -82,6 +83,7 @@ import org.cgiar.ccafs.marlo.data.manager.ReportSynthesisManager; import org.cgiar.ccafs.marlo.data.manager.RoleManager; import org.cgiar.ccafs.marlo.data.manager.SectionStatusManager; +import org.cgiar.ccafs.marlo.data.manager.ShfrmPriorityActionManager; import org.cgiar.ccafs.marlo.data.manager.SrfTargetUnitManager; import org.cgiar.ccafs.marlo.data.manager.UserManager; import org.cgiar.ccafs.marlo.data.manager.UserRoleManager; @@ -314,6 +316,12 @@ public class BaseAction extends ActionSupport implements Preparable, SessionAwar @Inject private ProjectBudgetManager projectBudgetManager; + @Inject + private DeliverableShfrmPriorityActionManager deliverableShfrmPriorityActionManager; + + @Inject + private ShfrmPriorityActionManager shfrmPriorityActionManager; + @Inject private ProjectPartnerPersonManager partnerPersonManager; @@ -884,6 +892,24 @@ public boolean canBeDeleted(long id, String className) { } + if (clazz == ShfrmPriorityAction.class) { + ShfrmPriorityAction shfrmPriorityAction = this.shfrmPriorityActionManager.getShfrmPriorityActionById(id); + if (shfrmPriorityAction != null && shfrmPriorityAction.getId() != null) { + List deliverableShfrmPriorityActions = + deliverableShfrmPriorityActionManager.findAll().stream() + .filter(d -> d.getShfrmPriorityAction() != null && d.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction().getId().equals(id) && d.getPhase() != null + && d.getPhase().getId().equals(this.getActualPhase().getId())) + .collect(Collectors.toList()); + if (deliverableShfrmPriorityActions != null && deliverableShfrmPriorityActions.isEmpty() + || (deliverableShfrmPriorityActions == null)) { + return true; + } else { + return false; + } + } + } + if (clazz == ProjectBudget.class) { ProjectBudget projectBudget = this.projectBudgetManager.getProjectBudgetById(id); @@ -1061,7 +1087,7 @@ public boolean canBeDeleted(long id, String className) { } return true; } catch (Exception e) { - + Log.error("error getting class " + e); return true; } @@ -5129,6 +5155,37 @@ public Map getSession() { return this.session; } + public List getShfrmActionDeliverablesRelation(Long shfrmPrimaryActionId) { + + List deliverablesRelated = new ArrayList<>(); + if (shfrmPrimaryActionId != null && shfrmPrimaryActionId != 0) { + List deliverableShfrmPriorityActions = null; + try { + deliverableShfrmPriorityActions = deliverableShfrmPriorityActionManager.findAll().stream() + .filter(d -> d.getShfrmPriorityAction() != null && d.getShfrmPriorityAction().getId() != null + && d.getShfrmPriorityAction().getId().equals(shfrmPrimaryActionId) && d.getPhase() != null + && d.getPhase().getId().equals(this.getActualPhase().getId())) + .collect(Collectors.toList()); + } catch (Exception e) { + Log.error("error getting shfrm " + e); + } + if (deliverableShfrmPriorityActions != null && !deliverableShfrmPriorityActions.isEmpty()) { + for (DeliverableShfrmPriorityAction deliverableShfrmPriorityAction : deliverableShfrmPriorityActions) { + if (deliverableShfrmPriorityAction != null && deliverableShfrmPriorityAction.getDeliverable() != null) { + Deliverable deliverableAdd = deliverableShfrmPriorityAction.getDeliverable(); + deliverableAdd.setDeliverableInfo(deliverableAdd.getDeliverableInfo(getActualPhase())); + deliverablesRelated.add(deliverableShfrmPriorityAction.getDeliverable()); + } + } + } + } + if (deliverablesRelated != null && !deliverablesRelated.isEmpty()) { + return deliverablesRelated; + } else { + return null; + } + } + /** * This method return the first AF AICCRA ID Phase * @@ -7288,6 +7345,14 @@ public boolean isSaveable() { return this.saveable; } + public boolean isShfrmSpecificityActive() { + try { + return Boolean.parseBoolean(this.getSession().get(APConstants.SHFRM_CONTRIBUTION_ACTIVE).toString()); + } catch (Exception e) { + return false; + } + } + public boolean isSubmit(long projectID) { Project project = this.projectManager.getProjectById(projectID); int year = this.getCurrentCycleYear(); @@ -8336,6 +8401,7 @@ public boolean validatePolicy(long policyID) { return true; } + // public boolean validURL(String URL) { try { @@ -8352,4 +8418,5 @@ public boolean validURL(String URL) { } + } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java new file mode 100644 index 0000000000..c3b062fdfb --- /dev/null +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/crp/admin/ShfrmManagementAction.java @@ -0,0 +1,277 @@ +/* + * This file is part of Managing Agricultural Research for Learning&*Outcomes Platform(MARLO). + ** MARLO is free software:you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation,either version 3 of the License,or*at your option)any later version. + ** MARLO is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY;without even the implied warranty of*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See + * the + ** GNU General Public License for more details. + ** You should have received a copy of the GNU General Public License + ** along with MARLO.If not,see. + *****************************************************************/ + +package org.cgiar.ccafs.marlo.action.crp.admin; + +import org.cgiar.ccafs.marlo.action.BaseAction; +import org.cgiar.ccafs.marlo.data.manager.ShfrmPriorityActionManager; +import org.cgiar.ccafs.marlo.data.manager.ShfrmSubActionManager; +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; +import org.cgiar.ccafs.marlo.utils.APConfig; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.inject.Inject; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class ShfrmManagementAction extends BaseAction { + + private static Logger logger = LoggerFactory.getLogger(ShfrmManagementAction.class); + private static final long serialVersionUID = -793652591843623397L; + private List priorityActions; + private final ShfrmPriorityActionManager shfrmPriorityActionManager; + private final ShfrmSubActionManager shfrmSubActionManager; + + @Inject + public ShfrmManagementAction(APConfig config, ShfrmPriorityActionManager shfrmPriorityActionManager, + ShfrmSubActionManager shfrmSubActionManager) { + super(config); + this.shfrmPriorityActionManager = shfrmPriorityActionManager; + this.shfrmSubActionManager = shfrmSubActionManager; + } + + /** + * Fill Priority actions with sub actions list + */ + public void fillSubActions() { + if (priorityActions != null && !priorityActions.isEmpty()) { + try { + List subActions = shfrmSubActionManager.findAll(); + + if (subActions != null && !subActions.isEmpty()) { + priorityActions.forEach(action -> { + List subActionsAdd = subActions.stream() + .filter(subaction -> action != null && action.getId() != null && subaction != null + && subaction.getShfrmPriorityAction() != null && subaction.getShfrmPriorityAction().getId() != null + && subaction.getShfrmPriorityAction().getId().equals(action.getId())) + .collect(Collectors.toList()); + + if (!subActionsAdd.isEmpty()) { + action.setShfrmSubActions(subActionsAdd); + } + }); + } + } catch (Exception e) { + logger.info(e + "no sub actions added yet"); + } + } + } + + public List getPriorityActions() { + return priorityActions; + } + + @Override + public void prepare() throws Exception { + priorityActions = new ArrayList<>(); + priorityActions = shfrmPriorityActionManager.findAll(); + this.fillSubActions(); + if (this.isHttpPost()) { + if (priorityActions != null) { + priorityActions.clear();; + } + } + } + + @Override + public String save() { + if (this.canAcessCrpAdmin()) { + List subActionstoDelete = new ArrayList<>(); + List priorityActionsDB = null; + priorityActionsDB = shfrmPriorityActionManager.findAll(); + + + try { + List subActionsDB = null; + subActionsDB = shfrmSubActionManager.findAll(); + if (this.priorityActions != null && !this.priorityActions.isEmpty()) { + for (ShfrmPriorityAction action : this.priorityActions) { + + // Remove Sub actions + if (action.getShfrmSubActions() != null && !action.getShfrmSubActions().isEmpty()) { + // Obtener los IDs de las subacciones en action.getShfrmSubActions() + Set subActionIdsInFrontend = action.getShfrmSubActions().stream().filter(Objects::nonNull) + .map(ShfrmSubAction::getId).collect(Collectors.toSet()); + + // Filter subActionsDB to retain only the subactions present in action.getShfrmSubActions() + subActionsDB = subActionsDB.stream() + .filter(subActionDB -> subActionDB.getShfrmPriorityAction() != null + && subActionDB.getShfrmPriorityAction().getId() != null + && subActionDB.getShfrmPriorityAction().getId().equals(action.getId()) + && !subActionIdsInFrontend.contains(subActionDB.getId())) + .collect(Collectors.toList()); + + // Delete subactions from subActionsDB that are not in action.getShfrmSubActions() + subActionsDB.forEach(subActionDB -> { + shfrmSubActionManager.deleteShfrmSubAction(subActionDB.getId()); + action.getShfrmSubActions().removeIf(sa -> sa.getId().equals(subActionDB.getId())); + subActionstoDelete.add(subActionDB); + }); + + } else { + subActionsDB.forEach(subActionDB -> { + shfrmSubActionManager.deleteShfrmSubAction(subActionDB.getId()); + subActionstoDelete.add(subActionDB); + }); + } + + } + } + + } catch (Exception e) { + logger.info(e + " error deleting sub action"); + } + + + if (this.priorityActions != null && !this.priorityActions.isEmpty()) { + + if (priorityActionsDB != null) { + try { + for (ShfrmPriorityAction actionDB : priorityActionsDB) { + if (this.priorityActions != null && !this.priorityActions.isEmpty()) { + Set actionIdsInFrontend = this.priorityActions.stream().filter(Objects::nonNull) + .map(ShfrmPriorityAction::getId).collect(Collectors.toSet()); + if (!actionIdsInFrontend.contains(actionDB.getId())) { + + // Validate previous sub actions in DB for each priority actions + if (actionDB.getShfrmSubActions() == null + || (actionDB.getShfrmSubActions() != null && actionDB.getShfrmSubActions().isEmpty())) { + shfrmPriorityActionManager.deleteShfrmPriorityAction(actionDB.getId()); + } + + + } + } + } + } catch (Exception e) { + logger.info(e + " error deleting actions"); + } + } + + for (ShfrmPriorityAction action : this.priorityActions) { + ShfrmPriorityAction actionSave = new ShfrmPriorityAction(); + if (action.getId() != null) { + actionSave = shfrmPriorityActionManager.getShfrmPriorityActionById(action.getId()); + } + + if (subActionstoDelete != null && !subActionstoDelete.isEmpty()) { + + for (ShfrmSubAction subActiontoDelete : subActionstoDelete) { + if (actionSave.getShfrmSubActions().contains(subActiontoDelete)) { + actionSave.getShfrmSubActions().remove(subActiontoDelete); + } + } + } + + if (action.getName() != null) { + actionSave.setName(action.getName()); + } + if (action.getDescription() != null) { + actionSave.setDescription(action.getDescription()); + } + List subActionsTemp = new ArrayList<>(); + if (action.getShfrmSubActions() != null && !action.getShfrmSubActions().isEmpty()) { + subActionsTemp = action.getShfrmSubActions(); + } + + action = shfrmPriorityActionManager.saveShfrmPriorityAction(actionSave); + action.setShfrmSubActions(subActionsTemp); + + // Save sub-actions + if (action.getShfrmSubActions() != null && !action.getShfrmSubActions().isEmpty()) { + for (ShfrmSubAction subAction : action.getShfrmSubActions()) { + ShfrmSubAction subActionSave = new ShfrmSubAction(); + + if (subAction.getId() != null) { + subActionSave.setId(subAction.getId()); + } + if (subAction.getName() != null) { + subActionSave.setName(subAction.getName()); + } + if (subAction.getDescription() != null) { + subActionSave.setDescription(subAction.getDescription()); + } + if (action.getId() != null) { + subActionSave.setShfrmPriorityAction(action); + } + try { + shfrmSubActionManager.saveShfrmSubAction(subActionSave); + } catch (Exception e) { + logger.info(e + " error saving sub action"); + } + } + } + } + } else { + // Delete all priority actions DB + try { + if (priorityActionsDB != null && !priorityActionsDB.isEmpty()) { + priorityActionsDB.forEach(priorityAction -> { + shfrmPriorityActionManager.deleteShfrmPriorityAction(priorityAction.getId()); + }); + } + } catch (Exception e) { + logger.error("error deleting priority actions: " + e); + } + } + + + if (this.getUrl() == null || this.getUrl().isEmpty()) { + Collection messages = this.getActionMessages(); + /* + * if (!this.getInvalidFields().isEmpty()) { + * this.setActionMessages(null); + * // this.addActionMessage(Map.toString(this.getInvalidFields().toArray())); + * List keys = new ArrayList(this.getInvalidFields().keySet()); + * for (String key : keys) { + * this.addActionMessage(key + ": " + this.getInvalidFields().get(key)); + * } + * } else { + * this.addActionMessage("message:" + this.getText("saving.saved")); + * } + */ + this.addActionMessage("message:" + this.getText("saving.saved")); + + return SUCCESS; + } else { + this.addActionMessage(""); + this.setActionMessages(null); + return REDIRECT; + } + + } else { + return NOT_AUTHORIZED; + } + } + + public void setPriorityActions(List priorityActions) { + this.priorityActions = priorityActions; + } + + + @Override + public void validate() { + if (save) { + // validator.validate(this, feedbackFields); + } + } +} \ No newline at end of file diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/bi/BiReportsTokenAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/bi/BiReportsTokenAction.java index 3de5e3b804..afc1dfc3b3 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/bi/BiReportsTokenAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/bi/BiReportsTokenAction.java @@ -102,7 +102,7 @@ private PowerBiBody generatePowerBiBody(BiReports biReport) { /* Identities */ List identities = new ArrayList<>(); Identities identitie = new Identities(); - identitie.setUsername(this.getCurrentUser().getUsername()); + identitie.setUsername(this.getCurrentUser().getEmail()); /* Roles */ List roles = new ArrayList<>(); diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/SubActionsByPriorityAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/SubActionsByPriorityAction.java new file mode 100644 index 0000000000..882fa4542a --- /dev/null +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/project/SubActionsByPriorityAction.java @@ -0,0 +1,102 @@ +/***************************************************************** + * This file is part of Managing Agricultural Research for Learning & + * Outcomes Platform (MARLO). + * MARLO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * MARLO is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with MARLO. If not, see . + *****************************************************************/ + +package org.cgiar.ccafs.marlo.action.json.project; + +import org.cgiar.ccafs.marlo.action.BaseAction; +import org.cgiar.ccafs.marlo.config.APConstants; +import org.cgiar.ccafs.marlo.data.manager.ShfrmSubActionManager; +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; +import org.cgiar.ccafs.marlo.utils.APConfig; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.inject.Inject; + +import org.apache.commons.lang3.StringUtils; +import org.apache.struts2.dispatcher.Parameter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SubActionsByPriorityAction extends BaseAction { + + private static final long serialVersionUID = 3674950424554096761L; + private long priorityActionID; + private ShfrmSubActionManager shfrmSubActionManager; + private List> subActions; + private final Logger logger = LoggerFactory.getLogger(SubActionsByPriorityAction.class); + + + @Inject + public SubActionsByPriorityAction(APConfig config, ShfrmSubActionManager shfrmSubActionManager) { + super(config); + this.shfrmSubActionManager = shfrmSubActionManager; + } + + @Override + public String execute() throws Exception { + subActions = new ArrayList<>(); + Map subAction; + List shfrmSubActions = new ArrayList<>(); + try { + shfrmSubActions = shfrmSubActionManager.findAll().stream() + .filter(s -> s != null && s.isActive() && s.getShfrmPriorityAction() != null + && s.getShfrmPriorityAction().getId() != null && s.getShfrmPriorityAction().getId().equals(priorityActionID)) + .collect(Collectors.toList()); + } catch (Exception e) { + logger.error("error getting sub actions " + e); + } + + if (shfrmSubActions != null && !shfrmSubActions.isEmpty()) { + for (ShfrmSubAction shfrmSubAction : shfrmSubActions) { + subAction = new HashMap(); + subAction.put("id", shfrmSubAction.getId()); + subAction.put("composedName", shfrmSubAction.getComposedName()); + subAction.put("name", shfrmSubAction.getName()); + subAction.put("description", shfrmSubAction.getDescription()); + if (shfrmSubAction.getShfrmPriorityAction() != null + && shfrmSubAction.getShfrmPriorityAction().getId() != null) { + subAction.put("priorityActionId", shfrmSubAction.getShfrmPriorityAction().getId()); + } + subActions.add(subAction); + } + } + return SUCCESS; + + } + + public List> getSubActions() { + return subActions; + } + + @Override + public void prepare() throws Exception { + // Map parameters = this.getParameters(); + // partnerID = Long.parseLong(StringUtils.trim(((String[]) parameters.get(APConstants.PARTNER_ID))[0])); + + Map parameters = this.getParameters(); + priorityActionID = + Long.parseLong(StringUtils.trim(parameters.get(APConstants.PRIORITY_ACTION_ID).getMultipleValues()[0])); + } + + public void setSubActions(List> subActions) { + this.subActions = subActions; + } + +} diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java index 83569e6c41..fab745cb95 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/DeliverableAction.java @@ -47,6 +47,8 @@ import org.cgiar.ccafs.marlo.data.manager.DeliverablePublicationMetadataManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableQualityAnswerManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableQualityCheckManager; +import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmPriorityActionManager; +import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmSubActionManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableTraineesIndicatorManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableTypeManager; import org.cgiar.ccafs.marlo.data.manager.DeliverableUserManager; @@ -77,6 +79,8 @@ import org.cgiar.ccafs.marlo.data.manager.RepIndTypeActivityManager; import org.cgiar.ccafs.marlo.data.manager.RepIndTypeParticipantManager; import org.cgiar.ccafs.marlo.data.manager.RepositoryChannelManager; +import org.cgiar.ccafs.marlo.data.manager.ShfrmPriorityActionManager; +import org.cgiar.ccafs.marlo.data.manager.ShfrmSubActionManager; import org.cgiar.ccafs.marlo.data.manager.UserManager; import org.cgiar.ccafs.marlo.data.model.Activity; import org.cgiar.ccafs.marlo.data.model.CgiarCrossCuttingMarker; @@ -104,6 +108,8 @@ import org.cgiar.ccafs.marlo.data.model.DeliverableProjectOutcome; import org.cgiar.ccafs.marlo.data.model.DeliverableQualityAnswer; import org.cgiar.ccafs.marlo.data.model.DeliverableQualityCheck; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; import org.cgiar.ccafs.marlo.data.model.DeliverableTraineesIndicator; import org.cgiar.ccafs.marlo.data.model.DeliverableType; import org.cgiar.ccafs.marlo.data.model.DeliverableUser; @@ -139,6 +145,8 @@ import org.cgiar.ccafs.marlo.data.model.RepIndTypeActivity; import org.cgiar.ccafs.marlo.data.model.RepIndTypeParticipant; import org.cgiar.ccafs.marlo.data.model.RepositoryChannel; +import org.cgiar.ccafs.marlo.data.model.ShfrmPriorityAction; +import org.cgiar.ccafs.marlo.data.model.ShfrmSubAction; import org.cgiar.ccafs.marlo.data.model.User; import org.cgiar.ccafs.marlo.security.Permission; import org.cgiar.ccafs.marlo.utils.APConfig; @@ -155,6 +163,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -248,7 +257,10 @@ public class DeliverableAction extends BaseAction { private FeedbackQACommentManager feedbackQACommentManager; private FeedbackQACommentableFieldsManager feedbackQACommentableFieldsManager; private DeliverableTraineesIndicatorManager deliverableTraineesIndicatorManager; - + private ShfrmPriorityActionManager shfrmPriorityActionManager; + private ShfrmSubActionManager shfrmSubActionManager; + private DeliverableShfrmPriorityActionManager deliverableShfrmPriorityActionManager; + private DeliverableShfrmSubActionManager deliverableShfrmSubActionManager; // Variables private List answers; @@ -262,6 +274,8 @@ public class DeliverableAction extends BaseAction { private Boolean has_specific_management_deliverables; private Boolean isManagingPartnerPersonRequerid; private List deliverableTypeParent; + private List shfrmPriorityActions; + private List deliverableShfrmPriorityActions; private DeliverableValidator deliverableValidator; private List fundingSources; private List activities; @@ -346,7 +360,10 @@ public DeliverableAction(APConfig config, DeliverableTypeManager deliverableType FeedbackQACommentableFieldsManager feedbackQACommentableFieldsManager, FeedbackQACommentManager feedbackQACommentManager, DeliverableClusterParticipantManager deliverableClusterParticipantManager, - DeliverableTraineesIndicatorManager deliverableTraineesIndicatorManager) { + DeliverableTraineesIndicatorManager deliverableTraineesIndicatorManager, + ShfrmPriorityActionManager shfrmPriorityActionManager, ShfrmSubActionManager shfrmSubActionManager, + DeliverableShfrmPriorityActionManager deliverableShfrmPriorityActionManager, + DeliverableShfrmSubActionManager deliverableShfrmSubActionManager) { super(config); this.activityManager = activityManager; this.deliverableManager = deliverableManager; @@ -408,6 +425,10 @@ public DeliverableAction(APConfig config, DeliverableTypeManager deliverableType this.feedbackQACommentableFieldsManager = feedbackQACommentableFieldsManager; this.feedbackQACommentManager = feedbackQACommentManager; this.deliverableTraineesIndicatorManager = deliverableTraineesIndicatorManager; + this.shfrmPriorityActionManager = shfrmPriorityActionManager; + this.shfrmSubActionManager = shfrmSubActionManager; + this.deliverableShfrmPriorityActionManager = deliverableShfrmPriorityActionManager; + this.deliverableShfrmSubActionManager = deliverableShfrmSubActionManager; } /** @@ -623,6 +644,80 @@ public void fillClusterParticipantsList() { } } + public void fillSubActionsGeneralList() { + try { + if (shfrmPriorityActions != null && !shfrmPriorityActions.isEmpty()) { + List subActions; + List subActionsAdd; + for (ShfrmPriorityAction shfrmPriorityAction : shfrmPriorityActions) { + subActions = new ArrayList<>(); + + // Priority action front + if (shfrmPriorityAction != null && shfrmPriorityAction.getId() != null) { + subActionsAdd = new ArrayList<>(); + // Sub Actions DB + subActions = shfrmSubActionManager.findAll(); + if (subActions != null) { + for (ShfrmSubAction subAction : subActions) { + + if (subAction != null && subAction.getShfrmPriorityAction() != null + && subAction.getShfrmPriorityAction().getId() != null) { + if (subAction.getShfrmPriorityAction().getId().equals(shfrmPriorityAction.getId())) { + subActionsAdd.add(subAction); + } + } + } + if (subActionsAdd != null) { + shfrmPriorityAction.setShfrmSubActions(subActionsAdd); + } + } + } + } + } + + } catch (Exception e) { + logger.error("error getting sub actions: " + e); + } + } + + public void fillSubActionsList() { + try { + if (deliverable.getShfrmPriorityActions() != null && !deliverable.getShfrmPriorityActions().isEmpty()) { + List subActions; + List subActionsAdd; + for (DeliverableShfrmPriorityAction deliverableShfrmPriorityAction : deliverable.getShfrmPriorityActions()) { + subActions = new ArrayList<>(); + + // Priority action front + if (deliverableShfrmPriorityAction != null && deliverableShfrmPriorityAction.getShfrmPriorityAction() != null + && deliverableShfrmPriorityAction.getShfrmPriorityAction().getId() != null) { + subActionsAdd = new ArrayList<>(); + // Sub Actions DB + subActions = shfrmSubActionManager.findAll(); + if (subActions != null) { + for (ShfrmSubAction subAction : subActions) { + + if (subAction != null && subAction.getShfrmPriorityAction() != null + && subAction.getShfrmPriorityAction().getId() != null) { + if (subAction.getShfrmPriorityAction().getId() + .equals(deliverableShfrmPriorityAction.getShfrmPriorityAction().getId())) { + subActionsAdd.add(subAction); + } + } + } + if (subActionsAdd != null) { + deliverableShfrmPriorityAction.getShfrmPriorityAction().setShfrmSubActions(subActionsAdd); + } + } + } + } + } + + } catch (Exception e) { + logger.error("error getting sub actions: " + e); + } + } + public Integer getAcceptationPercentage() { return acceptationPercentage; } @@ -652,6 +747,7 @@ public long getActualClusterParticipantID() { } } + public List getAnswers() { return answers; } @@ -723,6 +819,10 @@ public long getDeliverableID() { return deliverableID; } + public List getDeliverableShfrmPriorityActions() { + return deliverableShfrmPriorityActions; + } + public List> getDeliverablesSubTypes(long deliverableTypeID) { List> subTypes = new ArrayList<>(); Map keyOutput; @@ -798,20 +898,20 @@ public List getMyProjects() { return myProjects; } + public List getPartnerInstitutions() { return partnerInstitutions; } + public List getPartnerPersons() { return partnerPersons; } - public List getPartners() { return partners; } - /** * @return an array of integers. */ @@ -898,6 +998,10 @@ public List getResponsibleUsers() { return responsibleUsers; } + public List getShfrmPriorityActions() { + return shfrmPriorityActions; + } + public Map getStatus() { return status; } @@ -1409,6 +1513,46 @@ public void prepare() throws Exception { .filter(o -> o.getPhase().getId().equals(this.getActualPhase().getId())).collect(Collectors.toList()))); } + // SHFRM contribution + if (this.hasSpecificities(APConstants.SHFRM_CONTRIBUTION_ACTIVE)) { + shfrmPriorityActions = shfrmPriorityActionManager.findAll(); + + if (deliverable.getDeliverableShfrmPriorityAction() != null) { + deliverable.setShfrmPriorityActions(new ArrayList<>(deliverable.getDeliverableShfrmPriorityAction().stream() + .filter(o -> o.isActive() && o.getPhase().getId().equals(this.getActualPhase().getId())) + .sorted(Comparator.comparing(DeliverableShfrmPriorityAction::getId)).collect(Collectors.toList()))); + } + this.fillSubActionsList(); + this.fillSubActionsGeneralList(); + + if (deliverable != null && deliverable.getShfrmPriorityActions() != null + && !deliverable.getShfrmPriorityActions().isEmpty()) { + for (DeliverableShfrmPriorityAction deliverablePriorityAction : deliverable.getShfrmPriorityActions()) { + try { + + // Test code + if (deliverablePriorityAction.getShfrmSubActions() == null) { + List deliverableShfrmSubAction = new ArrayList<>(); + deliverablePriorityAction.setShfrmSubActions(deliverableShfrmSubAction); + } + + if (deliverablePriorityAction.getDeliverableShfrmSubAction() != null) { + deliverablePriorityAction + .setShfrmSubActions(new ArrayList<>(deliverablePriorityAction.getDeliverableShfrmSubAction() + .stream().filter(o -> o.isActive() && o.getPhase().getId().equals(this.getActualPhase().getId())) + .sorted(Comparator.comparing(DeliverableShfrmSubAction::getId)).collect(Collectors.toList()))); + } + + } catch (Exception e) { + logger.error("No se pueden obtener deliverableSubActions para deliverablePriorityAction: {}", + deliverablePriorityAction, e); + } + } + } + + + } + // Expected Study Geographic Regions List if (deliverable.getDeliverableGeographicRegions() != null && !deliverable.getDeliverableGeographicRegions().isEmpty()) { @@ -2166,6 +2310,14 @@ public void prepare() throws Exception { if (deliverable.getCrpOutcomes() != null) { deliverable.getCrpOutcomes().clear(); } + + if (deliverable.getShfrmPriorityActions() != null) { + deliverable.getShfrmPriorityActions().clear(); + } + + if (deliverable.getShfrmSubActions() != null) { + deliverable.getShfrmSubActions().clear(); + } } try { @@ -2292,6 +2444,12 @@ public String save() { } } + // SHFRM contribution + if (this.hasSpecificities(APConstants.SHFRM_CONTRIBUTION_ACTIVE)) { + this.savePriorityActions(false); + this.saveSubActions(); + } + /* * Delete the field 'new expected year' when the status is different to Extended and this field has information */ @@ -3530,6 +3688,113 @@ private void saveParticipant() { } } + /** + * Save Deliverable SHFRM priority action Information + * + * @param delete - true for only execute delete process + */ + public void savePriorityActions(boolean onlyDeleteProcess) { + + // Search and deleted form Information + try { + + List actionPrev = deliverableShfrmPriorityActionManager + .findByDeliverableAndPhase(deliverable.getId(), this.getActualPhase().getId()); + + if (this.deliverable.getShfrmPriorityActions() != null) { + List existingIds = new ArrayList<>(); + + for (DeliverableShfrmPriorityAction shfrmDeliverable : this.deliverable.getShfrmPriorityActions()) { + if (shfrmDeliverable != null && shfrmDeliverable.getId() != null) { + existingIds.add(shfrmDeliverable.getId()); + } + } + + List deliverableSubActions = new ArrayList<>(); + + if (actionPrev != null) { + for (DeliverableShfrmPriorityAction priorityAction : actionPrev) { + if (priorityAction != null && priorityAction.getId() != null) { + + // if (deliverableSubActions == null || (deliverableSubActions != null && + // deliverableSubActions.isEmpty())) { + + if (!existingIds.contains(priorityAction.getId())) { + deliverableSubActions = deliverableShfrmSubActionManager + .findByPriorityActionAndPhase(priorityAction.getId(), this.getActualPhase().getId()); + + if (deliverableSubActions != null && !deliverableSubActions.isEmpty()) { + + // delete sub actions + for (DeliverableShfrmSubAction deliverableSubActionDelete : deliverableSubActions) { + if (deliverableSubActionDelete != null && deliverableSubActionDelete.getId() != null) { + deliverableShfrmSubActionManager + .deleteDeliverableShfrmSubAction(deliverableSubActionDelete.getId()); + } + } + } + + // delete actions + deliverableShfrmPriorityActionManager.deleteDeliverableShfrmPriorityAction(priorityAction.getId()); + } + + } + } + } + } + + } catch (Exception e) { + logger.error("unable to delete priority action", e); + } + + // Save form Information + if (this.deliverable.getShfrmPriorityActions() != null && onlyDeleteProcess == false) { + DeliverableShfrmPriorityAction deliverablePriorityActionsSave; + for (DeliverableShfrmPriorityAction deliverablePriorityActions : this.deliverable.getShfrmPriorityActions()) { + deliverablePriorityActionsSave = new DeliverableShfrmPriorityAction(); + + if (deliverablePriorityActions != null) { + // For new deliverable Priority Actions + if (deliverablePriorityActions.getId() == null || deliverablePriorityActions.getId() == -1) { + deliverablePriorityActionsSave.setDeliverable(deliverable); + deliverablePriorityActionsSave.setPhase(this.getActualPhase()); + } else { + // For old deliverable Priority Actions + try { + if (deliverablePriorityActions.getId() != null) { + deliverablePriorityActionsSave = deliverableShfrmPriorityActionManager + .getDeliverableShfrmPriorityActionById(deliverablePriorityActions.getId()); + } + } catch (Exception e) { + logger.error("unable to get old deliverable Priority Actions", e); + } + } + + if (deliverablePriorityActions.getShfrmPriorityAction() != null + && deliverablePriorityActions.getShfrmPriorityAction().getId() != null) { + ShfrmPriorityAction priorityAction = shfrmPriorityActionManager + .getShfrmPriorityActionById(deliverablePriorityActions.getShfrmPriorityAction().getId()); + if (deliverable != null && priorityAction != null && priorityAction.getId() != null) { + deliverablePriorityActionsSave.setDeliverable(deliverable); + deliverablePriorityActionsSave.setShfrmPriorityAction(priorityAction); + deliverablePriorityActionsSave.setPhase(this.getActualPhase()); + } + + DeliverableShfrmPriorityAction priorityActionTemp = this.deliverableShfrmPriorityActionManager + .saveDeliverableShfrmPriorityAction(deliverablePriorityActionsSave); + if (priorityActionTemp != null && priorityActionTemp.getId() != null) { + deliverablePriorityActions.setId(priorityActionTemp.getId()); + } + // This is to add deliverablePriorityActions to generate correct auditlog. + if (!this.deliverable.getDeliverableShfrmPriorityAction().contains(deliverablePriorityActionsSave)) { + this.deliverable.getDeliverableShfrmPriorityAction().add(deliverablePriorityActionsSave); + } + } + } + } + } + } + /** * All we are doing here is setting the modification justification. */ @@ -3787,6 +4052,132 @@ public void saveQualityCheck() { } + /** + * Save Deliverable SHFRM sub actions Information + */ + public void saveSubActions() { + + // Search and deleted form Information + try { + if (this.deliverable.getShfrmPriorityActions() != null && !this.deliverable.getShfrmPriorityActions().isEmpty()) { + for (DeliverableShfrmPriorityAction priorityAction : this.deliverable.getShfrmPriorityActions()) { + + List existingIds = new ArrayList<>(); + List subPrev = null; + try { + subPrev = deliverableShfrmSubActionManager.findByPriorityActionAndPhase(priorityAction.getId(), + this.getActualPhase().getId()); + } catch (Exception e) { + logger.error("No sub actions added ", e); + } + + if (priorityAction.getShfrmSubActions() != null) { + + for (DeliverableShfrmSubAction shfrmSubDeliverable : priorityAction.getShfrmSubActions()) { + if (shfrmSubDeliverable != null && shfrmSubDeliverable.getId() != null) { + existingIds.add(shfrmSubDeliverable.getId()); + } + } + + if (subPrev != null) { + for (DeliverableShfrmSubAction subAction : subPrev) { + if (subAction != null && subAction.getId() != null) { + + if (!existingIds.contains(subAction.getId())) { + deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); + } + + } + } + } + } else { + // Delete all in DB + /* + * if (subPrev != null && !subPrev.isEmpty()) { + * for (DeliverableShfrmSubAction subAction : subPrev) { + * if (subAction != null && subAction.getId() != null) { + * if (!existingIds.contains(subAction.getId())) { + * deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); + * } + * } + * } + * } + */ + } + + /***************/ + + } + + } + } catch (Exception e) { + logger.error("unable to delete priority action", e); + } + + // Save form Information + if (this.deliverable.getShfrmPriorityActions() != null) { + DeliverableShfrmSubAction deliverableSubActionSave; + for (DeliverableShfrmPriorityAction deliverablePriorityAction : this.deliverable.getShfrmPriorityActions()) { + if (deliverablePriorityAction != null && deliverablePriorityAction.getShfrmSubActions() != null) { + for (DeliverableShfrmSubAction deliverableSubAction : deliverablePriorityAction.getShfrmSubActions()) { + deliverableSubActionSave = new DeliverableShfrmSubAction(); + + if (deliverableSubAction != null) { + if (deliverableSubAction.getShfrmSubAction() != null + && deliverableSubAction.getShfrmSubAction().getId() != null) { + ShfrmSubAction subAction = + shfrmSubActionManager.getShfrmSubActionById(deliverableSubAction.getShfrmSubAction().getId()); + if (subAction != null) { + // For new deliverable Priority Actions + if (deliverableSubAction.getId() == null || deliverableSubAction.getId() == -1) { + deliverableSubActionSave.setId(null); + deliverableSubActionSave.setDeliverableShfrmPriorityAction(deliverablePriorityAction); + deliverableSubActionSave.setPhase(this.getActualPhase()); + deliverableSubActionSave.setShfrmSubAction(subAction); + this.deliverableShfrmSubActionManager.saveDeliverableShfrmSubAction(deliverableSubActionSave); + + } else { + // For old deliverable Priority Actions + try { + deliverableSubActionSave = + deliverableShfrmSubActionManager.getDeliverableShfrmSubActionById(deliverableSubAction.getId()); + if (deliverableSubActionSave != null) { + deliverableSubActionSave.setDeliverableShfrmPriorityAction(deliverablePriorityAction); + deliverableSubActionSave.setPhase(this.getActualPhase()); + deliverableSubActionSave.setShfrmSubAction(subAction); + this.deliverableShfrmSubActionManager.saveDeliverableShfrmSubAction(deliverableSubActionSave); + } + + } catch (Exception e) { + logger.error("unable to get old deliverable sub Actions", e); + } + } + + // This is to add deliverablePriorityActions to generate correct auditlog. + /* + * if (!this.deliverable.getDeliverableShfrmSubAction().contains(deliverableSubActionSave)) { + * this.deliverable.getDeliverableShfrmSubAction().add(deliverableSubActionSave); + * } + */ + } + } + } + } + } + } + } + + // Try to check -> delete priority actions deleted from front-end after delete the sub-actions when all sub actions + // was deleted + /* + * if (this.deliverable.getShfrmPriorityActions() == null + * || (this.deliverable.getShfrmPriorityActions() != null && this.deliverable.getShfrmPriorityActions().isEmpty())) + * { + * this.savePriorityActions(true); + * } + */ + } + public void saveUsers() { if (deliverable.getUsers() == null) { @@ -3862,6 +4253,10 @@ public void setDeliverableID(long deliverableID) { this.deliverableID = deliverableID; } + public void setDeliverableShfrmPriorityActions(List deliverableShfrmPriorityActions) { + this.deliverableShfrmPriorityActions = deliverableShfrmPriorityActions; + } + public void setDeliverableSubTypes(List deliverableSubTypes) { this.deliverableSubTypes = deliverableSubTypes; } @@ -3990,6 +4385,10 @@ public void setResponsibleUsers(List responsibleUsers) { this.responsibleUsers = responsibleUsers; } + public void setShfrmPriorityActions(List shfrmPriorityActions) { + this.shfrmPriorityActions = shfrmPriorityActions; + } + public void setStatus(Map status) { this.status = status; } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/SafeguardAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/SafeguardAction.java index 59ac03ae1b..15abfcd7ea 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/SafeguardAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/SafeguardAction.java @@ -18,6 +18,8 @@ import org.cgiar.ccafs.marlo.action.BaseAction; import org.cgiar.ccafs.marlo.config.APConstants; import org.cgiar.ccafs.marlo.data.manager.AuditLogManager; +import org.cgiar.ccafs.marlo.data.manager.FeedbackQACommentManager; +import org.cgiar.ccafs.marlo.data.manager.FeedbackQACommentableFieldsManager; import org.cgiar.ccafs.marlo.data.manager.FileDBManager; import org.cgiar.ccafs.marlo.data.manager.ProjectInfoManager; import org.cgiar.ccafs.marlo.data.manager.ProjectManager; @@ -25,6 +27,8 @@ import org.cgiar.ccafs.marlo.data.manager.SectionStatusManager; import org.cgiar.ccafs.marlo.data.manager.UserManager; import org.cgiar.ccafs.marlo.data.model.CrpProgram; +import org.cgiar.ccafs.marlo.data.model.FeedbackQAComment; +import org.cgiar.ccafs.marlo.data.model.FeedbackQACommentableFields; import org.cgiar.ccafs.marlo.data.model.GlobalUnit; import org.cgiar.ccafs.marlo.data.model.Project; import org.cgiar.ccafs.marlo.data.model.ProjectInfo; @@ -87,12 +91,16 @@ public class SafeguardAction extends BaseAction { private String fileReportingFileName; private SafeguardValidator validator; private Safeguards safeguard; + private List feedbackComments; + private FeedbackQACommentManager feedbackQACommentManager; + private FeedbackQACommentableFieldsManager feedbackQACommentableFieldsManager; @Inject public SafeguardAction(APConfig config, ProjectManager projectManager, UserManager userManager, SectionStatusManager sectionStatusManager, FileDBManager fileDBManager, AuditLogManager auditLogManager, SafeguardValidator validator, HistoryComparator historyComparator, ProjectInfoManager projectInfoManagerManager, - SafeguardsManager safeguardsManager) { + SafeguardsManager safeguardsManager, FeedbackQACommentableFieldsManager feedbackQACommentableFieldsManager, + FeedbackQACommentManager feedbackQACommentManager) { super(config); this.projectManager = projectManager; this.projectInfoManagerManager = projectInfoManagerManager; @@ -102,6 +110,8 @@ public SafeguardAction(APConfig config, ProjectManager projectManager, UserManag this.fileDBManager = fileDBManager; this.historyComparator = historyComparator; this.safeguardsManager = safeguardsManager; + this.feedbackQACommentableFieldsManager = feedbackQACommentableFieldsManager; + this.feedbackQACommentManager = feedbackQACommentManager; } /** @@ -202,6 +212,10 @@ private String getBilateralProposalRelativePath() { + "safeguard" + File.separator; } + public List getFeedbackComments() { + return feedbackComments; + } + public File getFile() { return file; } @@ -245,6 +259,7 @@ public GlobalUnit getLoggedCrp() { return loggedCrp; } + public Project getProject() { return project; } @@ -279,7 +294,6 @@ public long getSafeguardID() { return safeguardID; } - public String getTransaction() { return transaction; } @@ -290,11 +304,11 @@ private String getWorkplanRelativePath() { + config.getProjectWorkplanFolder() + File.separator; } + public String getWorkplanURL() { return config.getDownloadURL() + "/" + this.getWorkplanRelativePath().replace('\\', '/'); } - /** * Return the absolute path where the work plan is or should be located. * @@ -305,6 +319,7 @@ private String getWorplansAbsolutePath() { return config.getUploadsBaseFolder() + File.separator + this.getWorkplanRelativePath() + File.separator; } + public void loadFile() { if (safeguard.getFile() != null) { if (safeguard.getFile().getId() != null) { @@ -315,7 +330,6 @@ public void loadFile() { } } - @Override public void prepare() throws Exception { @@ -445,6 +459,30 @@ public void prepare() throws Exception { projectDB = projectManager.getProjectById(projectID); + /* + * get feedback comments + */ + try { + + feedbackComments = new ArrayList<>(); + feedbackComments = feedbackQACommentableFieldsManager.findAll().stream() + .filter(f -> f.getSectionName() != null && f.getSectionName().equals("innovation")) + .collect(Collectors.toList()); + if (feedbackComments != null) { + for (FeedbackQACommentableFields field : feedbackComments) { + List comments = new ArrayList(); + comments = feedbackQACommentManager.findAll().stream() + .filter(f -> f != null && f.getPhase() != null && f.getPhase().getId() != null + && f.getPhase().getId().equals(this.getActualPhase().getId()) && f.getParentId() == safeguard.getId() + && f.getField() != null && f.getField().getId() != null && f.getField().getId().equals(field.getId())) + .collect(Collectors.toList()); + field.setQaComments(comments); + } + } + + } catch (Exception e) { + } + // The base permission is established for the current section String params[] = {loggedCrp.getAcronym(), project.getId() + ""}; @@ -490,6 +528,7 @@ public String save() { } + public void saveSafeguard() { Safeguards safeguardDB = new Safeguards(); if (safeguard != null && safeguard.getId() != null) { @@ -506,6 +545,10 @@ public void saveSafeguard() { } + public void setFeedbackComments(List feedbackComments) { + this.feedbackComments = feedbackComments; + } + public void setFile(File file) { this.file = file; } @@ -515,16 +558,15 @@ public void setFileContentType(String fileContentType) { this.fileContentType = fileContentType; } + public void setFileFileName(String fileFileName) { this.fileFileName = fileFileName; } - public void setFileReporting(File fileReporting) { this.fileReporting = fileReporting; } - public void setFileReportingFileName(String fileReportingFileName) { this.fileReportingFileName = fileReportingFileName; } @@ -537,6 +579,7 @@ public void setProject(Project project) { this.project = project; } + public void setProjectID(long projectID) { this.projectID = projectID; } @@ -545,7 +588,6 @@ public void setSafeguard(Safeguards safeguard) { this.safeguard = safeguard; } - public void setSafeguardID(long safeguardID) { this.safeguardID = safeguardID; } @@ -554,7 +596,6 @@ public void setTransaction(String transaction) { this.transaction = transaction; } - @Override public void validate() { this.setInvalidFields(new HashMap<>()); diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java index 61fb7893cb..97b3655e00 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java @@ -161,6 +161,7 @@ public final class APConstants { public static final String DUPLICATED_DELIVERABLES_FUNCTIONALITY_ACTIVE = "duplicated_deliverables_functionality_active"; public static final String HIGHLIGHT_COMMENTS_ACTIVE = "highlight_comments_active"; + public static final String SHFRM_CONTRIBUTION_ACTIVE = "shfrm_contribution_active"; public static final String TIP_SECTION_ACTIVE = "tip_section_active"; @@ -183,6 +184,8 @@ public final class APConstants { public static final String DELIVERABLE_FILE_LOCALLY_HOSTED_STR = "Locally"; public static final String DELIVERABLE_ID = "deliverableId"; + public static final String PRIORITY_ACTION_ID = "priorityActionId"; + public static final String SUB_ACTION_ID = "subActionId"; public static final int DELIVERABLE_QUALITY_ANSWER_NO = 3; public static final int DELIVERABLE_QUALITY_ANSWER_YES = 2; public static final int DELIVERABLE_QUALITY_ANSWER_YES_BUT_NO = 1; diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java index 765e29bb68..6bd9907487 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/validation/projects/DeliverableValidator.java @@ -24,26 +24,31 @@ import org.cgiar.ccafs.marlo.data.manager.ProjectManager; import org.cgiar.ccafs.marlo.data.manager.ProjectPartnerPersonManager; import org.cgiar.ccafs.marlo.data.manager.RepIndTypeActivityManager; +import org.cgiar.ccafs.marlo.data.manager.SoilIndicatorManager; import org.cgiar.ccafs.marlo.data.model.CgiarCrossCuttingMarker; import org.cgiar.ccafs.marlo.data.model.Deliverable; import org.cgiar.ccafs.marlo.data.model.DeliverableCrossCuttingMarker; +import org.cgiar.ccafs.marlo.data.model.DeliverableCrpOutcome; import org.cgiar.ccafs.marlo.data.model.DeliverableDissemination; import org.cgiar.ccafs.marlo.data.model.DeliverableGeographicScope; import org.cgiar.ccafs.marlo.data.model.DeliverableInfo; import org.cgiar.ccafs.marlo.data.model.DeliverableMetadataElement; import org.cgiar.ccafs.marlo.data.model.DeliverableParticipant; import org.cgiar.ccafs.marlo.data.model.DeliverablePublicationMetadata; +import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmPriorityAction; import org.cgiar.ccafs.marlo.data.model.GlobalUnit; import org.cgiar.ccafs.marlo.data.model.Project; import org.cgiar.ccafs.marlo.data.model.ProjectSectionStatusEnum; import org.cgiar.ccafs.marlo.data.model.ProjectStatusEnum; import org.cgiar.ccafs.marlo.data.model.RepIndTypeActivity; +import org.cgiar.ccafs.marlo.data.model.SoilIndicator; import org.cgiar.ccafs.marlo.utils.InvalidFieldsMessages; import org.cgiar.ccafs.marlo.utils.doi.DOIService; import org.cgiar.ccafs.marlo.validation.BaseValidator; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.stream.Collectors; @@ -69,6 +74,7 @@ public class DeliverableValidator extends BaseValidator { private DeliverableUserManager deliverableUserManager; private CgiarCrossCuttingMarkerManager cgiarCrossCuttingMarkerManager; private RepIndTypeActivityManager repIndTypeActivityManager; + private SoilIndicatorManager soilIndicatorManager; Boolean doesNotHaveDOI; @@ -76,13 +82,14 @@ public class DeliverableValidator extends BaseValidator { public DeliverableValidator(GlobalUnitManager crpManager, ProjectManager projectManager, ProjectPartnerPersonManager projectPartnerPersonManager, CgiarCrossCuttingMarkerManager cgiarCrossCuttingMarkerManager, RepIndTypeActivityManager repIndTypeActivityManager, - DeliverableUserManager deliverableUserManager) { + DeliverableUserManager deliverableUserManager, SoilIndicatorManager soilIndicatorManager) { this.crpManager = crpManager; this.projectManager = projectManager; this.projectPartnerPersonManager = projectPartnerPersonManager; this.cgiarCrossCuttingMarkerManager = cgiarCrossCuttingMarkerManager; this.deliverableUserManager = deliverableUserManager; this.repIndTypeActivityManager = repIndTypeActivityManager; + this.soilIndicatorManager = soilIndicatorManager; } private Path getAutoSaveFilePath(Deliverable deliverable, long crpID, BaseAction action) { @@ -525,7 +532,71 @@ public void validate(BaseAction action, Deliverable deliverable, boolean saving) } } + // SHFRM contribution validations + + if (action.hasSpecificities(APConstants.SHFRM_CONTRIBUTION_ACTIVE) && dInfo != null + && dInfo.getContributingShfrm() != null && dInfo.getContributingShfrm() == true) { + + // Validate Soil indicators + if (deliverable.getCrpOutcomes() == null || !deliverable.getCrpOutcomes().isEmpty()) { + List soilIndicators = new ArrayList<>(); + soilIndicators = soilIndicatorManager.findAll(); + + for (DeliverableCrpOutcome indicator : deliverable.getCrpOutcomes()) { + if (soilIndicators != null && !soilIndicators.isEmpty()) { + for (SoilIndicator soilIndicator : soilIndicators) { + if (soilIndicator != null && soilIndicator.getIndicatorName() != null && indicator != null + && indicator.getCrpProgramOutcome() != null && indicator.getCrpProgramOutcome().getAcronym() != null + && !indicator.getCrpProgramOutcome().getAcronym().contains(soilIndicator.getIndicatorName())) { + action.addMessage(action.getText("deliverable.crpOutcomes")); + action.addMissingField("deliverable.crpOutcomes"); + action.getInvalidFields().put("list-deliverable.crpOutcomes", InvalidFieldsMessages.EMPTYFIELD); + } + } + } + } + } + + // Validate contribution narrative + if (!(this + .isValidString(deliverable.getDeliverableInfo(action.getActualPhase()).getShfrmContributionNarrative()) + && this.wordCount( + deliverable.getDeliverableInfo(action.getActualPhase()).getShfrmContributionNarrative()) <= 200)) { + action.addMessage(action.getText("deliverable.deliverableInfo.shfrmContributionNarrative")); + action.addMissingField("deliverable.deliverableInfo.shfrmContributionNarrative"); + action.getInvalidFields().put("input-deliverable.deliverableInfo.shfrmContributionNarrative", + InvalidFieldsMessages.EMPTYFIELD); + } + + // Validate priority actions + if (deliverable.getShfrmPriorityActions() == null + || (deliverable.getShfrmPriorityActions() != null && deliverable.getShfrmPriorityActions().isEmpty())) { + action.addMessage(action.getText("deliverable.shfrmPriorityActions")); + action.addMissingField("deliverable.shfrmPriorityActions"); + action.getInvalidFields().put("list-deliverable.shfrmPriorityActions", InvalidFieldsMessages.EMPTYFIELD); + } else if (deliverable.getShfrmPriorityActions() != null && !deliverable.getShfrmPriorityActions().isEmpty()) { + int indexJ = 0; + + for (DeliverableShfrmPriorityAction priorityAction : deliverable.getShfrmPriorityActions()) { + if (priorityAction != null && priorityAction.getShfrmSubActions() == null + || (priorityAction.getShfrmSubActions() != null && priorityAction.getShfrmSubActions().isEmpty())) { + action.addMessage(action.getText("deliverable.shfrmSubActions")); + action.addMissingField("deliverable.shfrmPriorityActions"); + action.getInvalidFields().put("list-deliverable.shfrmPriorityActions", InvalidFieldsMessages.EMPTYFIELD); + /* + * action.addMessage(action.getText("deliverable.shfrmSubActions[" + indexJ + "]")); + * action.addMissingField("deliverable.shfrmSubActions[" + indexJ + "]"); + * action.getInvalidFields().put("list-deliverable.shfrmPriorityAction[" + indexJ + "].shfrmSubActions", + * InvalidFieldsMessages.EMPTYFIELD); + */ + indexJ++; + } + } + } + + } } + this.saveMissingFields(deliverable, action.getActualPhase().getDescription(), action.getActualPhase().getYear(), action.getActualPhase().getUpkeep(), ProjectSectionStatusEnum.DELIVERABLES.getStatus(), action); } diff --git a/marlo-web/src/main/resources/custom/aicrra.properties b/marlo-web/src/main/resources/custom/aicrra.properties index 03c85cfe04..078eb8683b 100644 --- a/marlo-web/src/main/resources/custom/aicrra.properties +++ b/marlo-web/src/main/resources/custom/aicrra.properties @@ -43,6 +43,7 @@ global.cookieConsentMessage=By default, MARLO uses cookies to ensure you get the global.webSiteLink.placeholder=https:// global.viewMore=View More global.crps=PTFs +global.ShfrmPriorityAction=Priority Action # Systems Messages systemMessage.serverReset=We are restarting the server in order to apply some improvements to the system. Please save what you are doing in a word document (if needed) since you will have to login again. Sorry for the inconvenience. @@ -343,6 +344,7 @@ breadCrumb.menu.timelineManagement=Timeline Management breadCrumb.menu.feedbackManagement=Feedback Management breadCrumb.menu.buttonGuideManagement=Button Guide Management breadCrumb.menu.messageManagement=MARLO Message Management +breadCrumb.menu.shfrmManagement=Soil Health and Fertility Road Map # Message section message.title=MARLO Message Management @@ -939,6 +941,15 @@ deliverable.typeOfActivity.other=Other deliverable.typeOfActivity.other.description= deliverable.missing.activity.alert=There are {0} deliverable(s) in this cluster not mapped to any activity
*Please keep in mind that without full fill this task the green-check mark validator will not be reflected
+deliverable.shfrmContribution.question.reporting=Is this deliverable contributing to contribute to the Soil Health and Fertiliser Road Map (SHFRM) implementation: +deliverable.shfrmContribution.question.planning=Is this deliverable expected to contribute to the Soil Health and Fertiliser Road Map (SHFRM) implementation: +deliverable.shfrmContribution.question.help=If you select yes, please make sure to select the SHFRM indicator in the next question +deliverable.shfrmContribution.narrative=Provide a short narrative on how this deliverable is expecting to contribute to the SHFRM +deliverable.shfrmContribution.priorityAction=To which priority action of the SHFRM is this deliverable contributing to? +deliverable.shfrmContribution.priorityAction.help=Select a priority action +deliverable.shfrmContribution.subAction=To which specific sub-action of the SHFRM is this deliverable contributing to? +deliverable.shfrmContribution.subAction.help=Select sub-action(s) + intellectualAsset.fillingType=Type of filling intellectualAsset.patentStatus=Patent status intellectualAsset.patentType=Patent Type @@ -1815,6 +1826,7 @@ CRPAdmin.menu.guestUsers=Guest Users CRPAdmin.menu.users=List of users CRPAdmin.menu.deliverables=Deliverables Management CRPAdmin.menu.crpPhases=Planning/Reporting Cycles +CRPAdmin.menu.shfrmManagement=Soil Health and Fertility Road Map # # Program Management Section programManagement.title=Project Management Committee @@ -1912,6 +1924,19 @@ projectPhases.help= projectPhases.visible=Display on timeline projectPhases.editable=Status +# Soil Health and Fertility Road Map Management +shfrmManagement.title=Manage the Soil Health and Fertility Road Map (SHFRM) +shfrmManagement.priorityActions.set=Set the control list for Priority Actions: +shfrmManagement.priorityActions.title=Title +shfrmManagement.priorityActions.description=Description +shfrmManagement.priorityActions.add=Add new priority action +shfrmManagement.subActions.add=Add new sub-action +shfrmManagement.subActions.title=Title +shfrmManagement.subActions.description=Description +shfrmManagement.deliverables.info=See {0} deliverables attached +shfrmManagement.subActionsEmpty=No sub-Action(s) added yet +shfrmManagement.actionsEmpty=No action(s) added yet + # # Super Admin marloSLOs.sloTitle=System Level Outcomes diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1508__UpdateDeliverablesInfoTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1508__UpdateDeliverablesInfoTable.sql new file mode 100644 index 0000000000..b27a22a659 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1508__UpdateDeliverablesInfoTable.sql @@ -0,0 +1,2 @@ +ALTER TABLE deliverables_info ADD is_contributing_shfrm tinyint(1) DEFAULT 0 NULL; +ALTER TABLE deliverables_info ADD shfrm_contribution_narrative varchar(200) NULL; \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1509__CreateShfrmPriorityActionsTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1509__CreateShfrmPriorityActionsTable.sql new file mode 100644 index 0000000000..d0fcff5e67 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1509__CreateShfrmPriorityActionsTable.sql @@ -0,0 +1,15 @@ +CREATE TABLE shfrm_priority_actions ( + id bigint(20) auto_increment NOT NULL, + name varchar(100) NULL, + is_active tinyint(1) NULL, + description varchar(300) NULL, + modified_by bigint(20) NULL, + modification_justification text NULL, + created_by bigint(20) NULL, + active_since timestamp DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP NULL, + CONSTRAINT shfrm_priority_action_pk PRIMARY KEY (id), + CONSTRAINT shfrm_priority_actions_users_FK FOREIGN KEY (modified_by) REFERENCES users(id) ON DELETE RESTRICT ON UPDATE RESTRICT +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_general_ci; \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1510__CreateShfrmSubActionsTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1510__CreateShfrmSubActionsTable.sql new file mode 100644 index 0000000000..d11df3f67e --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1510__CreateShfrmSubActionsTable.sql @@ -0,0 +1,17 @@ +CREATE TABLE shfrm_sub_actions ( + id bigint(20) auto_increment NOT NULL, + name varchar(100) NULL, + description varchar(300) NULL, + shfrm_priority_action_id bigint(20) NOT NULL, + is_active tinyint(1) NULL, + modified_by bigint(20) NULL, + modification_justification text NULL, + created_by bigint(20) NULL, + active_since timestamp DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP NULL, + CONSTRAINT shfrm_sub_action_pk PRIMARY KEY (id), + CONSTRAINT shfrm_sub_action_users_FK FOREIGN KEY (modified_by) REFERENCES users(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT shfrm_sub_actions_FK FOREIGN KEY (shfrm_priority_action_id) REFERENCES shfrm_priority_actions(id) ON DELETE RESTRICT ON UPDATE RESTRICT +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_czech_ci; \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1511__CreateDeliverableShfrmPriorityActionsTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1511__CreateDeliverableShfrmPriorityActionsTable.sql new file mode 100644 index 0000000000..a01fb1e7f2 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1511__CreateDeliverableShfrmPriorityActionsTable.sql @@ -0,0 +1,20 @@ +CREATE TABLE deliverable_shfrm_priority_action ( + id bigint(20) auto_increment NOT NULL, + deliverable_id bigint(20) NOT NULL, + shfrm_priority_action_id bigint(20) NOT NULL, + is_active tinyint(1) NULL, + id_phase bigint(20) NOT NULL, + modified_by bigint(20) NULL, + modification_justification text NULL, + created_by bigint(20) NULL, + active_since timestamp DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP NULL, + CONSTRAINT deliverable_shfrm_priority_action_pk PRIMARY KEY (id), + CONSTRAINT deliverable_shfrm_priority_action_deliverables_FK FOREIGN KEY (deliverable_id) REFERENCES deliverables(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfrm_priority_action_phases_FK FOREIGN KEY (id_phase) REFERENCES phases(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfrm_priority_action_shfrm_priority_actions_FK FOREIGN KEY (shfrm_priority_action_id) REFERENCES shfrm_priority_actions(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfmr_priority_action_users_FK FOREIGN KEY (modified_by) REFERENCES users(id) ON DELETE RESTRICT ON UPDATE RESTRICT + +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_general_ci; \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1512__CreateDeliverableShfrmSubActionsTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1512__CreateDeliverableShfrmSubActionsTable.sql new file mode 100644 index 0000000000..50ba5b0aa8 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240126_1512__CreateDeliverableShfrmSubActionsTable.sql @@ -0,0 +1,20 @@ +CREATE TABLE deliverable_shfmr_sub_action ( + id bigint(20) auto_increment NOT NULL, + deliverable_shfrm_priority_action_id bigint(20) NOT NULL, + shfrm_sub_action_id bigint(20) NULL, + is_active tinyint(1) NULL, + id_phase bigint(20) NOT NULL, + modified_by bigint(20) NULL, + modification_justification text NULL, + created_by bigint(20) NULL, + active_since timestamp DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP NULL, + CONSTRAINT deliverable_shfmr_sub_action_pk PRIMARY KEY (id), + CONSTRAINT deliverable_shfmr_sub_action_phases_FK FOREIGN KEY (id_phase) REFERENCES phases(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfmr_sub_action_users_FK FOREIGN KEY (modified_by) REFERENCES users(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfmr_sub_action_shfrm_sub_actions_FK FOREIGN KEY (shfrm_sub_action_id) REFERENCES shfrm_sub_actions(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT deliverable_shfmr_sub_action_deliverable_FK FOREIGN KEY (deliverable_shfrm_priority_action_id) REFERENCES deliverable_shfrm_priority_action(id) ON DELETE RESTRICT ON UPDATE RESTRICT +) + +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_general_ci; \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0728__UpdateShfrmTables.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0728__UpdateShfrmTables.sql new file mode 100644 index 0000000000..cc6d618c46 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0728__UpdateShfrmTables.sql @@ -0,0 +1,10 @@ +ALTER TABLE shfrm_priority_actions MODIFY COLUMN is_active tinyint(1) DEFAULT 1 NOT NULL; + +ALTER TABLE shfrm_sub_actions MODIFY COLUMN is_active tinyint(1) DEFAULT 1 NOT NULL; + +ALTER TABLE deliverable_shfrm_priority_action MODIFY COLUMN is_active tinyint(1) DEFAULT 1 NOT NULL; + +ALTER TABLE deliverable_shfmr_sub_action MODIFY COLUMN is_active tinyint(1) DEFAULT 1 NOT NULL; + + + diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0840__AddSpecifityForShfrmFunction.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0840__AddSpecifityForShfrmFunction.sql new file mode 100644 index 0000000000..eeeac93d5f --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0840__AddSpecifityForShfrmFunction.sql @@ -0,0 +1,6 @@ +INSERT INTO parameters (global_unit_type_id, `key`, `description`, `format`, default_value, category) +VALUES ( '1', 'shfrm_contribution_active', 'Enable shfrm deliverables contribution functionality)', '1', 'false', '2'); +INSERT INTO parameters (global_unit_type_id, `key`, `description`, `format`, default_value, category) +VALUES ( '3', 'shfrm_contribution_active', 'Enable shfrm deliverables contribution functionality', '1', 'false', '2'); +INSERT INTO parameters (global_unit_type_id, `key`, `description`, `format`, default_value, category) +VALUES ( '4', 'shfrm_contribution_active', 'Enable shfrm deliverables contribution functionality', '1', 'false', '2'); \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0841__CreateShfrmSoilIndicatorsTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0841__CreateShfrmSoilIndicatorsTable.sql new file mode 100644 index 0000000000..48be03b98a --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_0841__CreateShfrmSoilIndicatorsTable.sql @@ -0,0 +1,11 @@ +CREATE TABLE soil_indicators ( + id bigint(20) auto_increment NOT NULL, + indicator_name varchar(100) NOT NULL, + indicador_id bigint(20) NULL, + id_phase bigint(20) NOT NULL, + CONSTRAINT soil_indicators_pk PRIMARY KEY (id), + CONSTRAINT soil_indicators_phases_FK FOREIGN KEY (id_phase) REFERENCES phases(id) ON DELETE RESTRICT ON UPDATE RESTRICT +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_general_ci; \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1445__UpdateShfrmSoilIndicatorsField.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1445__UpdateShfrmSoilIndicatorsField.sql new file mode 100644 index 0000000000..c5807f8b8c --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1445__UpdateShfrmSoilIndicatorsField.sql @@ -0,0 +1 @@ +ALTER TABLE soil_indicators CHANGE indicador_id indicator_id bigint(20) NULL; diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1625__UpdateShfrmDeliverablesTables.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1625__UpdateShfrmDeliverablesTables.sql new file mode 100644 index 0000000000..26f8849fa5 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240202_1625__UpdateShfrmDeliverablesTables.sql @@ -0,0 +1,2 @@ +RENAME TABLE deliverable_shfmr_sub_action TO deliverable_shfmr_sub_actions; +RENAME TABLE deliverable_shfrm_priority_action TO deliverable_shfrm_priority_actions; \ No newline at end of file diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240204_0600__UpdateShfrmDeliverablesSubActionTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240204_0600__UpdateShfrmDeliverablesSubActionTable.sql new file mode 100644 index 0000000000..cdf00ccc76 --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240204_0600__UpdateShfrmDeliverablesSubActionTable.sql @@ -0,0 +1 @@ +RENAME TABLE deliverable_shfmr_sub_actions TO deliverable_shfrm_sub_actions; diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240207_0900__UpdateShfrmSubActionTable.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240207_0900__UpdateShfrmSubActionTable.sql new file mode 100644 index 0000000000..c3f00b49fc --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240207_0900__UpdateShfrmSubActionTable.sql @@ -0,0 +1 @@ +ALTER TABLE shfrm_sub_actions COLLATE=utf8_general_ci; diff --git a/marlo-web/src/main/resources/global.properties b/marlo-web/src/main/resources/global.properties index 5a49dd72ff..f2e88c5cae 100644 --- a/marlo-web/src/main/resources/global.properties +++ b/marlo-web/src/main/resources/global.properties @@ -43,6 +43,7 @@ global.cookieConsentMessage=By default, MARLO uses cookies to ensure you get the global.webSiteLink.placeholder=https:// global.viewMore=View More global.crps=CRPs +global.shfrmPriorityAction=Priority Action # Systems Messages systemMessage.serverReset=We are restarting the server in order to apply some improvements to the system. Please save what you are doing in a word document (if needed) since you will have to login again. Sorry for the inconvenience. @@ -344,6 +345,7 @@ breadCrumb.menu.timelineManagement=Timeline Management breadCrumb.menu.feedbackManagement=Feedback Management breadCrumb.menu.buttonGuideManagement=Button Guide Management breadCrumb.menu.messageManagement=MARLO Message Management +breadCrumb.menu.shfrmManagement=Soil Health and Fertility Road Map # Message section message.title=MARLO Message Management @@ -938,6 +940,16 @@ deliverable.typeOfActivity.trials=Trials and studies deliverable.typeOfActivity.trials.description=This includes participants in lab and field trials (including on-farm trials), and direct participants in nutrition studies, impact evaluations and other research studies (soil research, integrated pest management, etc.). deliverable.typeOfActivity.other=Other deliverable.typeOfActivity.other.description= +deliverable.missing.activity.alert=There are {0} deliverable(s) in this cluster not mapped to any activity
*Please keep in mind that without full fill this task the green-check mark validator will not be reflected
+ +deliverable.shfrmContribution.question.reporting=Is this deliverable contributing to contribute to the Soil Health and Fertiliser Road Map (SHFRM) implementation: +deliverable.shfrmContribution.question.planning=Is this deliverable expected to contribute to the Soil Health and Fertiliser Road Map (SHFRM) implementation: +deliverable.shfrmContribution.question.help=If you select yes, please make sure to select the SHFRM indicator in the next question +deliverable.shfrmContribution.narrative=Provide a short narrative on how this deliverable is expecting to contribute to the SHFRM +deliverable.shfrmContribution.priorityAction=To which priority action of the SHFRM is this deliverable contributing to? +deliverable.shfrmContribution.priorityAction.help=Select a priority action +deliverable.shfrmContribution.subAction=To which specific sub-action of the SHFRM is this deliverable contributing to? +deliverable.shfrmContribution.subAction.help=Select sub-action(s) intellectualAsset.fillingType=Type of filling intellectualAsset.patentStatus=Patent status @@ -1891,6 +1903,7 @@ CRPAdmin.menu.guestUsers=Guest Users CRPAdmin.menu.users=List of users CRPAdmin.menu.deliverables=Deliverables Management CRPAdmin.menu.crpPhases=Planning/Reporting Cycles +CRPAdmin.menu.shfrmManagement=Soil Health and Fertility Road Map # # Program Management Section programManagement.title=Program Management Unit Team @@ -1985,6 +1998,20 @@ projectPhases.help= projectPhases.visible=Display on timeline projectPhases.editable=Status +# Soil Health and Fertility Road Map Management +shfrmManagement.title=Manage the Soil Health and Fertility Road Map (SHFRM) +shfrmManagement.priorityActions.set=Set the control list for Priority Actions: +shfrmManagement.priorityActions.title=Title +shfrmManagement.priorityActions.description=Description +shfrmManagement.priorityActions.add=Add new priority action +shfrmManagement.subActions.add=Add new sub-action +shfrmManagement.subActions.title=Title +shfrmManagement.subActions.description=Description +shfrmManagement.deliverables.info=See {0} deliverables attached +shfrmManagement.subActionsEmpty=No sub-Action(s) added yet +shfrmManagement.actionsEmpty=No action(s) added yet + + # # Super Admin marloSLOs.sloTitle=System Level Outcomes diff --git a/marlo-web/src/main/resources/struts-admin.xml b/marlo-web/src/main/resources/struts-admin.xml index 55ffc0b0e6..497320f75d 100644 --- a/marlo-web/src/main/resources/struts-admin.xml +++ b/marlo-web/src/main/resources/struts-admin.xml @@ -109,6 +109,19 @@ ${phaseID} + + + + + /WEB-INF/crp/views/admin/shfrmManagement.ftl + + + ${crpSession}/shfrmManagement + true + ${phaseID} + + diff --git a/marlo-web/src/main/resources/struts-json.xml b/marlo-web/src/main/resources/struts-json.xml index f9185d2681..4f8ff1bead 100644 --- a/marlo-web/src/main/resources/struts-json.xml +++ b/marlo-web/src/main/resources/struts-json.xml @@ -444,6 +444,14 @@ true + + + + true + true + + diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl index 7994295d8f..bc8380203e 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/macros/relationsPopupMacro.ftl @@ -2,29 +2,48 @@ [#macro relationsMacro element labelText=true tag=""] [#local className = ((element.class.name)?split('.')?last)!''/] [#local composedID = "${className}-${(element.id)!}"] + [#-- [#local deliverablesProject = (action.getDeliverableRelationsProject(element.id, element.class.name,(element.project.id)!-1))! /] [#local deliverablesImpact = (action.getDeliverableRelationsImpact(element.id, element.class.name))! /] [#local deliverablesPartner = (action.getDeliverablesLedByPartner(element.id))! /] - - [#if className == "ProjectPartner"] - [#local deliverables = deliverablesPartner /] - [#elseif ((className == "ProjectOutcome") && (tag == "")) || (className == "ProjectBudget")] - [#local deliverables = deliverablesProject /] + --] + + [#if tag == "shfrm"] + [#local shfrmDeliverables = (action.getShfrmActionDeliverablesRelation(element.id))! /] + [#local deliverables = (shfrmDeliverables)![] /] [#else] - [#local deliverables = ((deliverablesImpact)!deliverablesPartner)! /] + + [#if className == "ProjectPartner"] + [#local deliverablesPartner = (action.getDeliverablesLedByPartner(element.id))! /] + [#local deliverables = deliverablesPartner /] + [#elseif ((className == "ProjectOutcome") && (tag == "")) || (className == "ProjectBudget")] + [#local deliverablesProject = (action.getDeliverableRelationsProject(element.id, element.class.name,(element.project.id)!-1))! /] + [#local deliverables = deliverablesProject /] + [#else] + [#local deliverablesImpact = (action.getDeliverableRelationsImpact(element.id, element.class.name))! /] + [#local deliverablesPartner = (action.getDeliverablesLedByPartner(element.id))! /] + [#local deliverables = ((deliverablesImpact)!deliverablesPartner)! /] + [/#if] + [/#if] + [#local projects = (action.getProjectRelationsImpact(element.id, element.class.name))! /] [#-- News buttons --] - [#local policies = (action.getPolicyContributingByPartner(element.id))![] /] - [#local innovations = (action.getInnovationContributingByPartner(element.id))![] /] - [#local evidencies = (action.getStudyContributingByPartner(element.id))![] /] + [#if !action.isAiccra()] + [#local policies = (action.getPolicyContributingByPartner(element.id))![] /] + [/#if] [#if tag == "expectedOutcomes"] [#local evidencies = (action.getexpectedCrpOutcomes(element.id))![] /] + [#else] + [#local evidencies = (action.getStudyContributingByPartner(element.id))![] /] [/#if] + [#if tag == "innovationOutcomes"] [#local innovations = (action.getInnovationProjectOutcomes(element.id))![] /] + [#else] + [#local innovations = (action.getInnovationContributingByPartner(element.id))![] /] [/#if] [#-- News buttons --] @@ -137,9 +156,13 @@ [@s.text name="projectsList.projectids" /] [@s.text name="project.deliverableList.deliverableName" /] - [@s.text name="project.deliverableList.subtype" /] - [@s.text name="project.deliverableList.owner" /] - [@s.text name="project.deliverableList.sharedW" /] + + [#if tag != "shfrm"] + [@s.text name="project.deliverableList.subtype" /] + [@s.text name="project.deliverableList.owner" /] + [@s.text name="project.deliverableList.sharedW" /] + [/#if] + [@s.text name="project.deliverableList.status" /] [@s.text name="project.deliverableList.year" /] @@ -160,10 +183,14 @@ [#else] ${(d.deliverableInfo.title)!'Untitled'} [/#if] - - ${(d.deliverableInfo.deliverableType.name?capitalize)!'-'} - ${(d.owner)!'-'} - ${(d.sharedWithProjects)!'-'} + + + [#if tag != "shfrm"] + ${(d.deliverableInfo.deliverableType.name?capitalize)!'-'} + ${(d.owner)!'-'} + ${(d.sharedWithProjects)!'-'} + [/#if] + ${(d.deliverableInfo.getStatusName(action.getActualPhase()))!'None'} [#-- Deliverable Year --] diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl index e37d9786ee..5609d35731 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/menu-admin.ftl @@ -15,6 +15,41 @@ { 'slug': 'crpPhases', 'name': 'CRPAdmin.menu.crpPhases', 'action': 'crpPhases', 'active': true } ]/] +[#if !action.isAiccra()] + [#assign items= [ + { 'slug': 'management', 'name': 'CRPAdmin.menu.hrefProgramManagement', 'action': 'management', 'active': true }, + { 'slug': 'regionalMapping', 'name': 'CRPAdmin.menu.hrefRegionalMapping', 'action': 'regionalMapping', 'active': action.hasProgramnsRegions() }, + { 'slug': 'siteIntegration', 'name': 'CRPAdmin.menu.hrefSiteIntegration', 'action': 'siteIntegration', 'active': true }, + { 'slug': 'ppaPartners', 'name': 'CRPAdmin.menu.hrefPPAPartners', 'action': 'ppaPartners', 'active': true }, + { 'slug': 'activities', 'name': 'CRPAdmin.menu.activities', 'action': 'activityManager', 'active': true }, + { 'slug': 'locations', 'name': 'CRPAdmin.menu.hrefLocations', 'action': 'locations', 'active': true }, + [#-- --{ 'slug': 'projectPhases', 'name': 'CRPAdmin.menu.hrefProjectPhases', 'action': 'projectPhases', 'active': false },--] + { 'slug': 'users', 'name': 'CRPAdmin.menu.users', 'action': 'crpUsers', 'active': true }, + { 'slug': 'deliverables', 'name': 'CRPAdmin.menu.deliverables', 'action': 'crpDeliverables', 'active': true }, + [#-- { 'slug': 'guestUsers', 'name': 'CRPAdmin.menu.guestUsers', 'action': 'guestUser', 'active': !config.production }, --] + { 'slug': 'targetUnits', 'name': 'CRPAdmin.menu.hrefTargetUnits', 'action': 'targetUnits', 'active': true }, + { 'slug': 'institutions', 'name': 'menu.superadmin.institutions', 'action': 'marloInstitutions', 'active': true }, + { 'slug': 'crpPhases', 'name': 'CRPAdmin.menu.crpPhases', 'action': 'crpPhases', 'active': true } + ]/] +[#else] + [#assign items= [ + { 'slug': 'management', 'name': 'CRPAdmin.menu.hrefProgramManagement', 'action': 'management', 'active': true }, + { 'slug': 'regionalMapping', 'name': 'CRPAdmin.menu.hrefRegionalMapping', 'action': 'regionalMapping', 'active': action.hasProgramnsRegions() }, + { 'slug': 'siteIntegration', 'name': 'CRPAdmin.menu.hrefSiteIntegration', 'action': 'siteIntegration', 'active': true }, + { 'slug': 'ppaPartners', 'name': 'CRPAdmin.menu.hrefPPAPartners', 'action': 'ppaPartners', 'active': true }, + { 'slug': 'activities', 'name': 'CRPAdmin.menu.activities', 'action': 'activityManager', 'active': true }, + { 'slug': 'locations', 'name': 'CRPAdmin.menu.hrefLocations', 'action': 'locations', 'active': true }, + [#-- --{ 'slug': 'projectPhases', 'name': 'CRPAdmin.menu.hrefProjectPhases', 'action': 'projectPhases', 'active': false },--] + { 'slug': 'users', 'name': 'CRPAdmin.menu.users', 'action': 'crpUsers', 'active': true }, + { 'slug': 'deliverables', 'name': 'CRPAdmin.menu.deliverables', 'action': 'crpDeliverables', 'active': true }, + [#-- { 'slug': 'guestUsers', 'name': 'CRPAdmin.menu.guestUsers', 'action': 'guestUser', 'active': !config.production }, --] + { 'slug': 'targetUnits', 'name': 'CRPAdmin.menu.hrefTargetUnits', 'action': 'targetUnits', 'active': true }, + <#-- { 'slug': 'institutions', 'name': 'menu.superadmin.institutions', 'action': 'marloInstitutions', 'active': true }, --> + { 'slug': 'crpPhases', 'name': 'CRPAdmin.menu.crpPhases', 'action': 'crpPhases', 'active': true }, + { 'slug': 'shfrmManagement', 'name': 'CRPAdmin.menu.shfrmManagement', 'action': 'shfrmManagement', 'active': action.isShfrmSpecificityActive()} + ]/] +[/#if] +