Skip to content

Commit

Permalink
Merge branch 'aiccra-deliverable-excel-improvements-A2-41' into aiccr…
Browse files Browse the repository at this point in the history
…a-dev
  • Loading branch information
kenjitm committed Apr 11, 2024
2 parents a4f5315 + 0586cd4 commit ce314c8
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.cgiar.ccafs.marlo.data.manager.DeliverableInfoManager;
import org.cgiar.ccafs.marlo.data.manager.DeliverableLocationManager;
import org.cgiar.ccafs.marlo.data.manager.DeliverableManager;
import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmPriorityActionManager;
import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmSubActionManager;
import org.cgiar.ccafs.marlo.data.manager.GenderTypeManager;
import org.cgiar.ccafs.marlo.data.manager.GlobalUnitManager;
import org.cgiar.ccafs.marlo.data.manager.PhaseManager;
Expand All @@ -48,6 +50,8 @@
import org.cgiar.ccafs.marlo.data.model.DeliverableProgram;
import org.cgiar.ccafs.marlo.data.model.DeliverablePublicationMetadata;
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.DeliverableUser;
import org.cgiar.ccafs.marlo.data.model.DeliverableUserPartnership;
import org.cgiar.ccafs.marlo.data.model.DeliverableUserPartnershipPerson;
Expand Down Expand Up @@ -118,6 +122,8 @@ public class DeliverablesReportingExcelSummaryAction extends BaseSummariesAction
private DeliverableLocationManager deliverableLocationManager;
private final CrpPpaPartnerManager crpPpaPartnerManager;
private final DeliverableInfoManager deliverableInfoManager;
private final DeliverableShfrmPriorityActionManager deliverableShfrmPriorityActionManager;
private final DeliverableShfrmSubActionManager deliverableShfrmSubActionManager;
private String showAllYears;
private String ppa;

Expand All @@ -141,7 +147,9 @@ public DeliverablesReportingExcelSummaryAction(APConfig config, GlobalUnitManage
DeliverableGeographicScopeManager deliverableGeographicScopeManager,
DeliverableGeographicRegionManager deliverableGeographicRegionManager,
DeliverableLocationManager deliverableLocationManager, CrpPpaPartnerManager crpPpaPartnerManager,
DeliverableInfoManager deliverableInfoManager) {
DeliverableInfoManager deliverableInfoManager,
DeliverableShfrmPriorityActionManager deliverableShfrmPriorityActionManager,
DeliverableShfrmSubActionManager deliverableShfrmSubActionManager) {
super(config, crpManager, phaseManager, projectManager);
this.genderTypeManager = genderTypeManager;
this.crpPpaPartnerManager = crpPpaPartnerManager;
Expand All @@ -155,6 +163,8 @@ public DeliverablesReportingExcelSummaryAction(APConfig config, GlobalUnitManage
this.deliverableGeographicRegionManager = deliverableGeographicRegionManager;
this.deliverableLocationManager = deliverableLocationManager;
this.deliverableInfoManager = deliverableInfoManager;
this.deliverableShfrmPriorityActionManager = deliverableShfrmPriorityActionManager;
this.deliverableShfrmSubActionManager = deliverableShfrmSubActionManager;
}

/**
Expand Down Expand Up @@ -258,6 +268,14 @@ private MasterReport addi8nParameters(MasterReport masterReport) {
masterReport.getParameterValues().put("i8nJustification", this.getText("deliverable.justification"));
masterReport.getParameterValues().put("i8nDeliverableDescription", this.getText("deliverable.description"));
masterReport.getParameterValues().put("i8nProjectLeadPartner", this.getText("summaries.deliverable.leadPartner"));
masterReport.getParameterValues().put("i8nDeliverablesContributingSHFRM",
"Is this deliverable aligned with the Soil Health and Fertility Road Map (SHFRM) implementation?");
masterReport.getParameterValues().put("i8nDeliverablesContributingNarrative",
"How this deliverable is expecting to contribute to the SHFRM?");
masterReport.getParameterValues().put("i8nDeliverablesContributingNarrativeReporting",
"How this deliverable is contributing to the SHFRM?");
masterReport.getParameterValues().put("i8nDeliverablesActions",
"To which Priority(ies) action is contributing to:");

/*
* Reporting
Expand Down Expand Up @@ -402,7 +420,8 @@ private TypedTableModel getDeliverablesDataReportingTableModel() {
"deliv_license_modifications", "volume", "issue", "pages", "journal", "journal_indicators", "acknowledge",
"fl_contrib", "project_ID", "project_title", "flagships", "regions", "others_responsibles", "newExceptedFlag",
"phaseID", "gender", "youth", "cap", "geographicScope", "region", "country", "status", "isComplete",
"individual", "ppaResponsible", "managingResponsible", "climate", "justification", "description", "articleURL"},
"individual", "ppaResponsible", "managingResponsible", "climate", "justification", "description", "articleURL",
"isContributing", "contributingNarrative", "shfrmActions", "contributingNarrativeReporting"},
new Class[] {Long.class, String.class, String.class, String.class, String.class, Integer.class, String.class,
String.class, String.class, String.class, Integer.class, String.class, String.class, String.class, String.class,
String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class,
Expand All @@ -411,7 +430,7 @@ private TypedTableModel getDeliverablesDataReportingTableModel() {
String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class,
String.class, String.class, String.class, Long.class, String.class, String.class, String.class, String.class,
String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class,
String.class, String.class, String.class},
String.class, String.class, String.class, String.class, String.class, String.class, String.class},
0);
if (!deliverableManager.findAll().isEmpty()) {
List<Deliverable> deliverables = new ArrayList<>();
Expand Down Expand Up @@ -1789,6 +1808,72 @@ private TypedTableModel getDeliverablesDataReportingTableModel() {
country = "<Not Defined>";
}

String isContributing = "", contributingNarrative = "", contributingNarrativeReporting = "", shfrmActions = "";

// SOIL Contribution
if (deliverable.getDeliverableInfo() != null
&& deliverable.getDeliverableInfo().getContributingShfrm() != null) {
if (deliverable.getDeliverableInfo().getContributingShfrm() == true) {
isContributing = "Yes";
} else {
isContributing = "No";
}
} else {
isContributing = "<Not Defined>";
}

if (isContributing.equals("Yes")) {

if (deliverable.getDeliverableInfo().getShfrmContributionNarrative() != null) {
contributingNarrative = deliverable.getDeliverableInfo().getShfrmContributionNarrative();
} else {
contributingNarrative = "<Not provided>";
}

if (deliverable.getDeliverableInfo().getShfrmContributionNarrativeAR() != null) {
contributingNarrativeReporting = deliverable.getDeliverableInfo().getShfrmContributionNarrativeAR();
} else {
contributingNarrativeReporting = "<Not provided>";
}

List<DeliverableShfrmPriorityAction> actions = new ArrayList<>();
List<DeliverableShfrmSubAction> subActions = new ArrayList<>();
String actionsText = "";

try {
actions = deliverableShfrmPriorityActionManager.findByDeliverableAndPhase(deliverable.getId(),
this.getSelectedPhase().getId());

if (actions != null && !actions.isEmpty()) {
for (DeliverableShfrmPriorityAction action : actions) {
if (action != null && action.getShfrmPriorityAction() != null
&& action.getShfrmPriorityAction().getId() != null
&& action.getShfrmPriorityAction().getComposedName() != null) {
actionsText += "\n " + action.getShfrmPriorityAction().getComposedName();
subActions = deliverableShfrmSubActionManager.findByPriorityActionAndPhase(action.getId(),
this.getSelectedPhase().getId());

if (subActions != null && !subActions.isEmpty()) {
actionsText += "\n <b> SubActions:</b>\n";
for (DeliverableShfrmSubAction subAction : subActions) {
if (subAction != null && subAction.getShfrmSubAction() != null
&& subAction.getShfrmSubAction().getComposedName() != null) {
actionsText += " ● " + subAction.getShfrmSubAction().getComposedName() + "\n";
}
}
}
}
}
}
shfrmActions = actionsText;
} catch (Exception e) {
LOG.error(e + " error getting shfrm actions and subactions");
}
} else {
contributingNarrative = "<Not Applicable>";
shfrmActions = "<Not Applicable>";
contributingNarrativeReporting = "<Not Applicable>";
}

model.addRow(new Object[] {deliverable.getId(), title, delivType, delivSubType, delivStatus, delivYear,
keyOutput, outcomes, leader, fundingSources, delivNewYear, delivNewYearJustification,
Expand All @@ -1798,7 +1883,8 @@ private TypedTableModel getDeliverablesDataReportingTableModel() {
disseminated, restrictedAccess, delivLicenseModifications, volume, issue, pages, journal, journalIndicator,
acknowledge, flContrib, projectID, projectTitle, flagships, regions, othersResponsibles, newExceptedFlag,
phaseID, gender, youth, cap, geographicScope, region, country, status, isComplete, individual, ppaResponsible,
managingResponsible, climate, justification, description, articleURL});
managingResponsible, climate, justification, description, articleURL, isContributing, contributingNarrative,
shfrmActions, contributingNarrativeReporting});
}
}
return model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.cgiar.ccafs.marlo.data.manager.DeliverableGeographicRegionManager;
import org.cgiar.ccafs.marlo.data.manager.DeliverableInfoManager;
import org.cgiar.ccafs.marlo.data.manager.DeliverableLocationManager;
import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmPriorityActionManager;
import org.cgiar.ccafs.marlo.data.manager.DeliverableShfrmSubActionManager;
import org.cgiar.ccafs.marlo.data.manager.GenderTypeManager;
import org.cgiar.ccafs.marlo.data.manager.GlobalUnitManager;
import org.cgiar.ccafs.marlo.data.manager.PhaseManager;
Expand All @@ -38,6 +40,8 @@
import org.cgiar.ccafs.marlo.data.model.DeliverableGeographicScope;
import org.cgiar.ccafs.marlo.data.model.DeliverableInfo;
import org.cgiar.ccafs.marlo.data.model.DeliverableLocation;
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.FundingSourceInfo;
Expand Down Expand Up @@ -132,6 +136,8 @@ public class ExpectedDeliverablesSummaryAction extends BaseSummariesAction imple
private final DeliverableGeographicRegionManager deliverableGeographicRegionManager;
private DeliverableLocationManager deliverableLocationManager;
private DeliverableInfoManager deliverableInfoManager;
private final DeliverableShfrmPriorityActionManager deliverableShfrmPriorityActionManager;
private final DeliverableShfrmSubActionManager deliverableShfrmSubActionManager;
// XLS bytes
private byte[] bytesXLSX;
// Streams
Expand All @@ -144,7 +150,9 @@ public ExpectedDeliverablesSummaryAction(APConfig config, GlobalUnitManager crpM
ResourceManager resourceManager, ProjectManager projectManager,
DeliverableCrossCuttingMarkerManager deliverableCrossCuttingMarkerManager,
DeliverableGeographicRegionManager deliverableGeographicRegionManager,
DeliverableLocationManager deliverableLocationManager, DeliverableInfoManager deliverableInfoManager) {
DeliverableLocationManager deliverableLocationManager, DeliverableInfoManager deliverableInfoManager,
DeliverableShfrmPriorityActionManager deliverableShfrmPriorityActionManager,
DeliverableShfrmSubActionManager deliverableShfrmSubActionManager) {
super(config, crpManager, phaseManager, projectManager);
this.genderTypeManager = genderTypeManager;
this.crpProgramManager = crpProgramManager;
Expand All @@ -154,6 +162,8 @@ public ExpectedDeliverablesSummaryAction(APConfig config, GlobalUnitManager crpM
this.deliverableGeographicRegionManager = deliverableGeographicRegionManager;
this.deliverableLocationManager = deliverableLocationManager;
this.deliverableInfoManager = deliverableInfoManager;
this.deliverableShfrmPriorityActionManager = deliverableShfrmPriorityActionManager;
this.deliverableShfrmSubActionManager = deliverableShfrmSubActionManager;
}

/**
Expand Down Expand Up @@ -206,6 +216,14 @@ private MasterReport addi8nParameters(MasterReport masterReport) {
this.getText("summaries.board.report.expectedDeliverables.isNewDeliverable"));
masterReport.getParameterValues().put("i8nArticleURL",
this.getText("summaries.board.report.expectedDeliverables.articleURL"));
masterReport.getParameterValues().put("i8nDeliverablesContributingSHFRM",
"Is this deliverable aligned with the Soil Health and Fertility Road Map (SHFRM) implementation?");
masterReport.getParameterValues().put("i8nDeliverablesContributingNarrative",
"How this deliverable is expecting to contribute to the SHFRM?");
masterReport.getParameterValues().put("i8nDeliverablesContributingNarrativeReporting",
"How this deliverable is contributing to the SHFRM?");
masterReport.getParameterValues().put("i8nDeliverablesActions",
"To which Priority(ies) action is contributing to:");

return masterReport;
}
Expand Down Expand Up @@ -299,12 +317,12 @@ private TypedTableModel getDeliverablesDetailsTableModel() {
"flagships", "regions", "individual", "partnersResponsible", "shared", "openFS", "fsWindows", "outcomes",
"projectLeadPartner", "managingResponsible", "phaseID", "finishedFS", "gender", "youth", "cap", "climate",
"deliverableDescription", "geographicScope", "region", "country", "newDeliverable", "divisions", "hasDivisions",
"articleURL"},
"articleURL", "isContributing", "contributingNarrative", "shfrmActions"},
new Class[] {Long.class, String.class, Integer.class, String.class, String.class, String.class, String.class,
String.class, Long.class, String.class, String.class, String.class, String.class, String.class, String.class,
String.class, String.class, String.class, String.class, String.class, String.class, Long.class, String.class,
String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class,
String.class, String.class, Boolean.class, String.class},
String.class, String.class, Boolean.class, String.class, String.class, Boolean.class, String.class},
0);
Boolean activePPAFilter = ppa != null && !ppa.isEmpty() && !ppa.equals("All") && !ppa.equals("-1");
Boolean addDeliverableRow = true;
Expand Down Expand Up @@ -658,13 +676,17 @@ private TypedTableModel getDeliverablesDetailsTableModel() {
if (deliverableDissemination.getArticleUrl() != null) {
articleURL = deliverableDissemination.getArticleUrl();
} else {
articleURL = "<Not Defined>";
articleURL = "&lt;Not Defined&gt;";
}
} else {
articleURL = "<Not Applicable>";
articleURL = "&lt;Not Applicable&gt;";
}
} else {
articleURL = "<Not Applicable>";
articleURL = "&lt;Not Applicable&gt;";
}

if (articleURL == null || (articleURL != null && articleURL.isEmpty())) {
articleURL = "Not Defined&gt;";
}

LinkedHashSet<Institution> managingResponsibleList = new LinkedHashSet<>();
Expand Down Expand Up @@ -1094,6 +1116,11 @@ private TypedTableModel getDeliverablesDetailsTableModel() {
} else {
regions = null;
}

if (regions == null) {
regions = "&lt;Not Defined&gt;";
}

String openFS = "";
String finishedFS = "";
Set<String> fsWindowsSet = new HashSet<String>();
Expand Down Expand Up @@ -1315,12 +1342,72 @@ private TypedTableModel getDeliverablesDetailsTableModel() {
divisions = null;
}

String isContributing = "", contributingNarrative = "", shfrmActions = "";

// SOIL Contribution
if (deliverable.getDeliverableInfo() != null
&& deliverable.getDeliverableInfo().getContributingShfrm() != null) {
if (deliverable.getDeliverableInfo().getContributingShfrm() == true) {
isContributing = "Yes";
} else {
isContributing = "No";
}
} else {
isContributing = "<Not Defined>";
}

if (isContributing.equals("Yes")) {

if (deliverable.getDeliverableInfo().getShfrmContributionNarrative() != null
&& !deliverable.getDeliverableInfo().getShfrmContributionNarrative().isEmpty()) {
contributingNarrative = deliverable.getDeliverableInfo().getShfrmContributionNarrative();
} else {
contributingNarrative = "<Not Provided>";
}

List<DeliverableShfrmPriorityAction> actions = new ArrayList<>();
List<DeliverableShfrmSubAction> subActions = new ArrayList<>();
String actionsText = "";

try {
actions = deliverableShfrmPriorityActionManager.findByDeliverableAndPhase(deliverable.getId(),
this.getSelectedPhase().getId());

if (actions != null && !actions.isEmpty()) {
for (DeliverableShfrmPriorityAction action : actions) {
if (action != null && action.getShfrmPriorityAction() != null
&& action.getShfrmPriorityAction().getId() != null
&& action.getShfrmPriorityAction().getComposedName() != null) {
actionsText += "\n " + action.getShfrmPriorityAction().getComposedName();
subActions = deliverableShfrmSubActionManager.findByPriorityActionAndPhase(action.getId(),
this.getSelectedPhase().getId());

if (subActions != null && !subActions.isEmpty()) {
actionsText += "\n <b> SubActions:</b> \n";
for (DeliverableShfrmSubAction subAction : subActions) {
if (subAction != null && subAction.getShfrmSubAction() != null
&& subAction.getShfrmSubAction().getComposedName() != null) {
actionsText += " ● " + subAction.getShfrmSubAction().getComposedName() + "\n";
}
}
}
}
}
}
shfrmActions = actionsText;
} catch (Exception e) {
LOG.error(e + " error getting shfrm actions and subactions");
}
} else {
contributingNarrative = "&lt;Not Applicable&gt;";
shfrmActions = "&lt;Not Applicable&gt;";
}

model.addRow(new Object[] {deliverableId, deliverableTitle, completionYear, deliverableType, deliverableSubType,
keyOutput, delivStatus, delivNewYear, projectID, projectTitle, projectClusterActivities, flagships, regions,
individual, ppaResponsible, shared, openFS, fsWindows, outcomes, projectLeadPartner, managingResponsible,
phaseID, finishedFS, gender, youth, cap, climate, deliverableDescription, geographicScope, region, country,
newDeliverable, divisions, hasDivisions, articleURL});
newDeliverable, divisions, hasDivisions, articleURL, isContributing, contributingNarrative, shfrmActions});

if (deliverablePerYearList.containsKey(completionYear)) {
Set<Deliverable> deliverableSet = deliverablePerYearList.get(completionYear);
Expand Down
Binary file modified marlo-web/src/main/resources/pentaho/crp/ExpectedDeliverables.prpt
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit ce314c8

Please sign in to comment.