Search in sources :

Example 1 with Table

use of com.epam.pipeline.manager.pipeline.documents.templates.structure.Table in project cloud-pipeline by epam.

the class PipelineDocumentTemplate method getCustomScriptsTable.

@Placeholder(regex = "Analytical Pipeline Custom Scripts", processor = TableTemplateProcessor.class)
public Table getCustomScriptsTable() {
    Table table = new Table();
    table.setContainsHeaderRow(true);
    table.addColumn("Custom script");
    table.addColumn("Version");
    for (GitRepositoryEntry customScript : this.customScripts) {
        TableRow row = table.addRow(customScript.getName());
        table.setData(row.getIndex(), 0, customScript.getName());
        table.setData(row.getIndex(), 1, "");
    }
    return table;
}
Also used : Table(com.epam.pipeline.manager.pipeline.documents.templates.structure.Table) TableRow(com.epam.pipeline.manager.pipeline.documents.templates.structure.TableRow) GitRepositoryEntry(com.epam.pipeline.entity.git.GitRepositoryEntry) Placeholder(com.epam.pipeline.manager.pipeline.documents.templates.processors.base.Placeholder)

Example 2 with Table

use of com.epam.pipeline.manager.pipeline.documents.templates.structure.Table in project cloud-pipeline by epam.

the class PipelineDocumentTemplate method getFilesGeneratedDuringPipelineProcessingTable.

@Placeholder(regex = "Files generated during pipeline processing", processor = TableTemplateProcessor.class)
public Table getFilesGeneratedDuringPipelineProcessingTable() {
    Table table = new Table();
    table.setContainsHeaderRow(true);
    table.addColumn("File Name");
    table.addColumn("Storage Fate");
    for (Pair<String, String> generatedFile : this.filesGeneratedDuringPipelineProcessing) {
        TableRow row = table.addRow(generatedFile.getKey());
        table.setData(row.getIndex(), 0, generatedFile.getKey());
        table.setData(row.getIndex(), 1, generatedFile.getValue());
    }
    return table;
}
Also used : Table(com.epam.pipeline.manager.pipeline.documents.templates.structure.Table) TableRow(com.epam.pipeline.manager.pipeline.documents.templates.structure.TableRow) Placeholder(com.epam.pipeline.manager.pipeline.documents.templates.processors.base.Placeholder)

Example 3 with Table

use of com.epam.pipeline.manager.pipeline.documents.templates.structure.Table in project cloud-pipeline by epam.

the class TableTemplateProcessor method insertData.

@Override
boolean insertData(XWPFParagraph splittedParagraph, XWPFRun runTemplate, XmlCursor cursor, Object data) {
    if (data instanceof Table) {
        Table table = (Table) data;
        XWPFTable xwpfTable = splittedParagraph.getDocument().insertNewTbl(cursor);
        CTTblPr properties = xwpfTable.getCTTbl().getTblPr();
        if (properties == null) {
            properties = xwpfTable.getCTTbl().addNewTblPr();
        }
        CTJc jc = (properties.isSetJc() ? properties.getJc() : properties.addNewJc());
        jc.setVal(STJc.CENTER);
        CTTblBorders borders = properties.addNewTblBorders();
        borders.addNewBottom().setVal(STBorder.SINGLE);
        borders.addNewLeft().setVal(STBorder.SINGLE);
        borders.addNewRight().setVal(STBorder.SINGLE);
        borders.addNewTop().setVal(STBorder.SINGLE);
        borders.addNewInsideH().setVal(STBorder.SINGLE);
        borders.addNewInsideV().setVal(STBorder.SINGLE);
        for (int rowIndex = -1; rowIndex < table.getRows().size(); rowIndex++) {
            if (rowIndex == -1 && !table.isContainsHeaderRow()) {
                continue;
            }
            XWPFTableRow xwpfTableRow = xwpfTable.insertNewTableRow(rowIndex + 1);
            for (int colIndex = -1; colIndex < table.getColumns().size(); colIndex++) {
                if (colIndex == -1 && !table.isContainsHeaderColumn()) {
                    continue;
                }
                String text = "";
                XWPFTableCell xwpfTableCell = xwpfTableRow.addNewTableCell();
                XWPFParagraph xwpfParagraph = xwpfTableCell.addParagraph();
                xwpfParagraph.setAlignment(ParagraphAlignment.CENTER);
                xwpfParagraph.setVerticalAlignment(TextAlignment.CENTER);
                XWPFRun xwpfRun = xwpfParagraph.createRun();
                this.copyRunProperties(runTemplate, xwpfRun);
                if (rowIndex == -1 && colIndex >= 0) {
                    text = table.getColumns().get(colIndex).getName();
                    xwpfRun.setBold(true);
                } else if (colIndex == -1 && rowIndex >= 0) {
                    text = table.getRows().get(rowIndex).getName();
                    xwpfRun.setBold(true);
                } else if (rowIndex >= 0 && colIndex >= 0) {
                    Object cellData = table.getData(rowIndex, colIndex);
                    text = cellData != null ? cellData.toString() : "";
                }
                xwpfRun.setText(text, 0);
            }
        }
        cursor.toNextSibling();
        return true;
    }
    return false;
}
Also used : XWPFParagraph(org.apache.poi.xwpf.usermodel.XWPFParagraph) XWPFTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell) Table(com.epam.pipeline.manager.pipeline.documents.templates.structure.Table) XWPFTable(org.apache.poi.xwpf.usermodel.XWPFTable) CTTblBorders(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblBorders) XWPFRun(org.apache.poi.xwpf.usermodel.XWPFRun) CTJc(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc) XWPFTable(org.apache.poi.xwpf.usermodel.XWPFTable) CTTblPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr) XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow)

Example 4 with Table

use of com.epam.pipeline.manager.pipeline.documents.templates.structure.Table in project cloud-pipeline by epam.

the class PipelineDocumentTemplate method getOpenSourceAlgorithmsAndSoftwareTable.

@Placeholder(regex = "Open Source Algorithms and Software", processor = TableTemplateProcessor.class)
public Table getOpenSourceAlgorithmsAndSoftwareTable() {
    Table table = new Table();
    table.setContainsHeaderRow(true);
    table.addColumn("Algorithm or Software");
    table.addColumn("Version");
    Map<String, List<String>> toolsVersions = new HashMap<>();
    for (Tool tool : this.openSourceSoftware) {
        String[] parts = tool.getImage().split("-");
        String toolName = tool.getImage();
        String toolVersion = null;
        if (parts.length >= 2) {
            toolName = parts[0].trim();
            toolVersion = parts[1].trim();
        }
        if (!toolsVersions.containsKey(toolName)) {
            toolsVersions.put(toolName, new ArrayList<>());
        }
        List<String> versions = toolsVersions.get(toolName);
        if (toolVersion != null && !toolVersion.equals("") && versions.indexOf(toolVersion) == -1) {
            versions.add(toolVersion);
            toolsVersions.put(toolName, versions);
        }
    }
    for (String tool : toolsVersions.keySet()) {
        List<String> versions = toolsVersions.get(tool);
        String versionsStr = String.join(", ", versions);
        TableRow row = table.addRow(tool);
        table.setData(row.getIndex(), 0, tool);
        table.setData(row.getIndex(), 1, versionsStr);
    }
    return table;
}
Also used : Table(com.epam.pipeline.manager.pipeline.documents.templates.structure.Table) HashMap(java.util.HashMap) TableRow(com.epam.pipeline.manager.pipeline.documents.templates.structure.TableRow) ArrayList(java.util.ArrayList) List(java.util.List) Tool(com.epam.pipeline.entity.pipeline.Tool) Placeholder(com.epam.pipeline.manager.pipeline.documents.templates.processors.base.Placeholder)

Aggregations

Table (com.epam.pipeline.manager.pipeline.documents.templates.structure.Table)4 Placeholder (com.epam.pipeline.manager.pipeline.documents.templates.processors.base.Placeholder)3 TableRow (com.epam.pipeline.manager.pipeline.documents.templates.structure.TableRow)3 GitRepositoryEntry (com.epam.pipeline.entity.git.GitRepositoryEntry)1 Tool (com.epam.pipeline.entity.pipeline.Tool)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 XWPFParagraph (org.apache.poi.xwpf.usermodel.XWPFParagraph)1 XWPFRun (org.apache.poi.xwpf.usermodel.XWPFRun)1 XWPFTable (org.apache.poi.xwpf.usermodel.XWPFTable)1 XWPFTableCell (org.apache.poi.xwpf.usermodel.XWPFTableCell)1 XWPFTableRow (org.apache.poi.xwpf.usermodel.XWPFTableRow)1 CTJc (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc)1 CTTblBorders (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblBorders)1 CTTblPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr)1