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 index 59e77d918d..76f4292b05 100644 --- 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 @@ -57,6 +57,9 @@ public interface DeliverableShfrmPriorityActionDAO { public List findByDeliverableAndPhase(long deliverableId, long phaseId); + public List findByDeliverablePriorityActionAndPhase(long deliverableId, + long priorityActionId, long phaseId); + /** * This method saves the information of the given deliverableShfrmPriorityAction 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 index b9f8064b03..a84e0d6020 100644 --- 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 @@ -85,6 +85,18 @@ public List findByDeliverableAndPhase(long deliv return null; } + @Override + public List findByDeliverablePriorityActionAndPhase(long deliverableId, + long priorityActionId, long phaseId) { + String query = "from " + DeliverableShfrmPriorityAction.class.getName() + " where is_active=1 and deliverable_id=" + + deliverableId + " and shfrm_priority_action_id=" + priorityActionId + " 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) { 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 index 217e982ac2..1b15093969 100644 --- 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 @@ -53,6 +53,9 @@ public interface DeliverableShfrmPriorityActionManager { public List findByDeliverableAndPhase(long deliverableId, long phaseId); + public List findByDeliverablePriorityActionAndPhase(long deliverableId, + long priorityActionId, long phaseId); + /** * This method gets a deliverableShfrmPriorityAction object by a given deliverableShfrmPriorityAction identifier. 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 index b3147077b7..a46fc66a06 100644 --- 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 @@ -109,6 +109,15 @@ public List findByDeliverableAndPhase(long deliv } + @Override + public List findByDeliverablePriorityActionAndPhase(long deliverableId, + long priorityActionId, long phaseId) { + return deliverableShfrmPriorityActionDAO.findByDeliverablePriorityActionAndPhase(deliverableId, priorityActionId, + phaseId); + + } + + @Override public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityActionById(long deliverableShfrmPriorityActionID) { @@ -134,7 +143,7 @@ public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityActionById(long public void saveDeliverableShfrmPriorityActionPhase(Phase next, long deliverableId, DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) { Phase phase = phaseDAO.find(next.getId()); - DeliverableShfrmPriorityAction deliverableShfrmPriorityActionPhase = new DeliverableShfrmPriorityAction(); + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionPhase = null; try { deliverableShfrmPriorityActionPhase = deliverableShfrmPriorityActionDAO .findByDeliverableAndPhase(deliverableId, phase.getId()).stream() 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 index 4811696bd4..3ac04b5666 100644 --- 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 @@ -15,9 +15,11 @@ package org.cgiar.ccafs.marlo.data.manager.impl; +import org.cgiar.ccafs.marlo.data.dao.DeliverableShfrmPriorityActionDAO; 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.DeliverableShfrmPriorityAction; import org.cgiar.ccafs.marlo.data.model.DeliverableShfrmSubAction; import org.cgiar.ccafs.marlo.data.model.Phase; @@ -39,12 +41,14 @@ public class DeliverableShfrmSubActionManagerImpl implements DeliverableShfrmSub // Managers private DeliverableShfrmSubActionDAO deliverableShfrmSubActionDAO; + private DeliverableShfrmPriorityActionDAO deliverableShfrmPriorityActionDAO; private PhaseDAO phaseDAO; @Inject public DeliverableShfrmSubActionManagerImpl(DeliverableShfrmSubActionDAO deliverableShfrmSubActionDAO, - PhaseDAO phaseDAO) { + PhaseDAO phaseDAO, DeliverableShfrmPriorityActionDAO deliverableShfrmPriorityActionDAO) { this.deliverableShfrmSubActionDAO = deliverableShfrmSubActionDAO; + this.deliverableShfrmPriorityActionDAO = deliverableShfrmPriorityActionDAO; this.phaseDAO = phaseDAO; } @@ -65,12 +69,15 @@ public void deleteDeliverableShfrmSubAction(long deliverableShfrmSubActionId) { public void deleteDeliverableShfrmSubActionPhase(Phase next, DeliverableShfrmSubAction deliverableShfrmSubAction) { Phase phase = phaseDAO.find(next.getId()); + DeliverableShfrmPriorityAction deliverablePriorityActionPhase = + this.findDeliverablePriorityActionByDeliverablePriorityActionAndPhase(deliverableShfrmSubAction, phase); DeliverableShfrmSubAction deliverableShfrmSubActionDelete = new DeliverableShfrmSubAction(); - deliverableShfrmSubActionDelete = deliverableShfrmSubActionDAO - .findByPriorityActionPhaseAndSubAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), - phase.getId(), deliverableShfrmSubAction.getShfrmSubAction().getId()) - .get(0); + if (deliverablePriorityActionPhase != null && deliverablePriorityActionPhase.getId() != null) { + deliverableShfrmSubActionDelete = + deliverableShfrmSubActionDAO.findByPriorityActionPhaseAndSubAction(deliverablePriorityActionPhase.getId(), + phase.getId(), deliverableShfrmSubAction.getShfrmSubAction().getId()).get(0); + } if (deliverableShfrmSubActionDelete != null) { deliverableShfrmSubActionDAO.deleteDeliverableShfrmSubAction(deliverableShfrmSubActionDelete.getId()); } @@ -106,6 +113,27 @@ public List findByPriorityActionPhaseAndSubAction(lon shfrmSubActionId); } + public DeliverableShfrmPriorityAction findDeliverablePriorityActionByDeliverablePriorityActionAndPhase( + DeliverableShfrmSubAction deliverableShfrmSubAction, Phase phase) { + DeliverableShfrmPriorityAction deliverableshfrmPriorityActionPhase = null; + try { + if (phase != null && phase.getId() != null && deliverableShfrmSubAction != null + && deliverableShfrmSubAction.getDeliverableShfrmPriorityAction() != null + && deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getShfrmPriorityAction() != null + && deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getShfrmPriorityAction().getId() != null + && deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getDeliverable() != null + && deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getDeliverable().getId() != null) { + deliverableshfrmPriorityActionPhase = deliverableShfrmPriorityActionDAO.findByDeliverablePriorityActionAndPhase( + deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getDeliverable().getId(), + deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getShfrmPriorityAction().getId(), phase.getId()) + .get(0); + } + } catch (Exception e) { + logger.error("error getting deliverableShfrmPriorityActionPhase in subActionsavePhase: " + e); + } + return deliverableshfrmPriorityActionPhase; + } + @Override public DeliverableShfrmSubAction getDeliverableShfrmSubActionById(long deliverableShfrmSubActionID) { @@ -129,31 +157,43 @@ public DeliverableShfrmSubAction saveDeliverableShfrmSubAction(DeliverableShfrmS public void saveDeliverableShfrmSubActionPhase(Phase next, DeliverableShfrmSubAction deliverableShfrmSubAction) { Phase phase = phaseDAO.find(next.getId()); DeliverableShfrmSubAction deliverableShfrmSubActionPhase = new DeliverableShfrmSubAction(); + + + // get priority action + DeliverableShfrmPriorityAction deliverableShfrmPriorityActionPhase = null; try { - deliverableShfrmSubActionPhase = deliverableShfrmSubActionDAO - .findByPriorityActionPhaseAndSubAction(deliverableShfrmSubAction.getDeliverableShfrmPriorityAction().getId(), - phase.getId(), deliverableShfrmSubAction.getShfrmSubAction().getId()) - .get(0); + deliverableShfrmPriorityActionPhase = + this.findDeliverablePriorityActionByDeliverablePriorityActionAndPhase(deliverableShfrmSubAction, phase); } catch (Exception e) { - logger.error("error getting deliverableShfrmSubActionPhase: " + e); + logger.error("error getting deliverable priority action " + 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); + try { + if (deliverableShfrmPriorityActionPhase != null && deliverableShfrmPriorityActionPhase.getId() != null) { + deliverableShfrmSubActionPhase = deliverableShfrmSubActionDAO + .findByPriorityActionPhaseAndSubAction(deliverableShfrmPriorityActionPhase.getId(), phase.getId(), + deliverableShfrmSubAction.getShfrmSubAction().getId()) + .get(0); + } + } catch (Exception e) { + logger.error("error getting deliverableShfrmSubActionPhase: " + e); } + if (deliverableShfrmPriorityActionPhase != null) { + if (deliverableShfrmSubActionPhase != null) { + DeliverableShfrmSubAction deliverableShfrmSubActionAdd = deliverableShfrmSubActionPhase; + deliverableShfrmSubActionAdd.setPhase(phase); + deliverableShfrmSubActionAdd.setShfrmSubAction(deliverableShfrmSubAction.getShfrmSubAction()); + deliverableShfrmSubActionAdd.setDeliverableShfrmPriorityAction(deliverableShfrmPriorityActionPhase); + deliverableShfrmSubActionDAO.save(deliverableShfrmSubActionAdd); + } else { + DeliverableShfrmSubAction deliverableShfrmSubActionAdd = new DeliverableShfrmSubAction(); + deliverableShfrmSubActionAdd.setPhase(phase); + deliverableShfrmSubActionAdd.setShfrmSubAction(deliverableShfrmSubAction.getShfrmSubAction()); + deliverableShfrmSubActionAdd.setDeliverableShfrmPriorityAction(deliverableShfrmPriorityActionPhase); + 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/model/DeliverableInfo.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/DeliverableInfo.java index 3bb1db091c..aaca7bf79c 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 @@ -51,6 +51,8 @@ public class DeliverableInfo extends MarloAuditableEntity implements java.io.Ser private Boolean contributingShfrm; @Expose private String shfrmContributionNarrative; + @Expose + private String shfrmContributionNarrativeAR; public DeliverableInfo() { } @@ -125,6 +127,10 @@ public String getShfrmContributionNarrative() { return shfrmContributionNarrative; } + public String getShfrmContributionNarrativeAR() { + return shfrmContributionNarrativeAR; + } + public Integer getStatus() { return status; } @@ -191,6 +197,7 @@ public Boolean isCompleted() { return false; } + /** * Check if the deliverables is from a previous year for the current cycle * Used in Project.getCurrentDeliverables and Project.getPreviousDeliverables to generate the deliverable list and; @@ -371,25 +378,24 @@ public boolean requeriedFair() { return false; } - 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; } - public void setDeliverable(Deliverable deliverable) { this.deliverable = deliverable; } @@ -434,6 +440,10 @@ public void setShfrmContributionNarrative(String shfrmContributionNarrative) { this.shfrmContributionNarrative = shfrmContributionNarrative; } + public void setShfrmContributionNarrativeAR(String shfrmContributionNarrativeAR) { + this.shfrmContributionNarrativeAR = shfrmContributionNarrativeAR; + } + public void setStatus(Integer status) { this.status = status; } @@ -471,6 +481,7 @@ public void updateDeliverableInfo(DeliverableInfo update) { this.setRegion(update.getRegion()); this.setContributingShfrm(update.getContributingShfrm()); this.setShfrmContributionNarrative(update.getShfrmContributionNarrative()); + this.setShfrmContributionNarrativeAR(update.getShfrmContributionNarrativeAR()); } } diff --git a/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml b/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml index abcc2c7770..98a8a0cb5d 100644 --- a/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml +++ b/marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml @@ -84,6 +84,9 @@ + + + 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 index 8072c56966..7ef57cccb7 100644 --- 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 @@ -29,6 +29,7 @@ import javax.inject.Inject; +import org.jfree.util.Log; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -310,8 +311,11 @@ public void setPriorityActions(List priorityActions) { @Override public void validate() { - if (save) { - // validator.validate(this, feedbackFields); + try { + if (save) { + } + } catch (Exception e) { + Log.error("validating error " + e); } } } \ No newline at end of file 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 9154250aae..62b1d13d3a 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 @@ -315,7 +315,6 @@ public class DeliverableAction extends BaseAction { private String disseminationURL; private String soilIndicatorsText; - private List focusLevels; // HJ 08/01/2019 new fileds Deliverable Partnerships private List partnerInstitutions; @@ -811,6 +810,7 @@ public long getActualClusterParticipantID() { } } + public List getAnswers() { return answers; } @@ -820,7 +820,6 @@ public List getAnswersDataDic() { return answersDataDic; } - private Path getAutoSaveFilePath() { // get the class simple name @@ -962,6 +961,7 @@ public List getMyProjects() { return myProjects; } + public List getPartnerInstitutions() { return partnerInstitutions; } @@ -971,7 +971,6 @@ public List getPartnerPersons() { return partnerPersons; } - public List getPartners() { return partners; } @@ -1242,6 +1241,43 @@ public boolean isPPA(Institution institution) { return false; } + public boolean isSoilIndicatorSelected() { + boolean containsIndicator = false; + + try { + 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 (indicator != null && indicator.getCrpProgramOutcome() != null + && indicator.getCrpProgramOutcome().getId() != null) { + try { + CrpProgramOutcome outcome = + crpProgramOutcomeManager.getCrpProgramOutcomeById(indicator.getCrpProgramOutcome().getId()); + if (outcome != null && outcome.getAcronym() != null) { + indicator.getCrpProgramOutcome().setAcronym(outcome.getAcronym()); + } + } catch (Exception e) { + Log.error("error getting crp program outcome " + e); + } + } + if (soilIndicator != null && soilIndicator.getIndicatorName() != null && indicator != null + && indicator.getCrpProgramOutcome() != null && indicator.getCrpProgramOutcome().getAcronym() != null + && indicator.getCrpProgramOutcome().getAcronym().contains(soilIndicator.getIndicatorName())) { + containsIndicator = true; + } + } + } + } + } + } catch (Exception e) { + Log.error("error validating soil indicator boolean " + e); + } + return containsIndicator; + } + @Override public void prepare() throws Exception { existCurrentCluster = false; @@ -4164,17 +4200,15 @@ public void saveSubActions() { } } 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()); - * } - * } - * } - * } - */ + + if (subPrev != null && !subPrev.isEmpty()) { + for (DeliverableShfrmSubAction subAction : subPrev) { + if (subAction != null && subAction.getId() != null) { + deliverableShfrmSubActionManager.deleteDeliverableShfrmSubAction(subAction.getId()); + } + } + } + } /***************/ @@ -4203,6 +4237,9 @@ public void saveSubActions() { // For new deliverable Priority Actions if (deliverableSubAction.getId() == null || deliverableSubAction.getId() == -1) { deliverableSubActionSave.setId(null); + if (deliverablePriorityAction.getDeliverable() == null) { + deliverablePriorityAction.setDeliverable(deliverable); + } deliverableSubActionSave.setDeliverableShfrmPriorityAction(deliverablePriorityAction); deliverableSubActionSave.setPhase(this.getActualPhase()); deliverableSubActionSave.setShfrmSubAction(subAction); @@ -4214,6 +4251,9 @@ public void saveSubActions() { deliverableSubActionSave = deliverableShfrmSubActionManager.getDeliverableShfrmSubActionById(deliverableSubAction.getId()); if (deliverableSubActionSave != null) { + if (deliverablePriorityAction.getDeliverable() == null) { + deliverablePriorityAction.setDeliverable(deliverable); + } deliverableSubActionSave.setDeliverableShfrmPriorityAction(deliverablePriorityAction); deliverableSubActionSave.setPhase(this.getActualPhase()); deliverableSubActionSave.setShfrmSubAction(subAction); 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 0683f9cc44..1ff5a31930 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 @@ -567,7 +567,8 @@ public void validate(BaseAction action, Deliverable deliverable, boolean saving) } if (soilIndicator != null && soilIndicator.getIndicatorName() != null && indicator != null && indicator.getCrpProgramOutcome() != null && indicator.getCrpProgramOutcome().getAcronym() != null - && indicator.getCrpProgramOutcome().getAcronym().contains(soilIndicator.getIndicatorName())) { + && indicator.getCrpProgramOutcome().getAcronym().trim() + .contains(soilIndicator.getIndicatorName().trim())) { containsIndicator = true; } } @@ -583,14 +584,26 @@ public void validate(BaseAction action, Deliverable deliverable, boolean saving) } // 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); + if (action.isReportingActive()) { + if (!(this + .isValidString(deliverable.getDeliverableInfo(action.getActualPhase()).getShfrmContributionNarrativeAR()) + && this.wordCount( + deliverable.getDeliverableInfo(action.getActualPhase()).getShfrmContributionNarrativeAR()) <= 200)) { + action.addMessage(action.getText("deliverable.deliverableInfo.shfrmContributionNarrativeAR")); + action.addMissingField("deliverable.deliverableInfo.shfrmContributionNarrativeAR"); + action.getInvalidFields().put("input-deliverable.deliverableInfo.shfrmContributionNarrativeAR", + InvalidFieldsMessages.EMPTYFIELD); + } + } else { + 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 @@ -601,22 +614,24 @@ public void validate(BaseAction action, Deliverable deliverable, boolean saving) action.getInvalidFields().put("list-deliverable.shfrmPriorityActions", InvalidFieldsMessages.EMPTYFIELD); } else if (deliverable.getShfrmPriorityActions() != null && !deliverable.getShfrmPriorityActions().isEmpty()) { - int indexJ = 0; + int indexI = 0; for (DeliverableShfrmPriorityAction priorityAction : deliverable.getShfrmPriorityActions()) { if (priorityAction != null && priorityAction.getShfrmSubActions() == null || (priorityAction != null && priorityAction.getShfrmSubActions() != null && priorityAction.getShfrmSubActions().isEmpty())) { action.addMessage(action.getText("deliverable.shfrmSubActions")); - action.addMissingField("deliverable.shfrmPriorityActions"); + action.addMissingField("deliverable.shfrmSubActions"); + action.getInvalidFields().put("list-deliverable.shfrmPriorityActions", + InvalidFieldsMessages.EMPTYFIELD); 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", + * action.addMessage(action.getText("deliverable.shfrmSubActions[" + indexI + "]")); + * action.addMissingField("deliverable.shfrmSubActions[" + indexI + "]"); + * action.getInvalidFields().put("list-deliverable.shfrmPriorityAction[" + indexI + "].shfrmSubActions", * InvalidFieldsMessages.EMPTYFIELD); */ - indexJ++; + indexI++; } } } diff --git a/marlo-web/src/main/resources/custom/aicrra.properties b/marlo-web/src/main/resources/custom/aicrra.properties index 65de7a122e..8781fb8e93 100644 --- a/marlo-web/src/main/resources/custom/aicrra.properties +++ b/marlo-web/src/main/resources/custom/aicrra.properties @@ -952,6 +952,8 @@ 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) deliverable.shfrmContribution.indicators.help=Soil Indicator(s): +deliverable.shfrmContribution.narrative.reporting.readText=How this deliverable is expecting to contribute to SHFRM +deliverable.shfrmContribution.narrative.planning.readText=How this deliverable is planning to contribute to SHFRM intellectualAsset.fillingType=Type of filling intellectualAsset.patentStatus=Patent status diff --git a/marlo-web/src/main/resources/database/migrations/V2_6_0_20240221_1420__CreateContributionARColumn.sql b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240221_1420__CreateContributionARColumn.sql new file mode 100644 index 0000000000..4c0619b04f --- /dev/null +++ b/marlo-web/src/main/resources/database/migrations/V2_6_0_20240221_1420__CreateContributionARColumn.sql @@ -0,0 +1 @@ +ALTER TABLE deliverables_info ADD shfrm_contribution_narrative_ar text NULL; diff --git a/marlo-web/src/main/resources/global.properties b/marlo-web/src/main/resources/global.properties index edbb641263..828eabb345 100644 --- a/marlo-web/src/main/resources/global.properties +++ b/marlo-web/src/main/resources/global.properties @@ -953,6 +953,8 @@ 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) deliverable.shfrmContribution.indicators.help=Soil Indicator(s): +deliverable.shfrmContribution.narrative.reporting.readText=How this deliverable is expecting to contribute to SHFRM +deliverable.shfrmContribution.narrative.planning.readText=How this deliverable is planning to contribute to SHFRM intellectualAsset.fillingType=Type of filling intellectualAsset.patentStatus=Patent status diff --git a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl index 20e9c6158d..e6c07ab4cd 100644 --- a/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/crp/views/admin/shfrmManagement.ftl @@ -149,12 +149,12 @@
- [@customForm.input name="${name}.name" i18nkey="shfrmManagement.priorityActions.title" className="name limitWords-100" required=true /] + [@customForm.input name="${name}.name" i18nkey="shfrmManagement.priorityActions.title" className="name" required=true /]
[#-- Action description --]
- [@customForm.input name="${name}.description" i18nkey="shfrmManagement.priorityActions.description" className="description limitWords-100" required=true /] + [@customForm.input name="${name}.description" i18nkey="shfrmManagement.priorityActions.description" className="description" required=true /]
diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl index 58cf8b8725..54b052e100 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/deliverableMacros.ftl @@ -1529,8 +1529,14 @@ [#-- Shfrm Contribution Narrative --] [#if reportingActive] + [#-- Previous narrative --] + [#if deliverable.deliverableInfo.shfrmContributionNarrative?has_content] +
+ [@customForm.textArea name="deliverable.deliverableInfo.shfrmContributionNarrative" value="${(deliverable.deliverableInfo.shfrmContributionNarrative)!}" i18nkey="deliverable.shfrmContribution.narrative.reporting" placeholder="" className="limitWords-200" required=false editable=false /] +
+ [/#if]
- [@customForm.textArea name="deliverable.deliverableInfo.shfrmContributionNarrative" value="${(deliverable.deliverableInfo.shfrmContributionNarrative)!}" i18nkey="deliverable.shfrmContribution.narrative.reporting" placeholder="" className="limitWords-200" required=true editable=editable /] + [@customForm.textArea name="deliverable.deliverableInfo.shfrmContributionNarrativeAR" value="${(deliverable.deliverableInfo.shfrmContributionNarrativeAR)!}" i18nkey="deliverable.shfrmContribution.narrative.reporting" placeholder="" className="limitWords-200" required=true editable=editable /]
[#else]
diff --git a/marlo-web/src/main/webapp/WEB-INF/global/macros/homeDashboard.ftl b/marlo-web/src/main/webapp/WEB-INF/global/macros/homeDashboard.ftl index da3e851146..7096ad99cf 100644 --- a/marlo-web/src/main/webapp/WEB-INF/global/macros/homeDashboard.ftl +++ b/marlo-web/src/main/webapp/WEB-INF/global/macros/homeDashboard.ftl @@ -21,7 +21,7 @@ [#-- Has draft version (Auto-save) --] [#--assign hasDraft = (action.getAutoSaveFilePath(deliverable.class.simpleName, "deliverable", deliverable.id))!false /--] [#-- Is Complete --] - [#assign isDeliverableComplete = action.isDeliverableComplete(deliverable.deliverableId, actualPhase.id) /] + [#assign isDeliverableComplete = action.isDeliverableComplete(deliverable.deliverableId, actualPhase.id)!false /] [#-- To Report --] [#local toReport = reportingActive && !isDeliverableComplete ]