From 802bac0a1af84fdfb1f10c528926b8999eb6daa6 Mon Sep 17 00:00:00 2001 From: Javier Godoy <11554739+javier-godoy@users.noreply.github.com> Date: Tue, 18 Mar 2025 14:42:58 -0300 Subject: [PATCH] chore(demo): remove GridExporterBigDatasetDemo --- .../GridExporterBigDatasetDemo.java | 113 ------------------ .../gridexporter/GridExporterDemoView.java | 1 - 2 files changed, 114 deletions(-) delete mode 100644 src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterBigDatasetDemo.java diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterBigDatasetDemo.java b/src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterBigDatasetDemo.java deleted file mode 100644 index 0a0c484..0000000 --- a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterBigDatasetDemo.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * #%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.flowingcode.vaadin.addons.demo.DemoSource; -import com.flowingcode.vaadin.addons.gridhelpers.GridHelper; -import com.flowingcode.vaadin.addons.gridhelpers.HeightMode; -import com.github.javafaker.Faker; -import com.vaadin.flow.component.Html; -import com.vaadin.flow.component.grid.Grid; -import com.vaadin.flow.component.grid.Grid.Column; -import com.vaadin.flow.component.html.Div; -import com.vaadin.flow.router.PageTitle; -import com.vaadin.flow.router.Route; -import java.io.IOException; -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import org.apache.poi.EncryptedDocumentException; - -@DemoSource -@PageTitle("Big Dataset") -@Route(value = "gridexporter/bigdataset", layout = GridExporterDemoView.class) -@SuppressWarnings("serial") -public class GridExporterBigDatasetDemo extends Div { - - private static final Faker faker = FakerInstance.get(); - - public GridExporterBigDatasetDemo() throws EncryptedDocumentException, IOException { - Grid grid = new Grid<>(Person.class); - grid.removeAllColumns(); - grid.setColumnReorderingAllowed(true); - Column nameCol = grid.addColumn("name").setHeader("Name"); - Column lastNameCol = grid.addColumn("lastName").setHeader("Last Name"); - Column budgetCol = grid.addColumn(item -> "$" + item.getBudget()).setHeader("Budget"); - BigDecimal[] total = new BigDecimal[1]; - total[0] = BigDecimal.ZERO; - List persons = - IntStream.range(0, 1400) - .asLongStream() - .mapToObj( - number -> { - Double budget = faker.number().randomDouble(2, 10000, 100000); - total[0] = total[0].add(BigDecimal.valueOf(budget)); - budgetCol.setFooter("$" + total[0]); - return new Person( - faker.name().firstName(), - faker.name().lastName(), - faker.number().numberBetween(15, 50), - budget); - }).collect(Collectors.toList()); - grid.setItems(query->persons.stream().skip(query.getOffset()).limit(query.getLimit())); - grid.setWidthFull(); - setSizeFull(); - GridExporter exporter = GridExporter.createFor(grid); - exporter.setAutoSizeColumns(false); - exporter.setExportValue(budgetCol, item -> "" + item.getBudget()); - exporter.setColumnPosition(lastNameCol, 1); - exporter.setTitle("People information"); - exporter.setFileName( - "GridExport" + new SimpleDateFormat("yyyyddMM").format(Calendar.getInstance().getTime())); - - // show-source add(grid); - - // #if vaadin eq 0 - GridHelper.setHeightByRows(grid, 6); - GridHelper.setHeightMode(grid, HeightMode.ROW); - Html block1 = new Html("
" - + "This configuration prepares the exporter for the BigDataset demo, enabling it to manage resource-intensive " - + "document generation tasks effectively. In this setup, an upper limit of 10 is established for the cost of " - + "concurrent downloads, and the big dataset exporter is configured with a cost of 9, while other exporters " - + "handling smaller datasets retain the default cost of 1. This customization allows a combination of one large " - + "dataset download alongside one small dataset download, or up to 10 concurrent downloads of smaller datasets " - + "when no big dataset is being exported." + "
"); - - Html block2 = new Html("
" - + "Additionally, setConcurrentDownloadTimeout enforces a timeout for acquiring the necessary permits " - + "during a download operation. If the permits are not obtained within the specified timeframe, the download " - + "request will be aborted and the DownloadTimeoutEvent listener will execute, preventing prolonged " - + "waiting periods, especially during peak system loads." + "
"); - - - add(block1, grid, block2); - // #endif - // begin-block concurrent - exporter.setConcurrentDownloadCost(9); - // end-block - - // Prevents additional downloads from starting while one is already in progress - exporter.setDisableOnClick(true); - } - -} diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterDemoView.java b/src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterDemoView.java index 5df5d04..15fb443 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterDemoView.java +++ b/src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterDemoView.java @@ -40,7 +40,6 @@ public GridExporterDemoView() { addDemo(GridExporterCustomLinkDemo.class); addDemo(GridExporterCustomColumnsDemo.class); addDemo(GridExporterHierarchicalDataDemo.class); - addDemo(GridExporterBigDatasetDemo.class); addDemo(GridExporterMultipleHeaderRowsDemo.class); setSizeFull(); }