Skip to content

Commit

Permalink
🔧 chore(validators): Update check button validators
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Oct 9, 2024
1 parent 665ae89 commit e65b2af
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ public class CrpProgramOutcome extends MarloAuditableEntity implements java.io.S
private Integer year;
@Expose
private FileDB file;


@Expose
private Integer orderIndex;
@Expose
private Integer afPhase;
@Expose
private BigDecimal value;

Expand Down Expand Up @@ -160,6 +162,11 @@ public String getAcronym() {
}


public Integer getAfPhase() {
return afPhase;
}


public String getComposedName() {
if (this.getCrpProgram() != null && this.getCrpProgram().getAcronym() != null && description != null) {
return this.getCrpProgram().getAcronym() + " Outcome: " + description;
Expand All @@ -168,7 +175,6 @@ public String getComposedName() {
}
}


public String getComposeID() {
if (composeID != null) {
return composeID;
Expand All @@ -192,7 +198,6 @@ public Set<CrpOutcomeSubIdo> getCrpOutcomeSubIdos() {
return this.crpOutcomeSubIdos;
}


public CrpProgram getCrpProgram() {
return this.crpProgram;
}
Expand All @@ -201,7 +206,6 @@ public Set<CrpProgramOutcomeIndicator> getCrpProgramOutcomeIndicators() {
return crpProgramOutcomeIndicators;
}


public Set<Deliverable> getDeliverables() {
return deliverables;
}
Expand Down Expand Up @@ -237,6 +241,9 @@ public List<CrpMilestone> getMilestones() {
return milestones;
}

public Integer getOrderIndex() {
return orderIndex;
}

public String getPAcronym() {
return this.getCrpProgram().getAcronym();
Expand Down Expand Up @@ -274,16 +281,18 @@ public void setAcronym(String acronym) {
this.acronym = acronym;
}

public void setAfPhase(Integer afPhase) {
this.afPhase = afPhase;
}

public void setComposeID(String composeID) {
this.composeID = composeID;
}


public void setCrpClusterKeyOutputOutcomes(Set<CrpClusterKeyOutputOutcome> crpClusterKeyOutputOutcomes) {
this.crpClusterKeyOutputOutcomes = crpClusterKeyOutputOutcomes;
}


public void setCrpMilestones(Set<CrpMilestone> crpMilestones) {
this.crpMilestones = crpMilestones;
}
Expand Down Expand Up @@ -328,6 +337,10 @@ public void setMilestones(List<CrpMilestone> milestones) {
this.milestones = milestones;
}

public void setOrderIndex(Integer orderIndex) {
this.orderIndex = orderIndex;
}

public void setPhase(Phase phase) {
this.phase = phase;
}
Expand Down
6 changes: 6 additions & 0 deletions marlo-data/src/main/resources/xmls/CrpProgramOutcomes.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
<property name="year" type="java.lang.Integer">
<column name="year" not-null="false" />
</property>
<property name="orderIndex" type="java.lang.Integer">
<column name="order_index" not-null="false" />
</property>
<property name="afPhase" type="java.lang.Integer">
<column name="af_phase" not-null="false" />
</property>
<property name="value" type="java.math.BigDecimal">
<column name="value" precision="20" not-null="false" />
</property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,17 @@ public String execute() throws Exception {
break;
case PARTNERS:
this.projectSectionValidator.validateProjectParnters(this, this.getProjectID(), this.loggedCrp);
/*
* case BUDGET:
* if (this.isPlanningActive() || ((this.isReportingActive() || this.isUpKeepActive())
* && this.hasSpecificities(this.getCrpEnableBudgetExecution()))) {
* this.projectSectionValidator.validateProjectBudgets(this, this.getProjectID());
* }
* break;
* case BUDGETBYFLAGSHIP:
* this.projectSectionValidator.validateProjectBudgetsFlagship(this, this.getProjectID(), true);
* break;
*/

case BUDGET:
if (this.isPlanningActive() || ((this.isReportingActive() || this.isUpKeepActive())
&& this.hasSpecificities(this.getCrpEnableBudgetExecution()))) {
this.projectSectionValidator.validateProjectBudgets(this, this.getProjectID());
}
break;
case BUDGETBYFLAGSHIP:
this.projectSectionValidator.validateProjectBudgetsFlagship(this, this.getProjectID(), true);
break;

case DELIVERABLES:
this.projectSectionValidator.validateProjectDeliverables(this, this.getProjectID());
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import org.cgiar.ccafs.marlo.data.model.DeliverableLocation;
import org.cgiar.ccafs.marlo.data.model.DeliverableParticipant;
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.DeliverableUserPartnership;
import org.cgiar.ccafs.marlo.data.model.DeliverableUserPartnershipPerson;
import org.cgiar.ccafs.marlo.data.model.ExpectedStudyProject;
Expand Down Expand Up @@ -108,6 +110,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -937,10 +940,11 @@ public void validateProjectBudgetsFlagship(BaseAction action, Long projectID, bo
Project project = projectManager.getProjectById(projectID);
project.setBudgetsFlagship(project.getProjectBudgetsFlagships().stream()
.filter(c -> c.isActive() && c.getPhase().equals(action.getActualPhase())).collect(Collectors.toList()));
if (!(project.getProjectBudgetsFlagships().isEmpty() || project.getProjectBudgetsFlagships().size() == 1)) {
projectBudgetsFlagshipValidator.validate(action, project, false, sMessage);
}

/*
* if (!(project.getProjectBudgetsFlagships().isEmpty() || project.getProjectBudgetsFlagships().size() == 1)) {
* }
*/
projectBudgetsFlagshipValidator.validate(action, project, false, sMessage);
}


Expand Down Expand Up @@ -1184,6 +1188,32 @@ public void validateProjectDeliverables(BaseAction action, Long projectID) {
deliverable.setCrossCuttingMarkers(deliverableCrossCuttingMarkers);
}

// Soil information
if (deliverable.getDeliverableShfrmPriorityAction() != null) {
deliverable.setShfrmPriorityActions(new ArrayList<>(deliverable.getDeliverableShfrmPriorityAction().stream()
.filter(o -> o.isActive() && o.getPhase().getId().equals(action.getActualPhase().getId()))
.sorted(Comparator.comparing(DeliverableShfrmPriorityAction::getId)).collect(Collectors.toList())));
}

if (deliverable.getShfrmPriorityActions() != null && !deliverable.getShfrmPriorityActions().isEmpty()) {
for (DeliverableShfrmPriorityAction deliverablePriorityAction : deliverable.getShfrmPriorityActions()) {
try {

if (deliverablePriorityAction.getDeliverableShfrmSubAction() != null) {
deliverablePriorityAction
.setShfrmSubActions(new ArrayList<>(deliverablePriorityAction.getDeliverableShfrmSubAction().stream()
.filter(o -> o.isActive() && o.getPhase().getId().equals(action.getActualPhase().getId()))
.sorted(Comparator.comparing(DeliverableShfrmSubAction::getId)).collect(Collectors.toList())));
}

} catch (Exception e) {
logger.error("unable to get deliverableSubActions for deliverablePriorityAction: {}",
deliverablePriorityAction, e);
}
}
}


if (action.isReportingActive() || action.isUpKeepActive()) {

DeliverableQualityCheck deliverableQualityCheck =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE crp_program_outcomes ADD order_index int(10) NULL;
ALTER TABLE crp_program_outcomes ADD af_phase int(10) NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
},
{ 'title': 'Budget', 'show': true,
'items': [
{ 'slug': 'budgetByPartners', 'name': 'projects.menu.budgetByPartners', 'action': 'budgetByPartners', 'active': true, 'show':true, "showCheck": isGlobalUnitProject },
{ 'slug': 'budgetByFlagships', 'name': 'projects.menu.budgetByFlagships', 'action': 'budgetByFlagship', 'active': true, 'show': action.getCountProjectFlagships(project.id) && !reportingActive && isCrpProject, "showCheck": isGlobalUnitProject},
{ 'slug': 'budgetByPartners', 'name': 'projects.menu.budgetByPartners', 'action': 'budgetByPartners', 'active': true, 'show':true, "showCheck": false },
{ 'slug': 'budgetByFlagships', 'name': 'projects.menu.budgetByFlagships', 'action': 'budgetByFlagship', 'active': true, 'show': action.getCountProjectFlagships(project.id) && !reportingActive && isCrpProject, "showCheck": false},
{ 'slug': 'leverages', 'name': 'Leverages', 'action': 'leverages', 'active': true, 'show': reportingActive && action.hasSpecificities("crp_leverages_module") && isCrpProject, "showCheck": isGlobalUnitProject}
]
},
Expand Down

0 comments on commit e65b2af

Please sign in to comment.