diff --git a/pom.xml b/pom.xml index fd3e764..81e64ac 100644 --- a/pom.xml +++ b/pom.xml @@ -113,6 +113,12 @@ vaadin-core true + + org.projectlombok + lombok + 1.18.34 + provided + jakarta.servlet jakarta.servlet-api diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java index 2616d73..ea8d033 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java @@ -82,12 +82,12 @@ protected boolean isExportable(Grid.Column column) { @SuppressWarnings({"unchecked", "rawtypes"}) protected Stream getDataStream(Query newQuery) { - Stream stream = exporter.grid.getDataProvider().fetch(newQuery); + Stream stream = exporter.getGrid().getDataProvider().fetch(newQuery); if (stream.isParallel()) { LoggerFactory.getLogger(DataCommunicator.class) .debug( "Data provider {} has returned " + "parallel stream on 'fetch' call", - exporter.grid.getDataProvider().getClass()); + exporter.getGrid().getDataProvider().getClass()); stream = stream.collect(Collectors.toList()).stream(); assert !stream.isParallel(); } @@ -142,11 +142,13 @@ private String renderCellTextContent(Grid grid, Column column, String colu } protected Stream obtainDataStream(DataProvider dataProvider) { + Grid grid = exporter.getGrid(); + Object filter = null; try { Method method = DataCommunicator.class.getDeclaredMethod("getFilter"); method.setAccessible(true); - filter = method.invoke(exporter.grid.getDataCommunicator()); + filter = method.invoke(grid.getDataCommunicator()); } catch (Exception e) { LOGGER.error("Unable to get filter from DataCommunicator", e); } @@ -154,19 +156,19 @@ protected Stream obtainDataStream(DataProvider dataProvider) { Stream dataStream; // special handling for hierarchical data provider - if (exporter.grid.getDataProvider() instanceof HierarchicalDataProvider) { - return obtainFlattenedHierarchicalDataStream(exporter.grid); + if (grid.getDataProvider() instanceof HierarchicalDataProvider) { + return obtainFlattenedHierarchicalDataStream(grid); } else if (dataProvider instanceof AbstractBackEndDataProvider) { - GridLazyDataView gridLazyDataView = exporter.grid.getLazyDataView(); + GridLazyDataView gridLazyDataView = grid.getLazyDataView(); dataStream = gridLazyDataView.getItems(); } else { @SuppressWarnings({"rawtypes", "unchecked"}) Query streamQuery = new Query<>( 0, - exporter.grid.getDataProvider().size(new Query(filter)), - exporter.grid.getDataCommunicator().getBackEndSorting(), - exporter.grid.getDataCommunicator().getInMemorySorting(), + grid.getDataProvider().size(new Query(filter)), + grid.getDataCommunicator().getBackEndSorting(), + grid.getDataCommunicator().getInMemorySorting(), filter); dataStream = getDataStream(streamQuery); } @@ -181,7 +183,9 @@ private Stream obtainFlattenedHierarchicalDataStream(final Grid grid) { private ArrayList fetchDataRecursive(final Grid grid, T parent) { ArrayList result = new ArrayList<>(); - if (parent != null) result.add(parent); + if (parent != null) { + result.add(parent); + } HierarchicalDataProvider hDataProvider = (HierarchicalDataProvider) grid.getDataProvider(); diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ConcurrentDownloadTimeoutEvent.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ConcurrentDownloadTimeoutEvent.java index 6b62d45..4861ed6 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ConcurrentDownloadTimeoutEvent.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ConcurrentDownloadTimeoutEvent.java @@ -1,3 +1,22 @@ +/*- + * #%L + * Grid Exporter Add-on + * %% + * Copyright (C) 2022 - 2024 Flowing Code + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ package com.flowingcode.vaadin.addons.gridexporter; import java.util.EventObject; diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ConcurrentStreamResourceWriter.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ConcurrentStreamResourceWriter.java index 76b7574..28fcd11 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ConcurrentStreamResourceWriter.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ConcurrentStreamResourceWriter.java @@ -1,3 +1,22 @@ +/*- + * #%L + * Grid Exporter Add-on + * %% + * Copyright (C) 2022 - 2024 Flowing Code + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ package com.flowingcode.vaadin.addons.gridexporter; import com.vaadin.flow.component.UI; @@ -268,4 +287,4 @@ public final void accept(OutputStream stream, VaadinSession session) throws IOEx } } -} \ No newline at end of file +} diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java index dd470b1..0075058 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java @@ -21,8 +21,7 @@ package com.flowingcode.vaadin.addons.gridexporter; import com.opencsv.CSVWriter; -import com.vaadin.flow.data.binder.BeanPropertySet; -import com.vaadin.flow.data.binder.PropertySet; +import com.vaadin.flow.component.grid.Grid; import com.vaadin.flow.server.VaadinSession; import java.io.IOException; import java.io.OutputStream; @@ -30,7 +29,6 @@ import java.nio.charset.StandardCharsets; import java.util.List; import java.util.stream.Collectors; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.slf4j.Logger; @@ -57,16 +55,17 @@ public void accept(OutputStream out, VaadinSession session) throws IOException { session.lock(); try { + Grid grid = exporter.getGrid(); exporter.setColumns( - exporter.grid.getColumns().stream() + grid.getColumns().stream() .filter(this::isExportable) .collect(Collectors.toList())); - headers = getGridHeaders(exporter.grid).stream().map(Pair::getLeft).toArray(String[]::new); - data = obtainDataStream(exporter.grid.getDataProvider()) + headers = getGridHeaders(grid).stream().map(Pair::getLeft).toArray(String[]::new); + data = obtainDataStream(grid.getDataProvider()) .map(this::buildRow) .collect(Collectors.toList()); - footers = getGridFooters(exporter.grid).stream() + footers = getGridFooters(grid).stream() .filter(pair -> StringUtils.isNotBlank(pair.getKey())) .map(Pair::getLeft) .toArray(String[]::new); @@ -90,12 +89,11 @@ public void accept(OutputStream out, VaadinSession session) throws IOException { } } - @SuppressWarnings("unchecked") private String[] buildRow(T item) { - if (exporter.propertySet == null) { - exporter.propertySet = (PropertySet) BeanPropertySet.get(item.getClass()); + + if (exporter.getColumns().isEmpty()) { + throw new IllegalStateException("Grid has no columns"); } - if (exporter.getColumns().isEmpty()) throw new IllegalStateException("Grid has no columns"); String[] result = new String[exporter.getColumns().size()]; int[] currentColumn = new int[1]; diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java index 5a37bfc..b67fb33 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java @@ -17,13 +17,11 @@ * limitations under the License. * #L% */ -/** */ package com.flowingcode.vaadin.addons.gridexporter; import com.vaadin.flow.component.grid.ColumnTextAlign; +import com.vaadin.flow.component.grid.Grid; import com.vaadin.flow.component.grid.Grid.Column; -import com.vaadin.flow.data.binder.BeanPropertySet; -import com.vaadin.flow.data.binder.PropertySet; import com.vaadin.flow.data.provider.DataProvider; import com.vaadin.flow.server.VaadinSession; import java.io.IOException; @@ -80,8 +78,9 @@ protected XWPFDocument createDoc(VaadinSession session) throws IOException { } private XWPFDocument createDoc() throws IOException { + Grid grid = exporter.getGrid(); exporter.setColumns( - exporter.grid.getColumns().stream() + grid.getColumns().stream() .filter(this::isExportable) .collect(Collectors.toList())); @@ -129,17 +128,17 @@ private XWPFDocument createDoc() throws IOException { cctblgridcol, "" + Math.round(9638 / exporter.getColumns().size())); }); - List>> headers = getGridHeaders(exporter.grid); + List>> headers = getGridHeaders(grid); XWPFTableCell cell = findCellWithPlaceHolder(table, exporter.headersPlaceHolder); if (cell != null) { fillHeaderOrFooter(table, cell, headers, true, exporter.headersPlaceHolder); } cell = findCellWithPlaceHolder(table, exporter.dataPlaceHolder); - fillData(table, cell, exporter.grid.getDataProvider()); + fillData(table, cell, grid.getDataProvider()); cell = findCellWithPlaceHolder(table, exporter.footersPlaceHolder); - List>> footers = getGridFooters(exporter.grid); + List>> footers = getGridFooters(grid); if (cell != null) { fillHeaderOrFooter(table, cell, footers, false, exporter.footersPlaceHolder); } @@ -178,17 +177,16 @@ private void fillData(XWPFTable table, XWPFTableCell dataCell, DataProvider) BeanPropertySet.get(item.getClass()); + + if (exporter.getColumns().isEmpty()) { + throw new IllegalStateException("Grid has no columns"); } - if (exporter.getColumns().isEmpty()) throw new IllegalStateException("Grid has no columns"); int[] currentColumn = new int[1]; currentColumn[0] = row.getTableCells().indexOf(startingCell); @@ -200,7 +198,9 @@ private void buildRow( XWPFTableCell currentCell = startingCell; if (row.getTableCells().indexOf(startingCell) < currentColumn[0]) { currentCell = startingCell.getTableRow().getCell(currentColumn[0]); - if (currentCell == null) currentCell = startingCell.getTableRow().createCell(); + if (currentCell == null) { + currentCell = startingCell.getTableRow().createCell(); + } } PoiHelper.setWidth(currentCell, "" + Math.round(9638 / exporter.getColumns().size())); currentCell.getCTTc().setTcPr(tcpr); @@ -226,12 +226,12 @@ private void buildCell(Object value, XWPFTableCell cell, CTPPr ctpPr, CTRPr ctrP if (value == null) { setCellValue("", cell, exporter.dataPlaceHolder, ctpPr, ctrPr); } else if (value instanceof Boolean) { - setCellValue("" + (Boolean) value, cell, exporter.dataPlaceHolder, ctpPr, ctrPr); + setCellValue("" + value, cell, exporter.dataPlaceHolder, ctpPr, ctrPr); } else if (value instanceof Calendar) { Calendar calendar = (Calendar) value; setCellValue("" + calendar.getTime(), cell, exporter.dataPlaceHolder, ctpPr, ctrPr); } else if (value instanceof Double) { - setCellValue("" + (Double) value, cell, exporter.dataPlaceHolder, ctpPr, ctrPr); + setCellValue("" + value, cell, exporter.dataPlaceHolder, ctpPr, ctrPr); } else { setCellValue("" + value.toString(), cell, exporter.dataPlaceHolder, ctpPr, ctrPr); } @@ -350,9 +350,12 @@ private XWPFTable findTable(XWPFDocument doc) { .forEach( row -> { XWPFTableCell cell = row.getCell(0); - if (cell.getText().equals(exporter.headersPlaceHolder)) + if (cell.getText().equals(exporter.headersPlaceHolder)) { foundHeaders[0] = true; - if (cell.getText().equals(exporter.dataPlaceHolder)) foundData[0] = true; + } + if (cell.getText().equals(exporter.dataPlaceHolder)) { + foundData[0] = true; + } }); if (foundHeaders[0] && foundData[0]) { result[0] = table; diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelStreamResourceWriter.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelStreamResourceWriter.java index 7a3587a..fc70c6c 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelStreamResourceWriter.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelStreamResourceWriter.java @@ -20,6 +20,13 @@ /** */ package com.flowingcode.vaadin.addons.gridexporter; +import com.vaadin.flow.component.ComponentUtil; +import com.vaadin.flow.component.grid.ColumnTextAlign; +import com.vaadin.flow.component.grid.Grid; +import com.vaadin.flow.component.grid.Grid.Column; +import com.vaadin.flow.data.provider.DataProvider; +import com.vaadin.flow.function.ValueProvider; +import com.vaadin.flow.server.VaadinSession; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -52,14 +59,6 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.vaadin.flow.component.ComponentUtil; -import com.vaadin.flow.component.grid.ColumnTextAlign; -import com.vaadin.flow.component.grid.Grid.Column; -import com.vaadin.flow.data.binder.BeanPropertySet; -import com.vaadin.flow.data.binder.PropertySet; -import com.vaadin.flow.data.provider.DataProvider; -import com.vaadin.flow.function.ValueProvider; -import com.vaadin.flow.server.VaadinSession; /** * @author mlopez */ @@ -70,7 +69,7 @@ class ExcelStreamResourceWriter extends BaseStreamResourceWriter { private static final String DEFAULT_TEMPLATE = "/template.xlsx"; private static final String COLUMN_CELLSTYLE_MAP = "colum-cellstyle-map"; private static enum ExcelCellType {HEADER,CELL,FOOTER}; - + public ExcelStreamResourceWriter(GridExporter exporter, String template) { super(exporter, template, DEFAULT_TEMPLATE); } @@ -83,7 +82,8 @@ public void accept(OutputStream out, VaadinSession session) throws IOException { private Workbook createWorkbook(VaadinSession session) { session.lock(); try { - exporter.setColumns(exporter.grid.getColumns().stream().filter(this::isExportable) + Grid grid = exporter.getGrid(); + exporter.setColumns(grid.getColumns().stream().filter(this::isExportable) .peek(col -> ComponentUtil.setData(col, COLUMN_CELLSTYLE_MAP, null)) .collect(Collectors.toList())); Workbook wb = getBaseTemplateWorkbook(); @@ -95,7 +95,7 @@ private Workbook createWorkbook(VaadinSession session) { } Cell cell = findCellWithPlaceHolder(sheet, exporter.headersPlaceHolder); - List>> headers = getGridHeaders(exporter.grid); + List>> headers = getGridHeaders(grid); fillHeaderOrFooter(sheet, cell, headers, true); if (exporter.autoMergeTitle && titleCell != null && exporter.getColumns().size()>1) { @@ -114,7 +114,7 @@ private Workbook createWorkbook(VaadinSession session) { Sheet tempSheet = wb.cloneSheet(exporter.sheetNumber); int lastRow = - fillData(sheet, cell, exporter.grid.getDataProvider(), dataRange, titleCell != null); + fillData(sheet, cell, grid.getDataProvider(), dataRange, titleCell != null); applyConditionalFormattings(sheet, dataRange); @@ -123,7 +123,7 @@ private Workbook createWorkbook(VaadinSession session) { wb.removeSheetAt(exporter.sheetNumber + 1); cell = findCellWithPlaceHolder(sheet, exporter.footersPlaceHolder); - List>> footers = getGridFooters(exporter.grid); + List>> footers = getGridFooters(grid); if (cell != null) { fillHeaderOrFooter(sheet, cell, footers, false); } @@ -235,12 +235,11 @@ private int fillData( return dataRange.getLastRow(); } - @SuppressWarnings("unchecked") private void buildRow(T item, Sheet sheet, Cell startingCell) { - if (exporter.propertySet == null) { - exporter.propertySet = (PropertySet) BeanPropertySet.get(item.getClass()); + + if (exporter.getColumns().isEmpty()) { + throw new IllegalStateException("Grid has no columns"); } - if (exporter.getColumns().isEmpty()) throw new IllegalStateException("Grid has no columns"); int[] currentColumn = new int[1]; currentColumn[0] = startingCell.getColumnIndex(); diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/FooterToolbar.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/FooterToolbar.java index 6eef233..ade50c5 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/FooterToolbar.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/FooterToolbar.java @@ -28,7 +28,7 @@ import java.util.List; /** - * + * * Footer toolbar for export grid. * */ @@ -52,7 +52,7 @@ public void add(List items) { /** * Checks if any {@link FooterToolbarItem} has been added. - * + * * @return true if has {@link FooterToolbarItem} added. */ public boolean hasItems() { @@ -65,7 +65,7 @@ protected void onAttach(AttachEvent attachEvent) { super.onAttach(attachEvent); items.stream().sorted(Comparator.comparing(FooterToolbarItem::getPosition)) - .map(FooterToolbarItem::getComponent).forEach(this.getContent()::add); + .map(FooterToolbarItem::getComponent).forEach(getContent()::add); } } diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/FooterToolbarItem.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/FooterToolbarItem.java index 85d50f2..747a084 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/FooterToolbarItem.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/FooterToolbarItem.java @@ -35,7 +35,7 @@ public class FooterToolbarItem implements Serializable { public FooterToolbarItem(Component component) { this.component = component; - this.position = FooterToolbarItemPosition.AFTER_EXPORT_BUTTONS; + position = FooterToolbarItemPosition.AFTER_EXPORT_BUTTONS; } public FooterToolbarItem(Component component, FooterToolbarItemPosition position) { diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridExporter.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridExporter.java index 736d4b4..1011723 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridExporter.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridExporter.java @@ -30,6 +30,7 @@ import com.vaadin.flow.component.grid.Grid.Column; import com.vaadin.flow.component.html.Anchor; import com.vaadin.flow.component.orderedlayout.FlexComponent.JustifyContentMode; +import com.vaadin.flow.data.binder.BeanPropertySet; import com.vaadin.flow.data.binder.PropertyDefinition; import com.vaadin.flow.data.binder.PropertySet; import com.vaadin.flow.data.renderer.BasicRenderer; @@ -59,6 +60,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.Stream; +import lombok.Getter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -100,7 +102,8 @@ public class GridExporter implements Serializable { static final String COLUMN_FOOTER = "column-footer"; static final String COLUMN_POSITION = "column-position"; - Grid grid; + @Getter + private Grid grid; String titlePlaceHolder = "${title}"; String headersPlaceHolder = "${headers}"; @@ -108,7 +111,7 @@ public class GridExporter implements Serializable { String footersPlaceHolder = "${footers}"; List> columns; - PropertySet propertySet; + private PropertySet propertySet; Map additionalPlaceHolders = new HashMap<>(); @@ -224,6 +227,9 @@ Object extractValueFromColumn(T item, Column column) { // if there is a key, assume that the property can be retrieved from it if (value == null && column.getKey() != null) { + if (propertySet == null) { + propertySet = (PropertySet) BeanPropertySet.get(item.getClass()); + } Optional> propertyDefinition = propertySet.getProperty(column.getKey()); if (propertyDefinition.isPresent()) { diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterConcurrentSettings.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterConcurrentSettings.java index 559f074..e6d97ab 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterConcurrentSettings.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterConcurrentSettings.java @@ -1,3 +1,22 @@ +/*- + * #%L + * Grid Exporter Add-on + * %% + * Copyright (C) 2022 - 2024 Flowing Code + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ package com.flowingcode.vaadin.addons.gridexporter; import com.vaadin.flow.function.SerializableConsumer; diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/PdfStreamResourceWriter.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/PdfStreamResourceWriter.java index f99cb55..1d8d18a 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/PdfStreamResourceWriter.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/PdfStreamResourceWriter.java @@ -17,7 +17,6 @@ * limitations under the License. * #L% */ -/** */ package com.flowingcode.vaadin.addons.gridexporter; import com.vaadin.flow.server.VaadinSession; @@ -52,10 +51,10 @@ public void accept(OutputStream out, VaadinSession session) throws IOException { createDoc(session).write(baos); WordprocessingMLPackage wordMLPackage = - WordprocessingMLPackage.load(new ByteArrayInputStream(baos.toByteArray())); - MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart(); + WordprocessingMLPackage.load(new ByteArrayInputStream(baos.toByteArray())); + MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart(); - Docx4J.toPDF(wordMLPackage, out); + Docx4J.toPDF(wordMLPackage, out); } catch (Docx4JException e) { throw new RuntimeException("Problem when exporting data to PDF file", e); } diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/ConfigurableConcurrentStreamResourceWriter.java b/src/test/java/com/flowingcode/vaadin/addons/gridexporter/ConfigurableConcurrentStreamResourceWriter.java index 0b32a94..b686a97 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/ConfigurableConcurrentStreamResourceWriter.java +++ b/src/test/java/com/flowingcode/vaadin/addons/gridexporter/ConfigurableConcurrentStreamResourceWriter.java @@ -1,3 +1,22 @@ +/*- + * #%L + * Grid Exporter Add-on + * %% + * Copyright (C) 2022 - 2024 Flowing Code + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ package com.flowingcode.vaadin.addons.gridexporter; import com.vaadin.flow.component.UI; diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/FakerInstance.java b/src/test/java/com/flowingcode/vaadin/addons/gridexporter/FakerInstance.java index d10dc1c..613bc2a 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/FakerInstance.java +++ b/src/test/java/com/flowingcode/vaadin/addons/gridexporter/FakerInstance.java @@ -1,3 +1,22 @@ +/*- + * #%L + * Grid Exporter Add-on + * %% + * Copyright (C) 2022 - 2024 Flowing Code + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ package com.flowingcode.vaadin.addons.gridexporter; import com.github.javafaker.Faker; diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/VaadinServiceInitListenerImpl.java b/src/test/java/com/flowingcode/vaadin/addons/gridexporter/VaadinServiceInitListenerImpl.java index cb06b63..1bb63e5 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/VaadinServiceInitListenerImpl.java +++ b/src/test/java/com/flowingcode/vaadin/addons/gridexporter/VaadinServiceInitListenerImpl.java @@ -1,3 +1,22 @@ +/*- + * #%L + * Grid Exporter Add-on + * %% + * Copyright (C) 2022 - 2024 Flowing Code + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ package com.flowingcode.vaadin.addons.gridexporter; import com.vaadin.flow.component.notification.Notification; diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/test/ConcurrentExportTests.java b/src/test/java/com/flowingcode/vaadin/addons/gridexporter/test/ConcurrentExportTests.java index 1aa479c..6bcd746 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/test/ConcurrentExportTests.java +++ b/src/test/java/com/flowingcode/vaadin/addons/gridexporter/test/ConcurrentExportTests.java @@ -1,3 +1,22 @@ +/*- + * #%L + * Grid Exporter Add-on + * %% + * Copyright (C) 2022 - 2024 Flowing Code + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ package com.flowingcode.vaadin.addons.gridexporter.test; import static org.apache.commons.io.output.NullOutputStream.NULL_OUTPUT_STREAM; @@ -407,4 +426,4 @@ public void testFailOnUiClose() throws InterruptedException, BrokenBarrierExcept } -} \ No newline at end of file +}