diff --git a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java index df46b27176..34ce0f417a 100644 --- a/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java +++ b/marlo-data/src/main/java/org/cgiar/ccafs/marlo/config/APConstants.java @@ -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 = diff --git a/marlo-parent/pom.xml b/marlo-parent/pom.xml index 597461eda1..5873068e1f 100644 --- a/marlo-parent/pom.xml +++ b/marlo-parent/pom.xml @@ -24,7 +24,7 @@ 8.0.28 3.0.1 2.2.1 - 5.3.0 + 3.13 1.0 4.0.1 20231013 diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/ParticipantsAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/ParticipantsAction.java index a2c893be4d..2e02a8ae04 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/ParticipantsAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/ParticipantsAction.java @@ -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; @@ -234,7 +236,7 @@ public String preLoadExcelFile() { input.close(); - } catch (Exception e) { + } catch (IOException | EncryptedDocumentException | InvalidFormatException e) { e.printStackTrace(); } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/test.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/test.java index e7d9bae39d..09f3923008 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/test.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/center/capdev/test.java @@ -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; } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReport2018POISummaryAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReport2018POISummaryAction.java index f36e13cb10..9e32684985 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReport2018POISummaryAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReport2018POISummaryAction.java @@ -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; @@ -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; @@ -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); @@ -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()); } } @@ -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 @@ -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 diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReportPOISummaryAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReportPOISummaryAction.java index 50bb52edb0..86f4cbeae5 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReportPOISummaryAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnnualReportPOISummaryAction.java @@ -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; @@ -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()); } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnualReportPOISummaryAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnualReportPOISummaryAction.java index 05a0eb4722..ce954d5423 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnualReportPOISummaryAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/AnualReportPOISummaryAction.java @@ -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; @@ -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()); } } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/POWBPOISummary2019Action.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/POWBPOISummary2019Action.java index d043fa7054..5042797b95 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/POWBPOISummary2019Action.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/POWBPOISummary2019Action.java @@ -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; @@ -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; @@ -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); @@ -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()); } @@ -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); @@ -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); diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ProgressReportProcessPOISummaryAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ProgressReportProcessPOISummaryAction.java index 2df9f4680c..c250ff0b09 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ProgressReportProcessPOISummaryAction.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/summaries/ProgressReportProcessPOISummaryAction.java @@ -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; @@ -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; @@ -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); @@ -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()); } @@ -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 @@ -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 @@ -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 { @@ -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 @@ -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 @@ -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 @@ -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); } @@ -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 @@ -1605,7 +1601,7 @@ public void loadProvider(Map session) { try { ServletActionContext.getContext().setLocale(locale); } catch (Exception e) { - LOG.error("Error generating Progress Summary " + e.getMessage()); + } if (session.containsKey(APConstants.SESSION_CRP)) { diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/ReadExcelFile.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/ReadExcelFile.java index 61dfc3c04d..66eb0f1475 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/ReadExcelFile.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/ReadExcelFile.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; @@ -28,6 +29,7 @@ import java.util.Map; 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.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -50,17 +52,17 @@ 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: @@ -156,7 +158,7 @@ public Object[][] readExcelFile(File file) { } - } catch (Exception e) { + } catch (EncryptedDocumentException | InvalidFormatException | IOException e) { e.printStackTrace(); } } @@ -238,7 +240,7 @@ public boolean validarExcelFile(File file) { equal = false; } - } catch (Exception e) { + } catch (EncryptedDocumentException | InvalidFormatException | IOException e) { equal = false; } diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoExcel.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoExcel.java index e6b2d81d82..abb1ae7d9e 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoExcel.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoExcel.java @@ -153,7 +153,7 @@ private static Font mergeFont(Font font, STYLES fontStyle, String fontValue, Wor case BOLD: case EM: case STRONG: - font.setBold(true); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); break; case UNDERLINE: font.setUnderline(Font.U_SINGLE); diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoWord.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoWord.java index 72c0452d6a..0ef7815c04 100644 --- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoWord.java +++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/utils/richTextPOI/HTMLtoWord.java @@ -170,7 +170,7 @@ private static Font mergeFont(Font font, STYLES fontStyle, String fontValue, XWP case BOLD: case EM: case STRONG: - font.setBold(true); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); break; case UNDERLINE: font.setUnderline(Font.U_SINGLE);