Skip to content

Commit

Permalink
Merge branch 'aiccra-staging' into AICCRA
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Aug 12, 2024
2 parents d1a9227 + 76a297d commit aca71fb
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,15 @@ public final class APConstants {
public static final String PROJECT_EXPECTED_STUDIES_GEOGRAPHIC_SCOPE =
"java.util.Set(org.cgiar.ccafs.marlo.data.model.ProjectExpectedStudy.projectExpectedStudyGeographicScopes)";

public static final String PROJECT_EXPECTED_STUDIES_CENTER_RELATION =
"java.util.Set(org.cgiar.ccafs.marlo.data.model.ProjectExpectedStudy.projectExpectedStudyCenters)";
public static final String PROJECT_EXPECTED_STUDIES_MILESTONE_RELATION =
"java.util.Set(org.cgiar.ccafs.marlo.data.model.ProjectExpectedStudy.projectExpectedStudyMilestones)";
public static final String PROJECT_EXPECTED_STUDIES_PROJECT_OUTCOME_RELATION =
"java.util.Set(org.cgiar.ccafs.marlo.data.model.ProjectExpectedStudy.projectExpectedStudyProjectOutcomes)";

public static final String PROJECT_INDICATOR_PHASE_PREVIOUS_NAME = "AR";

public static final String PROJECT_BILATERAL = "BILATERAL";
// public static final String PROJECT_CORE_TYPE = "CORE";
public static final String PROJECT_BUDGETS_ACTVITIES_RELATION =
Expand Down
2 changes: 1 addition & 1 deletion marlo-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<mysql.version>8.0.28</mysql.version>
<servlet-api.version>3.0.1</servlet-api.version>
<jsp-api.version>2.2.1</jsp-api.version>
<poi.version>5.3.0</poi.version>
<poi.version>3.13</poi.version>
<ooxml-schemas.version>1.0</ooxml-schemas.version>
<flyway.version>4.0.1</flyway.version>
<org.json.version>20231013</org.json.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;

import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationConstraint;
Expand Down Expand Up @@ -234,7 +236,7 @@ public String preLoadExcelFile() {
input.close();


} catch (Exception e) {
} catch (IOException | EncryptedDocumentException | InvalidFormatException e) {
e.printStackTrace();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,26 @@ public Object getCellData(Cell cell) {

if (cell != null) {
switch (cell.getCellType()) {
case STRING:
case Cell.CELL_TYPE_STRING:
cellData = cell.getStringCellValue();
break;
case NUMERIC:
case Cell.CELL_TYPE_NUMERIC:
cellData = cell.getNumericCellValue();
break;
case BOOLEAN:
case Cell.CELL_TYPE_BOOLEAN:
cellData = cell.getBooleanCellValue();
break;
case BLANK:
cellData = "";
case Cell.CELL_TYPE_BLANK:
cellData = cell.getStringCellValue();
break;


default:
break;
}
}


return cellData;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down Expand Up @@ -119,13 +120,13 @@
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPrGeneral;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPageSz;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSimpleField;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STPageOrientation;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType;
import org.slf4j.Logger;
Expand Down Expand Up @@ -160,7 +161,7 @@ private static void addCustomHeadingStyle(XWPFDocument docxDocument, String strS
ctStyle.setQFormat(onoffnull);

// style defines a heading of the given level
CTPPrGeneral ppr = CTPPrGeneral.Factory.newInstance();
CTPPr ppr = CTPPr.Factory.newInstance();
ppr.setOutlineLvl(indentNumber);
ctStyle.setPPr(ppr);

Expand Down Expand Up @@ -688,7 +689,7 @@ public void createPageFooter() {
try {
XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, paragraphs);
} catch (Exception e) {
} catch (IOException e) {
LOG.error("Failed to createFooter. Exception: " + e.getMessage());
}
}
Expand Down Expand Up @@ -2182,7 +2183,7 @@ public String execute() throws Exception {
CTP ctP = paragraph.getCTP();
CTSimpleField toc = ctP.addNewFldSimple();
toc.setInstr("TOC \\h");
toc.setDirty(true);
toc.setDirty(STOnOff.TRUE);
XWPFRun run = paragraph.createRun();

// First page
Expand Down Expand Up @@ -2667,7 +2668,7 @@ public String execute() throws Exception {
CTP ctP = paragraph.getCTP();
CTSimpleField toc = ctP.addNewFldSimple();
toc.setInstr("TOC \\h");
toc.setDirty(true);
toc.setDirty(STOnOff.TRUE);
XWPFRun run = paragraph.createRun();

// First page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down Expand Up @@ -570,7 +571,7 @@ public void createPageFooter() {
try {
XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, paragraphs);
} catch (Exception e) {
} catch (IOException e) {
LOG.error("Failed to createFooter. Exception: " + e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down Expand Up @@ -570,7 +571,7 @@ public void createPageFooter() {
try {
XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, paragraphs);
} catch (Exception e) {
} catch (IOException e) {
LOG.error("Failed to createFooter. Exception: " + e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down Expand Up @@ -107,7 +108,6 @@
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPrGeneral;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPageSz;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
Expand All @@ -133,25 +133,22 @@ private static void addCustomHeadingStyle(XWPFDocument docxDocument, String strS
styleName.setVal(strStyleId);
ctStyle.setName(styleName);

// Assuming headingLevel is an integer representing the level of the heading
CTDecimalNumber indentNumber = CTDecimalNumber.Factory.newInstance();
indentNumber.setVal(BigInteger.valueOf(headingLevel)); // Set the UI priority
indentNumber.setVal(BigInteger.valueOf(headingLevel));

// Set the style's UI priority (using an integer value)
// lower number > style is more prominent in the formats bar
ctStyle.setUiPriority(indentNumber);

CTOnOff onoffnull = CTOnOff.Factory.newInstance();
ctStyle.setUnhideWhenUsed(onoffnull); // Set the style to unhide when used
ctStyle.setUnhideWhenUsed(onoffnull);

// Style shows up in the formats bar
// style shows up in the formats bar
ctStyle.setQFormat(onoffnull);

// Define a heading of the given level
CTPPrGeneral pprGeneral = CTPPrGeneral.Factory.newInstance(); // Create a new instance of CTPPrGeneral
CTDecimalNumber outlineLvl = CTDecimalNumber.Factory.newInstance(); // Create a new instance of CTDecimalNumber
outlineLvl.setVal(BigInteger.valueOf(headingLevel)); // Set the outline level value
pprGeneral.setOutlineLvl(outlineLvl); // Set the outline level in the paragraph properties
ctStyle.setPPr(pprGeneral); // Apply the paragraph properties to the style
// style defines a heading of the given level
CTPPr ppr = CTPPr.Factory.newInstance();
ppr.setOutlineLvl(indentNumber);
ctStyle.setPPr(ppr);

XWPFStyle style = new XWPFStyle(ctStyle);

Expand Down Expand Up @@ -329,7 +326,7 @@ public void createPageFooter() {
try {
XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, paragraphs);
} catch (Exception e) {
} catch (IOException e) {
LOG.error("Failed to createFooter. Exception: " + e.getMessage());
}

Expand Down Expand Up @@ -1056,7 +1053,7 @@ public String execute() throws Exception {
* CTP ctP = paragraph.getCTP();
* CTSimpleField toc = ctP.addNewFldSimple();
* toc.setInstr("TOC \\h");
* toc.setDirty(true);
* toc.setDirty(STOnOff.TRUE);
*/
XWPFRun run = paragraph.createRun();
// run.addBreak(BreakType.PAGE);
Expand Down Expand Up @@ -1330,7 +1327,7 @@ public String execute() throws Exception {
* CTP ctP = paragraph.getCTP();
* CTSimpleField toc = ctP.addNewFldSimple();
* toc.setInstr("TOC \\h");
* toc.setDirty(true);
* toc.setDirty(STOnOff.TRUE);
*/
XWPFRun run = paragraph.createRun();
// run.addBreak(BreakType.PAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down Expand Up @@ -112,12 +113,13 @@
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocument1;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPrGeneral;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSimpleField;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -152,7 +154,7 @@ private static void addCustomHeadingStyle(XWPFDocument docxDocument, String strS
ctStyle.setQFormat(onoffnull);

// style defines a heading of the given level
CTPPrGeneral ppr = CTPPrGeneral.Factory.newInstance();
CTPPr ppr = CTPPr.Factory.newInstance();
ppr.setOutlineLvl(indentNumber);
ctStyle.setPPr(ppr);

Expand Down Expand Up @@ -614,7 +616,7 @@ public void createPageFooter() {
try {
XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, paragraphs);
} catch (Exception e) {
} catch (IOException e) {
LOG.error("Failed to createFooter. Exception: " + e.getMessage());
}

Expand Down Expand Up @@ -820,7 +822,6 @@ public String execute() throws Exception {
&& c.getCrpProgramOutcome().getComposedName().contains("PDO Indicator 1"))
.collect(Collectors.toList()));
} catch (Exception e) {
LOG.error("Error generating Progress Summary " + e.getMessage());
}

// PDO 2
Expand All @@ -831,7 +832,6 @@ public String execute() throws Exception {
&& c.getCrpProgramOutcome().getComposedName().contains("PDO Indicator 2"))
.collect(Collectors.toList()));
} catch (Exception e) {
LOG.error("Error generating Progress Summary " + e.getMessage());
}

// PDO 3
Expand All @@ -842,7 +842,6 @@ public String execute() throws Exception {
&& c.getCrpProgramOutcome().getComposedName().contains("PDO Indicator 3"))
.collect(Collectors.toList()));
} catch (Exception e) {
LOG.error("Error generating Progress Summary " + e.getMessage());
}
// PDO 4
try {
Expand All @@ -852,7 +851,6 @@ public String execute() throws Exception {
&& c.getCrpProgramOutcome().getComposedName().contains("PDO Indicator 4"))
.collect(Collectors.toList()));
} catch (Exception e) {
LOG.error("Error generating Progress Summary " + e.getMessage());
}

// IPI 1.1
Expand All @@ -863,7 +861,6 @@ public String execute() throws Exception {
&& c.getCrpProgramOutcome().getComposedName().contains("IPI 1.1"))
.collect(Collectors.toList()));
} catch (Exception e) {
LOG.error("Error generating Progress Summary " + e.getMessage());
}

// IPI 1.2
Expand All @@ -874,7 +871,6 @@ public String execute() throws Exception {
&& c.getCrpProgramOutcome().getComposedName().contains("IPI 1.2"))
.collect(Collectors.toList()));
} catch (Exception e) {
LOG.error("Error generating Progress Summary " + e.getMessage());
}

// IPI 1.3
Expand Down Expand Up @@ -1061,7 +1057,7 @@ public String execute() throws Exception {
CTP ctP = paragraph.getCTP();
CTSimpleField toc = ctP.addNewFldSimple();
toc.setInstr("TOC \\h");
toc.setDirty(true);
toc.setDirty(STOnOff.TRUE);
XWPFRun run = paragraph.createRun();
document.createParagraph().setPageBreak(true);
}
Expand Down Expand Up @@ -1111,7 +1107,7 @@ public String execute() throws Exception {
run.addBreak();
run.addPicture(new FileInputStream(imageFile), imgFormat, imgFile, Units.toEMU(width), Units.toEMU(height));
} catch (Exception e) {
LOG.error("Error generating Progress Summary " + e.getMessage());
// System.out.println(e);
}

// Project Title
Expand Down Expand Up @@ -1605,7 +1601,7 @@ public void loadProvider(Map<String, Object> session) {
try {
ServletActionContext.getContext().setLocale(locale);
} catch (Exception e) {
LOG.error("Error generating Progress Summary " + e.getMessage());

}

if (session.containsKey(APConstants.SESSION_CRP)) {
Expand Down
Loading

0 comments on commit aca71fb

Please sign in to comment.