Skip to content

Commit

Permalink
Merge branch 'aiccra-shfrm-contribution-functionality' into aiccra-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Feb 22, 2024
2 parents eff771e + c9d48a8 commit 8ced36e
Show file tree
Hide file tree
Showing 16 changed files with 214 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public interface DeliverableShfrmPriorityActionDAO {

public List<DeliverableShfrmPriorityAction> findByDeliverableAndPhase(long deliverableId, long phaseId);

public List<DeliverableShfrmPriorityAction> findByDeliverablePriorityActionAndPhase(long deliverableId,
long priorityActionId, long phaseId);


/**
* This method saves the information of the given deliverableShfrmPriorityAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ public List<DeliverableShfrmPriorityAction> findByDeliverableAndPhase(long deliv
return null;
}

@Override
public List<DeliverableShfrmPriorityAction> 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<DeliverableShfrmPriorityAction> list = super.findAll(query);
if (list.size() > 0) {
return list;
}
return null;
}

@Override
public DeliverableShfrmPriorityAction save(DeliverableShfrmPriorityAction deliverableShfrmPriorityAction) {
if (deliverableShfrmPriorityAction.getId() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public interface DeliverableShfrmPriorityActionManager {

public List<DeliverableShfrmPriorityAction> findByDeliverableAndPhase(long deliverableId, long phaseId);

public List<DeliverableShfrmPriorityAction> findByDeliverablePriorityActionAndPhase(long deliverableId,
long priorityActionId, long phaseId);


/**
* This method gets a deliverableShfrmPriorityAction object by a given deliverableShfrmPriorityAction identifier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ public List<DeliverableShfrmPriorityAction> findByDeliverableAndPhase(long deliv

}

@Override
public List<DeliverableShfrmPriorityAction> findByDeliverablePriorityActionAndPhase(long deliverableId,
long priorityActionId, long phaseId) {
return deliverableShfrmPriorityActionDAO.findByDeliverablePriorityActionAndPhase(deliverableId, priorityActionId,
phaseId);

}


@Override
public DeliverableShfrmPriorityAction getDeliverableShfrmPriorityActionById(long deliverableShfrmPriorityActionID) {

Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

Expand All @@ -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());
}
Expand Down Expand Up @@ -106,6 +113,27 @@ public List<DeliverableShfrmSubAction> 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) {

Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand Down Expand Up @@ -125,6 +127,10 @@ public String getShfrmContributionNarrative() {
return shfrmContributionNarrative;
}

public String getShfrmContributionNarrativeAR() {
return shfrmContributionNarrativeAR;
}

public Integer getStatus() {
return status;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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());
}
}

3 changes: 3 additions & 0 deletions marlo-data/src/main/resources/xmls/DeliverablesInfo.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
<property name="contributingShfrm" type="java.lang.Boolean">
<column name="is_contributing_shfrm" />
</property>
<property name="shfrmContributionNarrativeAR" type="string">
<column name="shfrm_contribution_narrative_ar" sql-type="TEXT" />
</property>
<property name="shfrmContributionNarrative" type="string">
<column name="shfrm_contribution_narrative" sql-type="TEXT" />
</property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import javax.inject.Inject;

import org.jfree.util.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -310,8 +311,11 @@ public void setPriorityActions(List<ShfrmPriorityAction> priorityActions) {

@Override
public void validate() {
if (save) {
// validator.validate(this, feedbackFields);
try {
if (save) {
}
} catch (Exception e) {
Log.error("validating error " + e);
}
}
}
Loading

0 comments on commit 8ced36e

Please sign in to comment.