Class AbstractTemplateExportFunctions

java.lang.Object
org.damap.base.conversion.AbstractTemplateExportFunctions
Direct Known Subclasses:
AbstractTemplateExportSetup

public abstract class AbstractTemplateExportFunctions extends Object
Abstract AbstractTemplateExportFunctions class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final SimpleDateFormat
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addReplacement(Map<String,String> replacements, String variable, Object dmpContent)
    Method to do a replacement of variable with desired value
    void
    formattingParagraph(List<org.apache.poi.xwpf.usermodel.XWPFParagraph> xwpfParagraphs, String startChar, String endChar)
    Method to preprocessing format of the paragraph list
    void
    formattingTable(List<org.apache.poi.xwpf.usermodel.XWPFTable> xwpfTables, String startChar, String endChar)
    Loop to format tables within tables in the template.
    List<org.apache.poi.xwpf.usermodel.XWPFTableCell>
    getAllOuterTableCells(org.apache.poi.xwpf.usermodel.XWPFDocument doc)
    Returns a list of all table cells of non nested tables in the document.
    List<org.apache.poi.xwpf.usermodel.XWPFTable>
    getAllTables(org.apache.poi.xwpf.usermodel.XWPFDocument doc)
    Returns a list of all tables and nested tables with depth 1.
    org.apache.poi.xwpf.usermodel.XWPFTableRow
    insertNewTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow sourceTableRow, int pos)
    Method to add new row in a table
    joinWithComma(List<String> variableList)
    Method to combine multiple values become one string.
    joinWithCommaAnd(List<String> variableList)
    joinWithCommaAnd.
    org.apache.poi.xwpf.usermodel.XWPFDocument
    loadTemplate(InputStream template, String startChar, String endChar)
    Method to load the export template
    void
    removeTable(org.apache.poi.xwpf.usermodel.XWPFDocument doc, org.apache.poi.xwpf.usermodel.XWPFTable table)
    Removes a table inside a document or nested inside another table.
    void
    removeTableAndParagraphAbove(org.apache.poi.xwpf.usermodel.XWPFDocument doc, org.apache.poi.xwpf.usermodel.XWPFTable table)
    Removes a table inside a document or nested inside another table.
    void
    replaceTextInFooter(org.apache.poi.xwpf.usermodel.XWPFDocument doc, Map<String,String> replacements)
    Method to do a replacement specific in document's footer area
    org.apache.poi.xwpf.usermodel.XWPFDocument
    templateFormatting(org.apache.poi.xwpf.usermodel.XWPFDocument document, String startChar, String endChar)
    Method to format the template.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AbstractTemplateExportFunctions

      public AbstractTemplateExportFunctions()
  • Method Details

    • loadTemplate

      public org.apache.poi.xwpf.usermodel.XWPFDocument loadTemplate(InputStream template, String startChar, String endChar) throws Exception
      Method to load the export template
      Parameters:
      template - a InputStream object
      startChar - a String object
      endChar - a String object
      Returns:
      a XWPFDocument object
      Throws:
      Exception
    • addReplacement

      public void addReplacement(Map<String,String> replacements, String variable, Object dmpContent)
      Method to do a replacement of variable with desired value
      Parameters:
      replacements - a Map object
      variable - a String object
      dmpContent - a Object object
    • insertNewTableRow

      public org.apache.poi.xwpf.usermodel.XWPFTableRow insertNewTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow sourceTableRow, int pos) throws org.apache.xmlbeans.XmlException, IOException
      Method to add new row in a table
      Parameters:
      sourceTableRow - a XWPFTableRow object
      pos - a int
      Returns:
      a XWPFTableRow object
      Throws:
      IOException
      org.apache.xmlbeans.XmlException
    • replaceTextInFooter

      public void replaceTextInFooter(org.apache.poi.xwpf.usermodel.XWPFDocument doc, Map<String,String> replacements)
      Method to do a replacement specific in document's footer area
      Parameters:
      doc - a XWPFDocument object
      replacements - a Map object
    • joinWithComma

      public String joinWithComma(List<String> variableList)
      Method to combine multiple values become one string. Can be used for generate values from a list of object or replace one variable with multiple values in one execution.
      Parameters:
      variableList - a List object
      Returns:
      a String object
    • joinWithCommaAnd

      public String joinWithCommaAnd(List<String> variableList)
      joinWithCommaAnd.
      Parameters:
      variableList - a List object
      Returns:
      a String object
    • templateFormatting

      public org.apache.poi.xwpf.usermodel.XWPFDocument templateFormatting(org.apache.poi.xwpf.usermodel.XWPFDocument document, String startChar, String endChar) throws Exception
      Method to format the template. Parsing all text inside the document and preprocessing the variables (currently, text started with "[" and end with "]") that are seperated to multiple runs.
      Parameters:
      document - a XWPFDocument object
      startChar - a String object
      endChar - a String object
      Returns:
      a XWPFDocument object
      Throws:
      Exception
    • formattingTable

      public void formattingTable(List<org.apache.poi.xwpf.usermodel.XWPFTable> xwpfTables, String startChar, String endChar)
      Loop to format tables within tables in the template.
      Parameters:
      xwpfTables - a List object
      startChar - a String object
      endChar - a String object
    • formattingParagraph

      public void formattingParagraph(List<org.apache.poi.xwpf.usermodel.XWPFParagraph> xwpfParagraphs, String startChar, String endChar)
      Method to preprocessing format of the paragraph list
      Parameters:
      xwpfParagraphs - a List object
      startChar - a String object
      endChar - a String object
    • removeTable

      public void removeTable(org.apache.poi.xwpf.usermodel.XWPFDocument doc, org.apache.poi.xwpf.usermodel.XWPFTable table)
      Removes a table inside a document or nested inside another table. For nested tables, this works only for depth 1. If the table is not to be found inside the doc or at depth 1, nothing happens.
      Parameters:
      doc - a XWPFDocument object
      table - a XWPFTable object
    • removeTableAndParagraphAbove

      public void removeTableAndParagraphAbove(org.apache.poi.xwpf.usermodel.XWPFDocument doc, org.apache.poi.xwpf.usermodel.XWPFTable table)
      Removes a table inside a document or nested inside another table. Also removes the paragraph above it. For nested tables, this works only for depth 1. If the table is not to be found inside the doc or at depth 1, nothing happens. If the there is no paragraph above the table, only the table will be removed.
      Parameters:
      doc - a XWPFDocument object
      table - a XWPFTable object
    • getAllOuterTableCells

      public List<org.apache.poi.xwpf.usermodel.XWPFTableCell> getAllOuterTableCells(org.apache.poi.xwpf.usermodel.XWPFDocument doc)
      Returns a list of all table cells of non nested tables in the document.
      Parameters:
      doc - a XWPFDocument object
      Returns:
      a List object
    • getAllTables

      public List<org.apache.poi.xwpf.usermodel.XWPFTable> getAllTables(org.apache.poi.xwpf.usermodel.XWPFDocument doc)
      Returns a list of all tables and nested tables with depth 1.
      Parameters:
      doc - a XWPFDocument object
      Returns:
      a List object