diff --git a/.run/Run Demo.run.xml b/.run/Run Demo.run.xml index 764b3b9..b12efb7 100644 --- a/.run/Run Demo.run.xml +++ b/.run/Run Demo.run.xml @@ -1,7 +1,7 @@ - \ No newline at end of file + diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..00c54c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,24 @@ +# 1.0.0 + +Initial release of the fork + +## Differences to [dynamicreports/dynamicreports-core](https://github.com/dynamicreports/dynamicreports/tree/f7d73961462f3f13cbc27c91df90d4cc3ccc669e/dynamicreports-core) +* Renamed ``net.sf.dynamicreports`` to ``software.xdev.dynamicreports`` to prevent conflicts with existing installations +* Dependency shedding + * Removed [``Defaults``](./src/main/java/software/xdev/dynamicreports/report/defaults/Defaults.java)-XML subsystem; can be supplied manually to the builder or using [Java Service Loading](https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html) + * ``jakarta.xml.bind:jakarta.xml.bind-api`` + * ``org.glassfish.jaxb:jaxb-runtime`` + * Removed barcode subsystem + * ``net.sf.barcode4j:barcode4j`` + * ``com.google.zxing:core`` + * ``net.sourceforge.barbecue:barbecue`` + * Removed charts subsystem + * Removed boolean to image subsystem + * ``org.apache.xmlgraphics:batik-bridge`` + * Dropped support for ``XLS`` as the required dependency was never shipped + * ``XLSX`` still works as expected + * Removed ``org.apache.commons:commons-text`` as it was only used on a single unused line of code +* Removed XML subsystem as XML exports were never producing valid XML +* Removed half-way implemented Image subsystem as it is unused +* Updated dependencies to lastest versions +* Fixed compile errors diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 79c7cf2..32be5c5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,10 +34,10 @@ You should have the following things installed: * Ensure that the JDK/Java-Version is correct -## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/standard-maven-template/release.yml?branch=master)](https://github.com/xdev-software/standard-maven-template/actions/workflows/release.yml) +## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/dynamicreports-core-for-grid-exporter/release.yml?branch=master)](https://github.com/xdev-software/dynamicreports-core-for-grid-exporter/actions/workflows/release.yml) Before releasing: -* Consider doing a [test-deployment](https://github.com/xdev-software/standard-maven-template/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing. +* Consider doing a [test-deployment](https://github.com/xdev-software/dynamicreports-core-for-grid-exporter/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing. * Check the [changelog](CHANGELOG.md) If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes diff --git a/LICENSE b/LICENSE index 2316c75..0a04128 100644 --- a/LICENSE +++ b/LICENSE @@ -1,201 +1,165 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2023 XDEV Software - - 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. + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md index e288929..8696c22 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ -[![Latest version](https://img.shields.io/maven-central/v/com.xdev-software/standard-maven-template?logo=apache%20maven)](https://mvnrepository.com/artifact/com.xdev-software/standard-maven-template) -[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/standard-maven-template/checkBuild.yml?branch=develop)](https://github.com/xdev-software/standard-maven-template/actions/workflows/checkBuild.yml?query=branch%3Adevelop) -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_standard-maven-template&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_standard-maven-template) +[![Latest version](https://img.shields.io/maven-central/v/com.xdev-software/dynamicreports-core-for-grid-exporter?logo=apache%20maven)](https://mvnrepository.com/artifact/com.xdev-software/dynamicreports-core-for-grid-exporter) +[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/dynamicreports-core-for-grid-exporter/checkBuild.yml?branch=develop)](https://github.com/xdev-software/dynamicreports-core-for-grid-exporter/actions/workflows/checkBuild.yml?query=branch%3Adevelop) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_dynamicreports-core-for-grid-exporter&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_dynamicreports-core-for-grid-exporter) -# standard-maven-template +# dynamicreports-core-for-grid-exporter +This is a fork of [dynamicreports-core](https://github.com/dynamicreports/dynamicreports) and specially designed for [XDEV's Vaadin Grid Exporer](https://github.com/xdev-software/vaadin-grid-exporter). +Differences from the original project are roughly descibed in the [changelog](./CHANGELOG.md). ## Installation -[Installation guide for the latest release](https://github.com/xdev-software/standard-maven-template/releases/latest#Installation) +[Installation guide for the latest release](https://github.com/xdev-software/dynamicreports-core-for-grid-exporter/releases/latest#Installation) ## Support @@ -16,4 +18,4 @@ If you need support as soon as possible and you can't wait for any pull request, See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project. ## Dependencies and Licenses -View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/standard-maven-template/dependencies/) +View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/dynamicreports-core-for-grid-exporter/dependencies/) diff --git a/SECURITY.md b/SECURITY.md index 92188f3..81520f8 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,4 +2,4 @@ ## Reporting a Vulnerability -Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/standard-maven-template/security/advisories/new). +Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/dynamicreports-core-for-grid-exporter/security/advisories/new). diff --git a/standard-maven-template-demo/pom.xml b/dynamicreports-core-for-grid-exporter-demo/pom.xml similarity index 59% rename from standard-maven-template-demo/pom.xml rename to dynamicreports-core-for-grid-exporter-demo/pom.xml index 10d5305..44b927e 100644 --- a/standard-maven-template-demo/pom.xml +++ b/dynamicreports-core-for-grid-exporter-demo/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.xdev-software - standard-maven-template-demo + dynamicreports-core-for-grid-exporter-demo 1.0.0-SNAPSHOT jar @@ -16,16 +16,7 @@ https://xdev.software - - - Apache License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt - - - - apache_v2 - 17 ${javaVersion} @@ -38,7 +29,7 @@ com.xdev-software - standard-maven-template + dynamicreports-core-for-grid-exporter ${project.version} @@ -58,6 +49,34 @@ + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + + + ${mainClass} + + + true + + + + jar-with-dependencies + + false + + + + make-assembly + package + + single + + + + diff --git a/dynamicreports-core-for-grid-exporter-demo/src/main/java/software/xdev/Application.java b/dynamicreports-core-for-grid-exporter-demo/src/main/java/software/xdev/Application.java new file mode 100644 index 0000000..33242b5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter-demo/src/main/java/software/xdev/Application.java @@ -0,0 +1,32 @@ +package software.xdev; + +import java.util.stream.Stream; + +import software.xdev.dynamicreports.jasper.builder.export.Exporters; +import software.xdev.dynamicreports.report.builder.DynamicReports; +import software.xdev.dynamicreports.report.builder.column.ColumnBuilders; +import software.xdev.dynamicreports.report.exception.DRException; + + +public class Application +{ + @SuppressWarnings("java:S106") // Just a simple demo + public static void main(final String[] args) throws DRException + { + DynamicReports.report() + .setDataSource(Stream.of("a", "b", "c") + .map(DummyDTO::new) + .toList()) + .columns(new ColumnBuilders() + .column("value", String.class)) + .export(Exporters.csvExporter(System.out)); + } + + public record DummyDTO(String value) + { + public String getValue() + { + return this.value(); + } + } +} diff --git a/standard-maven-template/pom.xml b/dynamicreports-core-for-grid-exporter/pom.xml similarity index 79% rename from standard-maven-template/pom.xml rename to dynamicreports-core-for-grid-exporter/pom.xml index 9f74dbf..829ed58 100644 --- a/standard-maven-template/pom.xml +++ b/dynamicreports-core-for-grid-exporter/pom.xml @@ -5,17 +5,17 @@ 4.0.0 com.xdev-software - standard-maven-template + dynamicreports-core-for-grid-exporter 1.0.0-SNAPSHOT jar - standard-maven-template - standard-maven-template - https://github.com/xdev-software/standard-maven-template + dynamicreports-core-for-grid-exporter + dynamicreports-core-for-grid-exporter + https://github.com/xdev-software/dynamicreports-core-for-grid-exporter - https://github.com/xdev-software/standard-maven-template - https://github.com/xdev-software/standard-maven-template.git + https://github.com/xdev-software/dynamicreports-core-for-grid-exporter + https://github.com/xdev-software/dynamicreports-core-for-grid-exporter.git 2023 @@ -35,8 +35,8 @@ - Apache License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt + GNU Lesser General Public License version 3 + https://www.gnu.org/licenses/lgpl-3.0.en.html repo @@ -84,6 +84,28 @@ + + + + net.sf.jasperreports + jasperreports + 6.20.5 + + + + org.apache.commons + commons-lang3 + 3.12.0 + + + + org.junit.jupiter + junit-jupiter + 5.9.2 + test + + + @@ -96,7 +118,7 @@ -
com/mycila/maven/plugin/license/templates/APACHE-2.txt
+
com/mycila/maven/plugin/license/templates/LGPL-3.txt
src/main/java/** src/test/java/** @@ -158,6 +180,11 @@ + + + maven-surefire-plugin + 3.0.0-M9 + diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignBand.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignBand.java new file mode 100644 index 0000000..769f7af --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignBand.java @@ -0,0 +1,151 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.definition.DRIDesignBand; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.SplitType; + +/** + *

DRDesignBand class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignBand implements DRIDesignBand { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private SplitType splitType; + private DRDesignList list; + private DRDesignComponent bandComponent; + private Integer height; + private DRIDesignExpression printWhenExpression; + + /** + *

Constructor for DRDesignBand.

+ * + * @param name a {@link java.lang.String} object. + */ + public DRDesignBand(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public SplitType getSplitType() { + return splitType; + } + + /** + *

Setter for the field splitType.

+ * + * @param splitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setSplitType(SplitType splitType) { + this.splitType = splitType; + } + + /** {@inheritDoc} */ + @Override + public DRDesignList getList() { + return list; + } + + /** + *

Setter for the field list.

+ * + * @param list a {@link software.xdev.dynamicreports.design.base.component.DRDesignList} object. + */ + public void setList(DRDesignList list) { + this.list = list; + } + + /** + *

addComponent.

+ * + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public void addComponent(DRDesignComponent component) { + list.addComponent(component); + } + + /** + *

addComponent.

+ * + * @param index a int. + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public void addComponent(int index, DRDesignComponent component) { + list.addComponent(index, component); + } + + /** {@inheritDoc} */ + @Override + public DRDesignComponent getBandComponent() { + return bandComponent; + } + + /** + *

Setter for the field bandComponent.

+ * + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public void setBandComponent(DRDesignComponent component) { + this.bandComponent = component; + } + + /** {@inheritDoc} */ + @Override + public Integer getHeight() { + return height; + } + + /** + *

Setter for the field height.

+ * + * @param height a {@link java.lang.Integer} object. + */ + public void setHeight(Integer height) { + this.height = height; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getPrintWhenExpression() { + return printWhenExpression; + } + + /** + *

Setter for the field printWhenExpression.

+ * + * @param printWhenExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setPrintWhenExpression(DRIDesignExpression printWhenExpression) { + this.printWhenExpression = printWhenExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignDataset.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignDataset.java new file mode 100644 index 0000000..37530e7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignDataset.java @@ -0,0 +1,177 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.design.definition.DRIDesignField; +import software.xdev.dynamicreports.design.definition.DRIDesignSort; +import software.xdev.dynamicreports.design.definition.DRIDesignVariable; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignJasperExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSystemExpression; +import software.xdev.dynamicreports.design.transformation.DatasetExpressionTransform; +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; + +import java.util.Collection; + +/** + *

DRDesignDataset class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignDataset implements DRIDesignDataset { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DatasetExpressionTransform datasetExpressionTransform; + private DRDesignQuery query; + private DRIDesignExpression connectionExpression; + private DRIDesignExpression dataSourceExpression; + private DRIDesignExpression filterExpression; + + /** + *

Constructor for DRDesignDataset.

+ * + * @param datasetExpressionTransform a {@link software.xdev.dynamicreports.design.transformation.DatasetExpressionTransform} object. + */ + public DRDesignDataset(DatasetExpressionTransform datasetExpressionTransform) { + this.datasetExpressionTransform = datasetExpressionTransform; + this.name = ReportUtils.generateUniqueName("dataset"); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

Getter for the field datasetExpressionTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.DatasetExpressionTransform} object. + */ + public DatasetExpressionTransform getDatasetExpressionTransform() { + return datasetExpressionTransform; + } + + /** {@inheritDoc} */ + @Override + public Collection getFields() { + return datasetExpressionTransform.getFields(); + } + + /** {@inheritDoc} */ + @Override + public Collection getVariables() { + return datasetExpressionTransform.getVariables(); + } + + /** {@inheritDoc} */ + @Override + public Collection getSystemExpressions() { + return datasetExpressionTransform.getSystemExpressions(); + } + + /** {@inheritDoc} */ + @Override + public Collection getJasperExpressions() { + return datasetExpressionTransform.getJasperExpressions(); + } + + /** {@inheritDoc} */ + @Override + public Collection getSimpleExpressions() { + return datasetExpressionTransform.getSimpleExpressions(); + } + + /** {@inheritDoc} */ + @Override + public Collection getComplexExpressions() { + return datasetExpressionTransform.getComplexExpressions(); + } + + /** {@inheritDoc} */ + @Override + public Collection getSorts() { + return datasetExpressionTransform.getSorts(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignQuery getQuery() { + return query; + } + + /** + *

Setter for the field query.

+ * + * @param query a {@link software.xdev.dynamicreports.design.base.DRDesignQuery} object. + */ + public void setQuery(DRDesignQuery query) { + this.query = query; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getConnectionExpression() { + return connectionExpression; + } + + /** + *

Setter for the field connectionExpression.

+ * + * @param connectionExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setConnectionExpression(DRIDesignExpression connectionExpression) { + this.connectionExpression = connectionExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getDataSourceExpression() { + return dataSourceExpression; + } + + /** + *

Setter for the field dataSourceExpression.

+ * + * @param dataSourceExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setDataSourceExpression(DRIDesignExpression dataSourceExpression) { + this.dataSourceExpression = dataSourceExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getFilterExpression() { + return filterExpression; + } + + /** + *

Setter for the field filterExpression.

+ * + * @param filterExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setFilterExpression(DRIDesignExpression filterExpression) { + this.filterExpression = filterExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignField.java new file mode 100644 index 0000000..f8d022c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignField.java @@ -0,0 +1,103 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.definition.DRIDesignField; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignField class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignField implements DRIDesignField { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private Class valueClass; + private boolean external; + private String description; + + /** + *

Constructor for DRDesignField.

+ */ + public DRDesignField() { + this.external = false; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

Setter for the field name.

+ * + * @param name a {@link java.lang.String} object. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return valueClass; + } + + /** + *

Setter for the field valueClass.

+ * + * @param valueClass a {@link java.lang.Class} object. + */ + public void setValueClass(Class valueClass) { + this.valueClass = valueClass; + } + + /** {@inheritDoc} */ + @Override + public boolean isExternal() { + return external; + } + + /** + *

Setter for the field external.

+ * + * @param external a boolean. + */ + public void setExternal(boolean external) { + this.external = external; + } + + /** {@inheritDoc} */ + @Override + public String getDescription() { + return description; + } + + /** + *

Setter for the field description.

+ * + * @param description a {@link java.lang.String} object. + */ + public void setDescription(String description) { + this.description = description; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignGroup.java new file mode 100644 index 0000000..9884830 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignGroup.java @@ -0,0 +1,264 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRDesignGroup class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignGroup implements DRIDesignGroup { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRIDesignExpression groupExpression; + private List headerBands; + private List footerBands; + private boolean startInNewPage; + private boolean startInNewColumn; + private boolean reprintHeaderOnEachPage; + private boolean resetPageNumber; + private Integer minHeightToStartNewPage; + private GroupFooterPosition footerPosition; + private boolean keepTogether; + private boolean headerWithSubtotal; + + /** + *

Constructor for DRDesignGroup.

+ * + * @param name a {@link java.lang.String} object. + */ + public DRDesignGroup(String name) { + this.name = name; + init(); + } + + private void init() { + headerBands = new ArrayList(); + footerBands = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getGroupExpression() { + return groupExpression; + } + + /** + *

Setter for the field groupExpression.

+ * + * @param groupExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setGroupExpression(DRIDesignExpression groupExpression) { + this.groupExpression = groupExpression; + } + + /** {@inheritDoc} */ + @Override + public List getHeaderBands() { + return headerBands; + } + + /** + *

Setter for the field headerBands.

+ * + * @param headerBands a {@link java.util.List} object. + */ + public void setHeaderBands(List headerBands) { + this.headerBands = headerBands; + } + + /** + *

addHeaderBand.

+ * + * @param headerBand a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public void addHeaderBand(DRDesignBand headerBand) { + this.headerBands.add(headerBand); + } + + /** {@inheritDoc} */ + @Override + public List getFooterBands() { + return footerBands; + } + + /** + *

Setter for the field footerBands.

+ * + * @param footerBands a {@link java.util.List} object. + */ + public void setFooterBands(List footerBands) { + this.footerBands = footerBands; + } + + /** + *

addFooterBand.

+ * + * @param footerBand a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public void addFooterBand(DRDesignBand footerBand) { + this.footerBands.add(footerBand); + } + + /** + *

addFooterBand.

+ * + * @param index a int. + * @param footerBand a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public void addFooterBand(int index, DRDesignBand footerBand) { + this.footerBands.add(index, footerBand); + } + + /** {@inheritDoc} */ + @Override + public boolean isStartInNewPage() { + return startInNewPage; + } + + /** + *

Setter for the field startInNewPage.

+ * + * @param startInNewPage a boolean. + */ + public void setStartInNewPage(boolean startInNewPage) { + this.startInNewPage = startInNewPage; + } + + /** {@inheritDoc} */ + @Override + public boolean isStartInNewColumn() { + return startInNewColumn; + } + + /** + *

Setter for the field startInNewColumn.

+ * + * @param startInNewColumn a boolean. + */ + public void setStartInNewColumn(boolean startInNewColumn) { + this.startInNewColumn = startInNewColumn; + } + + /** {@inheritDoc} */ + @Override + public boolean isReprintHeaderOnEachPage() { + return reprintHeaderOnEachPage; + } + + /** + *

Setter for the field reprintHeaderOnEachPage.

+ * + * @param reprintHeaderOnEachPage a boolean. + */ + public void setReprintHeaderOnEachPage(boolean reprintHeaderOnEachPage) { + this.reprintHeaderOnEachPage = reprintHeaderOnEachPage; + } + + /** {@inheritDoc} */ + @Override + public boolean isResetPageNumber() { + return resetPageNumber; + } + + /** + *

Setter for the field resetPageNumber.

+ * + * @param resetPageNumber a boolean. + */ + public void setResetPageNumber(boolean resetPageNumber) { + this.resetPageNumber = resetPageNumber; + } + + /** {@inheritDoc} */ + @Override + public Integer getMinHeightToStartNewPage() { + return minHeightToStartNewPage; + } + + /** + *

Setter for the field minHeightToStartNewPage.

+ * + * @param minHeightToStartNewPage a {@link java.lang.Integer} object. + */ + public void setMinHeightToStartNewPage(Integer minHeightToStartNewPage) { + this.minHeightToStartNewPage = minHeightToStartNewPage; + } + + /** {@inheritDoc} */ + @Override + public GroupFooterPosition getFooterPosition() { + return footerPosition; + } + + /** + *

Setter for the field footerPosition.

+ * + * @param footerPosition a {@link software.xdev.dynamicreports.report.constant.GroupFooterPosition} object. + */ + public void setFooterPosition(GroupFooterPosition footerPosition) { + this.footerPosition = footerPosition; + } + + /** {@inheritDoc} */ + @Override + public boolean isKeepTogether() { + return keepTogether; + } + + /** + *

Setter for the field keepTogether.

+ * + * @param keepTogether a boolean. + */ + public void setKeepTogether(boolean keepTogether) { + this.keepTogether = keepTogether; + } + + /** {@inheritDoc} */ + @Override + public boolean isHeaderWithSubtotal() { + return headerWithSubtotal; + } + + /** + *

Setter for the field headerWithSubtotal.

+ * + * @param headerWithSubtotal a boolean. + */ + public void setHeaderWithSubtotal(boolean headerWithSubtotal) { + this.headerWithSubtotal = headerWithSubtotal; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignHyperLink.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignHyperLink.java new file mode 100644 index 0000000..fd015c4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignHyperLink.java @@ -0,0 +1,130 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.definition.DRIDesignHyperLink; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignHyperLink class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignHyperLink implements DRIDesignHyperLink { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIDesignExpression anchorExpression; + private DRIDesignExpression pageExpression; + private DRIDesignExpression referenceExpression; + private DRIDesignExpression tooltipExpression; + private String hyperLinkType; + private String hyperLinkTarget; + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getAnchorExpression() { + return anchorExpression; + } + + /** + *

Setter for the field anchorExpression.

+ * + * @param anchorExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setAnchorExpression(DRIDesignExpression anchorExpression) { + this.anchorExpression = anchorExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getPageExpression() { + return pageExpression; + } + + /** + *

Setter for the field pageExpression.

+ * + * @param pageExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setPageExpression(DRIDesignExpression pageExpression) { + this.pageExpression = pageExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getReferenceExpression() { + return referenceExpression; + } + + /** + *

Setter for the field referenceExpression.

+ * + * @param referenceExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setReferenceExpression(DRIDesignExpression referenceExpression) { + this.referenceExpression = referenceExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getTooltipExpression() { + return tooltipExpression; + } + + /** + *

Setter for the field tooltipExpression.

+ * + * @param tooltipExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setTooltipExpression(DRIDesignExpression tooltipExpression) { + this.tooltipExpression = tooltipExpression; + } + + /** {@inheritDoc} */ + @Override + public String getType() { + return hyperLinkType; + } + + /** + *

setType.

+ * + * @param hyperLinkType a {@link java.lang.String} object. + */ + public void setType(String hyperLinkType) { + this.hyperLinkType = hyperLinkType; + } + + /** {@inheritDoc} */ + @Override + public String getTarget() { + return hyperLinkTarget; + } + + /** + *

setTarget.

+ * + * @param hyperLinkTarget a {@link java.lang.String} object. + */ + public void setTarget(String hyperLinkTarget) { + this.hyperLinkTarget = hyperLinkTarget; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignMargin.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignMargin.java new file mode 100644 index 0000000..b4bf8f0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignMargin.java @@ -0,0 +1,96 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.definition.DRIDesignMargin; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignMargin class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignMargin implements DRIDesignMargin { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int top; + private int left; + private int bottom; + private int right; + + /** {@inheritDoc} */ + @Override + public int getTop() { + return top; + } + + /** + *

Setter for the field top.

+ * + * @param top a int. + */ + public void setTop(int top) { + this.top = top; + } + + /** {@inheritDoc} */ + @Override + public int getLeft() { + return left; + } + + /** + *

Setter for the field left.

+ * + * @param left a int. + */ + public void setLeft(int left) { + this.left = left; + } + + /** {@inheritDoc} */ + @Override + public int getBottom() { + return bottom; + } + + /** + *

Setter for the field bottom.

+ * + * @param bottom a int. + */ + public void setBottom(int bottom) { + this.bottom = bottom; + } + + /** {@inheritDoc} */ + @Override + public int getRight() { + return right; + } + + /** + *

Setter for the field right.

+ * + * @param right a int. + */ + public void setRight(int right) { + this.right = right; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignPage.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignPage.java new file mode 100644 index 0000000..c7d5792 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignPage.java @@ -0,0 +1,145 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.definition.DRIDesignPage; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.PageOrientation; + +/** + *

DRDesignPage class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignPage implements DRIDesignPage { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int width; + private int height; + private PageOrientation orientation; + private DRDesignMargin margin; + private int columnsPerPage; + private int columnSpace; + private int columnWidth; + + /** {@inheritDoc} */ + @Override + public int getWidth() { + return width; + } + + /** + *

Setter for the field width.

+ * + * @param width a int. + */ + public void setWidth(int width) { + this.width = width; + } + + /** {@inheritDoc} */ + @Override + public int getHeight() { + return height; + } + + /** + *

Setter for the field height.

+ * + * @param height a int. + */ + public void setHeight(int height) { + this.height = height; + } + + /** {@inheritDoc} */ + @Override + public PageOrientation getOrientation() { + return orientation; + } + + /** + *

Setter for the field orientation.

+ * + * @param orientation a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + */ + public void setOrientation(PageOrientation orientation) { + this.orientation = orientation; + } + + /** {@inheritDoc} */ + @Override + public DRDesignMargin getMargin() { + return margin; + } + + /** + *

Setter for the field margin.

+ * + * @param margin a {@link software.xdev.dynamicreports.design.base.DRDesignMargin} object. + */ + public void setMargin(DRDesignMargin margin) { + this.margin = margin; + } + + /** {@inheritDoc} */ + @Override + public int getColumnsPerPage() { + return columnsPerPage; + } + + /** + *

Setter for the field columnsPerPage.

+ * + * @param columnsPerPage a int. + */ + public void setColumnsPerPage(int columnsPerPage) { + this.columnsPerPage = columnsPerPage; + } + + /** {@inheritDoc} */ + @Override + public int getColumnSpace() { + return columnSpace; + } + + /** + *

Setter for the field columnSpace.

+ * + * @param columnSpace a int. + */ + public void setColumnSpace(int columnSpace) { + this.columnSpace = columnSpace; + } + + /** {@inheritDoc} */ + @Override + public int getColumnWidth() { + return columnWidth; + } + + /** + *

Setter for the field columnWidth.

+ * + * @param columnWidth a int. + */ + public void setColumnWidth(int columnWidth) { + this.columnWidth = columnWidth; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignParameter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignParameter.java new file mode 100644 index 0000000..781dcd6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignParameter.java @@ -0,0 +1,96 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.definition.DRIDesignParameter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignParameter class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignParameter implements DRIDesignParameter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private Class valueClass; + private Object value; + private boolean external; + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

Setter for the field name.

+ * + * @param name a {@link java.lang.String} object. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return valueClass; + } + + /** + *

Setter for the field valueClass.

+ * + * @param valueClass a {@link java.lang.Class} object. + */ + public void setValueClass(Class valueClass) { + this.valueClass = valueClass; + } + + /** {@inheritDoc} */ + @Override + public Object getValue() { + return value; + } + + /** + *

Setter for the field value.

+ * + * @param value a {@link java.lang.Object} object. + */ + public void setValue(Object value) { + this.value = value; + } + + /** {@inheritDoc} */ + @Override + public boolean isExternal() { + return external; + } + + /** + *

Setter for the field external.

+ * + * @param external a boolean. + */ + public void setExternal(boolean external) { + this.external = external; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignQuery.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignQuery.java new file mode 100644 index 0000000..8d67edc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignQuery.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.definition.DRIDesignQuery; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignQuery class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignQuery implements DRIDesignQuery { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String text; + private String language; + + /** {@inheritDoc} */ + @Override + public String getText() { + return text; + } + + /** + *

Setter for the field text.

+ * + * @param text a {@link java.lang.String} object. + */ + public void setText(String text) { + this.text = text; + } + + /** {@inheritDoc} */ + @Override + public String getLanguage() { + return language; + } + + /** + *

Setter for the field language.

+ * + * @param language a {@link java.lang.String} object. + */ + public void setLanguage(String language) { + this.language = language; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignReport.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignReport.java new file mode 100644 index 0000000..af473f0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignReport.java @@ -0,0 +1,530 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; + +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.design.definition.DRIDesignField; +import software.xdev.dynamicreports.design.definition.DRIDesignParameter; +import software.xdev.dynamicreports.design.definition.DRIDesignReport; +import software.xdev.dynamicreports.design.definition.DRIDesignSort; +import software.xdev.dynamicreports.design.definition.DRIDesignTemplateDesign; +import software.xdev.dynamicreports.design.definition.DRIDesignVariable; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignJasperExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSystemExpression; +import software.xdev.dynamicreports.design.definition.style.DRIDesignStyle; +import software.xdev.dynamicreports.design.transformation.AbstractExpressionTransform; +import software.xdev.dynamicreports.design.transformation.BandTransform; +import software.xdev.dynamicreports.design.transformation.ColumnGridTransform; +import software.xdev.dynamicreports.design.transformation.ColumnTransform; +import software.xdev.dynamicreports.design.transformation.ComponentTransform; +import software.xdev.dynamicreports.design.transformation.CrosstabTransform; +import software.xdev.dynamicreports.design.transformation.DatasetTransform; +import software.xdev.dynamicreports.design.transformation.DesignTransformAccessor; +import software.xdev.dynamicreports.design.transformation.GroupTransform; +import software.xdev.dynamicreports.design.transformation.MainDatasetExpressionTransform; +import software.xdev.dynamicreports.design.transformation.PageTransform; +import software.xdev.dynamicreports.design.transformation.ReportTransform; +import software.xdev.dynamicreports.design.transformation.StyleTransform; +import software.xdev.dynamicreports.design.transformation.SubtotalTransform; +import software.xdev.dynamicreports.design.transformation.TableOfContentsTransform; +import software.xdev.dynamicreports.design.transformation.TemplateTransform; +import software.xdev.dynamicreports.jasper.base.tableofcontents.JasperTocHeading; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.DRIDataset; +import software.xdev.dynamicreports.report.definition.DRIReport; +import software.xdev.dynamicreports.report.definition.DRIScriptlet; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + *

DRDesignReport class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignReport implements DesignTransformAccessor, DRIDesignReport { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private final DRIReport report; + private final Integer pageWidth; + private final Map tocHeadings; + private ReportTransform reportTransform; + private TemplateTransform templateTransform; + private PageTransform pageTransform; + private MainDatasetExpressionTransform mainDatasetExpressionTransform; + private BandTransform bandTransform; + private ComponentTransform componentTransform; + private GroupTransform groupTransform; + private ColumnGridTransform columnGridTransform; + private ColumnTransform columnTransform; + private SubtotalTransform subtotalTransform; + private StyleTransform styleTransform; + private CrosstabTransform crosstabTransform; + private DatasetTransform datasetTransform; + private TableOfContentsTransform tableOfContentsTransform; + private AbstractExpressionTransform expressionTransform; + + /** + *

Constructor for DRDesignReport.

+ * + * @param report a {@link software.xdev.dynamicreports.report.definition.DRIReport} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public DRDesignReport(final DRIReport report) throws DRException { + this(report, null, null); + } + + /** + *

Constructor for DRDesignReport.

+ * + * @param report a {@link software.xdev.dynamicreports.report.definition.DRIReport} object. + * @param pageWidth a {@link java.lang.Integer} object. + * @param tocHeadings a {@link java.util.Map} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public DRDesignReport(final DRIReport report, final Integer pageWidth, final Map tocHeadings) throws DRException { + this.report = report; + this.pageWidth = pageWidth; + this.tocHeadings = tocHeadings; + this.init(); + this.transform(); + } + + private void init() { + this.reportTransform = new ReportTransform(this); + this.templateTransform = new TemplateTransform(this); + this.pageTransform = new PageTransform(this); + this.mainDatasetExpressionTransform = new MainDatasetExpressionTransform(this); + this.groupTransform = new GroupTransform(this); + this.bandTransform = new BandTransform(this); + this.componentTransform = new ComponentTransform(this); + this.columnGridTransform = new ColumnGridTransform(this); + this.columnTransform = new ColumnTransform(this); + this.subtotalTransform = new SubtotalTransform(this); + this.styleTransform = new StyleTransform(this); + this.crosstabTransform = new CrosstabTransform(this); + this.datasetTransform = new DatasetTransform(this); + this.tableOfContentsTransform = new TableOfContentsTransform(this); + this.transformToMainDataset(); + } + + private void transform() throws DRException { + this.reportTransform.transform(); + this.pageTransform.transform(); + this.groupTransform.transform(); + this.mainDatasetExpressionTransform.transform(); + this.bandTransform.transform(); + this.columnGridTransform.transform(); + this.columnTransform.transform(); + this.groupTransform.transformHeaderAndFooter(); + this.pageTransform.transformPageWidth(); + this.subtotalTransform.transform(); + this.bandTransform.prepareBands(); + this.styleTransform.transformTemplateStyles(); + } + + /** {@inheritDoc} */ + @Override + public DRIReport getReport() { + return this.report; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageWidth() { + return this.pageWidth; + } + + /** {@inheritDoc} */ + @Override + public ReportTransform getReportTransform() { + return this.reportTransform; + } + + /** {@inheritDoc} */ + @Override + public TemplateTransform getTemplateTransform() { + return this.templateTransform; + } + + /** {@inheritDoc} */ + @Override + public PageTransform getPageTransform() { + return this.pageTransform; + } + + /** {@inheritDoc} */ + @Override + public void transformToMainDataset() { + this.transformToDataset(null); + } + + /** {@inheritDoc} */ + @Override + public void transformToDataset(final DRIDataset dataset) { + if (dataset != null) { + this.expressionTransform = this.datasetTransform.getDatasetExpressionTransform(dataset); + } else { + this.expressionTransform = this.mainDatasetExpressionTransform; + } + } + + /** {@inheritDoc} */ + @Override + public AbstractExpressionTransform getExpressionTransform() { + return this.expressionTransform; + } + + /** {@inheritDoc} */ + @Override + public BandTransform getBandTransform() { + return this.bandTransform; + } + + /** {@inheritDoc} */ + @Override + public ComponentTransform getComponentTransform() { + return this.componentTransform; + } + + /** {@inheritDoc} */ + @Override + public GroupTransform getGroupTransform() { + return this.groupTransform; + } + + /** {@inheritDoc} */ + @Override + public ColumnTransform getColumnTransform() { + return this.columnTransform; + } + + /** {@inheritDoc} */ + @Override + public ColumnGridTransform getColumnGridTransform() { + return this.columnGridTransform; + } + + /** {@inheritDoc} */ + @Override + public StyleTransform getStyleTransform() { + return this.styleTransform; + } + + /** {@inheritDoc} */ + @Override + public CrosstabTransform getCrosstabTransform() { + return this.crosstabTransform; + } + + /** {@inheritDoc} */ + @Override + public DatasetTransform getDatasetTransform() { + return this.datasetTransform; + } + + /** {@inheritDoc} */ + @Override + public TableOfContentsTransform getTableOfContentsTransform() { + return this.tableOfContentsTransform; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignTemplateDesign getTemplateDesign() { + return this.reportTransform.getTemplateDesign(); + } + + /** {@inheritDoc} */ + @Override + public String getReportName() { + return this.templateTransform.getReportName(); + } + + /** {@inheritDoc} */ + @Override + public Locale getLocale() { + return this.templateTransform.getLocale(); + } + + /** {@inheritDoc} */ + @Override + public ResourceBundle getResourceBundle() { + return this.report.getResourceBundle(); + } + + /** {@inheritDoc} */ + @Override + public String getResourceBundleName() { + return this.templateTransform.getResourceBundleName(); + } + + /** {@inheritDoc} */ + @Override + public boolean isIgnorePagination() { + return this.templateTransform.isIgnorePagination(); + } + + /** {@inheritDoc} */ + @Override + public Properties getProperties() { + return this.report.getProperties(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignQuery getQuery() { + return this.reportTransform.getQuery(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignPage getPage() { + return this.pageTransform.getPage(); + } + + /** {@inheritDoc} */ + @Override + public WhenNoDataType getWhenNoDataType() { + return this.templateTransform.getWhenNoDataType(this.getDetailBands().isEmpty(), this.getNoDataBand()); + } + + /** {@inheritDoc} */ + @Override + public WhenResourceMissingType getWhenResourceMissingType() { + return this.templateTransform.getWhenResourceMissingType(); + } + + /** {@inheritDoc} */ + @Override + public boolean isTitleOnANewPage() { + return this.templateTransform.isTitleOnANewPage(); + } + + /** {@inheritDoc} */ + @Override + public boolean isSummaryOnANewPage() { + return this.templateTransform.isSummaryOnANewPage(); + } + + /** {@inheritDoc} */ + @Override + public boolean isSummaryWithPageHeaderAndFooter() { + return this.templateTransform.isSummaryWithPageHeaderAndFooter(); + } + + /** {@inheritDoc} */ + @Override + public boolean isFloatColumnFooter() { + return this.templateTransform.isFloatColumnFooter(); + } + + /** {@inheritDoc} */ + @Override + public Orientation getPrintOrder() { + return this.templateTransform.getPrintOrder(); + } + + /** {@inheritDoc} */ + @Override + public RunDirection getColumnDirection() { + return this.templateTransform.getColumnDirection(); + } + + /** {@inheritDoc} */ + @Override + public String getLanguage() { + return this.templateTransform.getLanguage(); + } + + /** {@inheritDoc} */ + @Override + public boolean isTableOfContents() { + return this.templateTransform.isTableOfContents(this.tocHeadings); + } + + /** {@inheritDoc} */ + @Override + public Map getTableOfContentsHeadings() { + return this.tocHeadings; + } + + /** {@inheritDoc} */ + @Override + public DRITableOfContentsCustomizer getTableOfContentsCustomizer() { + return this.templateTransform.getTableOfContentsCustomizer(); + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getFilterExpression() { + return this.reportTransform.getFilterExpression(); + } + + /** {@inheritDoc} */ + @Override + public Collection getParameters() { + return this.reportTransform.getParameters(); + } + + /** {@inheritDoc} */ + @Override + public Map getParameterValues() { + return this.report.getParameterValues(); + } + + /** {@inheritDoc} */ + @Override + public Collection getScriptlets() { + return this.report.getScriptlets(); + } + + /** {@inheritDoc} */ + @Override + public Collection getFields() { + return this.mainDatasetExpressionTransform.getFields(); + } + + /** {@inheritDoc} */ + @Override + public Collection getSystemExpressions() { + return this.mainDatasetExpressionTransform.getSystemExpressions(); + } + + /** {@inheritDoc} */ + @Override + public Collection getJasperExpressions() { + return this.mainDatasetExpressionTransform.getJasperExpressions(); + } + + /** {@inheritDoc} */ + @Override + public Collection getSimpleExpressions() { + return this.mainDatasetExpressionTransform.getSimpleExpressions(); + } + + /** {@inheritDoc} */ + @Override + public Collection getStyles() { + return this.styleTransform.getStyles(); + } + + /** {@inheritDoc} */ + @Override + public Collection getGroups() { + return this.groupTransform.getGroups(); + } + + /** {@inheritDoc} */ + @Override + public Collection getVariables() { + return this.mainDatasetExpressionTransform.getVariables(); + } + + /** {@inheritDoc} */ + @Override + public Collection getComplexExpressions() { + return this.mainDatasetExpressionTransform.getComplexExpressions(); + } + + /** {@inheritDoc} */ + @Override + public Collection getSorts() { + return this.mainDatasetExpressionTransform.getSorts(); + } + + /** {@inheritDoc} */ + @Override + public Collection getDatasets() { + return this.datasetTransform.getDatasets(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignBand getTitleBand() { + return this.bandTransform.getTitleBand(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignBand getPageHeaderBand() { + return this.bandTransform.getPageHeaderBand(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignBand getPageFooterBand() { + return this.bandTransform.getPageFooterBand(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignBand getColumnHeaderBand() { + return this.bandTransform.getColumnHeaderBand(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignBand getColumnFooterBand() { + return this.bandTransform.getColumnFooterBand(); + } + + /** {@inheritDoc} */ + @Override + public List getDetailBands() { + return this.bandTransform.getDetailBands(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignBand getLastPageFooterBand() { + return this.bandTransform.getLastPageFooterBand(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignBand getSummaryBand() { + return this.bandTransform.getSummaryBand(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignBand getNoDataBand() { + return this.bandTransform.getNoDataBand(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignBand getBackgroundBand() { + return this.bandTransform.getBackgroundBand(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignSort.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignSort.java new file mode 100644 index 0000000..639c812 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignSort.java @@ -0,0 +1,67 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.definition.DRIDesignSort; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.OrderType; + +/** + *

DRDesignSort class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignSort implements DRIDesignSort { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIDesignExpression expression; + private OrderType orderType; + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getExpression() { + return expression; + } + + /** + *

Setter for the field expression.

+ * + * @param expression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setExpression(DRIDesignExpression expression) { + this.expression = expression; + } + + /** {@inheritDoc} */ + @Override + public OrderType getOrderType() { + return orderType; + } + + /** + *

Setter for the field orderType.

+ * + * @param orderType a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + */ + public void setOrderType(OrderType orderType) { + this.orderType = orderType; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignTableOfContentsHeading.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignTableOfContentsHeading.java new file mode 100644 index 0000000..009daec --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignTableOfContentsHeading.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.design.definition.DRIDesignTableOfContentsHeading; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignTableOfContentsHeading class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignTableOfContentsHeading implements DRIDesignTableOfContentsHeading { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRDesignTextField referenceField; + + /** {@inheritDoc} */ + @Override + public DRDesignTextField getReferenceField() { + return referenceField; + } + + /** + *

Setter for the field referenceField.

+ * + * @param referenceField a {@link software.xdev.dynamicreports.design.base.component.DRDesignTextField} object. + */ + public void setReferenceField(DRDesignTextField referenceField) { + this.referenceField = referenceField; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignTemplateDesign.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignTemplateDesign.java new file mode 100644 index 0000000..fd9da2f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignTemplateDesign.java @@ -0,0 +1,104 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.definition.DRIDesignTemplateDesign; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRITemplateDesign; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + *

DRDesignTemplateDesign class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignTemplateDesign implements DRIDesignTemplateDesign { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRITemplateDesign templateDesign; + + /** + *

Constructor for DRDesignTemplateDesign.

+ * + * @param templateDesign a {@link software.xdev.dynamicreports.report.definition.DRITemplateDesign} object. + */ + public DRDesignTemplateDesign(DRITemplateDesign templateDesign) { + this.templateDesign = templateDesign; + } + + /** {@inheritDoc} */ + @Override + public int getTitleComponentsCount() { + return templateDesign.getTitleComponentsCount(); + } + + /** {@inheritDoc} */ + @Override + public int getPageHeaderComponentsCount() { + return templateDesign.getPageHeaderComponentsCount(); + } + + /** {@inheritDoc} */ + @Override + public int getPageFooterComponentsCount() { + return templateDesign.getPageFooterComponentsCount(); + } + + /** {@inheritDoc} */ + @Override + public int getColumnHeaderComponentsCount() { + return templateDesign.getColumnHeaderComponentsCount(); + } + + /** {@inheritDoc} */ + @Override + public int getColumnFooterComponentsCount() { + return templateDesign.getColumnFooterComponentsCount(); + } + + /** {@inheritDoc} */ + @Override + public int getLastPageFooterComponentsCount() { + return templateDesign.getLastPageFooterComponentsCount(); + } + + /** {@inheritDoc} */ + @Override + public int getSummaryComponentsCount() { + return templateDesign.getSummaryComponentsCount(); + } + + /** {@inheritDoc} */ + @Override + public int getNoDataComponentsCount() { + return templateDesign.getNoDataComponentsCount(); + } + + /** {@inheritDoc} */ + @Override + public int getBackgroundComponentsCount() { + return templateDesign.getBackgroundComponentsCount(); + } + + /** {@inheritDoc} */ + @Override + public Object getDesign() throws DRException { + return templateDesign.getDesign(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignVariable.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignVariable.java new file mode 100644 index 0000000..0372080 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/DRDesignVariable.java @@ -0,0 +1,145 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base; + +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.DRIDesignVariable; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignVariable class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignVariable implements DRIDesignVariable { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRIDesignExpression valueExpression; + private DRIDesignExpression initialValueExpression; + private Calculation calculation; + private ResetType resetType; + private DRDesignGroup resetGroup; + + /** + *

Constructor for DRDesignVariable.

+ */ + public DRDesignVariable() { + this.name = ReportUtils.generateUniqueName("variable"); + } + + /** + *

Constructor for DRDesignVariable.

+ * + * @param name a {@link java.lang.String} object. + */ + public DRDesignVariable(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getValueExpression() { + return valueExpression; + } + + /** + *

Setter for the field valueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setValueExpression(DRIDesignExpression valueExpression) { + this.valueExpression = valueExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getInitialValueExpression() { + return initialValueExpression; + } + + /** + *

Setter for the field initialValueExpression.

+ * + * @param initialValueExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setInitialValueExpression(DRIDesignExpression initialValueExpression) { + this.initialValueExpression = initialValueExpression; + } + + /** {@inheritDoc} */ + @Override + public Calculation getCalculation() { + return calculation; + } + + /** + *

Setter for the field calculation.

+ * + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + public void setCalculation(Calculation calculation) { + this.calculation = calculation; + } + + /** {@inheritDoc} */ + @Override + public ResetType getResetType() { + return resetType; + } + + /** + *

Setter for the field resetType.

+ * + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + */ + public void setResetType(ResetType resetType) { + this.resetType = resetType; + } + + /** {@inheritDoc} */ + @Override + public DRDesignGroup getResetGroup() { + return resetGroup; + } + + /** + *

Setter for the field resetGroup.

+ * + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + */ + public void setResetGroup(DRDesignGroup resetGroup) { + this.resetGroup = resetGroup; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return ReportUtils.getVariableValueClass(calculation, valueExpression.getValueClass()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignBreak.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignBreak.java new file mode 100644 index 0000000..97e731d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignBreak.java @@ -0,0 +1,56 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.definition.component.DRIDesignBreak; +import software.xdev.dynamicreports.report.constant.BreakType; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignBreak class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignBreak extends DRDesignComponent implements DRIDesignBreak { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private BreakType breakType; + + /** + *

Constructor for DRDesignBreak.

+ */ + public DRDesignBreak() { + super("break"); + } + + /** {@inheritDoc} */ + @Override + public BreakType getType() { + return breakType; + } + + /** + *

setType.

+ * + * @param breakType a {@link software.xdev.dynamicreports.report.constant.BreakType} object. + */ + public void setType(BreakType breakType) { + this.breakType = breakType; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignComponent.java new file mode 100644 index 0000000..4b36819 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignComponent.java @@ -0,0 +1,308 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.base.DRDesignTableOfContentsHeading; +import software.xdev.dynamicreports.design.base.style.DRDesignStyle; +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; +import software.xdev.dynamicreports.design.definition.component.DRIDesignComponent; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignPropertyExpression; +import software.xdev.dynamicreports.report.constant.ComponentPositionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.StretchType; + +import java.util.ArrayList; +import java.util.List; + +/** + *

Abstract DRDesignComponent class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class DRDesignComponent implements DRIDesignComponent { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private String uniqueName; + private DRDesignStyle style; + private Integer x; + private Integer y; + private Integer width; + private Integer height; + private DRIDesignExpression printWhenExpression; + private boolean isRemoveLineWhenBlank; + private List propertyExpressions; + private ComponentPositionType positionType; + private StretchType stretchType; + private boolean printInFirstWholeBand; + private boolean printWhenDetailOverflows; + private DRIDesignGroup printWhenGroupChanges; + private DRDesignTableOfContentsHeading tableOfContentsHeading; + + /** + *

Constructor for DRDesignComponent.

+ * + * @param name a {@link java.lang.String} object. + */ + protected DRDesignComponent(String name) { + this.name = name; + this.uniqueName = name; + init(); + } + + /** + *

init.

+ */ + protected void init() { + propertyExpressions = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public String getUniqueName() { + return uniqueName; + } + + /** + *

Setter for the field uniqueName.

+ * + * @param uniqueName a {@link java.lang.String} object. + */ + public void setUniqueName(String uniqueName) { + this.uniqueName = uniqueName; + } + + /** {@inheritDoc} */ + @Override + public DRDesignStyle getStyle() { + return style; + } + + /** + *

Setter for the field style.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + */ + public void setStyle(DRDesignStyle style) { + this.style = style; + } + + /** {@inheritDoc} */ + @Override + public Integer getX() { + return x; + } + + /** + *

Setter for the field x.

+ * + * @param x a {@link java.lang.Integer} object. + */ + public void setX(Integer x) { + this.x = x; + } + + /** {@inheritDoc} */ + @Override + public Integer getY() { + return y; + } + + /** + *

Setter for the field y.

+ * + * @param y a {@link java.lang.Integer} object. + */ + public void setY(Integer y) { + this.y = y; + } + + /** {@inheritDoc} */ + @Override + public Integer getWidth() { + return width; + } + + /** + *

Setter for the field width.

+ * + * @param width a {@link java.lang.Integer} object. + */ + public void setWidth(Integer width) { + this.width = width; + } + + /** {@inheritDoc} */ + @Override + public Integer getHeight() { + return height; + } + + /** + *

Setter for the field height.

+ * + * @param height a {@link java.lang.Integer} object. + */ + public void setHeight(Integer height) { + this.height = height; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getPrintWhenExpression() { + return printWhenExpression; + } + + /** + *

Setter for the field printWhenExpression.

+ * + * @param printWhenExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setPrintWhenExpression(DRIDesignExpression printWhenExpression) { + this.printWhenExpression = printWhenExpression; + } + + /** {@inheritDoc} */ + @Override + public boolean isRemoveLineWhenBlank() { + return isRemoveLineWhenBlank; + } + + /** + *

setRemoveLineWhenBlank.

+ * + * @param isRemoveLineWhenBlank a boolean. + */ + public void setRemoveLineWhenBlank(boolean isRemoveLineWhenBlank) { + this.isRemoveLineWhenBlank = isRemoveLineWhenBlank; + } + + /** {@inheritDoc} */ + @Override + public List getPropertyExpressions() { + return propertyExpressions; + } + + /** + *

Setter for the field propertyExpressions.

+ * + * @param propertyExpressions a {@link java.util.List} object. + */ + public void setPropertyExpressions(List propertyExpressions) { + this.propertyExpressions = propertyExpressions; + } + + /** {@inheritDoc} */ + @Override + public ComponentPositionType getPositionType() { + return positionType; + } + + /** + *

Setter for the field positionType.

+ * + * @param positionType a {@link software.xdev.dynamicreports.report.constant.ComponentPositionType} object. + */ + public void setPositionType(ComponentPositionType positionType) { + this.positionType = positionType; + } + + /** {@inheritDoc} */ + @Override + public StretchType getStretchType() { + return stretchType; + } + + /** + *

Setter for the field stretchType.

+ * + * @param stretchType a {@link software.xdev.dynamicreports.report.constant.StretchType} object. + */ + public void setStretchType(StretchType stretchType) { + this.stretchType = stretchType; + } + + /** {@inheritDoc} */ + @Override + public boolean isPrintInFirstWholeBand() { + return printInFirstWholeBand; + } + + /** + *

Setter for the field printInFirstWholeBand.

+ * + * @param printInFirstWholeBand a boolean. + */ + public void setPrintInFirstWholeBand(boolean printInFirstWholeBand) { + this.printInFirstWholeBand = printInFirstWholeBand; + } + + /** {@inheritDoc} */ + @Override + public boolean isPrintWhenDetailOverflows() { + return printWhenDetailOverflows; + } + + /** + *

Setter for the field printWhenDetailOverflows.

+ * + * @param printWhenDetailOverflows a boolean. + */ + public void setPrintWhenDetailOverflows(boolean printWhenDetailOverflows) { + this.printWhenDetailOverflows = printWhenDetailOverflows; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignGroup getPrintWhenGroupChanges() { + return printWhenGroupChanges; + } + + /** + *

Setter for the field printWhenGroupChanges.

+ * + * @param printWhenGroupChanges a {@link software.xdev.dynamicreports.design.definition.DRIDesignGroup} object. + */ + public void setPrintWhenGroupChanges(DRIDesignGroup printWhenGroupChanges) { + this.printWhenGroupChanges = printWhenGroupChanges; + } + + /** {@inheritDoc} */ + @Override + public DRDesignTableOfContentsHeading getTableOfContentsHeading() { + return tableOfContentsHeading; + } + + /** + *

Setter for the field tableOfContentsHeading.

+ * + * @param tableOfContentsHeading a {@link software.xdev.dynamicreports.design.base.DRDesignTableOfContentsHeading} object. + */ + public void setTableOfContentsHeading(DRDesignTableOfContentsHeading tableOfContentsHeading) { + this.tableOfContentsHeading = tableOfContentsHeading; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignEllipse.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignEllipse.java new file mode 100644 index 0000000..7970bca --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignEllipse.java @@ -0,0 +1,56 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.base.style.DRDesignPen; +import software.xdev.dynamicreports.design.definition.component.DRIDesignEllipse; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignEllipse class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignEllipse extends DRDesignComponent implements DRIDesignEllipse { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRDesignPen pen; + + /** + *

Constructor for DRDesignEllipse.

+ */ + public DRDesignEllipse() { + super("ellipse"); + } + + /** {@inheritDoc} */ + @Override + public DRDesignPen getPen() { + return pen; + } + + /** + *

Setter for the field pen.

+ * + * @param pen a {@link software.xdev.dynamicreports.design.base.style.DRDesignPen} object. + */ + public void setPen(DRDesignPen pen) { + this.pen = pen; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignFiller.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignFiller.java new file mode 100644 index 0000000..bdb15b5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignFiller.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.definition.component.DRIDesignFiller; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignFiller class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignFiller extends DRDesignComponent implements DRIDesignFiller { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for DRDesignFiller.

+ */ + public DRDesignFiller() { + super("filler"); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignGenericElement.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignGenericElement.java new file mode 100644 index 0000000..2c274dc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignGenericElement.java @@ -0,0 +1,132 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.constant.EvaluationTime; +import software.xdev.dynamicreports.design.definition.component.DRIDesignGenericElement; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignParameterExpression; +import software.xdev.dynamicreports.report.constant.Constants; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRDesignGenericElement class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignGenericElement extends DRDesignComponent implements DRIDesignGenericElement { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String genericElementNamespace; + private String genericElementName; + private EvaluationTime evaluationTime; + private DRDesignGroup evaluationGroup; + private List parameterExpressions; + + /** + *

Constructor for DRDesignGenericElement.

+ */ + public DRDesignGenericElement() { + super("genericElement"); + } + + /** {@inheritDoc} */ + @Override + protected void init() { + super.init(); + parameterExpressions = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public String getGenericElementNamespace() { + return genericElementNamespace; + } + + /** + *

Setter for the field genericElementNamespace.

+ * + * @param genericElementNamespace a {@link java.lang.String} object. + */ + public void setGenericElementNamespace(String genericElementNamespace) { + this.genericElementNamespace = genericElementNamespace; + } + + /** {@inheritDoc} */ + @Override + public String getGenericElementName() { + return genericElementName; + } + + /** + *

Setter for the field genericElementName.

+ * + * @param genericElementName a {@link java.lang.String} object. + */ + public void setGenericElementName(String genericElementName) { + this.genericElementName = genericElementName; + } + + /** {@inheritDoc} */ + @Override + public EvaluationTime getEvaluationTime() { + return evaluationTime; + } + + /** + *

Setter for the field evaluationTime.

+ * + * @param evaluationTime a {@link software.xdev.dynamicreports.design.constant.EvaluationTime} object. + */ + public void setEvaluationTime(EvaluationTime evaluationTime) { + this.evaluationTime = evaluationTime; + } + + /** {@inheritDoc} */ + @Override + public DRDesignGroup getEvaluationGroup() { + return evaluationGroup; + } + + /** + *

Setter for the field evaluationGroup.

+ * + * @param evaluationGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + */ + public void setEvaluationGroup(DRDesignGroup evaluationGroup) { + this.evaluationGroup = evaluationGroup; + } + + /** {@inheritDoc} */ + @Override + public List getParameterExpressions() { + return parameterExpressions; + } + + /** + *

Setter for the field parameterExpressions.

+ * + * @param parameterExpressions a {@link java.util.List} object. + */ + public void setParameterExpressions(List parameterExpressions) { + this.parameterExpressions = parameterExpressions; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignHyperlinkComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignHyperlinkComponent.java new file mode 100644 index 0000000..cebccdf --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignHyperlinkComponent.java @@ -0,0 +1,91 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.base.DRDesignHyperLink; +import software.xdev.dynamicreports.design.definition.component.DRIDesignHyperLinkComponent; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

Abstract DRDesignHyperlinkComponent class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class DRDesignHyperlinkComponent extends DRDesignComponent implements DRIDesignHyperLinkComponent { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIDesignExpression anchorNameExpression; + private Integer bookmarkLevel; + private DRDesignHyperLink hyperLink; + + /** + *

Constructor for DRDesignHyperlinkComponent.

+ * + * @param name a {@link java.lang.String} object. + */ + public DRDesignHyperlinkComponent(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getAnchorNameExpression() { + return anchorNameExpression; + } + + /** + *

Setter for the field anchorNameExpression.

+ * + * @param anchorNameExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setAnchorNameExpression(DRIDesignExpression anchorNameExpression) { + this.anchorNameExpression = anchorNameExpression; + } + + /** {@inheritDoc} */ + @Override + public Integer getBookmarkLevel() { + return bookmarkLevel; + } + + /** + *

Setter for the field bookmarkLevel.

+ * + * @param bookmarkLevel a {@link java.lang.Integer} object. + */ + public void setBookmarkLevel(Integer bookmarkLevel) { + this.bookmarkLevel = bookmarkLevel; + } + + /** {@inheritDoc} */ + @Override + public DRDesignHyperLink getHyperLink() { + return hyperLink; + } + + /** + *

Setter for the field hyperLink.

+ * + * @param hyperLink a {@link software.xdev.dynamicreports.design.base.DRDesignHyperLink} object. + */ + public void setHyperLink(DRDesignHyperLink hyperLink) { + this.hyperLink = hyperLink; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignImage.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignImage.java new file mode 100644 index 0000000..2ac7531 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignImage.java @@ -0,0 +1,123 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.definition.component.DRIDesignImage; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; + +/** + *

DRDesignImage class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignImage extends DRDesignHyperlinkComponent implements DRIDesignImage { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private ImageScale imageScale; + private DRIDesignExpression imageExpression; + private Boolean usingCache; + private Boolean lazy; + private HorizontalImageAlignment horizontalImageAlignment; + + /** + *

Constructor for DRDesignImage.

+ */ + public DRDesignImage() { + super("image"); + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getImageExpression() { + return imageExpression; + } + + /** + *

Setter for the field imageExpression.

+ * + * @param imageExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setImageExpression(DRIDesignExpression imageExpression) { + this.imageExpression = imageExpression; + } + + /** {@inheritDoc} */ + @Override + public ImageScale getImageScale() { + return imageScale; + } + + /** + *

Setter for the field imageScale.

+ * + * @param imageScale a {@link software.xdev.dynamicreports.report.constant.ImageScale} object. + */ + public void setImageScale(ImageScale imageScale) { + this.imageScale = imageScale; + } + + /** {@inheritDoc} */ + @Override + public Boolean getUsingCache() { + return usingCache; + } + + /** + *

Setter for the field usingCache.

+ * + * @param usingCache a {@link java.lang.Boolean} object. + */ + public void setUsingCache(Boolean usingCache) { + this.usingCache = usingCache; + } + + /** {@inheritDoc} */ + @Override + public Boolean getLazy() { + return lazy; + } + + /** + *

Setter for the field lazy.

+ * + * @param lazy a {@link java.lang.Boolean} object. + */ + public void setLazy(Boolean lazy) { + this.lazy = lazy; + } + + /** {@inheritDoc} */ + @Override + public HorizontalImageAlignment getHorizontalImageAlignment() { + return horizontalImageAlignment; + } + + /** + *

Setter for the field horizontalImageAlignment.

+ * + * @param horizontalImageAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public void setHorizontalImageAlignment(HorizontalImageAlignment horizontalImageAlignment) { + this.horizontalImageAlignment = horizontalImageAlignment; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignLine.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignLine.java new file mode 100644 index 0000000..ecc2ac7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignLine.java @@ -0,0 +1,73 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.base.style.DRDesignPen; +import software.xdev.dynamicreports.design.definition.component.DRIDesignLine; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.LineDirection; + +/** + *

DRDesignLine class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignLine extends DRDesignComponent implements DRIDesignLine { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private LineDirection direction; + private DRDesignPen pen; + + /** + *

Constructor for DRDesignLine.

+ */ + public DRDesignLine() { + super("line"); + } + + /** {@inheritDoc} */ + @Override + public LineDirection getDirection() { + return direction; + } + + /** + *

Setter for the field direction.

+ * + * @param direction a {@link software.xdev.dynamicreports.report.constant.LineDirection} object. + */ + public void setDirection(LineDirection direction) { + this.direction = direction; + } + + /** {@inheritDoc} */ + @Override + public DRDesignPen getPen() { + return pen; + } + + /** + *

Setter for the field pen.

+ * + * @param pen a {@link software.xdev.dynamicreports.design.base.style.DRDesignPen} object. + */ + public void setPen(DRDesignPen pen) { + this.pen = pen; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignList.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignList.java new file mode 100644 index 0000000..5630630 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignList.java @@ -0,0 +1,247 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.constant.ComponentGroupType; +import software.xdev.dynamicreports.design.definition.component.DRIDesignList; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRDesignList class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignList extends DRDesignComponent implements DRIDesignList { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private List listCells; + private List components; + private ListType type; + private ComponentGroupType componentGroupType; + private int gap; + private boolean calculateComponents; + private Boolean removable; + private DRDesignComponent backgroundComponent; + + /** + *

Constructor for DRDesignList.

+ */ + public DRDesignList() { + this(ListType.HORIZONTAL); + } + + /** + *

Constructor for DRDesignList.

+ * + * @param type a {@link software.xdev.dynamicreports.report.constant.ListType} object. + */ + public DRDesignList(ListType type) { + super("list"); + this.type = type; + this.calculateComponents = true; + } + + /** {@inheritDoc} */ + @Override + protected void init() { + super.init(); + this.listCells = new ArrayList(); + this.components = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public List getComponents() { + return components; + } + + /** + *

addComponent.

+ * + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public void addComponent(DRDesignComponent component) { + components.add(component); + listCells.add(new DRDesignListCell(component)); + } + + /** + *

addComponent.

+ * + * @param index a int. + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public void addComponent(int index, DRDesignComponent component) { + components.add(index, component); + listCells.add(index, new DRDesignListCell(component)); + } + + /** + *

addComponent.

+ * + * @param index a int. + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public void addComponent(int index, HorizontalCellComponentAlignment horizontalAlignment, VerticalCellComponentAlignment verticalAlignment, DRDesignComponent component) { + components.add(index, component); + listCells.add(index, new DRDesignListCell(horizontalAlignment, verticalAlignment, component)); + } + + /** + *

addComponent.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public void addComponent(HorizontalCellComponentAlignment horizontalAlignment, VerticalCellComponentAlignment verticalAlignment, DRDesignComponent component) { + components.add(component); + listCells.add(new DRDesignListCell(horizontalAlignment, verticalAlignment, component)); + } + + /** + *

Getter for the field listCells.

+ * + * @return a {@link java.util.List} object. + */ + public List getListCells() { + return listCells; + } + + /** + *

isEmpty.

+ * + * @return a boolean. + */ + public boolean isEmpty() { + return components.isEmpty(); + } + + /** {@inheritDoc} */ + @Override + public ListType getType() { + return type; + } + + /** + *

Setter for the field type.

+ * + * @param type a {@link software.xdev.dynamicreports.report.constant.ListType} object. + */ + public void setType(ListType type) { + this.type = type; + } + + /** {@inheritDoc} */ + @Override + public ComponentGroupType getComponentGroupType() { + return componentGroupType; + } + + /** + *

Setter for the field componentGroupType.

+ * + * @param componentGroupType a {@link software.xdev.dynamicreports.design.constant.ComponentGroupType} object. + */ + public void setComponentGroupType(ComponentGroupType componentGroupType) { + this.componentGroupType = componentGroupType; + } + + /** + *

Getter for the field gap.

+ * + * @return a int. + */ + public int getGap() { + return gap; + } + + /** + *

Setter for the field gap.

+ * + * @param gap a int. + */ + public void setGap(int gap) { + this.gap = gap; + } + + /** + *

isCalculateComponents.

+ * + * @return a boolean. + */ + public boolean isCalculateComponents() { + return calculateComponents; + } + + /** + *

Setter for the field calculateComponents.

+ * + * @param calculateComponents a boolean. + */ + public void setCalculateComponents(boolean calculateComponents) { + this.calculateComponents = calculateComponents; + } + + /** + *

isRemovable.

+ * + * @return a boolean. + */ + public boolean isRemovable() { + if (removable != null) { + return removable; + } else { + return ListType.VERTICAL.equals(type); + } + } + + /** + *

Setter for the field removable.

+ * + * @param removable a {@link java.lang.Boolean} object. + */ + public void setRemovable(Boolean removable) { + this.removable = removable; + } + + /** {@inheritDoc} */ + @Override + public DRDesignComponent getBackgroundComponent() { + return backgroundComponent; + } + + /** + *

Setter for the field backgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public void setBackgroundComponent(DRDesignComponent backgroundComponent) { + this.backgroundComponent = backgroundComponent; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignListCell.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignListCell.java new file mode 100644 index 0000000..e706bea --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignListCell.java @@ -0,0 +1,181 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; + +import java.io.Serializable; + +/** + *

DRDesignListCell class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignListCell implements Serializable { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private HorizontalCellComponentAlignment horizontalAlignment; + private VerticalCellComponentAlignment verticalAlignment; + private DRDesignComponent component; + private Integer x; + private Integer y; + private Integer width; + private Integer height; + + /** + *

Constructor for DRDesignListCell.

+ * + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + protected DRDesignListCell(DRDesignComponent component) { + this(null, null, component); + } + + /** + *

Constructor for DRDesignListCell.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + protected DRDesignListCell(HorizontalCellComponentAlignment horizontalAlignment, VerticalCellComponentAlignment verticalAlignment, DRDesignComponent component) { + this.horizontalAlignment = horizontalAlignment; + this.verticalAlignment = verticalAlignment; + this.component = component; + } + + /** + *

Getter for the field horizontalAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + */ + public HorizontalCellComponentAlignment getHorizontalAlignment() { + return horizontalAlignment; + } + + /** + *

Setter for the field horizontalAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + */ + public void setHorizontalAlignment(HorizontalCellComponentAlignment horizontalAlignment) { + this.horizontalAlignment = horizontalAlignment; + } + + /** + *

Getter for the field verticalAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + */ + public VerticalCellComponentAlignment getVerticalAlignment() { + return verticalAlignment; + } + + /** + *

Setter for the field verticalAlignment.

+ * + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + */ + public void setVerticalAlignment(VerticalCellComponentAlignment verticalAlignment) { + this.verticalAlignment = verticalAlignment; + } + + /** + *

Getter for the field component.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public DRDesignComponent getComponent() { + return component; + } + + /** + *

Getter for the field x.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getX() { + return x; + } + + /** + *

Setter for the field x.

+ * + * @param x a {@link java.lang.Integer} object. + */ + public void setX(Integer x) { + this.x = x; + } + + /** + *

Getter for the field y.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getY() { + return y; + } + + /** + *

Setter for the field y.

+ * + * @param y a {@link java.lang.Integer} object. + */ + public void setY(Integer y) { + this.y = y; + } + + /** + *

Getter for the field width.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getWidth() { + return width; + } + + /** + *

Setter for the field width.

+ * + * @param width a {@link java.lang.Integer} object. + */ + public void setWidth(Integer width) { + this.width = width; + } + + /** + *

Getter for the field height.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getHeight() { + return height; + } + + /** + *

Setter for the field height.

+ * + * @param height a {@link java.lang.Integer} object. + */ + public void setHeight(Integer height) { + this.height = height; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignMap.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignMap.java new file mode 100644 index 0000000..6f17ab1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignMap.java @@ -0,0 +1,122 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.constant.EvaluationTime; +import software.xdev.dynamicreports.design.definition.component.DRIDesignMap; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignMap class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignMap extends DRDesignComponent implements DRIDesignMap { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private EvaluationTime evaluationTime; + private DRDesignGroup evaluationGroup; + private DRIDesignExpression latitudeExpression; + private DRIDesignExpression longitudeExpression; + private DRIDesignExpression zoomExpression; + + /** + *

Constructor for DRDesignMap.

+ */ + public DRDesignMap() { + super("map"); + } + + /** {@inheritDoc} */ + @Override + public EvaluationTime getEvaluationTime() { + return evaluationTime; + } + + /** + *

Setter for the field evaluationTime.

+ * + * @param evaluationTime a {@link software.xdev.dynamicreports.design.constant.EvaluationTime} object. + */ + public void setEvaluationTime(EvaluationTime evaluationTime) { + this.evaluationTime = evaluationTime; + } + + /** {@inheritDoc} */ + @Override + public DRDesignGroup getEvaluationGroup() { + return evaluationGroup; + } + + /** + *

Setter for the field evaluationGroup.

+ * + * @param evaluationGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + */ + public void setEvaluationGroup(DRDesignGroup evaluationGroup) { + this.evaluationGroup = evaluationGroup; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getLatitudeExpression() { + return latitudeExpression; + } + + /** + *

Setter for the field latitudeExpression.

+ * + * @param latitudeExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setLatitudeExpression(DRIDesignExpression latitudeExpression) { + this.latitudeExpression = latitudeExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getLongitudeExpression() { + return longitudeExpression; + } + + /** + *

Setter for the field longitudeExpression.

+ * + * @param longitudeExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setLongitudeExpression(DRIDesignExpression longitudeExpression) { + this.longitudeExpression = longitudeExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getZoomExpression() { + return zoomExpression; + } + + /** + *

Setter for the field zoomExpression.

+ * + * @param zoomExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setZoomExpression(DRIDesignExpression zoomExpression) { + this.zoomExpression = zoomExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignRectangle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignRectangle.java new file mode 100644 index 0000000..faa074e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignRectangle.java @@ -0,0 +1,72 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.base.style.DRDesignPen; +import software.xdev.dynamicreports.design.definition.component.DRIDesignRectangle; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignRectangle class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignRectangle extends DRDesignComponent implements DRIDesignRectangle { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer radius; + private DRDesignPen pen; + + /** + *

Constructor for DRDesignRectangle.

+ */ + public DRDesignRectangle() { + super("rectangle"); + } + + /** {@inheritDoc} */ + @Override + public Integer getRadius() { + return radius; + } + + /** + *

Setter for the field radius.

+ * + * @param radius a {@link java.lang.Integer} object. + */ + public void setRadius(Integer radius) { + this.radius = radius; + } + + /** {@inheritDoc} */ + @Override + public DRDesignPen getPen() { + return pen; + } + + /** + *

Setter for the field pen.

+ * + * @param pen a {@link software.xdev.dynamicreports.design.base.style.DRDesignPen} object. + */ + public void setPen(DRDesignPen pen) { + this.pen = pen; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignSubreport.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignSubreport.java new file mode 100644 index 0000000..7141510 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignSubreport.java @@ -0,0 +1,120 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.definition.component.DRIDesignSubreport; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignSubreport class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignSubreport extends DRDesignComponent implements DRIDesignSubreport { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIDesignExpression reportExpression; + private DRIDesignExpression parametersExpression; + private DRIDesignExpression connectionExpression; + private DRIDesignExpression dataSourceExpression; + private Boolean runToBottom; + + /** + *

Constructor for DRDesignSubreport.

+ */ + public DRDesignSubreport() { + super("subreport"); + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getReportExpression() { + return reportExpression; + } + + /** + *

Setter for the field reportExpression.

+ * + * @param reportExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setReportExpression(DRIDesignExpression reportExpression) { + this.reportExpression = reportExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getParametersExpression() { + return parametersExpression; + } + + /** + *

Setter for the field parametersExpression.

+ * + * @param parametersExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setParametersExpression(DRIDesignExpression parametersExpression) { + this.parametersExpression = parametersExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getConnectionExpression() { + return connectionExpression; + } + + /** + *

Setter for the field connectionExpression.

+ * + * @param connectionExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setConnectionExpression(DRIDesignExpression connectionExpression) { + this.connectionExpression = connectionExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getDataSourceExpression() { + return dataSourceExpression; + } + + /** + *

Setter for the field dataSourceExpression.

+ * + * @param dataSourceExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setDataSourceExpression(DRIDesignExpression dataSourceExpression) { + this.dataSourceExpression = dataSourceExpression; + } + + /** {@inheritDoc} */ + @Override + public Boolean getRunToBottom() { + return runToBottom; + } + + /** + *

Setter for the field runToBottom.

+ * + * @param runToBottom a {@link java.lang.Boolean} object. + */ + public void setRunToBottom(Boolean runToBottom) { + this.runToBottom = runToBottom; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignTextField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignTextField.java new file mode 100644 index 0000000..747915d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/component/DRDesignTextField.java @@ -0,0 +1,209 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.component; + +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.constant.EvaluationTime; +import software.xdev.dynamicreports.design.definition.component.DRIDesignTextField; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.TextAdjust; + +/** + *

DRDesignTextField class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class DRDesignTextField extends DRDesignHyperlinkComponent implements DRIDesignTextField { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String pattern; + private DRIDesignExpression patternExpression; + private HorizontalTextAlignment horizontalTextAlignment; + private DRIDesignExpression valueExpression; + private boolean printRepeatedValues; + private EvaluationTime evaluationTime; + private DRDesignGroup evaluationGroup; + private Markup markup; + private boolean stretchWithOverflow; + private TextAdjust textAdjust; + + + /** + *

Constructor for DRDesignTextField.

+ */ + public DRDesignTextField() { + super("textField"); + } + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return pattern; + } + + /** + *

Setter for the field pattern.

+ * + * @param pattern a {@link java.lang.String} object. + */ + public void setPattern(final String pattern) { + this.pattern = pattern; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getPatternExpression() { + return patternExpression; + } + + /** + *

Setter for the field patternExpression.

+ * + * @param patternExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setPatternExpression(final DRIDesignExpression patternExpression) { + this.patternExpression = patternExpression; + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return horizontalTextAlignment; + } + + /** + *

Setter for the field horizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public void setHorizontalTextAlignment(final HorizontalTextAlignment horizontalTextAlignment) { + this.horizontalTextAlignment = horizontalTextAlignment; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getValueExpression() { + return valueExpression; + } + + /** + *

Setter for the field valueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setValueExpression(final DRIDesignExpression valueExpression) { + this.valueExpression = valueExpression; + } + + /** {@inheritDoc} */ + @Override + public boolean isPrintRepeatedValues() { + return printRepeatedValues; + } + + /** + *

Setter for the field printRepeatedValues.

+ * + * @param printRepeatedValues a boolean. + */ + public void setPrintRepeatedValues(final boolean printRepeatedValues) { + this.printRepeatedValues = printRepeatedValues; + } + + /** {@inheritDoc} */ + @Override + public EvaluationTime getEvaluationTime() { + return evaluationTime; + } + + /** + *

Setter for the field evaluationTime.

+ * + * @param evaluationTime a {@link software.xdev.dynamicreports.design.constant.EvaluationTime} object. + */ + public void setEvaluationTime(final EvaluationTime evaluationTime) { + this.evaluationTime = evaluationTime; + } + + /** {@inheritDoc} */ + @Override + public DRDesignGroup getEvaluationGroup() { + return evaluationGroup; + } + + /** + *

Setter for the field evaluationGroup.

+ * + * @param evaluationGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + */ + public void setEvaluationGroup(final DRDesignGroup evaluationGroup) { + this.evaluationGroup = evaluationGroup; + } + + /** {@inheritDoc} */ + @Override + public Markup getMarkup() { + return markup; + } + + /** + *

Setter for the field markup.

+ * + * @param markup a {@link software.xdev.dynamicreports.report.constant.Markup} object. + */ + public void setMarkup(final Markup markup) { + this.markup = markup; + } + + /** {@inheritDoc} */ + @Override + @Deprecated + public boolean isStretchWithOverflow() { + return stretchWithOverflow; + } + + /** + *

Setter for the field stretchWithOverflow.

+ * + * @param stretchWithOverflow a boolean. + * @deprecated Replaced by {@link #setTextAdjust(TextAdjust)}. + */ + @Deprecated + public void setStretchWithOverflow(final boolean stretchWithOverflow) { + this.stretchWithOverflow = stretchWithOverflow; + } + + /** {@inheritDoc} */ + @Override + public TextAdjust getTextAdjust() { + return textAdjust; + } + + /** + *

Setter for the field textAdjust.

+ * + * @param textAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + public void setTextAdjust(final TextAdjust textAdjust) { + this.textAdjust = textAdjust; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstab.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstab.java new file mode 100644 index 0000000..cb46de4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstab.java @@ -0,0 +1,247 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.crosstab; + +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstab; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabMeasure; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.RunDirection; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRDesignCrosstab class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignCrosstab extends DRDesignComponent implements DRIDesignCrosstab { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRDesignCrosstabDataset dataset; + private Boolean repeatColumnHeaders; + private Boolean repeatRowHeaders; + private Integer columnBreakOffset; + private Boolean ignoreWidth; + private RunDirection runDirection; + private DRDesignCrosstabCellContent whenNoDataCell; + private DRDesignCrosstabCellContent headerCell; + private List columnGroups; + private List rowGroups; + private List cells; + private List measures; + + /** + *

Constructor for DRDesignCrosstab.

+ */ + public DRDesignCrosstab() { + super("crosstab"); + } + + /** {@inheritDoc} */ + @Override + protected void init() { + super.init(); + columnGroups = new ArrayList(); + rowGroups = new ArrayList(); + cells = new ArrayList(); + measures = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public DRDesignCrosstabDataset getDataset() { + return dataset; + } + + /** + *

Setter for the field dataset.

+ * + * @param dataset a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabDataset} object. + */ + public void setDataset(DRDesignCrosstabDataset dataset) { + this.dataset = dataset; + } + + /** {@inheritDoc} */ + @Override + public Boolean isRepeatColumnHeaders() { + return repeatColumnHeaders; + } + + /** + *

Setter for the field repeatColumnHeaders.

+ * + * @param repeatColumnHeaders a {@link java.lang.Boolean} object. + */ + public void setRepeatColumnHeaders(Boolean repeatColumnHeaders) { + this.repeatColumnHeaders = repeatColumnHeaders; + } + + /** {@inheritDoc} */ + @Override + public Boolean isRepeatRowHeaders() { + return repeatRowHeaders; + } + + /** + *

Setter for the field repeatRowHeaders.

+ * + * @param repeatRowHeaders a {@link java.lang.Boolean} object. + */ + public void setRepeatRowHeaders(Boolean repeatRowHeaders) { + this.repeatRowHeaders = repeatRowHeaders; + } + + /** {@inheritDoc} */ + @Override + public Integer getColumnBreakOffset() { + return columnBreakOffset; + } + + /** + *

Setter for the field columnBreakOffset.

+ * + * @param columnBreakOffset a {@link java.lang.Integer} object. + */ + public void setColumnBreakOffset(Integer columnBreakOffset) { + this.columnBreakOffset = columnBreakOffset; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreWidth() { + return ignoreWidth; + } + + /** + *

Setter for the field ignoreWidth.

+ * + * @param ignoreWidth a {@link java.lang.Boolean} object. + */ + public void setIgnoreWidth(Boolean ignoreWidth) { + this.ignoreWidth = ignoreWidth; + } + + /** {@inheritDoc} */ + @Override + public RunDirection getRunDirection() { + return runDirection; + } + + /** + *

Setter for the field runDirection.

+ * + * @param runDirection a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public void setRunDirection(RunDirection runDirection) { + this.runDirection = runDirection; + } + + /** {@inheritDoc} */ + @Override + public DRDesignCrosstabCellContent getWhenNoDataCell() { + return whenNoDataCell; + } + + /** + *

Setter for the field whenNoDataCell.

+ * + * @param whenNoDataCell a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCellContent} object. + */ + public void setWhenNoDataCell(DRDesignCrosstabCellContent whenNoDataCell) { + this.whenNoDataCell = whenNoDataCell; + } + + /** {@inheritDoc} */ + @Override + public DRDesignCrosstabCellContent getHeaderCell() { + return headerCell; + } + + /** + *

Setter for the field headerCell.

+ * + * @param headerCell a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCellContent} object. + */ + public void setHeaderCell(DRDesignCrosstabCellContent headerCell) { + this.headerCell = headerCell; + } + + /** {@inheritDoc} */ + @Override + public List getColumnGroups() { + return columnGroups; + } + + /** + *

Setter for the field columnGroups.

+ * + * @param columnGroups a {@link java.util.List} object. + */ + public void setColumnGroups(List columnGroups) { + this.columnGroups = columnGroups; + } + + /** {@inheritDoc} */ + @Override + public List getRowGroups() { + return rowGroups; + } + + /** + *

Setter for the field rowGroups.

+ * + * @param rowGroups a {@link java.util.List} object. + */ + public void setRowGroups(List rowGroups) { + this.rowGroups = rowGroups; + } + + /** {@inheritDoc} */ + @Override + public List getCells() { + return cells; + } + + /** + *

Setter for the field cells.

+ * + * @param cells a {@link java.util.List} object. + */ + public void setCells(List cells) { + this.cells = cells; + } + + /** {@inheritDoc} */ + @Override + public List getMeasures() { + return measures; + } + + /** + *

Setter for the field measures.

+ * + * @param measures a {@link java.util.List} object. + */ + public void setMeasures(List measures) { + this.measures = measures; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabCell.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabCell.java new file mode 100644 index 0000000..f3010cd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabCell.java @@ -0,0 +1,96 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.crosstab; + +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabCell; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignCrosstabCell class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignCrosstabCell implements DRIDesignCrosstabCell { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private String rowTotalGroup; + private String columnTotalGroup; + private DRDesignCrosstabCellContent content; + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

Setter for the field name.

+ * + * @param name a {@link java.lang.String} object. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public String getRowTotalGroup() { + return rowTotalGroup; + } + + /** + *

Setter for the field rowTotalGroup.

+ * + * @param rowTotalGroup a {@link java.lang.String} object. + */ + public void setRowTotalGroup(String rowTotalGroup) { + this.rowTotalGroup = rowTotalGroup; + } + + /** {@inheritDoc} */ + @Override + public String getColumnTotalGroup() { + return columnTotalGroup; + } + + /** + *

Setter for the field columnTotalGroup.

+ * + * @param columnTotalGroup a {@link java.lang.String} object. + */ + public void setColumnTotalGroup(String columnTotalGroup) { + this.columnTotalGroup = columnTotalGroup; + } + + /** {@inheritDoc} */ + @Override + public DRDesignCrosstabCellContent getContent() { + return content; + } + + /** + *

Setter for the field content.

+ * + * @param content a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCellContent} object. + */ + public void setContent(DRDesignCrosstabCellContent content) { + this.content = content; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabCellContent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabCellContent.java new file mode 100644 index 0000000..f7ed65b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabCellContent.java @@ -0,0 +1,118 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.crosstab; + +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabCellContent; +import software.xdev.dynamicreports.design.definition.style.DRIDesignStyle; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignCrosstabCellContent class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignCrosstabCellContent implements DRIDesignCrosstabCellContent { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int width; + private int height; + private DRDesignList list; + private DRDesignComponent component; + private DRIDesignStyle style; + + /** {@inheritDoc} */ + @Override + public int getWidth() { + return width; + } + + /** + *

Setter for the field width.

+ * + * @param width a int. + */ + public void setWidth(int width) { + this.width = width; + } + + /** {@inheritDoc} */ + @Override + public int getHeight() { + return height; + } + + /** + *

Setter for the field height.

+ * + * @param height a int. + */ + public void setHeight(int height) { + this.height = height; + } + + /** + *

Getter for the field list.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignList} object. + */ + public DRDesignList getList() { + return list; + } + + /** + *

Setter for the field list.

+ * + * @param list a {@link software.xdev.dynamicreports.design.base.component.DRDesignList} object. + */ + public void setList(DRDesignList list) { + this.list = list; + } + + /** {@inheritDoc} */ + @Override + public DRDesignComponent getComponent() { + return component; + } + + /** + *

Setter for the field component.

+ * + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public void setComponent(DRDesignComponent component) { + this.component = component; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignStyle getStyle() { + return style; + } + + /** + *

Setter for the field style.

+ * + * @param style a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignStyle} object. + */ + public void setStyle(DRIDesignStyle style) { + this.style = style; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabColumnGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabColumnGroup.java new file mode 100644 index 0000000..c41cfef --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabColumnGroup.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.crosstab; + +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabColumnGroup; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignCrosstabColumnGroup class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignCrosstabColumnGroup extends DRDesignCrosstabGroup implements DRIDesignCrosstabColumnGroup { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int height; + + /** {@inheritDoc} */ + @Override + public int getHeight() { + return height; + } + + /** + *

Setter for the field height.

+ * + * @param height a int. + */ + public void setHeight(int height) { + this.height = height; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabDataset.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabDataset.java new file mode 100644 index 0000000..80c65f2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabDataset.java @@ -0,0 +1,99 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.crosstab; + +import software.xdev.dynamicreports.design.base.DRDesignDataset; +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabDataset; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignCrosstabDataset class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignCrosstabDataset implements DRIDesignCrosstabDataset { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRDesignDataset subDataset; + private Boolean dataPreSorted; + private ResetType resetType; + private DRDesignGroup resetGroup; + + /** {@inheritDoc} */ + @Override + public DRDesignDataset getSubDataset() { + return subDataset; + } + + /** + *

Setter for the field subDataset.

+ * + * @param subDataset a {@link software.xdev.dynamicreports.design.base.DRDesignDataset} object. + */ + public void setSubDataset(DRDesignDataset subDataset) { + this.subDataset = subDataset; + } + + /** {@inheritDoc} */ + @Override + public Boolean getDataPreSorted() { + return dataPreSorted; + } + + /** + *

Setter for the field dataPreSorted.

+ * + * @param dataPreSorted a {@link java.lang.Boolean} object. + */ + public void setDataPreSorted(Boolean dataPreSorted) { + this.dataPreSorted = dataPreSorted; + } + + /** {@inheritDoc} */ + @Override + public ResetType getResetType() { + return resetType; + } + + /** + *

Setter for the field resetType.

+ * + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + */ + public void setResetType(ResetType resetType) { + this.resetType = resetType; + } + + /** {@inheritDoc} */ + @Override + public DRDesignGroup getResetGroup() { + return resetGroup; + } + + /** + *

Setter for the field resetGroup.

+ * + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + */ + public void setResetGroup(DRDesignGroup resetGroup) { + this.resetGroup = resetGroup; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabGroup.java new file mode 100644 index 0000000..9cf10d8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabGroup.java @@ -0,0 +1,163 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.crosstab; + +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabGroup; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.CrosstabTotalPosition; +import software.xdev.dynamicreports.report.constant.OrderType; + +/** + *

Abstract DRDesignCrosstabGroup class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class DRDesignCrosstabGroup implements DRIDesignCrosstabGroup { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private CrosstabTotalPosition totalPosition; + private OrderType orderType; + private DRIDesignExpression expression; + private DRIDesignExpression orderByExpression; + private DRIDesignExpression comparatorExpression; + private DRDesignCrosstabCellContent header; + private DRDesignCrosstabCellContent totalHeader; + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

Setter for the field name.

+ * + * @param name a {@link java.lang.String} object. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public CrosstabTotalPosition getTotalPosition() { + return totalPosition; + } + + /** + *

Setter for the field totalPosition.

+ * + * @param totalPosition a {@link software.xdev.dynamicreports.report.constant.CrosstabTotalPosition} object. + */ + public void setTotalPosition(CrosstabTotalPosition totalPosition) { + this.totalPosition = totalPosition; + } + + /** {@inheritDoc} */ + @Override + public OrderType getOrderType() { + return orderType; + } + + /** + *

Setter for the field orderType.

+ * + * @param orderType a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + */ + public void setOrderType(OrderType orderType) { + this.orderType = orderType; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getExpression() { + return expression; + } + + /** + *

Setter for the field expression.

+ * + * @param expression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setExpression(DRIDesignExpression expression) { + this.expression = expression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getOrderByExpression() { + return orderByExpression; + } + + /** + *

Setter for the field orderByExpression.

+ * + * @param orderByExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setOrderByExpression(DRIDesignExpression orderByExpression) { + this.orderByExpression = orderByExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getComparatorExpression() { + return comparatorExpression; + } + + /** + *

Setter for the field comparatorExpression.

+ * + * @param comparatorExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setComparatorExpression(DRIDesignExpression comparatorExpression) { + this.comparatorExpression = comparatorExpression; + } + + /** {@inheritDoc} */ + @Override + public DRDesignCrosstabCellContent getHeader() { + return header; + } + + /** + *

Setter for the field header.

+ * + * @param header a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCellContent} object. + */ + public void setHeader(DRDesignCrosstabCellContent header) { + this.header = header; + } + + /** {@inheritDoc} */ + @Override + public DRDesignCrosstabCellContent getTotalHeader() { + return totalHeader; + } + + /** + *

Setter for the field totalHeader.

+ * + * @param totalHeader a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCellContent} object. + */ + public void setTotalHeader(DRDesignCrosstabCellContent totalHeader) { + this.totalHeader = totalHeader; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabMeasure.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabMeasure.java new file mode 100644 index 0000000..cacbfe5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabMeasure.java @@ -0,0 +1,109 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.crosstab; + +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabMeasure; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; + +/** + *

DRDesignCrosstabMeasure class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignCrosstabMeasure implements DRIDesignCrosstabMeasure { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRIDesignExpression valueExpression; + private Calculation calculation; + private CrosstabPercentageType percentageType; + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

Setter for the field name.

+ * + * @param name a {@link java.lang.String} object. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getValueExpression() { + return valueExpression; + } + + /** + *

Setter for the field valueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setValueExpression(DRIDesignExpression valueExpression) { + this.valueExpression = valueExpression; + } + + /** {@inheritDoc} */ + @Override + public Calculation getCalculation() { + return calculation; + } + + /** + *

Setter for the field calculation.

+ * + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + public void setCalculation(Calculation calculation) { + this.calculation = calculation; + } + + /** {@inheritDoc} */ + @Override + public CrosstabPercentageType getPercentageType() { + return percentageType; + } + + /** + *

Setter for the field percentageType.

+ * + * @param percentageType a {@link software.xdev.dynamicreports.report.constant.CrosstabPercentageType} object. + */ + public void setPercentageType(CrosstabPercentageType percentageType) { + this.percentageType = percentageType; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + if (percentageType != null && percentageType.equals(CrosstabPercentageType.GRAND_TOTAL) && !calculation.equals(Calculation.COUNT) && !calculation.equals(Calculation.DISTINCT_COUNT)) { + return Double.class; + } + return ReportUtils.getVariableValueClass(calculation, valueExpression.getValueClass()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabRowGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabRowGroup.java new file mode 100644 index 0000000..308eaf6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/crosstab/DRDesignCrosstabRowGroup.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.crosstab; + +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabRowGroup; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignCrosstabRowGroup class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignCrosstabRowGroup extends DRDesignCrosstabGroup implements DRIDesignCrosstabRowGroup { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int width; + + /** {@inheritDoc} */ + @Override + public int getWidth() { + return width; + } + + /** + *

Setter for the field width.

+ * + * @param width a int. + */ + public void setWidth(int width) { + this.width = width; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/AbstractDesignComplexExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/AbstractDesignComplexExpression.java new file mode 100644 index 0000000..6e9d927 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/AbstractDesignComplexExpression.java @@ -0,0 +1,92 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.expression; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; + +import java.util.ArrayList; +import java.util.List; + +/** + *

Abstract AbstractDesignComplexExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractDesignComplexExpression implements DRIDesignComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private List expressions; + + /** + *

Constructor for AbstractDesignComplexExpression.

+ */ + protected AbstractDesignComplexExpression() { + this(ReportUtils.generateUniqueName("complexExpression")); + } + + /** + *

Constructor for AbstractDesignComplexExpression.

+ * + * @param name a {@link java.lang.String} object. + */ + protected AbstractDesignComplexExpression(String name) { + this.name = name; + this.expressions = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

addExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void addExpression(DRIDesignExpression expression) { + this.expressions.add(expression); + } + + /** {@inheritDoc} */ + @Override + public List getExpressions() { + return expressions; + } + + /** + *

Setter for the field expressions.

+ * + * @param expressions a {@link java.util.List} object. + */ + public void setExpressions(List expressions) { + this.expressions = expressions; + } + + /** {@inheritDoc} */ + @Override + public String getParameterName() { + return null; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/AbstractDesignSimpleExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/AbstractDesignSimpleExpression.java new file mode 100644 index 0000000..6fad413 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/AbstractDesignSimpleExpression.java @@ -0,0 +1,62 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.expression; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

Abstract AbstractDesignSimpleExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractDesignSimpleExpression implements DRIDesignSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + + /** + *

Constructor for AbstractDesignSimpleExpression.

+ */ + protected AbstractDesignSimpleExpression() { + this(ReportUtils.generateUniqueName("simpleExpression")); + } + + /** + *

Constructor for AbstractDesignSimpleExpression.

+ * + * @param name a {@link java.lang.String} object. + */ + protected AbstractDesignSimpleExpression(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public String getParameterName() { + return null; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignComplexExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignComplexExpression.java new file mode 100644 index 0000000..2596bd9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignComplexExpression.java @@ -0,0 +1,72 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIComplexExpression; + +import java.util.List; + +/** + *

DRDesignComplexExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignComplexExpression extends AbstractDesignComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIComplexExpression complexExpression; + private String parameterName; + + /** + *

Constructor for DRDesignComplexExpression.

+ * + * @param complexExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIComplexExpression} object. + * @param parameterName a {@link java.lang.String} object. + */ + public DRDesignComplexExpression(DRIComplexExpression complexExpression, String parameterName) { + this.complexExpression = complexExpression; + this.parameterName = parameterName; + } + + /** {@inheritDoc} */ + @Override + public Object evaluate(List values, ReportParameters reportParameters) { + return complexExpression.evaluate(values, reportParameters); + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return complexExpression.getValueClass(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return complexExpression.getName(); + } + + /** {@inheritDoc} */ + @Override + public String getParameterName() { + return parameterName; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignJasperExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignJasperExpression.java new file mode 100644 index 0000000..0626940 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignJasperExpression.java @@ -0,0 +1,61 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.expression; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignJasperExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIJasperExpression; + +/** + *

DRDesignJasperExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignJasperExpression implements DRIDesignJasperExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIJasperExpression jasperExpression; + + /** + *

Constructor for DRDesignJasperExpression.

+ * + * @param jasperExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIJasperExpression} object. + */ + public DRDesignJasperExpression(DRIJasperExpression jasperExpression) { + this.jasperExpression = jasperExpression; + } + + /** {@inheritDoc} */ + @Override + public String getExpression() { + return jasperExpression.getExpression(); + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return jasperExpression.getValueClass(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return jasperExpression.getName(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignParameterExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignParameterExpression.java new file mode 100644 index 0000000..4a0ea5a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignParameterExpression.java @@ -0,0 +1,65 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.expression; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignParameterExpression; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignParameterExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignParameterExpression implements DRIDesignParameterExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRIDesignExpression valueExpression; + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

Setter for the field name.

+ * + * @param name a {@link java.lang.String} object. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getValueExpression() { + return valueExpression; + } + + /** + *

Setter for the field valueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setValueExpression(DRIDesignExpression valueExpression) { + this.valueExpression = valueExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignPropertyExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignPropertyExpression.java new file mode 100644 index 0000000..64d90a7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignPropertyExpression.java @@ -0,0 +1,65 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.expression; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignPropertyExpression; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignPropertyExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignPropertyExpression implements DRIDesignPropertyExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRIDesignExpression valueExpression; + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

Setter for the field name.

+ * + * @param name a {@link java.lang.String} object. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getValueExpression() { + return valueExpression; + } + + /** + *

Setter for the field valueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setValueExpression(DRIDesignExpression valueExpression) { + this.valueExpression = valueExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignSimpleExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignSimpleExpression.java new file mode 100644 index 0000000..7aa1a43 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignSimpleExpression.java @@ -0,0 +1,70 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRISimpleExpression; + +/** + *

DRDesignSimpleExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignSimpleExpression extends AbstractDesignSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRISimpleExpression simpleExpression; + private String parameterName; + + /** + *

Constructor for DRDesignSimpleExpression.

+ * + * @param simpleExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRISimpleExpression} object. + * @param parameterName a {@link java.lang.String} object. + */ + public DRDesignSimpleExpression(DRISimpleExpression simpleExpression, String parameterName) { + this.simpleExpression = simpleExpression; + this.parameterName = parameterName; + } + + /** {@inheritDoc} */ + @Override + public Object evaluate(ReportParameters reportParameters) { + return simpleExpression.evaluate(reportParameters); + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return simpleExpression.getValueClass(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return simpleExpression.getName(); + } + + /** {@inheritDoc} */ + @Override + public String getParameterName() { + return parameterName; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignSystemExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignSystemExpression.java new file mode 100644 index 0000000..844c3a5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignSystemExpression.java @@ -0,0 +1,55 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.expression; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSystemExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRISystemExpression; + +/** + *

DRDesignSystemExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignSystemExpression implements DRIDesignSystemExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRISystemExpression systemExpression; + + /** + *

Constructor for DRDesignSystemExpression.

+ * + * @param systemExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRISystemExpression} object. + */ + public DRDesignSystemExpression(DRISystemExpression systemExpression) { + this.systemExpression = systemExpression; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return systemExpression.getValueClass(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return systemExpression.getName(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignValueFormatter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignValueFormatter.java new file mode 100644 index 0000000..52a2678 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/expression/DRDesignValueFormatter.java @@ -0,0 +1,61 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.expression; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; + +import java.util.List; + +/** + *

DRDesignValueFormatter class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignValueFormatter extends AbstractDesignComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIValueFormatter valueFormatter; + + @SuppressWarnings("unchecked") + /** + * Constructor for DRDesignValueFormatter. + * + * @param valueFormatter a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + * @param valueExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRDesignValueFormatter(DRIValueFormatter valueFormatter, DRIDesignExpression valueExpression) { + this.valueFormatter = (DRIValueFormatter) valueFormatter; + addExpression(valueExpression); + } + + /** {@inheritDoc} */ + @Override + public Object evaluate(List values, ReportParameters reportParameters) { + return valueFormatter.format(values.get(0), reportParameters); + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return valueFormatter.getValueClass(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignBaseStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignBaseStyle.java new file mode 100644 index 0000000..1572013 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignBaseStyle.java @@ -0,0 +1,332 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.style; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignBaseStyle; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.Rotation; +import software.xdev.dynamicreports.report.constant.VerticalImageAlignment; +import software.xdev.dynamicreports.report.constant.VerticalTextAlignment; +import org.apache.commons.lang3.builder.EqualsBuilder; + +import java.awt.Color; + +/** + *

Abstract DRDesignBaseStyle class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class DRDesignBaseStyle implements DRIDesignBaseStyle { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Color foregroundColor; + private Color backgroundColor; + private Integer radius; + private ImageScale imageScale; + private HorizontalTextAlignment horizontalTextAlignment; + private VerticalTextAlignment verticalTextAlignment; + private HorizontalImageAlignment horizontalImageAlignment; + private VerticalImageAlignment verticalImageAlignment; + private DRDesignBorder border; + private DRDesignPadding padding; + private DRDesignFont font; + private Rotation rotation; + private String pattern; + private Markup markup; + private DRDesignParagraph paragraph; + private DRDesignPen linePen; + + /** {@inheritDoc} */ + @Override + public Color getForegroundColor() { + return foregroundColor; + } + + /** + *

Setter for the field foregroundColor.

+ * + * @param foregroundColor a {@link java.awt.Color} object. + */ + public void setForegroundColor(Color foregroundColor) { + this.foregroundColor = foregroundColor; + } + + /** {@inheritDoc} */ + @Override + public Color getBackgroundColor() { + return backgroundColor; + } + + /** + *

Setter for the field backgroundColor.

+ * + * @param backgroundColor a {@link java.awt.Color} object. + */ + public void setBackgroundColor(Color backgroundColor) { + this.backgroundColor = backgroundColor; + } + + /** {@inheritDoc} */ + @Override + public Integer getRadius() { + return radius; + } + + /** + *

Setter for the field radius.

+ * + * @param radius a {@link java.lang.Integer} object. + */ + public void setRadius(Integer radius) { + this.radius = radius; + } + + /** {@inheritDoc} */ + @Override + public ImageScale getImageScale() { + return imageScale; + } + + /** + *

Setter for the field imageScale.

+ * + * @param imageScale a {@link software.xdev.dynamicreports.report.constant.ImageScale} object. + */ + public void setImageScale(ImageScale imageScale) { + this.imageScale = imageScale; + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return horizontalTextAlignment; + } + + /** + *

Setter for the field horizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public void setHorizontalTextAlignment(HorizontalTextAlignment horizontalTextAlignment) { + this.horizontalTextAlignment = horizontalTextAlignment; + } + + /** {@inheritDoc} */ + @Override + public VerticalTextAlignment getVerticalTextAlignment() { + return verticalTextAlignment; + } + + /** + *

Setter for the field verticalTextAlignment.

+ * + * @param verticalTextAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalTextAlignment} object. + */ + public void setVerticalTextAlignment(VerticalTextAlignment verticalTextAlignment) { + this.verticalTextAlignment = verticalTextAlignment; + } + + /** {@inheritDoc} */ + @Override + public HorizontalImageAlignment getHorizontalImageAlignment() { + return horizontalImageAlignment; + } + + /** + *

Setter for the field horizontalImageAlignment.

+ * + * @param horizontalImageAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public void setHorizontalImageAlignment(HorizontalImageAlignment horizontalImageAlignment) { + this.horizontalImageAlignment = horizontalImageAlignment; + } + + /** {@inheritDoc} */ + @Override + public VerticalImageAlignment getVerticalImageAlignment() { + return verticalImageAlignment; + } + + /** + *

Setter for the field verticalImageAlignment.

+ * + * @param verticalImageAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalImageAlignment} object. + */ + public void setVerticalImageAlignment(VerticalImageAlignment verticalImageAlignment) { + this.verticalImageAlignment = verticalImageAlignment; + } + + /** {@inheritDoc} */ + @Override + public DRDesignBorder getBorder() { + return border; + } + + /** + *

Setter for the field border.

+ * + * @param border a {@link software.xdev.dynamicreports.design.base.style.DRDesignBorder} object. + */ + public void setBorder(DRDesignBorder border) { + this.border = border; + } + + /** {@inheritDoc} */ + @Override + public DRDesignPadding getPadding() { + return padding; + } + + /** + *

Setter for the field padding.

+ * + * @param padding a {@link software.xdev.dynamicreports.design.base.style.DRDesignPadding} object. + */ + public void setPadding(DRDesignPadding padding) { + this.padding = padding; + } + + /** {@inheritDoc} */ + @Override + public DRDesignFont getFont() { + return font; + } + + /** + *

Setter for the field font.

+ * + * @param font a {@link software.xdev.dynamicreports.design.base.style.DRDesignFont} object. + */ + public void setFont(DRDesignFont font) { + this.font = font; + } + + /** {@inheritDoc} */ + @Override + public Rotation getRotation() { + return rotation; + } + + /** + *

Setter for the field rotation.

+ * + * @param rotation a {@link software.xdev.dynamicreports.report.constant.Rotation} object. + */ + public void setRotation(Rotation rotation) { + this.rotation = rotation; + } + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return pattern; + } + + /** + *

Setter for the field pattern.

+ * + * @param pattern a {@link java.lang.String} object. + */ + public void setPattern(String pattern) { + this.pattern = pattern; + } + + /** {@inheritDoc} */ + @Override + public Markup getMarkup() { + return markup; + } + + /** + *

Setter for the field markup.

+ * + * @param markup a {@link software.xdev.dynamicreports.report.constant.Markup} object. + */ + public void setMarkup(Markup markup) { + this.markup = markup; + } + + /** {@inheritDoc} */ + @Override + public DRDesignParagraph getParagraph() { + return paragraph; + } + + /** + *

Setter for the field paragraph.

+ * + * @param paragraph a {@link software.xdev.dynamicreports.design.base.style.DRDesignParagraph} object. + */ + public void setParagraph(DRDesignParagraph paragraph) { + this.paragraph = paragraph; + } + + /** {@inheritDoc} */ + @Override + public DRDesignPen getLinePen() { + return linePen; + } + + /** + *

Setter for the field linePen.

+ * + * @param linePen a {@link software.xdev.dynamicreports.design.base.style.DRDesignPen} object. + */ + public void setLinePen(DRDesignPen linePen) { + this.linePen = linePen; + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj.getClass() != getClass()) { + return false; + } + + DRDesignBaseStyle o = (DRDesignBaseStyle) obj; + EqualsBuilder equalsBuilder = new EqualsBuilder().append(foregroundColor, o.foregroundColor) + .append(backgroundColor, o.backgroundColor) + .append(radius, o.radius) + .append(imageScale, o.imageScale) + .append(horizontalTextAlignment, o.horizontalTextAlignment) + .append(verticalTextAlignment, o.verticalTextAlignment) + .append(horizontalImageAlignment, o.horizontalImageAlignment) + .append(verticalImageAlignment, o.verticalImageAlignment) + .append(border, o.border) + .append(padding, o.padding) + .append(font, o.font) + .append(rotation, o.rotation) + .append(pattern, o.pattern) + .append(markup, o.markup) + .append(paragraph, o.paragraph) + .append(linePen, o.linePen); + return equalsBuilder.isEquals(); + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignBorder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignBorder.java new file mode 100644 index 0000000..674191d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignBorder.java @@ -0,0 +1,115 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.style; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignBorder; +import software.xdev.dynamicreports.report.constant.Constants; +import org.apache.commons.lang3.builder.EqualsBuilder; + +/** + *

DRDesignBorder class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignBorder implements DRIDesignBorder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRDesignPen topPen; + private DRDesignPen leftPen; + private DRDesignPen bottomPen; + private DRDesignPen rightPen; + + /** {@inheritDoc} */ + @Override + public DRDesignPen getTopPen() { + return topPen; + } + + /** + *

Setter for the field topPen.

+ * + * @param topPen a {@link software.xdev.dynamicreports.design.base.style.DRDesignPen} object. + */ + public void setTopPen(DRDesignPen topPen) { + this.topPen = topPen; + } + + /** {@inheritDoc} */ + @Override + public DRDesignPen getLeftPen() { + return leftPen; + } + + /** + *

Setter for the field leftPen.

+ * + * @param leftPen a {@link software.xdev.dynamicreports.design.base.style.DRDesignPen} object. + */ + public void setLeftPen(DRDesignPen leftPen) { + this.leftPen = leftPen; + } + + /** {@inheritDoc} */ + @Override + public DRDesignPen getBottomPen() { + return bottomPen; + } + + /** + *

Setter for the field bottomPen.

+ * + * @param bottomPen a {@link software.xdev.dynamicreports.design.base.style.DRDesignPen} object. + */ + public void setBottomPen(DRDesignPen bottomPen) { + this.bottomPen = bottomPen; + } + + /** {@inheritDoc} */ + @Override + public DRDesignPen getRightPen() { + return rightPen; + } + + /** + *

Setter for the field rightPen.

+ * + * @param rightPen a {@link software.xdev.dynamicreports.design.base.style.DRDesignPen} object. + */ + public void setRightPen(DRDesignPen rightPen) { + this.rightPen = rightPen; + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj.getClass() != getClass()) { + return false; + } + + DRDesignBorder o = (DRDesignBorder) obj; + EqualsBuilder equalsBuilder = new EqualsBuilder().append(topPen, o.topPen).append(leftPen, o.leftPen).append(bottomPen, o.bottomPen).append(rightPen, o.rightPen); + return equalsBuilder.isEquals(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignConditionalStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignConditionalStyle.java new file mode 100644 index 0000000..b3497f1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignConditionalStyle.java @@ -0,0 +1,78 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.style; + +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.style.DRIDesignConditionalStyle; +import software.xdev.dynamicreports.report.constant.Constants; +import org.apache.commons.lang3.builder.EqualsBuilder; + +/** + *

DRDesignConditionalStyle class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignConditionalStyle extends DRDesignBaseStyle implements DRIDesignConditionalStyle { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIDesignExpression conditionExpression; + private DRIDesignDataset dataset; + + /** {@inheritDoc} */ + @Override + public DRIDesignExpression getConditionExpression() { + return conditionExpression; + } + + /** + *

Setter for the field conditionExpression.

+ * + * @param conditionExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public void setConditionExpression(DRIDesignExpression conditionExpression) { + this.conditionExpression = conditionExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignDataset getDataset() { + return dataset; + } + + /** + *

Setter for the field dataset.

+ * + * @param dataset a {@link software.xdev.dynamicreports.design.definition.DRIDesignDataset} object. + */ + public void setDataset(DRIDesignDataset dataset) { + this.dataset = dataset; + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + EqualsBuilder equalsBuilder = new EqualsBuilder().appendSuper(super.equals(obj)); + if (equalsBuilder.isEquals()) { + DRDesignConditionalStyle o = (DRDesignConditionalStyle) obj; + equalsBuilder.append(conditionExpression, o.conditionExpression).append(dataset, o.dataset); + } + return equalsBuilder.isEquals(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignFont.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignFont.java new file mode 100644 index 0000000..9dc7ec7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignFont.java @@ -0,0 +1,203 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.style; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignFont; +import software.xdev.dynamicreports.report.constant.Constants; +import org.apache.commons.lang3.builder.EqualsBuilder; + +/** + *

DRDesignFont class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignFont implements DRIDesignFont { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String fontName; + private Integer fontSize; + private Boolean bold; + private Boolean italic; + private Boolean underline; + private Boolean strikeThrough; + private String pdfFontName; + private String pdfEncoding; + private Boolean pdfEmbedded; + + /** {@inheritDoc} */ + @Override + public String getFontName() { + return fontName; + } + + /** + *

Setter for the field fontName.

+ * + * @param fontName a {@link java.lang.String} object. + */ + public void setFontName(String fontName) { + this.fontName = fontName; + } + + /** {@inheritDoc} */ + @Override + public Boolean getBold() { + return bold; + } + + /** + *

Setter for the field bold.

+ * + * @param bold a {@link java.lang.Boolean} object. + */ + public void setBold(Boolean bold) { + this.bold = bold; + } + + /** {@inheritDoc} */ + @Override + public Boolean getItalic() { + return italic; + } + + /** + *

Setter for the field italic.

+ * + * @param italic a {@link java.lang.Boolean} object. + */ + public void setItalic(Boolean italic) { + this.italic = italic; + } + + /** {@inheritDoc} */ + @Override + public Boolean getUnderline() { + return underline; + } + + /** + *

Setter for the field underline.

+ * + * @param underline a {@link java.lang.Boolean} object. + */ + public void setUnderline(Boolean underline) { + this.underline = underline; + } + + /** {@inheritDoc} */ + @Override + public Boolean getStrikeThrough() { + return strikeThrough; + } + + /** + *

Setter for the field strikeThrough.

+ * + * @param strikeThrough a {@link java.lang.Boolean} object. + */ + public void setStrikeThrough(Boolean strikeThrough) { + this.strikeThrough = strikeThrough; + } + + /** {@inheritDoc} */ + @Override + public Integer getFontSize() { + return fontSize; + } + + /** + *

Setter for the field fontSize.

+ * + * @param fontSize a {@link java.lang.Integer} object. + */ + public void setFontSize(Integer fontSize) { + this.fontSize = fontSize; + } + + /** {@inheritDoc} */ + @Override + public String getPdfFontName() { + return pdfFontName; + } + + /** + *

Setter for the field pdfFontName.

+ * + * @param pdfFontName a {@link java.lang.String} object. + */ + public void setPdfFontName(String pdfFontName) { + this.pdfFontName = pdfFontName; + } + + /** {@inheritDoc} */ + @Override + public String getPdfEncoding() { + return pdfEncoding; + } + + /** + *

Setter for the field pdfEncoding.

+ * + * @param pdfEncoding a {@link java.lang.String} object. + */ + public void setPdfEncoding(String pdfEncoding) { + this.pdfEncoding = pdfEncoding; + } + + /** {@inheritDoc} */ + @Override + public Boolean getPdfEmbedded() { + return pdfEmbedded; + } + + /** + *

Setter for the field pdfEmbedded.

+ * + * @param pdfEmbedded a {@link java.lang.Boolean} object. + */ + public void setPdfEmbedded(Boolean pdfEmbedded) { + this.pdfEmbedded = pdfEmbedded; + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj.getClass() != getClass()) { + return false; + } + + DRDesignFont o = (DRDesignFont) obj; + EqualsBuilder equalsBuilder = new EqualsBuilder().append(fontName, o.fontName) + .append(fontSize, o.fontSize) + .append(bold, o.bold) + .append(italic, o.italic) + .append(underline, o.underline) + .append(strikeThrough, o.strikeThrough) + .append(pdfFontName, o.pdfFontName) + .append(pdfEncoding, o.pdfEncoding) + .append(pdfEmbedded, o.pdfEmbedded); + return equalsBuilder.isEquals(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignPadding.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignPadding.java new file mode 100644 index 0000000..9eeb7d1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignPadding.java @@ -0,0 +1,115 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.style; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignPadding; +import software.xdev.dynamicreports.report.constant.Constants; +import org.apache.commons.lang3.builder.EqualsBuilder; + +/** + *

DRDesignPadding class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignPadding implements DRIDesignPadding { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer top; + private Integer left; + private Integer bottom; + private Integer right; + + /** {@inheritDoc} */ + @Override + public Integer getTop() { + return top; + } + + /** + *

Setter for the field top.

+ * + * @param top a {@link java.lang.Integer} object. + */ + public void setTop(Integer top) { + this.top = top; + } + + /** {@inheritDoc} */ + @Override + public Integer getLeft() { + return left; + } + + /** + *

Setter for the field left.

+ * + * @param left a {@link java.lang.Integer} object. + */ + public void setLeft(Integer left) { + this.left = left; + } + + /** {@inheritDoc} */ + @Override + public Integer getBottom() { + return bottom; + } + + /** + *

Setter for the field bottom.

+ * + * @param bottom a {@link java.lang.Integer} object. + */ + public void setBottom(Integer bottom) { + this.bottom = bottom; + } + + /** {@inheritDoc} */ + @Override + public Integer getRight() { + return right; + } + + /** + *

Setter for the field right.

+ * + * @param right a {@link java.lang.Integer} object. + */ + public void setRight(Integer right) { + this.right = right; + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj.getClass() != getClass()) { + return false; + } + + DRDesignPadding o = (DRDesignPadding) obj; + EqualsBuilder equalsBuilder = new EqualsBuilder().append(top, o.top).append(left, o.left).append(bottom, o.bottom).append(right, o.right); + return equalsBuilder.isEquals(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignParagraph.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignParagraph.java new file mode 100644 index 0000000..29e4ad6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignParagraph.java @@ -0,0 +1,207 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.style; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignParagraph; +import software.xdev.dynamicreports.design.definition.style.DRIDesignTabStop; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.LineSpacing; +import org.apache.commons.lang3.builder.EqualsBuilder; + +import java.util.List; + +/** + *

DRDesignParagraph class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignParagraph implements DRIDesignParagraph { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private LineSpacing lineSpacing; + private Float lineSpacingSize; + private Integer firstLineIndent; + private Integer leftIndent; + private Integer rightIndent; + private Integer spacingBefore; + private Integer spacingAfter; + private Integer tabStopWidth; + private List tabStops; + + /** {@inheritDoc} */ + @Override + public LineSpacing getLineSpacing() { + return lineSpacing; + } + + /** + *

Setter for the field lineSpacing.

+ * + * @param lineSpacing a {@link software.xdev.dynamicreports.report.constant.LineSpacing} object. + */ + public void setLineSpacing(LineSpacing lineSpacing) { + this.lineSpacing = lineSpacing; + } + + /** {@inheritDoc} */ + @Override + public Float getLineSpacingSize() { + return lineSpacingSize; + } + + /** + *

Setter for the field lineSpacingSize.

+ * + * @param lineSpacingSize a {@link java.lang.Float} object. + */ + public void setLineSpacingSize(Float lineSpacingSize) { + this.lineSpacingSize = lineSpacingSize; + } + + /** {@inheritDoc} */ + @Override + public Integer getFirstLineIndent() { + return firstLineIndent; + } + + /** + *

Setter for the field firstLineIndent.

+ * + * @param firstLineIndent a {@link java.lang.Integer} object. + */ + public void setFirstLineIndent(Integer firstLineIndent) { + this.firstLineIndent = firstLineIndent; + } + + /** {@inheritDoc} */ + @Override + public Integer getLeftIndent() { + return leftIndent; + } + + /** + *

Setter for the field leftIndent.

+ * + * @param leftIndent a {@link java.lang.Integer} object. + */ + public void setLeftIndent(Integer leftIndent) { + this.leftIndent = leftIndent; + } + + /** {@inheritDoc} */ + @Override + public Integer getRightIndent() { + return rightIndent; + } + + /** + *

Setter for the field rightIndent.

+ * + * @param rightIndent a {@link java.lang.Integer} object. + */ + public void setRightIndent(Integer rightIndent) { + this.rightIndent = rightIndent; + } + + /** {@inheritDoc} */ + @Override + public Integer getSpacingBefore() { + return spacingBefore; + } + + /** + *

Setter for the field spacingBefore.

+ * + * @param spacingBefore a {@link java.lang.Integer} object. + */ + public void setSpacingBefore(Integer spacingBefore) { + this.spacingBefore = spacingBefore; + } + + /** {@inheritDoc} */ + @Override + public Integer getSpacingAfter() { + return spacingAfter; + } + + /** + *

Setter for the field spacingAfter.

+ * + * @param spacingAfter a {@link java.lang.Integer} object. + */ + public void setSpacingAfter(Integer spacingAfter) { + this.spacingAfter = spacingAfter; + } + + /** {@inheritDoc} */ + @Override + public Integer getTabStopWidth() { + return tabStopWidth; + } + + /** + *

Setter for the field tabStopWidth.

+ * + * @param tabStopWidth a {@link java.lang.Integer} object. + */ + public void setTabStopWidth(Integer tabStopWidth) { + this.tabStopWidth = tabStopWidth; + } + + /** {@inheritDoc} */ + @Override + public List getTabStops() { + return tabStops; + } + + /** + *

Setter for the field tabStops.

+ * + * @param tabStops a {@link java.util.List} object. + */ + public void setTabStops(List tabStops) { + this.tabStops = tabStops; + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj.getClass() != getClass()) { + return false; + } + + DRDesignParagraph o = (DRDesignParagraph) obj; + EqualsBuilder equalsBuilder = new EqualsBuilder().append(lineSpacing, o.lineSpacing) + .append(lineSpacingSize, o.lineSpacingSize) + .append(firstLineIndent, o.firstLineIndent) + .append(leftIndent, o.leftIndent) + .append(rightIndent, o.rightIndent) + .append(spacingBefore, o.spacingBefore) + .append(spacingAfter, o.spacingAfter) + .append(tabStopWidth, o.tabStopWidth) + .append(tabStops, o.tabStops); + return equalsBuilder.isEquals(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignPen.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignPen.java new file mode 100644 index 0000000..2bc67c6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignPen.java @@ -0,0 +1,102 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.style; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignPen; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.LineStyle; +import org.apache.commons.lang3.builder.EqualsBuilder; + +import java.awt.Color; + +/** + *

DRDesignPen class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignPen implements DRIDesignPen { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Float lineWidth; + private LineStyle lineStyle; + private Color lineColor; + + /** {@inheritDoc} */ + @Override + public Float getLineWidth() { + return lineWidth; + } + + /** + *

Setter for the field lineWidth.

+ * + * @param lineWidth a {@link java.lang.Float} object. + */ + public void setLineWidth(Float lineWidth) { + this.lineWidth = lineWidth; + } + + /** {@inheritDoc} */ + @Override + public LineStyle getLineStyle() { + return lineStyle; + } + + /** + *

Setter for the field lineStyle.

+ * + * @param lineStyle a {@link software.xdev.dynamicreports.report.constant.LineStyle} object. + */ + public void setLineStyle(LineStyle lineStyle) { + this.lineStyle = lineStyle; + } + + /** {@inheritDoc} */ + @Override + public Color getLineColor() { + return lineColor; + } + + /** + *

Setter for the field lineColor.

+ * + * @param lineColor a {@link java.awt.Color} object. + */ + public void setLineColor(Color lineColor) { + this.lineColor = lineColor; + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj.getClass() != getClass()) { + return false; + } + + DRDesignPen o = (DRDesignPen) obj; + EqualsBuilder equalsBuilder = new EqualsBuilder().append(lineWidth, o.lineWidth).append(lineStyle, o.lineStyle).append(lineColor, o.lineColor); + return equalsBuilder.isEquals(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignStyle.java new file mode 100644 index 0000000..a62527c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignStyle.java @@ -0,0 +1,117 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.style; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignStyle; +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; +import org.apache.commons.lang3.Validate; +import org.apache.commons.lang3.builder.EqualsBuilder; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRDesignStyle class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignStyle extends DRDesignBaseStyle implements DRIDesignStyle { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRDesignStyle parentStyle; + private List conditionalStyles; + + /** + *

Constructor for DRDesignStyle.

+ */ + public DRDesignStyle() { + this(ReportUtils.generateUniqueName("style")); + } + + /** + *

Constructor for DRDesignStyle.

+ * + * @param name a {@link java.lang.String} object. + */ + public DRDesignStyle(String name) { + this.name = Validate.notBlank(name); + this.conditionalStyles = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public DRDesignStyle getParentStyle() { + return parentStyle; + } + + /** + *

Setter for the field parentStyle.

+ * + * @param parentStyle a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + */ + public void setParentStyle(DRDesignStyle parentStyle) { + this.parentStyle = parentStyle; + } + + /** {@inheritDoc} */ + @Override + public List getConditionalStyles() { + return conditionalStyles; + } + + /** + *

Setter for the field conditionalStyles.

+ * + * @param conditionalStyles a {@link java.util.List} object. + */ + public void setConditionalStyles(List conditionalStyles) { + this.conditionalStyles = conditionalStyles; + } + + /** + *

addConditionalStyle.

+ * + * @param conditionalStyle a {@link software.xdev.dynamicreports.design.base.style.DRDesignConditionalStyle} object. + */ + public void addConditionalStyle(DRDesignConditionalStyle conditionalStyle) { + this.conditionalStyles.add(conditionalStyle); + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + EqualsBuilder equalsBuilder = new EqualsBuilder().appendSuper(super.equals(obj)); + if (equalsBuilder.isEquals()) { + DRDesignStyle o = (DRDesignStyle) obj; + if (!(parentStyle == null ? o.getParentStyle() == null : parentStyle.getName().equals(o.getParentStyle().getName()))) { + return false; + } + equalsBuilder.append(name, o.name).append(conditionalStyles, o.conditionalStyles); + } + return equalsBuilder.isEquals(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignTabStop.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignTabStop.java new file mode 100644 index 0000000..5399d39 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/base/style/DRDesignTabStop.java @@ -0,0 +1,84 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.base.style; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignTabStop; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.TabStopAlignment; +import org.apache.commons.lang3.builder.EqualsBuilder; + +/** + *

DRDesignTabStop class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignTabStop implements DRIDesignTabStop { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int position; + private TabStopAlignment alignment; + + /** {@inheritDoc} */ + @Override + public int getPosition() { + return position; + } + + /** + *

Setter for the field position.

+ * + * @param position a int. + */ + public void setPosition(int position) { + this.position = position; + } + + /** {@inheritDoc} */ + @Override + public TabStopAlignment getAlignment() { + return alignment; + } + + /** + *

Setter for the field alignment.

+ * + * @param alignment a {@link software.xdev.dynamicreports.report.constant.TabStopAlignment} object. + */ + public void setAlignment(TabStopAlignment alignment) { + this.alignment = alignment; + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj.getClass() != getClass()) { + return false; + } + + DRDesignTabStop o = (DRDesignTabStop) obj; + EqualsBuilder equalsBuilder = new EqualsBuilder().append(position, o.position).append(alignment, o.alignment); + return equalsBuilder.isEquals(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/ComponentGroupType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/ComponentGroupType.java new file mode 100644 index 0000000..18e6546 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/ComponentGroupType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.constant; + +/** + *

ComponentGroupType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum ComponentGroupType { + FRAME, NONE +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/DefaultStyleType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/DefaultStyleType.java new file mode 100644 index 0000000..d93750f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/DefaultStyleType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.constant; + +/** + *

DefaultStyleType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum DefaultStyleType { + NONE, TEXT, COLUMN, COLUMN_TITLE, GROUP, GROUP_TITLE, SUBTOTAL, IMAGE +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/EvaluationTime.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/EvaluationTime.java new file mode 100644 index 0000000..96e902d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/EvaluationTime.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.constant; + +/** + *

EvaluationTime class.

+ * + * @author Ricardo Mariaca + * + */ +public enum EvaluationTime { + NOW, REPORT, PAGE, COLUMN, GROUP, BAND, AUTO +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/ResetType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/ResetType.java new file mode 100644 index 0000000..e2f40ca --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/constant/ResetType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.constant; + +/** + *

ResetType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum ResetType { + NONE, REPORT, PAGE, COLUMN, GROUP +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignBand.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignBand.java new file mode 100644 index 0000000..01f28f2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignBand.java @@ -0,0 +1,76 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.definition.component.DRIDesignComponent; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.SplitType; + +import java.io.Serializable; + +/** + *

DRIDesignBand interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignBand extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getSplitType(); + + /** + *

getBandComponent.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.component.DRIDesignComponent} object. + */ + public DRIDesignComponent getBandComponent(); + + /** + *

getList.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignList} object. + */ + public DRDesignList getList(); + + /** + *

getHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getHeight(); + + /** + *

getPrintWhenExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getPrintWhenExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignDataset.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignDataset.java new file mode 100644 index 0000000..e435f7b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignDataset.java @@ -0,0 +1,120 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignJasperExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSystemExpression; + +import java.io.Serializable; +import java.util.Collection; + +/** + *

DRIDesignDataset interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignDataset extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getFields.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getFields(); + + /** + *

getVariables.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getVariables(); + + /** + *

getSystemExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getSystemExpressions(); + + /** + *

getJasperExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getJasperExpressions(); + + /** + *

getSimpleExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getSimpleExpressions(); + + /** + *

getComplexExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getComplexExpressions(); + + /** + *

getSorts.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getSorts(); + + /** + *

getQuery.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignQuery} object. + */ + public DRIDesignQuery getQuery(); + + /** + *

getConnectionExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getConnectionExpression(); + + /** + *

getDataSourceExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getDataSourceExpression(); + + /** + *

getFilterExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getFilterExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignField.java new file mode 100644 index 0000000..7f341bb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignField.java @@ -0,0 +1,43 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; + +/** + *

DRIDesignField interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignField extends DRIDesignExpression { + + /** + *

isExternal.

+ * + * @return a boolean. + */ + public boolean isExternal(); + + /** + *

getDescription.

+ * + * @return a {@link java.lang.String} object. + */ + public String getDescription(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignGroup.java new file mode 100644 index 0000000..6cc0cba --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignGroup.java @@ -0,0 +1,117 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; + +import java.io.Serializable; +import java.util.List; + +/** + *

DRIDesignGroup interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignGroup extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getGroupExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getGroupExpression(); + + /** + *

getHeaderBands.

+ * + * @return a {@link java.util.List} object. + */ + public List getHeaderBands(); + + /** + *

getFooterBands.

+ * + * @return a {@link java.util.List} object. + */ + public List getFooterBands(); + + /** + *

isStartInNewPage.

+ * + * @return a boolean. + */ + public boolean isStartInNewPage(); + + /** + *

isStartInNewColumn.

+ * + * @return a boolean. + */ + public boolean isStartInNewColumn(); + + /** + *

isReprintHeaderOnEachPage.

+ * + * @return a boolean. + */ + public boolean isReprintHeaderOnEachPage(); + + /** + *

isResetPageNumber.

+ * + * @return a boolean. + */ + public boolean isResetPageNumber(); + + /** + *

getMinHeightToStartNewPage.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getMinHeightToStartNewPage(); + + /** + *

getFooterPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.GroupFooterPosition} object. + */ + public GroupFooterPosition getFooterPosition(); + + /** + *

isKeepTogether.

+ * + * @return a boolean. + */ + public boolean isKeepTogether(); + + /** + *

isHeaderWithSubtotal.

+ * + * @return a boolean. + */ + public boolean isHeaderWithSubtotal(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignHyperLink.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignHyperLink.java new file mode 100644 index 0000000..87243da --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignHyperLink.java @@ -0,0 +1,73 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; + +import java.io.Serializable; + +/** + *

DRIDesignHyperLink interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignHyperLink extends Serializable { + + /** + *

getAnchorExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getAnchorExpression(); + + /** + *

getPageExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getPageExpression(); + + /** + *

getReferenceExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getReferenceExpression(); + + /** + *

getTooltipExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getTooltipExpression(); + + /** + *

getType.

+ * + * @return a {@link java.lang.String} object. + */ + public String getType(); + + /** + *

getTarget.

+ * + * @return a {@link java.lang.String} object. + */ + public String getTarget(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignMargin.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignMargin.java new file mode 100644 index 0000000..aecc420 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignMargin.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import java.io.Serializable; + +/** + *

DRIDesignMargin interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignMargin extends Serializable { + + /** + *

getTop.

+ * + * @return a int. + */ + public int getTop(); + + /** + *

getLeft.

+ * + * @return a int. + */ + public int getLeft(); + + /** + *

getBottom.

+ * + * @return a int. + */ + public int getBottom(); + + /** + *

getRight.

+ * + * @return a int. + */ + public int getRight(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignPage.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignPage.java new file mode 100644 index 0000000..e40b9f1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignPage.java @@ -0,0 +1,80 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import software.xdev.dynamicreports.report.constant.PageOrientation; + +import java.io.Serializable; + +/** + *

DRIDesignPage interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignPage extends Serializable { + + /** + *

getWidth.

+ * + * @return a int. + */ + public int getWidth(); + + /** + *

getHeight.

+ * + * @return a int. + */ + public int getHeight(); + + /** + *

getOrientation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + */ + public PageOrientation getOrientation(); + + /** + *

getMargin.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignMargin} object. + */ + public DRIDesignMargin getMargin(); + + /** + *

getColumnsPerPage.

+ * + * @return a int. + */ + public int getColumnsPerPage(); + + /** + *

getColumnSpace.

+ * + * @return a int. + */ + public int getColumnSpace(); + + /** + *

getColumnWidth.

+ * + * @return a int. + */ + public int getColumnWidth(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignParameter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignParameter.java new file mode 100644 index 0000000..086dd37 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignParameter.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import java.io.Serializable; + +/** + *

DRIDesignParameter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignParameter extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getValueClass.

+ * + * @return a {@link java.lang.Class} object. + */ + public Class getValueClass(); + + /** + *

getValue.

+ * + * @return a {@link java.lang.Object} object. + */ + public Object getValue(); + + /** + *

isExternal.

+ * + * @return a boolean. + */ + public boolean isExternal(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignQuery.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignQuery.java new file mode 100644 index 0000000..7a46c7f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignQuery.java @@ -0,0 +1,43 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import java.io.Serializable; + +/** + *

DRIDesignQuery interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignQuery extends Serializable { + + /** + *

getText.

+ * + * @return a {@link java.lang.String} object. + */ + public String getText(); + + /** + *

getLanguage.

+ * + * @return a {@link java.lang.String} object. + */ + public String getLanguage(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignReport.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignReport.java new file mode 100644 index 0000000..980fbc9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignReport.java @@ -0,0 +1,364 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignJasperExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSystemExpression; +import software.xdev.dynamicreports.design.definition.style.DRIDesignStyle; +import software.xdev.dynamicreports.jasper.base.tableofcontents.JasperTocHeading; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.DRIScriptlet; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; + +/** + *

DRIDesignReport interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignReport extends Serializable { + + /** + *

getTemplateDesign.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignTemplateDesign} object. + */ + public DRIDesignTemplateDesign getTemplateDesign(); + + /** + *

getReportName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getReportName(); + + /** + *

getLocale.

+ * + * @return a {@link java.util.Locale} object. + */ + public Locale getLocale(); + + /** + *

getResourceBundle.

+ * + * @return a {@link java.util.ResourceBundle} object. + */ + public ResourceBundle getResourceBundle(); + + /** + *

getResourceBundleName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getResourceBundleName(); + + /** + *

isIgnorePagination.

+ * + * @return a boolean. + */ + public boolean isIgnorePagination(); + + /** + *

getProperties.

+ * + * @return a {@link java.util.Properties} object. + */ + public Properties getProperties(); + + /** + *

getQuery.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignQuery} object. + */ + public DRIDesignQuery getQuery(); + + /** + *

getPage.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignPage} object. + */ + public DRIDesignPage getPage(); + + /** + *

getWhenNoDataType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenNoDataType} object. + */ + public WhenNoDataType getWhenNoDataType(); + + /** + *

getWhenResourceMissingType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + */ + public WhenResourceMissingType getWhenResourceMissingType(); + + /** + *

isTitleOnANewPage.

+ * + * @return a boolean. + */ + public boolean isTitleOnANewPage(); + + /** + *

isSummaryOnANewPage.

+ * + * @return a boolean. + */ + public boolean isSummaryOnANewPage(); + + /** + *

isSummaryWithPageHeaderAndFooter.

+ * + * @return a boolean. + */ + public boolean isSummaryWithPageHeaderAndFooter(); + + /** + *

isFloatColumnFooter.

+ * + * @return a boolean. + */ + public boolean isFloatColumnFooter(); + + /** + *

getPrintOrder.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Orientation} object. + */ + public Orientation getPrintOrder(); + + /** + *

getColumnDirection.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public RunDirection getColumnDirection(); + + /** + *

getLanguage.

+ * + * @return a {@link java.lang.String} object. + */ + public String getLanguage(); + + /** + *

isTableOfContents.

+ * + * @return a boolean. + */ + public boolean isTableOfContents(); + + /** + *

getTableOfContentsHeadings.

+ * + * @return a {@link java.util.Map} object. + */ + public Map getTableOfContentsHeadings(); + + /** + *

getTableOfContentsCustomizer.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer} object. + */ + public DRITableOfContentsCustomizer getTableOfContentsCustomizer(); + + /** + *

getFilterExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getFilterExpression(); + + /** + *

getParameters.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getParameters(); + + /** + *

getParameterValues.

+ * + * @return a {@link java.util.Map} object. + */ + public Map getParameterValues(); + + /** + *

getScriptlets.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getScriptlets(); + + /** + *

getFields.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getFields(); + + /** + *

getSystemExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getSystemExpressions(); + + /** + *

getJasperExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getJasperExpressions(); + + /** + *

getSimpleExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getSimpleExpressions(); + + /** + *

getStyles.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getStyles(); + + /** + *

getGroups.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getGroups(); + + /** + *

getVariables.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getVariables(); + + /** + *

getComplexExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getComplexExpressions(); + + /** + *

getSorts.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getSorts(); + + /** + *

getDatasets.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getDatasets(); + + /** + *

getTitleBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignBand} object. + */ + public DRIDesignBand getTitleBand(); + + /** + *

getPageHeaderBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignBand} object. + */ + public DRIDesignBand getPageHeaderBand(); + + /** + *

getPageFooterBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignBand} object. + */ + public DRIDesignBand getPageFooterBand(); + + /** + *

getColumnHeaderBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignBand} object. + */ + public DRIDesignBand getColumnHeaderBand(); + + /** + *

getColumnFooterBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignBand} object. + */ + public DRIDesignBand getColumnFooterBand(); + + /** + *

getDetailBands.

+ * + * @return a {@link java.util.List} object. + */ + public List getDetailBands(); + + /** + *

getLastPageFooterBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignBand} object. + */ + public DRIDesignBand getLastPageFooterBand(); + + /** + *

getSummaryBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignBand} object. + */ + public DRIDesignBand getSummaryBand(); + + /** + *

getNoDataBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignBand} object. + */ + public DRIDesignBand getNoDataBand(); + + /** + *

getBackgroundBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignBand} object. + */ + public DRIDesignBand getBackgroundBand(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignSort.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignSort.java new file mode 100644 index 0000000..e355151 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignSort.java @@ -0,0 +1,46 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.OrderType; + +import java.io.Serializable; + +/** + *

DRIDesignSort interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignSort extends Serializable { + + /** + *

getExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getExpression(); + + /** + *

getOrderType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + */ + public OrderType getOrderType(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignTableOfContentsHeading.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignTableOfContentsHeading.java new file mode 100644 index 0000000..bda7e33 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignTableOfContentsHeading.java @@ -0,0 +1,39 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import software.xdev.dynamicreports.design.definition.component.DRIDesignTextField; + +import java.io.Serializable; + +/** + *

DRIDesignTableOfContentsHeading interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignTableOfContentsHeading extends Serializable { + + /** + *

getReferenceField.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.component.DRIDesignTextField} object. + */ + public DRIDesignTextField getReferenceField(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignTemplateDesign.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignTemplateDesign.java new file mode 100644 index 0000000..e1dee4f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignTemplateDesign.java @@ -0,0 +1,102 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import software.xdev.dynamicreports.report.exception.DRException; + +import java.io.Serializable; + +/** + *

DRIDesignTemplateDesign interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignTemplateDesign extends Serializable { + + /** + *

getTitleComponentsCount.

+ * + * @return a int. + */ + public int getTitleComponentsCount(); + + /** + *

getPageHeaderComponentsCount.

+ * + * @return a int. + */ + public int getPageHeaderComponentsCount(); + + /** + *

getPageFooterComponentsCount.

+ * + * @return a int. + */ + public int getPageFooterComponentsCount(); + + /** + *

getColumnHeaderComponentsCount.

+ * + * @return a int. + */ + public int getColumnHeaderComponentsCount(); + + /** + *

getColumnFooterComponentsCount.

+ * + * @return a int. + */ + public int getColumnFooterComponentsCount(); + + /** + *

getLastPageFooterComponentsCount.

+ * + * @return a int. + */ + public int getLastPageFooterComponentsCount(); + + /** + *

getSummaryComponentsCount.

+ * + * @return a int. + */ + public int getSummaryComponentsCount(); + + /** + *

getNoDataComponentsCount.

+ * + * @return a int. + */ + public int getNoDataComponentsCount(); + + /** + *

getBackgroundComponentsCount.

+ * + * @return a int. + */ + public int getBackgroundComponentsCount(); + + /** + *

getDesign.

+ * + * @return a {@link java.lang.Object} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public Object getDesign() throws DRException; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignVariable.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignVariable.java new file mode 100644 index 0000000..a7d736a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/DRIDesignVariable.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition; + +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Calculation; + +/** + *

DRIDesignVariable interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignVariable extends DRIDesignExpression { + + /** + *

getValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getValueExpression(); + + /** + *

getInitialValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getInitialValueExpression(); + + /** + *

getCalculation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + public Calculation getCalculation(); + + /** + *

getResetType.

+ * + * @return a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + */ + public ResetType getResetType(); + + /** + *

getResetGroup.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignGroup} object. + */ + public DRIDesignGroup getResetGroup(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignBreak.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignBreak.java new file mode 100644 index 0000000..0870add --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignBreak.java @@ -0,0 +1,37 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.report.constant.BreakType; + +/** + *

DRIDesignBreak interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignBreak extends DRIDesignComponent { + + /** + *

getType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.BreakType} object. + */ + public BreakType getType(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignComponent.java new file mode 100644 index 0000000..362046f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignComponent.java @@ -0,0 +1,149 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; +import software.xdev.dynamicreports.design.definition.DRIDesignTableOfContentsHeading; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignPropertyExpression; +import software.xdev.dynamicreports.design.definition.style.DRIDesignStyle; +import software.xdev.dynamicreports.report.constant.ComponentPositionType; +import software.xdev.dynamicreports.report.constant.StretchType; + +import java.io.Serializable; +import java.util.List; + +/** + *

DRIDesignComponent interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignComponent extends Serializable { + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getUniqueName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getUniqueName(); + + /** + *

getStyle.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignStyle} object. + */ + public DRIDesignStyle getStyle(); + + /** + *

getX.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getX(); + + /** + *

getY.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getY(); + + /** + *

getWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getWidth(); + + /** + *

getHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getHeight(); + + /** + *

getPrintWhenExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getPrintWhenExpression(); + + /** + *

isRemoveLineWhenBlank.

+ * + * @return a boolean. + */ + public boolean isRemoveLineWhenBlank(); + + /** + *

getPropertyExpressions.

+ * + * @return a {@link java.util.List} object. + */ + public List getPropertyExpressions(); + + /** + *

getPositionType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ComponentPositionType} object. + */ + public ComponentPositionType getPositionType(); + + /** + *

getStretchType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.StretchType} object. + */ + public StretchType getStretchType(); + + /** + *

isPrintInFirstWholeBand.

+ * + * @return a boolean. + */ + public boolean isPrintInFirstWholeBand(); + + /** + *

isPrintWhenDetailOverflows.

+ * + * @return a boolean. + */ + public boolean isPrintWhenDetailOverflows(); + + /** + *

getPrintWhenGroupChanges.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignGroup} object. + */ + public DRIDesignGroup getPrintWhenGroupChanges(); + + /** + *

getTableOfContentsHeading.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignTableOfContentsHeading} object. + */ + public DRIDesignTableOfContentsHeading getTableOfContentsHeading(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignEllipse.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignEllipse.java new file mode 100644 index 0000000..1a7b90d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignEllipse.java @@ -0,0 +1,37 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignPen; + +/** + *

DRIDesignEllipse interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignEllipse extends DRIDesignComponent { + + /** + *

getPen.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignPen} object. + */ + public DRIDesignPen getPen(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignFiller.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignFiller.java new file mode 100644 index 0000000..7d56efc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignFiller.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +/** + *

DRIDesignFiller interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignFiller extends DRIDesignComponent { + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignGenericElement.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignGenericElement.java new file mode 100644 index 0000000..e032b67 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignGenericElement.java @@ -0,0 +1,69 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.design.constant.EvaluationTime; +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignParameterExpression; + +import java.util.List; + +/** + *

DRIDesignGenericElement interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignGenericElement extends DRIDesignComponent { + + /** + *

getGenericElementNamespace.

+ * + * @return a {@link java.lang.String} object. + */ + public String getGenericElementNamespace(); + + /** + *

getGenericElementName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getGenericElementName(); + + /** + *

getEvaluationTime.

+ * + * @return a {@link software.xdev.dynamicreports.design.constant.EvaluationTime} object. + */ + public EvaluationTime getEvaluationTime(); + + /** + *

getEvaluationGroup.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignGroup} object. + */ + public DRIDesignGroup getEvaluationGroup(); + + /** + *

getParameterExpressions.

+ * + * @return a {@link java.util.List} object. + */ + public List getParameterExpressions(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignHyperLinkComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignHyperLinkComponent.java new file mode 100644 index 0000000..20d6e68 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignHyperLinkComponent.java @@ -0,0 +1,51 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.design.definition.DRIDesignHyperLink; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; + +/** + *

DRIDesignHyperLinkComponent interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignHyperLinkComponent extends DRIDesignComponent { + + /** + *

getAnchorNameExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getAnchorNameExpression(); + + /** + *

getBookmarkLevel.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getBookmarkLevel(); + + /** + *

getHyperLink.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignHyperLink} object. + */ + public DRIDesignHyperLink getHyperLink(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignImage.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignImage.java new file mode 100644 index 0000000..f5476d5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignImage.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; + +/** + *

DRIDesignImage interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignImage extends DRIDesignHyperLinkComponent { + + /** + *

getImageExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getImageExpression(); + + /** + *

getImageScale.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ImageScale} object. + */ + public ImageScale getImageScale(); + + /** + *

getUsingCache.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getUsingCache(); + + /** + *

getLazy.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getLazy(); + + /** + *

getHorizontalImageAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public HorizontalImageAlignment getHorizontalImageAlignment(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignLine.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignLine.java new file mode 100644 index 0000000..7e04475 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignLine.java @@ -0,0 +1,45 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignPen; +import software.xdev.dynamicreports.report.constant.LineDirection; + +/** + *

DRIDesignLine interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignLine extends DRIDesignComponent { + + /** + *

getDirection.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.LineDirection} object. + */ + public LineDirection getDirection(); + + /** + *

getPen.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignPen} object. + */ + public DRIDesignPen getPen(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignList.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignList.java new file mode 100644 index 0000000..d55c66c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignList.java @@ -0,0 +1,60 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.design.constant.ComponentGroupType; +import software.xdev.dynamicreports.report.constant.ListType; + +import java.util.List; + +/** + *

DRIDesignList interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignList extends DRIDesignComponent { + + /** + *

getComponents.

+ * + * @return a {@link java.util.List} object. + */ + public List getComponents(); + + /** + *

getType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ListType} object. + */ + public ListType getType(); + + /** + *

getComponentGroupType.

+ * + * @return a {@link software.xdev.dynamicreports.design.constant.ComponentGroupType} object. + */ + public ComponentGroupType getComponentGroupType(); + + /** + *

getBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.component.DRIDesignComponent} object. + */ + public DRIDesignComponent getBackgroundComponent(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignMap.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignMap.java new file mode 100644 index 0000000..e18491a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignMap.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.design.constant.EvaluationTime; +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; + +/** + *

DRIDesignMap interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignMap extends DRIDesignComponent { + + /** + *

getEvaluationTime.

+ * + * @return a {@link software.xdev.dynamicreports.design.constant.EvaluationTime} object. + */ + public EvaluationTime getEvaluationTime(); + + /** + *

getEvaluationGroup.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignGroup} object. + */ + public DRIDesignGroup getEvaluationGroup(); + + /** + *

getLatitudeExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getLatitudeExpression(); + + /** + *

getLongitudeExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getLongitudeExpression(); + + /** + *

getZoomExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getZoomExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignRectangle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignRectangle.java new file mode 100644 index 0000000..311aab2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignRectangle.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignPen; + +/** + *

DRIDesignRectangle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignRectangle extends DRIDesignComponent { + + /** + *

getRadius.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getRadius(); + + /** + *

getPen.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignPen} object. + */ + public DRIDesignPen getPen(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignSubreport.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignSubreport.java new file mode 100644 index 0000000..6ef679f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignSubreport.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; + +/** + *

DRIDesignSubreport interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignSubreport extends DRIDesignComponent { + + /** + *

getReportExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getReportExpression(); + + /** + *

getParametersExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getParametersExpression(); + + /** + *

getConnectionExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getConnectionExpression(); + + /** + *

getDataSourceExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getDataSourceExpression(); + + /** + *

getRunToBottom.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getRunToBottom(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignTextField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignTextField.java new file mode 100644 index 0000000..9137b87 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/component/DRIDesignTextField.java @@ -0,0 +1,104 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.component; + +import software.xdev.dynamicreports.design.constant.EvaluationTime; +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.TextAdjust; + +/** + *

DRIDesignTextField interface.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public interface DRIDesignTextField extends DRIDesignHyperLinkComponent { + + /** + *

getPattern.

+ * + * @return a {@link java.lang.String} object. + */ + String getPattern(); + + /** + *

getPatternExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + DRIDesignExpression getPatternExpression(); + + /** + *

getHorizontalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + HorizontalTextAlignment getHorizontalTextAlignment(); + + /** + *

getValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + DRIDesignExpression getValueExpression(); + + /** + *

isPrintRepeatedValues.

+ * + * @return a boolean. + */ + boolean isPrintRepeatedValues(); + + /** + *

getEvaluationTime.

+ * + * @return a {@link software.xdev.dynamicreports.design.constant.EvaluationTime} object. + */ + EvaluationTime getEvaluationTime(); + + /** + *

getEvaluationGroup.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignGroup} object. + */ + DRIDesignGroup getEvaluationGroup(); + + /** + *

getMarkup.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Markup} object. + */ + Markup getMarkup(); + + /** + *

isStretchWithOverflow.

+ * + * @return a boolean. + * @deprecated Replaced by {@link #getTextAdjust()}. + */ + @Deprecated + boolean isStretchWithOverflow(); + + /** + * @return a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + TextAdjust getTextAdjust(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstab.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstab.java new file mode 100644 index 0000000..a861fa2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstab.java @@ -0,0 +1,116 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.crosstab; + +import software.xdev.dynamicreports.design.definition.component.DRIDesignComponent; +import software.xdev.dynamicreports.report.constant.RunDirection; + +import java.util.List; + +/** + *

DRIDesignCrosstab interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignCrosstab extends DRIDesignComponent { + + /** + *

getDataset.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabDataset} object. + */ + public DRIDesignCrosstabDataset getDataset(); + + /** + *

isRepeatColumnHeaders.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean isRepeatColumnHeaders(); + + /** + *

isRepeatRowHeaders.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean isRepeatRowHeaders(); + + /** + *

getColumnBreakOffset.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getColumnBreakOffset(); + + /** + *

getIgnoreWidth.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreWidth(); + + /** + *

getRunDirection.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public RunDirection getRunDirection(); + + /** + *

getWhenNoDataCell.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabCellContent} object. + */ + public DRIDesignCrosstabCellContent getWhenNoDataCell(); + + /** + *

getHeaderCell.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabCellContent} object. + */ + public DRIDesignCrosstabCellContent getHeaderCell(); + + /** + *

getColumnGroups.

+ * + * @return a {@link java.util.List} object. + */ + public List getColumnGroups(); + + /** + *

getRowGroups.

+ * + * @return a {@link java.util.List} object. + */ + public List getRowGroups(); + + /** + *

getCells.

+ * + * @return a {@link java.util.List} object. + */ + public List getCells(); + + /** + *

getMeasures.

+ * + * @return a {@link java.util.List} object. + */ + public List getMeasures(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabCell.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabCell.java new file mode 100644 index 0000000..0b30565 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabCell.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.crosstab; + +import java.io.Serializable; + +/** + *

DRIDesignCrosstabCell interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignCrosstabCell extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getRowTotalGroup.

+ * + * @return a {@link java.lang.String} object. + */ + public String getRowTotalGroup(); + + /** + *

getColumnTotalGroup.

+ * + * @return a {@link java.lang.String} object. + */ + public String getColumnTotalGroup(); + + /** + *

getContent.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabCellContent} object. + */ + public DRIDesignCrosstabCellContent getContent(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabCellContent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabCellContent.java new file mode 100644 index 0000000..8c0d275 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabCellContent.java @@ -0,0 +1,60 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.crosstab; + +import software.xdev.dynamicreports.design.definition.component.DRIDesignComponent; +import software.xdev.dynamicreports.design.definition.style.DRIDesignStyle; + +import java.io.Serializable; + +/** + *

DRIDesignCrosstabCellContent interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignCrosstabCellContent extends Serializable { + + /** + *

getWidth.

+ * + * @return a int. + */ + public int getWidth(); + + /** + *

getHeight.

+ * + * @return a int. + */ + public int getHeight(); + + /** + *

getComponent.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.component.DRIDesignComponent} object. + */ + public DRIDesignComponent getComponent(); + + /** + *

getStyle.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignStyle} object. + */ + public DRIDesignStyle getStyle(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabColumnGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabColumnGroup.java new file mode 100644 index 0000000..fbc8b1e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabColumnGroup.java @@ -0,0 +1,34 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.crosstab; + +/** + *

DRIDesignCrosstabColumnGroup interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignCrosstabColumnGroup extends DRIDesignCrosstabGroup { + + /** + *

getHeight.

+ * + * @return a int. + */ + public int getHeight(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabDataset.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabDataset.java new file mode 100644 index 0000000..79cc1c4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabDataset.java @@ -0,0 +1,61 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.crosstab; + +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; + +import java.io.Serializable; + +/** + *

DRIDesignCrosstabDataset interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignCrosstabDataset extends Serializable { + + /** + *

getSubDataset.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignDataset} object. + */ + public DRIDesignDataset getSubDataset(); + + /** + *

getDataPreSorted.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getDataPreSorted(); + + /** + *

getResetType.

+ * + * @return a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + */ + public ResetType getResetType(); + + /** + *

getResetGroup.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignGroup} object. + */ + public DRIDesignGroup getResetGroup(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabGroup.java new file mode 100644 index 0000000..d7b3d5a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabGroup.java @@ -0,0 +1,89 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.crosstab; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.CrosstabTotalPosition; +import software.xdev.dynamicreports.report.constant.OrderType; + +import java.io.Serializable; + +/** + *

DRIDesignCrosstabGroup interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignCrosstabGroup extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getTotalPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.CrosstabTotalPosition} object. + */ + public CrosstabTotalPosition getTotalPosition(); + + /** + *

getOrderType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + */ + public OrderType getOrderType(); + + /** + *

getExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getExpression(); + + /** + *

getOrderByExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getOrderByExpression(); + + /** + *

getComparatorExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getComparatorExpression(); + + /** + *

getHeader.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabCellContent} object. + */ + public DRIDesignCrosstabCellContent getHeader(); + + /** + *

getTotalHeader.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabCellContent} object. + */ + public DRIDesignCrosstabCellContent getTotalHeader(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabMeasure.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabMeasure.java new file mode 100644 index 0000000..b07bddc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabMeasure.java @@ -0,0 +1,68 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.crosstab; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; + +import java.io.Serializable; + +/** + *

DRIDesignCrosstabMeasure interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignCrosstabMeasure extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getValueClass.

+ * + * @return a {@link java.lang.Class} object. + */ + public Class getValueClass(); + + /** + *

getValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getValueExpression(); + + /** + *

getCalculation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + public Calculation getCalculation(); + + /** + *

getPercentageType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.CrosstabPercentageType} object. + */ + public CrosstabPercentageType getPercentageType(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabRowGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabRowGroup.java new file mode 100644 index 0000000..cce6190 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/crosstab/DRIDesignCrosstabRowGroup.java @@ -0,0 +1,34 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.crosstab; + +/** + *

DRIDesignCrosstabRowGroup interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignCrosstabRowGroup extends DRIDesignCrosstabGroup { + + /** + *

getWidth.

+ * + * @return a int. + */ + public int getWidth(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignComplexExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignComplexExpression.java new file mode 100644 index 0000000..6ed3d19 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignComplexExpression.java @@ -0,0 +1,54 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.expression; + +import software.xdev.dynamicreports.report.definition.ReportParameters; + +import java.util.List; + +/** + *

DRIDesignComplexExpression interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignComplexExpression extends DRIDesignExpression { + + /** + *

getExpressions.

+ * + * @return a {@link java.util.List} object. + */ + public List getExpressions(); + + /** + *

evaluate.

+ * + * @param values a {@link java.util.List} object. + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + * @return a {@link java.lang.Object} object. + */ + public Object evaluate(List values, ReportParameters reportParameters); + + /** + *

getParameterName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getParameterName(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignExpression.java new file mode 100644 index 0000000..2c9bed7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignExpression.java @@ -0,0 +1,43 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.expression; + +import java.io.Serializable; + +/** + *

DRIDesignExpression interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignExpression extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getValueClass.

+ * + * @return a {@link java.lang.Class} object. + */ + public Class getValueClass(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignJasperExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignJasperExpression.java new file mode 100644 index 0000000..82b5617 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignJasperExpression.java @@ -0,0 +1,34 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.expression; + +/** + *

DRIDesignJasperExpression interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignJasperExpression extends DRIDesignExpression { + + /** + *

getExpression.

+ * + * @return a {@link java.lang.String} object. + */ + public String getExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignParameterExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignParameterExpression.java new file mode 100644 index 0000000..65dd9f6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignParameterExpression.java @@ -0,0 +1,43 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.expression; + +import java.io.Serializable; + +/** + *

DRIDesignParameterExpression interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignParameterExpression extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getValueExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignPropertyExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignPropertyExpression.java new file mode 100644 index 0000000..dd7a962 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignPropertyExpression.java @@ -0,0 +1,43 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.expression; + +import java.io.Serializable; + +/** + *

DRIDesignPropertyExpression interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignPropertyExpression extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getValueExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignSimpleExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignSimpleExpression.java new file mode 100644 index 0000000..9664e67 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignSimpleExpression.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.expression; + +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

DRIDesignSimpleExpression interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignSimpleExpression extends DRIDesignExpression { + + /** + *

evaluate.

+ * + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + * @return a {@link java.lang.Object} object. + */ + public Object evaluate(ReportParameters reportParameters); + + /** + *

getParameterName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getParameterName(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignSystemExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignSystemExpression.java new file mode 100644 index 0000000..39f6ccb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/expression/DRIDesignSystemExpression.java @@ -0,0 +1,27 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.expression; + +/** + *

DRIDesignSystemExpression interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignSystemExpression extends DRIDesignExpression { +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignBaseStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignBaseStyle.java new file mode 100644 index 0000000..26953d3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignBaseStyle.java @@ -0,0 +1,151 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.style; + +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.Rotation; +import software.xdev.dynamicreports.report.constant.VerticalImageAlignment; +import software.xdev.dynamicreports.report.constant.VerticalTextAlignment; + +import java.awt.Color; +import java.io.Serializable; + +/** + *

DRIDesignBaseStyle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignBaseStyle extends Serializable { + + /** + *

getForegroundColor.

+ * + * @return a {@link java.awt.Color} object. + */ + public Color getForegroundColor(); + + /** + *

getBackgroundColor.

+ * + * @return a {@link java.awt.Color} object. + */ + public Color getBackgroundColor(); + + /** + *

getRadius.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getRadius(); + + /** + *

getImageScale.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ImageScale} object. + */ + public ImageScale getImageScale(); + + /** + *

getHorizontalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public HorizontalTextAlignment getHorizontalTextAlignment(); + + /** + *

getVerticalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.VerticalTextAlignment} object. + */ + public VerticalTextAlignment getVerticalTextAlignment(); + + /** + *

getHorizontalImageAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public HorizontalImageAlignment getHorizontalImageAlignment(); + + /** + *

getVerticalImageAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.VerticalImageAlignment} object. + */ + public VerticalImageAlignment getVerticalImageAlignment(); + + /** + *

getBorder.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignBorder} object. + */ + public DRIDesignBorder getBorder(); + + /** + *

getPadding.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignPadding} object. + */ + public DRIDesignPadding getPadding(); + + /** + *

getFont.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignFont} object. + */ + public DRIDesignFont getFont(); + + /** + *

getRotation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Rotation} object. + */ + public Rotation getRotation(); + + /** + *

getPattern.

+ * + * @return a {@link java.lang.String} object. + */ + public String getPattern(); + + /** + *

getMarkup.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Markup} object. + */ + public Markup getMarkup(); + + /** + *

getParagraph.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignParagraph} object. + */ + public DRIDesignParagraph getParagraph(); + + /** + *

getLinePen.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignPen} object. + */ + public DRIDesignPen getLinePen(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignBorder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignBorder.java new file mode 100644 index 0000000..e5945a1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignBorder.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.style; + +import java.io.Serializable; + +/** + *

DRIDesignBorder interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignBorder extends Serializable { + + /** + *

getTopPen.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignPen} object. + */ + public DRIDesignPen getTopPen(); + + /** + *

getLeftPen.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignPen} object. + */ + public DRIDesignPen getLeftPen(); + + /** + *

getBottomPen.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignPen} object. + */ + public DRIDesignPen getBottomPen(); + + /** + *

getRightPen.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignPen} object. + */ + public DRIDesignPen getRightPen(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignConditionalStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignConditionalStyle.java new file mode 100644 index 0000000..9b880f6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignConditionalStyle.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.style; + +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; + +/** + *

DRIDesignConditionalStyle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignConditionalStyle extends DRIDesignBaseStyle { + + /** + *

getConditionExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getConditionExpression(); + + /** + *

getDataset.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignDataset} object. + */ + public DRIDesignDataset getDataset(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignFont.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignFont.java new file mode 100644 index 0000000..35789c3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignFont.java @@ -0,0 +1,92 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.style; + +import java.io.Serializable; + +/** + *

DRIDesignFont interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignFont extends Serializable { + + /** + *

getFontName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getFontName(); + + /** + *

getBold.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getBold(); + + /** + *

getItalic.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getItalic(); + + /** + *

getUnderline.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getUnderline(); + + /** + *

getStrikeThrough.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getStrikeThrough(); + + /** + *

getFontSize.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getFontSize(); + + /** + *

getPdfFontName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getPdfFontName(); + + /** + *

getPdfEncoding.

+ * + * @return a {@link java.lang.String} object. + */ + public String getPdfEncoding(); + + /** + *

getPdfEmbedded.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getPdfEmbedded(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignPadding.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignPadding.java new file mode 100644 index 0000000..3d64ced --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignPadding.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.style; + +import java.io.Serializable; + +/** + *

DRIDesignPadding interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignPadding extends Serializable { + + /** + *

getTop.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getTop(); + + /** + *

getLeft.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getLeft(); + + /** + *

getBottom.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getBottom(); + + /** + *

getRight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getRight(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignParagraph.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignParagraph.java new file mode 100644 index 0000000..764f5bb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignParagraph.java @@ -0,0 +1,95 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.style; + +import software.xdev.dynamicreports.report.constant.LineSpacing; + +import java.io.Serializable; +import java.util.List; + +/** + *

DRIDesignParagraph interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignParagraph extends Serializable { + + /** + *

getLineSpacing.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.LineSpacing} object. + */ + public LineSpacing getLineSpacing(); + + /** + *

getLineSpacingSize.

+ * + * @return a {@link java.lang.Float} object. + */ + public Float getLineSpacingSize(); + + /** + *

getFirstLineIndent.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getFirstLineIndent(); + + /** + *

getLeftIndent.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getLeftIndent(); + + /** + *

getRightIndent.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getRightIndent(); + + /** + *

getSpacingBefore.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getSpacingBefore(); + + /** + *

getSpacingAfter.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getSpacingAfter(); + + /** + *

getTabStopWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getTabStopWidth(); + + /** + *

getTabStops.

+ * + * @return a {@link java.util.List} object. + */ + public List getTabStops(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignPen.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignPen.java new file mode 100644 index 0000000..055ad43 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignPen.java @@ -0,0 +1,53 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.style; + +import software.xdev.dynamicreports.report.constant.LineStyle; + +import java.awt.Color; +import java.io.Serializable; + +/** + *

DRIDesignPen interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignPen extends Serializable { + + /** + *

getLineWidth.

+ * + * @return a {@link java.lang.Float} object. + */ + public Float getLineWidth(); + + /** + *

getLineStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.LineStyle} object. + */ + public LineStyle getLineStyle(); + + /** + *

getLineColor.

+ * + * @return a {@link java.awt.Color} object. + */ + public Color getLineColor(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignStyle.java new file mode 100644 index 0000000..ce5531b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignStyle.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.style; + +import java.util.List; + +/** + *

DRIDesignStyle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignStyle extends DRIDesignBaseStyle { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getParentStyle.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignStyle} object. + */ + public DRIDesignStyle getParentStyle(); + + /** + *

getConditionalStyles.

+ * + * @return a {@link java.util.List} object. + */ + public List getConditionalStyles(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignTabStop.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignTabStop.java new file mode 100644 index 0000000..29b78c1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/definition/style/DRIDesignTabStop.java @@ -0,0 +1,45 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.definition.style; + +import software.xdev.dynamicreports.report.constant.TabStopAlignment; + +import java.io.Serializable; + +/** + *

DRIDesignTabStop interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignTabStop extends Serializable { + + /** + *

getPosition.

+ * + * @return a int. + */ + public int getPosition(); + + /** + *

getAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.TabStopAlignment} object. + */ + public TabStopAlignment getAlignment(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/exception/DRDesignReportException.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/exception/DRDesignReportException.java new file mode 100644 index 0000000..131455c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/exception/DRDesignReportException.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.exception; + +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRDesignReportException class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDesignReportException extends RuntimeException { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for DRDesignReportException.

+ * + * @param message a {@link java.lang.String} object. + */ + public DRDesignReportException(String message) { + super(message); + } + + /** + *

Constructor for DRDesignReportException.

+ * + * @param message a {@link java.lang.String} object. + * @param cause a {@link java.lang.Throwable} object. + */ + public DRDesignReportException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/AbstractExpressionTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/AbstractExpressionTransform.java new file mode 100644 index 0000000..94bfb02 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/AbstractExpressionTransform.java @@ -0,0 +1,459 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.DRDesignField; +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.base.DRDesignSort; +import software.xdev.dynamicreports.design.base.DRDesignVariable; +import software.xdev.dynamicreports.design.base.expression.DRDesignComplexExpression; +import software.xdev.dynamicreports.design.base.expression.DRDesignJasperExpression; +import software.xdev.dynamicreports.design.base.expression.DRDesignParameterExpression; +import software.xdev.dynamicreports.design.base.expression.DRDesignPropertyExpression; +import software.xdev.dynamicreports.design.base.expression.DRDesignSimpleExpression; +import software.xdev.dynamicreports.design.base.expression.DRDesignSystemExpression; +import software.xdev.dynamicreports.design.base.expression.DRDesignValueFormatter; +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.design.definition.DRIDesignField; +import software.xdev.dynamicreports.design.definition.DRIDesignSort; +import software.xdev.dynamicreports.design.definition.DRIDesignVariable; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignJasperExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignParameterExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignPropertyExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSystemExpression; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.report.base.DRVariable; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.DRISort; +import software.xdev.dynamicreports.report.definition.DRISubtotal; +import software.xdev.dynamicreports.report.definition.DRIVariable; +import software.xdev.dynamicreports.report.definition.column.DRIBooleanColumn; +import software.xdev.dynamicreports.report.definition.column.DRIValueColumn; +import software.xdev.dynamicreports.report.definition.expression.DRIComplexExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIJasperExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIParameterExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.expression.DRISimpleExpression; +import software.xdev.dynamicreports.report.definition.expression.DRISystemExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + *

Abstract AbstractExpressionTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractExpressionTransform { + protected DesignTransformAccessor accessor; + private Map fields; + private Map variables; + private Map systemExpressions; + private Map jasperExpressions; + private Map simpleExpressions; + private Map complexExpressions; + private Map, DRIDesignExpression> expressions; + private List sorts; + + /** + *

Constructor for AbstractExpressionTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public AbstractExpressionTransform(DesignTransformAccessor accessor) { + this.accessor = accessor; + init(); + } + + private void init() { + fields = new LinkedHashMap(); + variables = new LinkedHashMap(); + systemExpressions = new HashMap(); + jasperExpressions = new HashMap(); + simpleExpressions = new HashMap(); + complexExpressions = new HashMap(); + expressions = new HashMap, DRIDesignExpression>(); + sorts = new ArrayList(); + } + + /** + *

transform.

+ * + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public void transform() throws DRException { + for (DRIField field : transformFields()) { + transformExpression(field); + } + for (DRIVariable variable : transformVariables()) { + transformExpression(variable); + } + for (DRISort sort : transformSorts()) { + transformSort(sort); + } + } + + /** + *

transformExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public DRIDesignExpression transformExpression(DRIExpression expression) throws DRException { + return transformExpression(expression, null, null); + } + + /** + *

transformExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param parameterName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRIDesignExpression transformExpression(DRIExpression expression, String parameterName) throws DRException { + return transformExpression(expression, null, parameterName); + } + + /** + *

transformExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param valueFormatter a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + * @param parameterName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRIDesignExpression transformExpression(DRIExpression expression, DRIValueFormatter valueFormatter, String parameterName) throws DRException { + if (expression == null) { + return null; + } + + if (valueFormatter != null) { + return addExpression(new DRDesignValueFormatter(valueFormatter, transformExpression(expression))); + } + if (expressions.containsKey(expression)) { + return expressions.get(expression); + } + + DRIDesignExpression express; + if (expression instanceof DRISystemExpression) { + express = new DRDesignSystemExpression((DRISystemExpression) expression); + } else if (expression instanceof DRIJasperExpression) { + express = new DRDesignJasperExpression((DRIJasperExpression) expression); + } else if (expression instanceof DRISimpleExpression) { + express = new DRDesignSimpleExpression((DRISimpleExpression) expression, parameterName); + } else if (expression instanceof DRIComplexExpression) { + express = transformComplexExpression((DRIComplexExpression) expression, parameterName); + } else if (expression instanceof DRIField) { + express = transformField((DRIField) expression); + } else if (expression instanceof DRIVariable) { + express = transformVariable((DRIVariable) expression); + } else if (expression instanceof DRIValueColumn) { + express = transformExpression(((DRIValueColumn) expression).getComponent().getValueExpression()); + } else if (expression instanceof DRIBooleanColumn) { + express = transformExpression(((DRIBooleanColumn) expression).getComponent().getValueExpression()); + } else if (expression instanceof DRISubtotal) { + express = transformExpression(((DRISubtotal) expression).getValueField().getValueExpression()); + } else { + throw new DRDesignReportException("Expression " + expression.getClass().getName() + " not supported"); + } + express = addExpression(express); + if (valueFormatter == null) { + expressions.put(expression, express); + } + return express; + } + + private DRDesignField transformField(DRIField field) { + DRDesignField designField = new DRDesignField(); + designField.setName(field.getName()); + designField.setValueClass(field.getValueClass()); + designField.setDescription(accessor.getTemplateTransform().getFieldDescription(field)); + return designField; + } + + private DRIDesignExpression transformComplexExpression(DRIComplexExpression complexExpression, String parameterName) throws DRException { + DRDesignComplexExpression designComplexExpression = new DRDesignComplexExpression(complexExpression, parameterName); + for (DRIExpression expression : complexExpression.getExpressions()) { + designComplexExpression.addExpression(transformExpression(expression)); + } + return designComplexExpression; + } + + private DRIDesignExpression transformVariable(DRIVariable variable) throws DRException { + DRDesignVariable designVariable = new DRDesignVariable(variable.getName()); + designVariable.setValueExpression(transformExpression(variable.getValueExpression())); + designVariable.setInitialValueExpression(transformExpression(variable.getInitialValueExpression())); + designVariable.setCalculation(variable.getCalculation()); + designVariable.setResetType(getVariableResetType(variable)); + designVariable.setResetGroup(getVariableResetGroup(variable)); + return designVariable; + } + + /** + *

getVariableResetType.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.definition.DRIVariable} object. + * @return a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + */ + protected ResetType getVariableResetType(DRIVariable variable) { + return null; + } + + /** + *

getVariableResetGroup.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.definition.DRIVariable} object. + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignGroup getVariableResetGroup(DRIVariable variable) throws DRException { + return null; + } + + private void transformSort(DRISort sort) throws DRException { + DRIDesignExpression expression = transformExpression(sort.getExpression()); + DRIDesignExpression sortExpression; + if (expression instanceof DRIDesignField || expression instanceof DRIDesignVariable) { + sortExpression = expression; + } else { + @SuppressWarnings( {"rawtypes", "unchecked"}) DRVariable variable = new DRVariable(sort.getExpression(), Calculation.NOTHING); + variable.setResetType(Evaluation.NONE); + sortExpression = transformExpression(variable); + } + + DRDesignSort designSort = new DRDesignSort(); + designSort.setExpression(sortExpression); + designSort.setOrderType(sort.getOrderType()); + + sorts.add(designSort); + } + + /** + *

transformPropertyExpression.

+ * + * @param propertyExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression} object. + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignPropertyExpression} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRIDesignPropertyExpression transformPropertyExpression(DRIPropertyExpression propertyExpression) throws DRException { + DRDesignPropertyExpression designPropertyExpression = new DRDesignPropertyExpression(); + designPropertyExpression.setName(propertyExpression.getName()); + designPropertyExpression.setValueExpression(transformExpression(propertyExpression.getValueExpression())); + return designPropertyExpression; + } + + /** + *

transformParameterExpression.

+ * + * @param parameterExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIParameterExpression} object. + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignParameterExpression} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRIDesignParameterExpression transformParameterExpression(DRIParameterExpression parameterExpression) throws DRException { + DRDesignParameterExpression designParameterExpression = new DRDesignParameterExpression(); + designParameterExpression.setName(parameterExpression.getName()); + designParameterExpression.setValueExpression(transformExpression(parameterExpression.getValueExpression())); + return designParameterExpression; + } + + private DRIDesignExpression addExpression(DRIDesignExpression expression) { + if (expression == null) { + return null; + } + if (expression instanceof DRIDesignField) { + return addField((DRIDesignField) expression); + } else if (expression instanceof DRIDesignVariable) { + addVariable((DRDesignVariable) expression); + } else if (expression instanceof DRIDesignSystemExpression) { + addSystemExpression((DRIDesignSystemExpression) expression); + } else if (expression instanceof DRIDesignJasperExpression) { + addJasperExpression((DRIDesignJasperExpression) expression); + } else if (expression instanceof DRIDesignSimpleExpression) { + addSimpleExpression((DRIDesignSimpleExpression) expression); + } else if (expression instanceof DRIDesignComplexExpression) { + addComplexExpression((DRIDesignComplexExpression) expression); + } else { + throw new DRDesignReportException("Expression " + expression.getClass().getName() + " not supported"); + } + return expression; + } + + private void addVariable(DRDesignVariable variable) { + if (variables.containsKey(variable.getName())) { + if (!variables.get(variable.getName()).equals(variable)) { + throw new DRDesignReportException("Duplicate declaration of variable \"" + variable.getName() + "\""); + } + return; + } + variables.put(variable.getName(), variable); + } + + private DRIDesignField addField(DRIDesignField field) { + if (fields.containsKey(field.getName())) { + DRIDesignField fld = fields.get(field.getName()); + if (!fld.getValueClass().equals(field.getValueClass())) { + throw new DRDesignReportException("Duplicate declaration of field \"" + field.getName() + "\""); + } + return fld; + } + fields.put(field.getName(), field); + return field; + } + + private void addSystemExpression(DRIDesignSystemExpression systemExpression) { + if (systemExpressions.containsKey(systemExpression.getName())) { + return; + } + systemExpressions.put(systemExpression.getName(), systemExpression); + } + + private void addJasperExpression(DRIDesignJasperExpression jasperExpression) { + if (jasperExpressions.containsKey(jasperExpression.getName())) { + return; + } + jasperExpressions.put(jasperExpression.getName(), jasperExpression); + } + + private void addSimpleExpression(DRIDesignSimpleExpression simpleExpression) { + if (simpleExpressions.containsKey(simpleExpression.getName())) { + if (!simpleExpressions.get(simpleExpression.getName()).equals(simpleExpression)) { + throw new DRDesignReportException("Duplicate declaration of simple expression \"" + simpleExpression.getName() + "\""); + } + return; + } + simpleExpressions.put(simpleExpression.getName(), simpleExpression); + } + + private void addComplexExpression(DRIDesignComplexExpression complexExpression) { + if (complexExpressions.containsKey(complexExpression.getName())) { + if (!complexExpressions.get(complexExpression.getName()).equals(complexExpression)) { + throw new DRDesignReportException("Duplicate declaration of complex expression \"" + complexExpression.getName() + "\""); + } + return; + } + complexExpressions.put(complexExpression.getName(), complexExpression); + } + + /** + *

Getter for the field fields.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getFields() { + return fields.values(); + } + + /** + *

Getter for the field variables.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getVariables() { + return variables.values(); + } + + /** + *

Getter for the field systemExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getSystemExpressions() { + return systemExpressions.values(); + } + + /** + *

Getter for the field jasperExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getJasperExpressions() { + return jasperExpressions.values(); + } + + /** + *

Getter for the field simpleExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getSimpleExpressions() { + return simpleExpressions.values(); + } + + /** + *

Getter for the field complexExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getComplexExpressions() { + return complexExpressions.values(); + } + + /** + *

Getter for the field sorts.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getSorts() { + return sorts; + } + + /** + *

transformFields.

+ * + * @return a {@link java.util.List} object. + */ + protected abstract List> transformFields(); + + /** + *

transformVariables.

+ * + * @return a {@link java.util.List} object. + */ + protected abstract List> transformVariables(); + + /** + *

transformSorts.

+ * + * @return a {@link java.util.List} object. + */ + protected abstract List transformSorts(); + + /** + *

getDataset.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignDataset} object. + */ + protected abstract DRIDesignDataset getDataset(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/BandComponentsTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/BandComponentsTransform.java new file mode 100644 index 0000000..e0076f1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/BandComponentsTransform.java @@ -0,0 +1,454 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.DRDesignBand; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignFiller; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCell; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCellContent; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabColumnGroup; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabRowGroup; +import software.xdev.dynamicreports.design.constant.ComponentGroupType; +import software.xdev.dynamicreports.report.constant.StretchType; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Ricardo Mariaca + */ +class BandComponentsTransform { + private DesignTransformAccessor accessor; + private Map componentNames; + + /** + *

Constructor for BandComponentsTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public BandComponentsTransform(DesignTransformAccessor accessor) { + this.accessor = accessor; + componentNames = new HashMap(); + } + + /** + *

prepareBand.

+ * + * @param band a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + * @param maxWidth a int. + * @param templateDesignComponents a int. + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public DRDesignBand prepareBand(DRDesignBand band, int maxWidth, int templateDesignComponents) throws DRException { + if (band == null) { + return null; + } + if (band.getBandComponent() != null) { + return band; + } + + DRDesignComponent component = prepareList(band.getName(), band.getList(), maxWidth); + if (component == null) { + if (band.getList() == null || band.getList().getHeight() == null || band.getList().getHeight() == 0) { + return null; + } + } + band.setHeight(band.getList().getHeight()); + band.setBandComponent(component); + + if (band.getBandComponent() != null && templateDesignComponents > 0) { + throw new DRException("Band " + band.getName() + " must not be defined at once in jrxml template design and in dynamic design"); + } + + prepareListBackgroundComponents(component); + prepareCrosstabs(component); + + return band; + } + + private DRDesignComponent prepareList(String name, DRDesignList list, int maxWidth) throws DRException { + return prepareList(name, list, maxWidth, -1); + } + + private DRDesignComponent prepareList(String name, DRDesignList list, int maxWidth, int maxHeight) throws DRException { + if (list == null) { + return null; + } + if (list.isEmpty()) { + return null; + } + + ComponentPosition.component(name, list, maxWidth, maxHeight); + + DRDesignComponent component = removeEmptyComponents(list); + if (component == null) { + return null; + } + componentGroupType(component); + + generateComponentNames(component, name); + + return component; + } + + private void generateComponentNames(DRDesignComponent component, String bandName) { + String componentName = bandName + "." + component.getUniqueName(); + if (!componentNames.containsKey(componentName)) { + componentNames.put(componentName, 1); + } else { + componentNames.put(componentName, componentNames.get(componentName) + 1); + } + component.setUniqueName(componentName + componentNames.get(componentName)); + if (component instanceof DRDesignList) { + DRDesignList list = (DRDesignList) component; + for (DRDesignComponent lComponent : list.getComponents()) { + generateComponentNames(lComponent, bandName); + } + if (list.getBackgroundComponent() != null) { + list.getBackgroundComponent().setUniqueName(component.getUniqueName() + ".background"); + } + } + } + + private DRDesignComponent removeEmptyComponents(DRDesignComponent component) { + if (component instanceof DRDesignList) { + DRDesignList list = (DRDesignList) component; + if (list.getComponents().isEmpty()) { + return null; + } else if (list.getComponents().size() == 1) { + DRDesignComponent lComponent = list.getComponents().get(0); + DRDesignComponent elm = removeEmptyComponents(lComponent); + if (elm == null) { + if (list.getWidth() > 0 && list.getHeight() > 0 && (list.getStyle() != null || list.getBackgroundComponent() != null)) { + list.getComponents().clear(); + return list; + } + return null; + } + if (lComponent != elm && (!(lComponent instanceof DRDesignList) || lComponent instanceof DRDesignList && + !(lComponent.getStyle() == null && lComponent.getPrintWhenExpression() == null && ((DRDesignList) lComponent).getBackgroundComponent() == null))) { + elm.setX(lComponent.getX() + elm.getX()); + elm.setY(lComponent.getY() + elm.getY()); + } + + if (list.getStyle() == null && list.getPrintWhenExpression() == null && list.getBackgroundComponent() == null) { + elm.setX(list.getX() + elm.getX()); + elm.setY(list.getY() + elm.getY()); + return elm; + } else { + list.getComponents().clear(); + list.getComponents().add(elm); + return list; + } + } else { + List components = new ArrayList(); + for (DRDesignComponent listComponent : list.getComponents()) { + DRDesignComponent comp = removeEmptyComponents(listComponent); + if (comp != null) { + components.add(comp); + } + } + if (components.isEmpty()) { + if (list.getWidth() > 0 && list.getHeight() > 0 && (list.getStyle() != null || list.getBackgroundComponent() != null)) { + list.getComponents().clear(); + return list; + } + return null; + } + list.getComponents().clear(); + list.getComponents().addAll(components); + return list; + } + } else if (component instanceof DRDesignFiller && component.getStyle() == null && component.getPrintWhenExpression() == null) { + return null; + } + return component; + } + + private void componentGroupType(DRDesignComponent component) { + if (component instanceof DRDesignList) { + DRDesignList list = (DRDesignList) component; + if (list.isRemovable() && list.getStyle() == null && list.getPrintWhenExpression() == null && list.getBackgroundComponent() == null) { + list.setComponentGroupType(ComponentGroupType.NONE); + for (DRDesignComponent listComponent : list.getComponents()) { + listComponent.setX(list.getX() + listComponent.getX()); + listComponent.setY(list.getY() + listComponent.getY()); + } + } else { + list.setComponentGroupType(ComponentGroupType.FRAME); + } + + for (DRDesignComponent listComponent : list.getComponents()) { + componentGroupType(listComponent); + } + } + } + + private void prepareListBackgroundComponents(DRDesignComponent component) throws DRException { + if (component instanceof DRDesignList) { + DRDesignList list = (DRDesignList) component; + if (list.getBackgroundComponent() != null) { + DRDesignComponent backgroundComponent = list.getBackgroundComponent(); + backgroundComponent.setX(0); + backgroundComponent.setY(0); + backgroundComponent.setWidth(list.getWidth() - StyleResolver.getHorizontalPadding(list.getStyle())); + backgroundComponent.setHeight(list.getHeight() - StyleResolver.getVerticalPadding(list.getStyle())); + backgroundComponent.setStretchType(StretchType.ELEMENT_GROUP_HEIGHT); + list.setBackgroundComponent(backgroundComponent); + } + for (DRDesignComponent listComponent : list.getComponents()) { + prepareListBackgroundComponents(listComponent); + } + } + } + + private void prepareCrosstabs(DRDesignComponent component) throws DRException { + if (component instanceof DRDesignList) { + DRDesignList list = (DRDesignList) component; + for (DRDesignComponent listComponent : list.getComponents()) { + prepareCrosstabs(listComponent); + } + } else if (component instanceof DRDesignCrosstab) { + prepareCrosstab((DRDesignCrosstab) component); + } + } + + private void prepareCrosstab(DRDesignCrosstab crosstab) throws DRException { + calculateCellDimensions(crosstab); + + DRDesignCrosstabCellContent whenNoDataCell = crosstab.getWhenNoDataCell(); + + for (DRDesignCrosstabColumnGroup columnGroup : crosstab.getColumnGroups()) { + DRDesignCrosstabCellContent header = columnGroup.getHeader(); + if (header != null) { + header.setComponent(prepareCrosstabCell(crosstab.getUniqueName(), header)); + } + DRDesignCrosstabCellContent totalHeader = columnGroup.getTotalHeader(); + if (totalHeader != null) { + totalHeader.setComponent(prepareCrosstabCell(crosstab.getUniqueName(), totalHeader)); + } + } + + for (DRDesignCrosstabRowGroup rowGroup : crosstab.getRowGroups()) { + DRDesignCrosstabCellContent header = rowGroup.getHeader(); + if (header != null) { + header.setComponent(prepareCrosstabCell(crosstab.getUniqueName(), header)); + } + DRDesignCrosstabCellContent totalHeader = rowGroup.getTotalHeader(); + if (totalHeader != null) { + totalHeader.setComponent(prepareCrosstabCell(crosstab.getUniqueName(), totalHeader)); + } + } + + if (whenNoDataCell != null) { + whenNoDataCell.setComponent(prepareCrosstabCell(crosstab.getUniqueName() + ".whennodatacell", whenNoDataCell)); + } + + DRDesignCrosstabCellContent headerCell = crosstab.getHeaderCell(); + if (headerCell != null) { + crosstab.getHeaderCell().setComponent(prepareCrosstabCell(crosstab.getUniqueName() + ".headercell", headerCell)); + } + + for (DRDesignCrosstabCell cell : crosstab.getCells()) { + DRDesignCrosstabCellContent content = cell.getContent(); + if (content != null) { + content.setComponent(prepareCrosstabCell(crosstab.getUniqueName(), content)); + } + } + } + + private DRDesignComponent prepareCrosstabCell(String name, DRDesignCrosstabCellContent cell) throws DRException { + return prepareList(name, cell.getList(), cell.getWidth(), cell.getHeight()); + } + + private void calculateCellDimensions(DRDesignCrosstab designCrosstab) { + DRICrosstab crosstab = accessor.getCrosstabTransform().getCrosstab(designCrosstab); + int cellWidth = accessor.getTemplateTransform().getCrosstabCellWidth(crosstab, designCrosstab); + int cellHeight = accessor.getTemplateTransform().getCrosstabCellHeight(crosstab, designCrosstab); + Map columnGroups = new HashMap(); + Map rowGroups = new HashMap(); + int groupWidth = 0; + int groupHeight = 0; + + GroupCellDimension previousCellDimension = null; + for ( + int i = crosstab.getColumnGroups().size() - 1; i >= 0; i--) { + DRICrosstabColumnGroup columnGroup = crosstab.getColumnGroups().get(i); + int headerWidth = 0; + int headerHeight = 0; + int totalHeaderWidth = 0; + int totalHeaderHeight = 0; + + if (previousCellDimension == null) { + headerWidth = cellWidth; + } else { + headerWidth = previousCellDimension.getHeaderWidth() + previousCellDimension.getTotalHeaderWidth(); + } + headerHeight = accessor.getTemplateTransform().getCrosstabColumnGroupHeaderHeight(columnGroup, designCrosstab, groupHeight); + + if (accessor.getTemplateTransform().isCrosstabColumnGroupShowTotal(columnGroup)) { + totalHeaderWidth = accessor.getTemplateTransform().getCrosstabColumnGroupTotalHeaderWidth(columnGroup, crosstab.getCellWidth(), designCrosstab); + } + totalHeaderHeight = headerHeight; + if (previousCellDimension != null) { + totalHeaderHeight += previousCellDimension.getTotalHeaderHeight(); + } + + GroupCellDimension groupCellDimension = new GroupCellDimension(); + groupCellDimension.setHeaderWidth(headerWidth); + groupCellDimension.setHeaderHeight(headerHeight); + groupCellDimension.setTotalHeaderWidth(totalHeaderWidth); + groupCellDimension.setTotalHeaderHeight(totalHeaderHeight); + columnGroups.put(columnGroup.getName(), groupCellDimension); + previousCellDimension = groupCellDimension; + + groupHeight += groupCellDimension.getHeaderHeight(); + } + + previousCellDimension = null; + for ( + int i = crosstab.getRowGroups().size() - 1; i >= 0; i--) { + DRICrosstabRowGroup rowGroup = crosstab.getRowGroups().get(i); + int headerWidth = 0; + int headerHeight = 0; + int totalHeaderWidth = 0; + int totalHeaderHeight = 0; + + headerWidth = accessor.getTemplateTransform().getCrosstabRowGroupHeaderWidth(rowGroup, designCrosstab); + if (previousCellDimension == null) { + headerHeight = cellHeight; + } else { + headerHeight = previousCellDimension.getHeaderHeight() + previousCellDimension.getTotalHeaderHeight(); + } + + totalHeaderWidth = headerWidth; + if (previousCellDimension != null) { + totalHeaderWidth += previousCellDimension.getTotalHeaderWidth(); + } + if (accessor.getTemplateTransform().isCrosstabRowGroupShowTotal(rowGroup)) { + totalHeaderHeight = accessor.getTemplateTransform().getCrosstabRowGroupTotalHeaderHeight(rowGroup, crosstab.getCellHeight(), designCrosstab); + } + + GroupCellDimension groupCellDimension = new GroupCellDimension(); + groupCellDimension.setHeaderWidth(headerWidth); + groupCellDimension.setHeaderHeight(headerHeight); + groupCellDimension.setTotalHeaderWidth(totalHeaderWidth); + groupCellDimension.setTotalHeaderHeight(totalHeaderHeight); + rowGroups.put(rowGroup.getName(), groupCellDimension); + previousCellDimension = groupCellDimension; + + groupWidth += groupCellDimension.getHeaderWidth(); + } + + designCrosstab.getWhenNoDataCell().setWidth(designCrosstab.getWidth()); + designCrosstab.getWhenNoDataCell().setHeight(designCrosstab.getHeight()); + designCrosstab.getHeaderCell().setWidth(groupWidth); + designCrosstab.getHeaderCell().setHeight(groupHeight); + + for (DRDesignCrosstabColumnGroup designColumnGroup : designCrosstab.getColumnGroups()) { + GroupCellDimension groupCellDimension = columnGroups.get(designColumnGroup.getName()); + designColumnGroup.setHeight(groupCellDimension.getHeaderHeight()); + designColumnGroup.getHeader().setWidth(groupCellDimension.getHeaderWidth()); + designColumnGroup.getHeader().setHeight(groupCellDimension.getHeaderHeight()); + if (designColumnGroup.getTotalHeader() != null) { + designColumnGroup.getTotalHeader().setWidth(groupCellDimension.getTotalHeaderWidth()); + designColumnGroup.getTotalHeader().setHeight(groupCellDimension.getTotalHeaderHeight()); + } + } + + for (DRDesignCrosstabRowGroup designRowGroup : designCrosstab.getRowGroups()) { + GroupCellDimension groupCellDimension = rowGroups.get(designRowGroup.getName()); + designRowGroup.setWidth(groupCellDimension.getHeaderWidth()); + designRowGroup.getHeader().setWidth(groupCellDimension.getHeaderWidth()); + designRowGroup.getHeader().setHeight(groupCellDimension.getHeaderHeight()); + if (designRowGroup.getTotalHeader() != null) { + designRowGroup.getTotalHeader().setWidth(groupCellDimension.getTotalHeaderWidth()); + designRowGroup.getTotalHeader().setHeight(groupCellDimension.getTotalHeaderHeight()); + } + } + + for (DRDesignCrosstabCell designCell : designCrosstab.getCells()) { + if (designCell.getColumnTotalGroup() == null && designCell.getRowTotalGroup() == null) { + designCell.getContent().setWidth(cellWidth); + designCell.getContent().setHeight(cellHeight); + } else if (designCell.getColumnTotalGroup() != null && designCell.getRowTotalGroup() == null) { + GroupCellDimension groupCellDimension = columnGroups.get(designCell.getColumnTotalGroup()); + designCell.getContent().setWidth(groupCellDimension.getTotalHeaderWidth()); + designCell.getContent().setHeight(cellHeight); + } else if (designCell.getColumnTotalGroup() == null && designCell.getRowTotalGroup() != null) { + GroupCellDimension groupCellDimension = rowGroups.get(designCell.getRowTotalGroup()); + designCell.getContent().setWidth(cellWidth); + designCell.getContent().setHeight(groupCellDimension.getTotalHeaderHeight()); + } else { + GroupCellDimension groupCellDimension = columnGroups.get(designCell.getColumnTotalGroup()); + designCell.getContent().setWidth(groupCellDimension.getTotalHeaderWidth()); + groupCellDimension = rowGroups.get(designCell.getRowTotalGroup()); + designCell.getContent().setHeight(groupCellDimension.getTotalHeaderHeight()); + } + } + } + + private class GroupCellDimension { + private int headerWidth; + private int headerHeight; + private int totalHeaderWidth; + private int totalHeaderHeight; + + public int getHeaderWidth() { + return headerWidth; + } + + public void setHeaderWidth(int headerWidth) { + this.headerWidth = headerWidth; + } + + public int getHeaderHeight() { + return headerHeight; + } + + public void setHeaderHeight(int headerHeight) { + this.headerHeight = headerHeight; + } + + public int getTotalHeaderWidth() { + return totalHeaderWidth; + } + + public void setTotalHeaderWidth(int totalHeaderWidth) { + this.totalHeaderWidth = totalHeaderWidth; + } + + public int getTotalHeaderHeight() { + return totalHeaderHeight; + } + + public void setTotalHeaderHeight(int totalHeaderHeight) { + this.totalHeaderHeight = totalHeaderHeight; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/BandTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/BandTransform.java new file mode 100644 index 0000000..8649974 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/BandTransform.java @@ -0,0 +1,381 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.DRDesignBand; +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.base.component.DRDesignFiller; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.constant.DefaultStyleType; +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.DRIDesignPage; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.definition.DRIBand; +import software.xdev.dynamicreports.report.definition.DRIGroup; +import software.xdev.dynamicreports.report.definition.DRIReport; +import software.xdev.dynamicreports.report.definition.DRITemplateDesign; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.ArrayList; +import java.util.List; + +/** + *

BandTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class BandTransform { + private DesignTransformAccessor accessor; + + private DRDesignBand titleBand; + private DRDesignBand pageHeaderBand; + private DRDesignBand pageFooterBand; + private DRDesignBand columnHeaderBand; + private DRDesignBand columnHeaderForGroupBand; + private DRDesignBand columnFooterBand; + private List detailBands; + private DRDesignBand detailBand; + private DRDesignBand lastPageFooterBand; + private DRDesignBand summaryBand; + private DRDesignBand noDataBand; + private DRDesignBand backgroundBand; + + /** + *

Constructor for BandTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public BandTransform(DesignTransformAccessor accessor) { + this.accessor = accessor; + this.detailBands = new ArrayList(); + } + + /** + *

transform.

+ * + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public void transform() throws DRException { + TemplateTransform templateTransform = accessor.getTemplateTransform(); + + DRIReport report = accessor.getReport(); + + DRIBand band = report.getTitleBand(); + titleBand = band("title", band, templateTransform.getTitleSplitType(band), templateTransform.getTitleStyle(band), templateTransform.getTitleBackgroundComponent(band), ResetType.REPORT, null); + + band = report.getPageHeaderBand(); + pageHeaderBand = band("pageHeader", band, templateTransform.getPageHeaderSplitType(band), templateTransform.getPageHeaderStyle(band), templateTransform.getPageHeaderBackgroundComponent(band), + ResetType.PAGE, null); + + band = report.getPageFooterBand(); + pageFooterBand = band("pageFooter", band, templateTransform.getPageFooterSplitType(band), templateTransform.getPageFooterStyle(band), templateTransform.getPageFooterBackgroundComponent(band), + ResetType.PAGE, null); + + band = report.getColumnHeaderBand(); + columnHeaderBand = + band("columnHeader", band, templateTransform.getColumnHeaderSplitType(band), templateTransform.getColumnHeaderStyle(band), templateTransform.getColumnHeaderBackgroundComponent(band), + ResetType.COLUMN, null); + + for (DRIGroup group : report.getGroups()) { + if (templateTransform.isGroupShowColumnHeaderAndFooter(group)) { + band = report.getColumnHeaderBand(); + columnHeaderForGroupBand = band("columnHeaderForGroup", band, templateTransform.getColumnHeaderSplitType(band), templateTransform.getColumnHeaderStyle(band), + templateTransform.getColumnHeaderBackgroundComponent(band), ResetType.COLUMN, null); + break; + } + } + + band = report.getColumnFooterBand(); + columnFooterBand = + band("columnFooter", band, templateTransform.getColumnFooterSplitType(band), templateTransform.getColumnFooterStyle(band), templateTransform.getColumnFooterBackgroundComponent(band), + ResetType.COLUMN, null); + + band = report.getDetailHeaderBand(); + detailBands.add( + band("detailHeader", band, templateTransform.getDetailHeaderSplitType(band), templateTransform.getDetailHeaderStyle(band), templateTransform.getDetailHeaderBackgroundComponent(band), + ResetType.REPORT, null)); + + band = report.getDetailBand(); + detailBand = + band("detail", band, templateTransform.getDetailSplitType(band), templateTransform.getDetailStyle(band), templateTransform.getDetailBackgroundComponent(band), ResetType.REPORT, null); + detailBands.add(detailBand); + + band = report.getDetailFooterBand(); + detailBands.add( + band("detailFooter", band, templateTransform.getDetailFooterSplitType(band), templateTransform.getDetailFooterStyle(band), templateTransform.getDetailFooterBackgroundComponent(band), + ResetType.REPORT, null)); + + band = report.getLastPageFooterBand(); + lastPageFooterBand = band("lastPageFooter", band, templateTransform.getLastPageFooterSplitType(band), templateTransform.getLastPageFooterStyle(band), + templateTransform.getLastPageFooterBackgroundComponent(band), ResetType.PAGE, null); + + band = report.getSummaryBand(); + summaryBand = + band("summary", band, templateTransform.getSummarySplitType(band), templateTransform.getSummaryStyle(band), templateTransform.getSummaryBackgroundComponent(band), ResetType.NONE, null); + + band = report.getNoDataBand(); + noDataBand = + band("noData", band, templateTransform.getNoDataSplitType(band), templateTransform.getNoDataStyle(band), templateTransform.getNoDataBackgroundComponent(band), ResetType.NONE, null); + + band = report.getBackgroundBand(); + backgroundBand = band("background", band, templateTransform.getBackgroundSplitType(band), templateTransform.getBackgroundStyle(band), templateTransform.getBackgroundBackgroundComponent(band), + ResetType.NONE, null); + } + + /** + *

prepareBands.

+ * + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public void prepareBands() throws DRException { + BandComponentsTransform bandComponents = new BandComponentsTransform(accessor); + DRITemplateDesign templateDesign = accessor.getReport().getTemplateDesign(); + int maxWidth = accessor.getPageTransform().getMaxBandWidth(); + int maxColumnWidth = accessor.getPageTransform().getPage().getColumnWidth(); + + titleBand = bandComponents.prepareBand(titleBand, maxWidth, templateDesign.getTitleComponentsCount()); + pageHeaderBand = bandComponents.prepareBand(pageHeaderBand, maxWidth, templateDesign.getPageHeaderComponentsCount()); + pageFooterBand = bandComponents.prepareBand(pageFooterBand, maxWidth, templateDesign.getPageFooterComponentsCount()); + columnHeaderBand = bandComponents.prepareBand(columnHeaderBand, maxColumnWidth, templateDesign.getColumnHeaderComponentsCount()); + columnFooterBand = bandComponents.prepareBand(columnFooterBand, maxColumnWidth, templateDesign.getColumnFooterComponentsCount()); + List removeDetailBands = new ArrayList(); + for (DRDesignBand detailBand : detailBands) { + if (bandComponents.prepareBand(detailBand, maxColumnWidth, 0) == null) { + removeDetailBands.add(detailBand); + } + } + detailBands.removeAll(removeDetailBands); + lastPageFooterBand = bandComponents.prepareBand(lastPageFooterBand, maxWidth, templateDesign.getLastPageFooterComponentsCount()); + summaryBand = bandComponents.prepareBand(summaryBand, maxWidth, templateDesign.getSummaryComponentsCount()); + noDataBand = bandComponents.prepareBand(noDataBand, maxWidth, templateDesign.getNoDataComponentsCount()); + + if (backgroundBand.getList() != null && backgroundBand.getList().isEmpty() && (backgroundBand.getList().getStyle() != null || backgroundBand.getList().getBackgroundComponent() != null)) { + DRDesignFiller component = new DRDesignFiller(); + component.setWidth(1); + component.setHeight(1); + backgroundBand.getList().addComponent(component); + } + backgroundBand = bandComponents.prepareBand(backgroundBand, maxWidth, templateDesign.getBackgroundComponentsCount()); + if (backgroundBand != null && backgroundBand.getBandComponent() != null && backgroundBand.getList() != null && + (backgroundBand.getList().getStyle() != null || backgroundBand.getList().getBackgroundComponent() != null)) { + DRIDesignPage page = accessor.getPage(); + int height = page.getHeight() - page.getMargin().getTop() - page.getMargin().getBottom(); + backgroundBand.getList().setHeight(height); + if (backgroundBand.getList().getBackgroundComponent() != null) { + backgroundBand.getList().getBackgroundComponent().setHeight(height); + } + backgroundBand.setHeight(height); + } + + for (DRDesignGroup group : accessor.getGroupTransform().getGroups()) { + List bands = new ArrayList(); + for (DRDesignBand band : group.getHeaderBands()) { + DRDesignBand newBand = bandComponents.prepareBand(band, maxColumnWidth, 0); + if (newBand != null) { + bands.add(newBand); + } + } + group.setHeaderBands(bands); + bands = new ArrayList(); + for (DRDesignBand band : group.getFooterBands()) { + DRDesignBand newBand = bandComponents.prepareBand(band, maxColumnWidth, 0); + if (newBand != null) { + bands.add(newBand); + } + } + group.setFooterBands(bands); + } + } + + // band + + /** + *

band.

+ * + * @param bandName a {@link java.lang.String} object. + * @param bandName a {@link java.lang.String} object. + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @param splitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @param defaultStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + * @param defaultBackgroundComponent a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignBand band(String bandName, DRIBand band, SplitType splitType, DRIReportStyle defaultStyle, DRIComponent defaultBackgroundComponent, ResetType resetType, DRDesignGroup resetGroup) + throws DRException { + DRDesignBand designBand = new DRDesignBand(bandName); + designBand.setSplitType(splitType); + designBand.setList(accessor.getComponentTransform().list(band.getList(), DefaultStyleType.TEXT, resetType, resetGroup)); + designBand.setPrintWhenExpression(accessor.getExpressionTransform().transformExpression(band.getPrintWhenExpression())); + + if (designBand.getList().getStyle() == null && defaultStyle != null) { + designBand.getList().setStyle(accessor.getStyleTransform().transformStyle(defaultStyle, false, DefaultStyleType.NONE)); + } + if (designBand.getList().getBackgroundComponent() == null && defaultBackgroundComponent != null) { + designBand.getList().setBackgroundComponent(accessor.getComponentTransform().listBackgroundComponent(defaultBackgroundComponent, DefaultStyleType.TEXT, resetType, resetGroup)); + } + + return designBand; + } + + /** + *

band.

+ * + * @param bandName a {@link java.lang.String} object. + * @param bandName a {@link java.lang.String} object. + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @param splitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @param defaultStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + * @param defaultBackgroundComponent a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignBand band(String bandName, DRIBand band, SplitType splitType, DRIReportStyle defaultStyle, DRIComponent defaultBackgroundComponent) throws DRException { + DRDesignBand designBand = new DRDesignBand(bandName); + designBand.setSplitType(splitType); + DRDesignList list = new DRDesignList(); + list.setType(band.getList().getType()); + list.setGap(accessor.getTemplateTransform().getListGap(band.getList())); + list.setStretchType(accessor.getTemplateTransform().getStretchType(band.getList())); + list.setPrintWhenExpression(accessor.getExpressionTransform().transformExpression(band.getList().getPrintWhenExpression())); + list.setStyle(accessor.getStyleTransform().transformStyle(band.getList().getStyle(), false, DefaultStyleType.NONE)); + designBand.setList(list); + + if (list.getStyle() == null && defaultStyle != null) { + list.setStyle(accessor.getStyleTransform().transformStyle(defaultStyle, false, DefaultStyleType.NONE)); + } + if (designBand.getList().getBackgroundComponent() == null && defaultBackgroundComponent != null) { + designBand.getList().setBackgroundComponent(accessor.getComponentTransform().listBackgroundComponent(defaultBackgroundComponent, DefaultStyleType.TEXT, ResetType.NONE, null)); + } + + return designBand; + } + + /** + *

Getter for the field titleBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public DRDesignBand getTitleBand() { + return titleBand; + } + + /** + *

Getter for the field pageHeaderBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public DRDesignBand getPageHeaderBand() { + return pageHeaderBand; + } + + /** + *

Getter for the field pageFooterBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public DRDesignBand getPageFooterBand() { + return pageFooterBand; + } + + /** + *

Getter for the field columnHeaderBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public DRDesignBand getColumnHeaderBand() { + return columnHeaderBand; + } + + /** + *

Getter for the field columnHeaderForGroupBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public DRDesignBand getColumnHeaderForGroupBand() { + return columnHeaderForGroupBand; + } + + /** + *

Getter for the field columnFooterBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public DRDesignBand getColumnFooterBand() { + return columnFooterBand; + } + + /** + *

Getter for the field detailBands.

+ * + * @return a {@link java.util.List} object. + */ + public List getDetailBands() { + return detailBands; + } + + /** + *

Getter for the field detailBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public DRDesignBand getDetailBand() { + return detailBand; + } + + /** + *

Getter for the field lastPageFooterBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public DRDesignBand getLastPageFooterBand() { + return lastPageFooterBand; + } + + /** + *

Getter for the field summaryBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public DRDesignBand getSummaryBand() { + return summaryBand; + } + + /** + *

Getter for the field noDataBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public DRDesignBand getNoDataBand() { + return noDataBand; + } + + /** + *

Getter for the field backgroundBand.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignBand} object. + */ + public DRDesignBand getBackgroundBand() { + return backgroundBand; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ColumnGrid.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ColumnGrid.java new file mode 100644 index 0000000..256f795 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ColumnGrid.java @@ -0,0 +1,121 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import software.xdev.dynamicreports.report.definition.column.DRIColumn; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Ricardo Mariaca + */ +class ColumnGrid { + private DRDesignList list; + private Map, DRDesignList> columnsLists; + private boolean isEmpty; + + /** + *

Constructor for ColumnGrid.

+ */ + public ColumnGrid() { + columnsLists = new HashMap, DRDesignList>(); + isEmpty = true; + } + + /** + *

addList.

+ * + * @param column a {@link software.xdev.dynamicreports.report.definition.column.DRIColumn} object. + * @param list a {@link software.xdev.dynamicreports.design.base.component.DRDesignList} object. + */ + public void addList(DRIColumn column, DRDesignList list) { + columnsLists.put(column, list); + } + + /** + *

addComponent.

+ * + * @param column a {@link software.xdev.dynamicreports.report.definition.column.DRIColumn} object. + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public void addComponent(DRIColumn column, DRDesignComponent component) { + if (columnsLists.containsKey(column)) { + columnsLists.get(column).addComponent(component); + } + } + + /** + *

addComponent.

+ * + * @param column a {@link software.xdev.dynamicreports.report.definition.column.DRIColumn} object. + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + */ + public void addComponent(DRIColumn column, HorizontalCellComponentAlignment horizontalAlignment, VerticalCellComponentAlignment verticalAlignment, DRDesignComponent component) { + if (columnsLists.containsKey(column)) { + columnsLists.get(column).addComponent(horizontalAlignment, verticalAlignment, component); + } + } + + /** + *

Getter for the field list.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignList} object. + */ + public DRDesignList getList() { + return list; + } + + /** + *

Setter for the field list.

+ * + * @param list a {@link software.xdev.dynamicreports.design.base.component.DRDesignList} object. + */ + public void setList(DRDesignList list) { + this.list = list; + } + + /** + *

isEmpty.

+ * + * @return a boolean. + */ + public boolean isEmpty() { + for (DRDesignList list : columnsLists.values()) { + if (!list.isEmpty()) { + return false; + } + } + return isEmpty; + } + + /** + *

setEmpty.

+ * + * @param isEmpty a boolean. + */ + public void setEmpty(boolean isEmpty) { + this.isEmpty = isEmpty; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ColumnGridTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ColumnGridTransform.java new file mode 100644 index 0000000..a1b05d8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ColumnGridTransform.java @@ -0,0 +1,273 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.component.DRDesignFiller; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignListCell; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.design.base.style.DRDesignStyle; +import software.xdev.dynamicreports.design.constant.DefaultStyleType; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.base.grid.DRColumnGridList; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import software.xdev.dynamicreports.report.definition.DRIReport; +import software.xdev.dynamicreports.report.definition.column.DRIBooleanColumn; +import software.xdev.dynamicreports.report.definition.column.DRIColumn; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.component.DRIDimensionComponent; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGrid; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGridList; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGridListCell; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnTitleGroup; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + *

ColumnGridTransform class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class ColumnGridTransform { + private final DesignTransformAccessor accessor; + private DRIColumnGridList columnGridList; + + /** + *

Constructor for ColumnGridTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public ColumnGridTransform(final DesignTransformAccessor accessor) { + this.accessor = accessor; + } + + /** + *

transform.

+ */ + public void transform() { + final DRIReport report = accessor.getReport(); + final DRIColumnGrid columnGrid = report.getColumnGrid(); + if (columnGrid != null && !columnGrid.getList().getListCells().isEmpty()) { + this.columnGridList = columnGrid.getList(); + return; + } + + final DRColumnGridList columnGridList = new DRColumnGridList(); + if (columnGrid != null) { + columnGridList.setGap(columnGrid.getList().getGap()); + columnGridList.setType(columnGrid.getList().getType()); + } + addColumnsToGridList(columnGridList); + this.columnGridList = columnGridList; + } + + private void addColumnsToGridList(final DRColumnGridList columnGridList) { + final DRIReport report = accessor.getReport(); + for (final DRIColumn column : report.getColumns()) { + if (!accessor.getGroupTransform().getHideGroupColumns().contains(column)) { + columnGridList.addComponent(column); + } + } + } + + /** + *

createColumnGrid.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.ColumnGrid} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected ColumnGrid createColumnGrid() throws DRException { + return createColumnGrid(columnGridList, null, false); + } + + /** + *

createColumnTitleGrid.

+ * + * @param groupPaddingStyle a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link software.xdev.dynamicreports.design.transformation.ColumnGrid} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected ColumnGrid createColumnTitleGrid(final DRDesignStyle groupPaddingStyle) throws DRException { + return createColumnGrid(columnGridList, groupPaddingStyle, true); + } + + private ColumnGrid createColumnGrid(final DRIColumnGridList columnGridList, final DRDesignStyle groupPaddingStyle, final boolean titleGroup) throws DRException { + final ColumnGrid columnGrid = new ColumnGrid(); + final DRDesignList list = list(columnGridList, columnGrid, titleGroup).getList(); + final int groupPadding = accessor.getGroupTransform().getGroupPadding(); + if (groupPadding > 0) { + final DRDesignFiller filler = new DRDesignFiller(); + filler.setStyle(groupPaddingStyle); + filler.setWidth(groupPadding); + filler.setHeight(0); + list.addComponent(0, HorizontalCellComponentAlignment.CENTER, null, filler); + } + columnGrid.setList(list); + return columnGrid; + } + + private GridList list(final DRIColumnGridComponent columnGridComponent, final ColumnGrid columnGrid, final boolean titleGroup) throws DRException { + if (columnGridComponent instanceof DRIColumn) { + final DRDesignList list = new DRDesignList(ListType.VERTICAL); + final DRIColumn column = (DRIColumn) columnGridComponent; + list.setWidth(accessor.getTemplateTransform().getColumnWidth(column, accessor.getStyleTransform().getDefaultStyle(DefaultStyleType.COLUMN))); + columnGrid.addList(column, list); + return new GridList(list, null); + } else if (columnGridComponent instanceof DRIColumnGridList) { + return new GridList(columnGridList((DRIColumnGridList) columnGridComponent, columnGrid, titleGroup), null); + } else if (columnGridComponent instanceof DRIColumnTitleGroup) { + return columnGridTitleGroup((DRIColumnTitleGroup) columnGridComponent, columnGrid, titleGroup); + } else { + throw new DRDesignReportException("Column grid component " + columnGridComponent.getClass().getName() + " not supported"); + } + } + + private DRDesignList columnGridList(final DRIColumnGridList columnGridList, final ColumnGrid columnGrid, final boolean titleGroup) throws DRException { + final DRDesignList list = new DRDesignList(); + list.setType(columnGridList.getType()); + list.setGap(columnGridList.getGap()); + for (final DRIColumnGridListCell cell : columnGridList.getListCells()) { + final DRIColumnGridComponent component = cell.getComponent(); + HorizontalCellComponentAlignment horizontalAlignment = cell.getHorizontalAlignment(); + VerticalCellComponentAlignment verticalAlignment = cell.getVerticalAlignment(); + if (component instanceof DRIColumn) { + final DRIColumn column = (DRIColumn) component; + if (column instanceof DRIBooleanColumn) { + if (horizontalAlignment == null) { + horizontalAlignment = ConstantTransform.toHorizontalCellComponentAlignment(((DRIBooleanColumn) column).getComponent().getWidthType()); + } + if (verticalAlignment == null) { + verticalAlignment = ConstantTransform.toVerticalCellComponentAlignment(((DRIBooleanColumn) column).getComponent().getHeightType()); + } + } else { + final DRIComponent columnComponent = accessor.getColumnTransform().getColumnComponent(column); + if (columnComponent instanceof DRIDimensionComponent) { + if (horizontalAlignment == null) { + horizontalAlignment = ConstantTransform.toHorizontalCellComponentAlignment(((DRIDimensionComponent) columnComponent).getWidthType()); + } + if (verticalAlignment == null) { + verticalAlignment = ConstantTransform.toVerticalCellComponentAlignment(((DRIDimensionComponent) columnComponent).getHeightType()); + } + } + } + } + final GridList gridList = list(component, columnGrid, titleGroup); + if (gridList.getHorizontalCellAlignment() != null) { + list.addComponent(gridList.getHorizontalCellAlignment(), cell.getVerticalAlignment(), gridList.getList()); + } else { + list.addComponent(horizontalAlignment, cell.getVerticalAlignment(), gridList.getList()); + } + } + return list; + } + + @SuppressWarnings("unchecked") + private GridList columnGridTitleGroup(final DRIColumnTitleGroup columnGridTitleGroup, final ColumnGrid columnGrid, final boolean titleGroup) throws DRException { + final DRDesignList columnList = list(columnGridTitleGroup.getList(), columnGrid, titleGroup).getList(); + + @SuppressWarnings("rawtypes") final DRTextField titleGroupField = new DRTextField(); + titleGroupField.setValueExpression(columnGridTitleGroup.getTitleExpression()); + titleGroupField.setStyle(columnGridTitleGroup.getTitleStyle()); + titleGroupField.setHeight(columnGridTitleGroup.getTitleHeight()); + titleGroupField.setHeightType(columnGridTitleGroup.getTitleHeightType()); + titleGroupField.setRows(columnGridTitleGroup.getTitleRows()); + titleGroupField.setStretchWithOverflow(columnGridTitleGroup.getTitleStretchWithOverflow()); + titleGroupField.setTextAdjust(columnGridTitleGroup.getTitleTextAdjust()); + titleGroupField.setPropertyExpressions(columnGridTitleGroup.getTitlePropertyExpressions()); + + HorizontalCellComponentAlignment hCellAlignment = null; + if (columnGridTitleGroup.getTitleWidth() == null && columnGridTitleGroup.getTitleColumns() == null) { + int totalWidth = 0; + for (final DRDesignListCell cell : columnList.getListCells()) { + final Integer width = cell.getComponent().getWidth(); + final HorizontalCellComponentAlignment horizontalAlignment = cell.getHorizontalAlignment(); + if (horizontalAlignment == null || horizontalAlignment.equals(HorizontalCellComponentAlignment.EXPAND) || horizontalAlignment.equals(HorizontalCellComponentAlignment.FLOAT)) { + totalWidth = 0; + break; + } + if (width != null) { + totalWidth += width; + } + } + if (totalWidth > 0) { + titleGroupField.setWidth(totalWidth); + hCellAlignment = HorizontalCellComponentAlignment.LEFT; + } + } else { + if (columnGridTitleGroup.getTitleWidth() != null) { + titleGroupField.setWidth(columnGridTitleGroup.getTitleWidth()); + } + if (columnGridTitleGroup.getTitleColumns() != null) { + titleGroupField.setColumns(columnGridTitleGroup.getTitleColumns()); + } + hCellAlignment = ConstantTransform.toHorizontalCellComponentAlignment(columnGridTitleGroup.getTitleWidthType()); + } + + final DRDesignTextField designTitleGroupField = accessor.getComponentTransform().textField(titleGroupField, DefaultStyleType.COLUMN_TITLE); + designTitleGroupField.setUniqueName("columngroup.title"); + + if (!titleGroup || columnGridTitleGroup.getTitleExpression() == null) { + columnList.setRemovable(true); + if (hCellAlignment != null) { + final DRDesignList list = new DRDesignList(); + list.setType(ListType.VERTICAL); + list.addComponent(columnList); + list.setWidth(designTitleGroupField.getWidth()); + return new GridList(list, hCellAlignment); + } + return new GridList(columnList, null); + } + + columnGrid.setEmpty(!titleGroup); + + final DRDesignList list = new DRDesignList(); + list.setType(ListType.VERTICAL); + if (hCellAlignment != null) { + list.addComponent(hCellAlignment, null, designTitleGroupField); + list.addComponent(columnList); + list.setWidth(designTitleGroupField.getWidth()); + return new GridList(list, hCellAlignment); + } else { + list.addComponent(designTitleGroupField); + list.addComponent(columnList); + return new GridList(list, null); + } + } + + private class GridList { + private final HorizontalCellComponentAlignment horizontalCellAlignment; + private final DRDesignList list; + + private GridList(final DRDesignList list, final HorizontalCellComponentAlignment horizontalCellAlignment) { + this.list = list; + this.horizontalCellAlignment = horizontalCellAlignment; + } + + public HorizontalCellComponentAlignment getHorizontalCellAlignment() { + return horizontalCellAlignment; + } + + public DRDesignList getList() { + return list; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ColumnTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ColumnTransform.java new file mode 100644 index 0000000..b5f9233 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ColumnTransform.java @@ -0,0 +1,272 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import java.awt.Color; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.design.base.style.DRDesignStyle; +import software.xdev.dynamicreports.design.constant.DefaultStyleType; +import software.xdev.dynamicreports.report.base.component.DRBooleanField; +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.base.style.DRConditionalStyle; +import software.xdev.dynamicreports.report.base.style.DRPadding; +import software.xdev.dynamicreports.report.base.style.DRStyle; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.definition.column.DRIBooleanColumn; +import software.xdev.dynamicreports.report.definition.column.DRIColumn; +import software.xdev.dynamicreports.report.definition.column.DRIValueColumn; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.style.DRIConditionalStyle; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.definition.style.DRISimpleStyle; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + *

ColumnTransform class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class ColumnTransform { + private final DesignTransformAccessor accessor; + private Map, DRIComponent> columnComponents; + + /** + *

Constructor for ColumnTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public ColumnTransform(final DesignTransformAccessor accessor) { + this.accessor = accessor; + } + + // columns + + /** + *

transform.

+ * + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public void transform() throws DRException { + columnComponents = getColumnComponents(); + final boolean showColumnTitle = accessor.getTemplateTransform().isShowColumnTitle(); + final boolean showColumnValues = accessor.getTemplateTransform().isShowColumnValues(); + final boolean showColumnTitleForGroup = accessor.getBandTransform().getColumnHeaderForGroupBand() != null; + + ColumnGrid columnTitle = null; + if (showColumnTitle) { + columnTitle = accessor.getColumnGridTransform().createColumnTitleGrid(accessor.getStyleTransform().getDefaultStyle(DefaultStyleType.COLUMN_TITLE)); + } + ColumnGrid columnTitleForGroup = null; + if (showColumnTitleForGroup) { + columnTitleForGroup = accessor.getColumnGridTransform().createColumnTitleGrid(accessor.getStyleTransform().getDefaultStyle(DefaultStyleType.COLUMN_TITLE)); + } + final ColumnGrid detail = accessor.getColumnGridTransform().createColumnGrid(); + + for (final DRIColumn column : accessor.getReport().getColumns()) { + if (!accessor.getGroupTransform().getHideGroupColumns().contains(column)) { + if (column.getTitleExpression() != null) { + if (showColumnTitle) { + columnTitle.addComponent(column, titleComponent(column)); + } + if (showColumnTitleForGroup) { + columnTitleForGroup.addComponent(column, titleComponent(column)); + } + } + DRDesignComponent detailComponent = null; + if (column instanceof DRIValueColumn) { + detailComponent = detailValueComponent((DRIValueColumn) column); + } else if (column instanceof DRIBooleanColumn) { + detailComponent = detailBooleanComponent((DRIBooleanColumn) column); + } else { + detailComponent = detailComponent(column); + } + detail.addComponent(column, detailComponent); + } + } + + if (showColumnTitle && !columnTitle.isEmpty()) { + accessor.getBandTransform().getColumnHeaderBand().addComponent(0, columnTitle.getList()); + } + if (showColumnTitleForGroup && !columnTitleForGroup.isEmpty()) { + accessor.getBandTransform().getColumnHeaderForGroupBand().addComponent(0, columnTitleForGroup.getList()); + } + if (showColumnValues) { + accessor.getBandTransform().getDetailBand().addComponent(detail.getList()); + } + } + + private Map, DRIComponent> getColumnComponents() throws DRException { + final Map, DRIComponent> columnComponents = new HashMap<>(); + for (final DRIColumn column : accessor.getReport().getColumns()) { + if (!accessor.getGroupTransform().getHideGroupColumns().contains(column)) { + DRIComponent component = column.getComponent(); + if (column instanceof DRIBooleanColumn) { + component = createBooleanComponent((DRIBooleanColumn) column); + } + columnComponents.put(column, component); + } + } + return columnComponents; + } + + private DRIComponent createBooleanComponent(final DRIBooleanColumn column) throws DRException { + final DRIReportStyle booleanColumnStyle = accessor.getTemplateTransform().getBooleanColumnStyle(column); + if (booleanColumnStyle == null) { + return column.getComponent(); + } + final DRBooleanField booleanField = new DRBooleanField(); + booleanField.setComponentType(column.getComponent().getComponentType()); + booleanField.setEmptyWhenNullValue(column.getComponent().getEmptyWhenNullValue()); + booleanField.setValueExpression(column.getComponent().getValueExpression()); + booleanField.setWidth(column.getComponent().getWidth()); + booleanField.setWidthType(column.getComponent().getWidthType()); + booleanField.setHeight(column.getComponent().getHeight()); + booleanField.setHeightType(column.getComponent().getHeightType()); + booleanField.setImageWidth(column.getComponent().getImageWidth()); + booleanField.setImageHeight(column.getComponent().getImageHeight()); + booleanField.setHorizontalImageAlignment(column.getComponent().getHorizontalImageAlignment()); + booleanField.setHorizontalTextAlignment(column.getComponent().getHorizontalTextAlignment()); + booleanField.setStyle(booleanColumnStyle); + booleanField.setPrintWhenExpression(column.getComponent().getPrintWhenExpression()); + return booleanField; + } + + // title + @SuppressWarnings("unchecked") + private DRDesignComponent titleComponent(final DRIColumn column) throws DRException { + @SuppressWarnings("rawtypes") final DRTextField titleField = new DRTextField(); + titleField.setValueExpression(column.getTitleExpression()); + titleField.setStyle(column.getTitleStyle()); + titleField.setWidth(accessor.getTemplateTransform().getColumnWidth(column, accessor.getStyleTransform().getDefaultStyle(DefaultStyleType.COLUMN))); + titleField.setHeight(column.getTitleHeight()); + titleField.setHeightType(column.getTitleHeightType()); + titleField.setRows(column.getTitleRows()); + titleField.setStretchWithOverflow(column.getTitleStretchWithOverflow()); + titleField.setTextAdjust(column.getTitleTextAdjust()); + titleField.setPropertyExpressions(column.getTitlePropertyExpressions()); + final DRDesignTextField designTitleField = accessor.getComponentTransform().textField(titleField, DefaultStyleType.COLUMN_TITLE); + designTitleField.setUniqueName("column_" + column.getName() + ".title"); + return designTitleField; + } + + // detail + private DRDesignComponent detailValueComponent(final DRIValueColumn column) throws DRException { + final DRDesignComponent detailComponent = detailComponent(column); + ((DRDesignTextField) detailComponent).setPrintRepeatedValues(accessor.getTemplateTransform().isColumnPrintRepeatedDetailValues(column)); + return detailComponent; + } + + private DRDesignComponent detailBooleanComponent(final DRIBooleanColumn column) throws DRException { + final DRDesignComponent detailComponent = detailComponent(column); + + return detailComponent; + } + + private DRDesignComponent detailComponent(final DRIColumn column) throws DRException { + final DRDesignComponent designComponent = accessor.getComponentTransform().component(getColumnComponent(column), DefaultStyleType.COLUMN, null, null); + designComponent.setUniqueName("column_" + column.getName()); + + final List rowHighlighters = new ArrayList<>(); + rowHighlighters.addAll(getDetailRowHighlighters()); + final DRISimpleStyle detailOddRowStyle = accessor.getTemplateTransform().getDetailOddRowStyle(); + if (detailOddRowStyle != null) { + rowHighlighters.add(detailRowConditionalStyle(detailOddRowStyle, Expressions.printInOddRow())); + } + final DRISimpleStyle detailEvenRowStyle = accessor.getTemplateTransform().getDetailEvenRowStyle(); + if (detailEvenRowStyle != null) { + rowHighlighters.add(detailRowConditionalStyle(detailEvenRowStyle, Expressions.printInEvenRow())); + } + if (!rowHighlighters.isEmpty()) { + DRIReportStyle style = getColumnComponent(column).getStyle(); + if (style == null) { + style = accessor.getTemplateTransform().getColumnStyle(column instanceof DRIValueColumn); + } + final DRStyle newStyle = new DRStyle(); + newStyle.setParentStyle(style); + if (!(column instanceof DRIValueColumn)) { + newStyle.setPadding(new DRPadding(0)); + } + final List conditionalStyles = new ArrayList<>(); + if (style != null) { + final DRIStyle stl = accessor.getStyleTransform().getStyle(style); + for (final DRIConditionalStyle conditionalStyle : stl.getConditionalStyles()) { + conditionalStyles.add(conditionalStyle); + } + } + for (final DRIConditionalStyle conditionalStyle : rowHighlighters) { + conditionalStyles.add(conditionalStyle); + } + final Color backgroundColor = StyleResolver.getBackgroundColor(style, accessor.getStyleTransform()); + for (final DRIConditionalStyle conditionalStyle : conditionalStyles) { + if (backgroundColor != null && conditionalStyle.getBackgroundColor() != null) { + final DRConditionalStyle newConditionalStyle = new DRConditionalStyle(conditionalStyle.getConditionExpression()); + accessor.getStyleTransform().copyStyle(newConditionalStyle, conditionalStyle); + final Color mergedColor = StyleResolver.mergeColors(backgroundColor, conditionalStyle.getBackgroundColor(), 0.25f); + newConditionalStyle.setBackgroundColor(mergedColor); + newStyle.addConditionalStyle(newConditionalStyle); + } else { + newStyle.addConditionalStyle((DRConditionalStyle) conditionalStyle); + } + } + designComponent.setStyle(accessor.getStyleTransform().transformStyle(newStyle, true, DefaultStyleType.COLUMN)); + } else { + if (designComponent.getStyle() == null && !(column instanceof DRIValueColumn)) { + final DRIReportStyle columnStyle = accessor.getTemplateTransform().getColumnStyle(false); + DRStyle newStyle = null; + if (columnStyle != null) { + newStyle = new DRStyle(); + newStyle.setParentStyle(columnStyle); + newStyle.setPadding(new DRPadding(0)); + } + final DRDesignStyle designColumnStyle = accessor.getStyleTransform().transformStyle(newStyle, false, DefaultStyleType.NONE); + designComponent.setStyle(designColumnStyle); + } + } + + return designComponent; + } + + private List getDetailRowHighlighters() { + return accessor.getReport().getDetailRowHighlighters(); + } + + private DRConditionalStyle detailRowConditionalStyle(final DRISimpleStyle style, final DRIExpression expression) { + final DRConditionalStyle conditionalStyle = new DRConditionalStyle(expression); + accessor.getStyleTransform().copyStyle(conditionalStyle, style); + return conditionalStyle; + } + + /** + *

getColumnComponent.

+ * + * @param column a {@link software.xdev.dynamicreports.report.definition.column.DRIColumn} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getColumnComponent(final DRIColumn column) { + return columnComponents.get(column); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ComponentPosition.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ComponentPosition.java new file mode 100644 index 0000000..77f815c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ComponentPosition.java @@ -0,0 +1,836 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignListCell; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Ricardo Mariaca + */ +class ComponentPosition { + + /** + *

component.

+ * + * @param name a {@link java.lang.String} object. + * @param component a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + * @param maxWidth a int. + * @param maxHeight a int. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected static void component(String name, DRDesignComponent component, int maxWidth, int maxHeight) throws DRException { + if (component instanceof DRDesignList) { + DRDesignList list = (DRDesignList) component; + list.setX(0); + list.setY(0); + list(name, list, maxWidth, maxHeight, true); + list(name, list); + } else { + throw new DRDesignReportException("Component " + component.getClass().getName() + " position not supported"); + } + } + + private static void list(String name, DRDesignList list, int maxWidth, int maxHeight, boolean stretch) throws DRException { + width(list); + alignment(list); + recalculateWidth(name, list, maxWidth - StyleResolver.getHorizontalPadding(list.getStyle())); + height(list); + + int availableWidth = maxWidth - list.getWidth(); + if (availableWidth < 0) { + throw new DRException(name + " components reaches outside available width, available width = " + maxWidth + ", components width = " + list.getWidth()); + } + if (stretch) { + list.setWidth(list.getWidth() + availableWidth); + } + + if (maxHeight > 0) { + int availableHeight = maxHeight - list.getHeight(); + if (availableHeight < 0) { + throw new DRException(name + " components reaches outside available height, available height = " + maxHeight + ", components height = " + list.getHeight()); + } + if (stretch) { + list.setHeight(list.getHeight() + availableHeight); + } + } + + listCellWidth(list, availableWidth, list.getWidth() - StyleResolver.getHorizontalPadding(list.getStyle())); + listCellX(list); + listCellHeight(list, list.getHeight() - StyleResolver.getVerticalPadding(list.getStyle())); + listCellY(list); + + componentX(list); + componentY(list); + componentWidth(list); + componentHeight(list); + } + + private static void list(String name, DRDesignList list) throws DRException { + for (DRDesignComponent designComponent : list.getComponents()) { + if (designComponent instanceof DRDesignList) { + DRDesignList listComponent = (DRDesignList) designComponent; + if (!listComponent.isCalculateComponents()) { + listComponent.setCalculateComponents(true); + list(name, listComponent, listComponent.getWidth(), listComponent.getHeight(), false); + } + list(name, listComponent); + } + } + } + + private static void alignment(DRDesignList list) { + for (DRDesignListCell listCell : list.getListCells()) { + if (listCell.getComponent() instanceof DRDesignList) { + DRDesignList comList = (DRDesignList) listCell.getComponent(); + alignment(comList); + if (listCell.getHorizontalAlignment() == null) { + listCell.setHorizontalAlignment(detectHorizontalCellComponentAlignment(comList)); + } + if (listCell.getVerticalAlignment() == null) { + listCell.setVerticalAlignment(detectVerticalCellComponentAlignment(comList)); + } + } + if (listCell.getHorizontalAlignment() == null) { + listCell.setHorizontalAlignment(Defaults.getDefaults().getHorizontalCellComponentAlignment()); + } + if (listCell.getVerticalAlignment() == null) { + listCell.setVerticalAlignment(Defaults.getDefaults().getVerticalCellComponentAlignment()); + } + } + } + + private static HorizontalCellComponentAlignment detectHorizontalCellComponentAlignment(DRDesignList list) { + ListType type = list.getType(); + + if (type == null) { + return null; + } + + switch (type) { + case HORIZONTAL: + case HORIZONTAL_FLOW: + for (DRDesignListCell listCell : list.getListCells()) { + switch (listCell.getHorizontalAlignment()) { + case EXPAND: + case FLOAT: + return null; + default: + break; + } + } + return HorizontalCellComponentAlignment.LEFT; + case VERTICAL: + HorizontalCellComponentAlignment alignment = null; + int maxWidth = 0; + for (DRDesignComponent designComponent : list.getComponents()) { + if (designComponent.getWidth() > maxWidth) { + maxWidth = designComponent.getWidth(); + } + } + for (DRDesignListCell listCell : list.getListCells()) { + switch (listCell.getHorizontalAlignment()) { + case EXPAND: + return HorizontalCellComponentAlignment.EXPAND; + case FLOAT: + alignment = HorizontalCellComponentAlignment.FLOAT; + break; + default: + if (alignment == null) { + alignment = HorizontalCellComponentAlignment.LEFT; + } else { + if (alignment != HorizontalCellComponentAlignment.LEFT && maxWidth == listCell.getComponent().getWidth()) { + return HorizontalCellComponentAlignment.EXPAND; + } + } + break; + } + } + return alignment; + default: + throw new DRDesignReportException("List type " + type.name() + " not supported"); + } + } + + private static VerticalCellComponentAlignment detectVerticalCellComponentAlignment(DRDesignList list) { + ListType type = list.getType(); + + if (type == null) { + return null; + } + + switch (type) { + case HORIZONTAL: + case HORIZONTAL_FLOW: + VerticalCellComponentAlignment alignment = null; + for (DRDesignListCell listCell : list.getListCells()) { + switch (listCell.getVerticalAlignment()) { + case EXPAND: + return VerticalCellComponentAlignment.EXPAND; + default: + if (alignment == null) { + alignment = VerticalCellComponentAlignment.TOP; + } + break; + } + } + return alignment; + case VERTICAL: + return null; + default: + throw new DRDesignReportException("List type " + type.name() + " not supported"); + } + } + + /** + *

width.

+ * + * @param list a {@link software.xdev.dynamicreports.design.base.component.DRDesignList} object. + */ + protected static void width(DRDesignList list) { + int maxWidth = 0; + ListType type = list.getType(); + + if (type != null) { + switch (type) { + case HORIZONTAL: + case HORIZONTAL_FLOW: + for (DRDesignComponent component : list.getComponents()) { + if (component instanceof DRDesignList) { + width((DRDesignList) component);// , availableWidth - StyleResolver.getHorizontalPadding(component.getStyle())); + } + if (component.getWidth() == null) { + throw new DRDesignReportException("Component has null width"); + } + maxWidth += component.getWidth() + list.getGap(); + } + if (!list.getComponents().isEmpty()) { + maxWidth -= list.getGap(); + } + break; + case VERTICAL: + for (DRDesignComponent component : list.getComponents()) { + if (component instanceof DRDesignList) { + width((DRDesignList) component);// , availableWidth - StyleResolver.getHorizontalPadding(component.getStyle())); + } + if (component.getWidth() == null) { + throw new DRDesignReportException("Component has null width"); + } + if (component.getWidth() > maxWidth) { + maxWidth = component.getWidth(); + } + } + break; + default: + throw new DRDesignReportException("List type " + type.name() + " not supported"); + } + } else { + for (DRDesignComponent component : list.getComponents()) { + if (component instanceof DRDesignList) { + width((DRDesignList) component);// , availableWidth - StyleResolver.getHorizontalPadding(component.getStyle())); + } + if (component.getWidth() == null) { + throw new DRDesignReportException("Component has null width"); + } + if (component.getWidth() + component.getX() > maxWidth) { + maxWidth = component.getWidth() + component.getX(); + } + } + } + + maxWidth += StyleResolver.getHorizontalPadding(list.getStyle()); + + if (list.getWidth() == null) { + list.setWidth(maxWidth); + } + } + + private static void recalculateWidth(String name, DRDesignList list, int availableWidth) throws DRException { + if (!list.isCalculateComponents()) { + return; + } + if (list.getWidth() <= availableWidth) { + return; + } + + int maxWidth = 0; + ListType type = list.getType(); + + if (type == null) { + return; + } + + switch (type) { + case HORIZONTAL: + int floatCells = 0; + int floatCellsWidth = 0; + for (DRDesignListCell listCell : list.getListCells()) { + if (listCell.getHorizontalAlignment().equals(HorizontalCellComponentAlignment.FLOAT)) { + floatCellsWidth += listCell.getComponent().getWidth(); + floatCells++; + } + } + if (list.getWidth() - floatCellsWidth >= availableWidth) { + throw new DRException(name + " components reaches outside available width, available width = " + availableWidth + ", components width = " + list.getWidth()); + } + availableWidth -= list.getWidth() - floatCellsWidth; + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + if (listCell.getHorizontalAlignment().equals(HorizontalCellComponentAlignment.FLOAT)) { + int availableCellWidth = 0; + if (floatCells > 1) { + availableCellWidth = (int) ((double) availableWidth / floatCellsWidth * component.getWidth()); + floatCellsWidth -= component.getWidth(); + availableWidth -= availableCellWidth; + } else if (floatCells == 1) { + availableCellWidth = availableWidth; + availableWidth = 0; + } + floatCells--; + + if (component instanceof DRDesignList) { + recalculateWidth(name, (DRDesignList) component, availableCellWidth - StyleResolver.getHorizontalPadding(component.getStyle())); + } else { + component.setWidth(availableCellWidth); + } + } + maxWidth += component.getWidth() + list.getGap(); + } + if (!list.getComponents().isEmpty()) { + maxWidth -= list.getGap(); + } + break; + case HORIZONTAL_FLOW: + maxWidth = splitHorizontalListWhenOverflowWidth(name, list, availableWidth); + break; + case VERTICAL: + maxWidth = availableWidth; + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + if (component.getWidth() > availableWidth) { + if (listCell.getHorizontalAlignment().equals(HorizontalCellComponentAlignment.FLOAT)) { + if (component instanceof DRDesignList) { + recalculateWidth(name, (DRDesignList) component, availableWidth - StyleResolver.getHorizontalPadding(component.getStyle())); + } else { + component.setWidth(availableWidth); + } + } else { + throw new DRException(name + " components reaches outside available width, available width = " + availableWidth + ", components width = " + component.getWidth()); + } + } + if (component.getWidth() > maxWidth) { + maxWidth = component.getWidth(); + } + } + break; + default: + throw new DRDesignReportException("List type " + type.name() + " not supported"); + } + maxWidth += StyleResolver.getHorizontalPadding(list.getStyle()); + list.setWidth(maxWidth); + } + + private static int splitHorizontalListWhenOverflowWidth(String name, DRDesignList list, int availableWidth) throws DRException { + List listCells = new ArrayList(list.getListCells()); + list.getListCells().clear(); + list.getComponents().clear(); + + HorizontalCellComponentAlignment hAlignment = Defaults.getDefaults().getHorizontalCellComponentAlignment(); + VerticalCellComponentAlignment vAlignment = Defaults.getDefaults().getVerticalCellComponentAlignment(); + + DRDesignList column = new DRDesignList(ListType.VERTICAL); + list.addComponent(hAlignment, vAlignment, column); + DRDesignList row = new DRDesignList(ListType.HORIZONTAL); + row.setGap(list.getGap()); + column.addComponent(hAlignment, vAlignment, row); + + int maxWidth = 0; + int rowMaxWidth = 0; + for (DRDesignListCell listCell : listCells) { + DRDesignComponent component = listCell.getComponent(); + if (component.getWidth() > availableWidth) { + throw new DRException(name + " components reaches outside available width, available width = " + availableWidth + ", components width = " + component.getWidth()); + } + if (rowMaxWidth + component.getWidth() > availableWidth) { + int width = rowMaxWidth - list.getGap(); + if (width > maxWidth) { + maxWidth = width; + } + row.setWidth(width); + row = new DRDesignList(ListType.HORIZONTAL); + row.setGap(list.getGap()); + column.addComponent(hAlignment, vAlignment, row); + rowMaxWidth = 0; + } + row.addComponent(listCell.getHorizontalAlignment(), listCell.getVerticalAlignment(), component); + rowMaxWidth += component.getWidth() + list.getGap(); + } + int width = rowMaxWidth - list.getGap(); + if (width > maxWidth) { + maxWidth = width; + } + row.setWidth(width); + column.setWidth(maxWidth); + + return maxWidth; + } + + /** + *

height.

+ * + * @param list a {@link software.xdev.dynamicreports.design.base.component.DRDesignList} object. + */ + protected static void height(DRDesignList list) { + int maxHeight = 0; + ListType type = list.getType(); + + if (type != null) { + switch (type) { + case HORIZONTAL: + case HORIZONTAL_FLOW: + for (DRDesignComponent component : list.getComponents()) { + if (component instanceof DRDesignList) { + height((DRDesignList) component); + } + if (component.getHeight() == null) { + throw new DRDesignReportException("Component has null height"); + } + if (component.getHeight() > maxHeight) { + maxHeight = component.getHeight(); + } + } + break; + case VERTICAL: + for (DRDesignComponent component : list.getComponents()) { + if (component instanceof DRDesignList) { + height((DRDesignList) component); + } + if (component.getHeight() == null) { + throw new DRDesignReportException("Component has null height"); + } + maxHeight += component.getHeight() + list.getGap(); + + } + if (!list.getComponents().isEmpty()) { + maxHeight -= list.getGap(); + } + break; + default: + throw new DRDesignReportException("List type " + type.name() + " not supported"); + } + } else { + for (DRDesignComponent component : list.getComponents()) { + if (component instanceof DRDesignList) { + height((DRDesignList) component); + } + if (component.getHeight() == null) { + throw new DRDesignReportException("Component has null height"); + } + if (component.getHeight() + component.getY() > maxHeight) { + maxHeight = component.getHeight() + component.getY(); + } + } + } + + maxHeight += StyleResolver.getVerticalPadding(list.getStyle()); + + if (list.getHeight() == null) { + list.setHeight(maxHeight); + } + } + + private static void listCellWidth(DRDesignList list, int availableWidth, int maxWidth) { + if (!list.isCalculateComponents()) { + return; + } + + ListType type = list.getType(); + if (type != null) { + switch (type) { + case HORIZONTAL: + case HORIZONTAL_FLOW: + int expandCellsWidth = 0; + int expandCells = 0; + for (DRDesignListCell listCell : list.getListCells()) { + switch (listCell.getHorizontalAlignment()) { + case FLOAT: + case EXPAND: + expandCellsWidth += listCell.getComponent().getWidth(); + expandCells++; + break; + default: + break; + } + } + + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + switch (listCell.getHorizontalAlignment()) { + case FLOAT: + case EXPAND: + int availableCellWidth = 0; + if (expandCells > 1) { + availableCellWidth = (int) ((double) availableWidth / expandCellsWidth * component.getWidth()); + expandCellsWidth -= component.getWidth(); + availableWidth -= availableCellWidth; + } else if (expandCells == 1) { + availableCellWidth = availableWidth; + availableWidth = 0; + } + expandCells--; + + listCell.setWidth(component.getWidth() + availableCellWidth); + if (component instanceof DRDesignList) { + listCellWidth((DRDesignList) component, availableCellWidth, component.getWidth() + availableCellWidth - StyleResolver.getHorizontalPadding(component.getStyle())); + } + break; + default: + listCell.setWidth(component.getWidth()); + if (component instanceof DRDesignList) { + listCellWidth((DRDesignList) component, 0, component.getWidth() - StyleResolver.getHorizontalPadding(component.getStyle())); + } + break; + } + } + break; + case VERTICAL: + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + switch (listCell.getHorizontalAlignment()) { + case FLOAT: + case EXPAND: + listCell.setWidth(maxWidth); + if (component instanceof DRDesignList) { + listCellWidth((DRDesignList) component, maxWidth - component.getWidth(), maxWidth - StyleResolver.getHorizontalPadding(component.getStyle())); + } + break; + default: + listCell.setWidth(maxWidth); + if (component instanceof DRDesignList) { + listCellWidth((DRDesignList) component, 0, component.getWidth() - StyleResolver.getHorizontalPadding(component.getStyle())); + } + break; + } + } + break; + default: + throw new DRDesignReportException("List type " + type.name() + " not supported"); + } + } else { + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + listCell.setWidth(component.getWidth()); + if (component instanceof DRDesignList) { + listCellWidth((DRDesignList) component, 0, component.getWidth() - StyleResolver.getHorizontalPadding(component.getStyle())); + } + } + } + } + + private static void listCellX(DRDesignList list) { + if (!list.isCalculateComponents()) { + return; + } + + ListType type = list.getType(); + if (type != null) { + switch (type) { + case HORIZONTAL: + case HORIZONTAL_FLOW: + int x = 0; + for (DRDesignListCell listCell : list.getListCells()) { + listCell.setX(x); + x += listCell.getWidth() + list.getGap(); + if (listCell.getComponent() instanceof DRDesignList) { + listCellX((DRDesignList) listCell.getComponent()); + } + } + break; + case VERTICAL: + for (DRDesignListCell listCell : list.getListCells()) { + listCell.setX(0); + if (listCell.getComponent() instanceof DRDesignList) { + listCellX((DRDesignList) listCell.getComponent()); + } + } + break; + default: + throw new DRDesignReportException("List type " + type.name() + " not supported"); + } + } else { + for (DRDesignListCell listCell : list.getListCells()) { + listCell.setX(listCell.getComponent().getX()); + if (listCell.getComponent() instanceof DRDesignList) { + listCellX((DRDesignList) listCell.getComponent()); + } + } + } + } + + private static void listCellHeight(DRDesignList list, int availableHeight) { + if (!list.isCalculateComponents()) { + return; + } + + ListType type = list.getType(); + if (type != null) { + switch (type) { + case HORIZONTAL: + case HORIZONTAL_FLOW: + int maxHeight = availableHeight; + for (DRDesignListCell listCell : list.getListCells()) { + if (listCell.getComponent().getHeight() > maxHeight) { + maxHeight = listCell.getComponent().getHeight(); + } + } + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + switch (listCell.getVerticalAlignment()) { + case EXPAND: + listCell.setHeight(maxHeight); + if (component instanceof DRDesignList) { + listCellHeight((DRDesignList) component, maxHeight - StyleResolver.getVerticalPadding(component.getStyle())); + } + break; + default: + listCell.setHeight(maxHeight); + if (component instanceof DRDesignList) { + listCellHeight((DRDesignList) component, component.getHeight() - StyleResolver.getVerticalPadding(component.getStyle())); + } + break; + } + } + break; + case VERTICAL: + maxHeight = 0; + int expandCellsHeight = 0; + int expandCells = 0; + for (DRDesignListCell listCell : list.getListCells()) { + maxHeight += listCell.getComponent().getHeight(); + switch (listCell.getVerticalAlignment()) { + case EXPAND: + expandCellsHeight += listCell.getComponent().getHeight(); + expandCells++; + break; + default: + break; + } + } + availableHeight = availableHeight - maxHeight - list.getGap() * (list.getComponents().size() - 1); + + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + switch (listCell.getVerticalAlignment()) { + case EXPAND: + int availableCellHeight = 0; + if (expandCells > 1) { + availableCellHeight = (int) ((double) availableHeight / expandCellsHeight * component.getHeight()); + expandCellsHeight -= component.getHeight(); + availableHeight -= availableCellHeight; + } else if (expandCells == 1) { + availableCellHeight = availableHeight; + availableHeight = 0; + } + expandCells--; + + listCell.setHeight(component.getHeight() + availableCellHeight); + if (component instanceof DRDesignList) { + listCellHeight((DRDesignList) component, listCell.getHeight() - StyleResolver.getVerticalPadding(component.getStyle())); + } + break; + default: + listCell.setHeight(component.getHeight()); + if (component instanceof DRDesignList) { + listCellHeight((DRDesignList) component, listCell.getHeight() - StyleResolver.getVerticalPadding(component.getStyle())); + } + break; + } + } + break; + default: + throw new DRDesignReportException("List type " + type.name() + " not supported"); + } + } else { + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + listCell.setHeight(component.getHeight()); + if (component instanceof DRDesignList) { + listCellHeight((DRDesignList) component, listCell.getHeight() - StyleResolver.getVerticalPadding(component.getStyle())); + } + } + } + } + + private static void listCellY(DRDesignList list) { + if (!list.isCalculateComponents()) { + return; + } + + ListType type = list.getType(); + if (type != null) { + switch (type) { + case HORIZONTAL: + case HORIZONTAL_FLOW: + for (DRDesignListCell listCell : list.getListCells()) { + listCell.setY(0); + if (listCell.getComponent() instanceof DRDesignList) { + listCellY((DRDesignList) listCell.getComponent()); + } + } + break; + case VERTICAL: + int y = 0; + for (DRDesignListCell listCell : list.getListCells()) { + listCell.setY(y); + y += listCell.getHeight() + list.getGap(); + if (listCell.getComponent() instanceof DRDesignList) { + listCellY((DRDesignList) listCell.getComponent()); + } + } + break; + default: + throw new DRDesignReportException("List type " + type.name() + " not supported"); + } + } else { + for (DRDesignListCell listCell : list.getListCells()) { + listCell.setY(listCell.getComponent().getY()); + if (listCell.getComponent() instanceof DRDesignList) { + listCellY((DRDesignList) listCell.getComponent()); + } + } + } + } + + private static void componentX(DRDesignList list) { + if (!list.isCalculateComponents()) { + return; + } + + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + HorizontalCellComponentAlignment alignment = listCell.getHorizontalAlignment(); + switch (alignment) { + case FLOAT: + case EXPAND: + case LEFT: + component.setX(listCell.getX()); + break; + case CENTER: + component.setX(listCell.getX() + listCell.getWidth() / 2 - component.getWidth() / 2); + break; + case RIGHT: + component.setX(listCell.getX() + listCell.getWidth() - component.getWidth()); + break; + default: + throw new DRDesignReportException("Component alignment " + alignment.name() + " not supported"); + } + if (component instanceof DRDesignList) { + componentX((DRDesignList) component); + } + } + } + + private static void componentY(DRDesignList list) { + if (!list.isCalculateComponents()) { + return; + } + + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + VerticalCellComponentAlignment alignment = listCell.getVerticalAlignment(); + switch (alignment) { + case EXPAND: + case TOP: + component.setY(listCell.getY()); + break; + case MIDDLE: + component.setY(listCell.getY() + listCell.getHeight() / 2 - component.getHeight() / 2); + break; + case BOTTOM: + component.setY(listCell.getY() + listCell.getHeight() - component.getHeight()); + break; + default: + throw new DRDesignReportException("Component alignment " + alignment.name() + " not supported"); + } + if (component instanceof DRDesignList) { + componentY((DRDesignList) component); + } + } + } + + private static void componentWidth(DRDesignList list) { + if (!list.isCalculateComponents()) { + return; + } + + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + HorizontalCellComponentAlignment alignment = listCell.getHorizontalAlignment(); + switch (alignment) { + case FLOAT: + case EXPAND: + component.setWidth(listCell.getWidth()); + break; + case LEFT: + case CENTER: + case RIGHT: + break; + default: + throw new DRDesignReportException("Component alignment " + alignment.name() + " not supported"); + } + if (component instanceof DRDesignList) { + componentWidth((DRDesignList) component); + } + } + } + + private static void componentHeight(DRDesignList list) { + if (!list.isCalculateComponents()) { + return; + } + + for (DRDesignListCell listCell : list.getListCells()) { + DRDesignComponent component = listCell.getComponent(); + VerticalCellComponentAlignment alignment = listCell.getVerticalAlignment(); + switch (alignment) { + case EXPAND: + component.setHeight(listCell.getHeight()); + break; + case TOP: + case MIDDLE: + case BOTTOM: + break; + default: + throw new DRDesignReportException("Component alignment " + alignment.name() + " not supported"); + } + if (component instanceof DRDesignList) { + componentHeight((DRDesignList) component); + } + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ComponentTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ComponentTransform.java new file mode 100644 index 0000000..71015af --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ComponentTransform.java @@ -0,0 +1,912 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.base.DRDesignHyperLink; +import software.xdev.dynamicreports.design.base.DRDesignTableOfContentsHeading; +import software.xdev.dynamicreports.design.base.DRDesignVariable; +import software.xdev.dynamicreports.design.base.component.DRDesignBreak; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignEllipse; +import software.xdev.dynamicreports.design.base.component.DRDesignFiller; +import software.xdev.dynamicreports.design.base.component.DRDesignGenericElement; +import software.xdev.dynamicreports.design.base.component.DRDesignHyperlinkComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignImage; +import software.xdev.dynamicreports.design.base.component.DRDesignLine; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignMap; +import software.xdev.dynamicreports.design.base.component.DRDesignRectangle; +import software.xdev.dynamicreports.design.base.component.DRDesignSubreport; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab; +import software.xdev.dynamicreports.design.base.style.DRDesignStyle; +import software.xdev.dynamicreports.design.constant.DefaultStyleType; +import software.xdev.dynamicreports.design.constant.EvaluationTime; +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.DRIDesignField; +import software.xdev.dynamicreports.design.definition.DRIDesignVariable; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignJasperExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSystemExpression; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.design.transformation.expressions.BooleanTextValueFormatter; +import software.xdev.dynamicreports.design.transformation.expressions.CurrentDateExpression; +import software.xdev.dynamicreports.design.transformation.expressions.MultiPageListDataSourceExpression; +import software.xdev.dynamicreports.design.transformation.expressions.MultiPageListSubreportExpression; +import software.xdev.dynamicreports.design.transformation.expressions.PageNumberExpression; +import software.xdev.dynamicreports.design.transformation.expressions.PageXofYNumberExpression; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.DRGroup; +import software.xdev.dynamicreports.report.base.DRHyperLink; +import software.xdev.dynamicreports.report.base.component.DRHyperLinkComponent; +import software.xdev.dynamicreports.report.base.component.DRList; +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.base.style.DRPen; +import software.xdev.dynamicreports.report.base.style.DRStyle; +import software.xdev.dynamicreports.report.builder.DynamicReports; +import software.xdev.dynamicreports.report.builder.component.Components; +import software.xdev.dynamicreports.report.builder.datatype.DataTypes; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.component.CustomComponentTransform; +import software.xdev.dynamicreports.report.component.CustomComponents; +import software.xdev.dynamicreports.report.component.DRICustomComponent; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import software.xdev.dynamicreports.report.definition.DRIGroup; +import software.xdev.dynamicreports.report.definition.DRIHyperLink; +import software.xdev.dynamicreports.report.definition.component.DRIBooleanField; +import software.xdev.dynamicreports.report.definition.component.DRIBreak; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.component.DRICurrentDate; +import software.xdev.dynamicreports.report.definition.component.DRIDimensionComponent; +import software.xdev.dynamicreports.report.definition.component.DRIEllipse; +import software.xdev.dynamicreports.report.definition.component.DRIFiller; +import software.xdev.dynamicreports.report.definition.component.DRIFormatField; +import software.xdev.dynamicreports.report.definition.component.DRIGenericElement; +import software.xdev.dynamicreports.report.definition.component.DRIHyperLinkComponent; +import software.xdev.dynamicreports.report.definition.component.DRIImage; +import software.xdev.dynamicreports.report.definition.component.DRILine; +import software.xdev.dynamicreports.report.definition.component.DRIList; +import software.xdev.dynamicreports.report.definition.component.DRIListCell; +import software.xdev.dynamicreports.report.definition.component.DRIMap; +import software.xdev.dynamicreports.report.definition.component.DRIMultiPageList; +import software.xdev.dynamicreports.report.definition.component.DRIPageNumber; +import software.xdev.dynamicreports.report.definition.component.DRIPageXofY; +import software.xdev.dynamicreports.report.definition.component.DRIRectangle; +import software.xdev.dynamicreports.report.definition.component.DRISubreport; +import software.xdev.dynamicreports.report.definition.component.DRITextField; +import software.xdev.dynamicreports.report.definition.component.DRITotalPages; +import software.xdev.dynamicreports.report.definition.component.DRIXyList; +import software.xdev.dynamicreports.report.definition.component.DRIXyListCell; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIParameterExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + *

ComponentTransform class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class ComponentTransform { + private final DesignTransformAccessor accessor; + + /** + *

Constructor for ComponentTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public ComponentTransform(final DesignTransformAccessor accessor) { + this.accessor = accessor; + } + + // component + + /** + *

component.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + * @param defaultStyleType a {@link software.xdev.dynamicreports.design.constant.DefaultStyleType} object. + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignComponent component(final DRIComponent component, final DefaultStyleType defaultStyleType, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + if (component instanceof DRITextField) { + return this.textField((DRITextField) component, defaultStyleType); + } + if (component instanceof DRIList) { + return this.list((DRIList) component, defaultStyleType, resetType, resetGroup); + } + if (component instanceof DRIXyList) { + return this.xyList((DRIXyList) component, defaultStyleType, resetType, resetGroup); + } + if (component instanceof DRIMultiPageList) { + return this.multiPageList((DRIMultiPageList) component); + } + if (component instanceof DRIFiller) { + return this.filler((DRIFiller) component); + } + if (component instanceof DRIImage) { + return this.image((DRIImage) component); + } + if (component instanceof DRISubreport) { + return this.subreport((DRISubreport) component); + } + if (component instanceof DRIPageXofY) { + return this.pageXofY((DRIPageXofY) component, defaultStyleType); + } + if (component instanceof DRITotalPages) { + return this.totalPages((DRITotalPages) component, defaultStyleType); + } + if (component instanceof DRIPageNumber) { + return this.pageNumber((DRIPageNumber) component, defaultStyleType); + } + if (component instanceof DRICurrentDate) { + return this.currentDate((DRICurrentDate) component, defaultStyleType); + } + if (component instanceof DRILine) { + return this.line((DRILine) component); + } + if (component instanceof DRIEllipse) { + return this.ellipse((DRIEllipse) component); + } + if (component instanceof DRIRectangle) { + return this.rectangle((DRIRectangle) component); + } + if (component instanceof DRIBooleanField) { + return this.booleanField((DRIBooleanField) component, defaultStyleType, resetType, resetGroup); + } + if (component instanceof DRIBreak) { + return this.breakComponent((DRIBreak) component); + } + if (component instanceof DRIGenericElement) { + return this.genericElement((DRIGenericElement) component, resetType, resetGroup); + } + if (component instanceof DRICrosstab) { + return this.crosstab((DRICrosstab) component, resetType, resetGroup); + } + if (component instanceof DRIMap) { + return this.map((DRIMap) component, resetType, resetGroup); + } + if (component instanceof DRICustomComponent) { + return this.customComponent((DRICustomComponent) component, resetType, resetGroup); + } + throw new DRDesignReportException("Component " + component.getClass().getName() + " not supported"); + } + + private void component(final DRDesignComponent designComponent, final DRIComponent component, final DRIReportStyle style, final boolean textStyle, final DefaultStyleType defaultStyleType) throws DRException { + designComponent.setStyle(this.accessor.getStyleTransform().transformStyle(style, textStyle, defaultStyleType)); + designComponent.setPrintWhenExpression(this.accessor.getExpressionTransform().transformExpression(component.getPrintWhenExpression())); + designComponent.setRemoveLineWhenBlank(this.accessor.getTemplateTransform().getRemoveLineWhenBlank(component)); + designComponent.setPositionType(this.accessor.getTemplateTransform().getPositionType(component)); + designComponent.setStretchType(this.accessor.getTemplateTransform().getStretchType(component)); + designComponent.setPrintInFirstWholeBand(this.accessor.getTemplateTransform().getPrintInFirstWholeBand(component)); + designComponent.setPrintWhenDetailOverflows(this.accessor.getTemplateTransform().getPrintWhenDetailOverflows(component)); + designComponent.setPrintWhenGroupChanges(this.accessor.getTemplateTransform().getPrintWhenGroupChanges(component)); + for (final DRIPropertyExpression propertyExpression : component.getPropertyExpressions()) { + designComponent.getPropertyExpressions().add(this.accessor.getExpressionTransform().transformPropertyExpression(propertyExpression)); + } + final DRDesignTableOfContentsHeading designTocHeading = + this.accessor.getTableOfContentsTransform().componentHeading(component); + if (designTocHeading != null) { + designComponent.setTableOfContentsHeading(designTocHeading); + final DRIDesignExpression anchorNameExpression = designTocHeading.getReferenceField().getAnchorNameExpression(); + final Integer bookmarkLevel = designTocHeading.getReferenceField().getBookmarkLevel(); + final DRDesignHyperLink designHyperLink = designTocHeading.getReferenceField().getHyperLink(); + if (designComponent instanceof DRDesignHyperlinkComponent) { + ((DRDesignHyperlinkComponent) designComponent).setAnchorNameExpression(anchorNameExpression); + ((DRDesignHyperlinkComponent) designComponent).setBookmarkLevel(bookmarkLevel); + ((DRDesignHyperlinkComponent) designComponent).setHyperLink(designHyperLink); + } + } + } + + private void hyperlink(final DRDesignHyperlinkComponent designHyperlinkComponent, final DRIHyperLinkComponent hyperlinkComponent, final DRIReportStyle style, final boolean textStyle, final DefaultStyleType defaultStyleType) + throws DRException { + this.component(designHyperlinkComponent, hyperlinkComponent, style, textStyle, defaultStyleType); + + if (hyperlinkComponent.getAnchorNameExpression() != null) { + designHyperlinkComponent.setAnchorNameExpression(this.accessor.getExpressionTransform().transformExpression(hyperlinkComponent.getAnchorNameExpression())); + } + if (hyperlinkComponent.getBookmarkLevel() != null) { + designHyperlinkComponent.setBookmarkLevel(hyperlinkComponent.getBookmarkLevel()); + } + + final DRIHyperLink hyperLink = hyperlinkComponent.getHyperLink(); + final DRDesignHyperLink designHyperLink = this.accessor.getReportTransform().hyperlink(hyperLink); + if (designHyperLink != null) { + designHyperlinkComponent.setHyperLink(designHyperLink); + } + } + + // list + + /** + *

list.

+ * + * @param list a {@link software.xdev.dynamicreports.report.definition.component.DRIList} object. + * @param defaultStyleType a {@link software.xdev.dynamicreports.design.constant.DefaultStyleType} object. + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignList} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignList list(final DRIList list, final DefaultStyleType defaultStyleType, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final DRDesignList designList = new DRDesignList(); + this.component(designList, list, list.getStyle(), false, DefaultStyleType.NONE); + designList.setType(list.getType()); + designList.setGap(this.accessor.getTemplateTransform().getListGap(list)); + designList.setWidth(this.accessor.getTemplateTransform().getListWidth(list)); + designList.setHeight(this.accessor.getTemplateTransform().getListHeight(list)); + designList.setCalculateComponents(designList.getWidth() == null && designList.getHeight() == null); + for (final DRIListCell innerComponent : list.getListCells()) { + final DRIComponent component = innerComponent.getComponent(); + HorizontalCellComponentAlignment horizontalAlignment = innerComponent.getHorizontalAlignment(); + VerticalCellComponentAlignment verticalAlignment = innerComponent.getVerticalAlignment(); + if (component instanceof DRIDimensionComponent) { + final DRIDimensionComponent dimComponent = (DRIDimensionComponent) component; + if (horizontalAlignment == null) { + horizontalAlignment = ConstantTransform.toHorizontalCellComponentAlignment(dimComponent.getWidthType()); + } + if (verticalAlignment == null) { + verticalAlignment = ConstantTransform.toVerticalCellComponentAlignment(dimComponent.getHeightType()); + } + } + designList.addComponent(horizontalAlignment, verticalAlignment, + this.component(component, defaultStyleType, resetType, resetGroup)); + } + designList.setBackgroundComponent(this.listBackgroundComponent(list.getBackgroundComponent(), defaultStyleType, resetType, resetGroup)); + + return designList; + } + + /** + *

xyList.

+ * + * @param xyList a {@link software.xdev.dynamicreports.report.definition.component.DRIXyList} object. + * @param defaultStyleType a {@link software.xdev.dynamicreports.design.constant.DefaultStyleType} object. + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignList} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignList xyList(final DRIXyList xyList, final DefaultStyleType defaultStyleType, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final DRDesignList designList = new DRDesignList(null); + this.component(designList, xyList, xyList.getStyle(), false, DefaultStyleType.NONE); + designList.setWidth(this.accessor.getTemplateTransform().getXyListWidth(xyList)); + designList.setHeight(this.accessor.getTemplateTransform().getXyListHeight(xyList)); + designList.setCalculateComponents(designList.getWidth() == null && designList.getHeight() == null); + designList.setRemovable(true); + for (final DRIXyListCell innerComponent : xyList.getXyListCells()) { + final DRDesignComponent designComponent = + this.component(innerComponent.getComponent(), defaultStyleType, resetType, resetGroup); + designComponent.setX(innerComponent.getX()); + designComponent.setY(innerComponent.getY()); + designList.addComponent(HorizontalCellComponentAlignment.LEFT, VerticalCellComponentAlignment.TOP, designComponent); + } + + return designList; + } + + /** + *

listBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + * @param defaultStyleType a {@link software.xdev.dynamicreports.design.constant.DefaultStyleType} object. + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignComponent listBackgroundComponent(final DRIComponent backgroundComponent, final DefaultStyleType defaultStyleType, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + if (backgroundComponent != null) { + if (backgroundComponent instanceof DRIRectangle || backgroundComponent instanceof DRIImage || backgroundComponent instanceof DRITextField) { + return this.component(backgroundComponent, defaultStyleType, resetType, resetGroup); + } else { + throw new DRDesignReportException("List background component not supported. Only rectangle, image and textfield are supported"); + } + } + return null; + } + + // multi page list + private DRDesignSubreport multiPageList(final DRIMultiPageList multiPageList) throws DRException { + final DRDesignSubreport designSubreport = new DRDesignSubreport(); + this.component(designSubreport, multiPageList, multiPageList.getStyle(), false, DefaultStyleType.NONE); + designSubreport.setWidth(this.accessor.getTemplateTransform().getMultiPageListWidth(multiPageList)); + designSubreport.setHeight(this.accessor.getTemplateTransform().getMultiPageListHeight(multiPageList)); + final JasperReportBuilder multiPageReport = DynamicReports.report(); + final MultiPageListSubreportExpression subreportExpression = + new MultiPageListSubreportExpression( + this.accessor.getLocale(), + this.accessor.getResourceBundle(), + this.accessor.getResourceBundleName(), + this.accessor.getWhenResourceMissingType(), + multiPageList.getComponents(), + this.accessor.getTemplateTransform().getTemplateStyles()); + multiPageReport.detail(Components.subreport(subreportExpression)); + multiPageReport.setDetailSplitType(multiPageList.getSplitType()); + final DRIDesignExpression reportExpression = + this.accessor.getExpressionTransform().transformExpression(Expressions.value(multiPageReport)); + final DRIDesignExpression dataSourceExpression = this.accessor.getExpressionTransform().transformExpression(new MultiPageListDataSourceExpression(multiPageList.getComponents().size())); + designSubreport.setReportExpression(reportExpression); + designSubreport.setDataSourceExpression(dataSourceExpression); + return designSubreport; + } + + // text field + + /** + *

textField.

+ * + * @param textField a {@link software.xdev.dynamicreports.report.definition.component.DRITextField} object. + * @param defaultStyleType a {@link software.xdev.dynamicreports.design.constant.DefaultStyleType} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignTextField} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignTextField textField(final DRITextField textField, final DefaultStyleType defaultStyleType) throws DRException { + final DRDesignTextField designTextField = new DRDesignTextField(); + this.hyperlink(designTextField, textField, textField.getStyle(), true, defaultStyleType); + final TemplateTransform templateTransform = this.accessor.getTemplateTransform(); + designTextField.setPrintRepeatedValues(templateTransform.isTextFieldPrintRepeatedValues(textField)); + designTextField.setStretchWithOverflow(templateTransform.getTextFieldStretchWithOverflow(textField)); + designTextField.setTextAdjust(templateTransform.getTextFieldTextAdjust(textField)); + final DRDesignStyle style = designTextField.getStyle(); + designTextField.setWidth(templateTransform.getTextFieldWidth(textField, style)); + designTextField.setHeight(templateTransform.getTextFieldHeight(textField, style)); + designTextField.setPattern(templateTransform.getTextFieldPattern(textField, style)); + designTextField.setPatternExpression(this.accessor.getExpressionTransform().transformExpression(textField.getPatternExpression())); + designTextField.setHorizontalTextAlignment(templateTransform.getTextFieldHorizontalTextAlignment(textField, style)); + designTextField.setValueExpression(this.accessor.getExpressionTransform().transformExpression(textField.getValueExpression(), templateTransform.getTextFieldValueFormatter(textField), null)); + designTextField.setMarkup(textField.getMarkup()); + if (textField.getEvaluationTime() != null) { + designTextField.setEvaluationTime(ConstantTransform.textFieldEvaluationTime(textField.getEvaluationTime(), textField.getEvaluationGroup(), + this.accessor)); + designTextField.setEvaluationGroup( + this.accessor.getGroupTransform().getGroup(ConstantTransform.textFieldEvaluationGroup(textField.getEvaluationTime(), textField.getEvaluationGroup(), + this.accessor))); + } else { + if (textField.getEvaluationGroup() != null) { + throw new DRException("Evaluation group for textField is required only for evaluation time BEFORE_GROUP or GROUP"); + } + final EvaluationTime evaluationTime = this.detectEvaluationTime(designTextField.getValueExpression()); + designTextField.setEvaluationTime(evaluationTime); + designTextField.setEvaluationGroup(this.detectEvaluationGroup(evaluationTime, designTextField.getValueExpression())); + } + return designTextField; + } + + // filler + + /** + *

filler.

+ * + * @param filler a {@link software.xdev.dynamicreports.report.definition.component.DRIFiller} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignFiller} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignFiller filler(final DRIFiller filler) throws DRException { + final DRDesignFiller designFiller = new DRDesignFiller(); + this.component(designFiller, filler, filler.getStyle(), false, DefaultStyleType.NONE); + designFiller.setWidth(this.accessor.getTemplateTransform().getFillerWidth(filler)); + designFiller.setHeight(this.accessor.getTemplateTransform().getFillerHeight(filler)); + return designFiller; + } + + // image + private DRDesignImage image(final DRIImage image) throws DRException { + return this.image(image, null, DefaultStyleType.IMAGE); + } + + private DRDesignImage image(final DRIImage image, final Integer imageHeight, final DefaultStyleType defaultStyleType) throws DRException { + final DRDesignImage designImage = new DRDesignImage(); + this.hyperlink(designImage, image, image.getStyle(), false, defaultStyleType); + designImage.setImageScale(image.getImageScale()); + designImage.setImageExpression(this.accessor.getExpressionTransform().transformExpression(image.getImageExpression())); + designImage.setUsingCache(image.getUsingCache()); + designImage.setLazy(image.getLazy()); + designImage.setHorizontalImageAlignment(image.getHorizontalImageAlignment()); + designImage.setWidth(this.accessor.getTemplateTransform().getImageWidth(image)); + final DRDesignStyle style = designImage.getStyle(); + designImage.setHeight(this.accessor.getTemplateTransform().getImageHeight(image, imageHeight, style)); + return designImage; + } + + + // subreport + private DRDesignSubreport subreport(final DRISubreport subreport) throws DRException { + final DRDesignSubreport designSubreport = new DRDesignSubreport(); + this.component(designSubreport, subreport, subreport.getStyle(), false, DefaultStyleType.NONE); + designSubreport.setWidth(this.accessor.getTemplateTransform().getSubreportWidth(subreport)); + designSubreport.setHeight(this.accessor.getTemplateTransform().getSubreportHeight(subreport)); + designSubreport.setReportExpression(this.accessor.getExpressionTransform().transformExpression(subreport.getReportExpression())); + designSubreport.setParametersExpression(this.accessor.getExpressionTransform().transformExpression(subreport.getParametersExpression())); + designSubreport.setConnectionExpression(this.accessor.getExpressionTransform().transformExpression(subreport.getConnectionExpression())); + designSubreport.setDataSourceExpression(this.accessor.getExpressionTransform().transformExpression(subreport.getDataSourceExpression())); + designSubreport.setRunToBottom(subreport.getRunToBottom()); + return designSubreport; + } + + // page x of y + private DRDesignList pageXofY(final DRIPageXofY pageXofY, final DefaultStyleType defaultStyleType) throws DRException { + final TemplateTransform templateTransform = this.accessor.getTemplateTransform(); + DRIReportStyle pageXofYStyle = pageXofY.getStyle(); + if (pageXofYStyle == null) { + pageXofYStyle = this.accessor.getTemplateTransform().getTextStyle(); + } + final DRDesignStyle style = + this.accessor.getStyleTransform().transformStyle(pageXofYStyle, true, defaultStyleType); + final Integer height = templateTransform.getPageXofYHeight(pageXofY, style); + final HorizontalTextAlignment horizontalTextAlignment = templateTransform.getPageXofYHorizontalTextAlignment(pageXofY, style); + + final DRStyle newStylePageX = new DRStyle(); + newStylePageX.setParentStyle(pageXofYStyle); + newStylePageX.getPadding().setRight(0); + final DRPen pen = new DRPen(); + pen.setLineWidth(0f); + newStylePageX.getBorder().setRightPen(pen); + final DRStyle newStylePageY = new DRStyle(); + newStylePageY.setParentStyle(pageXofYStyle); + newStylePageY.getPadding().setLeft(0); + newStylePageY.getBorder().setLeftPen(pen); + + final DRTextField pageXField = new DRTextField<>(); + pageXField.setAnchorNameExpression(pageXofY.getAnchorNameExpression()); + pageXField.setBookmarkLevel(pageXofY.getBookmarkLevel()); + pageXField.setHyperLink((DRHyperLink) pageXofY.getHyperLink()); + pageXField.setPrintWhenExpression(pageXofY.getPrintWhenExpression()); + pageXField.setStyle(newStylePageX); + pageXField.setHeight(height); + pageXField.setHeightType(pageXofY.getHeightType()); + pageXField.setHorizontalTextAlignment(HorizontalTextAlignment.RIGHT); + pageXField.setValueExpression(new PageXofYNumberExpression(pageXofY.getFormatExpression(), 0)); + + final DRTextField pageYField = new DRTextField<>(); + pageYField.setAnchorNameExpression(pageXofY.getAnchorNameExpression()); + pageYField.setBookmarkLevel(pageXofY.getBookmarkLevel()); + pageYField.setHyperLink((DRHyperLink) pageXofY.getHyperLink()); + pageYField.setPrintWhenExpression(pageXofY.getPrintWhenExpression()); + pageYField.setStyle(newStylePageY); + pageYField.setHeight(height); + pageYField.setHeightType(pageXofY.getHeightType()); + pageYField.setHorizontalTextAlignment(HorizontalTextAlignment.LEFT); + pageYField.setValueExpression(new PageXofYNumberExpression(pageXofY.getFormatExpression(), 1)); + final DRIGroup pageYEvaluationGroup = this.accessor.getGroupTransform().getFirstResetPageNumberGroup(); + if (pageYEvaluationGroup == null) { + pageYField.setEvaluationTime(Evaluation.REPORT); + } else { + pageYField.setEvaluationTime(Evaluation.GROUP); + pageYField.setEvaluationGroup((DRGroup) pageYEvaluationGroup); + } + + final int pageXofYWidth = templateTransform.getPageXofYWidth(pageXofY); + switch (horizontalTextAlignment) { + case LEFT: + int pageXWidth = StyleResolver.getFontWidth(style, 4); + int pageYWidth = pageXofYWidth - pageXWidth; + if (pageYWidth <= 0) { + pageYWidth = 10; + } + pageXField.setWidth(pageXWidth); + pageXField.setWidthType(ComponentDimensionType.FIXED); + pageYField.setWidth(pageYWidth); + pageYField.setWidthType(pageXofY.getWidthType()); + break; + case RIGHT: + pageYWidth = StyleResolver.getFontWidth(style, 6); + pageXWidth = pageXofYWidth - pageYWidth; + if (pageXWidth <= 0) { + pageXWidth = 10; + } + pageXField.setWidth(pageXWidth); + pageXField.setWidthType(pageXofY.getWidthType()); + pageYField.setWidth(pageYWidth); + pageYField.setWidthType(ComponentDimensionType.FIXED); + break; + default: + pageXField.setWidth(pageXofYWidth / 2); + pageXField.setWidthType(pageXofY.getWidthType()); + pageYField.setWidth(pageXofYWidth / 2); + pageYField.setWidthType(pageXofY.getWidthType()); + break; + } + + if (pageXofY.getPageXWidth() != null) { + pageXField.setWidth(pageXofY.getPageXWidth()); + } + if (pageXofY.getPageXWidthType() != null) { + pageXField.setWidthType(pageXofY.getPageXWidthType()); + } + if (pageXofY.getPageYWidth() != null) { + pageYField.setWidth(pageXofY.getPageYWidth()); + } + if (pageXofY.getPageYWidthType() != null) { + pageYField.setWidthType(pageXofY.getPageYWidthType()); + } + + final DRList listPageXofY = new DRList(); + listPageXofY.addComponent(pageXField); + listPageXofY.addComponent(pageYField); + return this.list(listPageXofY, DefaultStyleType.TEXT, null, null); + } + + // total pages + private DRDesignTextField totalPages(final DRITotalPages totalPages, final DefaultStyleType defaultStyleType) throws DRException { + final PageNumberExpression expression = new PageNumberExpression(totalPages.getFormatExpression()); + final DRTextField totalPagesField = this.formatField(totalPages, expression); + final DRIGroup pageEvaluationGroup = this.accessor.getGroupTransform().getFirstResetPageNumberGroup(); + if (pageEvaluationGroup == null) { + totalPagesField.setEvaluationTime(Evaluation.REPORT); + } else { + totalPagesField.setEvaluationTime(Evaluation.GROUP); + totalPagesField.setEvaluationGroup((DRGroup) pageEvaluationGroup); + } + + return this.textField(totalPagesField, defaultStyleType); + } + + // page number + private DRDesignTextField pageNumber(final DRIPageNumber pageNumber, final DefaultStyleType defaultStyleType) throws DRException { + final PageNumberExpression expression = new PageNumberExpression(pageNumber.getFormatExpression()); + return this.textField(this.formatField(pageNumber, expression), defaultStyleType); + } + + // current date + private DRDesignTextField currentDate(final DRICurrentDate currentDate, final DefaultStyleType defaultStyleType) throws DRException { + final CurrentDateExpression expression = new CurrentDateExpression(currentDate.getFormatExpression(), currentDate.getPattern()); + return this.textField(this.formatField(currentDate, expression), defaultStyleType); + } + + // format field + private DRTextField formatField(final DRIFormatField formatField, final DRIExpression expression) throws DRException { + final DRTextField formatFieldTextField = new DRTextField<>(); + formatFieldTextField.setAnchorNameExpression(formatField.getAnchorNameExpression()); + formatFieldTextField.setBookmarkLevel(formatField.getBookmarkLevel()); + formatFieldTextField.setHyperLink((DRHyperLink) formatField.getHyperLink()); + formatFieldTextField.setPrintWhenExpression(formatField.getPrintWhenExpression()); + formatFieldTextField.setStyle(formatField.getStyle()); + formatFieldTextField.setWidth(formatField.getWidth()); + formatFieldTextField.setWidthType(formatField.getWidthType()); + formatFieldTextField.setHeight(formatField.getHeight()); + formatFieldTextField.setHeightType(formatField.getHeightType()); + formatFieldTextField.setHorizontalTextAlignment(formatField.getHorizontalTextAlignment()); + formatFieldTextField.setValueExpression(expression); + return formatFieldTextField; + } + + // line + + /** + *

line.

+ * + * @param line a {@link software.xdev.dynamicreports.report.definition.component.DRILine} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignLine} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignLine line(final DRILine line) throws DRException { + final DRDesignLine designLine = new DRDesignLine(); + this.component(designLine, line, line.getStyle(), false, DefaultStyleType.NONE); + designLine.setDirection(line.getDirection()); + designLine.setPen(this.accessor.getStyleTransform().pen(line.getPen())); + designLine.setWidth(this.accessor.getTemplateTransform().getLineWidth(line)); + designLine.setHeight(this.accessor.getTemplateTransform().getLineHeight(line)); + return designLine; + } + + // ellipse + + /** + *

ellipse.

+ * + * @param ellipse a {@link software.xdev.dynamicreports.report.definition.component.DRIEllipse} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignEllipse} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignEllipse ellipse(final DRIEllipse ellipse) throws DRException { + final DRDesignEllipse designEllipse = new DRDesignEllipse(); + this.component(designEllipse, ellipse, ellipse.getStyle(), false, DefaultStyleType.NONE); + designEllipse.setPen(this.accessor.getStyleTransform().pen(ellipse.getPen())); + designEllipse.setWidth(this.accessor.getTemplateTransform().getEllipseWidth(ellipse)); + designEllipse.setHeight(this.accessor.getTemplateTransform().getEllipseHeight(ellipse)); + return designEllipse; + } + + // rectangle + + /** + *

rectangle.

+ * + * @param rectangle a {@link software.xdev.dynamicreports.report.definition.component.DRIRectangle} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignRectangle} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignRectangle rectangle(final DRIRectangle rectangle) throws DRException { + final DRDesignRectangle designRectangle = new DRDesignRectangle(); + this.component(designRectangle, rectangle, rectangle.getStyle(), false, DefaultStyleType.NONE); + designRectangle.setRadius(this.accessor.getTemplateTransform().getRectangleRadius(rectangle)); + designRectangle.setPen(this.accessor.getStyleTransform().pen(rectangle.getPen())); + designRectangle.setWidth(this.accessor.getTemplateTransform().getRectangleWidth(rectangle)); + designRectangle.setHeight(this.accessor.getTemplateTransform().getRectangleHeight(rectangle)); + return designRectangle; + } + + // boolean + + /** + *

booleanField.

+ * + * @param booleanField a {@link software.xdev.dynamicreports.report.definition.component.DRIBooleanField} object. + * @param defaultStyleType a {@link software.xdev.dynamicreports.design.constant.DefaultStyleType} object. + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignComponent} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignComponent booleanField(final DRIBooleanField booleanField, final DefaultStyleType defaultStyleType, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final BooleanComponentType componentType = + this.accessor.getTemplateTransform().getBooleanComponentType(booleanField); + final boolean emptyWhenNullValue = + this.accessor.getTemplateTransform().getBooleanEmptyWhenNullValue(booleanField); + + DRHyperLinkComponent component = null; + + switch (componentType) { + case TEXT_TRUE_FALSE: + case TEXT_YES_NO: + final String keyTrue; + final String keyFalse; + if (componentType.equals(BooleanComponentType.TEXT_TRUE_FALSE)) { + keyTrue = "true"; + keyFalse = "false"; + } else { + keyTrue = "yes"; + keyFalse = "no"; + } + final DRTextField textField = new DRTextField<>(); + textField.setValueExpression(booleanField.getValueExpression()); + textField.setDataType(DataTypes.booleanType()); + textField.setHorizontalTextAlignment(booleanField.getHorizontalTextAlignment()); + textField.setValueFormatter(new BooleanTextValueFormatter(keyTrue, keyFalse, emptyWhenNullValue)); + component = textField; + break; + default: + throw new DRDesignReportException("Boolean component type " + componentType.name() + " not supported"); + } + + component.setWidth(booleanField.getWidth()); + component.setWidthType(booleanField.getWidthType()); + component.setHeight(booleanField.getHeight()); + component.setHeightType(booleanField.getHeightType()); + component.setAnchorNameExpression(booleanField.getAnchorNameExpression()); + component.setBookmarkLevel(booleanField.getBookmarkLevel()); + component.setHyperLink((DRHyperLink) booleanField.getHyperLink()); + component.setStyle(booleanField.getStyle()); + component.setPrintWhenExpression(booleanField.getPrintWhenExpression()); + component.setPropertyExpressions(booleanField.getPropertyExpressions()); + + final DRDesignComponent designComponent; + if (component instanceof DRIImage) { + final int imageHeight = this.accessor.getTemplateTransform().getBooleanImageHeight(booleanField); + designComponent = this.image((DRIImage) component, imageHeight, defaultStyleType); + final TemplateTransform templateTransform = this.accessor.getTemplateTransform(); + ((DRDesignImage) designComponent).setHorizontalImageAlignment(templateTransform.getBooleanHorizontalImageAlignment(booleanField, designComponent.getStyle())); + } else { + designComponent = this.component(component, defaultStyleType, resetType, resetGroup); + } + return designComponent; + } + + // break + + /** + *

breakComponent.

+ * + * @param breakComponent a {@link software.xdev.dynamicreports.report.definition.component.DRIBreak} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignBreak} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignBreak breakComponent(final DRIBreak breakComponent) throws DRException { + final DRDesignBreak designBreak = new DRDesignBreak(); + this.component(designBreak, breakComponent, null, false, DefaultStyleType.NONE); + designBreak.setType(breakComponent.getType()); + designBreak.setWidth(this.accessor.getTemplateTransform().getBreakWidth(breakComponent)); + designBreak.setHeight(this.accessor.getTemplateTransform().getBreakHeight(breakComponent)); + return designBreak; + } + + // generic element + + /** + *

genericElement.

+ * + * @param genericElement a {@link software.xdev.dynamicreports.report.definition.component.DRIGenericElement} object. + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + * @return a {@link software.xdev.dynamicreports.design.base.component.DRDesignGenericElement} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignGenericElement genericElement(final DRIGenericElement genericElement, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final DRDesignGenericElement designGenericElement = new DRDesignGenericElement(); + this.component(designGenericElement, genericElement, genericElement.getStyle(), false, DefaultStyleType.NONE); + designGenericElement.setGenericElementNamespace(genericElement.getGenericElementNamespace()); + designGenericElement.setGenericElementName(genericElement.getGenericElementName()); + designGenericElement.setEvaluationTime(this.evaluationTimeFromResetType(resetType)); + designGenericElement.setEvaluationGroup(resetGroup); + designGenericElement.setWidth(this.accessor.getTemplateTransform().getGenericElementWidth(genericElement)); + designGenericElement.setHeight(this.accessor.getTemplateTransform().getGenericElementHeight(genericElement)); + for (final DRIParameterExpression parameterExpression : genericElement.getParameterExpressions()) { + designGenericElement.getParameterExpressions().add(this.accessor.getExpressionTransform().transformParameterExpression(parameterExpression)); + } + return designGenericElement; + } + + // crosstab + private DRDesignCrosstab crosstab(final DRICrosstab crosstab, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final DRDesignCrosstab designCrosstab = + this.accessor.getCrosstabTransform().transform(crosstab, resetType, resetGroup); + this.component(designCrosstab, crosstab, crosstab.getStyle(), false, DefaultStyleType.NONE); + return designCrosstab; + } + + // map + private DRDesignMap map(final DRIMap map, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final DRDesignMap designMap = new DRDesignMap(); + this.component(designMap, map, map.getStyle(), false, DefaultStyleType.NONE); + designMap.setLatitudeExpression(this.accessor.getExpressionTransform().transformExpression(map.getLatitudeExpression())); + designMap.setLongitudeExpression(this.accessor.getExpressionTransform().transformExpression(map.getLongitudeExpression())); + designMap.setZoomExpression(this.accessor.getExpressionTransform().transformExpression(map.getZoomExpression())); + designMap.setWidth(this.accessor.getTemplateTransform().getMapWidth(map)); + designMap.setHeight(this.accessor.getTemplateTransform().getMapHeight(map)); + designMap.setEvaluationTime(this.evaluationTimeFromResetType(resetType)); + designMap.setEvaluationGroup(resetGroup); + return designMap; + } + + // custom component + private DRDesignComponent customComponent(final DRICustomComponent component, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + @SuppressWarnings("rawtypes") final CustomComponentTransform componentTransfom = CustomComponents.getComponentTransform(component); + if (componentTransfom == null) { + throw new DRDesignReportException("Component " + component.getClass().getName() + " not supported"); + } + @SuppressWarnings("unchecked") final DRDesignComponent designComponent = (DRDesignComponent) componentTransfom.designComponent( + this.accessor, component, resetType, resetGroup); + this.component(designComponent, component, component.getStyle(), false, DefaultStyleType.NONE); + final DRIDimensionComponent dimensionComponent = component; + if (designComponent.getWidth() == null) { + designComponent.setWidth(this.accessor.getTemplateTransform().getCustomComponentWidth(dimensionComponent)); + } + if (designComponent.getHeight() == null) { + designComponent.setHeight(this.accessor.getTemplateTransform().getCustomComponentHeight(dimensionComponent)); + } + return designComponent; + } + + /** + *

detectEvaluationTime.

+ * + * @param expression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + * @return a {@link software.xdev.dynamicreports.design.constant.EvaluationTime} object. + */ + protected EvaluationTime detectEvaluationTime(final DRIDesignExpression expression) { + if (expression == null) { + return null; + } + + if (expression instanceof DRIDesignField || expression instanceof DRIDesignSystemExpression || expression instanceof DRIDesignSimpleExpression || + expression instanceof DRIDesignJasperExpression) { + return EvaluationTime.NOW; + } + if (expression instanceof DRIDesignVariable) { + return this.evaluationTimeFromResetType(((DRIDesignVariable) expression).getResetType()); + } + if (expression instanceof DRIDesignComplexExpression) { + return this.detectComplexExpressionEvaluationTime((DRIDesignComplexExpression) expression); + } + throw new DRDesignReportException("Expression " + expression.getClass().getName() + " not supported"); + } + + /** + *

evaluationTimeFromResetType.

+ * + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @return a {@link software.xdev.dynamicreports.design.constant.EvaluationTime} object. + */ + public EvaluationTime evaluationTimeFromResetType(final ResetType resetType) { + if (resetType == null) { + return null; + } + + switch (resetType) { + case NONE: + return EvaluationTime.NOW; + case REPORT: + return EvaluationTime.REPORT; + case PAGE: + return EvaluationTime.PAGE; + case COLUMN: + return EvaluationTime.COLUMN; + case GROUP: + return EvaluationTime.GROUP; + default: + throw new DRDesignReportException("Reset type " + resetType.name() + " not supported"); + } + } + + private EvaluationTime detectComplexExpressionEvaluationTime(final DRIDesignComplexExpression complexExpression) { + EvaluationTime evaluationTime = null; + for (final DRIDesignExpression expression : complexExpression.getExpressions()) { + final EvaluationTime evalTime = this.detectEvaluationTime(expression); + if (evaluationTime == null) { + evaluationTime = evalTime; + } else if (evaluationTime != evalTime || evaluationTime.equals(EvaluationTime.GROUP) && evalTime.equals(EvaluationTime.GROUP)) { + return EvaluationTime.AUTO; + } + } + return evaluationTime; + } + + private DRDesignGroup detectEvaluationGroup(final EvaluationTime evaluationTime, final DRIDesignExpression expression) { + if (expression != null && evaluationTime != null && evaluationTime.equals(EvaluationTime.GROUP)) { + final DRDesignGroup evaluationGroup = this.detectEvaluationGroup(expression); + if (evaluationGroup == null) { + throw new DRDesignReportException("Can not detect evaluation group"); + } + return evaluationGroup; + } + return null; + } + + private DRDesignGroup detectEvaluationGroup(final DRIDesignExpression expression) { + if (expression instanceof DRIDesignField || expression instanceof DRIDesignSimpleExpression) { + return null; + } + if (expression instanceof DRDesignVariable) { + return ((DRDesignVariable) expression).getResetGroup(); + } + if (expression instanceof DRIDesignComplexExpression) { + return this.detectComplexExpressionEvaluationGroup((DRIDesignComplexExpression) expression); + } + throw new DRDesignReportException("Expression " + expression.getClass().getName() + " not supported"); + } + + private DRDesignGroup detectComplexExpressionEvaluationGroup(final DRIDesignComplexExpression complexExpression) { + DRDesignGroup evaluationGroup = null; + for (final DRIDesignExpression expression : complexExpression.getExpressions()) { + final DRDesignGroup group = this.detectEvaluationGroup(expression); + if (evaluationGroup == null) { + evaluationGroup = group; + } else if (evaluationGroup != group) { + throw new DRDesignReportException("Can not detect evaluation group"); + } + } + return evaluationGroup; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ConstantTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ConstantTransform.java new file mode 100644 index 0000000..80118ee --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ConstantTransform.java @@ -0,0 +1,264 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.constant.EvaluationTime; +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import software.xdev.dynamicreports.report.definition.DRIGroup; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + * @author Ricardo Mariaca + */ +class ConstantTransform { + + /** + *

variableResetType.

+ * + * @param resetType a {@link software.xdev.dynamicreports.report.constant.Evaluation} object. + * @param resetGroup a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + * @return a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + */ + public static ResetType variableResetType(Evaluation resetType, DRIGroup resetGroup, DesignTransformAccessor accessor) { + if (resetType == null) { + return ResetType.REPORT; + } + + switch (resetType) { + case NONE: + return ResetType.NONE; + case REPORT: + return ResetType.REPORT; + case PAGE: + return ResetType.PAGE; + case COLUMN: + return ResetType.COLUMN; + case FIRST_GROUP: + if (accessor.getGroupTransform().getFirstGroup() == null) { + return ResetType.REPORT; + } + return ResetType.GROUP; + case BEFORE_GROUP: + if (accessor.getGroupTransform().getBeforeGroup(resetGroup) == null) { + return ResetType.REPORT; + } + return ResetType.GROUP; + case LAST_GROUP: + if (accessor.getGroupTransform().getLastGroup() == null) { + return ResetType.REPORT; + } + return ResetType.GROUP; + case GROUP: + return ResetType.GROUP; + default: + throw new DRDesignReportException("Reset type " + resetType.name() + " not supported"); + } + } + + /** + *

variableResetGroup.

+ * + * @param name a {@link java.lang.String} object. + * @param resetType a {@link software.xdev.dynamicreports.report.constant.Evaluation} object. + * @param resetGroup a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + * @return a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public static DRIGroup variableResetGroup(String name, Evaluation resetType, DRIGroup resetGroup, DesignTransformAccessor accessor) throws DRException { + if (resetType == null) { + return null; + } + + switch (resetType) { + case NONE: + case REPORT: + case PAGE: + case COLUMN: + if (resetGroup != null) { + throw new DRException("Reset group for variable " + name + " is required only for reset type BEFORE_GROUP or GROUP"); + } + return null; + case FIRST_GROUP: + if (resetGroup != null) { + throw new DRException("Reset group for variable " + name + " is required only for reset type BEFORE_GROUP or GROUP"); + } + return accessor.getGroupTransform().getFirstGroup(); + case BEFORE_GROUP: + if (resetGroup == null) { + throw new DRException("Reset group missing for variable " + name); + } + return accessor.getGroupTransform().getBeforeGroup(resetGroup); + case LAST_GROUP: + if (resetGroup != null) { + throw new DRException("Reset group for variable " + name + " is required only for reset type BEFORE_GROUP or GROUP"); + } + return accessor.getGroupTransform().getLastGroup(); + case GROUP: + if (resetGroup == null) { + throw new DRException("Reset group missing for variable " + name); + } + return resetGroup; + default: + throw new DRDesignReportException("Reset group " + resetType.name() + " not supported"); + } + } + + /** + *

textFieldEvaluationTime.

+ * + * @param evaluationTime a {@link software.xdev.dynamicreports.report.constant.Evaluation} object. + * @param evaluationGroup a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + * @return a {@link software.xdev.dynamicreports.design.constant.EvaluationTime} object. + */ + public static EvaluationTime textFieldEvaluationTime(Evaluation evaluationTime, DRIGroup evaluationGroup, DesignTransformAccessor accessor) { + if (evaluationTime == null) { + return EvaluationTime.NOW; + } + + switch (evaluationTime) { + case NONE: + return EvaluationTime.NOW; + case REPORT: + return EvaluationTime.REPORT; + case PAGE: + return EvaluationTime.PAGE; + case COLUMN: + return EvaluationTime.COLUMN; + case FIRST_GROUP: + if (accessor.getGroupTransform().getFirstGroup() == null) { + return EvaluationTime.REPORT; + } + return EvaluationTime.GROUP; + case BEFORE_GROUP: + if (accessor.getGroupTransform().getBeforeGroup(evaluationGroup) == null) { + return EvaluationTime.REPORT; + } + return EvaluationTime.GROUP; + case LAST_GROUP: + if (accessor.getGroupTransform().getLastGroup() == null) { + return EvaluationTime.REPORT; + } + return EvaluationTime.GROUP; + case GROUP: + return EvaluationTime.GROUP; + default: + throw new DRDesignReportException("Evaluation time " + evaluationTime.name() + " not supported"); + } + } + + /** + *

textFieldEvaluationGroup.

+ * + * @param evaluationTime a {@link software.xdev.dynamicreports.report.constant.Evaluation} object. + * @param evaluationGroup a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + * @return a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public static DRIGroup textFieldEvaluationGroup(Evaluation evaluationTime, DRIGroup evaluationGroup, DesignTransformAccessor accessor) throws DRException { + if (evaluationTime == null) { + return null; + } + + switch (evaluationTime) { + case NONE: + case REPORT: + case PAGE: + case COLUMN: + if (evaluationGroup != null) { + throw new DRException("Evaluation group for textField is required only for evaluation time BEFORE_GROUP or GROUP"); + } + return null; + case FIRST_GROUP: + if (evaluationGroup != null) { + throw new DRException("Evaluation group for textField is required only for evaluation time BEFORE_GROUP or GROUP"); + } + return accessor.getGroupTransform().getFirstGroup(); + case BEFORE_GROUP: + if (evaluationGroup == null) { + throw new DRException("Evaluation group missing for textField"); + } + return accessor.getGroupTransform().getBeforeGroup(evaluationGroup); + case LAST_GROUP: + if (evaluationGroup != null) { + throw new DRException("Evaluation group for textField is required only for evaluation time BEFORE_GROUP or GROUP"); + } + return accessor.getGroupTransform().getLastGroup(); + case GROUP: + if (evaluationGroup == null) { + throw new DRException("Evaluation group missing for textField"); + } + return evaluationGroup; + default: + throw new DRDesignReportException("Evaluation group " + evaluationTime.name() + " not supported"); + } + } + + /** + *

toHorizontalCellComponentAlignment.

+ * + * @param widthType a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + */ + public static HorizontalCellComponentAlignment toHorizontalCellComponentAlignment(ComponentDimensionType widthType) { + if (widthType == null) { + return null; + } + + switch (widthType) { + case FIXED: + return HorizontalCellComponentAlignment.LEFT; + case FLOAT: + return HorizontalCellComponentAlignment.FLOAT; + case EXPAND: + return HorizontalCellComponentAlignment.EXPAND; + default: + throw new DRDesignReportException("Component dimension type " + widthType.name() + " not supported"); + } + } + + /** + *

toVerticalCellComponentAlignment.

+ * + * @param heightType a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + * @return a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + */ + public static VerticalCellComponentAlignment toVerticalCellComponentAlignment(ComponentDimensionType heightType) { + if (heightType == null) { + return null; + } + + switch (heightType) { + case FIXED: + return VerticalCellComponentAlignment.TOP; + case FLOAT: + case EXPAND: + return VerticalCellComponentAlignment.EXPAND; + default: + throw new DRDesignReportException("Component dimension type " + heightType.name() + " not supported"); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/CrosstabTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/CrosstabTransform.java new file mode 100644 index 0000000..9399756 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/CrosstabTransform.java @@ -0,0 +1,665 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import java.awt.Color; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCell; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCellContent; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabColumnGroup; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabDataset; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabGroup; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabMeasure; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabRowGroup; +import software.xdev.dynamicreports.design.constant.DefaultStyleType; +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.transformation.expressions.CrosstabExpression; +import software.xdev.dynamicreports.design.transformation.expressions.CrosstabMeasureExpression; +import software.xdev.dynamicreports.design.transformation.expressions.CrosstabPrintInEvenRow; +import software.xdev.dynamicreports.design.transformation.expressions.CrosstabPrintInOddRow; +import software.xdev.dynamicreports.design.transformation.expressions.CrosstabRowCount; +import software.xdev.dynamicreports.design.transformation.expressions.CrosstabRowCounter; +import software.xdev.dynamicreports.report.base.DRHyperLink; +import software.xdev.dynamicreports.report.base.component.DRFiller; +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.base.crosstab.DRCrosstabCellContent; +import software.xdev.dynamicreports.report.base.crosstab.DRCrosstabCellStyle; +import software.xdev.dynamicreports.report.base.style.DRConditionalStyle; +import software.xdev.dynamicreports.report.base.style.DRStyle; +import software.xdev.dynamicreports.report.builder.expression.SystemMessageExpression; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; +import software.xdev.dynamicreports.report.constant.StretchType; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabCellContent; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabCellStyle; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabDataset; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabGroup; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabMeasure; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabVariable; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIJasperExpression; +import software.xdev.dynamicreports.report.definition.expression.DRISimpleExpression; +import software.xdev.dynamicreports.report.definition.style.DRIConditionalStyle; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.definition.style.DRISimpleStyle; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + *

CrosstabTransform class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class CrosstabTransform { + private final DesignTransformAccessor accessor; + private Map crosstabs; + private CrosstabRowCounter crosstabRowCounter; + + /** + *

Constructor for CrosstabTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public CrosstabTransform(final DesignTransformAccessor accessor) { + this.accessor = accessor; + init(); + } + + private void init() { + crosstabs = new HashMap<>(); + crosstabRowCounter = new CrosstabRowCounter(); + } + + /** + *

transform.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + * @return a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignCrosstab transform(final DRICrosstab crosstab, ResetType resetType, DRDesignGroup resetGroup) throws DRException { + final DRDesignCrosstab designCrosstab = new DRDesignCrosstab(); + designCrosstab.setDataset(dataset(crosstab.getDataset(), resetType, resetGroup)); + accessor.transformToDataset(crosstab.getDataset().getSubDataset()); + if (crosstab.getDataset() != null) { + resetType = null; + resetGroup = null; + } + final DRDesignCrosstabCellContent whenNoDataCell = cellContent(crosstab.getWhenNoDataCell(), resetType, resetGroup); + designCrosstab.setWidth(accessor.getTemplateTransform().getCrosstabWidth(crosstab)); + designCrosstab.setHeight(accessor.getTemplateTransform().getCrosstabHeight(crosstab, whenNoDataCell)); + designCrosstab.setRepeatColumnHeaders(crosstab.isRepeatColumnHeaders()); + designCrosstab.setRepeatRowHeaders(crosstab.isRepeatRowHeaders()); + designCrosstab.setColumnBreakOffset(crosstab.getColumnBreakOffset()); + designCrosstab.setIgnoreWidth(crosstab.getIgnoreWidth()); + designCrosstab.setRunDirection(crosstab.getRunDirection()); + designCrosstab.setWhenNoDataCell(whenNoDataCell); + designCrosstab.setHeaderCell(cellContent(crosstab.getHeaderCell(), resetType, resetGroup)); + for (final DRICrosstabColumnGroup columnGroup : crosstab.getColumnGroups()) { + addColumnGroup(crosstab, designCrosstab, columnGroup, resetType, resetGroup); + } + for (final DRICrosstabRowGroup rowGroup : crosstab.getRowGroups()) { + addRowGroup(crosstab, designCrosstab, rowGroup, resetType, resetGroup); + } + addCells(crosstab, designCrosstab, resetType, resetGroup); + for (final DRICrosstabVariable variable : crosstab.getVariables()) { + addMeasure(designCrosstab, variable); + } + for (final DRICrosstabMeasure measure : crosstab.getMeasures()) { + if (measure.getExpression() instanceof DRICrosstabVariable) { + addMeasure(designCrosstab, (DRICrosstabVariable) measure.getExpression()); + } + } + accessor.getExpressionTransform().transformExpression(crosstabRowCounter); + addRowCountExpression(designCrosstab); + crosstabs.put(designCrosstab, crosstab); + accessor.transformToMainDataset(); + + return designCrosstab; + } + + // dataset + private DRDesignCrosstabDataset dataset(final DRICrosstabDataset dataset, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final DRDesignCrosstabDataset designDataset = new DRDesignCrosstabDataset(); + designDataset.setSubDataset(accessor.getDatasetTransform().transform(dataset.getSubDataset())); + designDataset.setDataPreSorted(dataset.getDataPreSorted()); + if (resetType != null && resetType.equals(ResetType.NONE)) { + designDataset.setResetType(ResetType.REPORT); + } else { + designDataset.setResetType(resetType); + } + designDataset.setResetGroup(resetGroup); + return designDataset; + } + + private void addRowCountExpression(final DRDesignCrosstab designCrosstab) throws DRException { + final DRDesignCrosstabRowGroup lastRowGroup = getLastValue(designCrosstab.getRowGroups()); + final DRFiller filler = new DRFiller(); + final CrosstabRowCount rowCountExpression = new CrosstabRowCount(); + filler.setPrintWhenExpression(rowCountExpression); + final DRDesignComponent designTextField = accessor.getComponentTransform().filler(filler); + lastRowGroup.getHeader().getList().addComponent(designTextField); + } + + private DRDesignCrosstabCellContent cellContent(final DRICrosstabCellContent cellContent, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final DRDesignCrosstabCellContent designCellContents = new DRDesignCrosstabCellContent(); + designCellContents.setList(accessor.getComponentTransform().list(cellContent.getList(), DefaultStyleType.TEXT, resetType, resetGroup)); + designCellContents.setStyle(accessor.getStyleTransform().transformStyle(cellContent.getStyle(), false, DefaultStyleType.NONE)); + return designCellContents; + } + + @SuppressWarnings( {"rawtypes", "unchecked"}) + private void group(final DRDesignCrosstabGroup designGroup, final DRICrosstab crosstab, final DRICrosstabGroup group, final boolean showTotal, final ResetType resetType, final DRDesignGroup resetGroup, + final DRDesignComponent designTitleComponent, final DRDesignComponent designTotalTitleComponent) throws DRException { + designGroup.setName(group.getName()); + designGroup.setOrderType(group.getOrderType()); + + designGroup.setExpression(accessor.getExpressionTransform().transformExpression(group.getExpression())); + if (group.getOrderByExpression() != null) { + final DRIExpression orderByExpression = getCrosstabExpression(crosstab, group.getOrderByExpression()); + designGroup.setOrderByExpression(accessor.getExpressionTransform().transformExpression(orderByExpression)); + } + if (group.getComparatorExpression() != null) { + final DRIExpression comparatorExpression = getCrosstabExpression(crosstab, group.getComparatorExpression()); + designGroup.setComparatorExpression(accessor.getExpressionTransform().transformExpression(comparatorExpression)); + } + + DRTextField textField = new DRTextField(); + textField.setValueExpression(group); + textField.setPattern(group.getHeaderPattern()); + textField.setHorizontalTextAlignment(group.getHeaderHorizontalTextAlignment()); + textField.setValueFormatter(group.getHeaderValueFormatter()); + textField.setDataType(group.getDataType()); + textField.setStretchWithOverflow(group.getHeaderStretchWithOverflow()); + textField.setTextAdjust(group.getHeaderTextAdjust()); + textField.setHyperLink((DRHyperLink) group.getHeaderHyperLink()); + textField.setPropertyExpressions(group.getHeaderPropertyExpressions()); + + boolean measureTitle = false; + for (final DRICrosstabMeasure crosstabMeasure : crosstab.getMeasures()) { + if (crosstabMeasure.getTitleExpression() != null) { + measureTitle = true; + break; + } + } + + if (group instanceof DRICrosstabRowGroup || group instanceof DRICrosstabColumnGroup && !measureTitle) { + textField.setStretchType(StretchType.CONTAINER_HEIGHT); + } + DRIReportStyle groupStyle = group.getHeaderStyle(); + if (groupStyle == null) { + groupStyle = accessor.getTemplateTransform().getCrosstabGroupStyle(crosstab); + } + textField.setStyle(groupStyle); + final DRDesignCrosstabCellContent header = createCellContent(getCellStyle(groupStyle), resetType, resetGroup); + DRDesignTextField designTextField = accessor.getComponentTransform().textField(textField, DefaultStyleType.TEXT); + designTextField.setUniqueName("group_" + designGroup.getName() + ".header"); + header.getList().addComponent(designTextField); + if (designTitleComponent != null) { + header.getList().addComponent(designTitleComponent); + } + designGroup.setHeader(header); + if (showTotal) { + DRIReportStyle totalStyle = group.getTotalHeaderStyle(); + if (totalStyle == null) { + DRICrosstabGroup firstGroup = null; + if (group instanceof DRICrosstabRowGroup) { + firstGroup = getFirstValue(crosstab.getRowGroups()); + } else { + firstGroup = getFirstValue(crosstab.getColumnGroups()); + } + if (firstGroup == group) { + totalStyle = accessor.getTemplateTransform().getCrosstabGrandTotalStyle(crosstab); + } else { + totalStyle = accessor.getTemplateTransform().getCrosstabGroupTotalStyle(crosstab); + } + } + + textField = new DRTextField(); + DRIExpression totalHeaderExpression = group.getTotalHeaderExpression(); + if (totalHeaderExpression == null) { + totalHeaderExpression = new SystemMessageExpression("total"); + } + textField.setValueExpression(totalHeaderExpression); + textField.setStretchWithOverflow(group.getTotalHeaderStretchWithOverflow()); + textField.setTextAdjust(group.getTotalHeaderTextAdjust()); + textField.setPropertyExpressions(group.getTotalHeaderPropertyExpressions()); + textField.setStyle(totalStyle); + if (group instanceof DRICrosstabRowGroup || group instanceof DRICrosstabColumnGroup && !measureTitle) { + textField.setStretchType(StretchType.CONTAINER_HEIGHT); + } + + final DRDesignCrosstabCellContent totalHeader = createCellContent(getCellStyle(totalStyle), resetType, resetGroup); + designTextField = accessor.getComponentTransform().textField(textField, DefaultStyleType.TEXT); + designTextField.setUniqueName("group_" + designGroup.getName() + ".totalheader"); + totalHeader.getList().addComponent(designTextField); + if (designTotalTitleComponent != null) { + totalHeader.getList().addComponent(designTotalTitleComponent); + } + designGroup.setTotalHeader(totalHeader); + } + } + + private void addColumnGroup(final DRICrosstab crosstab, final DRDesignCrosstab designCrosstab, final DRICrosstabColumnGroup columnGroup, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final DRDesignCrosstabColumnGroup designColumnGroup = new DRDesignCrosstabColumnGroup(); + final boolean showTotal = accessor.getTemplateTransform().isCrosstabColumnGroupShowTotal(columnGroup); + + DRDesignComponent designTitleComponent = null; + DRDesignComponent designTotalTitleComponent = null; + final boolean lastColumn = columnGroup == getLastValue(crosstab.getColumnGroups()); + if (showTotal || lastColumn) { + boolean showTitle = false; + for (final DRICrosstabMeasure measure : crosstab.getMeasures()) { + if (measure.getTitleExpression() != null) { + showTitle = true; + break; + } + } + + if (showTitle) { + if (lastColumn) { + DRIReportStyle groupStyle = columnGroup.getHeaderStyle(); + if (groupStyle == null) { + groupStyle = accessor.getTemplateTransform().getCrosstabGroupStyle(crosstab); + } + final String name = "group_" + columnGroup.getName() + ".titleheader"; + designTitleComponent = getMeasureTitleComponent(name, crosstab, groupStyle); + } + if (showTotal) { + DRIReportStyle totalStyle = columnGroup.getTotalHeaderStyle(); + if (totalStyle == null) { + final DRICrosstabGroup firstGroup = getFirstValue(crosstab.getColumnGroups()); + if (firstGroup == columnGroup) { + totalStyle = accessor.getTemplateTransform().getCrosstabGrandTotalStyle(crosstab); + } else { + totalStyle = accessor.getTemplateTransform().getCrosstabGroupTotalStyle(crosstab); + } + } + final String name = "group_" + columnGroup.getName() + ".titletotalheader"; + designTotalTitleComponent = getMeasureTitleComponent(name, crosstab, totalStyle); + } + } + } + + group(designColumnGroup, crosstab, columnGroup, showTotal, resetType, resetGroup, designTitleComponent, designTotalTitleComponent); + designColumnGroup.setTotalPosition(accessor.getTemplateTransform().getCrosstabColumnGroupTotalPosition(columnGroup)); + designCrosstab.getColumnGroups().add(designColumnGroup); + } + + @SuppressWarnings( {"rawtypes", "unchecked"}) + private DRDesignComponent getMeasureTitleComponent(final String name, final DRICrosstab crosstab, final DRIReportStyle defaultStyle) throws DRException { + final DRDesignList titleComponent = new DRDesignList(); + for (final DRICrosstabMeasure measure : crosstab.getMeasures()) { + final DRTextField textField = new DRTextField(); + if (measure.getTitleExpression() != null) { + textField.setValueExpression(measure.getTitleExpression()); + } + DRIReportStyle titleStyle = accessor.getTemplateTransform().getCrosstabMeasureTitleStyle(crosstab, measure); + if (titleStyle == null) { + titleStyle = defaultStyle; + } + textField.setStyle(titleStyle); + final DRDesignTextField designTextField = accessor.getComponentTransform().textField(textField, DefaultStyleType.TEXT); + designTextField.setUniqueName(name + "." + measure.getName()); + titleComponent.addComponent(designTextField); + } + + return titleComponent; + } + + private void addRowGroup(final DRICrosstab crosstab, final DRDesignCrosstab designCrosstab, final DRICrosstabRowGroup rowGroup, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final DRDesignCrosstabRowGroup designRowGroup = new DRDesignCrosstabRowGroup(); + final boolean showTotal = accessor.getTemplateTransform().isCrosstabRowGroupShowTotal(rowGroup); + group(designRowGroup, crosstab, rowGroup, showTotal, resetType, resetGroup, null, null); + designRowGroup.setTotalPosition(accessor.getTemplateTransform().getCrosstabRowGroupTotalPosition(rowGroup)); + designCrosstab.getRowGroups().add(designRowGroup); + } + + private void addCells(final DRICrosstab crosstab, final DRDesignCrosstab designCrosstab, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final MeasuresStyles measuresStyle = new MeasuresStyles(crosstab, designCrosstab); + + DRIReportStyle groupTotalStyle = accessor.getTemplateTransform().getCrosstabGroupTotalStyle(crosstab); + groupTotalStyle = getCellStyle(groupTotalStyle); + DRIReportStyle grandTotalStyle = accessor.getTemplateTransform().getCrosstabGrandTotalStyle(crosstab); + grandTotalStyle = getCellStyle(grandTotalStyle); + DRIReportStyle cellStyle = accessor.getTemplateTransform().getCrosstabCellStyle(crosstab); + cellStyle = getCellStyle(cellStyle); + + final DRICrosstabGroup firstColumnGroup = getFirstValue(crosstab.getColumnGroups()); + final DRICrosstabGroup firstRowGroup = getFirstValue(crosstab.getRowGroups()); + + DRDesignCrosstabCell designCell = cell(crosstab, cellStyle, measuresStyle, null, null, resetType, resetGroup); + designCrosstab.getCells().add(designCell); + + DRIReportStyle style = null; + for (final DRICrosstabColumnGroup columnGroup : crosstab.getColumnGroups()) { + if (columnGroup == firstColumnGroup) { + style = grandTotalStyle; + } else { + style = groupTotalStyle; + } + if (accessor.getTemplateTransform().isCrosstabColumnGroupShowTotal(columnGroup)) { + designCell = cell(crosstab, style, measuresStyle, null, columnGroup, resetType, resetGroup); + designCrosstab.getCells().add(designCell); + } + } + + for (final DRICrosstabRowGroup rowGroup : crosstab.getRowGroups()) { + if (rowGroup == firstRowGroup) { + style = grandTotalStyle; + } else { + style = groupTotalStyle; + } + if (accessor.getTemplateTransform().isCrosstabRowGroupShowTotal(rowGroup)) { + designCell = cell(crosstab, style, measuresStyle, rowGroup, null, resetType, resetGroup); + designCrosstab.getCells().add(designCell); + + for (final DRICrosstabColumnGroup columnGroup : crosstab.getColumnGroups()) { + if (accessor.getTemplateTransform().isCrosstabColumnGroupShowTotal(columnGroup)) { + DRIReportStyle totalStyle = style; + if (columnGroup == firstColumnGroup) { + totalStyle = grandTotalStyle; + } + designCell = cell(crosstab, totalStyle, measuresStyle, rowGroup, columnGroup, resetType, resetGroup); + designCrosstab.getCells().add(designCell); + } + } + } + } + } + + private T getFirstValue(final List values) { + if (!values.isEmpty()) { + return values.get(0); + } + + return null; + } + + private T getLastValue(final List values) { + if (!values.isEmpty()) { + return values.get(values.size() - 1); + } + + return null; + } + + private DRIReportStyle getCellStyle(final DRIReportStyle reportStyle) throws DRException { + final DRIStyle style = accessor.getStyleTransform().getStyle(reportStyle); + if (style == null || style.getBackgroundColor() == null) { + return null; + } + + final DRStyle cellStyle = new DRStyle(); + cellStyle.setBackgroundColor(style.getBackgroundColor()); + return cellStyle; + } + + private DRIReportStyle cellStyle(final DRICrosstab crosstab, final List rowHighlighters, final DRIReportStyle reportStyle) throws DRException { + final DRIStyle style = accessor.getStyleTransform().getStyle(reportStyle); + if (rowHighlighters != null && !rowHighlighters.isEmpty() || !style.getConditionalStyles().isEmpty()) { + final DRStyle newStyle = new DRStyle(); + if (style != null) { + newStyle.setParentStyle(style); + for (final DRIConditionalStyle conditionalStyle : style.getConditionalStyles()) { + final DRIExpression conditionalStyleExpression = getCrosstabExpression(crosstab, conditionalStyle.getConditionExpression()); + final DRConditionalStyle newConditionalStyle = new DRConditionalStyle(conditionalStyleExpression); + accessor.getStyleTransform().copyStyle(newConditionalStyle, conditionalStyle); + newStyle.addConditionalStyle(newConditionalStyle); + } + } + if (rowHighlighters != null && !rowHighlighters.isEmpty()) { + final Color backgroundColor = StyleResolver.getBackgroundColor(style, accessor.getStyleTransform()); + for (final DRIConditionalStyle conditionalStyle : rowHighlighters) { + if (backgroundColor != null && conditionalStyle.getBackgroundColor() != null) { + final DRConditionalStyle newConditionalStyle = new DRConditionalStyle(conditionalStyle.getConditionExpression()); + accessor.getStyleTransform().copyStyle(newConditionalStyle, conditionalStyle); + final Color mergedColor = StyleResolver.mergeColors(backgroundColor, conditionalStyle.getBackgroundColor(), 0.25f); + newConditionalStyle.setBackgroundColor(mergedColor); + newStyle.addConditionalStyle(newConditionalStyle); + } else { + newStyle.addConditionalStyle((DRConditionalStyle) conditionalStyle); + } + } + } + return newStyle; + } + + return style; + } + + @SuppressWarnings( {"rawtypes", "unchecked"}) + private DRDesignCrosstabCell cell(final DRICrosstab crosstab, final DRIReportStyle cellStyle, final MeasuresStyles measuresStyle, final DRICrosstabRowGroup rowGroup, final DRICrosstabColumnGroup columnGroup, + final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final DRDesignCrosstabCell designCell = new DRDesignCrosstabCell(); + String rowTotalGroup = null; + String columnTotalGroup = null; + if (rowGroup != null) { + rowTotalGroup = rowGroup.getName(); + } + if (columnGroup != null) { + columnTotalGroup = columnGroup.getName(); + } + designCell.setRowTotalGroup(rowTotalGroup); + designCell.setColumnTotalGroup(columnTotalGroup); + + final DRDesignList designList = new DRDesignList(); + designList.setStretchType(StretchType.CONTAINER_HEIGHT); + for (final DRICrosstabMeasure measure : crosstab.getMeasures()) { + final DRTextField textField = new DRTextField(); + + if (measure.getExpression() instanceof DRICrosstabVariable) { + textField.setValueExpression(measure.getExpression()); + } else { + final DRIExpression valueExpression = getCrosstabExpression(crosstab, measure.getExpression()); + textField.setValueExpression(valueExpression); + } + + textField.setPattern(measure.getPattern()); + textField.setHorizontalTextAlignment(measure.getHorizontalTextAlignment()); + textField.setValueFormatter(measure.getValueFormatter()); + textField.setDataType(measure.getDataType()); + textField.setStretchWithOverflow(measure.getStretchWithOverflow()); + textField.setTextAdjust(measure.getTextAdjust()); + textField.setStretchType(StretchType.CONTAINER_HEIGHT); + textField.setHyperLink((DRHyperLink) measure.getHyperLink()); + textField.setPropertyExpressions(measure.getPropertyExpressions()); + textField.setStyle(measuresStyle.getStyle(measure, rowGroup, columnGroup)); + final DRDesignTextField designTextField = accessor.getComponentTransform().textField(textField, DefaultStyleType.TEXT); + String name = "cell_measure[" + measure.getName() + "]"; + if (rowTotalGroup != null) { + name += "_rowgroup[" + rowTotalGroup + "]"; + } + if (columnTotalGroup != null) { + name += "_columngroup[" + columnTotalGroup + "]"; + } + designTextField.setUniqueName(name); + designList.addComponent(designTextField); + } + + final DRDesignCrosstabCellContent content = createCellContent(cellStyle, resetType, resetGroup); + designCell.setContent(content); + content.getList().addComponent(designList); + + return designCell; + } + + private DRConditionalStyle detailRowConditionalStyle(final DRISimpleStyle style, final DRISimpleExpression expression) { + final DRConditionalStyle conditionalStyle = new DRConditionalStyle(expression); + accessor.getStyleTransform().copyStyle(conditionalStyle, style); + return conditionalStyle; + } + + private boolean equalsGroup(final DRICrosstabGroup group1, final DRICrosstabGroup group2) { + if (group1 == null && group2 == null) { + return true; + } + if (group1 != null && group2 != null) { + return group1.equals(group2); + } + return false; + } + + private DRDesignCrosstabCellContent createCellContent(final DRIReportStyle style, final ResetType resetType, final DRDesignGroup resetGroup) throws DRException { + final DRCrosstabCellContent cellContent = new DRCrosstabCellContent(); + cellContent.setStyle(style); + return cellContent(cellContent, resetType, resetGroup); + } + + private void addMeasure(final DRDesignCrosstab designCrosstab, final DRICrosstabVariable variable) throws DRException { + final DRDesignCrosstabMeasure designMeasure = new DRDesignCrosstabMeasure(); + designMeasure.setName(variable.getName()); + DRIExpression expression; + if (variable.getPercentageType() != null && variable.getPercentageType().equals(CrosstabPercentageType.GRAND_TOTAL) && !variable.getCalculation().equals(Calculation.COUNT) && + !variable.getCalculation().equals(Calculation.DISTINCT_COUNT)) { + expression = new CrosstabMeasureExpression(variable.getValueExpression()); + } else { + expression = variable.getValueExpression(); + } + designMeasure.setValueExpression(accessor.getExpressionTransform().transformExpression(expression)); + designMeasure.setCalculation(variable.getCalculation()); + designMeasure.setPercentageType(accessor.getTemplateTransform().getCrosstabPercentageType(variable)); + + designCrosstab.getMeasures().add(designMeasure); + } + + /** + *

getCrosstab.

+ * + * @param designCrosstab a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab} object. + * @return a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + */ + protected DRICrosstab getCrosstab(final DRDesignCrosstab designCrosstab) { + return crosstabs.get(designCrosstab); + } + + private DRIExpression getCrosstabExpression(final DRICrosstab crosstab, final DRIExpression expression) throws DRException { + if (expression instanceof DRIJasperExpression) { + return expression; + } + accessor.getExpressionTransform().transformExpression(expression); + return new CrosstabExpression<>(crosstab, expression); + } + + private class MeasuresStyles { + private final Map, List> measuresStyle; + private DRIReportStyle defaultCellStyle; + private DRIReportStyle defaultGroupTotalStyle; + private DRIReportStyle defaultGrandTotalStyle; + private DRIReportStyle defaultRowGroupTotalStyle; + private DRIReportStyle defaultRowGrandTotalStyle; + private DRICrosstabGroup firstColumnGroup; + private DRICrosstabGroup firstRowGroup; + + private MeasuresStyles(final DRICrosstab crosstab, final DRDesignCrosstab designCrosstab) throws DRException { + measuresStyle = new HashMap<>(); + init(crosstab, designCrosstab); + } + + private void init(final DRICrosstab crosstab, final DRDesignCrosstab designCrosstab) throws DRException { + final List rowHighlighters = new ArrayList<>(); + final DRISimpleStyle detailOddRowStyle = accessor.getTemplateTransform().getCrosstabOddRowStyle(crosstab); + final DRISimpleStyle detailEvenRowStyle = accessor.getTemplateTransform().getCrosstabEvenRowStyle(crosstab); + if (detailOddRowStyle != null || detailEvenRowStyle != null) { + if (detailOddRowStyle != null) { + rowHighlighters.add(detailRowConditionalStyle(detailOddRowStyle, new CrosstabPrintInOddRow())); + } + if (detailEvenRowStyle != null) { + rowHighlighters.add(detailRowConditionalStyle(detailEvenRowStyle, new CrosstabPrintInEvenRow())); + } + } + + for (final DRICrosstabMeasure measure : crosstab.getMeasures()) { + final List styles = new ArrayList<>(); + measuresStyle.put(measure, styles); + + for (final DRICrosstabCellStyle cellStyle : measure.getStyles()) { + final DRIReportStyle newStyle = cellStyle(crosstab, rowHighlighters, cellStyle.getStyle()); + styles.add(new DRCrosstabCellStyle(newStyle, cellStyle.getRowGroup(), cellStyle.getColumnGroup())); + } + } + + DRIReportStyle groupTotalStyle = accessor.getTemplateTransform().getCrosstabGroupTotalStyle(crosstab); + DRIReportStyle grandTotalStyle = accessor.getTemplateTransform().getCrosstabGrandTotalStyle(crosstab); + final DRIReportStyle cellStyle = accessor.getTemplateTransform().getCrosstabCellStyle(crosstab); + if (groupTotalStyle == null) { + groupTotalStyle = cellStyle; + } + if (grandTotalStyle == null) { + grandTotalStyle = cellStyle; + } + defaultGroupTotalStyle = cellStyle(crosstab, rowHighlighters, groupTotalStyle); + defaultGrandTotalStyle = cellStyle(crosstab, rowHighlighters, grandTotalStyle); + if (StyleResolver.getBackgroundColor(groupTotalStyle, accessor.getStyleTransform()) != null) { + defaultRowGroupTotalStyle = cellStyle(crosstab, null, groupTotalStyle); + } + if (StyleResolver.getBackgroundColor(grandTotalStyle, accessor.getStyleTransform()) != null) { + defaultRowGrandTotalStyle = cellStyle(crosstab, null, grandTotalStyle); + } + defaultCellStyle = cellStyle(crosstab, rowHighlighters, cellStyle); + firstColumnGroup = getFirstValue(crosstab.getColumnGroups()); + firstRowGroup = getFirstValue(crosstab.getRowGroups()); + } + + public DRIReportStyle getStyle(final DRICrosstabMeasure measure, final DRICrosstabRowGroup rowGroup, final DRICrosstabColumnGroup columnGroup) { + final List styles = measuresStyle.get(measure); + for (final DRICrosstabCellStyle crosstabCellStyle : styles) { + if (equalsGroup(rowGroup, crosstabCellStyle.getRowGroup()) && equalsGroup(columnGroup, crosstabCellStyle.getColumnGroup())) { + return crosstabCellStyle.getStyle(); + } + } + for (final DRICrosstabCellStyle crosstabCellStyle : styles) { + if (crosstabCellStyle.getRowGroup() == null && crosstabCellStyle.getColumnGroup() == null) { + return crosstabCellStyle.getStyle(); + } + } + + if (rowGroup == null && columnGroup == null) { + return defaultCellStyle; + } + if (rowGroup != null) { + if ((columnGroup == firstColumnGroup || rowGroup == firstRowGroup) && defaultRowGrandTotalStyle != null) { + return defaultRowGrandTotalStyle; + } + if (defaultRowGroupTotalStyle != null) { + return defaultRowGroupTotalStyle; + } + } + if (columnGroup == firstColumnGroup || rowGroup == firstRowGroup) { + return defaultGrandTotalStyle; + } else { + return defaultGroupTotalStyle; + } + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/DatasetExpressionTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/DatasetExpressionTransform.java new file mode 100644 index 0000000..075e923 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/DatasetExpressionTransform.java @@ -0,0 +1,78 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.report.definition.DRIDataset; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.DRISort; +import software.xdev.dynamicreports.report.definition.DRIVariable; + +import java.util.List; + +/** + *

DatasetExpressionTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class DatasetExpressionTransform extends AbstractExpressionTransform { + private DRIDataset dataset; + + /** + *

Constructor for DatasetExpressionTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + * @param dataset a {@link software.xdev.dynamicreports.report.definition.DRIDataset} object. + */ + public DatasetExpressionTransform(DesignTransformAccessor accessor, DRIDataset dataset) { + super(accessor); + this.dataset = dataset; + } + + /** {@inheritDoc} */ + @Override + protected ResetType getVariableResetType(DRIVariable variable) { + return ResetType.REPORT; + } + + /** {@inheritDoc} */ + @Override + protected List> transformFields() { + return dataset.getFields(); + } + + /** {@inheritDoc} */ + @Override + protected List> transformVariables() { + return dataset.getVariables(); + } + + /** {@inheritDoc} */ + @Override + protected List transformSorts() { + return dataset.getSorts(); + } + + /** {@inheritDoc} */ + @Override + protected DRIDesignDataset getDataset() { + return accessor.getDatasetTransform().getDesignDataset(dataset); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/DatasetTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/DatasetTransform.java new file mode 100644 index 0000000..0bb2539 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/DatasetTransform.java @@ -0,0 +1,119 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.DRDesignDataset; +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.jasper.base.JasperScriptlet; +import software.xdev.dynamicreports.report.definition.DRIDataset; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + *

DatasetTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class DatasetTransform { + private DesignTransformAccessor accessor; + private Map datasets; + private Map designDatasets; + + /** + *

Constructor for DatasetTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public DatasetTransform(DesignTransformAccessor accessor) { + this.accessor = accessor; + datasets = new HashMap<>(); + designDatasets = new HashMap<>(); + } + + /** + *

transform.

+ * + * @param dataset a {@link software.xdev.dynamicreports.report.definition.DRIDataset} object. + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignDataset} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public DRDesignDataset transform(DRIDataset dataset) throws DRException { + if (dataset == null) { + return null; + } + if (designDatasets.containsKey(dataset)) { + return designDatasets.get(dataset); + } + + DatasetExpressionTransform datasetExpressionTransform = new DatasetExpressionTransform(accessor, dataset); + datasetExpressionTransform.transform(); + DRDesignDataset designDataset = new DRDesignDataset(datasetExpressionTransform); + if (dataset.getQuery() != null) { + designDataset.setQuery(accessor.getReportTransform().query(dataset.getQuery())); + } + designDataset.setConnectionExpression(accessor.getExpressionTransform().transformExpression(dataset.getConnectionExpression())); + designDataset.setDataSourceExpression(accessor.getExpressionTransform().transformExpression(dataset.getDataSourceExpression())); + designDataset.setFilterExpression(datasetExpressionTransform.transformExpression(dataset.getFilterExpression(), JasperScriptlet.SCRIPTLET_NAME)); + + addDataset(dataset, designDataset); + + return designDataset; + } + + /** + *

getDatasetExpressionTransform.

+ * + * @param dataset a {@link software.xdev.dynamicreports.report.definition.DRIDataset} object. + * @return a {@link software.xdev.dynamicreports.design.transformation.DatasetExpressionTransform} object. + */ + public DatasetExpressionTransform getDatasetExpressionTransform(DRIDataset dataset) { + return designDatasets.get(dataset).getDatasetExpressionTransform(); + } + + /** + *

getDesignDataset.

+ * + * @param dataset a {@link software.xdev.dynamicreports.report.definition.DRIDataset} object. + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignDataset} object. + */ + protected DRDesignDataset getDesignDataset(DRIDataset dataset) { + return designDatasets.get(dataset); + } + + private void addDataset(DRIDataset dataset, DRDesignDataset designDataset) { + if (datasets.containsKey(designDataset.getName())) { + throw new DRDesignReportException("Duplicate declaration of dataset \"" + designDataset.getName() + "\""); + } + datasets.put(designDataset.getName(), designDataset); + designDatasets.put(dataset, designDataset); + } + + /** + *

Getter for the field datasets.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getDatasets() { + return datasets.values(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/DesignTransformAccessor.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/DesignTransformAccessor.java new file mode 100644 index 0000000..0a23b63 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/DesignTransformAccessor.java @@ -0,0 +1,194 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import java.util.Locale; +import java.util.ResourceBundle; + +import software.xdev.dynamicreports.design.base.DRDesignPage; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.DRIDataset; +import software.xdev.dynamicreports.report.definition.DRIReport; + +/** + *

DesignTransformAccessor interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DesignTransformAccessor { + + /** + *

getReport.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIReport} object. + */ + public DRIReport getReport(); + + /** + *

getPageWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageWidth(); + + /** + *

getReportTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.ReportTransform} object. + */ + public ReportTransform getReportTransform(); + + /** + *

getTemplateTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.TemplateTransform} object. + */ + public TemplateTransform getTemplateTransform(); + + /** + *

transformToMainDataset.

+ */ + public void transformToMainDataset(); + + /** + *

transformToDataset.

+ * + * @param dataset a {@link software.xdev.dynamicreports.report.definition.DRIDataset} object. + */ + public void transformToDataset(DRIDataset dataset); + + /** + *

getExpressionTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.AbstractExpressionTransform} object. + */ + public AbstractExpressionTransform getExpressionTransform(); + + /** + *

getPageTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.PageTransform} object. + */ + public PageTransform getPageTransform(); + + /** + *

getBandTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.BandTransform} object. + */ + public BandTransform getBandTransform(); + + /** + *

getComponentTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.ComponentTransform} object. + */ + public ComponentTransform getComponentTransform(); + + /** + *

getGroupTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.GroupTransform} object. + */ + public GroupTransform getGroupTransform(); + + /** + *

getColumnTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.ColumnTransform} object. + */ + public ColumnTransform getColumnTransform(); + + /** + *

getColumnGridTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.ColumnGridTransform} object. + */ + public ColumnGridTransform getColumnGridTransform(); + + /** + *

getStyleTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.StyleTransform} object. + */ + public StyleTransform getStyleTransform(); + + /** + *

getCrosstabTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.CrosstabTransform} object. + */ + public CrosstabTransform getCrosstabTransform(); + + /** + *

getDatasetTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.DatasetTransform} object. + */ + public DatasetTransform getDatasetTransform(); + + /** + *

getTableOfContentsTransform.

+ * + * @return a {@link software.xdev.dynamicreports.design.transformation.TableOfContentsTransform} object. + */ + public TableOfContentsTransform getTableOfContentsTransform(); + + /** + *

isTableOfContents.

+ * + * @return a boolean. + */ + public boolean isTableOfContents(); + + /** + *

getPage.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignPage} object. + */ + public DRDesignPage getPage(); + + /** + *

getLocale.

+ * + * @return a {@link java.util.Locale} object. + */ + public Locale getLocale(); + + /** + *

getResourceBundle.

+ * + * @return a {@link java.util.ResourceBundle} object. + */ + public ResourceBundle getResourceBundle(); + + /** + *

getResourceBundleName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getResourceBundleName(); + + /** + *

getWhenResourceMissingType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + */ + public WhenResourceMissingType getWhenResourceMissingType(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/GroupTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/GroupTransform.java new file mode 100644 index 0000000..29be44d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/GroupTransform.java @@ -0,0 +1,331 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.DRDesignBand; +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.base.DRDesignTableOfContentsHeading; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignFiller; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.design.constant.DefaultStyleType; +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.design.transformation.expressions.GroupByDataTypeExpression; +import software.xdev.dynamicreports.report.base.DRVariable; +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.definition.DRIBand; +import software.xdev.dynamicreports.report.definition.DRIGroup; +import software.xdev.dynamicreports.report.definition.DRIReport; +import software.xdev.dynamicreports.report.definition.column.DRIValueColumn; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + *

GroupTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class GroupTransform { + private DesignTransformAccessor accessor; + private List groups; + private Map designGroups; + private List> hideGroupColumns; + private DRIGroup firstResetPageNumberGroup; + private int groupPadding; + + /** + *

Constructor for GroupTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public GroupTransform(DesignTransformAccessor accessor) { + this.accessor = accessor; + init(); + } + + private void init() { + DRIReport report = accessor.getReport(); + groups = report.getGroups(); + designGroups = new LinkedHashMap(); + hideGroupColumns = new ArrayList>(); + groupPadding = 0; + } + + /** + *

transform.

+ * + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public void transform() throws DRException { + for (DRIGroup group : groups) { + DRDesignGroup designGroup = group(group); + addGroup(group, designGroup); + } + } + + private void addGroup(DRIGroup group, DRDesignGroup designGroup) { + if (accessor.getTemplateTransform().isGroupHideColumn(group) && group.getValueField().getValueExpression() instanceof DRIValueColumn) { + hideGroupColumns.add((DRIValueColumn) group.getValueField().getValueExpression()); + } + designGroups.put(group, designGroup); + if (firstResetPageNumberGroup == null && designGroup.isResetPageNumber()) { + firstResetPageNumberGroup = group; + } + groupPadding += accessor.getTemplateTransform().getGroupPadding(group); + } + + /** + *

transformHeaderAndFooter.

+ * + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public void transformHeaderAndFooter() throws DRException { + int groupPadding = 0; + int level = 0; + for (DRIGroup group : groups) { + headerAndFooter(group, designGroups.get(group), groupPadding, level++); + groupPadding += accessor.getTemplateTransform().getGroupPadding(group); + } + } + + private void headerAndFooter(DRIGroup group, DRDesignGroup designGroup, int groupPadding, int level) throws DRException { + DRDesignList header = new DRDesignList(); + TemplateTransform templateTransform = accessor.getTemplateTransform(); + + DRDesignTableOfContentsHeading designTocHeading = accessor.getTableOfContentsTransform().groupHeading(group, level); + if (designTocHeading != null) { + header.addComponent(designTocHeading.getReferenceField()); + } + + switch (templateTransform.getGroupHeaderLayout(group)) { + case EMPTY: + break; + case TITLE_AND_VALUE: + if (groupPadding > 0) { + DRDesignFiller filler = new DRDesignFiller(); + filler.setWidth(groupPadding); + filler.setHeight(0); + header.addComponent(HorizontalCellComponentAlignment.CENTER, null, filler); + } + header.addComponent(HorizontalCellComponentAlignment.LEFT, null, titleComponent(group)); + DRDesignTextField valueComponent = valueComponent(group); + header.addComponent(valueComponent); + if (designTocHeading != null) { + valueComponent.setAnchorNameExpression(designTocHeading.getReferenceField().getAnchorNameExpression()); + valueComponent.setBookmarkLevel(designTocHeading.getReferenceField().getBookmarkLevel()); + valueComponent.setHyperLink(designTocHeading.getReferenceField().getHyperLink()); + } + break; + case VALUE: + if (groupPadding > 0) { + DRDesignFiller filler = new DRDesignFiller(); + filler.setWidth(groupPadding); + filler.setHeight(0); + header.addComponent(HorizontalCellComponentAlignment.CENTER, null, filler); + } + valueComponent = valueComponent(group); + header.addComponent(valueComponent); + if (designTocHeading != null) { + valueComponent.setAnchorNameExpression(designTocHeading.getReferenceField().getAnchorNameExpression()); + valueComponent.setBookmarkLevel(designTocHeading.getReferenceField().getBookmarkLevel()); + valueComponent.setHyperLink(designTocHeading.getReferenceField().getHyperLink()); + } + break; + default: + throw new DRDesignReportException("Group header layout " + templateTransform.getGroupHeaderLayout(group).name() + " not supported"); + } + if (!header.isEmpty()) { + DRIBand bnd = group.getHeaderBand(); + DRDesignBand band = accessor.getBandTransform() + .band("groupHeaderTitleAndValue", bnd, templateTransform.getGroupHeaderSplitType(bnd), templateTransform.getGroupHeaderStyle(bnd), + templateTransform.getGroupHeaderBackgroundComponent(bnd)); + band.addComponent(header); + designGroup.addHeaderBand(band); + } + + DRIBand band = group.getHeaderBand(); + designGroup.addHeaderBand( + groupBand("groupHeader", band, templateTransform.getGroupHeaderSplitType(band), templateTransform.getGroupHeaderStyle(band), templateTransform.getGroupHeaderBackgroundComponent(band), + groupPadding, designGroup)); + band = group.getFooterBand(); + designGroup.addFooterBand( + groupBand("groupFooter", band, templateTransform.getGroupFooterSplitType(band), templateTransform.getGroupFooterStyle(band), templateTransform.getGroupFooterBackgroundComponent(band), + groupPadding, designGroup)); + if (templateTransform.isGroupShowColumnHeaderAndFooter(group)) { + designGroup.addHeaderBand(accessor.getBandTransform().getColumnHeaderForGroupBand()); + designGroup.addFooterBand(accessor.getBandTransform().getColumnFooterBand()); + } + } + + private DRDesignBand groupBand(String name, DRIBand band, SplitType splitType, DRIReportStyle defaultStyle, DRIComponent defaultBackgroundComponent, int groupPadding, DRDesignGroup resetGroup) + throws DRException { + DRDesignBand designBand = accessor.getBandTransform().band(name, band, splitType, defaultStyle, defaultBackgroundComponent, ResetType.GROUP, resetGroup); + if (groupPadding > 0) { + DRDesignFiller filler = new DRDesignFiller(); + filler.setWidth(groupPadding); + filler.setHeight(0); + DRDesignList list = new DRDesignList(); + list.addComponent(HorizontalCellComponentAlignment.CENTER, null, filler); + list.addComponent(designBand.getList()); + designBand.setList(list); + } + return designBand; + } + + // title + @SuppressWarnings("unchecked") + private DRDesignComponent titleComponent(DRIGroup group) throws DRException { + @SuppressWarnings("rawtypes") DRTextField titleField = new DRTextField(); + titleField.setValueExpression(group.getTitleExpression()); + titleField.setStyle(group.getTitleStyle()); + titleField.setWidth(group.getTitleWidth()); + DRDesignTextField designTitleField = accessor.getComponentTransform().textField(titleField, DefaultStyleType.GROUP_TITLE); + designTitleField.setUniqueName("group_" + group.getName() + ".title"); + return designTitleField; + } + + // value + private DRDesignTextField valueComponent(DRIGroup group) throws DRException { + DRDesignTextField designValueField = accessor.getComponentTransform().textField(group.getValueField(), DefaultStyleType.GROUP); + designValueField.setUniqueName("group_" + group.getName()); + return designValueField; + } + + // group + @SuppressWarnings( {"unchecked", "rawtypes"}) + private DRDesignGroup group(DRIGroup group) throws DRException { + TemplateTransform templateTransform = accessor.getTemplateTransform(); + DRDesignGroup designGroup = new DRDesignGroup(group.getName()); + designGroup.setStartInNewPage(templateTransform.isGroupStartInNewPage(group)); + designGroup.setStartInNewColumn(templateTransform.isGroupStartInNewColumn(group)); + designGroup.setReprintHeaderOnEachPage(templateTransform.isGroupReprintHeaderOnEachPage(group)); + designGroup.setResetPageNumber(templateTransform.isGroupResetPageNumber(group)); + designGroup.setMinHeightToStartNewPage(templateTransform.getGroupMinHeightToStartNewPage(group)); + designGroup.setFooterPosition(templateTransform.getGroupFooterPosition(group)); + designGroup.setKeepTogether(templateTransform.isGroupKeepTogether(group)); + designGroup.setHeaderWithSubtotal(templateTransform.isGroupHeaderWithSubtotal(group)); + DRIExpression groupExpression = group.getValueField().getValueExpression(); + if (templateTransform.isGroupByDataType(group) && group.getValueField().getDataType() != null) { + accessor.getExpressionTransform().transformExpression(groupExpression); + DRIDataType dataType = group.getValueField().getDataType(); + groupExpression = new GroupByDataTypeExpression(groupExpression, dataType); + } + groupExpression = new DRVariable(groupExpression, Calculation.NOTHING); + designGroup.setGroupExpression(accessor.getExpressionTransform().transformExpression(groupExpression)); + return designGroup; + } + + /** + *

getGroup.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + */ + protected DRDesignGroup getGroup(DRIGroup group) { + return designGroups.get(group); + } + + /** + *

getFirstGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + */ + protected DRIGroup getFirstGroup() { + if (!groups.isEmpty()) { + return groups.get(0); + } + return null; + } + + /** + *

getBeforeGroup.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + */ + protected DRIGroup getBeforeGroup(DRIGroup group) { + if (groups.size() > 1 && groups.indexOf(group) > 0) { + return groups.get(groups.indexOf(group) - 1); + } + return null; + } + + /** + *

getLastGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + */ + protected DRIGroup getLastGroup() { + if (!groups.isEmpty()) { + return groups.get(groups.size() - 1); + } + return null; + } + + /** + *

Getter for the field firstResetPageNumberGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + */ + protected DRIGroup getFirstResetPageNumberGroup() { + return firstResetPageNumberGroup; + } + + /** + *

Getter for the field groupPadding.

+ * + * @return a int. + */ + protected int getGroupPadding() { + return groupPadding; + } + + /** + *

Getter for the field hideGroupColumns.

+ * + * @return a {@link java.util.List} object. + */ + protected List> getHideGroupColumns() { + return hideGroupColumns; + } + + /** + *

Getter for the field groups.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getGroups() { + return designGroups.values(); + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/MainDatasetExpressionTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/MainDatasetExpressionTransform.java new file mode 100644 index 0000000..17ff9e1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/MainDatasetExpressionTransform.java @@ -0,0 +1,98 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.DRDesignField; +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.DRIReport; +import software.xdev.dynamicreports.report.definition.DRISort; +import software.xdev.dynamicreports.report.definition.DRIVariable; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.List; + +/** + *

MainDatasetExpressionTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class MainDatasetExpressionTransform extends AbstractExpressionTransform { + + /** + *

Constructor for MainDatasetExpressionTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public MainDatasetExpressionTransform(DesignTransformAccessor accessor) { + super(accessor); + } + + /** {@inheritDoc} */ + @Override + public void transform() throws DRException { + DRIReport report = accessor.getReport(); + List> templateDesignFields = report.getTemplateDesign().getFields(); + if (templateDesignFields != null) { + for (DRIField field : templateDesignFields) { + DRDesignField designField = (DRDesignField) transformExpression(field); + designField.setExternal(true); + } + } + super.transform(); + } + + /** {@inheritDoc} */ + @Override + protected ResetType getVariableResetType(DRIVariable variable) { + return ConstantTransform.variableResetType(variable.getResetType(), variable.getResetGroup(), accessor); + } + + /** {@inheritDoc} */ + @Override + protected DRDesignGroup getVariableResetGroup(DRIVariable variable) throws DRException { + return accessor.getGroupTransform().getGroup(ConstantTransform.variableResetGroup(variable.getName(), variable.getResetType(), variable.getResetGroup(), accessor)); + } + + /** {@inheritDoc} */ + @Override + protected List> transformFields() { + return accessor.getReport().getFields(); + } + + /** {@inheritDoc} */ + @Override + protected List> transformVariables() { + return accessor.getReport().getVariables(); + } + + /** {@inheritDoc} */ + @Override + protected List transformSorts() { + return accessor.getReport().getSorts(); + } + + /** {@inheritDoc} */ + @Override + protected DRIDesignDataset getDataset() { + return null; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/PageTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/PageTransform.java new file mode 100644 index 0000000..270015f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/PageTransform.java @@ -0,0 +1,97 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.DRDesignMargin; +import software.xdev.dynamicreports.design.base.DRDesignPage; +import software.xdev.dynamicreports.report.definition.DRIMargin; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + *

PageTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class PageTransform { + private TemplateTransform templateTransform; + private DRDesignPage page; + private int maxBandWidth; + + /** + *

Constructor for PageTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public PageTransform(DesignTransformAccessor accessor) { + this.templateTransform = accessor.getTemplateTransform(); + this.page = new DRDesignPage(); + } + + /** + *

transform.

+ * + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public void transform() throws DRException { + this.page.setHeight(templateTransform.getPageHeight()); + this.page.setOrientation(templateTransform.getPageOrientation()); + this.page.setMargin(margin(templateTransform.getPageMargin())); + this.page.setColumnsPerPage(templateTransform.getPageColumnsPerPage()); + this.page.setColumnSpace(templateTransform.getPageColumnSpace()); + } + + private DRDesignMargin margin(DRIMargin margin) { + DRDesignMargin designMargin = new DRDesignMargin(); + designMargin.setTop(margin.getTop()); + designMargin.setLeft(margin.getLeft()); + designMargin.setBottom(margin.getBottom()); + designMargin.setRight(margin.getRight()); + return designMargin; + } + + /** + *

Getter for the field page.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignPage} object. + */ + public DRDesignPage getPage() { + return page; + } + + /** + *

transformPageWidth.

+ * + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public void transformPageWidth() throws DRException { + int pageWidth = templateTransform.getPageWidth(); + maxBandWidth = pageWidth - getPage().getMargin().getLeft() - getPage().getMargin().getRight(); + this.page.setWidth(pageWidth); + this.page.setColumnWidth(templateTransform.getPageColumnWidth(this.page)); + } + + /** + *

Getter for the field maxBandWidth.

+ * + * @return a int. + */ + public int getMaxBandWidth() { + return maxBandWidth; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ReportTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ReportTransform.java new file mode 100644 index 0000000..1b32383 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/ReportTransform.java @@ -0,0 +1,157 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.DRDesignHyperLink; +import software.xdev.dynamicreports.design.base.DRDesignParameter; +import software.xdev.dynamicreports.design.base.DRDesignQuery; +import software.xdev.dynamicreports.design.base.DRDesignTemplateDesign; +import software.xdev.dynamicreports.design.definition.DRIDesignParameter; +import software.xdev.dynamicreports.design.definition.DRIDesignTemplateDesign; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.jasper.base.JasperScriptlet; +import software.xdev.dynamicreports.report.definition.DRIHyperLink; +import software.xdev.dynamicreports.report.definition.DRIParameter; +import software.xdev.dynamicreports.report.definition.DRIQuery; +import software.xdev.dynamicreports.report.definition.DRIReport; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.ArrayList; +import java.util.List; + +/** + *

ReportTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class ReportTransform { + private DesignTransformAccessor accessor; + private DRIDesignTemplateDesign templateDesign; + private DRDesignQuery query; + private List parameters; + private DRIDesignExpression filterExpression; + + /** + *

Constructor for ReportTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public ReportTransform(DesignTransformAccessor accessor) { + this.accessor = accessor; + parameters = new ArrayList(); + } + + /** + *

transform.

+ * + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public void transform() throws DRException { + DRIReport report = accessor.getReport(); + templateDesign = new DRDesignTemplateDesign(report.getTemplateDesign()); + if (report.getQuery() != null) { + query = query(report.getQuery()); + } + for (DRIParameter parameter : report.getParameters()) { + parameters.add(parameter(parameter)); + } + filterExpression = accessor.getExpressionTransform().transformExpression(report.getFilterExpression(), JasperScriptlet.SCRIPTLET_NAME); + } + + /** + *

query.

+ * + * @param query a {@link software.xdev.dynamicreports.report.definition.DRIQuery} object. + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignQuery} object. + */ + protected DRDesignQuery query(DRIQuery query) { + DRDesignQuery designQuery = new DRDesignQuery(); + designQuery.setText(query.getText()); + designQuery.setLanguage(query.getLanguage()); + return designQuery; + } + + private DRDesignParameter parameter(DRIParameter parameter) { + DRDesignParameter designParameter = new DRDesignParameter(); + designParameter.setName(parameter.getName()); + designParameter.setValueClass(parameter.getValueClass()); + designParameter.setValue(parameter.getValue()); + designParameter.setExternal(accessor.getReport().getTemplateDesign().isDefinedParameter(parameter.getName())); + return designParameter; + } + + /** + *

hyperlink.

+ * + * @param hyperLink a {@link software.xdev.dynamicreports.report.definition.DRIHyperLink} object. + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignHyperLink} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public DRDesignHyperLink hyperlink(DRIHyperLink hyperLink) throws DRException { + if (hyperLink == null) { + return null; + } + + DRDesignHyperLink designHyperLink = new DRDesignHyperLink(); + designHyperLink.setAnchorExpression(accessor.getExpressionTransform().transformExpression(hyperLink.getAnchorExpression())); + designHyperLink.setPageExpression(accessor.getExpressionTransform().transformExpression(hyperLink.getPageExpression())); + designHyperLink.setReferenceExpression(accessor.getExpressionTransform().transformExpression(hyperLink.getReferenceExpression())); + designHyperLink.setTooltipExpression(accessor.getExpressionTransform().transformExpression(hyperLink.getTooltipExpression())); + designHyperLink.setType(hyperLink.getType()); + designHyperLink.setTarget(hyperLink.getTarget()); + + return designHyperLink; + } + + /** + *

Getter for the field templateDesign.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignTemplateDesign} object. + */ + public DRIDesignTemplateDesign getTemplateDesign() { + return templateDesign; + } + + /** + *

Getter for the field query.

+ * + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignQuery} object. + */ + public DRDesignQuery getQuery() { + return query; + } + + /** + *

Getter for the field parameters.

+ * + * @return a {@link java.util.List} object. + */ + public List getParameters() { + return parameters; + } + + /** + *

Getter for the field filterExpression.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public DRIDesignExpression getFilterExpression() { + return filterExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/StyleResolver.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/StyleResolver.java new file mode 100644 index 0000000..e921d46 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/StyleResolver.java @@ -0,0 +1,502 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.style.DRDesignStyle; +import software.xdev.dynamicreports.design.definition.style.DRIDesignStyle; +import software.xdev.dynamicreports.report.base.style.DRFont; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; +import net.sf.jasperreports.engine.DefaultJasperReportsContext; +import net.sf.jasperreports.engine.fonts.FontUtil; + +import java.awt.Color; +import java.awt.Font; +import java.awt.font.FontRenderContext; +import java.awt.image.BufferedImage; +import java.util.Locale; + +/** + *

StyleResolver class.

+ * + * @author Ricardo Mariaca + * + */ +public class StyleResolver { + private static FontRenderContext context = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).createGraphics().getFontRenderContext(); + + /** + *

getFontWidth.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @param columns a int. + * @return a int. + */ + protected static int getFontWidth(DRDesignStyle style, int columns) { + double width = getFont(style).getStringBounds("m", context).getWidth(); + return (int) Math.ceil(width * columns) + getHorizontalPadding(style); + } + + /** + *

getFontHeight.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @param rows a int. + * @return a int. + */ + protected static int getFontHeight(DRDesignStyle style, int rows) { + double height = getFont(style).getMaxCharBounds(context).getHeight(); + return (int) Math.ceil(height * rows) + getVerticalPadding(style); + } + + /** + *

getFontWidth.

+ * + * @param font a {@link software.xdev.dynamicreports.report.base.style.DRFont} object. + * @return a double. + */ + public static double getFontWidth(DRFont font) { + Font fnt = getFont(font.getFontName(), font.getBold(), font.getItalic(), font.getFontSize()); + return fnt.getStringBounds("m", context).getWidth(); + } + + /** + *

getFontHeight.

+ * + * @param font a {@link software.xdev.dynamicreports.report.base.style.DRFont} object. + * @return a double. + */ + public static double getFontHeight(DRFont font) { + Font fnt = getFont(font.getFontName(), font.getBold(), font.getItalic(), font.getFontSize()); + return fnt.getMaxCharBounds(context).getHeight(); + } + + private static Font getFont(DRDesignStyle style) { + String fontName = getFontName(style); + Integer fontSize = getFontSize(style); + Boolean bold = getFontBold(style); + Boolean italic = getFontItalic(style); + return getFont(fontName, bold, italic, fontSize); + } + + private static Font getFont(String fontName, Boolean bold, Boolean italic, Integer fontSize) { + if (bold == null) { + bold = false; + } + if (italic == null) { + italic = false; + } + int fontStyle; + if (bold && italic) { + fontStyle = Font.BOLD | Font.ITALIC; + } else if (bold) { + fontStyle = Font.BOLD; + } else if (italic) { + fontStyle = Font.ITALIC; + } else { + fontStyle = Font.PLAIN; + } + + FontUtil fontUtil = FontUtil.getInstance(DefaultJasperReportsContext.getInstance()); + Font font = fontUtil.getAwtFontFromBundles(fontName, fontStyle, (float) fontSize, Locale.getDefault(), true); + if (font == null) { + font = new Font(fontName, fontStyle, fontSize); + } + return font; + } + + /** + *

getFontName.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link java.lang.String} object. + */ + protected static String getFontName(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getFont().getFontName() != null) { + return style.getFont().getFontName(); + } + if (style.getParentStyle() != null) { + return getFontName(style.getParentStyle()); + } + return null; + } + + /** + *

getFontSize.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link java.lang.Integer} object. + */ + protected static Integer getFontSize(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getFont().getFontSize() != null) { + return style.getFont().getFontSize(); + } + if (style.getParentStyle() != null) { + return getFontSize(style.getParentStyle()); + } + return null; + } + + /** + *

getFontBold.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link java.lang.Boolean} object. + */ + protected static Boolean getFontBold(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getFont().getBold() != null) { + return style.getFont().getBold(); + } + if (style.getParentStyle() != null) { + return getFontBold(style.getParentStyle()); + } + return null; + } + + /** + *

getFontItalic.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link java.lang.Boolean} object. + */ + protected static Boolean getFontItalic(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getFont().getItalic() != null) { + return style.getFont().getItalic(); + } + if (style.getParentStyle() != null) { + return getFontItalic(style.getParentStyle()); + } + return null; + } + + /** + *

getFontUnderline.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link java.lang.Boolean} object. + */ + protected static Boolean getFontUnderline(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getFont().getUnderline() != null) { + return style.getFont().getUnderline(); + } + if (style.getParentStyle() != null) { + return getFontUnderline(style.getParentStyle()); + } + return null; + } + + /** + *

getFontStrikeThrough.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link java.lang.Boolean} object. + */ + protected static Boolean getFontStrikeThrough(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getFont().getStrikeThrough() != null) { + return style.getFont().getStrikeThrough(); + } + if (style.getParentStyle() != null) { + return getFontStrikeThrough(style.getParentStyle()); + } + return null; + } + + /** + *

getPdfFontName.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link java.lang.String} object. + */ + protected static String getPdfFontName(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getFont().getPdfFontName() != null) { + return style.getFont().getPdfFontName(); + } + if (style.getParentStyle() != null) { + return getPdfFontName(style.getParentStyle()); + } + return null; + } + + /** + *

getPdfEncoding.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link java.lang.String} object. + */ + protected static String getPdfEncoding(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getFont().getPdfEncoding() != null) { + return style.getFont().getPdfEncoding(); + } + if (style.getParentStyle() != null) { + return getPdfEncoding(style.getParentStyle()); + } + return null; + } + + /** + *

getPdfEmbedded.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link java.lang.Boolean} object. + */ + protected static Boolean getPdfEmbedded(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getFont().getPdfEmbedded() != null) { + return style.getFont().getPdfEmbedded(); + } + if (style.getParentStyle() != null) { + return getPdfEmbedded(style.getParentStyle()); + } + return null; + } + + /** + *

getHorizontalPadding.

+ * + * @param style a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignStyle} object. + * @return a int. + */ + public static int getHorizontalPadding(DRIDesignStyle style) { + return getLeftPadding(style) + getRightPadding(style) + getLeftIndent(style) + getRightIndent(style); + } + + /** + *

getVerticalPadding.

+ * + * @param style a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignStyle} object. + * @return a int. + */ + public static int getVerticalPadding(DRIDesignStyle style) { + return getTopPadding(style) + getBottomPadding(style) + getFirstLineIndent(style); + } + + private static Integer getTopPadding(DRIDesignStyle style) { + if (style == null) { + return 0; + } + if (style.getPadding() != null && style.getPadding().getTop() != null) { + return style.getPadding().getTop(); + } + if (style.getParentStyle() != null) { + return getTopPadding(style.getParentStyle()); + } + return 0; + } + + private static Integer getBottomPadding(DRIDesignStyle style) { + if (style == null) { + return 0; + } + if (style.getPadding() != null && style.getPadding().getBottom() != null) { + return style.getPadding().getBottom(); + } + if (style.getParentStyle() != null) { + return getBottomPadding(style.getParentStyle()); + } + return 0; + } + + private static Integer getLeftPadding(DRIDesignStyle style) { + if (style == null) { + return 0; + } + if (style.getPadding() != null && style.getPadding().getLeft() != null) { + return style.getPadding().getLeft(); + } + if (style.getParentStyle() != null) { + return getLeftPadding(style.getParentStyle()); + } + return 0; + } + + private static Integer getRightPadding(DRIDesignStyle style) { + if (style == null) { + return 0; + } + if (style.getPadding() != null && style.getPadding().getRight() != null) { + return style.getPadding().getRight(); + } + if (style.getParentStyle() != null) { + return getRightPadding(style.getParentStyle()); + } + return 0; + } + + private static Integer getFirstLineIndent(DRIDesignStyle style) { + if (style == null) { + return 0; + } + if (style.getParagraph() != null && style.getParagraph().getFirstLineIndent() != null) { + return style.getParagraph().getFirstLineIndent(); + } + if (style.getParentStyle() != null) { + return getFirstLineIndent(style.getParentStyle()); + } + return 0; + } + + private static Integer getLeftIndent(DRIDesignStyle style) { + if (style == null) { + return 0; + } + if (style.getParagraph() != null && style.getParagraph().getLeftIndent() != null) { + return style.getParagraph().getLeftIndent(); + } + if (style.getParentStyle() != null) { + return getLeftIndent(style.getParentStyle()); + } + return 0; + } + + private static Integer getRightIndent(DRIDesignStyle style) { + if (style == null) { + return 0; + } + if (style.getParagraph() != null && style.getParagraph().getRightIndent() != null) { + return style.getParagraph().getRightIndent(); + } + if (style.getParentStyle() != null) { + return getRightIndent(style.getParentStyle()); + } + return 0; + } + + /** + *

getPattern.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link java.lang.String} object. + */ + public static String getPattern(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getPattern() != null) { + return style.getPattern(); + } + if (style.getParentStyle() != null) { + return getPattern(style.getParentStyle()); + } + return null; + } + + /** + *

getHorizontalTextAlignment.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public static HorizontalTextAlignment getHorizontalTextAlignment(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getHorizontalTextAlignment() != null) { + return style.getHorizontalTextAlignment(); + } + if (style.getParentStyle() != null) { + return getHorizontalTextAlignment(style.getParentStyle()); + } + return null; + } + + /** + *

getHorizontalImageAlignment.

+ * + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public static HorizontalImageAlignment getHorizontalImageAlignment(DRDesignStyle style) { + if (style == null) { + return null; + } + if (style.getHorizontalImageAlignment() != null) { + return style.getHorizontalImageAlignment(); + } + if (style.getParentStyle() != null) { + return getHorizontalImageAlignment(style.getParentStyle()); + } + return null; + } + + /** + *

getBackgroundColor.

+ * + * @param reportStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + * @param transform a {@link software.xdev.dynamicreports.design.transformation.StyleTransform} object. + * @return a {@link java.awt.Color} object. + */ + public static Color getBackgroundColor(DRIReportStyle reportStyle, StyleTransform transform) { + if (reportStyle == null) { + return null; + } + DRIStyle style = transform.getStyle(reportStyle); + if (style.getBackgroundColor() != null) { + return style.getBackgroundColor(); + } + if (style.getParentStyle() != null) { + return getBackgroundColor(style.getParentStyle(), transform); + } + return null; + } + + /** + *

mergeColors.

+ * + * @param color1 a {@link java.awt.Color} object. + * @param color2 a {@link java.awt.Color} object. + * @param percent a float. + * @return a {@link java.awt.Color} object. + */ + public static Color mergeColors(Color color1, Color color2, float percent) { + float amount = 1.0f - percent; + int r = (int) (color1.getRed() * amount + color2.getRed() * percent); + int g = (int) (color1.getGreen() * amount + color2.getGreen() * percent); + int b = (int) (color1.getBlue() * amount + color2.getBlue() * percent); + int a = (int) (color1.getAlpha() * amount + color2.getAlpha() * percent); + return new Color(r, g, b, a); + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/StyleTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/StyleTransform.java new file mode 100644 index 0000000..05ebc57 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/StyleTransform.java @@ -0,0 +1,440 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; + +import software.xdev.dynamicreports.design.base.style.DRDesignBaseStyle; +import software.xdev.dynamicreports.design.base.style.DRDesignBorder; +import software.xdev.dynamicreports.design.base.style.DRDesignConditionalStyle; +import software.xdev.dynamicreports.design.base.style.DRDesignFont; +import software.xdev.dynamicreports.design.base.style.DRDesignPadding; +import software.xdev.dynamicreports.design.base.style.DRDesignParagraph; +import software.xdev.dynamicreports.design.base.style.DRDesignPen; +import software.xdev.dynamicreports.design.base.style.DRDesignStyle; +import software.xdev.dynamicreports.design.base.style.DRDesignTabStop; +import software.xdev.dynamicreports.design.constant.DefaultStyleType; +import software.xdev.dynamicreports.design.definition.style.DRIDesignStyle; +import software.xdev.dynamicreports.design.definition.style.DRIDesignTabStop; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.report.base.style.DRBaseStyle; +import software.xdev.dynamicreports.report.base.style.DRBorder; +import software.xdev.dynamicreports.report.base.style.DRFont; +import software.xdev.dynamicreports.report.base.style.DRPadding; +import software.xdev.dynamicreports.report.base.style.DRParagraph; +import software.xdev.dynamicreports.report.base.style.DRPen; +import software.xdev.dynamicreports.report.definition.style.DRIBaseStyle; +import software.xdev.dynamicreports.report.definition.style.DRIBorder; +import software.xdev.dynamicreports.report.definition.style.DRIConditionalStyle; +import software.xdev.dynamicreports.report.definition.style.DRIFont; +import software.xdev.dynamicreports.report.definition.style.DRIPadding; +import software.xdev.dynamicreports.report.definition.style.DRIParagraph; +import software.xdev.dynamicreports.report.definition.style.DRIPen; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; +import software.xdev.dynamicreports.report.definition.style.DRITabStop; +import software.xdev.dynamicreports.report.definition.style.DRITemplateStyle; +import software.xdev.dynamicreports.report.exception.DRException; + + +/** + *

StyleTransform class.

+ * + * @author Ricardo Mariaca + */ +public class StyleTransform +{ + private final DesignTransformAccessor accessor; + private Map styles; + private Map designStyles; + private Map templateStyles; + + /** + *

Constructor for StyleTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public StyleTransform(final DesignTransformAccessor accessor) + { + this.accessor = accessor; + this.init(); + } + + private void init() + { + this.styles = new LinkedHashMap<>(); + this.designStyles = new HashMap<>(); + this.templateStyles = this.accessor.getTemplateTransform().getTemplateStyles(); + } + + private DRDesignStyle transformStyle(final DRIReportStyle style, final boolean textStyle) throws DRException + { + return this.transformStyle(style, textStyle, DefaultStyleType.NONE); + } + + /** + *

transformStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + * @param textStyle a boolean. + * @param defaultStyleType a {@link software.xdev.dynamicreports.design.constant.DefaultStyleType} object. + * @return a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignStyle transformStyle( + final DRIReportStyle style, + final boolean textStyle, + final DefaultStyleType defaultStyleType) throws DRException + { + if(style == null) + { + return this.getDefaultStyle(defaultStyleType); + } + final String styleName = style.hashCode() + "_" + textStyle; + if(this.designStyles.containsKey(styleName)) + { + return this.designStyles.get(styleName); + } + + final DRDesignStyle designStyle = this.style(this.getStyle(style), textStyle, defaultStyleType); + if(textStyle) + { + if(StyleResolver.getFontName(designStyle) == null) + { + designStyle.getFont().setFontName(this.accessor.getTemplateTransform().getDefaultFontName()); + } + if(StyleResolver.getFontSize(designStyle) == null) + { + designStyle.getFont().setFontSize(this.accessor.getTemplateTransform().getDefaultFontSize()); + } + if(StyleResolver.getFontBold(designStyle) == null) + { + designStyle.getFont().setBold(this.accessor.getTemplateTransform().getDefaultFontBold()); + } + if(StyleResolver.getFontItalic(designStyle) == null) + { + designStyle.getFont().setItalic(this.accessor.getTemplateTransform().getDefaultFontItalic()); + } + if(StyleResolver.getFontUnderline(designStyle) == null) + { + designStyle.getFont().setUnderline(this.accessor.getTemplateTransform().getDefaultFontUnderline()); + } + if(StyleResolver.getFontStrikeThrough(designStyle) == null) + { + designStyle.getFont() + .setStrikeThrough(this.accessor.getTemplateTransform().getDefaultFontStrikeThrough()); + } + if(StyleResolver.getPdfFontName(designStyle) == null) + { + designStyle.getFont().setPdfFontName(this.accessor.getTemplateTransform().getDefaultFontPdfFontName()); + } + if(StyleResolver.getPdfEncoding(designStyle) == null) + { + designStyle.getFont().setPdfEncoding(this.accessor.getTemplateTransform().getDefaultFontPdfEncoding()); + } + if(StyleResolver.getPdfEmbedded(designStyle) == null) + { + designStyle.getFont().setPdfEmbedded(this.accessor.getTemplateTransform().getDefaultFontPdfEmbedded()); + } + } + this.addStyle(styleName, designStyle); + return designStyle; + } + + /** + *

transformFont.

+ * + * @param font a {@link software.xdev.dynamicreports.report.definition.style.DRIFont} object. + * @return a {@link software.xdev.dynamicreports.design.base.style.DRDesignFont} object. + */ + protected DRDesignFont transformFont(final DRIFont font) + { + if(font == null) + { + return null; + } + + final DRDesignFont designFont = new DRDesignFont(); + designFont.setFontName(font.getFontName()); + designFont.setFontSize(font.getFontSize()); + designFont.setBold(font.getBold()); + designFont.setItalic(font.getItalic()); + designFont.setUnderline(font.getUnderline()); + designFont.setStrikeThrough(font.getStrikeThrough()); + designFont.setPdfFontName(font.getPdfFontName()); + designFont.setPdfEncoding(font.getPdfEncoding()); + designFont.setPdfEmbedded(font.getPdfEmbedded()); + return designFont; + } + + private DRDesignStyle style(final DRIStyle style, final boolean textStyle, final DefaultStyleType defaultStyleType) + throws DRException + { + final DRDesignStyle designStyle; + if(StringUtils.isBlank(style.getName())) + { + designStyle = new DRDesignStyle(); + } + else + { + designStyle = new DRDesignStyle(style.getName()); + } + this.baseStyle(designStyle, style); + if(style.getParentStyle() != null) + { + designStyle.setParentStyle(this.transformStyle(style.getParentStyle(), textStyle, defaultStyleType)); + } + for(final DRIConditionalStyle conditionalStyle : style.getConditionalStyles()) + { + designStyle.addConditionalStyle(this.conditionalStyle(conditionalStyle)); + } + return designStyle; + } + + /** + *

getStyle.

+ * + * @param reportStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIStyle} object. + */ + protected DRIStyle getStyle(final DRIReportStyle reportStyle) + { + if(reportStyle == null) + { + return null; + } + if(reportStyle instanceof DRIStyle) + { + return (DRIStyle)reportStyle; + } + if(reportStyle instanceof DRITemplateStyle) + { + final String name = ((DRITemplateStyle)reportStyle).getName(); + final DRIStyle style = this.templateStyles.get(name); + if(style == null) + { + throw new DRDesignReportException("Template style " + name + " not found"); + } + return style; + } + throw new DRDesignReportException("Style " + reportStyle.getClass().getName() + " not supported"); + } + + /** + *

transformTemplateStyles.

+ * + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public void transformTemplateStyles() throws DRException + { + for(final DRIStyle style : this.templateStyles.values()) + { + if(this.styles.containsKey(style.getName())) + { + continue; + } + this.transformStyle(style, false); + } + } + + private DRDesignConditionalStyle conditionalStyle(final DRIConditionalStyle conditionalStyle) throws DRException + { + final DRDesignConditionalStyle designConditionalStyle = new DRDesignConditionalStyle(); + this.baseStyle(designConditionalStyle, conditionalStyle); + designConditionalStyle.setConditionExpression(this.accessor.getExpressionTransform() + .transformExpression(conditionalStyle.getConditionExpression())); + designConditionalStyle.setDataset(this.accessor.getExpressionTransform().getDataset()); + return designConditionalStyle; + } + + private void baseStyle(final DRDesignBaseStyle designBaseStyle, final DRIBaseStyle baseStyle) throws DRException + { + designBaseStyle.setForegroundColor(baseStyle.getForegroundColor()); + designBaseStyle.setBackgroundColor(baseStyle.getBackgroundColor()); + designBaseStyle.setRadius(baseStyle.getRadius()); + designBaseStyle.setImageScale(baseStyle.getImageScale()); + designBaseStyle.setHorizontalImageAlignment(baseStyle.getHorizontalImageAlignment()); + designBaseStyle.setVerticalImageAlignment(baseStyle.getVerticalImageAlignment()); + designBaseStyle.setHorizontalTextAlignment(baseStyle.getHorizontalTextAlignment()); + designBaseStyle.setVerticalTextAlignment(baseStyle.getVerticalTextAlignment()); + designBaseStyle.setBorder(this.border(baseStyle.getBorder())); + designBaseStyle.setPadding(this.padding(baseStyle.getPadding())); + designBaseStyle.setFont(this.transformFont(baseStyle.getFont())); + designBaseStyle.setRotation(baseStyle.getRotation()); + designBaseStyle.setPattern(baseStyle.getPattern()); + designBaseStyle.setMarkup(baseStyle.getMarkup()); + designBaseStyle.setParagraph(this.paragraph(baseStyle.getParagraph())); + designBaseStyle.setLinePen(this.pen(baseStyle.getLinePen())); + } + + private DRDesignParagraph paragraph(final DRIParagraph paragraph) + { + final DRDesignParagraph designParagraph = new DRDesignParagraph(); + designParagraph.setLineSpacing(paragraph.getLineSpacing()); + designParagraph.setLineSpacingSize(paragraph.getLineSpacingSize()); + designParagraph.setFirstLineIndent(paragraph.getFirstLineIndent()); + designParagraph.setLeftIndent(paragraph.getLeftIndent()); + designParagraph.setRightIndent(paragraph.getRightIndent()); + designParagraph.setSpacingBefore(paragraph.getSpacingBefore()); + designParagraph.setSpacingAfter(paragraph.getSpacingAfter()); + designParagraph.setTabStopWidth(paragraph.getTabStopWidth()); + final List designTabStops = new ArrayList<>(); + for(final DRITabStop tabStop : paragraph.getTabStops()) + { + final DRDesignTabStop designTabStop = new DRDesignTabStop(); + designTabStop.setPosition(tabStop.getPosition()); + designTabStop.setAlignment(tabStop.getAlignment()); + designTabStops.add(designTabStop); + } + designParagraph.setTabStops(designTabStops); + return designParagraph; + } + + private DRDesignBorder border(final DRIBorder border) + { + final DRDesignBorder designBorder = new DRDesignBorder(); + designBorder.setTopPen(this.pen(border.getTopPen())); + designBorder.setLeftPen(this.pen(border.getLeftPen())); + designBorder.setBottomPen(this.pen(border.getBottomPen())); + designBorder.setRightPen(this.pen(border.getRightPen())); + return designBorder; + } + + private DRDesignPadding padding(final DRIPadding padding) + { + final DRDesignPadding designPadding = new DRDesignPadding(); + designPadding.setTop(padding.getTop()); + designPadding.setLeft(padding.getLeft()); + designPadding.setBottom(padding.getBottom()); + designPadding.setRight(padding.getRight()); + return designPadding; + } + + /** + *

pen.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.definition.style.DRIPen} object. + * @return a {@link software.xdev.dynamicreports.design.base.style.DRDesignPen} object. + */ + protected DRDesignPen pen(final DRIPen pen) + { + if(pen == null) + { + return null; + } + final DRDesignPen designPen = new DRDesignPen(); + designPen.setLineWidth(pen.getLineWidth()); + designPen.setLineStyle(pen.getLineStyle()); + designPen.setLineColor(pen.getLineColor()); + return designPen; + } + + /** + *

getDefaultStyle.

+ * + * @param defaultStyleType a {@link software.xdev.dynamicreports.design.constant.DefaultStyleType} object. + * @return a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignStyle getDefaultStyle(final DefaultStyleType defaultStyleType) throws DRException + { + final TemplateTransform templateTransform = this.accessor.getTemplateTransform(); + switch(defaultStyleType) + { + case NONE: + return null; + case TEXT: + return this.transformStyle(templateTransform.getTextStyle(), true); + case COLUMN: + return this.transformStyle(templateTransform.getColumnStyle(true), true); + case COLUMN_TITLE: + return this.transformStyle(templateTransform.getColumnTitleStyle(), true); + case GROUP: + return this.transformStyle(templateTransform.getGroupStyle(), true); + case GROUP_TITLE: + return this.transformStyle(templateTransform.getGroupTitleStyle(), true); + case SUBTOTAL: + return this.transformStyle(templateTransform.getSubtotalStyle(), true); + case IMAGE: + return this.transformStyle(templateTransform.getImageStyle(), false); + default: + throw new DRDesignReportException("Default style type " + defaultStyleType.name() + " not supported"); + } + } + + private void addStyle(final String styleName, final DRDesignStyle designStyle) + { + if(designStyle == null) + { + return; + } + if(this.styles.containsKey(designStyle.getName())) + { + if(!this.styles.get(designStyle.getName()).equals(designStyle)) + { + throw new DRDesignReportException("Duplicate declaration of style \"" + designStyle.getName() + "\""); + } + return; + } + this.styles.put(designStyle.getName(), designStyle); + this.designStyles.put(styleName, designStyle); + } + + /** + *

copyStyle.

+ * + * @param toStyle a {@link software.xdev.dynamicreports.report.base.style.DRBaseStyle} object. + * @param fromStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIBaseStyle} object. + */ + public void copyStyle(final DRBaseStyle toStyle, final DRIBaseStyle fromStyle) + { + toStyle.setForegroundColor(fromStyle.getForegroundColor()); + toStyle.setBackgroundColor(fromStyle.getBackgroundColor()); + toStyle.setRadius(fromStyle.getRadius()); + toStyle.setImageScale(fromStyle.getImageScale()); + toStyle.setHorizontalImageAlignment(fromStyle.getHorizontalImageAlignment()); + toStyle.setVerticalImageAlignment(fromStyle.getVerticalImageAlignment()); + toStyle.setHorizontalTextAlignment(fromStyle.getHorizontalTextAlignment()); + toStyle.setVerticalTextAlignment(fromStyle.getVerticalTextAlignment()); + toStyle.setBorder((DRBorder)fromStyle.getBorder()); + toStyle.setPadding((DRPadding)fromStyle.getPadding()); + toStyle.setFont((DRFont)fromStyle.getFont()); + toStyle.setRotation(fromStyle.getRotation()); + toStyle.setPattern(fromStyle.getPattern()); + toStyle.setMarkup(fromStyle.getMarkup()); + toStyle.setParagraph((DRParagraph)fromStyle.getParagraph()); + toStyle.setLinePen((DRPen)fromStyle.getLinePen()); + } + + /** + *

Getter for the field styles.

+ * + * @return a {@link java.util.Collection} object. + */ + public Collection getStyles() + { + return this.styles.values(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/SubtotalTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/SubtotalTransform.java new file mode 100644 index 0000000..36e46cc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/SubtotalTransform.java @@ -0,0 +1,327 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.DRDesignBand; +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.design.constant.DefaultStyleType; +import software.xdev.dynamicreports.design.constant.EvaluationTime; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.report.base.component.DRFiller; +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.Position; +import software.xdev.dynamicreports.report.constant.SubtotalPosition; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import software.xdev.dynamicreports.report.definition.DRIBand; +import software.xdev.dynamicreports.report.definition.DRIGroup; +import software.xdev.dynamicreports.report.definition.DRISubtotal; +import software.xdev.dynamicreports.report.definition.column.DRIColumn; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +/** + *

SubtotalTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class SubtotalTransform { + private DesignTransformAccessor accessor; + + /** + *

Constructor for SubtotalTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public SubtotalTransform(DesignTransformAccessor accessor) { + this.accessor = accessor; + } + + // subtotals + + /** + *

transform.

+ * + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public void transform() throws DRException { + ColumnGrid title = accessor.getColumnGridTransform().createColumnGrid(); + ColumnGrid pageHeader = accessor.getColumnGridTransform().createColumnGrid(); + ColumnGrid pageFooter = accessor.getColumnGridTransform().createColumnGrid(); + ColumnGrid columnHeader = accessor.getColumnGridTransform().createColumnGrid(); + ColumnGrid columnFooter = accessor.getColumnGridTransform().createColumnGrid(); + Map groupHeader = new HashMap(); + Map groupFooter = new HashMap(); + ColumnGrid lastPageFooter = accessor.getColumnGridTransform().createColumnGrid(); + ColumnGrid summary = accessor.getColumnGridTransform().createColumnGrid(); + + HorizontalCellComponentAlignment horizontalAlignment = HorizontalCellComponentAlignment.FLOAT; + VerticalCellComponentAlignment verticalAlignment = VerticalCellComponentAlignment.TOP; + for (DRISubtotal subtotal : accessor.getReport().getSubtotals()) { + SubtotalPosition position = subtotal.getPosition(); + DRIColumn showInColumn = subtotal.getShowInColumn(); + DRDesignTextField subtotalValueComponent = valueComponent(subtotal); + DRDesignComponent subtotalComponent = subtotalValueComponent; + if (subtotal.getLabelExpression() != null) { + subtotalComponent = subtotalWithLabelComponent(subtotal, subtotalComponent); + } + switch (position) { + case TITLE: + title.addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + break; + case PAGE_HEADER: + pageHeader.addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + break; + case PAGE_FOOTER: + pageFooter.addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + break; + case COLUMN_HEADER: + columnHeader.addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + break; + case COLUMN_FOOTER: + columnFooter.addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + break; + case GROUP_HEADER: + EvaluationTime evaluationTime = accessor.getComponentTransform().detectEvaluationTime(subtotalValueComponent.getValueExpression()); + if (evaluationTime == null || !evaluationTime.equals(EvaluationTime.AUTO)) { + subtotalValueComponent.setEvaluationTime(EvaluationTime.GROUP); + subtotalValueComponent.setEvaluationGroup(accessor.getGroupTransform().getGroup(subtotal.getGroup())); + } + getGroupGrid(subtotal.getGroup(), groupHeader).addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + break; + case GROUP_FOOTER: + evaluationTime = accessor.getComponentTransform().detectEvaluationTime(subtotalValueComponent.getValueExpression()); + if (evaluationTime == null || !evaluationTime.equals(EvaluationTime.AUTO)) { + subtotalValueComponent.setEvaluationTime(EvaluationTime.NOW); + } + getGroupGrid(subtotal.getGroup(), groupFooter).addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + break; + case FIRST_GROUP_HEADER: + DRIGroup firstGroup = accessor.getGroupTransform().getFirstGroup(); + evaluationTime = accessor.getComponentTransform().detectEvaluationTime(subtotalValueComponent.getValueExpression()); + if (evaluationTime == null || !evaluationTime.equals(EvaluationTime.AUTO)) { + subtotalValueComponent.setEvaluationTime(EvaluationTime.GROUP); + subtotalValueComponent.setEvaluationGroup(accessor.getGroupTransform().getGroup(firstGroup)); + } + if (firstGroup != null) { + getGroupGrid(firstGroup, groupHeader).addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + } + break; + case FIRST_GROUP_FOOTER: + firstGroup = accessor.getGroupTransform().getFirstGroup(); + if (firstGroup != null) { + evaluationTime = accessor.getComponentTransform().detectEvaluationTime(subtotalValueComponent.getValueExpression()); + if (evaluationTime == null || !evaluationTime.equals(EvaluationTime.AUTO)) { + subtotalValueComponent.setEvaluationTime(EvaluationTime.NOW); + } + getGroupGrid(firstGroup, groupFooter).addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + } + break; + case LAST_GROUP_HEADER: + DRIGroup lastGroup = accessor.getGroupTransform().getLastGroup(); + evaluationTime = accessor.getComponentTransform().detectEvaluationTime(subtotalValueComponent.getValueExpression()); + if (evaluationTime == null || !evaluationTime.equals(EvaluationTime.AUTO)) { + subtotalValueComponent.setEvaluationTime(EvaluationTime.GROUP); + subtotalValueComponent.setEvaluationGroup(accessor.getGroupTransform().getGroup(lastGroup)); + } + if (lastGroup != null) { + getGroupGrid(lastGroup, groupHeader).addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + } + break; + case LAST_GROUP_FOOTER: + lastGroup = accessor.getGroupTransform().getLastGroup(); + if (lastGroup != null) { + evaluationTime = accessor.getComponentTransform().detectEvaluationTime(subtotalValueComponent.getValueExpression()); + if (evaluationTime == null || !evaluationTime.equals(EvaluationTime.AUTO)) { + subtotalValueComponent.setEvaluationTime(EvaluationTime.NOW); + } + getGroupGrid(lastGroup, groupFooter).addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + } + break; + case LAST_PAGE_FOOTER: + lastPageFooter.addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + break; + case SUMMARY: + subtotalValueComponent.setEvaluationTime(EvaluationTime.NOW); + summary.addComponent(showInColumn, horizontalAlignment, verticalAlignment, subtotalComponent); + break; + default: + throw new DRDesignReportException("Subtotal position " + position.name() + " not supported"); + } + } + + DRFiller filler = null; + TemplateTransform templateTransform = accessor.getTemplateTransform(); + if (templateTransform.getPageColumnsPerPage() > 1) { + int fillerWidth = accessor.getPageTransform().getMaxBandWidth() - accessor.getPageTransform().getPage().getColumnWidth(); + filler = new DRFiller(); + filler.setWidth(fillerWidth); + } + + addAfterBandComponent(accessor.getBandTransform().getTitleBand(), title, filler); + addAfterBandComponent(accessor.getBandTransform().getPageHeaderBand(), pageHeader, filler); + addBeforeBandComponent(accessor.getBandTransform().getPageFooterBand(), pageFooter, filler); + addAfterBandComponent(accessor.getBandTransform().getColumnHeaderBand(), columnHeader, null); + addBeforeBandComponent(accessor.getBandTransform().getColumnFooterBand(), columnFooter, null); + for (Entry entry : groupHeader.entrySet()) { + DRIGroup group = entry.getKey(); + DRIBand bnd = group.getHeaderBand(); + DRDesignGroup designGroup = accessor.getGroupTransform().getGroup(group); + DRDesignBand band = accessor.getBandTransform() + .band("subtotalGroupHeader", bnd, templateTransform.getGroupHeaderSplitType(bnd), templateTransform.getGroupHeaderStyle(bnd), + templateTransform.getGroupHeaderBackgroundComponent(bnd)); + addAfterBandComponent(band, entry.getValue(), null); + setPrintGroupSubtotalsWhenExpression(group, entry.getValue()); + designGroup.addHeaderBand(band); + } + for (Entry entry : groupFooter.entrySet()) { + DRIGroup group = entry.getKey(); + DRIBand bnd = group.getFooterBand(); + DRDesignGroup designGroup = accessor.getGroupTransform().getGroup(group); + DRDesignBand band = accessor.getBandTransform() + .band("subtotalGroupFooter", bnd, templateTransform.getGroupFooterSplitType(bnd), templateTransform.getGroupFooterStyle(bnd), + templateTransform.getGroupFooterBackgroundComponent(bnd)); + addBeforeBandComponent(band, entry.getValue(), null); + setPrintGroupSubtotalsWhenExpression(group, entry.getValue()); + designGroup.addFooterBand(0, band); + } + addBeforeBandComponent(accessor.getBandTransform().getLastPageFooterBand(), lastPageFooter, filler); + addBeforeBandComponent(accessor.getBandTransform().getSummaryBand(), summary, filler); + } + + private DRDesignComponent subtotalWithLabelComponent(DRISubtotal subtotal, DRDesignComponent subtotalComponent) throws DRException { + HorizontalCellComponentAlignment horizontalAlignment = HorizontalCellComponentAlignment.FLOAT; + VerticalCellComponentAlignment verticalAlignment = VerticalCellComponentAlignment.TOP; + DRDesignList list = new DRDesignList(); + + Position labelPosition = accessor.getTemplateTransform().getSubtotalLabelPosition(subtotal); + switch (labelPosition) { + case TOP: + list.setType(ListType.VERTICAL); + list.addComponent(horizontalAlignment, verticalAlignment, labelComponent(subtotal)); + list.addComponent(horizontalAlignment, verticalAlignment, subtotalComponent); + break; + case BOTTOM: + list.setType(ListType.VERTICAL); + list.addComponent(horizontalAlignment, verticalAlignment, subtotalComponent); + list.addComponent(horizontalAlignment, verticalAlignment, labelComponent(subtotal)); + break; + case LEFT: + list.setType(ListType.HORIZONTAL); + DRDesignComponent labelComponent = labelComponent(subtotal); + if (subtotal.getLabelWidth() != null) { + labelComponent.setWidth(subtotal.getLabelWidth()); + } + HorizontalCellComponentAlignment labelHorizontalAlignment = horizontalAlignment; + if (subtotal.getLabelWidthType() != null) { + labelHorizontalAlignment = ConstantTransform.toHorizontalCellComponentAlignment(subtotal.getLabelWidthType()); + } + list.addComponent(labelHorizontalAlignment, VerticalCellComponentAlignment.EXPAND, labelComponent); + list.addComponent(horizontalAlignment, VerticalCellComponentAlignment.EXPAND, subtotalComponent); + break; + case RIGHT: + list.setType(ListType.HORIZONTAL); + labelComponent = labelComponent(subtotal); + if (subtotal.getLabelWidth() != null) { + labelComponent.setWidth(subtotal.getLabelWidth()); + } + labelHorizontalAlignment = horizontalAlignment; + if (subtotal.getLabelWidthType() != null) { + labelHorizontalAlignment = ConstantTransform.toHorizontalCellComponentAlignment(subtotal.getLabelWidthType()); + } + list.addComponent(horizontalAlignment, VerticalCellComponentAlignment.EXPAND, subtotalComponent); + list.addComponent(labelHorizontalAlignment, VerticalCellComponentAlignment.EXPAND, labelComponent); + break; + default: + throw new DRDesignReportException("Subtotal label position " + labelPosition.name() + " not supported"); + } + + return list; + } + + private ColumnGrid getGroupGrid(DRIGroup group, Map groupList) throws DRException { + if (!groupList.containsKey(group)) { + groupList.put(group, accessor.getColumnGridTransform().createColumnGrid()); + } + return groupList.get(group); + } + + private void setPrintGroupSubtotalsWhenExpression(DRIGroup group, ColumnGrid grid) throws DRException { + DRIExpression printSubtotalsWhenExpression = group.getPrintSubtotalsWhenExpression(); + if (grid.isEmpty() || printSubtotalsWhenExpression == null) { + return; + } + grid.getList().setPrintWhenExpression(accessor.getExpressionTransform().transformExpression(printSubtotalsWhenExpression)); + } + + private void addAfterBandComponent(DRDesignBand band, ColumnGrid grid, DRFiller filler) throws DRException { + if (grid.isEmpty()) { + return; + } + DRDesignList list = grid.getList(); + if (filler != null) { + list = new DRDesignList(); + list.addComponent(grid.getList()); + list.addComponent(HorizontalCellComponentAlignment.LEFT, null, accessor.getComponentTransform().filler(filler)); + } + + band.addComponent(list); + } + + private void addBeforeBandComponent(DRDesignBand band, ColumnGrid grid, DRFiller filler) throws DRException { + if (grid.isEmpty()) { + return; + } + DRDesignList list = grid.getList(); + if (filler != null) { + list = new DRDesignList(); + list.addComponent(grid.getList()); + list.addComponent(HorizontalCellComponentAlignment.LEFT, null, accessor.getComponentTransform().filler(filler)); + } + band.addComponent(0, list); + } + + // label + @SuppressWarnings("unchecked") + private DRDesignComponent labelComponent(DRISubtotal subtotal) throws DRException { + @SuppressWarnings("rawtypes") DRTextField labelField = new DRTextField(); + labelField.setValueExpression(subtotal.getLabelExpression()); + labelField.setStyle(subtotal.getLabelStyle()); + labelField.setWidth(accessor.getTemplateTransform().getColumnWidth(subtotal.getShowInColumn(), accessor.getStyleTransform().getDefaultStyle(DefaultStyleType.COLUMN))); + DRDesignTextField designLabelField = accessor.getComponentTransform().textField(labelField, DefaultStyleType.TEXT); + designLabelField.setUniqueName("column_" + subtotal.getShowInColumn().getName() + ".subtotal.label"); + return designLabelField; + } + + // value + private DRDesignTextField valueComponent(DRISubtotal subtotal) throws DRException { + DRDesignTextField designValueField = accessor.getComponentTransform().textField(subtotal.getValueField(), DefaultStyleType.SUBTOTAL); + designValueField.setUniqueName("column_" + subtotal.getShowInColumn().getName() + ".subtotal"); + designValueField.setWidth(accessor.getTemplateTransform().getColumnWidth(subtotal.getShowInColumn(), accessor.getStyleTransform().getDefaultStyle(DefaultStyleType.COLUMN))); + return designValueField; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/TableOfContentsTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/TableOfContentsTransform.java new file mode 100644 index 0000000..5b7583e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/TableOfContentsTransform.java @@ -0,0 +1,143 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import software.xdev.dynamicreports.design.base.DRDesignTableOfContentsHeading; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.design.constant.DefaultStyleType; +import software.xdev.dynamicreports.design.transformation.expressions.TocPrintWhenExpression; +import software.xdev.dynamicreports.design.transformation.expressions.TocReferenceExpression; +import software.xdev.dynamicreports.design.transformation.expressions.TocReferenceLinkExpression; +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.definition.DRIGroup; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsHeading; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.component.DRIHyperLinkComponent; +import software.xdev.dynamicreports.report.definition.component.DRITextField; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.HashMap; +import java.util.Map; + +/** + *

TableOfContentsTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class TableOfContentsTransform { + private DesignTransformAccessor accessor; + private Map levels; + + /** + *

Constructor for TableOfContentsTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public TableOfContentsTransform(DesignTransformAccessor accessor) { + this.accessor = accessor; + this.levels = new HashMap(); + } + + /** + *

componentHeading.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignTableOfContentsHeading} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignTableOfContentsHeading componentHeading(DRIComponent component) throws DRException { + DRITableOfContentsHeading tocHeading = component.getTableOfContentsHeading(); + boolean tableOfContents = accessor.isTableOfContents(); + if (tableOfContents && tocHeading != null) { + DRTextField referenceField = new DRTextField(); + int level = getLevel(tocHeading); + DRIExpression labelExpression = tocHeading.getLabelExpression(); + if (labelExpression == null && component instanceof DRITextField) { + labelExpression = ((DRITextField) component).getValueExpression(); + } + if (labelExpression == null) { + labelExpression = Expressions.text(""); + } + String expressionName = labelExpression.getName(); + DRIExpression anchorNameExpression = null; + if (component instanceof DRIHyperLinkComponent) { + anchorNameExpression = ((DRIHyperLinkComponent) component).getAnchorNameExpression(); + } + DRIExpression customValueExpression = tocHeading.getCustomValueExpression(); + referenceField.setValueExpression(new TocReferenceExpression(level, expressionName, labelExpression, anchorNameExpression, customValueExpression)); + referenceField.setAnchorNameExpression(new TocReferenceLinkExpression(expressionName, anchorNameExpression)); + referenceField.setPrintWhenExpression(component.getPrintWhenExpression()); + DRDesignTextField designReferenceField = accessor.getComponentTransform().textField(referenceField, DefaultStyleType.TEXT); + designReferenceField.setWidth(1); + designReferenceField.setHeight(1); + designReferenceField.setUniqueName(expressionName + ".tocReference"); + + DRDesignTableOfContentsHeading designTocHeading = new DRDesignTableOfContentsHeading(); + designTocHeading.setReferenceField(designReferenceField); + return designTocHeading; + } + + return null; + } + + private int getLevel(DRITableOfContentsHeading tocHeading) { + if (levels.containsKey(tocHeading)) { + return levels.get(tocHeading); + } + int level = 0; + if (tocHeading.getParentHeading() != null) { + level = getLevel(tocHeading.getParentHeading()) + 1; + } + levels.put(tocHeading, level); + return level; + } + + /** + *

groupHeading.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @param level a int. + * @return a {@link software.xdev.dynamicreports.design.base.DRDesignTableOfContentsHeading} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRDesignTableOfContentsHeading groupHeading(DRIGroup group, int level) throws DRException { + boolean tableOfContents = accessor.isTableOfContents(); + boolean isAddGroupToTableOfContents = accessor.getTemplateTransform().isAddGroupToTableOfContents(group); + if (tableOfContents && isAddGroupToTableOfContents) { + DRTextField referenceField = new DRTextField(); + DRITextField valueField = group.getValueField(); + referenceField.setValueExpression(new TocReferenceExpression(level, group.getName(), valueField.getValueExpression(), valueField.getAnchorNameExpression(), null)); + referenceField.setAnchorNameExpression(new TocReferenceLinkExpression(group.getName(), valueField.getAnchorNameExpression())); + referenceField.setPrintWhenExpression(new TocPrintWhenExpression(valueField.getValueExpression())); + DRDesignTextField designReferenceField = accessor.getComponentTransform().textField(referenceField, DefaultStyleType.TEXT); + designReferenceField.setWidth(0); + designReferenceField.setHeight(0); + designReferenceField.setUniqueName("group_" + group.getName() + ".tocReference"); + + DRDesignTableOfContentsHeading designTocHeading = new DRDesignTableOfContentsHeading(); + designTocHeading.setReferenceField(designReferenceField); + return designTocHeading; + } + + return null; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/TemplateTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/TemplateTransform.java new file mode 100644 index 0000000..450e8f9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/TemplateTransform.java @@ -0,0 +1,3572 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCell; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCellContent; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabColumnGroup; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabRowGroup; +import software.xdev.dynamicreports.design.base.style.DRDesignStyle; +import software.xdev.dynamicreports.design.constant.DefaultStyleType; +import software.xdev.dynamicreports.design.definition.DRIDesignBand; +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; +import software.xdev.dynamicreports.design.definition.DRIDesignPage; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.jasper.base.tableofcontents.JasperTocHeading; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.constant.ComponentPositionType; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; +import software.xdev.dynamicreports.report.constant.CrosstabTotalPosition; +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.Position; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.constant.StretchType; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.defaults.Defaults; +import software.xdev.dynamicreports.report.definition.DRIBand; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.DRIGroup; +import software.xdev.dynamicreports.report.definition.DRIMargin; +import software.xdev.dynamicreports.report.definition.DRIReport; +import software.xdev.dynamicreports.report.definition.DRIReportTemplate; +import software.xdev.dynamicreports.report.definition.DRISubtotal; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer; +import software.xdev.dynamicreports.report.definition.DRITemplateDesign; +import software.xdev.dynamicreports.report.definition.column.DRIBooleanColumn; +import software.xdev.dynamicreports.report.definition.column.DRIColumn; +import software.xdev.dynamicreports.report.definition.column.DRIValueColumn; +import software.xdev.dynamicreports.report.definition.component.DRIBooleanField; +import software.xdev.dynamicreports.report.definition.component.DRIBreak; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.component.DRIDimensionComponent; +import software.xdev.dynamicreports.report.definition.component.DRIEllipse; +import software.xdev.dynamicreports.report.definition.component.DRIFiller; +import software.xdev.dynamicreports.report.definition.component.DRIGenericElement; +import software.xdev.dynamicreports.report.definition.component.DRIImage; +import software.xdev.dynamicreports.report.definition.component.DRILine; +import software.xdev.dynamicreports.report.definition.component.DRIList; +import software.xdev.dynamicreports.report.definition.component.DRIMap; +import software.xdev.dynamicreports.report.definition.component.DRIMultiPageList; +import software.xdev.dynamicreports.report.definition.component.DRIPageXofY; +import software.xdev.dynamicreports.report.definition.component.DRIRectangle; +import software.xdev.dynamicreports.report.definition.component.DRISubreport; +import software.xdev.dynamicreports.report.definition.component.DRITextField; +import software.xdev.dynamicreports.report.definition.component.DRIXyList; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabMeasure; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabVariable; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.definition.style.DRISimpleStyle; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; +import software.xdev.dynamicreports.report.exception.DRException; + + +/** + *

TemplateTransform class.

+ * + * @author Ricardo Mariaca, Jan Moxter + */ +public class TemplateTransform +{ + private final DRIReport report; + private final DesignTransformAccessor accessor; + private final DRIReportTemplate template; + private final DRITemplateDesign templateDesign; + + /** + *

Constructor for TemplateTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + */ + public TemplateTransform(final DesignTransformAccessor accessor) + { + this.accessor = accessor; + this.report = accessor.getReport(); + this.template = this.report.getTemplate(); + this.templateDesign = this.report.getTemplateDesign(); + } + + /** + *

getReportName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getReportName() + { + if(this.report.getReportName() != null) + { + return this.report.getReportName(); + } + if(this.templateDesign.getReportName() != null) + { + return this.templateDesign.getReportName(); + } + return Defaults.getDefaults().getReportName(); + } + + /** + *

getLocale.

+ * + * @return a {@link java.util.Locale} object. + */ + public Locale getLocale() + { + if(this.report.getLocale() != null) + { + return this.report.getLocale(); + } + if(this.template.getLocale() != null) + { + return this.template.getLocale(); + } + return Defaults.getDefaults().getLocale(); + } + + /** + *

isShowColumnTitle.

+ * + * @return a boolean. + */ + protected boolean isShowColumnTitle() + { + if(this.report.getShowColumnTitle() != null) + { + return this.report.getShowColumnTitle(); + } + if(this.template.getShowColumnTitle() != null) + { + return this.template.getShowColumnTitle(); + } + return Defaults.getDefaults().isShowColumnTitle(); + } + + /** + *

isShowColumnValues.

+ * + * @return a boolean. + */ + protected boolean isShowColumnValues() + { + if(this.report.getShowColumnValues() != null) + { + return this.report.getShowColumnValues(); + } + if(this.template.getShowColumnValues() != null) + { + return this.template.getShowColumnValues(); + } + return Defaults.getDefaults().isShowColumnValues(); + } + + /** + *

getResourceBundleName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getResourceBundleName() + { + if(this.report.getResourceBundleName() != null) + { + return this.report.getResourceBundleName(); + } + if(this.templateDesign.getResourceBundleName() != null) + { + return this.templateDesign.getResourceBundleName(); + } + return null; + } + + /** + *

isIgnorePagination.

+ * + * @return a boolean. + */ + public boolean isIgnorePagination() + { + if(this.report.getIgnorePagination() != null) + { + return this.report.getIgnorePagination(); + } + if(this.templateDesign.getIgnorePagination() != null) + { + return this.templateDesign.getIgnorePagination(); + } + if(this.template.getIgnorePagination() != null) + { + return this.template.getIgnorePagination(); + } + return Defaults.getDefaults().isIgnorePagination(); + } + + /** + *

getWhenNoDataType.

+ * + * @param emptyDetail a boolean. + * @param noDataBand a {@link software.xdev.dynamicreports.design.definition.DRIDesignBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.WhenNoDataType} object. + */ + public WhenNoDataType getWhenNoDataType(final boolean emptyDetail, final DRIDesignBand noDataBand) + { + if(this.report.getWhenNoDataType() != null) + { + return this.report.getWhenNoDataType(); + } + if(this.templateDesign.getWhenNoDataType() != null) + { + return this.templateDesign.getWhenNoDataType(); + } + if(this.template.getWhenNoDataType() != null) + { + return this.template.getWhenNoDataType(); + } + if(noDataBand != null) + { + return WhenNoDataType.NO_DATA_SECTION; + } + if(emptyDetail) + { + return WhenNoDataType.ALL_SECTIONS_NO_DETAIL; + } + return Defaults.getDefaults().getWhenNoDataType(); + } + + /** + *

getWhenResourceMissingType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + */ + public WhenResourceMissingType getWhenResourceMissingType() + { + if(this.report.getWhenResourceMissingType() != null) + { + return this.report.getWhenResourceMissingType(); + } + if(this.templateDesign.getWhenResourceMissingType() != null) + { + return this.templateDesign.getWhenResourceMissingType(); + } + if(this.template.getWhenResourceMissingType() != null) + { + return this.template.getWhenResourceMissingType(); + } + return Defaults.getDefaults().getWhenResourceMissingType(); + } + + /** + *

isTitleOnANewPage.

+ * + * @return a boolean. + */ + public boolean isTitleOnANewPage() + { + if(this.report.getTitleOnANewPage() != null) + { + return this.report.getTitleOnANewPage(); + } + if(this.templateDesign.getTitleOnANewPage() != null) + { + return this.templateDesign.getTitleOnANewPage(); + } + if(this.template.getTitleOnANewPage() != null) + { + return this.template.getTitleOnANewPage(); + } + return Defaults.getDefaults().isTitleOnANewPage(); + } + + /** + *

isSummaryOnANewPage.

+ * + * @return a boolean. + */ + public boolean isSummaryOnANewPage() + { + if(this.report.getSummaryOnANewPage() != null) + { + return this.report.getSummaryOnANewPage(); + } + if(this.templateDesign.getSummaryOnANewPage() != null) + { + return this.templateDesign.getSummaryOnANewPage(); + } + if(this.template.getSummaryOnANewPage() != null) + { + return this.template.getSummaryOnANewPage(); + } + return Defaults.getDefaults().isSummaryOnANewPage(); + } + + /** + *

isSummaryWithPageHeaderAndFooter.

+ * + * @return a boolean. + */ + public boolean isSummaryWithPageHeaderAndFooter() + { + if(this.report.getSummaryWithPageHeaderAndFooter() != null) + { + return this.report.getSummaryWithPageHeaderAndFooter(); + } + if(this.templateDesign.getSummaryWithPageHeaderAndFooter() != null) + { + return this.templateDesign.getSummaryWithPageHeaderAndFooter(); + } + if(this.template.getSummaryWithPageHeaderAndFooter() != null) + { + return this.template.getSummaryWithPageHeaderAndFooter(); + } + return Defaults.getDefaults().isSummaryWithPageHeaderAndFooter(); + } + + /** + *

isFloatColumnFooter.

+ * + * @return a boolean. + */ + public boolean isFloatColumnFooter() + { + if(this.report.getFloatColumnFooter() != null) + { + return this.report.getFloatColumnFooter(); + } + if(this.templateDesign.getFloatColumnFooter() != null) + { + return this.templateDesign.getFloatColumnFooter(); + } + if(this.template.getFloatColumnFooter() != null) + { + return this.template.getFloatColumnFooter(); + } + return Defaults.getDefaults().isFloatColumnFooter(); + } + + /** + *

getPrintOrder.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Orientation} object. + */ + public Orientation getPrintOrder() + { + if(this.report.getPrintOrder() != null) + { + return this.report.getPrintOrder(); + } + if(this.template.getPrintOrder() != null) + { + return this.template.getPrintOrder(); + } + return Defaults.getDefaults().getPrintOrder(); + } + + /** + *

getColumnDirection.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public RunDirection getColumnDirection() + { + if(this.report.getColumnDirection() != null) + { + return this.report.getColumnDirection(); + } + if(this.template.getColumnDirection() != null) + { + return this.template.getColumnDirection(); + } + return Defaults.getDefaults().getColumnDirection(); + } + + /** + *

getLanguage.

+ * + * @return a {@link java.lang.String} object. + */ + public String getLanguage() + { + if(this.report.getLanguage() != null) + { + return this.report.getLanguage(); + } + if(this.template.getLanguage() != null) + { + return this.template.getLanguage(); + } + return Defaults.getDefaults().getLanguage(); + } + + /** + *

getFieldDescription.

+ * + * @param field a {@link software.xdev.dynamicreports.report.definition.DRIField} object. + * @return a {@link java.lang.String} object. + */ + public String getFieldDescription(final DRIField field) + { + if(field.getDescription() != null) + { + return field.getDescription(); + } + if(this.isUseFieldNameAsDescription()) + { + return field.getName(); + } + return null; + } + + private boolean isUseFieldNameAsDescription() + { + if(this.report.getUseFieldNameAsDescription() != null) + { + return this.report.getUseFieldNameAsDescription(); + } + if(this.template.getUseFieldNameAsDescription() != null) + { + return this.template.getUseFieldNameAsDescription(); + } + return Defaults.getDefaults().isUseFieldNameAsDescription(); + } + + // table of contents + + /** + *

isTableOfContents.

+ * + * @param tocHeadings a {@link java.util.Map} object. + * @return a boolean. + */ + public boolean isTableOfContents(final Map tocHeadings) + { + if(tocHeadings != null) + { + return true; + } + if(this.report.getTableOfContents() != null) + { + return this.report.getTableOfContents(); + } + if(this.template.getTableOfContents() != null) + { + return this.template.getTableOfContents(); + } + return Defaults.getDefaults().isTableOfContents(); + } + + /** + *

getTableOfContentsCustomizer.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer} object. + */ + public DRITableOfContentsCustomizer getTableOfContentsCustomizer() + { + if(this.report.getTableOfContentsCustomizer() != null) + { + return this.report.getTableOfContentsCustomizer(); + } + if(this.template.getTableOfContentsCustomizer() != null) + { + return this.template.getTableOfContentsCustomizer(); + } + return Defaults.getDefaults().getTableOfContentsCustomizer(); + } + + /** + *

isAddGroupToTableOfContents.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a boolean. + */ + public boolean isAddGroupToTableOfContents(final DRIGroup group) + { + if(group.getAddToTableOfContents() != null) + { + return group.getAddToTableOfContents(); + } + return Defaults.getDefaults().isAddGroupToTableOfContents(); + } + + // style + + /** + *

getDetailOddRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + protected DRISimpleStyle getDetailOddRowStyle() + { + if(this.isHighlightDetailOddRows()) + { + if(this.report.getDetailOddRowStyle() != null) + { + return this.report.getDetailOddRowStyle(); + } + if(this.template.getDetailOddRowStyle() != null) + { + return this.template.getDetailOddRowStyle(); + } + return Defaults.getDefaults().getDetailOddRowStyle(); + } + return null; + } + + /** + *

getDetailEvenRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + protected DRISimpleStyle getDetailEvenRowStyle() + { + if(this.isHighlightDetailEvenRows()) + { + if(this.report.getDetailEvenRowStyle() != null) + { + return this.report.getDetailEvenRowStyle(); + } + if(this.template.getDetailEvenRowStyle() != null) + { + return this.template.getDetailEvenRowStyle(); + } + return Defaults.getDefaults().getDetailEvenRowStyle(); + } + return null; + } + + private boolean isHighlightDetailOddRows() + { + if(this.report.getHighlightDetailOddRows() != null) + { + return this.report.getHighlightDetailOddRows(); + } + if(this.template.getHighlightDetailOddRows() != null) + { + return this.template.getHighlightDetailOddRows(); + } + return Defaults.getDefaults().isHighlightDetailOddRows(); + } + + private boolean isHighlightDetailEvenRows() + { + if(this.report.getHighlightDetailEvenRows() != null) + { + return this.report.getHighlightDetailEvenRows(); + } + if(this.template.getHighlightDetailEvenRows() != null) + { + return this.template.getHighlightDetailEvenRows(); + } + return Defaults.getDefaults().isHighlightDetailEvenRows(); + } + + /** + *

getDefaultFontName.

+ * + * @return a {@link java.lang.String} object. + */ + protected String getDefaultFontName() + { + if(this.report.getDefaultFont() != null && this.report.getDefaultFont().getFontName() != null) + { + return this.report.getDefaultFont().getFontName(); + } + if(this.template.getDefaultFont() != null && this.template.getDefaultFont().getFontName() != null) + { + return this.template.getDefaultFont().getFontName(); + } + return Defaults.getDefaults().getFont().getFontName(); + } + + /** + *

getDefaultFontSize.

+ * + * @return a {@link java.lang.Integer} object. + */ + protected Integer getDefaultFontSize() + { + if(this.report.getDefaultFont() != null && this.report.getDefaultFont().getFontSize() != null) + { + return this.report.getDefaultFont().getFontSize(); + } + if(this.template.getDefaultFont() != null && this.template.getDefaultFont().getFontSize() != null) + { + return this.template.getDefaultFont().getFontSize(); + } + return Defaults.getDefaults().getFont().getFontSize(); + } + + /** + *

getDefaultFontBold.

+ * + * @return a {@link java.lang.Boolean} object. + */ + protected Boolean getDefaultFontBold() + { + if(this.report.getDefaultFont() != null && this.report.getDefaultFont().getBold() != null) + { + return this.report.getDefaultFont().getBold(); + } + if(this.template.getDefaultFont() != null && this.template.getDefaultFont().getBold() != null) + { + return this.template.getDefaultFont().getBold(); + } + return Defaults.getDefaults().getFont().getBold(); + } + + /** + *

getDefaultFontItalic.

+ * + * @return a {@link java.lang.Boolean} object. + */ + protected Boolean getDefaultFontItalic() + { + if(this.report.getDefaultFont() != null && this.report.getDefaultFont().getItalic() != null) + { + return this.report.getDefaultFont().getItalic(); + } + if(this.template.getDefaultFont() != null && this.template.getDefaultFont().getItalic() != null) + { + return this.template.getDefaultFont().getItalic(); + } + return Defaults.getDefaults().getFont().getItalic(); + } + + /** + *

getDefaultFontUnderline.

+ * + * @return a {@link java.lang.Boolean} object. + */ + protected Boolean getDefaultFontUnderline() + { + if(this.report.getDefaultFont() != null && this.report.getDefaultFont().getUnderline() != null) + { + return this.report.getDefaultFont().getUnderline(); + } + if(this.template.getDefaultFont() != null && this.template.getDefaultFont().getUnderline() != null) + { + return this.template.getDefaultFont().getUnderline(); + } + return Defaults.getDefaults().getFont().getUnderline(); + } + + /** + *

getDefaultFontStrikeThrough.

+ * + * @return a {@link java.lang.Boolean} object. + */ + protected Boolean getDefaultFontStrikeThrough() + { + if(this.report.getDefaultFont() != null && this.report.getDefaultFont().getStrikeThrough() != null) + { + return this.report.getDefaultFont().getStrikeThrough(); + } + if(this.template.getDefaultFont() != null && this.template.getDefaultFont().getStrikeThrough() != null) + { + return this.template.getDefaultFont().getStrikeThrough(); + } + return Defaults.getDefaults().getFont().getStrikeThrough(); + } + + /** + *

getDefaultFontPdfFontName.

+ * + * @return a {@link java.lang.String} object. + */ + protected String getDefaultFontPdfFontName() + { + if(this.report.getDefaultFont() != null && this.report.getDefaultFont().getPdfFontName() != null) + { + return this.report.getDefaultFont().getPdfFontName(); + } + if(this.template.getDefaultFont() != null && this.template.getDefaultFont().getPdfFontName() != null) + { + return this.template.getDefaultFont().getPdfFontName(); + } + return Defaults.getDefaults().getFont().getPdfFontName(); + } + + /** + *

getDefaultFontPdfEncoding.

+ * + * @return a {@link java.lang.String} object. + */ + protected String getDefaultFontPdfEncoding() + { + if(this.report.getDefaultFont() != null && this.report.getDefaultFont().getPdfEncoding() != null) + { + return this.report.getDefaultFont().getPdfEncoding(); + } + if(this.template.getDefaultFont() != null && this.template.getDefaultFont().getPdfEncoding() != null) + { + return this.template.getDefaultFont().getPdfEncoding(); + } + return Defaults.getDefaults().getFont().getPdfEncoding(); + } + + /** + *

getDefaultFontPdfEmbedded.

+ * + * @return a {@link java.lang.Boolean} object. + */ + protected Boolean getDefaultFontPdfEmbedded() + { + if(this.report.getDefaultFont() != null && this.report.getDefaultFont().getPdfEmbedded() != null) + { + return this.report.getDefaultFont().getPdfEmbedded(); + } + if(this.template.getDefaultFont() != null && this.template.getDefaultFont().getPdfEmbedded() != null) + { + return this.template.getDefaultFont().getPdfEmbedded(); + } + return Defaults.getDefaults().getFont().getPdfEmbedded(); + } + + /** + *

getTextStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getTextStyle() + { + if(this.report.getTextStyle() != null) + { + return this.report.getTextStyle(); + } + if(this.template.getTextStyle() != null) + { + return this.template.getTextStyle(); + } + return Defaults.getDefaults().getTextStyle(); + } + + /** + *

getColumnTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getColumnTitleStyle() + { + if(this.report.getColumnTitleStyle() != null) + { + return this.report.getColumnTitleStyle(); + } + if(this.template.getColumnTitleStyle() != null) + { + return this.template.getColumnTitleStyle(); + } + if(Defaults.getDefaults().getColumnTitleStyle() != null) + { + return Defaults.getDefaults().getColumnTitleStyle(); + } + return this.getTextStyle(); + } + + /** + *

getColumnStyle.

+ * + * @param textStyle a boolean. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getColumnStyle(final boolean textStyle) + { + if(this.report.getColumnStyle() != null) + { + return this.report.getColumnStyle(); + } + if(this.template.getColumnStyle() != null) + { + return this.template.getColumnStyle(); + } + if(Defaults.getDefaults().getColumnStyle() != null) + { + return Defaults.getDefaults().getColumnStyle(); + } + if(textStyle) + { + return this.getTextStyle(); + } + return null; + } + + /** + *

getGroupTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getGroupTitleStyle() + { + if(this.report.getGroupTitleStyle() != null) + { + return this.report.getGroupTitleStyle(); + } + if(this.template.getGroupTitleStyle() != null) + { + return this.template.getGroupTitleStyle(); + } + if(Defaults.getDefaults().getGroupTitleStyle() != null) + { + return Defaults.getDefaults().getGroupTitleStyle(); + } + return this.getTextStyle(); + } + + /** + *

getGroupStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getGroupStyle() + { + if(this.report.getGroupStyle() != null) + { + return this.report.getGroupStyle(); + } + if(this.template.getGroupStyle() != null) + { + return this.template.getGroupStyle(); + } + if(Defaults.getDefaults().getGroupStyle() != null) + { + return Defaults.getDefaults().getGroupStyle(); + } + return this.getTextStyle(); + } + + /** + *

getSubtotalStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getSubtotalStyle() + { + if(this.report.getSubtotalStyle() != null) + { + return this.report.getSubtotalStyle(); + } + if(this.template.getSubtotalStyle() != null) + { + return this.template.getSubtotalStyle(); + } + if(Defaults.getDefaults().getSubtotalStyle() != null) + { + return Defaults.getDefaults().getSubtotalStyle(); + } + return this.getTextStyle(); + } + + /** + *

getImageStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getImageStyle() + { + if(this.report.getImageStyle() != null) + { + return this.report.getImageStyle(); + } + if(this.template.getImageStyle() != null) + { + return this.template.getImageStyle(); + } + return Defaults.getDefaults().getImageStyle(); + } + + // page + + /** + *

getPageWidth.

+ * + * @return a int. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected int getPageWidth() throws DRException + { + if(this.isIgnorePageWidth()) + { + return this.getDynamicPageWidth(); + } + else + { + return this.getStaticPageWidth(); + } + } + + private boolean isIgnorePageWidth() + { + if(this.report.getPage().getIgnorePageWidth() != null) + { + return this.report.getPage().getIgnorePageWidth(); + } + if(this.template.getIgnorePageWidth() != null) + { + return this.template.getIgnorePageWidth(); + } + return Defaults.getDefaults().isIgnorePageWidth(); + } + + private int getDynamicPageWidth() throws DRException + { + int maxPageWidth = 0; + maxPageWidth = this.getMaxBandWidth(this.accessor.getBandTransform().getTitleBand(), maxPageWidth); + maxPageWidth = this.getMaxBandWidth(this.accessor.getBandTransform().getPageHeaderBand(), maxPageWidth); + maxPageWidth = this.getMaxBandWidth(this.accessor.getBandTransform().getPageFooterBand(), maxPageWidth); + maxPageWidth = this.getMaxBandWidth(this.accessor.getBandTransform().getColumnHeaderBand(), maxPageWidth); + maxPageWidth = this.getMaxBandWidth(this.accessor.getBandTransform().getColumnFooterBand(), maxPageWidth); + maxPageWidth = this.getMaxBandWidth(this.accessor.getBandTransform().getDetailBand(), maxPageWidth); + maxPageWidth = this.getMaxBandWidth(this.accessor.getBandTransform().getLastPageFooterBand(), maxPageWidth); + maxPageWidth = this.getMaxBandWidth(this.accessor.getBandTransform().getSummaryBand(), maxPageWidth); + + return maxPageWidth + this.getPageMargin().getLeft() + this.getPageMargin().getRight(); + } + + private int getMaxBandWidth(final DRIDesignBand band, final int maxWidth) throws DRException + { + if(band == null || band.getList() == null) + { + return maxWidth; + } + + final int bandWidth = this.detectWidth(band.getList()); + if(bandWidth > maxWidth) + { + return bandWidth; + } + return maxWidth; + } + + private int getStaticPageWidth() throws DRException + { + if(this.accessor.getPageWidth() != null) + { + return this.accessor.getPageWidth(); + } + if(this.report.getPage().getWidth() != null) + { + return this.report.getPage().getWidth(); + } + if(this.templateDesign.getPageWidth() != null) + { + return this.templateDesign.getPageWidth(); + } + if(this.template.getPageWidth() != null) + { + return this.template.getPageWidth(); + } + return Defaults.getDefaults().getPageWidth(); + } + + /** + *

getPageHeight.

+ * + * @return a int. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected int getPageHeight() throws DRException + { + if(this.report.getPage().getHeight() != null) + { + return this.report.getPage().getHeight(); + } + if(this.templateDesign.getPageHeight() != null) + { + return this.templateDesign.getPageHeight(); + } + if(this.template.getPageHeight() != null) + { + return this.template.getPageHeight(); + } + return Defaults.getDefaults().getPageHeight(); + } + + /** + *

getPageOrientation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected PageOrientation getPageOrientation() throws DRException + { + if(this.report.getPage().getOrientation() != null) + { + return this.report.getPage().getOrientation(); + } + if(this.templateDesign.getPageOrientation() != null) + { + return this.templateDesign.getPageOrientation(); + } + if(this.template.getPageOrientation() != null) + { + return this.template.getPageOrientation(); + } + return Defaults.getDefaults().getPageOrientation(); + } + + /** + *

getPageMargin.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIMargin} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected DRIMargin getPageMargin() throws DRException + { + if(this.report.getPage().getMargin() != null) + { + return this.report.getPage().getMargin(); + } + if(this.templateDesign.getPageMargin() != null) + { + return this.templateDesign.getPageMargin(); + } + if(this.accessor.getPageWidth() != null) + { + return Defaults.getDefaults().getSubreportPageMargin(); + } + if(this.template.getPageMargin() != null) + { + return this.template.getPageMargin(); + } + return Defaults.getDefaults().getPageMargin(); + } + + /** + *

getPageColumnsPerPage.

+ * + * @return a int. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected int getPageColumnsPerPage() throws DRException + { + if(this.report.getPage().getColumnsPerPage() != null) + { + return this.report.getPage().getColumnsPerPage(); + } + if(this.templateDesign.getPageColumnsPerPage() != null) + { + return this.templateDesign.getPageColumnsPerPage(); + } + if(this.template.getPageColumnsPerPage() != null) + { + return this.template.getPageColumnsPerPage(); + } + return Defaults.getDefaults().getPageColumnsPerPage(); + } + + /** + *

getPageColumnSpace.

+ * + * @return a int. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected int getPageColumnSpace() throws DRException + { + if(this.report.getPage().getColumnSpace() != null) + { + return this.report.getPage().getColumnSpace(); + } + if(this.templateDesign.getPageColumnSpace() != null) + { + return this.templateDesign.getPageColumnSpace(); + } + if(this.template.getPageColumnSpace() != null) + { + return this.template.getPageColumnSpace(); + } + return Defaults.getDefaults().getPageColumnSpace(); + } + + /** + *

getPageColumnWidth.

+ * + * @param page a {@link software.xdev.dynamicreports.design.definition.DRIDesignPage} object. + * @return a int. + */ + protected int getPageColumnWidth(final DRIDesignPage page) + { + int columnWidth = page.getWidth() - page.getMargin().getLeft() - page.getMargin().getRight(); + columnWidth -= page.getColumnSpace() * (page.getColumnsPerPage() - 1); + columnWidth = columnWidth / page.getColumnsPerPage(); + if(this.templateDesign.getPageColumnWidth() != null && this.templateDesign.getPageColumnWidth() > 0 + && this.templateDesign.getPageColumnWidth() < columnWidth && !this.isIgnorePageWidth()) + { + return this.templateDesign.getPageColumnWidth(); + } + return columnWidth; + } + + // column + + /** + *

isColumnPrintRepeatedDetailValues.

+ * + * @param column a {@link software.xdev.dynamicreports.report.definition.column.DRIValueColumn} object. + * @return a boolean. + */ + protected boolean isColumnPrintRepeatedDetailValues(final DRIValueColumn column) + { + if(column.getPrintRepeatedDetailValues() != null) + { + return column.getPrintRepeatedDetailValues(); + } + if(this.template.getColumnPrintRepeatedDetailValues() != null) + { + return this.template.getColumnPrintRepeatedDetailValues(); + } + return Defaults.getDefaults().isColumnPrintRepeatedDetailValues(); + } + + /** + *

getColumnWidth.

+ * + * @param column a {@link software.xdev.dynamicreports.report.definition.column.DRIColumn} object. + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a int. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + protected int getColumnWidth(final DRIColumn column, final DRDesignStyle style) throws DRException + { + final DRIComponent component = this.accessor.getColumnTransform().getColumnComponent(column); + if(component != null) + { + if(component instanceof DRIList) + { + final DRDesignList list = + this.accessor.getComponentTransform().list((DRIList)component, DefaultStyleType.COLUMN, null, null); + return this.detectWidth(list); + } + else if(component instanceof DRIDimensionComponent) + { + if(((DRIDimensionComponent)component).getWidth() != null) + { + return ((DRIDimensionComponent)component).getWidth(); + } + if(component instanceof DRITextField) + { + if(((DRITextField)component).getColumns() != null) + { + return StyleResolver.getFontWidth(style, ((DRITextField)component).getColumns()); + } + } + } + else + { + throw new DRDesignReportException("Component " + component.getClass().getName() + " not supported"); + } + } + return this.getColumnWidth(); + } + + /** + *

getColumnWidth.

+ * + * @return a int. + */ + protected int getColumnWidth() + { + if(this.template.getColumnWidth() != null) + { + return this.template.getColumnWidth(); + } + return Defaults.getDefaults().getColumnWidth(); + } + + // component + + /** + *

getRemoveLineWhenBlank.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + * @return a boolean. + */ + protected boolean getRemoveLineWhenBlank(final DRIComponent component) + { + if(component.getRemoveLineWhenBlank() != null) + { + return component.getRemoveLineWhenBlank(); + } + return Defaults.getDefaults().isRemoveLineWhenBlank(); + } + + /** + *

getPositionType.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + * @return a {@link software.xdev.dynamicreports.report.constant.ComponentPositionType} object. + */ + protected ComponentPositionType getPositionType(final DRIComponent component) + { + if(component instanceof DRIDimensionComponent && ((DRIDimensionComponent)component).getPositionType() != null) + { + return ((DRIDimensionComponent)component).getPositionType(); + } + return null; + } + + /** + *

getStretchType.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + * @return a {@link software.xdev.dynamicreports.report.constant.StretchType} object. + */ + protected StretchType getStretchType(final DRIComponent component) + { + if(component instanceof DRIDimensionComponent && ((DRIDimensionComponent)component).getStretchType() != null) + { + return ((DRIDimensionComponent)component).getStretchType(); + } + return null; + } + + /** + *

getPrintInFirstWholeBand.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + * @return a boolean. + */ + protected boolean getPrintInFirstWholeBand(final DRIComponent component) + { + if(component instanceof DRIDimensionComponent + && ((DRIDimensionComponent)component).getPrintInFirstWholeBand() != null) + { + return ((DRIDimensionComponent)component).getPrintInFirstWholeBand(); + } + return Defaults.getDefaults().isPrintInFirstWholeBand(); + } + + /** + *

getPrintWhenDetailOverflows.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + * @return a boolean. + */ + protected boolean getPrintWhenDetailOverflows(final DRIComponent component) + { + if(component instanceof DRIDimensionComponent + && ((DRIDimensionComponent)component).getPrintWhenDetailOverflows() != null) + { + return ((DRIDimensionComponent)component).getPrintWhenDetailOverflows(); + } + return Defaults.getDefaults().isPrintWhenDetailOverflows(); + } + + /** + *

getPrintWhenGroupChanges.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignGroup} object. + */ + protected DRIDesignGroup getPrintWhenGroupChanges(final DRIComponent component) + { + if(component instanceof DRIDimensionComponent + && ((DRIDimensionComponent)component).getPrintWhenGroupChanges() != null) + { + return this.accessor.getGroupTransform().getGroup(((DRIDimensionComponent)component).getPrintWhenGroupChanges()); + } + return null; + } + + // group + + /** + *

getGroupHeaderLayout.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a {@link software.xdev.dynamicreports.report.constant.GroupHeaderLayout} object. + */ + protected GroupHeaderLayout getGroupHeaderLayout(final DRIGroup group) + { + if(group.getHeaderLayout() != null) + { + return group.getHeaderLayout(); + } + if(this.template.getGroupHeaderLayout() != null) + { + return this.template.getGroupHeaderLayout(); + } + return Defaults.getDefaults().getGroupHeaderLayout(); + } + + /** + *

isGroupHideColumn.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a boolean. + */ + protected boolean isGroupHideColumn(final DRIGroup group) + { + if(group.getHideColumn() != null) + { + return group.getHideColumn(); + } + if(this.template.getGroupHideColumn() != null) + { + return this.template.getGroupHideColumn(); + } + return Defaults.getDefaults().isGroupHideColumn(); + } + + /** + *

isGroupShowColumnHeaderAndFooter.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a boolean. + */ + protected boolean isGroupShowColumnHeaderAndFooter(final DRIGroup group) + { + if(group.getShowColumnHeaderAndFooter() != null) + { + return group.getShowColumnHeaderAndFooter(); + } + if(this.template.getGroupShowColumnHeaderAndFooter() != null) + { + return this.template.getGroupShowColumnHeaderAndFooter(); + } + return Defaults.getDefaults().isGroupShowColumnHeaderAndFooter(); + } + + /** + *

getGroupPadding.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a int. + */ + protected int getGroupPadding(final DRIGroup group) + { + if(group.getPadding() != null) + { + return group.getPadding(); + } + if(this.template.getGroupPadding() != null) + { + return this.template.getGroupPadding(); + } + return Defaults.getDefaults().getGroupPadding(); + } + + /** + *

isGroupStartInNewPage.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a boolean. + */ + protected boolean isGroupStartInNewPage(final DRIGroup group) + { + if(group.getStartInNewPage() != null) + { + return group.getStartInNewPage(); + } + if(this.template.getGroupStartInNewPage() != null) + { + return this.template.getGroupStartInNewPage(); + } + return Defaults.getDefaults().isGroupStartInNewPage(); + } + + /** + *

isGroupStartInNewColumn.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a boolean. + */ + protected boolean isGroupStartInNewColumn(final DRIGroup group) + { + if(group.getStartInNewColumn() != null) + { + return group.getStartInNewColumn(); + } + if(this.template.getGroupStartInNewColumn() != null) + { + return this.template.getGroupStartInNewColumn(); + } + return Defaults.getDefaults().isGroupStartInNewColumn(); + } + + /** + *

isGroupReprintHeaderOnEachPage.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a boolean. + */ + protected boolean isGroupReprintHeaderOnEachPage(final DRIGroup group) + { + if(group.getReprintHeaderOnEachPage() != null) + { + return group.getReprintHeaderOnEachPage(); + } + if(this.template.getGroupReprintHeaderOnEachPage() != null) + { + return this.template.getGroupReprintHeaderOnEachPage(); + } + return Defaults.getDefaults().isGroupReprintHeaderOnEachPage(); + } + + /** + *

isGroupResetPageNumber.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a boolean. + */ + protected boolean isGroupResetPageNumber(final DRIGroup group) + { + if(group.getResetPageNumber() != null) + { + return group.getResetPageNumber(); + } + if(this.template.getGroupResetPageNumber() != null) + { + return this.template.getGroupResetPageNumber(); + } + return Defaults.getDefaults().isGroupResetPageNumber(); + } + + /** + *

getGroupMinHeightToStartNewPage.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a {@link java.lang.Integer} object. + */ + protected Integer getGroupMinHeightToStartNewPage(final DRIGroup group) + { + if(group.getMinHeightToStartNewPage() != null) + { + return group.getMinHeightToStartNewPage(); + } + return Defaults.getDefaults().getGroupMinHeightToStartNewPage(); + } + + /** + *

getGroupFooterPosition.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a {@link software.xdev.dynamicreports.report.constant.GroupFooterPosition} object. + */ + protected GroupFooterPosition getGroupFooterPosition(final DRIGroup group) + { + if(group.getFooterPosition() != null) + { + return group.getFooterPosition(); + } + if(this.template.getGroupFooterPosition() != null) + { + return this.template.getGroupFooterPosition(); + } + return Defaults.getDefaults().getGroupFooterPosition(); + } + + /** + *

isGroupKeepTogether.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a boolean. + */ + protected boolean isGroupKeepTogether(final DRIGroup group) + { + if(group.getKeepTogether() != null) + { + return group.getKeepTogether(); + } + if(this.template.getGroupKeepTogether() != null) + { + return this.template.getGroupKeepTogether(); + } + return Defaults.getDefaults().isGroupKeepTogether(); + } + + /** + *

isGroupHeaderWithSubtotal.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a boolean. + */ + protected boolean isGroupHeaderWithSubtotal(final DRIGroup group) + { + if(group.getHeaderWithSubtotal() != null) + { + return group.getHeaderWithSubtotal(); + } + if(this.template.getGroupHeaderWithSubtotal() != null) + { + return this.template.getGroupHeaderWithSubtotal(); + } + return Defaults.getDefaults().isGroupHeaderWithSubtotal(); + } + + /** + *

isGroupByDataType.

+ * + * @param group a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + * @return a boolean. + */ + protected boolean isGroupByDataType(final DRIGroup group) + { + if(group.getGroupByDataType() != null) + { + return group.getGroupByDataType(); + } + return Defaults.getDefaults().isGroupByDataType(); + } + + // subtotal + + /** + *

getSubtotalLabelPosition.

+ * + * @param subtotal a {@link software.xdev.dynamicreports.report.definition.DRISubtotal} object. + * @return a {@link software.xdev.dynamicreports.report.constant.Position} object. + */ + public Position getSubtotalLabelPosition(final DRISubtotal subtotal) + { + if(subtotal.getLabelPosition() != null) + { + return subtotal.getLabelPosition(); + } + if(this.template.getSubtotalLabelPosition() != null) + { + return this.template.getSubtotalLabelPosition(); + } + return Defaults.getDefaults().getSubtotalLabelPosition(); + } + + // text field + + /** + *

getTextFieldWidth.

+ * + * @param textField a {@link software.xdev.dynamicreports.report.definition.component.DRITextField} object. + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a int. + */ + protected int getTextFieldWidth(final DRITextField textField, final DRDesignStyle style) + { + if(textField.getWidth() != null) + { + return textField.getWidth(); + } + if(textField.getColumns() != null) + { + return StyleResolver.getFontWidth(style, textField.getColumns()); + } + if(this.template.getTextFieldWidth() != null) + { + return this.template.getTextFieldWidth(); + } + return Defaults.getDefaults().getTextFieldWidth(); + } + + /** + *

getTextFieldHeight.

+ * + * @param textField a {@link software.xdev.dynamicreports.report.definition.component.DRITextField} object. + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a int. + */ + protected int getTextFieldHeight(final DRITextField textField, final DRDesignStyle style) + { + if(textField.getHeight() != null) + { + return textField.getHeight(); + } + if(textField.getRows() != null) + { + return StyleResolver.getFontHeight(style, textField.getRows()); + } + return StyleResolver.getFontHeight(style, 1); + } + + /** + *

getTextFieldPattern.

+ * + * @param textField a {@link software.xdev.dynamicreports.report.definition.component.DRITextField} object. + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link java.lang.String} object. + */ + protected String getTextFieldPattern(final DRITextField textField, final DRDesignStyle style) + { + if(textField.getPattern() != null) + { + return textField.getPattern(); + } + if(StyleResolver.getPattern(style) != null) + { + return null;// StyleResolver.getPattern(style); + } + if(textField.getDataType() != null) + { + return textField.getDataType().getPattern(); + } + return null; + } + + /** + *

getTextFieldHorizontalTextAlignment.

+ * + * @param textField a {@link software.xdev.dynamicreports.report.definition.component.DRITextField} object. + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + protected HorizontalTextAlignment getTextFieldHorizontalTextAlignment( + final DRITextField textField, + final DRDesignStyle style) + { + if(textField.getHorizontalTextAlignment() != null) + { + return textField.getHorizontalTextAlignment(); + } + if(StyleResolver.getHorizontalTextAlignment(style) != null) + { + return null;// StyleResolver.getHorizontalTextAlignment(style); + } + if(textField.getDataType() != null) + { + return textField.getDataType().getHorizontalTextAlignment(); + } + return null; + } + + /** + *

getTextFieldValueFormatter.

+ * + * @param textField a {@link software.xdev.dynamicreports.report.definition.component.DRITextField} object. + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + */ + protected DRIValueFormatter getTextFieldValueFormatter(final DRITextField textField) + { + if(textField.getValueFormatter() != null) + { + return textField.getValueFormatter(); + } + if(textField.getDataType() != null) + { + return textField.getDataType().getValueFormatter(); + } + return null; + } + + /** + *

getTextFieldStretchWithOverflow.

+ * + * @param textField a {@link software.xdev.dynamicreports.report.definition.component.DRITextField} object. + * @return a boolean. + * @deprecated replaced by {@link #getTextFieldTextAdjust(DRITextField)} + */ + @Deprecated + protected boolean getTextFieldStretchWithOverflow(final DRITextField textField) + { + if(textField.getStretchWithOverflow() != null) + { + return textField.getStretchWithOverflow(); + } + return Defaults.getDefaults().isTextFieldStretchWithOverflow(); + } + + /** + *

getTextFieldTextAdjust.

+ * + * @param textField a {@link software.xdev.dynamicreports.report.definition.component.DRITextField} object. + * @return a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + protected TextAdjust getTextFieldTextAdjust(final DRITextField textField) + { + if(textField.getTextAdjust() != null) + { + return textField.getTextAdjust(); + } + return Defaults.getDefaults().getTextFieldTextAdjust(); + } + + /** + *

isTextFieldPrintRepeatedValues.

+ * + * @param textField a {@link software.xdev.dynamicreports.report.definition.component.DRITextField} object. + * @return a boolean. + */ + protected boolean isTextFieldPrintRepeatedValues(final DRITextField textField) + { + if(textField.getPrintRepeatedValues() != null) + { + return textField.getPrintRepeatedValues(); + } + return Defaults.getDefaults().isTextFieldPrintRepeatedValues(); + } + + // text field + + /** + *

getBooleanFieldWidth.

+ * + * @param booleanField a {@link software.xdev.dynamicreports.report.definition.component.DRIBooleanField} object. + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a int. + */ + protected int getBooleanFieldWidth(final DRIBooleanField booleanField, final DRDesignStyle style) + { + if(booleanField.getWidth() != null) + { + return booleanField.getWidth(); + } + if(this.template.getTextFieldWidth() != null) + { + return this.template.getTextFieldWidth(); + } + return Defaults.getDefaults().getTextFieldWidth(); + } + + /** + *

getBooleanFieldHeight.

+ * + * @param booleanField a {@link software.xdev.dynamicreports.report.definition.component.DRIBooleanField} object. + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a int. + */ + protected int getBooleanFieldHeight(final DRIBooleanField booleanField, final DRDesignStyle style) + { + if(booleanField.getHeight() != null) + { + return booleanField.getHeight(); + } + return StyleResolver.getFontHeight(style, 1); + } + + // page x of y + + /** + *

getPageXofYWidth.

+ * + * @param pageXofY a {@link software.xdev.dynamicreports.report.definition.component.DRIPageXofY} object. + * @return a int. + */ + protected int getPageXofYWidth(final DRIPageXofY pageXofY) + { + if(pageXofY.getWidth() != null) + { + return pageXofY.getWidth(); + } + if(this.template.getTextFieldWidth() != null) + { + return this.template.getTextFieldWidth(); + } + return Defaults.getDefaults().getTextFieldWidth(); + } + + /** + *

getPageXofYHeight.

+ * + * @param pageXofY a {@link software.xdev.dynamicreports.report.definition.component.DRIPageXofY} object. + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a int. + */ + protected int getPageXofYHeight(final DRIPageXofY pageXofY, final DRDesignStyle style) + { + if(pageXofY.getHeight() != null) + { + return pageXofY.getHeight(); + } + return StyleResolver.getFontHeight(style, 1); + } + + /** + *

getPageXofYHorizontalTextAlignment.

+ * + * @param pageXofY a {@link software.xdev.dynamicreports.report.definition.component.DRIPageXofY} object. + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + protected HorizontalTextAlignment getPageXofYHorizontalTextAlignment( + final DRIPageXofY pageXofY, + final DRDesignStyle style) + { + if(pageXofY.getHorizontalTextAlignment() != null) + { + return pageXofY.getHorizontalTextAlignment(); + } + if(StyleResolver.getHorizontalTextAlignment(style) != null) + { + return StyleResolver.getHorizontalTextAlignment(style); + } + return Defaults.getDefaults().getPageXofYHorizontalTextAlignment(); + } + + // image + + /** + *

getImageWidth.

+ * + * @param image a {@link software.xdev.dynamicreports.report.definition.component.DRIImage} object. + * @return a int. + */ + protected int getImageWidth(final DRIImage image) + { + if(image.getWidth() != null) + { + return image.getWidth(); + } + if(this.template.getImageWidth() != null) + { + return this.template.getImageWidth(); + } + return Defaults.getDefaults().getImageWidth(); + } + + /** + *

getImageHeight.

+ * + * @param image a {@link software.xdev.dynamicreports.report.definition.component.DRIImage} object. + * @param imageHeight a {@link java.lang.Integer} object. + * @param imageHeight a {@link java.lang.Integer} object. + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a int. + */ + protected int getImageHeight(final DRIImage image, final Integer imageHeight, final DRDesignStyle style) + { + if(image.getHeight() != null) + { + return image.getHeight(); + } + if(imageHeight != null) + { + return imageHeight + StyleResolver.getVerticalPadding(style); + } + if(this.template.getImageHeight() != null) + { + return this.template.getImageHeight(); + } + return Defaults.getDefaults().getImageHeight(); + } + + // filler + + /** + *

getFillerWidth.

+ * + * @param filler a {@link software.xdev.dynamicreports.report.definition.component.DRIFiller} object. + * @return a int. + */ + protected int getFillerWidth(final DRIFiller filler) + { + if(filler.getWidth() != null) + { + return filler.getWidth(); + } + return Defaults.getDefaults().getFillerWidth(); + } + + /** + *

getFillerHeight.

+ * + * @param filler a {@link software.xdev.dynamicreports.report.definition.component.DRIFiller} object. + * @return a int. + */ + protected int getFillerHeight(final DRIFiller filler) + { + if(filler.getHeight() != null) + { + return filler.getHeight(); + } + return Defaults.getDefaults().getFillerHeight(); + } + + // line + + /** + *

getLineWidth.

+ * + * @param line a {@link software.xdev.dynamicreports.report.definition.component.DRILine} object. + * @return a int. + */ + protected int getLineWidth(final DRILine line) + { + if(line.getWidth() != null) + { + return line.getWidth(); + } + return Defaults.getDefaults().getLineWidth(); + } + + /** + *

getLineHeight.

+ * + * @param line a {@link software.xdev.dynamicreports.report.definition.component.DRILine} object. + * @return a int. + */ + protected int getLineHeight(final DRILine line) + { + if(line.getHeight() != null) + { + return line.getHeight(); + } + return Defaults.getDefaults().getLineHeight(); + } + + // ellipse + + /** + *

getEllipseWidth.

+ * + * @param ellipse a {@link software.xdev.dynamicreports.report.definition.component.DRIEllipse} object. + * @return a int. + */ + protected int getEllipseWidth(final DRIEllipse ellipse) + { + if(ellipse.getWidth() != null) + { + return ellipse.getWidth(); + } + return Defaults.getDefaults().getEllipseWidth(); + } + + /** + *

getEllipseHeight.

+ * + * @param ellipse a {@link software.xdev.dynamicreports.report.definition.component.DRIEllipse} object. + * @return a int. + */ + protected int getEllipseHeight(final DRIEllipse ellipse) + { + if(ellipse.getHeight() != null) + { + return ellipse.getHeight(); + } + return Defaults.getDefaults().getEllipseHeight(); + } + + // rectangle + + /** + *

getRectangleRadius.

+ * + * @param rectangle a {@link software.xdev.dynamicreports.report.definition.component.DRIRectangle} object. + * @return a {@link java.lang.Integer} object. + */ + protected Integer getRectangleRadius(final DRIRectangle rectangle) + { + if(rectangle.getRadius() != null) + { + return rectangle.getRadius(); + } + return Defaults.getDefaults().getRectangleRadius(); + } + + /** + *

getRectangleWidth.

+ * + * @param rectangle a {@link software.xdev.dynamicreports.report.definition.component.DRIRectangle} object. + * @return a int. + */ + protected int getRectangleWidth(final DRIRectangle rectangle) + { + if(rectangle.getWidth() != null) + { + return rectangle.getWidth(); + } + return Defaults.getDefaults().getRectangleWidth(); + } + + /** + *

getRectangleHeight.

+ * + * @param rectangle a {@link software.xdev.dynamicreports.report.definition.component.DRIRectangle} object. + * @return a int. + */ + protected int getRectangleHeight(final DRIRectangle rectangle) + { + if(rectangle.getHeight() != null) + { + return rectangle.getHeight(); + } + return Defaults.getDefaults().getRectangleHeight(); + } + + // map + + /** + *

getMapWidth.

+ * + * @param map a {@link software.xdev.dynamicreports.report.definition.component.DRIMap} object. + * @return a int. + */ + protected int getMapWidth(final DRIMap map) + { + if(map.getWidth() != null) + { + return map.getWidth(); + } + return Defaults.getDefaults().getMapWidth(); + } + + /** + *

getMapHeight.

+ * + * @param map a {@link software.xdev.dynamicreports.report.definition.component.DRIMap} object. + * @return a int. + */ + protected int getMapHeight(final DRIMap map) + { + if(map.getHeight() != null) + { + return map.getHeight(); + } + return Defaults.getDefaults().getMapHeight(); + } + + // custom component + + /** + *

getCustomComponentWidth.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.component.DRIDimensionComponent} object. + * @return a int. + */ + protected int getCustomComponentWidth(final DRIDimensionComponent component) + { + if(component.getWidth() != null) + { + return component.getWidth(); + } + return Defaults.getDefaults().getCustomComponentWidth(); + } + + /** + *

getCustomComponentHeight.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.component.DRIDimensionComponent} object. + * @return a int. + */ + protected int getCustomComponentHeight(final DRIDimensionComponent component) + { + if(component.getHeight() != null) + { + return component.getHeight(); + } + return Defaults.getDefaults().getCustomComponentHeight(); + } + + // break + + /** + *

getBreakWidth.

+ * + * @param breakComponent a {@link software.xdev.dynamicreports.report.definition.component.DRIBreak} object. + * @return a int. + */ + protected int getBreakWidth(final DRIBreak breakComponent) + { + return Defaults.getDefaults().getBreakWidth(); + } + + /** + *

getBreakHeight.

+ * + * @param breakComponent a {@link software.xdev.dynamicreports.report.definition.component.DRIBreak} object. + * @return a int. + */ + protected int getBreakHeight(final DRIBreak breakComponent) + { + return Defaults.getDefaults().getBreakHeight(); + } + + // generic element + + /** + *

getGenericElementWidth.

+ * + * @param genericElement a {@link software.xdev.dynamicreports.report.definition.component.DRIGenericElement} object. + * @return a {@link java.lang.Integer} object. + */ + protected Integer getGenericElementWidth(final DRIGenericElement genericElement) + { + if(genericElement.getWidth() != null) + { + return genericElement.getWidth(); + } + return Defaults.getDefaults().getGenericElementWidth(); + } + + /** + *

getGenericElementHeight.

+ * + * @param genericElement a {@link software.xdev.dynamicreports.report.definition.component.DRIGenericElement} object. + * @return a {@link java.lang.Integer} object. + */ + protected Integer getGenericElementHeight(final DRIGenericElement genericElement) + { + if(genericElement.getHeight() != null) + { + return genericElement.getHeight(); + } + return Defaults.getDefaults().getGenericElementHeight(); + } + + // list + + /** + *

getListWidth.

+ * + * @param list a {@link software.xdev.dynamicreports.report.definition.component.DRIList} object. + * @return a {@link java.lang.Integer} object. + */ + protected Integer getListWidth(final DRIList list) + { + if(list.getWidth() != null) + { + return list.getWidth(); + } + return Defaults.getDefaults().getListWidth(); + } + + /** + *

getListHeight.

+ * + * @param list a {@link software.xdev.dynamicreports.report.definition.component.DRIList} object. + * @return a {@link java.lang.Integer} object. + */ + protected Integer getListHeight(final DRIList list) + { + if(list.getHeight() != null) + { + return list.getHeight(); + } + return Defaults.getDefaults().getListHeight(); + } + + /** + *

getListGap.

+ * + * @param list a {@link software.xdev.dynamicreports.report.definition.component.DRIList} object. + * @return a int. + */ + protected int getListGap(final DRIList list) + { + if(list.getGap() != null) + { + return list.getGap(); + } + if(this.template.getListgap() != null) + { + return this.template.getListgap(); + } + return Defaults.getDefaults().getListgap(); + } + + // xy list + + /** + *

getXyListWidth.

+ * + * @param xyList a {@link software.xdev.dynamicreports.report.definition.component.DRIXyList} object. + * @return a {@link java.lang.Integer} object. + */ + protected Integer getXyListWidth(final DRIXyList xyList) + { + if(xyList.getWidth() != null) + { + return xyList.getWidth(); + } + return Defaults.getDefaults().getListWidth(); + } + + /** + *

getXyListHeight.

+ * + * @param xyList a {@link software.xdev.dynamicreports.report.definition.component.DRIXyList} object. + * @return a {@link java.lang.Integer} object. + */ + protected Integer getXyListHeight(final DRIXyList xyList) + { + if(xyList.getHeight() != null) + { + return xyList.getHeight(); + } + return Defaults.getDefaults().getListHeight(); + } + + // multi page list + + /** + *

getMultiPageListWidth.

+ * + * @param multiPageList a {@link software.xdev.dynamicreports.report.definition.component.DRIMultiPageList} object. + * @return a int. + */ + protected int getMultiPageListWidth(final DRIMultiPageList multiPageList) + { + if(multiPageList.getWidth() != null) + { + return multiPageList.getWidth(); + } + if(this.template.getMultiPageListWidth() != null) + { + return this.template.getMultiPageListWidth(); + } + return Defaults.getDefaults().getMultiPageListWidth(); + } + + /** + *

getMultiPageListHeight.

+ * + * @param multiPageList a {@link software.xdev.dynamicreports.report.definition.component.DRIMultiPageList} object. + * @return a int. + */ + protected int getMultiPageListHeight(final DRIMultiPageList multiPageList) + { + if(multiPageList.getHeight() != null) + { + return multiPageList.getHeight(); + } + if(this.template.getMultiPageListHeight() != null) + { + return this.template.getMultiPageListHeight(); + } + return Defaults.getDefaults().getMultiPageListHeight(); + } + + // subreport + + /** + *

getSubreportWidth.

+ * + * @param subreport a {@link software.xdev.dynamicreports.report.definition.component.DRISubreport} object. + * @return a int. + */ + protected int getSubreportWidth(final DRISubreport subreport) + { + if(subreport.getWidth() != null) + { + return subreport.getWidth(); + } + if(this.template.getSubreportWidth() != null) + { + return this.template.getSubreportWidth(); + } + return Defaults.getDefaults().getSubreportWidth(); + } + + /** + *

getSubreportHeight.

+ * + * @param subreport a {@link software.xdev.dynamicreports.report.definition.component.DRISubreport} object. + * @return a int. + */ + protected int getSubreportHeight(final DRISubreport subreport) + { + if(subreport.getHeight() != null) + { + return subreport.getHeight(); + } + if(this.template.getSubreportHeight() != null) + { + return this.template.getSubreportHeight(); + } + return Defaults.getDefaults().getSubreportHeight(); + } + + // crosstab + + /** + *

getCrosstabWidth.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @return a int. + */ + protected int getCrosstabWidth(final DRICrosstab crosstab) + { + if(crosstab.getWidth() != null) + { + return crosstab.getWidth(); + } + if(this.template.getCrosstabWidth() != null) + { + return this.template.getCrosstabWidth(); + } + return Defaults.getDefaults().getCrosstabWidth(); + } + + /** + *

getCrosstabHeight.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @param whenNoDataCell a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCellContent} object. + * @return a int. + */ + protected int getCrosstabHeight(final DRICrosstab crosstab, final DRDesignCrosstabCellContent whenNoDataCell) + { + final int height; + if(crosstab.getHeight() != null) + { + height = crosstab.getHeight(); + } + else if(this.template.getCrosstabHeight() != null) + { + height = this.template.getCrosstabHeight(); + } + else + { + height = Defaults.getDefaults().getCrosstabHeight(); + } + final int whenNoDataCellHeight = this.getCrosstabWhenNoDataCellHeight(whenNoDataCell); + if(height == 0 && whenNoDataCellHeight > 0) + { + return whenNoDataCellHeight; + } + return height; + } + + /** + *

getCrosstabColumnGroupTotalPosition.

+ * + * @param columnGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup} object. + * @return a {@link software.xdev.dynamicreports.report.constant.CrosstabTotalPosition} object. + */ + public CrosstabTotalPosition getCrosstabColumnGroupTotalPosition(final DRICrosstabColumnGroup columnGroup) + { + if(!this.isCrosstabColumnGroupShowTotal(columnGroup)) + { + return null; + } + if(columnGroup.getTotalPosition() != null) + { + return columnGroup.getTotalPosition(); + } + return Defaults.getDefaults().getCrosstabColumnGroupTotalPosition(); + } + + /** + *

getCrosstabRowGroupTotalPosition.

+ * + * @param rowGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup} object. + * @return a {@link software.xdev.dynamicreports.report.constant.CrosstabTotalPosition} object. + */ + public CrosstabTotalPosition getCrosstabRowGroupTotalPosition(final DRICrosstabRowGroup rowGroup) + { + if(!this.isCrosstabRowGroupShowTotal(rowGroup)) + { + return null; + } + if(rowGroup.getTotalPosition() != null) + { + return rowGroup.getTotalPosition(); + } + return Defaults.getDefaults().getCrosstabRowGroupTotalPosition(); + } + + /** + *

isCrosstabColumnGroupShowTotal.

+ * + * @param columnGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup} object. + * @return a boolean. + */ + public boolean isCrosstabColumnGroupShowTotal(final DRICrosstabColumnGroup columnGroup) + { + if(columnGroup.getShowTotal() != null) + { + return columnGroup.getShowTotal(); + } + return Defaults.getDefaults().isCrosstabColumnGroupShowTotal(); + } + + /** + *

isCrosstabRowGroupShowTotal.

+ * + * @param rowGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup} object. + * @return a boolean. + */ + public boolean isCrosstabRowGroupShowTotal(final DRICrosstabRowGroup rowGroup) + { + if(rowGroup.getShowTotal() != null) + { + return rowGroup.getShowTotal(); + } + return Defaults.getDefaults().isCrosstabRowGroupShowTotal(); + } + + /** + *

getCrosstabColumnGroupHeaderHeight.

+ * + * @param columnGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup} object. + * @param designCrosstab a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab} object. + * @param availableHeight a int. + * @return a int. + */ + public int getCrosstabColumnGroupHeaderHeight( + final DRICrosstabColumnGroup columnGroup, + final DRDesignCrosstab designCrosstab, + final int availableHeight) + { + if(columnGroup.getHeaderHeight() != null) + { + return columnGroup.getHeaderHeight(); + } + int maxHeight = 0; + for(final DRDesignCrosstabColumnGroup designColumnGroup : designCrosstab.getColumnGroups()) + { + if(designColumnGroup.getName().equals(columnGroup.getName())) + { + int height = this.detectHeight(designColumnGroup.getHeader().getList()); + if(maxHeight < height) + { + maxHeight = height; + } + if(designColumnGroup.getTotalHeader() != null) + { + height = this.detectHeight(designColumnGroup.getTotalHeader().getList()); + if(maxHeight < height && height > availableHeight) + { + maxHeight = height; + } + } + break; + } + } + return maxHeight; + } + + /** + *

getCrosstabColumnGroupTotalHeaderWidth.

+ * + * @param columnGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup} object. + * @param cellWidth a {@link java.lang.Integer} object. + * @param designCrosstab a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab} object. + * @return a int. + */ + public int getCrosstabColumnGroupTotalHeaderWidth( + final DRICrosstabColumnGroup columnGroup, + final Integer cellWidth, + final DRDesignCrosstab designCrosstab) + { + if(columnGroup.getTotalHeaderWidth() != null) + { + return columnGroup.getTotalHeaderWidth(); + } + if(cellWidth != null) + { + return cellWidth; + } + int maxWidth = 0; + for(final DRDesignCrosstabColumnGroup designColumnGroup : designCrosstab.getColumnGroups()) + { + if(designColumnGroup.getName().equals(columnGroup.getName())) + { + if(designColumnGroup.getTotalHeader() != null) + { + final int height = this.detectWidth(designColumnGroup.getTotalHeader().getList()); + if(maxWidth < height) + { + maxWidth = height; + } + } + break; + } + } + for(final DRDesignCrosstabCell designCell : designCrosstab.getCells()) + { + if(designCell.getColumnTotalGroup() == columnGroup.getName()) + { + final int height = this.detectWidth(designCell.getContent().getList()); + if(maxWidth < height) + { + maxWidth = height; + } + } + } + if(maxWidth > Defaults.getDefaults().getCrosstabColumnGroupTotalHeaderMaxWidth()) + { + return Defaults.getDefaults().getCrosstabColumnGroupTotalHeaderMaxWidth(); + } + return maxWidth; + } + + /** + *

getCrosstabRowGroupHeaderWidth.

+ * + * @param rowGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup} object. + * @param designCrosstab a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab} object. + * @return a int. + */ + public int getCrosstabRowGroupHeaderWidth( + final DRICrosstabRowGroup rowGroup, + final DRDesignCrosstab designCrosstab) + { + if(rowGroup.getHeaderWidth() != null) + { + return rowGroup.getHeaderWidth(); + } + int maxWidth = 0; + for(final DRDesignCrosstabRowGroup designRowGroup : designCrosstab.getRowGroups()) + { + if(designRowGroup.getName().equals(rowGroup.getName())) + { + int width = this.detectWidth(designRowGroup.getHeader().getList()); + if(maxWidth < width) + { + maxWidth = width; + } + if(designRowGroup.getTotalHeader() != null) + { + width = this.detectWidth(designRowGroup.getTotalHeader().getList()); + if(maxWidth < width) + { + maxWidth = width; + } + } + break; + } + } + if(maxWidth > Defaults.getDefaults().getCrosstabRowGroupHeaderMaxWidth()) + { + return Defaults.getDefaults().getCrosstabRowGroupHeaderMaxWidth(); + } + return maxWidth; + } + + /** + *

getCrosstabRowGroupTotalHeaderHeight.

+ * + * @param rowGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup} object. + * @param cellHeight a {@link java.lang.Integer} object. + * @param designCrosstab a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab} object. + * @return a int. + */ + public int getCrosstabRowGroupTotalHeaderHeight( + final DRICrosstabRowGroup rowGroup, + final Integer cellHeight, + final DRDesignCrosstab designCrosstab) + { + if(rowGroup.getTotalHeaderHeight() != null) + { + return rowGroup.getTotalHeaderHeight(); + } + if(cellHeight != null) + { + return cellHeight; + } + int maxHeight = 0; + for(final DRDesignCrosstabRowGroup designRowGroup : designCrosstab.getRowGroups()) + { + if(designRowGroup.getName().equals(rowGroup.getName())) + { + if(designRowGroup.getTotalHeader() != null) + { + final int height = this.detectHeight(designRowGroup.getTotalHeader().getList()); + if(maxHeight < height) + { + maxHeight = height; + } + } + break; + } + } + for(final DRDesignCrosstabCell designCell : designCrosstab.getCells()) + { + if(designCell.getRowTotalGroup() == rowGroup.getName()) + { + final int height = this.detectHeight(designCell.getContent().getList()); + if(maxHeight < height) + { + maxHeight = height; + } + } + } + return maxHeight; + } + + /** + *

getCrosstabCellWidth.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @param designCrosstab a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab} object. + * @return a int. + */ + public int getCrosstabCellWidth(final DRICrosstab crosstab, final DRDesignCrosstab designCrosstab) + { + if(crosstab.getCellWidth() != null) + { + return crosstab.getCellWidth(); + } + int maxWidth = 0; + for(final DRDesignCrosstabCell designCell : designCrosstab.getCells()) + { + if(designCell.getColumnTotalGroup() == null) + { + final int width = this.detectWidth(designCell.getContent().getList()); + if(maxWidth < width) + { + maxWidth = width; + } + } + } + for(final DRDesignCrosstabColumnGroup designColumnGroup : designCrosstab.getColumnGroups()) + { + final int width = this.detectWidth(designColumnGroup.getHeader().getList()); + if(maxWidth < width) + { + maxWidth = width; + } + } + if(maxWidth > Defaults.getDefaults().getCrosstabCellMaxWidth()) + { + return Defaults.getDefaults().getCrosstabCellMaxWidth(); + } + return maxWidth; + } + + /** + *

getCrosstabCellHeight.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @param designCrosstab a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab} object. + * @return a int. + */ + public int getCrosstabCellHeight(final DRICrosstab crosstab, final DRDesignCrosstab designCrosstab) + { + if(crosstab.getCellHeight() != null) + { + return crosstab.getCellHeight(); + } + int maxHeight = 0; + for(final DRDesignCrosstabCell designCell : designCrosstab.getCells()) + { + if(designCell.getRowTotalGroup() == null) + { + final int height = this.detectHeight(designCell.getContent().getList()); + if(maxHeight < height) + { + maxHeight = height; + } + } + } + for(final DRDesignCrosstabRowGroup designRowGroup : designCrosstab.getRowGroups()) + { + final int height = this.detectHeight(designRowGroup.getHeader().getList()); + if(maxHeight < height) + { + maxHeight = height; + } + } + return maxHeight; + } + + /** + *

getCrosstabWhenNoDataCellHeight.

+ * + * @param whenNoDataCell a {@link software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstabCellContent} object. + * @return a int. + */ + public int getCrosstabWhenNoDataCellHeight(final DRDesignCrosstabCellContent whenNoDataCell) + { + return this.detectHeight(whenNoDataCell.getList()); + } + + /** + *

getCrosstabOddRowStyle.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + protected DRISimpleStyle getCrosstabOddRowStyle(final DRICrosstab crosstab) + { + if(this.isCrosstabHighlightOddRows(crosstab)) + { + if(crosstab.getOddRowStyle() != null) + { + return crosstab.getOddRowStyle(); + } + if(this.template.getCrosstabOddRowStyle() != null) + { + return this.template.getCrosstabOddRowStyle(); + } + return Defaults.getDefaults().getCrosstabOddRowStyle(); + } + return null; + } + + /** + *

getCrosstabEvenRowStyle.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + protected DRISimpleStyle getCrosstabEvenRowStyle(final DRICrosstab crosstab) + { + if(this.isCrosstabHighlightEvenRows(crosstab)) + { + if(crosstab.getEvenRowStyle() != null) + { + return crosstab.getEvenRowStyle(); + } + if(this.template.getCrosstabEvenRowStyle() != null) + { + return this.template.getCrosstabEvenRowStyle(); + } + return Defaults.getDefaults().getCrosstabEvenRowStyle(); + } + return null; + } + + private boolean isCrosstabHighlightOddRows(final DRICrosstab crosstab) + { + if(crosstab.getHighlightOddRows() != null) + { + return crosstab.getHighlightOddRows(); + } + if(this.template.getCrosstabHighlightOddRows() != null) + { + return this.template.getCrosstabHighlightOddRows(); + } + return Defaults.getDefaults().isCrosstabHighlightOddRows(); + } + + private boolean isCrosstabHighlightEvenRows(final DRICrosstab crosstab) + { + if(crosstab.getHighlightEvenRows() != null) + { + return crosstab.getHighlightEvenRows(); + } + if(this.template.getCrosstabHighlightEvenRows() != null) + { + return this.template.getCrosstabHighlightEvenRows(); + } + return Defaults.getDefaults().isCrosstabHighlightEvenRows(); + } + + /** + *

getCrosstabGroupStyle.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getCrosstabGroupStyle(final DRICrosstab crosstab) + { + if(crosstab.getGroupStyle() != null) + { + return crosstab.getGroupStyle(); + } + if(this.template.getCrosstabGroupStyle() != null) + { + return this.template.getCrosstabGroupStyle(); + } + if(Defaults.getDefaults().getCrosstabGroupStyle() != null) + { + return Defaults.getDefaults().getCrosstabGroupStyle(); + } + return this.getTextStyle(); + } + + /** + *

getCrosstabGroupTotalStyle.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getCrosstabGroupTotalStyle(final DRICrosstab crosstab) + { + if(crosstab.getGroupTotalStyle() != null) + { + return crosstab.getGroupTotalStyle(); + } + if(this.template.getCrosstabGroupTotalStyle() != null) + { + return this.template.getCrosstabGroupTotalStyle(); + } + if(Defaults.getDefaults().getCrosstabGroupTotalStyle() != null) + { + return Defaults.getDefaults().getCrosstabGroupTotalStyle(); + } + return this.getTextStyle(); + } + + /** + *

getCrosstabGrandTotalStyle.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getCrosstabGrandTotalStyle(final DRICrosstab crosstab) + { + if(crosstab.getGrandTotalStyle() != null) + { + return crosstab.getGrandTotalStyle(); + } + if(this.template.getCrosstabGrandTotalStyle() != null) + { + return this.template.getCrosstabGrandTotalStyle(); + } + if(Defaults.getDefaults().getCrosstabGrandTotalStyle() != null) + { + return Defaults.getDefaults().getCrosstabGrandTotalStyle(); + } + return this.getTextStyle(); + } + + /** + *

getCrosstabCellStyle.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getCrosstabCellStyle(final DRICrosstab crosstab) + { + if(crosstab.getCellStyle() != null) + { + return crosstab.getCellStyle(); + } + if(this.template.getCrosstabCellStyle() != null) + { + return this.template.getCrosstabCellStyle(); + } + if(Defaults.getDefaults().getCrosstabCellStyle() != null) + { + return Defaults.getDefaults().getCrosstabCellStyle(); + } + return this.getTextStyle(); + } + + /** + *

getCrosstabMeasureTitleStyle.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @param measure a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabMeasure} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getCrosstabMeasureTitleStyle(final DRICrosstab crosstab, final DRICrosstabMeasure measure) + { + if(measure.getTitleStyle() != null) + { + return measure.getTitleStyle(); + } + if(crosstab.getMeasureTitleStyle() != null) + { + return crosstab.getMeasureTitleStyle(); + } + if(this.template.getCrosstabMeasureTitleStyle() != null) + { + return this.template.getCrosstabMeasureTitleStyle(); + } + return Defaults.getDefaults().getCrosstabMeasureTitleStyle(); + } + + /** + *

getCrosstabPercentageType.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabVariable} object. + * @return a {@link software.xdev.dynamicreports.report.constant.CrosstabPercentageType} object. + */ + protected CrosstabPercentageType getCrosstabPercentageType(final DRICrosstabVariable variable) + { + if(variable.getPercentageType() != null) + { + return variable.getPercentageType(); + } + return Defaults.getDefaults().getCrosstabPercentageType(); + } + + /** + *

getBooleanComponentType.

+ * + * @param booleanField a {@link software.xdev.dynamicreports.report.definition.component.DRIBooleanField} object. + * @return a {@link software.xdev.dynamicreports.report.constant.BooleanComponentType} object. + */ + public BooleanComponentType getBooleanComponentType(final DRIBooleanField booleanField) + { + if(booleanField.getComponentType() != null) + { + return booleanField.getComponentType(); + } + if(this.template.getBooleanComponentType() != null) + { + return this.template.getBooleanComponentType(); + } + return Defaults.getDefaults().getBooleanComponentType(); + } + + /** + *

getBooleanEmptyWhenNullValue.

+ * + * @param booleanField a {@link software.xdev.dynamicreports.report.definition.component.DRIBooleanField} object. + * @return a boolean. + */ + public boolean getBooleanEmptyWhenNullValue(final DRIBooleanField booleanField) + { + if(booleanField.getEmptyWhenNullValue() != null) + { + return booleanField.getEmptyWhenNullValue(); + } + if(this.template.getBooleanEmptyWhenNullValue() != null) + { + return this.template.getBooleanEmptyWhenNullValue(); + } + return Defaults.getDefaults().isBooleanEmptyWhenNullValue(); + } + + /** + *

getBooleanImageWidth.

+ * + * @param booleanField a {@link software.xdev.dynamicreports.report.definition.component.DRIBooleanField} object. + * @return a int. + */ + public int getBooleanImageWidth(final DRIBooleanField booleanField) + { + if(booleanField.getImageWidth() != null) + { + return booleanField.getImageWidth(); + } + if(this.template.getBooleanImageWidth() != null) + { + return this.template.getBooleanImageWidth(); + } + return Defaults.getDefaults().getBooleanImageWidth(); + } + + /** + *

getBooleanImageHeight.

+ * + * @param booleanField a {@link software.xdev.dynamicreports.report.definition.component.DRIBooleanField} object. + * @return a int. + */ + public int getBooleanImageHeight(final DRIBooleanField booleanField) + { + if(booleanField.getImageHeight() != null) + { + return booleanField.getImageHeight(); + } + if(this.template.getBooleanImageHeight() != null) + { + return this.template.getBooleanImageHeight(); + } + return Defaults.getDefaults().getBooleanImageHeight(); + } + + /** + *

getBooleanHorizontalImageAlignment.

+ * + * @param booleanField a {@link software.xdev.dynamicreports.report.definition.component.DRIBooleanField} object. + * @param style a {@link software.xdev.dynamicreports.design.base.style.DRDesignStyle} object. + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + protected HorizontalImageAlignment getBooleanHorizontalImageAlignment( + final DRIBooleanField booleanField, + final DRDesignStyle style) + { + if(booleanField.getHorizontalImageAlignment() != null) + { + return booleanField.getHorizontalImageAlignment(); + } + if(StyleResolver.getHorizontalImageAlignment(style) != null) + { + return null;// StyleResolver.getHorizontalAlignment(style); + } + return Defaults.getDefaults().getBooleanHorizontalImageAlignment(); + } + + /** + *

getBooleanColumnStyle.

+ * + * @param column a {@link software.xdev.dynamicreports.report.definition.column.DRIBooleanColumn} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getBooleanColumnStyle(final DRIBooleanColumn column) + { + if(column.getComponent().getStyle() != null) + { + return column.getComponent().getStyle(); + } + if(this.template.getBooleanColumnStyle() != null) + { + return this.template.getBooleanColumnStyle(); + } + return Defaults.getDefaults().getBooleanColumnStyle(); + } + + /** + *

getTemplateStyles.

+ * + * @return a {@link java.util.Map} object. + */ + public Map getTemplateStyles() + { + final Map templateStyles = new HashMap<>(); + for(final DRIStyle style : this.template.getTemplateStyles()) + { + templateStyles.put(style.getName(), style); + } + for(final DRIStyle style : this.report.getTemplateStyles()) + { + templateStyles.put(style.getName(), style); + } + return templateStyles; + } + + // split + + /** + *

getTitleSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getTitleSplitType(final DRIBand band) + { + return this.getSplitType(band, this.template.getTitleSplitType(), Defaults.getDefaults().getTitleSplitType()); + } + + /** + *

getPageHeaderSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getPageHeaderSplitType(final DRIBand band) + { + return this.getSplitType(band, + this.template.getPageHeaderSplitType(), Defaults.getDefaults().getPageHeaderSplitType()); + } + + /** + *

getPageFooterSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getPageFooterSplitType(final DRIBand band) + { + return this.getSplitType(band, + this.template.getPageFooterSplitType(), Defaults.getDefaults().getPageFooterSplitType()); + } + + /** + *

getColumnHeaderSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getColumnHeaderSplitType(final DRIBand band) + { + return this.getSplitType( + band, + this.template.getColumnHeaderSplitType(), + Defaults.getDefaults().getColumnHeaderSplitType()); + } + + /** + *

getColumnFooterSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getColumnFooterSplitType(final DRIBand band) + { + return this.getSplitType( + band, + this.template.getColumnFooterSplitType(), + Defaults.getDefaults().getColumnFooterSplitType()); + } + + /** + *

getGroupHeaderSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getGroupHeaderSplitType(final DRIBand band) + { + return this.getSplitType(band, this.template.getGroupHeaderSplitType(), + Defaults.getDefaults().getGroupHeaderSplitType()); + } + + /** + *

getGroupFooterSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getGroupFooterSplitType(final DRIBand band) + { + return this.getSplitType(band, this.template.getGroupFooterSplitType(), + Defaults.getDefaults().getGroupFooterSplitType()); + } + + /** + *

getDetailHeaderSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getDetailHeaderSplitType(final DRIBand band) + { + return this.getSplitType( + band, + this.template.getDetailHeaderSplitType(), + Defaults.getDefaults().getDetailHeaderSplitType()); + } + + /** + *

getDetailSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getDetailSplitType(final DRIBand band) + { + return this.getSplitType(band, this.template.getDetailSplitType(), Defaults.getDefaults().getDetailSplitType()); + } + + /** + *

getDetailFooterSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getDetailFooterSplitType(final DRIBand band) + { + return this.getSplitType( + band, + this.template.getDetailFooterSplitType(), + Defaults.getDefaults().getDetailFooterSplitType()); + } + + /** + *

getLastPageFooterSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getLastPageFooterSplitType(final DRIBand band) + { + return this.getSplitType( + band, + this.template.getLastPageFooterSplitType(), + Defaults.getDefaults().getLastPageFooterSplitType()); + } + + /** + *

getSummarySplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getSummarySplitType(final DRIBand band) + { + return this.getSplitType(band, this.template.getSummarySplitType(), Defaults.getDefaults().getSummarySplitType()); + } + + /** + *

getNoDataSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getNoDataSplitType(final DRIBand band) + { + return this.getSplitType(band, this.template.getNoDataSplitType(), Defaults.getDefaults().getNoDataSplitType()); + } + + /** + *

getBackgroundSplitType.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + protected SplitType getBackgroundSplitType(final DRIBand band) + { + return this.getSplitType(band, + this.template.getBackgroundSplitType(), Defaults.getDefaults().getBackgroundSplitType()); + } + + private SplitType getSplitType(final DRIBand band, final SplitType templateSplitType, final SplitType splitType) + { + if(band.getSplitType() != null) + { + return band.getSplitType(); + } + if(templateSplitType != null) + { + return templateSplitType; + } + if(splitType != null) + { + return splitType; + } + if(this.template.getDefaultSplitType() != null) + { + return this.template.getDefaultSplitType(); + } + return Defaults.getDefaults().getDefaultSplitType(); + } + + // band style + + /** + *

getTitleStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getTitleStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getTitleStyle()); + } + + /** + *

getPageHeaderStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getPageHeaderStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getPageHeaderStyle()); + } + + /** + *

getPageFooterStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getPageFooterStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getPageFooterStyle()); + } + + /** + *

getColumnHeaderStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getColumnHeaderStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getColumnHeaderStyle()); + } + + /** + *

getColumnFooterStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getColumnFooterStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getColumnFooterStyle()); + } + + /** + *

getGroupHeaderStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getGroupHeaderStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getGroupHeaderStyle()); + } + + /** + *

getGroupFooterStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getGroupFooterStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getGroupFooterStyle()); + } + + /** + *

getDetailHeaderStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getDetailHeaderStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getDetailHeaderStyle()); + } + + /** + *

getDetailStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getDetailStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getDetailStyle()); + } + + /** + *

getDetailFooterStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getDetailFooterStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getDetailFooterStyle()); + } + + /** + *

getLastPageFooterStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getLastPageFooterStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getLastPageFooterStyle()); + } + + /** + *

getSummaryStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getSummaryStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getSummaryStyle()); + } + + /** + *

getNoDataStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getNoDataStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getNoDataStyle()); + } + + /** + *

getBackgroundStyle.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + protected DRIReportStyle getBackgroundStyle(final DRIBand band) + { + return this.getBandStyle(band, this.template.getBackgroundStyle()); + } + + private DRIReportStyle getBandStyle(final DRIBand band, final DRIReportStyle templateStyle) + { + if(band.getList().getStyle() != null) + { + return band.getList().getStyle(); + } + if(templateStyle != null) + { + return templateStyle; + } + return Defaults.getDefaults().getBandStyle(); + } + + // band background component + + /** + *

getTitleBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getTitleBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getTitleBackgroundComponent()); + } + + /** + *

getPageHeaderBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getPageHeaderBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getPageHeaderBackgroundComponent()); + } + + /** + *

getPageFooterBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getPageFooterBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getPageFooterBackgroundComponent()); + } + + /** + *

getColumnHeaderBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getColumnHeaderBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getColumnHeaderBackgroundComponent()); + } + + /** + *

getColumnFooterBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getColumnFooterBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getColumnFooterBackgroundComponent()); + } + + /** + *

getGroupHeaderBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getGroupHeaderBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getGroupHeaderBackgroundComponent()); + } + + /** + *

getGroupFooterBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getGroupFooterBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getGroupFooterBackgroundComponent()); + } + + /** + *

getDetailHeaderBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getDetailHeaderBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getDetailHeaderBackgroundComponent()); + } + + /** + *

getDetailBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getDetailBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getDetailBackgroundComponent()); + } + + /** + *

getDetailFooterBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getDetailFooterBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getDetailFooterBackgroundComponent()); + } + + /** + *

getLastPageFooterBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getLastPageFooterBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getLastPageFooterBackgroundComponent()); + } + + /** + *

getSummaryBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getSummaryBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getSummaryBackgroundComponent()); + } + + /** + *

getNoDataBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getNoDataBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getNoDataBackgroundComponent()); + } + + /** + *

getBackgroundBackgroundComponent.

+ * + * @param band a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + protected DRIComponent getBackgroundBackgroundComponent(final DRIBand band) + { + return this.getBandBackgroundComponent(band, this.template.getBackgroundBackgroundComponent()); + } + + private DRIComponent getBandBackgroundComponent(final DRIBand band, final DRIComponent templateBackgroundComponent) + { + if(band.getList().getBackgroundComponent() != null) + { + return band.getList().getBackgroundComponent(); + } + if(templateBackgroundComponent != null) + { + return templateBackgroundComponent; + } + return Defaults.getDefaults().getBandBackgroundComponent(); + } + + private int detectWidth(final DRDesignList designList) + { + ComponentPosition.width(designList); + return designList.getWidth(); + } + + private int detectHeight(final DRDesignList designList) + { + ComponentPosition.height(designList); + return designList.getHeight(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/BooleanTextValueFormatter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/BooleanTextValueFormatter.java new file mode 100644 index 0000000..8925acf --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/BooleanTextValueFormatter.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.base.expression.AbstractValueFormatter; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +import java.util.ResourceBundle; + +/** + *

BooleanTextValueFormatter class.

+ * + * @author Ricardo Mariaca + * + */ +public class BooleanTextValueFormatter extends AbstractValueFormatter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String keyTrue; + private String keyFalse; + private boolean emptyWhenNullValue; + + /** + *

Constructor for BooleanTextValueFormatter.

+ * + * @param keyTrue a {@link java.lang.String} object. + * @param keyFalse a {@link java.lang.String} object. + * @param emptyWhenNullValue a boolean. + */ + public BooleanTextValueFormatter(String keyTrue, String keyFalse, boolean emptyWhenNullValue) { + this.keyTrue = keyTrue; + this.keyFalse = keyFalse; + this.emptyWhenNullValue = emptyWhenNullValue; + } + + /** {@inheritDoc} */ + @Override + public String format(Boolean value, ReportParameters reportParameters) { + if (emptyWhenNullValue && value == null) { + return ""; + } + String key; + if (value != null && value) { + key = keyTrue; + } else { + key = keyFalse; + } + return ResourceBundle.getBundle(Constants.RESOURCE_BUNDLE_NAME, reportParameters.getLocale()).getString(key); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabExpression.java new file mode 100644 index 0000000..2bd209c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabExpression.java @@ -0,0 +1,90 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.builder.expression.AbstractComplexExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRICustomValues; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabMeasure; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabVariable; +import software.xdev.dynamicreports.report.definition.expression.DRIComplexExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.List; + +/** + *

CrosstabExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class CrosstabExpression extends AbstractComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression expression; + + /** + *

Constructor for CrosstabExpression.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab} object. + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public CrosstabExpression(DRICrosstab crosstab, DRIExpression expression) throws DRException { + this.expression = expression; + if (expression instanceof DRIComplexExpression) { + for (DRIExpression express : ((DRIComplexExpression) expression).getExpressions()) { + addExpression(express); + } + } + for (DRICrosstabVariable variable : crosstab.getVariables()) { + addExpression(variable); + } + for (DRICrosstabMeasure measure : crosstab.getMeasures()) { + if (measure.getExpression() instanceof DRICrosstabVariable) { + addExpression(measure.getExpression()); + } + } + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override + public T evaluate(List values, ReportParameters reportParameters) { + DRICustomValues customValues = (DRICustomValues) reportParameters.getParameterValue(DRICustomValues.NAME); + for (int i = 0; i < getExpressions().size(); i++) { + customValues.setSystemValue(getExpressions().get(i).getName(), values.get(i)); + } + if (expression instanceof DRIComplexExpression) { + DRIComplexExpression express = (DRIComplexExpression) expression; + return (T) express.evaluate(values, reportParameters); + } else { + return reportParameters.getValue(expression.getName()); + } + } + + /** {@inheritDoc} */ + @SuppressWarnings( {"rawtypes", "unchecked"}) + @Override + public Class getValueClass() { + return expression.getValueClass(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabMeasureExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabMeasureExpression.java new file mode 100644 index 0000000..bc6dcd6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabMeasureExpression.java @@ -0,0 +1,54 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.builder.expression.AbstractComplexExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.util.List; + +/** + *

CrosstabMeasureExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class CrosstabMeasureExpression extends AbstractComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for CrosstabMeasureExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public CrosstabMeasureExpression(DRIExpression expression) { + addExpression(expression); + } + + /** {@inheritDoc} */ + @Override + public Double evaluate(List values, ReportParameters reportParameters) { + Number value = (Number) values.get(0); + if (value != null) { + return value.doubleValue(); + } + return null; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabPrintInEvenRow.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabPrintInEvenRow.java new file mode 100644 index 0000000..ac39847 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabPrintInEvenRow.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

CrosstabPrintInEvenRow class.

+ * + * @author Ricardo Mariaca + * + */ +public class CrosstabPrintInEvenRow extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + return reportParameters.getCrosstabRowNumber() % 2 == 0; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabPrintInOddRow.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabPrintInOddRow.java new file mode 100644 index 0000000..4164a7d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabPrintInOddRow.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

CrosstabPrintInOddRow class.

+ * + * @author Ricardo Mariaca + * + */ +public class CrosstabPrintInOddRow extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + return reportParameters.getCrosstabRowNumber() % 2 != 0; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabRowCount.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabRowCount.java new file mode 100644 index 0000000..cb7391a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabRowCount.java @@ -0,0 +1,40 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

CrosstabRowCount class.

+ * + * @author Ricardo Mariaca + * + */ +public class CrosstabRowCount extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + CrosstabRowCounter counter = reportParameters.getValue(ReportParameters.CROSSTAB_ROW_COUNTER); + counter.increment(); + return false; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabRowCounter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabRowCounter.java new file mode 100644 index 0000000..e8fd6a7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CrosstabRowCounter.java @@ -0,0 +1,62 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

CrosstabRowCounter class.

+ * + * @author Ricardo Mariaca + * + */ +public class CrosstabRowCounter extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int rowNumber = 1; + + /** {@inheritDoc} */ + @Override + public CrosstabRowCounter evaluate(ReportParameters reportParameters) { + return this; + } + + /** + *

increment.

+ */ + public void increment() { + rowNumber++; + } + + /** + *

Getter for the field rowNumber.

+ * + * @return a int. + */ + public int getRowNumber() { + return rowNumber; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return ReportParameters.CROSSTAB_ROW_COUNTER; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CurrentDateExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CurrentDateExpression.java new file mode 100644 index 0000000..c933445 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/CurrentDateExpression.java @@ -0,0 +1,69 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.builder.datatype.DataTypes; +import software.xdev.dynamicreports.report.builder.expression.AbstractComplexExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.text.MessageFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +/** + *

CurrentDateExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class CurrentDateExpression extends AbstractComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String datePattern; + + /** + *

Constructor for CurrentDateExpression.

+ * + * @param currentDateExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param datePattern a {@link java.lang.String} object. + */ + public CurrentDateExpression(DRIExpression currentDateExpression, String datePattern) { + this.datePattern = datePattern; + addExpression(currentDateExpression); + } + + /** {@inheritDoc} */ + @Override + public String evaluate(List values, ReportParameters reportParameters) { + String pattern = (String) values.get(0); + Locale locale = reportParameters.getLocale(); + MessageFormat format = new MessageFormat(pattern, locale); + String date; + if (datePattern == null) { + date = DataTypes.dateType().valueToString(new Date(), locale); + } else { + date = new SimpleDateFormat(datePattern, locale).format(new Date()); + } + String result = format.format(new Object[] {date}); + return result; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/GroupByDataTypeExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/GroupByDataTypeExpression.java new file mode 100644 index 0000000..9a7a813 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/GroupByDataTypeExpression.java @@ -0,0 +1,53 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

GroupByDataTypeExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class GroupByDataTypeExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + DRIDataType dataType; + private DRIExpression valueExpression; + + /** + *

Constructor for GroupByDataTypeExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + */ + public GroupByDataTypeExpression(DRIExpression valueExpression, DRIDataType dataType) { + this.valueExpression = valueExpression; + this.dataType = dataType; + } + + /** {@inheritDoc} */ + @Override + public String evaluate(ReportParameters reportParameters) { + return dataType.valueToString(valueExpression.getName(), reportParameters); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/MultiPageListDataSourceExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/MultiPageListDataSourceExpression.java new file mode 100644 index 0000000..2c5cbc6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/MultiPageListDataSourceExpression.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JREmptyDataSource; + +/** + *

MultiPageListDataSourceExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class MultiPageListDataSourceExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int count; + + /** + *

Constructor for MultiPageListDataSourceExpression.

+ * + * @param count a int. + */ + public MultiPageListDataSourceExpression(int count) { + this.count = count; + } + + /** {@inheritDoc} */ + @Override + public JRDataSource evaluate(ReportParameters reportParameters) { + return new JREmptyDataSource(count); + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return JRDataSource.class; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/MultiPageListSubreportExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/MultiPageListSubreportExpression.java new file mode 100644 index 0000000..681e922 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/MultiPageListSubreportExpression.java @@ -0,0 +1,90 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.DRBand; +import software.xdev.dynamicreports.report.base.component.DRComponent; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; + +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; + +/** + *

MultiPageListSubreportExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class MultiPageListSubreportExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Locale locale; + private ResourceBundle resourceBundle; + private String resourceBundleName; + private WhenResourceMissingType whenResourceMissingType; + private List detailComponents; + private Map templateStyles; + + /** + *

Constructor for MultiPageListSubreportExpression.

+ * + * @param locale a {@link java.util.Locale} object. + * @param resourceBundle a {@link java.util.ResourceBundle} object. + * @param resourceBundleName a {@link java.lang.String} object. + * @param resourceBundleName a {@link java.lang.String} object. + * @param whenResourceMissingType a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + * @param detailComponents a {@link java.util.List} object. + * @param templateStyles a {@link java.util.Map} object. + */ + public MultiPageListSubreportExpression(Locale locale, ResourceBundle resourceBundle, String resourceBundleName, WhenResourceMissingType whenResourceMissingType, + List detailComponents, Map templateStyles) { + this.locale = locale; + this.resourceBundle = resourceBundle; + this.resourceBundleName = resourceBundleName; + this.whenResourceMissingType = whenResourceMissingType; + this.detailComponents = detailComponents; + this.templateStyles = templateStyles; + } + + /** {@inheritDoc} */ + @Override + public JasperReportBuilder evaluate(ReportParameters reportParameters) { + JasperReportBuilder report = report(); + report.setLocale(locale); + report.setResourceBundle(resourceBundle); + report.setResourceBundle(resourceBundleName); + report.setWhenResourceMissingType(whenResourceMissingType); + for (DRIStyle style : templateStyles.values()) { + report.getReport().addTemplateStyle(style); + } + DRBand titleBand = report.getReport().getTitleBand(); + DRComponent detailComponent = (DRComponent) detailComponents.get(reportParameters.getReportRowNumber() - 1); + titleBand.addComponent(detailComponent); + return report; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/PageNumberExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/PageNumberExpression.java new file mode 100644 index 0000000..57baf47 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/PageNumberExpression.java @@ -0,0 +1,54 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.builder.expression.AbstractComplexExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.text.MessageFormat; +import java.util.List; + +/** + *

PageNumberExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class PageNumberExpression extends AbstractComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for PageNumberExpression.

+ * + * @param pageNumberFormatExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public PageNumberExpression(DRIExpression pageNumberFormatExpression) { + addExpression(pageNumberFormatExpression); + } + + /** {@inheritDoc} */ + @Override + public String evaluate(List values, ReportParameters reportParameters) { + String pattern = (String) values.get(0); + MessageFormat format = new MessageFormat(pattern, reportParameters.getLocale()); + String result = format.format(new Object[] {reportParameters.getPageNumber()}); + return result; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/PageXofYNumberExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/PageXofYNumberExpression.java new file mode 100644 index 0000000..cf7ad21 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/PageXofYNumberExpression.java @@ -0,0 +1,69 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.builder.expression.AbstractComplexExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; + +import java.text.MessageFormat; +import java.util.List; + +/** + *

PageXofYNumberExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class PageXofYNumberExpression extends AbstractComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int index; + + /** + *

Constructor for PageXofYNumberExpression.

+ * + * @param pageNumberFormatExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param index a int. + */ + public PageXofYNumberExpression(DRIExpression pageNumberFormatExpression, int index) { + addExpression(pageNumberFormatExpression); + this.index = index; + } + + /** {@inheritDoc} */ + @Override + public String evaluate(List values, ReportParameters reportParameters) { + String pattern = (String) values.get(0); + Validate.isTrue(StringUtils.contains(pattern, "{0}"), "Wrong format pattern \"" + pattern + "\", missing argument {0}"); + Validate.isTrue(StringUtils.contains(pattern, "{1}"), "Wrong format pattern \"" + pattern + "\", missing argument {1}"); + Validate.isTrue(pattern.indexOf("{0}") < pattern.indexOf("{1}"), "Wrong format pattern \"" + pattern + "\", argument {0} must be before {1}"); + int index1 = pattern.indexOf("{0}"); + if (index == 0) { + pattern = pattern.substring(0, index1 + 3); + } else { + pattern = pattern.substring(index1 + 3); + } + MessageFormat format = new MessageFormat(pattern, reportParameters.getLocale()); + String result = format.format(new Object[] {reportParameters.getPageNumber(), reportParameters.getPageNumber()}); + return result; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/SerieValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/SerieValueExpression.java new file mode 100644 index 0000000..e372ba6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/SerieValueExpression.java @@ -0,0 +1,114 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +import java.util.HashMap; +import java.util.Map; + +/** + *

SerieValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class SerieValueExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIDesignExpression valueExpression; + private DRIDesignExpression serieExpression; + private ResetType resetType; + private DRDesignGroup resetGroup; + private String key; + private Object resetValue; + private Map values; + + /** + *

Constructor for SerieValueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + * @param serieExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + * @param key a {@link java.lang.String} object. + */ + public SerieValueExpression(DRIDesignExpression valueExpression, DRIDesignExpression serieExpression, ResetType resetType, DRDesignGroup resetGroup, String key) { + this.valueExpression = valueExpression; + this.serieExpression = serieExpression; + this.resetType = resetType; + this.resetGroup = resetGroup; + this.key = key; + } + + /** {@inheritDoc} */ + @Override + public Number evaluate(ReportParameters reportParameters) { + if (reportParameters.getReportRowNumber() <= 1) { + resetValue = null; + values = new HashMap(); + } + + Object resetValue = null; + switch (resetType) { + case NONE: + case REPORT: + break; + case PAGE: + resetValue = reportParameters.getPageNumber(); + break; + case COLUMN: + resetValue = reportParameters.getColumnNumber(); + break; + case GROUP: + resetValue = reportParameters.getValue(resetGroup.getGroupExpression().getName()); + break; + default: + throw new DRDesignReportException("Reset type " + resetType.name() + " not supported"); + } + if (this.resetValue != null && !this.resetValue.equals(resetValue)) { + this.values = new HashMap(); + } + this.resetValue = resetValue; + + Object keyValue; + if (key != null) { + keyValue = reportParameters.getValue(valueExpression.getName()) + "_" + reportParameters.getValue(key); + } else { + keyValue = reportParameters.getValue(valueExpression.getName()); + } + Number serieValue = reportParameters.getValue(serieExpression.getName()); + Double value = values.get(keyValue); + if (serieValue != null) { + if (value == null) { + value = serieValue.doubleValue(); + } else { + value += serieValue.doubleValue(); + } + values.put(keyValue, value); + } + + return value; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/TocPrintWhenExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/TocPrintWhenExpression.java new file mode 100644 index 0000000..7f1823f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/TocPrintWhenExpression.java @@ -0,0 +1,58 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.builder.expression.AbstractComplexExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.util.List; + +/** + *

TocPrintWhenExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class TocPrintWhenExpression extends AbstractComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Object lastValue; + + /** + *

Constructor for TocPrintWhenExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public TocPrintWhenExpression(DRIExpression expression) { + addExpression(expression); + } + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(List values, ReportParameters reportParameters) { + Object value = values.get(0); + if (lastValue != null && lastValue.equals(value)) { + lastValue = value; + return false; + } + lastValue = value; + return true; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/TocReferenceExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/TocReferenceExpression.java new file mode 100644 index 0000000..95540e0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/TocReferenceExpression.java @@ -0,0 +1,86 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.builder.expression.AbstractComplexExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRICustomValues; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.util.List; + +/** + *

TocReferenceExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class TocReferenceExpression extends AbstractComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int level; + private String expressionName; + private boolean customId; + private boolean isCustomValue; + + /** + *

Constructor for TocReferenceExpression.

+ * + * @param level a int. + * @param expressionName a {@link java.lang.String} object. + * @param labelExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param anchorNameExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param customValueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public TocReferenceExpression(int level, String expressionName, DRIExpression labelExpression, DRIExpression anchorNameExpression, DRIExpression customValueExpression) { + this.level = level; + this.expressionName = expressionName; + customId = anchorNameExpression != null; + addExpression(labelExpression); + if (anchorNameExpression != null) { + addExpression(anchorNameExpression); + } + isCustomValue = customValueExpression != null; + if (customValueExpression != null) { + addExpression(customValueExpression); + } + } + + /** {@inheritDoc} */ + @Override + public String evaluate(List values, ReportParameters reportParameters) { + String id; + Object customValue = null; + if (customId) { + id = (String) values.get(1); + if (isCustomValue) { + customValue = values.get(2); + } + } else { + id = expressionName + "_" + reportParameters.getReportRowNumber(); + if (isCustomValue) { + customValue = values.get(1); + } + } + DRICustomValues customValues = (DRICustomValues) reportParameters.getParameterValue(DRICustomValues.NAME); + String text = String.valueOf(values.get(0)); + customValues.addTocHeading(level, id, text, customValue); + return null; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/TocReferenceLinkExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/TocReferenceLinkExpression.java new file mode 100644 index 0000000..d1072ec --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/design/transformation/expressions/TocReferenceLinkExpression.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.design.transformation.expressions; + +import software.xdev.dynamicreports.report.builder.expression.AbstractComplexExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.util.List; + +/** + *

TocReferenceLinkExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class TocReferenceLinkExpression extends AbstractComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String expressionName; + private boolean customId; + + /** + *

Constructor for TocReferenceLinkExpression.

+ * + * @param expressionName a {@link java.lang.String} object. + * @param anchorNameExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public TocReferenceLinkExpression(String expressionName, DRIExpression anchorNameExpression) { + this.expressionName = expressionName; + customId = anchorNameExpression != null; + if (anchorNameExpression != null) { + addExpression(anchorNameExpression); + } + } + + /** {@inheritDoc} */ + @Override + public String evaluate(List values, ReportParameters reportParameters) { + String id; + if (customId) { + id = (String) values.get(0); + } else { + id = expressionName + "_" + reportParameters.getReportRowNumber(); + } + return id; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/CustomScriptlet.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/CustomScriptlet.java new file mode 100644 index 0000000..01dd34b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/CustomScriptlet.java @@ -0,0 +1,121 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +import software.xdev.dynamicreports.report.definition.DRIScriptlet; +import net.sf.jasperreports.engine.JRAbstractScriptlet; +import net.sf.jasperreports.engine.JRScriptletException; + +/** + *

CustomScriptlet class.

+ * + * @author Ricardo Mariaca + * + */ +public class CustomScriptlet extends JRAbstractScriptlet { + private DRIScriptlet scriptlet; + private JasperReportParameters reportParameters; + + /** + *

Constructor for CustomScriptlet.

+ * + * @param scriptlet a {@link software.xdev.dynamicreports.report.definition.DRIScriptlet} object. + */ + public CustomScriptlet(DRIScriptlet scriptlet) { + this.scriptlet = scriptlet; + } + + /** {@inheritDoc} */ + @Override + public void afterColumnInit() throws JRScriptletException { + scriptlet.afterColumnInit(getReportParameters()); + } + + /** {@inheritDoc} */ + @Override + public void afterDetailEval() throws JRScriptletException { + scriptlet.afterDetailEval(getReportParameters()); + } + + /** {@inheritDoc} */ + @Override + public void afterGroupInit(String groupName) throws JRScriptletException { + scriptlet.afterGroupInit(groupName, getReportParameters()); + } + + /** {@inheritDoc} */ + @Override + public void afterPageInit() throws JRScriptletException { + scriptlet.afterPageInit(getReportParameters()); + } + + /** {@inheritDoc} */ + @Override + public void afterReportInit() throws JRScriptletException { + scriptlet.afterReportInit(getReportParameters()); + } + + /** {@inheritDoc} */ + @Override + public void beforeColumnInit() throws JRScriptletException { + scriptlet.beforeColumnInit(getReportParameters()); + } + + /** {@inheritDoc} */ + @Override + public void beforeDetailEval() throws JRScriptletException { + scriptlet.beforeDetailEval(getReportParameters()); + } + + /** {@inheritDoc} */ + @Override + public void beforeGroupInit(String groupName) throws JRScriptletException { + scriptlet.beforeGroupInit(groupName, getReportParameters()); + } + + /** {@inheritDoc} */ + @Override + public void beforePageInit() throws JRScriptletException { + scriptlet.beforePageInit(getReportParameters()); + } + + /** {@inheritDoc} */ + @Override + public void beforeReportInit() throws JRScriptletException { + scriptlet.beforeReportInit(getReportParameters()); + } + + private JasperReportParameters getReportParameters() { + if (reportParameters == null) { + try { + reportParameters = ((JasperScriptlet) getParameterValue(JasperScriptlet.SCRIPTLET_NAME)).getReportParameters(); + } catch (JRScriptletException e) { + } + } + return reportParameters; + } + + /** + *

Getter for the field scriptlet.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIScriptlet} object. + */ + protected DRIScriptlet getScriptlet() { + return scriptlet; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/DefaultJasperScriptletManager.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/DefaultJasperScriptletManager.java new file mode 100644 index 0000000..1f48073 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/DefaultJasperScriptletManager.java @@ -0,0 +1,42 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +/** + * Simple, default implementation of {@link software.xdev.dynamicreports.jasper.base.JasperScriptletManager}. + * + * @author edwin.njeru + * @version 6.0.1-SNAPSHOT + */ +public class DefaultJasperScriptletManager implements JasperScriptletManager { + + private JasperScriptlet jasperScriptlet; + + /** {@inheritDoc} */ + @Override + public JasperScriptlet getJasperScriptlet() { + return jasperScriptlet; + } + + /** {@inheritDoc} */ + @Override + public void setJasperScriptlet(JasperScriptlet jasperScriptlet) { + this.jasperScriptlet = jasperScriptlet; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperCustomValues.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperCustomValues.java new file mode 100644 index 0000000..46ff888 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperCustomValues.java @@ -0,0 +1,363 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +import static java.lang.Boolean.TRUE; +import static software.xdev.dynamicreports.jasper.base.JasperScriptletManager.USE_THREAD_SAFE_SCRIPLET_MANAGER_PROPERTY_KEY; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.apache.commons.lang3.StringUtils; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.jasper.base.tableofcontents.JasperTocHeading; +import software.xdev.dynamicreports.jasper.constant.ValueType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRICustomValues; + + +/** + *

+ * JasperCustomValues class. + *

+ * + * @author edwin.njeru + */ +public class JasperCustomValues implements DRICustomValues +{ + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Map valueTypes; + private Map simpleExpressions; + private Map complexExpressions; + private Map systemValues; + private Integer startPageNumber; + private Map tocHeadings; + private Integer subreportWidth; + private transient JasperScriptletManager scriptletManager; + + /** + *

+ * Constructor for JasperCustomValues. + *

+ * + * @param properties a {@link java.util.Properties} object. + */ + public JasperCustomValues(final Properties properties) + { + this.init(properties); + } + + private void init(final Properties properties) + { + this.valueTypes = new HashMap<>(); + this.simpleExpressions = new HashMap<>(); + this.complexExpressions = new HashMap<>(); + this.systemValues = new HashMap<>(); + this.scriptletManager = this.createScriptletManager(properties); + } + + private JasperScriptletManager createScriptletManager(final Properties properties) + { + final String useThreadSafeScriptletManagerPropertyValue = + properties.getProperty(USE_THREAD_SAFE_SCRIPLET_MANAGER_PROPERTY_KEY); + if(TRUE.toString().equalsIgnoreCase(useThreadSafeScriptletManagerPropertyValue)) + { + return new ThreadSafeJasperScriptletManager(); + } + return new DefaultJasperScriptletManager(); + } + + /** + *

+ * addSimpleExpression. + *

+ * + * @param simpleExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression} + * object. + */ + public void addSimpleExpression(final DRIDesignSimpleExpression simpleExpression) + { + this.simpleExpressions.put(simpleExpression.getName(), simpleExpression); + this.addValueType(simpleExpression.getName(), ValueType.SIMPLE_EXPRESSION); + } + + /** + *

+ * addComplexExpression. + *

+ * + * @param complexExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression} + * object. + */ + public void addComplexExpression(final DRIDesignComplexExpression complexExpression) + { + this.complexExpressions.put(complexExpression.getName(), complexExpression); + this.addValueType(complexExpression.getName(), ValueType.COMPLEX_EXPRESSION); + } + + /** + *

+ * addValueType. + *

+ * + * @param name a {@link java.lang.String} object. + * @param valueType a {@link software.xdev.dynamicreports.jasper.constant.ValueType} object. + */ + public void addValueType(final String name, final ValueType valueType) + { + this.valueTypes.put(name, valueType); + } + + /** + *

+ * getValueType. + *

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.constant.ValueType} object. + */ + protected ValueType getValueType(final String name) + { + return this.valueTypes.get(name); + } + + /** + *

+ * getSimpleExpression. + *

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression} object. + */ + protected DRIDesignSimpleExpression getSimpleExpression(final String name) + { + return this.simpleExpressions.get(name); + } + + /** + *

+ * getComplexExpression. + *

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression} object. + */ + protected DRIDesignComplexExpression getComplexExpression(final String name) + { + return this.complexExpressions.get(name); + } + + /** + *

+ * isEmpty. + *

+ * + * @return a boolean. + */ + public boolean isEmpty() + { + if(!this.simpleExpressions.isEmpty()) + { + return false; + } + if(!this.complexExpressions.isEmpty()) + { + return false; + } + return true; + } + + /** + *

+ * getValue. + *

+ * + * @param valueName a {@link java.lang.String} object. + * @return a {@link java.lang.Object} object. + */ + public Object getValue(final String valueName) + { + return this.scriptletManager.getJasperScriptlet().getValue(valueName); + } + + /** + *

+ * getValue. + *

+ * + * @param name a {@link java.lang.String} object. + * @param values an array of {@link java.lang.Object} objects. + * @return a {@link java.lang.Object} object. + */ + public Object getValue(final String name, final Object[] values) + { + return this.scriptletManager.getJasperScriptlet().getValue(name, values); + } + + /** + * {@inheritDoc} + */ + @Override + public void setSystemValue(final String name, final Object value) + { + this.systemValues.put(name, value); + } + + /** + *

+ * getSystemValue. + *

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link java.lang.Object} object. + */ + protected Object getSystemValue(final String name) + { + return this.systemValues.get(name); + } + + /** + *

+ * Getter for the field jasperScriptlet. + *

+ * + * @return a {@link software.xdev.dynamicreports.jasper.base.JasperScriptlet} object. + */ + protected JasperScriptlet getJasperScriptlet() + { + return this.scriptletManager.getJasperScriptlet(); + } + + /** + *

+ * Setter for the field jasperScriptlet. + *

+ * + * @param jasperScriptlet a {@link software.xdev.dynamicreports.jasper.base.JasperScriptlet} object. + */ + protected void setJasperScriptlet(final JasperScriptlet jasperScriptlet) + { + this.scriptletManager.setJasperScriptlet(jasperScriptlet); + } + + /** + *

+ * Getter for the field startPageNumber. + *

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getStartPageNumber() + { + return this.startPageNumber; + } + + /** + *

+ * Setter for the field startPageNumber. + *

+ * + * @param startPageNumber a {@link java.lang.Integer} object. + */ + public void setStartPageNumber(final Integer startPageNumber) + { + this.startPageNumber = startPageNumber; + } + + /** + * {@inheritDoc} + */ + @Override + public void addTocHeading(final int level, final String id, final String text, final Object customValue) + { + final JasperTocHeading heading = new JasperTocHeading(); + heading.setLevel(level); + heading.setText(text); + heading.setReference(id); + heading.setCustomValue(customValue); + this.tocHeadings.put(id, heading); + } + + /** + * {@inheritDoc} + */ + @Override + public Map getTocHeadings() + { + return this.tocHeadings; + } + + /** + * {@inheritDoc} + */ + @Override + public void setTocHeadings(final Map tocHeadings) + { + this.tocHeadings = tocHeadings; + } + + /** + *

+ * Getter for the field subreportWidth. + *

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getSubreportWidth() + { + return this.subreportWidth; + } + + /** + * {@inheritDoc} + */ + @Override + public void setSubreportWidth(final Integer subreportWidth) + { + this.subreportWidth = subreportWidth; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() + { + final StringBuilder result = new StringBuilder(); + for(final String name : this.valueTypes.keySet()) + { + result.append(this.valueTypes.get(name).name() + ":" + name); + result.append(", "); + } + return "{" + StringUtils.removeEnd(result.toString(), ", ") + "}"; + } + + /** + * Getter for testing purposes. + * + * @return the {@link JasperScriptletManager} + */ + JasperScriptletManager getScriptletManager() + { + return this.scriptletManager; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperReportDesign.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperReportDesign.java new file mode 100644 index 0000000..20af6af --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperReportDesign.java @@ -0,0 +1,143 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +import software.xdev.dynamicreports.design.definition.DRIDesignReport; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.design.JasperDesign; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +/** + *

JasperReportDesign class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperReportDesign implements Serializable { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private JasperCustomValues customValues; + private JasperDesign design; + private Map parameters; + private ReportParameters masterReportParameters; + private Integer startPageNumber; + private boolean tableOfContents; + private DRITableOfContentsCustomizer tableOfContentsCustomizer; + + /** + *

Constructor for JasperReportDesign.

+ * + * @param report a {@link software.xdev.dynamicreports.design.definition.DRIDesignReport} object. + * @param startPageNumber a {@link java.lang.Integer} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportDesign(DRIDesignReport report, Integer startPageNumber) throws DRException { + this(report, null, startPageNumber); + } + + /** + *

Constructor for JasperReportDesign.

+ * + * @param report a {@link software.xdev.dynamicreports.design.definition.DRIDesignReport} object. + * @param masterReportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + * @param startPageNumber a {@link java.lang.Integer} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportDesign(DRIDesignReport report, ReportParameters masterReportParameters, Integer startPageNumber) throws DRException { + this.masterReportParameters = masterReportParameters; + this.startPageNumber = startPageNumber; + init(report); + } + + private void init(DRIDesignReport report) throws DRException { + this.design = (JasperDesign) report.getTemplateDesign().getDesign(); + this.tableOfContents = report.isTableOfContents(); + this.tableOfContentsCustomizer = report.getTableOfContentsCustomizer(); + this.customValues = new JasperCustomValues(report.getProperties()); + this.parameters = new HashMap(); + } + + /** + *

Getter for the field customValues.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.base.JasperCustomValues} object. + */ + public JasperCustomValues getCustomValues() { + return customValues; + } + + /** + *

Getter for the field design.

+ * + * @return a {@link net.sf.jasperreports.engine.design.JasperDesign} object. + */ + public JasperDesign getDesign() { + return design; + } + + /** + *

Getter for the field parameters.

+ * + * @return a {@link java.util.Map} object. + */ + public Map getParameters() { + return parameters; + } + + /** + *

Getter for the field startPageNumber.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getStartPageNumber() { + return startPageNumber; + } + + /** + *

Getter for the field masterReportParameters.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public ReportParameters getMasterReportParameters() { + return masterReportParameters; + } + + /** + *

isTableOfContents.

+ * + * @return a boolean. + */ + public boolean isTableOfContents() { + return tableOfContents; + } + + /** + *

Getter for the field tableOfContentsCustomizer.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer} object. + */ + public DRITableOfContentsCustomizer getTableOfContentsCustomizer() { + return tableOfContentsCustomizer; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperReportParameters.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperReportParameters.java new file mode 100644 index 0000000..944abf4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperReportParameters.java @@ -0,0 +1,280 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.transformation.expressions.CrosstabRowCounter; +import software.xdev.dynamicreports.jasper.constant.ValueType; +import software.xdev.dynamicreports.report.definition.DRIScriptlet; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.exception.DRReportException; +import net.sf.jasperreports.engine.JRParameter; +import net.sf.jasperreports.engine.JRScriptlet; +import net.sf.jasperreports.engine.JRScriptletException; +import net.sf.jasperreports.engine.JRVariable; + +import java.sql.Connection; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +/** + *

JasperReportParameters class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperReportParameters implements ReportParameters { + /** + * Constant MASTER_REPORT_PARAMETERS="MASTER_REPORT_PARAMETERS" + */ + public static final String MASTER_REPORT_PARAMETERS = "MASTER_REPORT_PARAMETERS"; + + private JasperScriptlet jasperScriptlet; + + /** + *

Constructor for JasperReportParameters.

+ * + * @param jasperScriptlet a {@link software.xdev.dynamicreports.jasper.base.JasperScriptlet} object. + */ + protected JasperReportParameters(JasperScriptlet jasperScriptlet) { + this.jasperScriptlet = jasperScriptlet; + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public T getValue(String name) { + ValueType type = jasperScriptlet.getValueType(name); + if (type != null) { + switch (type) { + case FIELD: + return (T) getFieldValue(name); + case VARIABLE: + return (T) getVariableValue(name); + case PARAMETER: + return (T) getParameterValue(name); + case SIMPLE_EXPRESSION: + return (T) getSimpleExpressionValue(name); + case COMPLEX_EXPRESSION: + return (T) getComplexExpressionValue(name); + case SYSTEM_EXPRESSION: + return (T) getSystemExpressionValue(name); + default: + break; + } + } + + throw new DRReportException("Value " + name + " not found"); + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public T getValue(DRIValue value) { + return (T) getValue(value.getName()); + } + + // field + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public T getFieldValue(String name) { + try { + return (T) jasperScriptlet.getFieldValue(name); + } catch (JRScriptletException e) { + throw new DRReportException(e); + } + } + + // variable + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public T getVariableValue(String name) { + try { + return (T) jasperScriptlet.getVariableValue(name); + } catch (JRScriptletException e) { + throw new DRReportException(e); + } + } + + /** {@inheritDoc} */ + @Override + public Integer getPageNumber() { + return (Integer) getVariableValue(JRVariable.PAGE_NUMBER); + } + + /** {@inheritDoc} */ + @Override + public Integer getColumnNumber() { + return (Integer) getVariableValue(JRVariable.COLUMN_NUMBER); + } + + /** {@inheritDoc} */ + @Override + public Integer getReportRowNumber() { + return (Integer) getVariableValue(JRVariable.REPORT_COUNT); + } + + /** {@inheritDoc} */ + @Override + public Integer getPageRowNumber() { + return (Integer) getVariableValue(JRVariable.PAGE_COUNT); + } + + /** {@inheritDoc} */ + @Override + public Integer getColumnRowNumber() { + return (Integer) getVariableValue(JRVariable.COLUMN_COUNT); + } + + /** {@inheritDoc} */ + @Override + public Integer getCrosstabRowNumber() { + CrosstabRowCounter counter = (CrosstabRowCounter) getValue(CROSSTAB_ROW_COUNTER); + if (counter != null) { + return counter.getRowNumber(); + } + return 0; + } + + /** {@inheritDoc} */ + @Override + public Integer getGroupCount(String groupName) { + return (Integer) getVariableValue(groupName + "_COUNT"); + } + + // parameter + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public T getParameterValue(String name) { + try { + return (T) ((Map) jasperScriptlet.getParameterValue(JRParameter.REPORT_PARAMETERS_MAP)).get(name); + } catch (JRScriptletException e) { + throw new DRReportException(e); + } + } + + /** {@inheritDoc} */ + @Override + public Connection getConnection() { + return (Connection) getParameterValue(JRParameter.REPORT_CONNECTION); + } + + /** {@inheritDoc} */ + @Override + public Locale getLocale() { + return (Locale) getParameterValue(JRParameter.REPORT_LOCALE); + } + + /** {@inheritDoc} */ + @Override + public DRIScriptlet getScriptlet(String name) { + return ((CustomScriptlet) getParameterValue(name + JRScriptlet.SCRIPTLET_PARAMETER_NAME_SUFFIX)).getScriptlet(); + } + + /** {@inheritDoc} */ + @Override + public String getMessage(String key) { + return ((ResourceBundle) getParameterValue(JRParameter.REPORT_RESOURCE_BUNDLE)).getString(key); + } + + /** {@inheritDoc} */ + @Override + public String getMessage(String key, Object[] arguments) { + String message = getMessage(key); + if (arguments != null) { + MessageFormat format = new MessageFormat(message, getLocale()); + message = format.format(arguments); + } + return message; + } + + // simple expression + private Object getSimpleExpressionValue(String name) { + return jasperScriptlet.getSimpleExpression(name).evaluate(this); + } + + // complex expression + private Object getComplexExpressionValue(String name) { + List values = new ArrayList(); + DRIDesignComplexExpression complexExpression = jasperScriptlet.getComplexExpression(name); + for (DRIDesignExpression valueExpression : complexExpression.getExpressions()) { + values.add(getValue(valueExpression.getName())); + } + return complexExpression.evaluate(values, this); + } + + // system expression + private Object getSystemExpressionValue(String name) { + return jasperScriptlet.getSystemValue(name); + } + + /** {@inheritDoc} */ + @Override + public ReportParameters getMasterParameters() { + return (ReportParameters) getParameterValue(MASTER_REPORT_PARAMETERS); + } + + /** {@inheritDoc} */ + @Override + public Integer getSubreportWidth() { + return jasperScriptlet.getSubreportWidth(); + } + + /** {@inheritDoc} */ + @Override + public String toString() { + StringBuilder result = new StringBuilder(); + + result.append("FIELDS:\n"); + Collection names = jasperScriptlet.getFields(); + for (String name : names) { + result.append(name + " = " + getFieldValue(name)); + result.append("\n"); + } + + result.append("VARIABLES:\n"); + names = jasperScriptlet.getVariables(); + for (String name : names) { + result.append(name + " = " + getVariableValue(name)); + result.append("\n"); + } + + result.append("PARAMETERS:\n"); + names = jasperScriptlet.getParameters(); + for (String name : names) { + result.append(name + " = " + getParameterValue(name)); + result.append("\n"); + } + + return result.toString(); + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperScriptlet.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperScriptlet.java new file mode 100644 index 0000000..0b83aef --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperScriptlet.java @@ -0,0 +1,211 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; + +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.jasper.constant.ValueType; +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import net.sf.jasperreports.engine.JRDefaultScriptlet; +import net.sf.jasperreports.engine.JRScriptlet; +import net.sf.jasperreports.engine.JRScriptletException; +import net.sf.jasperreports.engine.fill.JRFillField; +import net.sf.jasperreports.engine.fill.JRFillGroup; +import net.sf.jasperreports.engine.fill.JRFillParameter; +import net.sf.jasperreports.engine.fill.JRFillVariable; + + +/** + *

JasperScriptlet class.

+ * + * @author Ricardo Mariaca + */ +public class JasperScriptlet extends JRDefaultScriptlet +{ + /** + * Constant NAME="DYNAMICREPORTS" + */ + public static final String NAME = "DYNAMICREPORTS"; + /** + * Constant SCRIPTLET_NAME="NAME + JRScriptlet.SCRIPTLET_PARAMETER_"{trunked} + */ + public static final String SCRIPTLET_NAME = NAME + JRScriptlet.SCRIPTLET_PARAMETER_NAME_SUFFIX; + + private JasperReportParameters reportParameters; + + /** + *

getValue.

+ * + * @param valueName a {@link java.lang.String} object. + * @return a {@link java.lang.Object} object. + */ + public Object getValue(final String valueName) + { + return this.reportParameters.getValue(valueName); + } + + /** + *

getValue.

+ * + * @param name a {@link java.lang.String} object. + * @param values an array of {@link java.lang.Object} objects. + * @return a {@link java.lang.Object} object. + */ + public Object getValue(final String name, final Object[] values) + { + return this.getComplexExpression(name).evaluate(Arrays.asList(values), this.reportParameters); + } + + /** + *

Getter for the field reportParameters.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.base.JasperReportParameters} object. + */ + public JasperReportParameters getReportParameters() + { + return this.reportParameters; + } + + private JasperCustomValues getCustomValues() + { + try + { + return (JasperCustomValues)this.getParameterValue(JasperCustomValues.NAME, false); + } + catch(final JRScriptletException e) + { + throw new JasperDesignException("Custom values not found", e); + } + } + + /** + *

getValueType.

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.constant.ValueType} object. + */ + protected ValueType getValueType(final String name) + { + return this.getCustomValues().getValueType(name); + } + + /** + *

getSimpleExpression.

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression} object. + */ + protected DRIDesignSimpleExpression getSimpleExpression(final String name) + { + return this.getCustomValues().getSimpleExpression(name); + } + + /** + *

getComplexExpression.

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression} object. + */ + protected DRIDesignComplexExpression getComplexExpression(final String name) + { + return this.getCustomValues().getComplexExpression(name); + } + + /** + *

getSystemValue.

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link java.lang.Object} object. + */ + protected Object getSystemValue(final String name) + { + return this.getCustomValues().getSystemValue(name); + } + + /** + *

getFields.

+ * + * @return a {@link java.util.Collection} object. + */ + protected Collection getFields() + { + return this.fieldsMap.keySet(); + } + + /** + *

getVariables.

+ * + * @return a {@link java.util.Collection} object. + */ + protected Collection getVariables() + { + return this.variablesMap.keySet(); + } + + /** + *

getParameters.

+ * + * @return a {@link java.util.Collection} object. + */ + protected Collection getParameters() + { + return this.parametersMap.keySet(); + } + + /** + *

getSubreportWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + protected Integer getSubreportWidth() + { + return this.getCustomValues().getSubreportWidth(); + } + + /** + * {@inheritDoc} + */ + @Override + public void setData( + final Map parsm, + final Map fldsm, + final Map varsm, + final JRFillGroup[] grps) + { + super.setData(parsm, fldsm, varsm, grps); + this.reportParameters = new JasperReportParameters(this); + } + + /** + * {@inheritDoc} + */ + @Override + public void afterReportInit() throws JRScriptletException + { + super.afterReportInit(); + final JasperCustomValues customValues = this.getCustomValues(); + if(customValues != null) + { + customValues.setJasperScriptlet(this); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperScriptletManager.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperScriptletManager.java new file mode 100644 index 0000000..04cdd3f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperScriptletManager.java @@ -0,0 +1,46 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +/** + * Interface for managers of {@link software.xdev.dynamicreports.jasper.base.JasperScriptlet} used in {@link software.xdev.dynamicreports.jasper.base.JasperCustomValues}. + * + * @author edwin.njeru + * @version 6.0.1-SNAPSHOT + */ +public interface JasperScriptletManager { + + /** + * Property key used for selecting thread safe implementation. + */ + public static final String USE_THREAD_SAFE_SCRIPLET_MANAGER_PROPERTY_KEY = "software.xdev.dynamicreports.useThreadSafeScriptletManager"; + + /** + * Getter for the {@link software.xdev.dynamicreports.jasper.base.JasperScriptlet} instance. + * + * @return the set {@link software.xdev.dynamicreports.jasper.base.JasperScriptlet} instance + */ + JasperScriptlet getJasperScriptlet(); + + /** + * Setter for the {@link software.xdev.dynamicreports.jasper.base.JasperScriptlet} instance. + * + * @param jasperScriptlet the {@link software.xdev.dynamicreports.jasper.base.JasperScriptlet} instance to set + */ + void setJasperScriptlet(JasperScriptlet jasperScriptlet); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperSystemFontExtensionsRegistryFactory.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperSystemFontExtensionsRegistryFactory.java new file mode 100644 index 0000000..5bc81be --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperSystemFontExtensionsRegistryFactory.java @@ -0,0 +1,65 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +import software.xdev.dynamicreports.report.defaults.Defaults; +import net.sf.jasperreports.engine.JRPropertiesMap; +import net.sf.jasperreports.engine.JRPropertiesUtil; +import net.sf.jasperreports.engine.JRPropertiesUtil.PropertySuffix; +import net.sf.jasperreports.engine.fonts.FontExtensionsRegistry; +import net.sf.jasperreports.extensions.DefaultExtensionsRegistry; +import net.sf.jasperreports.extensions.ExtensionsRegistry; +import net.sf.jasperreports.extensions.ExtensionsRegistryFactory; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + *

JasperSystemFontExtensionsRegistryFactory class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperSystemFontExtensionsRegistryFactory implements ExtensionsRegistryFactory { + /** + * Constant SYSTEM_FONT_FAMILIES_PROPERTY_PREFIX="DefaultExtensionsRegistry.PROPERTY_REGI"{trunked} + */ + public static final String SYSTEM_FONT_FAMILIES_PROPERTY_PREFIX = DefaultExtensionsRegistry.PROPERTY_REGISTRY_PREFIX + "system.font.families."; + /** + * Constant PROPERTY_SYSTEM_FONT_FAMILIES_REGISTRY_FACTORY="DefaultExtensionsRegistry.PROPERTY_REGI"{trunked} + */ + public static final String PROPERTY_SYSTEM_FONT_FAMILIES_REGISTRY_FACTORY = DefaultExtensionsRegistry.PROPERTY_REGISTRY_FACTORY_PREFIX + "system.font.families"; + + /** {@inheritDoc} */ + @Override + public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { + List fontFamiliesProperties = JRPropertiesUtil.getProperties(properties, SYSTEM_FONT_FAMILIES_PROPERTY_PREFIX); + List fontFamiliesLocations = new ArrayList(); + if (Defaults.getDefaults().isLoadSystemFonts()) { + for (Iterator it = fontFamiliesProperties.iterator(); it.hasNext(); ) { + PropertySuffix fontFamiliesProp = it.next(); + String fontFamiliesLocation = fontFamiliesProp.getValue(); + fontFamiliesLocations.add(fontFamiliesLocation); + } + } + + return new FontExtensionsRegistry(fontFamiliesLocations); + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperTemplateStyleLoader.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperTemplateStyleLoader.java new file mode 100644 index 0000000..1e23652 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/JasperTemplateStyleLoader.java @@ -0,0 +1,426 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import software.xdev.dynamicreports.report.base.style.DRBaseStyle; +import software.xdev.dynamicreports.report.base.style.DRBorder; +import software.xdev.dynamicreports.report.base.style.DRConditionalStyle; +import software.xdev.dynamicreports.report.base.style.DRFont; +import software.xdev.dynamicreports.report.base.style.DRPadding; +import software.xdev.dynamicreports.report.base.style.DRParagraph; +import software.xdev.dynamicreports.report.base.style.DRPen; +import software.xdev.dynamicreports.report.base.style.DRStyle; +import software.xdev.dynamicreports.report.base.style.DRTabStop; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.constant.LineSpacing; +import software.xdev.dynamicreports.report.constant.LineStyle; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.Rotation; +import software.xdev.dynamicreports.report.constant.TabStopAlignment; +import software.xdev.dynamicreports.report.constant.VerticalImageAlignment; +import software.xdev.dynamicreports.report.constant.VerticalTextAlignment; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.JRConditionalStyle; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRLineBox; +import net.sf.jasperreports.engine.JRParagraph; +import net.sf.jasperreports.engine.JRPen; +import net.sf.jasperreports.engine.JRStyle; +import net.sf.jasperreports.engine.JRTemplate; +import net.sf.jasperreports.engine.TabStop; +import net.sf.jasperreports.engine.type.HorizontalImageAlignEnum; +import net.sf.jasperreports.engine.type.HorizontalTextAlignEnum; +import net.sf.jasperreports.engine.type.LineSpacingEnum; +import net.sf.jasperreports.engine.type.LineStyleEnum; +import net.sf.jasperreports.engine.type.RotationEnum; +import net.sf.jasperreports.engine.type.ScaleImageEnum; +import net.sf.jasperreports.engine.type.TabStopAlignEnum; +import net.sf.jasperreports.engine.type.VerticalImageAlignEnum; +import net.sf.jasperreports.engine.type.VerticalTextAlignEnum; +import net.sf.jasperreports.engine.xml.JRXmlTemplateLoader; +import org.apache.commons.lang3.Validate; + +import java.io.File; +import java.io.InputStream; +import java.net.URL; + +/** + *

JasperTemplateStyleLoader class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperTemplateStyleLoader { + + /** + *

loadStyles.

+ * + * @param file a {@link java.io.File} object. + * @return an array of {@link software.xdev.dynamicreports.report.base.style.DRStyle} objects. + */ + public static DRStyle[] loadStyles(File file) { + Validate.notNull(file, "file must not be null"); + return loadStyles(JRXmlTemplateLoader.load(file)); + } + + /** + *

loadStyles.

+ * + * @param fileName a {@link java.lang.String} object. + * @return an array of {@link software.xdev.dynamicreports.report.base.style.DRStyle} objects. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public static DRStyle[] loadStyles(String fileName) throws DRException { + Validate.notNull(fileName, "fileName must not be null"); + try { + return loadStyles(JRXmlTemplateLoader.load(fileName)); + } catch (JRException e) { + throw new DRException(e); + } + } + + /** + *

loadStyles.

+ * + * @param inputStream a {@link java.io.InputStream} object. + * @return an array of {@link software.xdev.dynamicreports.report.base.style.DRStyle} objects. + */ + public static DRStyle[] loadStyles(InputStream inputStream) { + Validate.notNull(inputStream, "inputStream must not be null"); + return loadStyles(JRXmlTemplateLoader.load(inputStream)); + } + + /** + *

loadStyles.

+ * + * @param url a {@link java.net.URL} object. + * @return an array of {@link software.xdev.dynamicreports.report.base.style.DRStyle} objects. + */ + public static DRStyle[] loadStyles(URL url) { + Validate.notNull(url, "url must not be null"); + return loadStyles(JRXmlTemplateLoader.load(url)); + } + + private static DRStyle[] loadStyles(JRTemplate template) { + Validate.notNull(template, "template must not be null"); + JRStyle[] jrStyles = template.getStyles(); + DRStyle[] styles = new DRStyle[jrStyles.length]; + for (int i = 0; i < jrStyles.length; i++) { + JRStyle jrStyle = jrStyles[i]; + styles[i] = convertStyle(jrStyle); + } + return styles; + } + + private static DRStyle convertStyle(JRStyle jrStyle) { + DRStyle style = new DRStyle(); + abstractStyle(jrStyle, style); + + style.setName(jrStyle.getName()); + JRStyle jrParentStyle = jrStyle.getStyle(); + if (jrParentStyle != null) { + style.setParentStyle(convertStyle(jrParentStyle)); + } + for (JRConditionalStyle jrConditionalStyle : jrStyle.getConditionalStyles()) { + style.addConditionalStyle(conditionalStyle(jrConditionalStyle)); + } + return style; + } + + private static DRConditionalStyle conditionalStyle(JRConditionalStyle jrConditionalStyle) { + DRIExpression expression = Expressions.jasperSyntax(jrConditionalStyle.getConditionExpression().getText(), Boolean.class); + DRConditionalStyle conditionalStyle = new DRConditionalStyle(expression); + abstractStyle(jrConditionalStyle, conditionalStyle); + return conditionalStyle; + } + + private static void abstractStyle(JRStyle jrStyle, DRBaseStyle style) { + style.setForegroundColor(jrStyle.getOwnForecolor()); + style.setBackgroundColor(jrStyle.getOwnBackcolor()); + style.setRadius(jrStyle.getOwnRadius()); + style.setImageScale(imageScale(jrStyle.getOwnScaleImageValue())); + style.setHorizontalImageAlignment(horizontalImageAlignment(jrStyle.getOwnHorizontalImageAlign())); + style.setVerticalImageAlignment(verticalImageAlignment(jrStyle.getOwnVerticalImageAlign())); + style.setHorizontalTextAlignment(horizontalTextAlignment(jrStyle.getOwnHorizontalTextAlign())); + style.setVerticalTextAlignment(verticalTextAlignment(jrStyle.getOwnVerticalTextAlign())); + border(jrStyle.getLineBox(), style.getBorder()); + padding(jrStyle.getLineBox(), style.getPadding()); + font(jrStyle, style.getFont()); + style.setRotation(rotation(jrStyle.getOwnRotationValue())); + style.setPattern(jrStyle.getOwnPattern()); + style.setMarkup(markup(jrStyle.getOwnMarkup())); + paragraph(jrStyle.getParagraph(), style.getParagraph()); + pen(jrStyle.getLinePen(), style.getLinePen()); + } + + private static void paragraph(JRParagraph jrParagraph, DRParagraph paragraph) { + paragraph.setLineSpacing(lineSpacing(jrParagraph.getOwnLineSpacing())); + paragraph.setLineSpacingSize(jrParagraph.getOwnLineSpacingSize()); + paragraph.setFirstLineIndent(jrParagraph.getOwnFirstLineIndent()); + paragraph.setLeftIndent(jrParagraph.getOwnLeftIndent()); + paragraph.setRightIndent(jrParagraph.getOwnRightIndent()); + paragraph.setSpacingBefore(jrParagraph.getOwnSpacingBefore()); + paragraph.setSpacingAfter(jrParagraph.getOwnSpacingAfter()); + paragraph.setTabStopWidth(jrParagraph.getOwnTabStopWidth()); + if (jrParagraph.getOwnTabStops() != null) { + for (TabStop jrTabStop : jrParagraph.getOwnTabStops()) { + DRTabStop tabStop = new DRTabStop(); + tabStop.setPosition(jrTabStop.getPosition()); + tabStop.setAlignment(tabStopAlignment(jrTabStop.getAlignment())); + paragraph.getTabStops().add(tabStop); + } + } + } + + /** + *

pen.

+ * + * @param jrPen a {@link net.sf.jasperreports.engine.JRPen} object. + * @param pen a {@link software.xdev.dynamicreports.report.base.style.DRPen} object. + */ + protected static void pen(JRPen jrPen, DRPen pen) { + pen.setLineColor(jrPen.getOwnLineColor()); + pen.setLineStyle(lineStyle(jrPen.getOwnLineStyleValue())); + pen.setLineWidth(jrPen.getOwnLineWidth()); + } + + private static void border(JRLineBox jrLineBox, DRBorder border) { + pen(jrLineBox.getLeftPen(), border.getLeftPen()); + pen(jrLineBox.getRightPen(), border.getRightPen()); + pen(jrLineBox.getTopPen(), border.getTopPen()); + pen(jrLineBox.getBottomPen(), border.getBottomPen()); + } + + private static void padding(JRLineBox jrLineBox, DRPadding padding) { + padding.setLeft(jrLineBox.getOwnLeftPadding()); + padding.setRight(jrLineBox.getOwnRightPadding()); + padding.setTop(jrLineBox.getOwnTopPadding()); + padding.setBottom(jrLineBox.getOwnBottomPadding()); + } + + @SuppressWarnings("deprecation") + private static void font(JRStyle jrStyle, DRFont font) { + font.setFontName(jrStyle.getOwnFontName()); + font.setBold(jrStyle.isOwnBold()); + font.setItalic(jrStyle.isOwnItalic()); + font.setFontSize(jrStyle.getOwnFontsize() == null ? null : jrStyle.getOwnFontsize().intValue()); + font.setStrikeThrough(jrStyle.isOwnStrikeThrough()); + font.setUnderline(jrStyle.isOwnUnderline()); + font.setPdfFontName(jrStyle.getOwnPdfFontName()); + font.setPdfEncoding(jrStyle.getOwnPdfEncoding()); + font.setPdfEmbedded(jrStyle.isOwnPdfEmbedded()); + } + + private static LineStyle lineStyle(LineStyleEnum lineStyle) { + if (lineStyle == null) { + return null; + } + + switch (lineStyle) { + case SOLID: + return LineStyle.SOLID; + case DASHED: + return LineStyle.DASHED; + case DOTTED: + return LineStyle.DOTTED; + case DOUBLE: + return LineStyle.DOUBLE; + default: + throw new JasperDesignException("Line style " + lineStyle.name() + " not supported"); + } + } + + private static ImageScale imageScale(ScaleImageEnum imageScale) { + if (imageScale == null) { + return null; + } + + switch (imageScale) { + case CLIP: + return ImageScale.CLIP; + case FILL_FRAME: + return ImageScale.FILL_FRAME; + case RETAIN_SHAPE: + return ImageScale.RETAIN_SHAPE; + case REAL_HEIGHT: + return ImageScale.REAL_HEIGHT; + case REAL_SIZE: + return ImageScale.REAL_SIZE; + default: + throw new JasperDesignException("Image scale " + imageScale.name() + " not supported"); + } + } + + private static HorizontalImageAlignment horizontalImageAlignment(HorizontalImageAlignEnum horizontalImageAlignment) { + if (horizontalImageAlignment == null) { + return null; + } + + switch (horizontalImageAlignment) { + case LEFT: + return HorizontalImageAlignment.LEFT; + case CENTER: + return HorizontalImageAlignment.CENTER; + case RIGHT: + return HorizontalImageAlignment.RIGHT; + default: + throw new JasperDesignException("Horizontal image alignment " + horizontalImageAlignment.name() + " not supported"); + } + } + + private static VerticalImageAlignment verticalImageAlignment(VerticalImageAlignEnum verticalImageAlignment) { + if (verticalImageAlignment == null) { + return null; + } + + switch (verticalImageAlignment) { + case TOP: + return VerticalImageAlignment.TOP; + case MIDDLE: + return VerticalImageAlignment.MIDDLE; + case BOTTOM: + return VerticalImageAlignment.BOTTOM; + default: + throw new JasperDesignException("Vertical image alignment " + verticalImageAlignment.name() + " not supported"); + } + } + + private static HorizontalTextAlignment horizontalTextAlignment(HorizontalTextAlignEnum horizontalTextAlignment) { + if (horizontalTextAlignment == null) { + return null; + } + + switch (horizontalTextAlignment) { + case LEFT: + return HorizontalTextAlignment.LEFT; + case CENTER: + return HorizontalTextAlignment.CENTER; + case RIGHT: + return HorizontalTextAlignment.RIGHT; + case JUSTIFIED: + return HorizontalTextAlignment.JUSTIFIED; + default: + throw new JasperDesignException("Horizontal text alignment " + horizontalTextAlignment.name() + " not supported"); + } + } + + private static VerticalTextAlignment verticalTextAlignment(VerticalTextAlignEnum verticalTextAlignment) { + if (verticalTextAlignment == null) { + return null; + } + + switch (verticalTextAlignment) { + case TOP: + return VerticalTextAlignment.TOP; + case MIDDLE: + return VerticalTextAlignment.MIDDLE; + case BOTTOM: + return VerticalTextAlignment.BOTTOM; + case JUSTIFIED: + return VerticalTextAlignment.JUSTIFIED; + default: + throw new JasperDesignException("Vertical text alignment " + verticalTextAlignment.name() + " not supported"); + } + } + + private static Markup markup(String markup) { + if (markup == null) { + return null; + } + + if (markup.equals("none")) { + return Markup.NONE; + } + if (markup.equals("styled")) { + return Markup.STYLED; + } + if (markup.equals("rtf")) { + return Markup.RTF; + } + if (markup.equals("html")) { + return Markup.HTML; + } + throw new JasperDesignException("Markup " + markup + " not supported"); + } + + private static LineSpacing lineSpacing(LineSpacingEnum lineSpacing) { + if (lineSpacing == null) { + return null; + } + + switch (lineSpacing) { + case SINGLE: + return LineSpacing.SINGLE; + case ONE_AND_HALF: + return LineSpacing.ONE_AND_HALF; + case DOUBLE: + return LineSpacing.DOUBLE; + case AT_LEAST: + return LineSpacing.AT_LEAST; + case FIXED: + return LineSpacing.FIXED; + case PROPORTIONAL: + return LineSpacing.PROPORTIONAL; + default: + throw new JasperDesignException("LineSpacing " + lineSpacing.name() + " not supported"); + } + } + + /** + *

rotation.

+ * + * @param rotation a {@link net.sf.jasperreports.engine.type.RotationEnum} object. + * @return a {@link software.xdev.dynamicreports.report.constant.Rotation} object. + */ + protected static Rotation rotation(RotationEnum rotation) { + if (rotation == null) { + return null; + } + + switch (rotation) { + case NONE: + return Rotation.NONE; + case LEFT: + return Rotation.LEFT; + case RIGHT: + return Rotation.RIGHT; + case UPSIDE_DOWN: + return Rotation.UPSIDE_DOWN; + default: + throw new JasperDesignException("Rotation " + rotation.name() + " not supported"); + } + } + + private static TabStopAlignment tabStopAlignment(TabStopAlignEnum alignment) { + switch (alignment) { + case LEFT: + return TabStopAlignment.LEFT; + case CENTER: + return TabStopAlignment.CENTER; + case RIGHT: + return TabStopAlignment.RIGHT; + default: + throw new JasperDesignException("TabStopAlignment " + alignment.name() + " not supported"); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/StartPageNumberScriptlet.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/StartPageNumberScriptlet.java new file mode 100644 index 0000000..c85d0bb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/StartPageNumberScriptlet.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import net.sf.jasperreports.engine.JRDefaultScriptlet; +import net.sf.jasperreports.engine.JRScriptletException; +import net.sf.jasperreports.engine.JRVariable; + +/** + *

StartPageNumberScriptlet class.

+ * + * @author Ricardo Mariaca + * + */ +public class StartPageNumberScriptlet extends JRDefaultScriptlet { + + private JasperCustomValues getCustomValues() { + try { + return (JasperCustomValues) getParameterValue(JasperCustomValues.NAME, false); + } catch (JRScriptletException e) { + throw new JasperDesignException("Custom values not found", e); + } + } + + /** {@inheritDoc} */ + @Override + public void afterReportInit() throws JRScriptletException { + super.afterReportInit(); + JasperCustomValues customValues = getCustomValues(); + if (customValues != null && customValues.getStartPageNumber() != null) { + setVariableValue(JRVariable.PAGE_NUMBER, customValues.getStartPageNumber()); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/ThreadSafeJasperScriptletManager.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/ThreadSafeJasperScriptletManager.java new file mode 100644 index 0000000..fc9d4cb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/ThreadSafeJasperScriptletManager.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +/** + * Thread safe implementation of {@link software.xdev.dynamicreports.jasper.base.JasperScriptletManager} used for filling cached reports concurrently. Note: use of this class can lead to memory leaks if the threads starting the report fill + * are not terminated properly. + * + * @author edwin.njeru + * @version 6.0.1-SNAPSHOT + */ +public class ThreadSafeJasperScriptletManager implements JasperScriptletManager { + + private ThreadLocal threadLocalScriptlet = new ThreadLocal<>(); + + /** {@inheritDoc} */ + @Override + public JasperScriptlet getJasperScriptlet() { + return threadLocalScriptlet.get(); + } + + /** {@inheritDoc} */ + @Override + public void setJasperScriptlet(JasperScriptlet jasperScriptlet) { + threadLocalScriptlet.set(jasperScriptlet); + + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/AbstractJasperExcelExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/AbstractJasperExcelExporter.java new file mode 100644 index 0000000..c549cb3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/AbstractJasperExcelExporter.java @@ -0,0 +1,679 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.definition.export.JasperIExcelExporter; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.ImageAnchorType; +import software.xdev.dynamicreports.report.constant.RunDirection; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + *

Abstract AbstractJasperExcelExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractJasperExcelExporter extends AbstractJasperExporter implements JasperIExcelExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Boolean onePagePerSheet; + private Boolean removeEmptySpaceBetweenRows; + private Boolean removeEmptySpaceBetweenColumns; + private Boolean whitePageBackground; + private Boolean detectCellType; + private List sheetNames; + private Boolean fontSizeFixEnabled; + private Boolean imageBorderFixEnabled; + private Integer maxRowsPerSheet; + private Boolean ignoreGraphics; + private Boolean collapseRowSpan; + private Boolean ignoreCellBorder; + private Boolean ignoreCellBackground; + private String password; + private Boolean ignorePageMargins; + private Boolean wrapText; + private Boolean cellLocked; + private Boolean cellHidden; + private String sheetHeaderLeft; + private String sheetHeaderCenter; + private String sheetHeaderRight; + private String sheetFooterLeft; + private String sheetFooterCenter; + private String sheetFooterRight; + private Map formatPatternsMap; + private Boolean ignoreHyperLink; + private Boolean ignoreAnchors; + private Integer fitWidth; + private Integer fitHeight; + private Integer pageScale; + private RunDirection sheetDirection; + private Float columnWidthRatio; + private Boolean useTimeZone; + private Integer firstPageNumber; + private Boolean showGridLines; + private ImageAnchorType imageAnchorType; + private Boolean createCustomPalette; + private String workbookTemplate; + private Boolean keepWorkbookTemplateSheets; + + /** + *

Constructor for AbstractJasperExcelExporter.

+ */ + public AbstractJasperExcelExporter() { + this.sheetNames = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public Boolean getOnePagePerSheet() { + return onePagePerSheet; + } + + /** + *

Setter for the field onePagePerSheet.

+ * + * @param onePagePerSheet a {@link java.lang.Boolean} object. + */ + public void setOnePagePerSheet(Boolean onePagePerSheet) { + this.onePagePerSheet = onePagePerSheet; + } + + /** {@inheritDoc} */ + @Override + public Boolean getRemoveEmptySpaceBetweenRows() { + return removeEmptySpaceBetweenRows; + } + + /** + *

Setter for the field removeEmptySpaceBetweenRows.

+ * + * @param removeEmptySpaceBetweenRows a {@link java.lang.Boolean} object. + */ + public void setRemoveEmptySpaceBetweenRows(Boolean removeEmptySpaceBetweenRows) { + this.removeEmptySpaceBetweenRows = removeEmptySpaceBetweenRows; + } + + /** {@inheritDoc} */ + @Override + public Boolean getRemoveEmptySpaceBetweenColumns() { + return removeEmptySpaceBetweenColumns; + } + + /** + *

Setter for the field removeEmptySpaceBetweenColumns.

+ * + * @param removeEmptySpaceBetweenColumns a {@link java.lang.Boolean} object. + */ + public void setRemoveEmptySpaceBetweenColumns(Boolean removeEmptySpaceBetweenColumns) { + this.removeEmptySpaceBetweenColumns = removeEmptySpaceBetweenColumns; + } + + /** {@inheritDoc} */ + @Override + public Boolean getWhitePageBackground() { + return whitePageBackground; + } + + /** + *

Setter for the field whitePageBackground.

+ * + * @param whitePageBackground a {@link java.lang.Boolean} object. + */ + public void setWhitePageBackground(Boolean whitePageBackground) { + this.whitePageBackground = whitePageBackground; + } + + /** {@inheritDoc} */ + @Override + public Boolean getDetectCellType() { + return detectCellType; + } + + /** + *

Setter for the field detectCellType.

+ * + * @param detectCellType a {@link java.lang.Boolean} object. + */ + public void setDetectCellType(Boolean detectCellType) { + this.detectCellType = detectCellType; + } + + /** {@inheritDoc} */ + @Override + public List getSheetNames() { + return sheetNames; + } + + /** + *

Setter for the field sheetNames.

+ * + * @param sheetNames a {@link java.util.List} object. + */ + public void setSheetNames(List sheetNames) { + this.sheetNames = sheetNames; + } + + /** + *

addSheetName.

+ * + * @param sheetName a {@link java.lang.String} object. + */ + public void addSheetName(String sheetName) { + this.sheetNames.add(sheetName); + } + + /** {@inheritDoc} */ + @Override + public Boolean getFontSizeFixEnabled() { + return fontSizeFixEnabled; + } + + /** + *

Setter for the field fontSizeFixEnabled.

+ * + * @param fontSizeFixEnabled a {@link java.lang.Boolean} object. + */ + public void setFontSizeFixEnabled(Boolean fontSizeFixEnabled) { + this.fontSizeFixEnabled = fontSizeFixEnabled; + } + + /** {@inheritDoc} */ + @Override + public Boolean getImageBorderFixEnabled() { + return imageBorderFixEnabled; + } + + /** + *

Setter for the field imageBorderFixEnabled.

+ * + * @param imageBorderFixEnabled a {@link java.lang.Boolean} object. + */ + public void setImageBorderFixEnabled(Boolean imageBorderFixEnabled) { + this.imageBorderFixEnabled = imageBorderFixEnabled; + } + + /** {@inheritDoc} */ + @Override + public Integer getMaxRowsPerSheet() { + return maxRowsPerSheet; + } + + /** + *

Setter for the field maxRowsPerSheet.

+ * + * @param maxRowsPerSheet a {@link java.lang.Integer} object. + */ + public void setMaxRowsPerSheet(Integer maxRowsPerSheet) { + this.maxRowsPerSheet = maxRowsPerSheet; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreGraphics() { + return ignoreGraphics; + } + + /** + *

Setter for the field ignoreGraphics.

+ * + * @param ignoreGraphics a {@link java.lang.Boolean} object. + */ + public void setIgnoreGraphics(Boolean ignoreGraphics) { + this.ignoreGraphics = ignoreGraphics; + } + + /** {@inheritDoc} */ + @Override + public Boolean getCollapseRowSpan() { + return collapseRowSpan; + } + + /** + *

Setter for the field collapseRowSpan.

+ * + * @param collapseRowSpan a {@link java.lang.Boolean} object. + */ + public void setCollapseRowSpan(Boolean collapseRowSpan) { + this.collapseRowSpan = collapseRowSpan; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreCellBorder() { + return ignoreCellBorder; + } + + /** + *

Setter for the field ignoreCellBorder.

+ * + * @param ignoreCellBorder a {@link java.lang.Boolean} object. + */ + public void setIgnoreCellBorder(Boolean ignoreCellBorder) { + this.ignoreCellBorder = ignoreCellBorder; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreCellBackground() { + return ignoreCellBackground; + } + + /** + *

Setter for the field ignoreCellBackground.

+ * + * @param ignoreCellBackground a {@link java.lang.Boolean} object. + */ + public void setIgnoreCellBackground(Boolean ignoreCellBackground) { + this.ignoreCellBackground = ignoreCellBackground; + } + + /** {@inheritDoc} */ + @Override + public String getPassword() { + return password; + } + + /** + *

Setter for the field password.

+ * + * @param password a {@link java.lang.String} object. + */ + public void setPassword(String password) { + this.password = password; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnorePageMargins() { + return ignorePageMargins; + } + + /** + *

Setter for the field ignorePageMargins.

+ * + * @param ignorePageMargins a {@link java.lang.Boolean} object. + */ + public void setIgnorePageMargins(Boolean ignorePageMargins) { + this.ignorePageMargins = ignorePageMargins; + } + + /** {@inheritDoc} */ + @Override + public Boolean getWrapText() { + return wrapText; + } + + /** + *

Setter for the field wrapText.

+ * + * @param wrapText a {@link java.lang.Boolean} object. + */ + public void setWrapText(Boolean wrapText) { + this.wrapText = wrapText; + } + + /** {@inheritDoc} */ + @Override + public Boolean getCellLocked() { + return cellLocked; + } + + /** + *

Setter for the field cellLocked.

+ * + * @param cellLocked a {@link java.lang.Boolean} object. + */ + public void setCellLocked(Boolean cellLocked) { + this.cellLocked = cellLocked; + } + + /** {@inheritDoc} */ + @Override + public Boolean getCellHidden() { + return cellHidden; + } + + /** + *

Setter for the field cellHidden.

+ * + * @param cellHidden a {@link java.lang.Boolean} object. + */ + public void setCellHidden(Boolean cellHidden) { + this.cellHidden = cellHidden; + } + + /** {@inheritDoc} */ + @Override + public String getSheetHeaderLeft() { + return sheetHeaderLeft; + } + + /** + *

Setter for the field sheetHeaderLeft.

+ * + * @param sheetHeaderLeft a {@link java.lang.String} object. + */ + public void setSheetHeaderLeft(String sheetHeaderLeft) { + this.sheetHeaderLeft = sheetHeaderLeft; + } + + /** {@inheritDoc} */ + @Override + public String getSheetHeaderCenter() { + return sheetHeaderCenter; + } + + /** + *

Setter for the field sheetHeaderCenter.

+ * + * @param sheetHeaderCenter a {@link java.lang.String} object. + */ + public void setSheetHeaderCenter(String sheetHeaderCenter) { + this.sheetHeaderCenter = sheetHeaderCenter; + } + + /** {@inheritDoc} */ + @Override + public String getSheetHeaderRight() { + return sheetHeaderRight; + } + + /** + *

Setter for the field sheetHeaderRight.

+ * + * @param sheetHeaderRight a {@link java.lang.String} object. + */ + public void setSheetHeaderRight(String sheetHeaderRight) { + this.sheetHeaderRight = sheetHeaderRight; + } + + /** {@inheritDoc} */ + @Override + public String getSheetFooterLeft() { + return sheetFooterLeft; + } + + /** + *

Setter for the field sheetFooterLeft.

+ * + * @param sheetFooterLeft a {@link java.lang.String} object. + */ + public void setSheetFooterLeft(String sheetFooterLeft) { + this.sheetFooterLeft = sheetFooterLeft; + } + + /** {@inheritDoc} */ + @Override + public String getSheetFooterCenter() { + return sheetFooterCenter; + } + + /** + *

Setter for the field sheetFooterCenter.

+ * + * @param sheetFooterCenter a {@link java.lang.String} object. + */ + public void setSheetFooterCenter(String sheetFooterCenter) { + this.sheetFooterCenter = sheetFooterCenter; + } + + /** {@inheritDoc} */ + @Override + public String getSheetFooterRight() { + return sheetFooterRight; + } + + /** + *

Setter for the field sheetFooterRight.

+ * + * @param sheetFooterRight a {@link java.lang.String} object. + */ + public void setSheetFooterRight(String sheetFooterRight) { + this.sheetFooterRight = sheetFooterRight; + } + + /** {@inheritDoc} */ + @Override + public Map getFormatPatternsMap() { + return formatPatternsMap; + } + + /** + *

Setter for the field formatPatternsMap.

+ * + * @param formatPatternsMap a {@link java.util.Map} object. + */ + public void setFormatPatternsMap(Map formatPatternsMap) { + this.formatPatternsMap = formatPatternsMap; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreHyperLink() { + return ignoreHyperLink; + } + + /** + *

Setter for the field ignoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + */ + public void setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.ignoreHyperLink = ignoreHyperLink; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreAnchors() { + return ignoreAnchors; + } + + /** + *

Setter for the field ignoreAnchors.

+ * + * @param ignoreAnchors a {@link java.lang.Boolean} object. + */ + public void setIgnoreAnchors(Boolean ignoreAnchors) { + this.ignoreAnchors = ignoreAnchors; + } + + /** {@inheritDoc} */ + @Override + public Integer getFitWidth() { + return fitWidth; + } + + /** + *

Setter for the field fitWidth.

+ * + * @param fitWidth a {@link java.lang.Integer} object. + */ + public void setFitWidth(Integer fitWidth) { + this.fitWidth = fitWidth; + } + + /** {@inheritDoc} */ + @Override + public Integer getFitHeight() { + return fitHeight; + } + + /** + *

Setter for the field fitHeight.

+ * + * @param fitHeight a {@link java.lang.Integer} object. + */ + public void setFitHeight(Integer fitHeight) { + this.fitHeight = fitHeight; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageScale() { + return pageScale; + } + + /** + *

Setter for the field pageScale.

+ * + * @param pageScale a {@link java.lang.Integer} object. + */ + public void setPageScale(Integer pageScale) { + this.pageScale = pageScale; + } + + /** {@inheritDoc} */ + @Override + public RunDirection getSheetDirection() { + return sheetDirection; + } + + /** + *

Setter for the field sheetDirection.

+ * + * @param sheetDirection a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public void setSheetDirection(RunDirection sheetDirection) { + this.sheetDirection = sheetDirection; + } + + /** {@inheritDoc} */ + @Override + public Float getColumnWidthRatio() { + return columnWidthRatio; + } + + /** + *

Setter for the field columnWidthRatio.

+ * + * @param columnWidthRatio a {@link java.lang.Float} object. + */ + public void setColumnWidthRatio(Float columnWidthRatio) { + this.columnWidthRatio = columnWidthRatio; + } + + /** {@inheritDoc} */ + @Override + public Boolean getUseTimeZone() { + return useTimeZone; + } + + /** + *

Setter for the field useTimeZone.

+ * + * @param useTimeZone a {@link java.lang.Boolean} object. + */ + public void setUseTimeZone(Boolean useTimeZone) { + this.useTimeZone = useTimeZone; + } + + /** {@inheritDoc} */ + @Override + public Integer getFirstPageNumber() { + return firstPageNumber; + } + + /** + *

Setter for the field firstPageNumber.

+ * + * @param firstPageNumber a {@link java.lang.Integer} object. + */ + public void setFirstPageNumber(Integer firstPageNumber) { + this.firstPageNumber = firstPageNumber; + } + + /** {@inheritDoc} */ + @Override + public Boolean getShowGridLines() { + return showGridLines; + } + + /** + *

Setter for the field showGridLines.

+ * + * @param showGridLines a {@link java.lang.Boolean} object. + */ + public void setShowGridLines(Boolean showGridLines) { + this.showGridLines = showGridLines; + } + + /** {@inheritDoc} */ + @Override + public ImageAnchorType getImageAnchorType() { + return imageAnchorType; + } + + /** + *

Setter for the field imageAnchorType.

+ * + * @param imageAnchorType a {@link software.xdev.dynamicreports.report.constant.ImageAnchorType} object. + */ + public void setImageAnchorType(ImageAnchorType imageAnchorType) { + this.imageAnchorType = imageAnchorType; + } + + /** {@inheritDoc} */ + @Override + public Boolean getCreateCustomPalette() { + return createCustomPalette; + } + + /** + *

Setter for the field createCustomPalette.

+ * + * @param createCustomPalette a {@link java.lang.Boolean} object. + */ + public void setCreateCustomPalette(Boolean createCustomPalette) { + this.createCustomPalette = createCustomPalette; + } + + /** {@inheritDoc} */ + @Override + public String getWorkbookTemplate() { + return workbookTemplate; + } + + /** + *

Setter for the field workbookTemplate.

+ * + * @param workbookTemplate a {@link java.lang.String} object. + */ + public void setWorkbookTemplate(String workbookTemplate) { + this.workbookTemplate = workbookTemplate; + } + + /** {@inheritDoc} */ + @Override + public Boolean getKeepWorkbookTemplateSheets() { + return keepWorkbookTemplateSheets; + } + + /** + *

Setter for the field keepWorkbookTemplateSheets.

+ * + * @param keepWorkbookTemplateSheets a {@link java.lang.Boolean} object. + */ + public void setKeepWorkbookTemplateSheets(Boolean keepWorkbookTemplateSheets) { + this.keepWorkbookTemplateSheets = keepWorkbookTemplateSheets; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/AbstractJasperExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/AbstractJasperExporter.java new file mode 100644 index 0000000..da107d1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/AbstractJasperExporter.java @@ -0,0 +1,203 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.definition.export.JasperIExporter; +import software.xdev.dynamicreports.report.constant.Constants; +import org.apache.commons.lang3.Validate; + +import java.io.File; +import java.io.OutputStream; +import java.io.Writer; + +/** + *

Abstract AbstractJasperExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractJasperExporter implements JasperIExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Writer outputWriter; + private OutputStream outputStream; + private File outputFile; + private String outputFileName; + + private Integer pageIndex; + private Integer startPageIndex; + private Integer endPageIndex; + private String characterEncoding; + private Integer offsetX; + private Integer offsetY; + + /** {@inheritDoc} */ + @Override + public Writer getOutputWriter() { + return outputWriter; + } + + /** + *

Setter for the field outputWriter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + */ + public void setOutputWriter(Writer outputWriter) { + Validate.notNull(outputWriter, "outputWriter must not be null"); + this.outputWriter = outputWriter; + } + + /** {@inheritDoc} */ + @Override + public OutputStream getOutputStream() { + return outputStream; + } + + /** + *

Setter for the field outputStream.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + */ + public void setOutputStream(OutputStream outputStream) { + Validate.notNull(outputStream, "outputStream must not be null"); + this.outputStream = outputStream; + } + + /** {@inheritDoc} */ + @Override + public File getOutputFile() { + return outputFile; + } + + /** + *

Setter for the field outputFile.

+ * + * @param outputFile a {@link java.io.File} object. + */ + public void setOutputFile(File outputFile) { + Validate.notNull(outputFile, "outputFile must not be null"); + this.outputFile = outputFile; + } + + /** {@inheritDoc} */ + @Override + public String getOutputFileName() { + return outputFileName; + } + + /** + *

Setter for the field outputFileName.

+ * + * @param outputFileName a {@link java.lang.String} object. + */ + public void setOutputFileName(String outputFileName) { + Validate.notNull(outputFileName, "outputFileName must not be null"); + this.outputFileName = outputFileName; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageIndex() { + return pageIndex; + } + + /** + *

Setter for the field pageIndex.

+ * + * @param pageIndex a {@link java.lang.Integer} object. + */ + public void setPageIndex(Integer pageIndex) { + this.pageIndex = pageIndex; + } + + /** {@inheritDoc} */ + @Override + public Integer getStartPageIndex() { + return startPageIndex; + } + + /** + *

Setter for the field startPageIndex.

+ * + * @param startPageIndex a {@link java.lang.Integer} object. + */ + public void setStartPageIndex(Integer startPageIndex) { + this.startPageIndex = startPageIndex; + } + + /** {@inheritDoc} */ + @Override + public Integer getEndPageIndex() { + return endPageIndex; + } + + /** + *

Setter for the field endPageIndex.

+ * + * @param endPageIndex a {@link java.lang.Integer} object. + */ + public void setEndPageIndex(Integer endPageIndex) { + this.endPageIndex = endPageIndex; + } + + /** {@inheritDoc} */ + @Override + public String getCharacterEncoding() { + return characterEncoding; + } + + /** + *

Setter for the field characterEncoding.

+ * + * @param characterEncoding a {@link java.lang.String} object. + */ + public void setCharacterEncoding(String characterEncoding) { + this.characterEncoding = characterEncoding; + } + + /** {@inheritDoc} */ + @Override + public Integer getOffsetX() { + return offsetX; + } + + /** + *

Setter for the field offsetX.

+ * + * @param offsetX a {@link java.lang.Integer} object. + */ + public void setOffsetX(Integer offsetX) { + this.offsetX = offsetX; + } + + /** {@inheritDoc} */ + @Override + public Integer getOffsetY() { + return offsetY; + } + + /** + *

Setter for the field offsetY.

+ * + * @param offsetY a {@link java.lang.Integer} object. + */ + public void setOffsetY(Integer offsetY) { + this.offsetY = offsetY; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperCsvExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperCsvExporter.java new file mode 100644 index 0000000..0169d35 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperCsvExporter.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.definition.export.JasperICsvExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperCsvExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperCsvExporter extends AbstractJasperExporter implements JasperICsvExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String fieldDelimiter; + private String recordDelimiter; + + /** {@inheritDoc} */ + @Override + public String getFieldDelimiter() { + return fieldDelimiter; + } + + /** + *

Setter for the field fieldDelimiter.

+ * + * @param fieldDelimiter a {@link java.lang.String} object. + */ + public void setFieldDelimiter(String fieldDelimiter) { + this.fieldDelimiter = fieldDelimiter; + } + + /** {@inheritDoc} */ + @Override + public String getRecordDelimiter() { + return recordDelimiter; + } + + /** + *

Setter for the field recordDelimiter.

+ * + * @param recordDelimiter a {@link java.lang.String} object. + */ + public void setRecordDelimiter(String recordDelimiter) { + this.recordDelimiter = recordDelimiter; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperDocxExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperDocxExporter.java new file mode 100644 index 0000000..d66c761 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperDocxExporter.java @@ -0,0 +1,81 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.definition.export.JasperIDocxExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperDocxExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperDocxExporter extends AbstractJasperExporter implements JasperIDocxExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Boolean framesAsNestedTables; + private Boolean flexibleRowHeight; + private Boolean ignoreHyperLink; + + /** {@inheritDoc} */ + @Override + public Boolean getFramesAsNestedTables() { + return framesAsNestedTables; + } + + /** + *

Setter for the field framesAsNestedTables.

+ * + * @param framesAsNestedTables a {@link java.lang.Boolean} object. + */ + public void setFramesAsNestedTables(Boolean framesAsNestedTables) { + this.framesAsNestedTables = framesAsNestedTables; + } + + /** {@inheritDoc} */ + @Override + public Boolean getFlexibleRowHeight() { + return flexibleRowHeight; + } + + /** + *

Setter for the field flexibleRowHeight.

+ * + * @param flexibleRowHeight a {@link java.lang.Boolean} object. + */ + public void setFlexibleRowHeight(Boolean flexibleRowHeight) { + this.flexibleRowHeight = flexibleRowHeight; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreHyperLink() { + return ignoreHyperLink; + } + + /** + *

Setter for the field ignoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + */ + public void setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.ignoreHyperLink = ignoreHyperLink; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperHtmlExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperHtmlExporter.java new file mode 100644 index 0000000..fff083e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperHtmlExporter.java @@ -0,0 +1,322 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.constant.SizeUnit; +import software.xdev.dynamicreports.jasper.definition.export.JasperIHtmlExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperHtmlExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperHtmlExporter extends AbstractJasperExporter implements JasperIHtmlExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Boolean outputImagesToDir; + private String imagesDirName; + private String imagesURI; + private String htmlHeader; + private String betweenPagesHtml; + private String htmlFooter; + private Boolean removeEmptySpaceBetweenRows; + private Boolean whitePageBackground; + private Boolean usingImagesToAlign; + private Boolean wrapBreakWord; + private SizeUnit sizeUnit; + private Boolean framesAsNestedTables; + private Boolean ignorePageMargins; + private String borderCollapse; + private Boolean accessibleHtml; + private Float zoomRatio; + private Boolean ignoreHyperLink; + private Boolean flushOutput; + + /** {@inheritDoc} */ + @Override + public Boolean getOutputImagesToDir() { + return outputImagesToDir; + } + + /** + *

Setter for the field outputImagesToDir.

+ * + * @param outputImagesToDir a {@link java.lang.Boolean} object. + */ + public void setOutputImagesToDir(Boolean outputImagesToDir) { + this.outputImagesToDir = outputImagesToDir; + } + + /** {@inheritDoc} */ + @Override + public String getImagesDirName() { + return imagesDirName; + } + + /** + *

Setter for the field imagesDirName.

+ * + * @param imagesDirName a {@link java.lang.String} object. + */ + public void setImagesDirName(String imagesDirName) { + this.imagesDirName = imagesDirName; + } + + /** {@inheritDoc} */ + @Override + public String getImagesURI() { + return imagesURI; + } + + /** + *

Setter for the field imagesURI.

+ * + * @param imagesURI a {@link java.lang.String} object. + */ + public void setImagesURI(String imagesURI) { + this.imagesURI = imagesURI; + } + + /** {@inheritDoc} */ + @Override + public String getHtmlHeader() { + return htmlHeader; + } + + /** + *

Setter for the field htmlHeader.

+ * + * @param htmlHeader a {@link java.lang.String} object. + */ + public void setHtmlHeader(String htmlHeader) { + this.htmlHeader = htmlHeader; + } + + /** {@inheritDoc} */ + @Override + public String getBetweenPagesHtml() { + return betweenPagesHtml; + } + + /** + *

Setter for the field betweenPagesHtml.

+ * + * @param betweenPagesHtml a {@link java.lang.String} object. + */ + public void setBetweenPagesHtml(String betweenPagesHtml) { + this.betweenPagesHtml = betweenPagesHtml; + } + + /** {@inheritDoc} */ + @Override + public String getHtmlFooter() { + return htmlFooter; + } + + /** + *

Setter for the field htmlFooter.

+ * + * @param htmlFooter a {@link java.lang.String} object. + */ + public void setHtmlFooter(String htmlFooter) { + this.htmlFooter = htmlFooter; + } + + /** {@inheritDoc} */ + @Override + public Boolean getRemoveEmptySpaceBetweenRows() { + return removeEmptySpaceBetweenRows; + } + + /** + *

Setter for the field removeEmptySpaceBetweenRows.

+ * + * @param removeEmptySpaceBetweenRows a {@link java.lang.Boolean} object. + */ + public void setRemoveEmptySpaceBetweenRows(Boolean removeEmptySpaceBetweenRows) { + this.removeEmptySpaceBetweenRows = removeEmptySpaceBetweenRows; + } + + /** {@inheritDoc} */ + @Override + public Boolean getWhitePageBackground() { + return whitePageBackground; + } + + /** + *

Setter for the field whitePageBackground.

+ * + * @param whitePageBackground a {@link java.lang.Boolean} object. + */ + public void setWhitePageBackground(Boolean whitePageBackground) { + this.whitePageBackground = whitePageBackground; + } + + /** {@inheritDoc} */ + @Override + public Boolean getUsingImagesToAlign() { + return usingImagesToAlign; + } + + /** + *

Setter for the field usingImagesToAlign.

+ * + * @param usingImagesToAlign a {@link java.lang.Boolean} object. + */ + public void setUsingImagesToAlign(Boolean usingImagesToAlign) { + this.usingImagesToAlign = usingImagesToAlign; + } + + /** {@inheritDoc} */ + @Override + public Boolean getWrapBreakWord() { + return wrapBreakWord; + } + + /** + *

Setter for the field wrapBreakWord.

+ * + * @param wrapBreakWord a {@link java.lang.Boolean} object. + */ + public void setWrapBreakWord(Boolean wrapBreakWord) { + this.wrapBreakWord = wrapBreakWord; + } + + /** {@inheritDoc} */ + @Override + public SizeUnit getSizeUnit() { + return sizeUnit; + } + + /** + *

Setter for the field sizeUnit.

+ * + * @param sizeUnit a {@link software.xdev.dynamicreports.jasper.constant.SizeUnit} object. + */ + public void setSizeUnit(SizeUnit sizeUnit) { + this.sizeUnit = sizeUnit; + } + + /** {@inheritDoc} */ + @Override + public Boolean getFramesAsNestedTables() { + return framesAsNestedTables; + } + + /** + *

Setter for the field framesAsNestedTables.

+ * + * @param framesAsNestedTables a {@link java.lang.Boolean} object. + */ + public void setFramesAsNestedTables(Boolean framesAsNestedTables) { + this.framesAsNestedTables = framesAsNestedTables; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnorePageMargins() { + return ignorePageMargins; + } + + /** + *

Setter for the field ignorePageMargins.

+ * + * @param ignorePageMargins a {@link java.lang.Boolean} object. + */ + public void setIgnorePageMargins(Boolean ignorePageMargins) { + this.ignorePageMargins = ignorePageMargins; + } + + /** {@inheritDoc} */ + @Override + public String getBorderCollapse() { + return borderCollapse; + } + + /** + *

Setter for the field borderCollapse.

+ * + * @param borderCollapse a {@link java.lang.String} object. + */ + public void setBorderCollapse(String borderCollapse) { + this.borderCollapse = borderCollapse; + } + + /** {@inheritDoc} */ + @Override + public Boolean getAccessibleHtml() { + return accessibleHtml; + } + + /** + *

Setter for the field accessibleHtml.

+ * + * @param accessibleHtml a {@link java.lang.Boolean} object. + */ + public void setAccessibleHtml(Boolean accessibleHtml) { + this.accessibleHtml = accessibleHtml; + } + + /** {@inheritDoc} */ + @Override + public Float getZoomRatio() { + return zoomRatio; + } + + /** + *

Setter for the field zoomRatio.

+ * + * @param zoomRatio a {@link java.lang.Float} object. + */ + public void setZoomRatio(Float zoomRatio) { + this.zoomRatio = zoomRatio; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreHyperLink() { + return ignoreHyperLink; + } + + /** + *

Setter for the field ignoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + */ + public void setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.ignoreHyperLink = ignoreHyperLink; + } + + /** {@inheritDoc} */ + @Override + public Boolean getFlushOutput() { + return flushOutput; + } + + /** + *

Setter for the field flushOutput.

+ * + * @param flushOutput a {@link java.lang.Boolean} object. + */ + public void setFlushOutput(Boolean flushOutput) { + this.flushOutput = flushOutput; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperOdsExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperOdsExporter.java new file mode 100644 index 0000000..55d4fd1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperOdsExporter.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.definition.export.JasperIOdsExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperOdsExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperOdsExporter extends AbstractJasperExcelExporter implements JasperIOdsExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Boolean flexibleRowHeight; + + /** {@inheritDoc} */ + @Override + public Boolean getFlexibleRowHeight() { + return flexibleRowHeight; + } + + /** + *

Setter for the field flexibleRowHeight.

+ * + * @param flexibleRowHeight a {@link java.lang.Boolean} object. + */ + public void setFlexibleRowHeight(Boolean flexibleRowHeight) { + this.flexibleRowHeight = flexibleRowHeight; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperOdtExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperOdtExporter.java new file mode 100644 index 0000000..7b68176 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperOdtExporter.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.definition.export.JasperIOdtExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperOdtExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperOdtExporter extends AbstractJasperExporter implements JasperIOdtExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Boolean flexibleRowHeight; + private Boolean ignoreHyperLink; + + /** {@inheritDoc} */ + @Override + public Boolean getFlexibleRowHeight() { + return flexibleRowHeight; + } + + /** + *

Setter for the field flexibleRowHeight.

+ * + * @param flexibleRowHeight a {@link java.lang.Boolean} object. + */ + public void setFlexibleRowHeight(Boolean flexibleRowHeight) { + this.flexibleRowHeight = flexibleRowHeight; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreHyperLink() { + return ignoreHyperLink; + } + + /** + *

Setter for the field ignoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + */ + public void setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.ignoreHyperLink = ignoreHyperLink; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperPdfExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperPdfExporter.java new file mode 100644 index 0000000..4b90089 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperPdfExporter.java @@ -0,0 +1,488 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.constant.PdfPermission; +import software.xdev.dynamicreports.jasper.constant.PdfVersion; +import software.xdev.dynamicreports.jasper.definition.export.JasperIPdfExporter; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.PdfPrintScaling; +import software.xdev.dynamicreports.report.constant.PdfaConformance; + +import java.util.ArrayList; +import java.util.List; + +/** + *

JasperPdfExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperPdfExporter extends AbstractJasperExporter implements JasperIPdfExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Boolean creatingBatchModeBookmarks; + private Boolean compressed; + private Boolean encrypted; + private Boolean bitKey128; + private String userPassword; + private String ownerPassword; + private List permissions; + private PdfVersion pdfVersion; + private String metadataTitle; + private String metadataAuthor; + private String metadataSubject; + private String metadataKeyWords; + private String metadataCreator; + private Boolean forceSvgShapes; + private String pdfJavaScript; + private Boolean tagged; + private String tagLanguage; + private Boolean collapseMissingBookmarkLevels; + private Boolean sizePageToContent; + private Boolean ignoreHyperLink; + private Boolean forceLineBreakPolicy; + private PdfPrintScaling printScaling; + private PdfaConformance pdfaConformance; + private String iccProfilePath; + private String allowedPermissionsHint; + private String deniedPermissionsHint; + private Boolean displayMetadataTitle; + + /** + *

Constructor for JasperPdfExporter.

+ */ + public JasperPdfExporter() { + permissions = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public Boolean getCreatingBatchModeBookmarks() { + return creatingBatchModeBookmarks; + } + + /** + *

Setter for the field creatingBatchModeBookmarks.

+ * + * @param creatingBatchModeBookmarks a {@link java.lang.Boolean} object. + */ + public void setCreatingBatchModeBookmarks(Boolean creatingBatchModeBookmarks) { + this.creatingBatchModeBookmarks = creatingBatchModeBookmarks; + } + + /** {@inheritDoc} */ + @Override + public Boolean getCompressed() { + return compressed; + } + + /** + *

Setter for the field compressed.

+ * + * @param compressed a {@link java.lang.Boolean} object. + */ + public void setCompressed(Boolean compressed) { + this.compressed = compressed; + } + + /** {@inheritDoc} */ + @Override + public Boolean getEncrypted() { + return encrypted; + } + + /** + *

Setter for the field encrypted.

+ * + * @param encrypted a {@link java.lang.Boolean} object. + */ + public void setEncrypted(Boolean encrypted) { + this.encrypted = encrypted; + } + + /** {@inheritDoc} */ + @Override + public Boolean getBitKey128() { + return bitKey128; + } + + /** + *

Setter for the field bitKey128.

+ * + * @param bitKey128 a {@link java.lang.Boolean} object. + */ + public void setBitKey128(Boolean bitKey128) { + this.bitKey128 = bitKey128; + } + + /** {@inheritDoc} */ + @Override + public String getUserPassword() { + return userPassword; + } + + /** + *

Setter for the field userPassword.

+ * + * @param userPassword a {@link java.lang.String} object. + */ + public void setUserPassword(String userPassword) { + this.userPassword = userPassword; + } + + /** {@inheritDoc} */ + @Override + public String getOwnerPassword() { + return ownerPassword; + } + + /** + *

Setter for the field ownerPassword.

+ * + * @param ownerPassword a {@link java.lang.String} object. + */ + public void setOwnerPassword(String ownerPassword) { + this.ownerPassword = ownerPassword; + } + + /** {@inheritDoc} */ + @Override + public List getPermissions() { + return permissions; + } + + /** + *

Setter for the field permissions.

+ * + * @param permissions a {@link java.util.List} object. + */ + public void setPermissions(List permissions) { + this.permissions = permissions; + } + + /** + *

addPermission.

+ * + * @param permission a {@link software.xdev.dynamicreports.jasper.constant.PdfPermission} object. + */ + public void addPermission(PdfPermission permission) { + this.permissions.add(permission); + } + + /** {@inheritDoc} */ + @Override + public PdfVersion getPdfVersion() { + return pdfVersion; + } + + /** + *

Setter for the field pdfVersion.

+ * + * @param pdfVersion a {@link software.xdev.dynamicreports.jasper.constant.PdfVersion} object. + */ + public void setPdfVersion(PdfVersion pdfVersion) { + this.pdfVersion = pdfVersion; + } + + /** {@inheritDoc} */ + @Override + public String getMetadataTitle() { + return metadataTitle; + } + + /** + *

Setter for the field metadataTitle.

+ * + * @param metadataTitle a {@link java.lang.String} object. + */ + public void setMetadataTitle(String metadataTitle) { + this.metadataTitle = metadataTitle; + } + + /** {@inheritDoc} */ + @Override + public String getMetadataAuthor() { + return metadataAuthor; + } + + /** + *

Setter for the field metadataAuthor.

+ * + * @param metadataAuthor a {@link java.lang.String} object. + */ + public void setMetadataAuthor(String metadataAuthor) { + this.metadataAuthor = metadataAuthor; + } + + /** {@inheritDoc} */ + @Override + public String getMetadataSubject() { + return metadataSubject; + } + + /** + *

Setter for the field metadataSubject.

+ * + * @param metadataSubject a {@link java.lang.String} object. + */ + public void setMetadataSubject(String metadataSubject) { + this.metadataSubject = metadataSubject; + } + + /** {@inheritDoc} */ + @Override + public String getMetadataKeyWords() { + return metadataKeyWords; + } + + /** + *

Setter for the field metadataKeyWords.

+ * + * @param metadataKeyWords a {@link java.lang.String} object. + */ + public void setMetadataKeyWords(String metadataKeyWords) { + this.metadataKeyWords = metadataKeyWords; + } + + /** {@inheritDoc} */ + @Override + public String getMetadataCreator() { + return metadataCreator; + } + + /** + *

Setter for the field metadataCreator.

+ * + * @param metadataCreator a {@link java.lang.String} object. + */ + public void setMetadataCreator(String metadataCreator) { + this.metadataCreator = metadataCreator; + } + + /** {@inheritDoc} */ + @Override + public Boolean getForceSvgShapes() { + return forceSvgShapes; + } + + /** + *

Setter for the field forceSvgShapes.

+ * + * @param forceSvgShapes a {@link java.lang.Boolean} object. + */ + public void setForceSvgShapes(Boolean forceSvgShapes) { + this.forceSvgShapes = forceSvgShapes; + } + + /** {@inheritDoc} */ + @Override + public String getPdfJavaScript() { + return pdfJavaScript; + } + + /** + *

Setter for the field pdfJavaScript.

+ * + * @param pdfJavaScript a {@link java.lang.String} object. + */ + public void setPdfJavaScript(String pdfJavaScript) { + this.pdfJavaScript = pdfJavaScript; + } + + /** {@inheritDoc} */ + @Override + public Boolean getTagged() { + return tagged; + } + + /** + *

Setter for the field tagged.

+ * + * @param tagged a {@link java.lang.Boolean} object. + */ + public void setTagged(Boolean tagged) { + this.tagged = tagged; + } + + /** {@inheritDoc} */ + @Override + public String getTagLanguage() { + return tagLanguage; + } + + /** + *

Setter for the field tagLanguage.

+ * + * @param tagLanguage a {@link java.lang.String} object. + */ + public void setTagLanguage(String tagLanguage) { + this.tagLanguage = tagLanguage; + } + + /** {@inheritDoc} */ + @Override + public Boolean getCollapseMissingBookmarkLevels() { + return collapseMissingBookmarkLevels; + } + + /** + *

Setter for the field collapseMissingBookmarkLevels.

+ * + * @param collapseMissingBookmarkLevels a {@link java.lang.Boolean} object. + */ + public void setCollapseMissingBookmarkLevels(Boolean collapseMissingBookmarkLevels) { + this.collapseMissingBookmarkLevels = collapseMissingBookmarkLevels; + } + + /** {@inheritDoc} */ + @Override + public Boolean getSizePageToContent() { + return sizePageToContent; + } + + /** + *

Setter for the field sizePageToContent.

+ * + * @param sizePageToContent a {@link java.lang.Boolean} object. + */ + public void setSizePageToContent(Boolean sizePageToContent) { + this.sizePageToContent = sizePageToContent; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreHyperLink() { + return ignoreHyperLink; + } + + /** + *

Setter for the field ignoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + */ + public void setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.ignoreHyperLink = ignoreHyperLink; + } + + /** {@inheritDoc} */ + @Override + public Boolean getForceLineBreakPolicy() { + return forceLineBreakPolicy; + } + + /** + *

Setter for the field forceLineBreakPolicy.

+ * + * @param forceLineBreakPolicy a {@link java.lang.Boolean} object. + */ + public void setForceLineBreakPolicy(Boolean forceLineBreakPolicy) { + this.forceLineBreakPolicy = forceLineBreakPolicy; + } + + /** {@inheritDoc} */ + @Override + public PdfPrintScaling getPrintScaling() { + return printScaling; + } + + /** + *

Setter for the field printScaling.

+ * + * @param printScaling a {@link software.xdev.dynamicreports.report.constant.PdfPrintScaling} object. + */ + public void setPrintScaling(PdfPrintScaling printScaling) { + this.printScaling = printScaling; + } + + /** {@inheritDoc} */ + @Override + public PdfaConformance getPdfaConformance() { + return pdfaConformance; + } + + /** + *

Setter for the field pdfaConformance.

+ * + * @param pdfaConformance a {@link software.xdev.dynamicreports.report.constant.PdfaConformance} object. + */ + public void setPdfaConformance(PdfaConformance pdfaConformance) { + this.pdfaConformance = pdfaConformance; + } + + /** {@inheritDoc} */ + @Override + public String getIccProfilePath() { + return iccProfilePath; + } + + /** + *

Setter for the field iccProfilePath.

+ * + * @param iccProfilePath a {@link java.lang.String} object. + */ + public void setIccProfilePath(String iccProfilePath) { + this.iccProfilePath = iccProfilePath; + } + + /** {@inheritDoc} */ + @Override + public String getAllowedPermissionsHint() { + return allowedPermissionsHint; + } + + /** + *

Setter for the field allowedPermissionsHint.

+ * + * @param allowedPermissionsHint a {@link java.lang.String} object. + */ + public void setAllowedPermissionsHint(String allowedPermissionsHint) { + this.allowedPermissionsHint = allowedPermissionsHint; + } + + /** {@inheritDoc} */ + @Override + public String getDeniedPermissionsHint() { + return deniedPermissionsHint; + } + + /** + *

Setter for the field deniedPermissionsHint.

+ * + * @param deniedPermissionsHint a {@link java.lang.String} object. + */ + public void setDeniedPermissionsHint(String deniedPermissionsHint) { + this.deniedPermissionsHint = deniedPermissionsHint; + } + + /** {@inheritDoc} */ + @Override + public Boolean getDisplayMetadataTitle() { + return displayMetadataTitle; + } + + /** + *

Setter for the field displayMetadataTitle.

+ * + * @param displayMetadataTitle a {@link java.lang.Boolean} object. + */ + public void setDisplayMetadataTitle(Boolean displayMetadataTitle) { + this.displayMetadataTitle = displayMetadataTitle; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperPptxExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperPptxExporter.java new file mode 100644 index 0000000..5650f43 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperPptxExporter.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.definition.export.JasperIPptxExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperPptxExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperPptxExporter extends AbstractJasperExporter implements JasperIPptxExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Boolean ignoreHyperLink; + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreHyperLink() { + return ignoreHyperLink; + } + + /** + *

Setter for the field ignoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + */ + public void setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.ignoreHyperLink = ignoreHyperLink; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperRtfExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperRtfExporter.java new file mode 100644 index 0000000..a188084 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperRtfExporter.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.definition.export.JasperIRtfExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperRtfExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperRtfExporter extends AbstractJasperExporter implements JasperIRtfExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Boolean ignoreHyperLink; + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreHyperLink() { + return ignoreHyperLink; + } + + /** + *

Setter for the field ignoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + */ + public void setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.ignoreHyperLink = ignoreHyperLink; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperTextExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperTextExporter.java new file mode 100644 index 0000000..918f9a9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperTextExporter.java @@ -0,0 +1,145 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.definition.export.JasperITextExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperTextExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperTextExporter extends AbstractJasperExporter implements JasperITextExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Float characterWidth; + private Float characterHeight; + private Integer pageWidthInChars; + private Integer pageHeightInChars; + private String pageSeparator; + private String lineSeparator; + private Boolean trimLineRight; + + /** {@inheritDoc} */ + @Override + public Float getCharacterWidth() { + return characterWidth; + } + + /** + *

Setter for the field characterWidth.

+ * + * @param characterWidth a {@link java.lang.Float} object. + */ + public void setCharacterWidth(Float characterWidth) { + this.characterWidth = characterWidth; + } + + /** {@inheritDoc} */ + @Override + public Float getCharacterHeight() { + return characterHeight; + } + + /** + *

Setter for the field characterHeight.

+ * + * @param characterHeight a {@link java.lang.Float} object. + */ + public void setCharacterHeight(Float characterHeight) { + this.characterHeight = characterHeight; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageWidthInChars() { + return pageWidthInChars; + } + + /** + *

Setter for the field pageWidthInChars.

+ * + * @param pageWidthInChars a {@link java.lang.Integer} object. + */ + public void setPageWidthInChars(Integer pageWidthInChars) { + this.pageWidthInChars = pageWidthInChars; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageHeightInChars() { + return pageHeightInChars; + } + + /** + *

Setter for the field pageHeightInChars.

+ * + * @param pageHeightInChars a {@link java.lang.Integer} object. + */ + public void setPageHeightInChars(Integer pageHeightInChars) { + this.pageHeightInChars = pageHeightInChars; + } + + /** {@inheritDoc} */ + @Override + public String getPageSeparator() { + return pageSeparator; + } + + /** + *

Setter for the field pageSeparator.

+ * + * @param pageSeparator a {@link java.lang.String} object. + */ + public void setPageSeparator(String pageSeparator) { + this.pageSeparator = pageSeparator; + } + + /** {@inheritDoc} */ + @Override + public String getLineSeparator() { + return lineSeparator; + } + + /** + *

Setter for the field lineSeparator.

+ * + * @param lineSeparator a {@link java.lang.String} object. + */ + public void setLineSeparator(String lineSeparator) { + this.lineSeparator = lineSeparator; + } + + /** {@inheritDoc} */ + @Override + public Boolean getTrimLineRight() { + return trimLineRight; + } + + /** + *

Setter for the field trimLineRight.

+ * + * @param trimLineRight a {@link java.lang.Boolean} object. + */ + public void setTrimLineRight(Boolean trimLineRight) { + this.trimLineRight = trimLineRight; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperXlsxExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperXlsxExporter.java new file mode 100644 index 0000000..3c427d6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/export/JasperXlsxExporter.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.export; + +import software.xdev.dynamicreports.jasper.definition.export.JasperIXlsxExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperXlsxExporter class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperXlsxExporter extends AbstractJasperExcelExporter implements JasperIXlsxExporter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String macroTemplate; + + /** {@inheritDoc} */ + @Override + public String getMacroTemplate() { + return macroTemplate; + } + + /** + *

Setter for the field macroTemplate.

+ * + * @param macroTemplate a {@link java.lang.String} object. + */ + public void setMacroTemplate(String macroTemplate) { + this.macroTemplate = macroTemplate; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/AbstractPrintListHandler.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/AbstractPrintListHandler.java new file mode 100644 index 0000000..bcbcebe --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/AbstractPrintListHandler.java @@ -0,0 +1,74 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.reporthandler; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.jasper.definition.JasperReportHandler; +import net.sf.jasperreports.engine.JasperPrint; + +/** + *

Abstract AbstractPrintListHandler class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractPrintListHandler implements JasperReportHandler { + private boolean continuousPageNumbering; + private int pageNumber; + + /** + *

Constructor for AbstractPrintListHandler.

+ */ + public AbstractPrintListHandler() { + continuousPageNumbering = false; + pageNumber = 1; + } + + /** {@inheritDoc} */ + @Override + public void concatenate(JasperReportBuilder... jasperReportBuilders) { + for (JasperReportBuilder jasperReportBuilder : jasperReportBuilders) { + try { + if (continuousPageNumbering) { + jasperReportBuilder.setStartPageNumber(pageNumber); + } else { + jasperReportBuilder.setStartPageNumber(null); + } + JasperPrint jasperPrint = jasperReportBuilder.toJasperPrint(); + add(jasperPrint); + pageNumber += jasperPrint.getPages().size(); + jasperReportBuilder.rebuild(); + } catch (Exception e) { + } + } + } + + /** + *

add.

+ * + * @param jasperPrint a {@link net.sf.jasperreports.engine.JasperPrint} object. + */ + protected abstract void add(JasperPrint jasperPrint); + + /** {@inheritDoc} */ + @Override + public void setContinuousPageNumbering(boolean continuousPageNumbering) { + this.continuousPageNumbering = continuousPageNumbering; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/JasperPrintListFileHandler.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/JasperPrintListFileHandler.java new file mode 100644 index 0000000..806713e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/JasperPrintListFileHandler.java @@ -0,0 +1,249 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.reporthandler; + +import software.xdev.dynamicreports.report.exception.DRReportException; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRVirtualizer; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.util.JRLoader; +import net.sf.jasperreports.engine.util.JRSaver; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +/** + *

JasperPrintListFileHandler class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperPrintListFileHandler extends AbstractPrintListHandler { + private static final String TEMP_FILE_PREFIX = "JasperPrint"; + + private List printList; + private List tempFiles; + private File directory; + private JRVirtualizer virtualizer; + + /** + *

Constructor for JasperPrintListFileHandler.

+ * + * @param directory a {@link java.lang.String} object. + */ + public JasperPrintListFileHandler(String directory) { + this(directory, null); + } + + /** + *

Constructor for JasperPrintListFileHandler.

+ * + * @param directory a {@link java.lang.String} object. + * @param virtualizer a {@link net.sf.jasperreports.engine.JRVirtualizer} object. + */ + public JasperPrintListFileHandler(String directory, JRVirtualizer virtualizer) { + this.virtualizer = virtualizer; + if (directory != null) { + this.directory = new File(directory); + } + printList = new PrintList(); + tempFiles = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + protected void add(JasperPrint jasperPrint) { + try { + File tempFile = File.createTempFile(TEMP_FILE_PREFIX, null, directory); + JRSaver.saveObject(jasperPrint, tempFile); + tempFiles.add(tempFile); + } catch (JRException e) { + throw new DRReportException(e); + } catch (IOException e) { + throw new DRReportException(e); + } + } + + /** {@inheritDoc} */ + @Override + public List getPrintList() { + return printList; + } + + /** {@inheritDoc} */ + @Override + protected void finalize() throws Throwable { + for (File tempFile : tempFiles) { + tempFile.delete(); + } + super.finalize(); + } + + private class PrintList implements List { + + @Override + public int size() { + return tempFiles.size(); + } + + @Override + public boolean isEmpty() { + return tempFiles.isEmpty(); + } + + @Override + public boolean contains(Object o) { + throw new UnsupportedOperationException(); + } + + @Override + public Iterator iterator() { + return new Iterator() { + private Iterator it = tempFiles.iterator(); + + @Override + public boolean hasNext() { + return it.hasNext(); + } + + @Override + public JasperPrint next() { + File tempFile = it.next(); + try { + JasperPrint jasperPrint = JRLoader.loadJasperPrint(tempFile, virtualizer); + return jasperPrint; + } catch (JRException e) { + throw new DRReportException(e); + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + }; + } + + @Override + public Object[] toArray() { + throw new UnsupportedOperationException(); + } + + @Override + public T[] toArray(T[] a) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean add(JasperPrint o) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean remove(Object o) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean containsAll(Collection c) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean addAll(Collection c) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean addAll(int index, Collection c) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean removeAll(Collection c) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean retainAll(Collection c) { + throw new UnsupportedOperationException(); + } + + @Override + public void clear() { + throw new UnsupportedOperationException(); + } + + @Override + public JasperPrint get(int index) { + try { + File tempFile = tempFiles.get(index); + JasperPrint jasperPrint = JRLoader.loadJasperPrint(tempFile, virtualizer); + return jasperPrint; + } catch (JRException e) { + throw new DRReportException(e); + } + } + + @Override + public JasperPrint set(int index, JasperPrint element) { + throw new UnsupportedOperationException(); + } + + @Override + public void add(int index, JasperPrint element) { + throw new UnsupportedOperationException(); + } + + @Override + public JasperPrint remove(int index) { + throw new UnsupportedOperationException(); + } + + @Override + public int indexOf(Object o) { + throw new UnsupportedOperationException(); + } + + @Override + public int lastIndexOf(Object o) { + throw new UnsupportedOperationException(); + } + + @Override + public ListIterator listIterator() { + throw new UnsupportedOperationException(); + } + + @Override + public ListIterator listIterator(int index) { + throw new UnsupportedOperationException(); + } + + @Override + public List subList(int fromIndex, int toIndex) { + throw new UnsupportedOperationException(); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/JasperPrintListHandler.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/JasperPrintListHandler.java new file mode 100644 index 0000000..07f2c83 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/JasperPrintListHandler.java @@ -0,0 +1,53 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.reporthandler; + +import net.sf.jasperreports.engine.JasperPrint; + +import java.util.ArrayList; +import java.util.List; + +/** + *

JasperPrintListHandler class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperPrintListHandler extends AbstractPrintListHandler { + private List printList; + + /** + *

Constructor for JasperPrintListHandler.

+ */ + public JasperPrintListHandler() { + printList = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + protected void add(JasperPrint jasperPrint) { + printList.add(jasperPrint); + } + + /** {@inheritDoc} */ + @Override + public List getPrintList() { + return printList; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/JasperReportBuilderHandler.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/JasperReportBuilderHandler.java new file mode 100644 index 0000000..cf4631a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/reporthandler/JasperReportBuilderHandler.java @@ -0,0 +1,78 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.reporthandler; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.jasper.definition.JasperReportHandler; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.JasperPrint; + +import java.util.ArrayList; +import java.util.List; + +/** + *

JasperReportBuilderHandler class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperReportBuilderHandler implements JasperReportHandler { + private List jasperReportBuilders; + private boolean continuousPageNumbering; + + /** + *

Constructor for JasperReportBuilderHandler.

+ */ + public JasperReportBuilderHandler() { + jasperReportBuilders = new ArrayList(); + continuousPageNumbering = false; + } + + /** {@inheritDoc} */ + @Override + public void concatenate(JasperReportBuilder... jasperReportBuilders) { + for (JasperReportBuilder jasperReportBuilder : jasperReportBuilders) { + this.jasperReportBuilders.add(jasperReportBuilder); + } + } + + /** {@inheritDoc} */ + @Override + public void setContinuousPageNumbering(boolean continuousPageNumbering) { + this.continuousPageNumbering = continuousPageNumbering; + } + + /** {@inheritDoc} */ + @Override + public List getPrintList() throws DRException { + List printList = new ArrayList(); + int pageNumber = 1; + for (JasperReportBuilder jasperReportBuilder : jasperReportBuilders) { + if (continuousPageNumbering) { + jasperReportBuilder.setStartPageNumber(pageNumber); + } else { + jasperReportBuilder.setStartPageNumber(null); + } + JasperPrint jasperPrint = jasperReportBuilder.toJasperPrint(); + printList.add(jasperPrint); + pageNumber += jasperPrint.getPages().size(); + } + return printList; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/tableofcontents/JasperTocHeading.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/tableofcontents/JasperTocHeading.java new file mode 100644 index 0000000..b712c43 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/tableofcontents/JasperTocHeading.java @@ -0,0 +1,129 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.tableofcontents; + +import software.xdev.dynamicreports.report.constant.Constants; + +import java.io.Serializable; + +/** + *

JasperTocHeading class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperTocHeading implements Serializable { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer level; + private String text; + private String reference; + private Integer pageIndex; + private Object customValue; + + /** + *

Getter for the field level.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getLevel() { + return level; + } + + /** + *

Setter for the field level.

+ * + * @param level a {@link java.lang.Integer} object. + */ + public void setLevel(Integer level) { + this.level = level; + } + + /** + *

Getter for the field text.

+ * + * @return a {@link java.lang.String} object. + */ + public String getText() { + return text; + } + + /** + *

Setter for the field text.

+ * + * @param text a {@link java.lang.String} object. + */ + public void setText(String text) { + this.text = text; + } + + /** + *

Getter for the field reference.

+ * + * @return a {@link java.lang.String} object. + */ + public String getReference() { + return reference; + } + + /** + *

Setter for the field reference.

+ * + * @param reference a {@link java.lang.String} object. + */ + public void setReference(String reference) { + this.reference = reference; + } + + /** + *

Getter for the field pageIndex.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageIndex() { + return pageIndex; + } + + /** + *

Setter for the field pageIndex.

+ * + * @param pageIndex a {@link java.lang.Integer} object. + */ + public void setPageIndex(Integer pageIndex) { + this.pageIndex = pageIndex; + } + + /** + *

Getter for the field customValue.

+ * + * @return a {@link java.lang.Object} object. + */ + public Object getCustomValue() { + return customValue; + } + + /** + *

Setter for the field customValue.

+ * + * @param customValue a {@link java.lang.Object} object. + */ + public void setCustomValue(Object customValue) { + this.customValue = customValue; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/tableofcontents/JasperTocReport.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/tableofcontents/JasperTocReport.java new file mode 100644 index 0000000..8b201e8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/tableofcontents/JasperTocReport.java @@ -0,0 +1,151 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.tableofcontents; + +import software.xdev.dynamicreports.jasper.base.JasperCustomValues; +import software.xdev.dynamicreports.jasper.base.JasperReportDesign; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import software.xdev.dynamicreports.jasper.transformation.ConstantTransform; +import software.xdev.dynamicreports.report.base.DRPage; +import software.xdev.dynamicreports.report.builder.MarginBuilder; +import software.xdev.dynamicreports.report.constant.TableOfContentsPosition; +import software.xdev.dynamicreports.report.defaults.Defaults; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRParameter; +import net.sf.jasperreports.engine.JRPrintElement; +import net.sf.jasperreports.engine.JRPrintFrame; +import net.sf.jasperreports.engine.JRPrintPage; +import net.sf.jasperreports.engine.JRPrintText; +import net.sf.jasperreports.engine.JRStyle; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.margin; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; + +/** + *

JasperTocReport class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperTocReport { + + /** + *

createTocReport.

+ * + * @param jasperReportDesign a {@link software.xdev.dynamicreports.jasper.base.JasperReportDesign} object. + * @param jasperPrint a {@link net.sf.jasperreports.engine.JasperPrint} object. + * @param parameters a {@link java.util.Map} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + * @throws net.sf.jasperreports.engine.JRException if any. + */ + public static void createTocReport(JasperReportDesign jasperReportDesign, JasperPrint jasperPrint, Map parameters) throws DRException, JRException { + JasperCustomValues customValues = jasperReportDesign.getCustomValues(); + Map headings = customValues.getTocHeadings(); + if (headings != null && !headings.isEmpty()) { + JasperReportBuilder tocReport = report(); + + List headingList = new ArrayList(); + int pageNumber = 1; + for (JRPrintPage page : jasperPrint.getPages()) { + for (JRPrintElement element : page.getElements()) { + addTocHeading(headings, headingList, element, pageNumber); + } + pageNumber++; + } + + int levels = 0; + for (JasperTocHeading heading : headingList) { + if (heading.getLevel() > levels) { + levels = heading.getLevel(); + } + } + levels++; + + DRPage tocPage = tocReport.getReport().getPage(); + tocPage.setWidth(jasperReportDesign.getDesign().getPageWidth()); + tocPage.setHeight(jasperReportDesign.getDesign().getPageHeight()); + tocPage.setOrientation(ConstantTransform.pageOrientation(jasperReportDesign.getDesign().getOrientationValue())); + MarginBuilder tocMargin = margin(); + tocMargin.setTop(jasperReportDesign.getDesign().getTopMargin()); + tocMargin.setLeft(jasperReportDesign.getDesign().getLeftMargin()); + tocMargin.setBottom(jasperReportDesign.getDesign().getBottomMargin()); + tocMargin.setRight(jasperReportDesign.getDesign().getRightMargin()); + tocReport.setLocale((Locale) parameters.get(JRParameter.REPORT_LOCALE)); + tocReport.setResourceBundle((ResourceBundle) parameters.get(JRParameter.REPORT_RESOURCE_BUNDLE)); + tocReport.setPageMargin(tocMargin); + tocReport.setDataSource(new JRBeanCollectionDataSource(headingList)); + + DRITableOfContentsCustomizer tableOfContents = jasperReportDesign.getTableOfContentsCustomizer(); + tableOfContents.setReport(tocReport); + tableOfContents.setHeadingList(headingList); + tableOfContents.setHeadings(headings.size()); + tableOfContents.setLevels(levels); + tableOfContents.customize(); + + TableOfContentsPosition tableOfContentsPosition = tableOfContents.getPosition(); + if (tableOfContentsPosition == null) { + tableOfContentsPosition = Defaults.getDefaults().getTableOfContentsPosition(); + } + JasperPrint tocJasperPrint = tocReport.toJasperPrint(); + for ( + int i = 0; i < tocJasperPrint.getPages().size(); i++) { + JRPrintPage page = tocJasperPrint.getPages().get(i); + switch (tableOfContentsPosition) { + case TOP: + jasperPrint.addPage(i, page); + break; + case BOTTOM: + jasperPrint.addPage(page); + break; + default: + throw new JasperDesignException("Table of contents position " + tableOfContentsPosition.name() + " not supported"); + } + } + for (JRStyle style : tocJasperPrint.getStyles()) { + jasperPrint.addStyle(style); + } + } + } + + private static void addTocHeading(Map headings, List headingList, JRPrintElement element, int pageNumber) { + if (element instanceof JRPrintText && StringUtils.contains(element.getKey(), ".tocReference")) { + String id = ((JRPrintText) element).getAnchorName(); + JasperTocHeading heading = headings.get(id); + heading.setPageIndex(pageNumber); + headingList.add(heading); + } + if (element instanceof JRPrintFrame) { + for (JRPrintElement element2 : ((JRPrintFrame) element).getElements()) { + addTocHeading(headings, headingList, element2, pageNumber); + } + } + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/templatedesign/JasperEmptyTemplateDesign.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/templatedesign/JasperEmptyTemplateDesign.java new file mode 100644 index 0000000..c30aab9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/templatedesign/JasperEmptyTemplateDesign.java @@ -0,0 +1,40 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.templatedesign; + +import software.xdev.dynamicreports.report.base.AbstractTemplateDesign; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.design.JasperDesign; + +/** + *

JasperEmptyTemplateDesign class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperEmptyTemplateDesign extends AbstractTemplateDesign { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public JasperDesign getDesign() throws DRException { + JasperDesign design = new JasperDesign(); + return design; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/templatedesign/JasperTemplateDesign.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/templatedesign/JasperTemplateDesign.java new file mode 100644 index 0000000..002ca1a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/base/templatedesign/JasperTemplateDesign.java @@ -0,0 +1,336 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base.templatedesign; + +import software.xdev.dynamicreports.jasper.transformation.ConstantTransform; +import software.xdev.dynamicreports.report.base.DRField; +import software.xdev.dynamicreports.report.base.DRMargin; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.DRIMargin; +import software.xdev.dynamicreports.report.definition.DRITemplateDesign; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.JRBand; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRField; +import net.sf.jasperreports.engine.JRParameter; +import net.sf.jasperreports.engine.design.JasperDesign; +import net.sf.jasperreports.engine.xml.JRXmlLoader; +import net.sf.jasperreports.engine.xml.JRXmlWriter; +import org.apache.commons.lang3.Validate; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/** + *

JasperTemplateDesign class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperTemplateDesign implements DRITemplateDesign { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private JasperDesign jasperDesign; + private List> fields; + private DRMargin margin; + private transient ByteArrayOutputStream templateDesign; + + /** + *

Constructor for JasperTemplateDesign.

+ * + * @param jasperDesign a {@link net.sf.jasperreports.engine.design.JasperDesign} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperTemplateDesign(JasperDesign jasperDesign) throws DRException { + init(jasperDesign); + } + + /** + *

Constructor for JasperTemplateDesign.

+ * + * @param file a {@link java.io.File} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperTemplateDesign(File file) throws DRException { + Validate.notNull(file, "file must not be null"); + try { + init(JRXmlLoader.load(file)); + } catch (JRException e) { + throw new DRException(e); + } + } + + /** + *

Constructor for JasperTemplateDesign.

+ * + * @param fileName a {@link java.lang.String} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperTemplateDesign(String fileName) throws DRException { + Validate.notNull(fileName, "fileName must not be null"); + try { + init(JRXmlLoader.load(fileName)); + } catch (JRException e) { + throw new DRException(e); + } + } + + /** + *

Constructor for JasperTemplateDesign.

+ * + * @param inputStream a {@link java.io.InputStream} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperTemplateDesign(InputStream inputStream) throws DRException { + Validate.notNull(inputStream, "inputStream must not be null"); + try { + init(JRXmlLoader.load(inputStream)); + } catch (JRException e) { + throw new DRException(e); + } + } + + /** + *

Constructor for JasperTemplateDesign.

+ * + * @param url a {@link java.net.URL} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperTemplateDesign(URL url) throws DRException { + Validate.notNull(url, "url must not be null"); + try { + init(JRXmlLoader.load(url.openStream())); + } catch (JRException e) { + throw new DRException(e); + } catch (IOException e) { + throw new DRException(e); + } + } + + private void init(JasperDesign jasperDesign) throws DRException { + Validate.notNull(jasperDesign, "jasperDesign must not be null"); + this.jasperDesign = jasperDesign; + + this.fields = new ArrayList>(); + for (JRField jrField : jasperDesign.getFields()) { + @SuppressWarnings( {"unchecked", "rawtypes"}) DRField field = new DRField(jrField.getName(), jrField.getValueClass()); + fields.add(field); + } + + this.margin = new DRMargin(); + margin.setTop(jasperDesign.getTopMargin()); + margin.setLeft(jasperDesign.getLeftMargin()); + margin.setBottom(jasperDesign.getBottomMargin()); + margin.setRight(jasperDesign.getRightMargin()); + } + + /** {@inheritDoc} */ + @Override + public String getReportName() { + return jasperDesign.getName(); + } + + /** {@inheritDoc} */ + @Override + public List> getFields() { + return fields; + } + + /** {@inheritDoc} */ + @Override + public boolean isDefinedParameter(String name) { + JRParameter parameter = jasperDesign.getParametersMap().get(name); + return parameter != null; + } + + /** {@inheritDoc} */ + @Override + public String getResourceBundleName() { + return jasperDesign.getResourceBundle(); + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnorePagination() { + return jasperDesign.isIgnorePagination(); + } + + /** {@inheritDoc} */ + @Override + public WhenNoDataType getWhenNoDataType() { + return ConstantTransform.whenNoDataType(jasperDesign.getWhenNoDataTypeValue()); + } + + /** {@inheritDoc} */ + @Override + public WhenResourceMissingType getWhenResourceMissingType() { + return ConstantTransform.whenResourceMissingType(jasperDesign.getWhenResourceMissingTypeValue()); + } + + /** {@inheritDoc} */ + @Override + public Boolean getTitleOnANewPage() { + return jasperDesign.isTitleNewPage(); + } + + /** {@inheritDoc} */ + @Override + public Boolean getSummaryOnANewPage() { + return jasperDesign.isSummaryNewPage(); + } + + /** {@inheritDoc} */ + @Override + public Boolean getSummaryWithPageHeaderAndFooter() { + return jasperDesign.isSummaryWithPageHeaderAndFooter(); + } + + /** {@inheritDoc} */ + @Override + public Boolean getFloatColumnFooter() { + return jasperDesign.isFloatColumnFooter(); + } + + /** {@inheritDoc} */ + @Override + public Integer getPageWidth() { + return jasperDesign.getPageWidth(); + } + + /** {@inheritDoc} */ + @Override + public Integer getPageHeight() { + return jasperDesign.getPageHeight(); + } + + /** {@inheritDoc} */ + @Override + public PageOrientation getPageOrientation() { + return ConstantTransform.pageOrientation(jasperDesign.getOrientationValue()); + } + + /** {@inheritDoc} */ + @Override + public DRIMargin getPageMargin() { + return margin; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageColumnsPerPage() { + return jasperDesign.getColumnCount(); + } + + /** {@inheritDoc} */ + @Override + public Integer getPageColumnSpace() { + return jasperDesign.getColumnSpacing(); + } + + /** {@inheritDoc} */ + @Override + public Integer getPageColumnWidth() { + return jasperDesign.getColumnWidth(); + } + + /** {@inheritDoc} */ + @Override + public int getTitleComponentsCount() { + return getBandComponentsCount(jasperDesign.getTitle()); + } + + /** {@inheritDoc} */ + @Override + public int getPageHeaderComponentsCount() { + return getBandComponentsCount(jasperDesign.getPageHeader()); + } + + /** {@inheritDoc} */ + @Override + public int getPageFooterComponentsCount() { + return getBandComponentsCount(jasperDesign.getPageFooter()); + } + + /** {@inheritDoc} */ + @Override + public int getColumnHeaderComponentsCount() { + return getBandComponentsCount(jasperDesign.getColumnHeader()); + } + + /** {@inheritDoc} */ + @Override + public int getColumnFooterComponentsCount() { + return getBandComponentsCount(jasperDesign.getColumnFooter()); + } + + /** {@inheritDoc} */ + @Override + public int getLastPageFooterComponentsCount() { + return getBandComponentsCount(jasperDesign.getLastPageFooter()); + } + + /** {@inheritDoc} */ + @Override + public int getSummaryComponentsCount() { + return getBandComponentsCount(jasperDesign.getSummary()); + } + + /** {@inheritDoc} */ + @Override + public int getNoDataComponentsCount() { + return getBandComponentsCount(jasperDesign.getNoData()); + } + + /** {@inheritDoc} */ + @Override + public int getBackgroundComponentsCount() { + return getBandComponentsCount(jasperDesign.getBackground()); + } + + private int getBandComponentsCount(JRBand band) { + if (band != null && band.getElements() != null) { + return band.getElements().length; + } + return 0; + } + + /** {@inheritDoc} */ + @Override + public JasperDesign getDesign() throws DRException { + try { + if (templateDesign == null) { + templateDesign = new ByteArrayOutputStream(); + JRXmlWriter.writeReport(jasperDesign, templateDesign, "UTF-8"); + } + + return JRXmlLoader.load(new ByteArrayInputStream(templateDesign.toByteArray())); + } catch (JRException e) { + throw new DRException(e); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/JasperConcatenatedReportBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/JasperConcatenatedReportBuilder.java new file mode 100644 index 0000000..ddc5632 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/JasperConcatenatedReportBuilder.java @@ -0,0 +1,462 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.awt.image.RenderedImage; +import java.io.IOException; +import java.io.OutputStream; +import java.io.Serializable; + +import javax.imageio.ImageIO; + +import org.apache.commons.lang3.Validate; + +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.export.JRGraphics2DExporter; +import net.sf.jasperreports.export.Exporter; +import net.sf.jasperreports.export.ExporterInput; +import net.sf.jasperreports.export.SimpleExporterInput; +import net.sf.jasperreports.export.SimpleGraphics2DExporterConfiguration; +import net.sf.jasperreports.export.SimpleGraphics2DExporterOutput; +import net.sf.jasperreports.export.SimpleGraphics2DReportConfiguration; +import software.xdev.dynamicreports.jasper.base.export.AbstractJasperExporter; +import software.xdev.dynamicreports.jasper.base.reporthandler.JasperReportBuilderHandler; +import software.xdev.dynamicreports.jasper.builder.export.AbstractJasperExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.Exporters; +import software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder; +import software.xdev.dynamicreports.jasper.definition.JasperReportHandler; +import software.xdev.dynamicreports.jasper.transformation.ExporterTransform; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + * This report builder allows concatenating several separated reports into one single document. Each report starts on a new page with its own page dimension. + * + * @author Ricardo Mariaca + * + */ +public class JasperConcatenatedReportBuilder implements Serializable { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private final JasperReportHandler jasperReportHandler; + + /** + *

Constructor for JasperConcatenatedReportBuilder.

+ */ + public JasperConcatenatedReportBuilder() { + this(new JasperReportBuilderHandler()); + } + + /** + *

Constructor for JasperConcatenatedReportBuilder.

+ * + * @param jasperReportHandler a {@link software.xdev.dynamicreports.jasper.definition.JasperReportHandler} object. + */ + public JasperConcatenatedReportBuilder(final JasperReportHandler jasperReportHandler) { + this.jasperReportHandler = jasperReportHandler; + } + + /** + *

concatenate.

+ * + * @param jasperReportBuilders a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + */ + public JasperConcatenatedReportBuilder concatenate(final JasperReportBuilder... jasperReportBuilders) { + Validate.notNull(jasperReportBuilders, "jasperReportBuilders must not be null"); + Validate.noNullElements(jasperReportBuilders, "jasperReportBuilders must not contains null jasperReportBuilder"); + this.jasperReportHandler.concatenate(jasperReportBuilders); + return this; + } + + /** + *

toPng.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toPng(final OutputStream outputStream) throws DRException { + return this.toPng(outputStream, 1); + } + + /** + *

toPng.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @param zoom a float. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + @SuppressWarnings("java:S2184") // FP: int - int != float? + public JasperConcatenatedReportBuilder toPng(final OutputStream outputStream, final float zoom) throws DRException { + Validate.notNull(outputStream, "outputStream must not be null"); + Validate.isTrue(zoom > 0, "zoom must be > 0"); + + int maxWidth = 0; + int maxHeight = 0; + + for (final JasperPrint jasperPrint : this.jasperReportHandler.getPrintList()) { + final int pages = jasperPrint.getPages().size(); + final int pageWidth = (int) (jasperPrint.getPageWidth() * zoom); + maxWidth += pageWidth * pages + pages - 1 + 2; + final int height = (int) (jasperPrint.getPageHeight() * zoom) + 2; + if (height > maxHeight) { + maxHeight = height; + } + } + + final Image image = new BufferedImage(maxWidth, maxHeight, BufferedImage.TYPE_INT_RGB); + final Graphics2D g2d = (Graphics2D) image.getGraphics(); + g2d.setColor(Color.LIGHT_GRAY); + g2d.fill(new Rectangle2D.Float(1, 1, maxWidth - 1, maxHeight - 1)); + + int offset = 1; + for (final JasperPrint jasperPrint : this.jasperReportHandler.getPrintList()) { + final int pageWidth = (int) (jasperPrint.getPageWidth() * zoom); + final int pageHeight = (int) (jasperPrint.getPageHeight() * zoom); + for ( + int i = 0; i < jasperPrint.getPages().size(); i++) { + try { + final SimpleExporterInput exporterInput = new SimpleExporterInput(jasperPrint); + final SimpleGraphics2DExporterOutput exporterOutput = new SimpleGraphics2DExporterOutput(); + final Image pageImage = new BufferedImage(pageWidth, pageHeight, BufferedImage.TYPE_INT_RGB); + exporterOutput.setGraphics2D((Graphics2D) pageImage.getGraphics()); + final SimpleGraphics2DReportConfiguration reportExportConfiguration = new SimpleGraphics2DReportConfiguration(); + reportExportConfiguration.setPageIndex(i); + reportExportConfiguration.setZoomRatio(zoom); + final SimpleGraphics2DExporterConfiguration exporterConfiguration = new SimpleGraphics2DExporterConfiguration(); + + final JRGraphics2DExporter jrExporter = new JRGraphics2DExporter(); + jrExporter.setExporterInput(exporterInput); + jrExporter.setExporterOutput(exporterOutput); + jrExporter.setConfiguration(reportExportConfiguration); + jrExporter.setConfiguration(exporterConfiguration); + + jrExporter.exportReport(); + ((Graphics2D) image.getGraphics()).drawImage(pageImage, offset, 1, null); + offset += pageWidth + 1; + } catch (final JRException e) { + throw new DRException(e); + } + } + } + try { + ImageIO.write((RenderedImage) image, "png", outputStream); + } catch (final IOException e) { + throw new DRException(e); + } + return this; + } + + /** + *

continuousPageNumbering.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + */ + public JasperConcatenatedReportBuilder continuousPageNumbering() { + return this.setContinuousPageNumbering(true); + } + + /** + *

setContinuousPageNumbering.

+ * + * @param continuousPageNumbering a boolean. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + */ + public JasperConcatenatedReportBuilder setContinuousPageNumbering(final boolean continuousPageNumbering) { + this.jasperReportHandler.setContinuousPageNumbering(continuousPageNumbering); + return this; + } + + // csv + + /** + *

toCsv.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toCsv(final OutputStream outputStream) throws DRException { + return this.toCsv(Exporters.csvExporter(outputStream)); + } + + /** + *

toCsv.

+ * + * @param csvExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toCsv(final JasperCsvExporterBuilder csvExporterBuilder) throws DRException { + return this.export(csvExporterBuilder); + } + + // docx + + /** + *

toDocx.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toDocx(final OutputStream outputStream) throws DRException { + return this.toDocx(Exporters.docxExporter(outputStream)); + } + + /** + *

toDocx.

+ * + * @param docxExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toDocx(final JasperDocxExporterBuilder docxExporterBuilder) throws DRException { + return this.export(docxExporterBuilder); + } + + // html + + /** + *

toHtml.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toHtml(final OutputStream outputStream) throws DRException { + return this.toHtml(Exporters.htmlExporter(outputStream)); + } + + /** + *

toHtml.

+ * + * @param htmlExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toHtml(final JasperHtmlExporterBuilder htmlExporterBuilder) throws DRException { + return this.export(htmlExporterBuilder); + } + + // ods + + /** + *

toOds.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toOds(final OutputStream outputStream) throws DRException { + return this.toOds(Exporters.odsExporter(outputStream)); + } + + /** + *

toOds.

+ * + * @param odsExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toOds(final JasperOdsExporterBuilder odsExporterBuilder) throws DRException { + return this.export(odsExporterBuilder); + } + + // odt + + /** + *

toOdt.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toOdt(final OutputStream outputStream) throws DRException { + return this.toOdt(Exporters.odtExporter(outputStream)); + } + + /** + *

toOdt.

+ * + * @param odtExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toOdt(final JasperOdtExporterBuilder odtExporterBuilder) throws DRException { + return this.export(odtExporterBuilder); + } + + // pdf + + /** + *

toPdf.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toPdf(final OutputStream outputStream) throws DRException { + return this.toPdf(Exporters.pdfExporter(outputStream)); + } + + /** + *

toPdf.

+ * + * @param pdfExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toPdf(final JasperPdfExporterBuilder pdfExporterBuilder) throws DRException { + return this.export(pdfExporterBuilder); + } + + // rtf + + /** + *

toRtf.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toRtf(final OutputStream outputStream) throws DRException { + return this.toRtf(Exporters.rtfExporter(outputStream)); + } + + /** + *

toRtf.

+ * + * @param rtfExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toRtf(final JasperRtfExporterBuilder rtfExporterBuilder) throws DRException { + return this.export(rtfExporterBuilder); + } + + // text + + /** + *

toText.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toText(final OutputStream outputStream) throws DRException { + return this.toText(Exporters.textExporter(outputStream)); + } + + /** + *

toText.

+ * + * @param textExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toText(final JasperTextExporterBuilder textExporterBuilder) throws DRException { + return this.export(textExporterBuilder); + } + + // xlsx + + /** + *

toXlsx.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toXlsx(final OutputStream outputStream) throws DRException { + return this.toXlsx(Exporters.xlsxExporter(outputStream)); + } + + /** + *

toXlsx.

+ * + * @param xlsxExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toXlsx(final JasperXlsxExporterBuilder xlsxExporterBuilder) throws DRException { + return this.export(xlsxExporterBuilder); + } + + // pptx + + /** + *

toPptx.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toPptx(final OutputStream outputStream) throws DRException { + return this.toPptx(Exporters.pptxExporter(outputStream)); + } + + /** + *

toPptx.

+ * + * @param pptxExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder toPptx(final JasperPptxExporterBuilder pptxExporterBuilder) throws DRException { + return this.export(pptxExporterBuilder); + } + + /** + *

export.

+ * + * @param exporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.AbstractJasperExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperConcatenatedReportBuilder export(final AbstractJasperExporterBuilder exporterBuilder) throws DRException { + Validate.notNull(exporterBuilder, "exporterBuilder must not be null"); + try { + final ExporterTransform exporterTransform = new ExporterTransform(exporterBuilder.build()); + @SuppressWarnings("unchecked") + final Exporter exporter = (Exporter) exporterTransform.transform(); + exporter.setExporterInput(SimpleExporterInput.getInstance(this.jasperReportHandler.getPrintList())); + exporter.exportReport(); + } catch (final JRException e) { + throw new DRException(e); + } + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/JasperReportBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/JasperReportBuilder.java new file mode 100644 index 0000000..c9f24c8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/JasperReportBuilder.java @@ -0,0 +1,759 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder; + +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.sql.Connection; +import java.sql.ResultSet; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.lang3.Validate; + +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRParameter; +import net.sf.jasperreports.engine.JRResultSetDataSource; +import net.sf.jasperreports.engine.JRRewindableDataSource; +import net.sf.jasperreports.engine.JRVirtualizer; +import net.sf.jasperreports.engine.JasperCompileManager; +import net.sf.jasperreports.engine.JasperFillManager; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.JasperPrintManager; +import net.sf.jasperreports.engine.JasperReport; +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; +import net.sf.jasperreports.engine.design.JasperDesign; +import net.sf.jasperreports.engine.xml.JRXmlWriter; +import net.sf.jasperreports.export.Exporter; +import net.sf.jasperreports.export.ExporterInput; +import net.sf.jasperreports.export.SimpleExporterInput; +import net.sf.jasperreports.view.JasperDesignViewer; +import net.sf.jasperreports.view.JasperViewer; +import software.xdev.dynamicreports.design.base.DRDesignReport; +import software.xdev.dynamicreports.design.definition.DRIDesignReport; +import software.xdev.dynamicreports.jasper.base.JasperReportDesign; +import software.xdev.dynamicreports.jasper.base.export.AbstractJasperExporter; +import software.xdev.dynamicreports.jasper.base.tableofcontents.JasperTocReport; +import software.xdev.dynamicreports.jasper.base.templatedesign.JasperEmptyTemplateDesign; +import software.xdev.dynamicreports.jasper.base.templatedesign.JasperTemplateDesign; +import software.xdev.dynamicreports.jasper.builder.export.AbstractJasperExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.Exporters; +import software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder; +import software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder; +import software.xdev.dynamicreports.jasper.transformation.ExporterTransform; +import software.xdev.dynamicreports.jasper.transformation.JasperTransform; +import software.xdev.dynamicreports.report.builder.DynamicReports; +import software.xdev.dynamicreports.report.builder.QueryBuilder; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.QueryLanguage; +import software.xdev.dynamicreports.report.definition.DRITemplateDesign; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + * The most used report builder for creating reports. It allows constructing and customizing the whole report content. A report consists of bands, columns, subtotals, groups, and other parts. Each + * part is created and configured using a particular builder method and it's passed to the report builder instance. + * + * @author Ricardo Mariaca + * + */ +public class JasperReportBuilder extends ReportBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private JasperReportDesign reportDesign; + private JasperDesign jasperDesign; + private JasperReport jasperReport; + private JasperPrint jasperPrint; + private transient JRDataSource dataSource; + private transient Connection connection; + private transient JRVirtualizer virtualizer; + private Integer startPageNumber; + private Map parameters; + + /** + *

Constructor for JasperReportBuilder.

+ */ + public JasperReportBuilder() { + this.setTemplateDesign(new JasperEmptyTemplateDesign()); + } + + /** + *

Setter for the field startPageNumber.

+ * + * @param startPageNumber a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder setStartPageNumber(final Integer startPageNumber) throws DRException { + if (this.startPageNumber == startPageNumber) { + return this; + } + this.startPageNumber = startPageNumber; + this.rebuild(); + return this; + } + + /** + * Sets a data source object. Creates a new JRBeanCollectionDataSource data source object. + * + * @param collection - the collection values + * @return a report builder + */ + public JasperReportBuilder setDataSource(final Collection collection) { + return this.setDataSource(new JRBeanCollectionDataSource(collection)); + } + + /** + * Sets a database data source. In this type of data source, data are retrieved from a database. + * + * @param resultSet - the resultSet object + * @return a report builder + */ + public JasperReportBuilder setDataSource(final ResultSet resultSet) { + return this.setDataSource(new JRResultSetDataSource(resultSet)); + } + + /** + * Sets a database data source. In this type of data source, data are retrieved from a database. + * + * @param sql - the sql query + * @param connection - the database connection + * @return a report builder + */ + public JasperReportBuilder setDataSource(final String sql, final Connection connection) { + Validate.notNull(sql, "sql must not be null"); + return this.setDataSource(DynamicReports.query(sql, QueryLanguage.SQL), connection); + } + + /** + * Sets a database data source. In this type of data source, data are retrieved from a database. + * + * @param query - the query definition + * @param connection - the database connection + * @return a report builder + */ + public JasperReportBuilder setDataSource(final QueryBuilder query, final Connection connection) { + Validate.notNull(query, "query must not be null"); + Validate.notNull(connection, "connection must not be null"); + this.getObject().setQuery(query.build()); + this.connection = connection; + this.dataSource = null; + return this; + } + + /** + *

setTemplateDesign.

+ * + * @param inputStream a {@link java.io.InputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder setTemplateDesign(final InputStream inputStream) throws DRException { + return this.setTemplateDesign(new JasperTemplateDesign(inputStream)); + } + + /** + *

setTemplateDesign.

+ * + * @param file a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder setTemplateDesign(final File file) throws DRException { + return this.setTemplateDesign(new JasperTemplateDesign(file)); + } + + // template design + + /** + *

setTemplateDesign.

+ * + * @param fileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder setTemplateDesign(final String fileName) throws DRException { + return this.setTemplateDesign(new JasperTemplateDesign(fileName)); + } + + /** + *

setTemplateDesign.

+ * + * @param jasperDesign a {@link net.sf.jasperreports.engine.design.JasperDesign} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder setTemplateDesign(final JasperDesign jasperDesign) throws DRException { + return this.setTemplateDesign(new JasperTemplateDesign(jasperDesign)); + } + + /** + *

setTemplateDesign.

+ * + * @param jasperDesignUrl a {@link java.net.URL} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder setTemplateDesign(final URL jasperDesignUrl) throws DRException { + return this.setTemplateDesign(new JasperTemplateDesign(jasperDesignUrl)); + } + + private JasperReportBuilder setTemplateDesign(final DRITemplateDesign templateDesign) { + this.getObject().setTemplateDesign(templateDesign); + return this; + } + + /** {@inheritDoc} */ + @Override + public JasperReportBuilder setParameter(final String name, final Object value) { + super.setParameter(name, value); + this.parameters = null; + this.jasperPrint = null; + return this; + } + + /** {@inheritDoc} */ + @Override + public JasperReportBuilder setParameters(final Map parameters) { + super.setParameters(parameters); + this.parameters = null; + this.jasperPrint = null; + return this; + } + + /** + *

rebuild.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder rebuild() throws DRException { + this.builded = false; + this.reportDesign = null; + this.jasperDesign = null; + this.jasperReport = null; + this.parameters = null; + this.jasperPrint = null; + if (this.dataSource != null && this.dataSource instanceof JRRewindableDataSource) { + try { + ((JRRewindableDataSource)this.dataSource).moveFirst(); + } catch (final JRException e) { + throw new DRException(e); + } + } + return this; + } + + private JasperReportDesign toJasperReportDesign() throws DRException { + if (this.reportDesign == null) { + final DRIDesignReport report = new DRDesignReport(this.build()); + this.reportDesign = new JasperReportDesign(report, this.startPageNumber); + final JasperTransform jasperTransform = new JasperTransform(report, this.reportDesign); + jasperTransform.transform(); + } + return this.reportDesign; + } + + /** + *

toJasperDesign.

+ * + * @return a {@link net.sf.jasperreports.engine.design.JasperDesign} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperDesign toJasperDesign() throws DRException { + if (this.jasperDesign == null) { + this.jasperDesign = this.toJasperReportDesign().getDesign(); + } + return this.jasperDesign; + } + + /** + *

toJasperReport.

+ * + * @return a {@link net.sf.jasperreports.engine.JasperReport} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReport toJasperReport() throws DRException { + if (this.jasperReport == null) { + try { + this.jasperReport = JasperCompileManager.compileReport(this.toJasperDesign()); + } catch (final JRException e) { + throw new DRException(e); + } + } + return this.jasperReport; + } + + /** + *

getJasperParameters.

+ * + * @return a {@link java.util.Map} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public Map getJasperParameters() throws DRException { + if (this.parameters == null) { + this.parameters = new HashMap<>(); + final JasperReportDesign jasperReportDesign = this.toJasperReportDesign(); + this.parameters.putAll(jasperReportDesign.getParameters()); + if (this.getReport().getParameterValues() != null) { + this.parameters.putAll(this.getReport().getParameterValues()); + } + } + return this.parameters; + } + + /** + *

toJasperPrint.

+ * + * @return a {@link net.sf.jasperreports.engine.JasperPrint} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperPrint toJasperPrint() throws DRException { + if (this.jasperPrint == null) { + final Map parameters = this.getJasperParameters(); + if (this.virtualizer != null) { + parameters.put(JRParameter.REPORT_VIRTUALIZER, this.virtualizer); + } + + try { + if (this.connection != null && this.toJasperReport().getQuery() != null) { + this.jasperPrint = JasperFillManager.fillReport(this.toJasperReport(), parameters, this.connection); + } else if (this.dataSource != null) { + this.jasperPrint = JasperFillManager.fillReport(this.toJasperReport(), parameters, this.dataSource); + } else { + this.jasperPrint = JasperFillManager.fillReport(this.toJasperReport(), parameters); + } + + if (this.toJasperReportDesign().isTableOfContents()) { + JasperTocReport.createTocReport(this.toJasperReportDesign(), this.jasperPrint, parameters); + } + } catch (final JRException e) { + throw new DRException(e); + } + + } + return this.jasperPrint; + } + + /** + *

show.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder show() throws DRException { + JasperViewer.viewReport(this.toJasperPrint()); + return this; + } + + /** + *

show.

+ * + * @param exitOnClose a boolean. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder show(final boolean exitOnClose) throws DRException { + JasperViewer.viewReport(this.toJasperPrint(), exitOnClose, null); + return this; + } + + /** + *

showJrXml.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder showJrXml() throws DRException { + try { + JasperDesignViewer.viewReportDesign(this.toJasperDesign()); + } catch (final JRException e) { + throw new DRException(e); + } + return this; + } + + /** + *

toJrXml.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toJrXml(final OutputStream outputStream) throws DRException { + Validate.notNull(outputStream, "outputStream must not be null"); + try { + JRXmlWriter.writeReport(this.toJasperDesign(), outputStream, "UTF-8"); + } catch (final JRException e) { + throw new DRException(e); + } + return this; + } + + /** + *

print.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder print() throws DRException { + return this.print(true); + } + + /** + *

print.

+ * + * @param withPrintDialog a boolean. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder print(final boolean withPrintDialog) throws DRException { + try { + JasperPrintManager.printReport(this.toJasperPrint(), withPrintDialog); + } catch (final JRException e) { + throw new DRException(e); + } + return this; + } + + /** + *

Setter for the field virtualizer.

+ * + * @param virtualizer a {@link net.sf.jasperreports.engine.JRVirtualizer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + */ + public JasperReportBuilder setVirtualizer(final JRVirtualizer virtualizer) { + this.virtualizer = virtualizer; + return this; + } + + /** + *

toCsv.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toCsv(final OutputStream outputStream) throws DRException { + return this.toCsv(Exporters.csvExporter(outputStream)); + } + + /** + *

toCsv.

+ * + * @param csvExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toCsv(final JasperCsvExporterBuilder csvExporterBuilder) throws DRException { + return this.export(csvExporterBuilder); + } + + // csv + + /** + *

toDocx.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toDocx(final OutputStream outputStream) throws DRException { + return this.toDocx(Exporters.docxExporter(outputStream)); + } + + /** + *

toDocx.

+ * + * @param docxExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toDocx(final JasperDocxExporterBuilder docxExporterBuilder) throws DRException { + return this.export(docxExporterBuilder); + } + + // docx + + /** + *

toHtml.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toHtml(final OutputStream outputStream) throws DRException { + return this.toHtml(Exporters.htmlExporter(outputStream)); + } + + /** + *

toHtml.

+ * + * @param htmlExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toHtml(final JasperHtmlExporterBuilder htmlExporterBuilder) throws DRException { + return this.export(htmlExporterBuilder); + } + + // html + + /** + *

toOds.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toOds(final OutputStream outputStream) throws DRException { + return this.toOds(Exporters.odsExporter(outputStream)); + } + + /** + *

toOds.

+ * + * @param odsExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toOds(final JasperOdsExporterBuilder odsExporterBuilder) throws DRException { + return this.export(odsExporterBuilder); + } + + // ods + + /** + *

toOdt.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toOdt(final OutputStream outputStream) throws DRException { + return this.toOdt(Exporters.odtExporter(outputStream)); + } + + /** + *

toOdt.

+ * + * @param odtExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toOdt(final JasperOdtExporterBuilder odtExporterBuilder) throws DRException { + return this.export(odtExporterBuilder); + } + + // odt + + /** + *

toPdf.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toPdf(final OutputStream outputStream) throws DRException { + return this.toPdf(Exporters.pdfExporter(outputStream)); + } + + /** + *

toPdf.

+ * + * @param pdfExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toPdf(final JasperPdfExporterBuilder pdfExporterBuilder) throws DRException { + return this.export(pdfExporterBuilder); + } + + // pdf + + /** + *

toRtf.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toRtf(final OutputStream outputStream) throws DRException { + return this.toRtf(Exporters.rtfExporter(outputStream)); + } + + /** + *

toRtf.

+ * + * @param rtfExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toRtf(final JasperRtfExporterBuilder rtfExporterBuilder) throws DRException { + return this.export(rtfExporterBuilder); + } + + // rtf + + /** + *

toText.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toText(final OutputStream outputStream) throws DRException { + return this.toText(Exporters.textExporter(outputStream)); + } + + /** + *

toText.

+ * + * @param textExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toText(final JasperTextExporterBuilder textExporterBuilder) throws DRException { + return this.export(textExporterBuilder); + } + + // text + + /** + *

toXlsx.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toXlsx(final OutputStream outputStream) throws DRException { + return this.toXlsx(Exporters.xlsxExporter(outputStream)); + } + + /** + *

toXlsx.

+ * + * @param xlsxExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toXlsx(final JasperXlsxExporterBuilder xlsxExporterBuilder) throws DRException { + return this.export(xlsxExporterBuilder); + } + + // xlsx + + /** + *

toPptx.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toPptx(final OutputStream outputStream) throws DRException { + return this.toPptx(Exporters.pptxExporter(outputStream)); + } + + /** + *

toPptx.

+ * + * @param pptxExporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder toPptx(final JasperPptxExporterBuilder pptxExporterBuilder) throws DRException { + return this.export(pptxExporterBuilder); + } + + // pptx + + /** + *

export.

+ * + * @param exporterBuilder a {@link software.xdev.dynamicreports.jasper.builder.export.AbstractJasperExporterBuilder} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperReportBuilder export(final AbstractJasperExporterBuilder exporterBuilder) throws DRException { + Validate.notNull(exporterBuilder, "exporterBuilder must not be null"); + try { + final ExporterTransform exporterTransform = new ExporterTransform(exporterBuilder.build()); + @SuppressWarnings("unchecked") + final Exporter exporter = (Exporter) exporterTransform.transform(); + exporter.setExporterInput(new SimpleExporterInput(this.toJasperPrint())); + exporter.exportReport(); + } catch (final JRException e) { + throw new DRException(e); + } + return this; + } + + /** + *

Getter for the field connection.

+ * + * @return a {@link java.sql.Connection} object. + */ + public Connection getConnection() { + return this.connection; + } + + /** + *

Setter for the field connection.

+ * + * @param connection a {@link java.sql.Connection} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + */ + public JasperReportBuilder setConnection(final Connection connection) { + Validate.notNull(connection, "connection must not be null"); + this.connection = connection; + return this; + } + + /** + *

Getter for the field dataSource.

+ * + * @return a {@link net.sf.jasperreports.engine.JRDataSource} object. + */ + public JRDataSource getDataSource() { + return this.dataSource; + } + + /** + * Sets a data source object. + * + * @param dataSource - the JRDataSource object + * @return a report builder + */ + public JasperReportBuilder setDataSource(final JRDataSource dataSource) { + this.dataSource = dataSource; + this.connection = null; + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/AbstractJasperExcelExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/AbstractJasperExcelExporterBuilder.java new file mode 100644 index 0000000..e5d861f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/AbstractJasperExcelExporterBuilder.java @@ -0,0 +1,489 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.AbstractJasperExcelExporter; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.ImageAnchorType; +import software.xdev.dynamicreports.report.constant.RunDirection; +import org.apache.commons.lang3.Validate; + +import java.util.Map; + +/** + *

Abstract AbstractJasperExcelExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings("unchecked") +public abstract class AbstractJasperExcelExporterBuilder, U extends AbstractJasperExcelExporter> extends AbstractJasperExporterBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for AbstractJasperExcelExporterBuilder.

+ * + * @param exporter a U object. + */ + protected AbstractJasperExcelExporterBuilder(U exporter) { + super(exporter); + } + + /** + *

setOnePagePerSheet.

+ * + * @param onePagePerSheet a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setOnePagePerSheet(Boolean onePagePerSheet) { + this.getObject().setOnePagePerSheet(onePagePerSheet); + return (T) this; + } + + /** + *

setRemoveEmptySpaceBetweenRows.

+ * + * @param removeEmptySpaceBetweenRows a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setRemoveEmptySpaceBetweenRows(Boolean removeEmptySpaceBetweenRows) { + this.getObject().setRemoveEmptySpaceBetweenRows(removeEmptySpaceBetweenRows); + return (T) this; + } + + /** + *

setRemoveEmptySpaceBetweenColumns.

+ * + * @param removeEmptySpaceBetweenColumns a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setRemoveEmptySpaceBetweenColumns(Boolean removeEmptySpaceBetweenColumns) { + this.getObject().setRemoveEmptySpaceBetweenColumns(removeEmptySpaceBetweenColumns); + return (T) this; + } + + /** + *

setWhitePageBackground.

+ * + * @param whitePageBackground a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setWhitePageBackground(Boolean whitePageBackground) { + this.getObject().setWhitePageBackground(whitePageBackground); + return (T) this; + } + + /** + *

setDetectCellType.

+ * + * @param detectCellType a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setDetectCellType(Boolean detectCellType) { + this.getObject().setDetectCellType(detectCellType); + return (T) this; + } + + /** + *

sheetNames.

+ * + * @param sheetNames a {@link java.lang.String} object. + * @return a T object. + */ + public T sheetNames(String... sheetNames) { + return addSheetName(sheetNames); + } + + /** + *

addSheetName.

+ * + * @param sheetNames a {@link java.lang.String} object. + * @return a T object. + */ + public T addSheetName(String... sheetNames) { + Validate.notNull(sheetNames, "sheetNames must not be null"); + Validate.noNullElements(sheetNames, "sheetNames must not contains null sheetName"); + for (String sheetName : sheetNames) { + this.getObject().addSheetName(sheetName); + } + return (T) this; + } + + /** + *

setFontSizeFixEnabled.

+ * + * @param fontSizeFixEnabled a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setFontSizeFixEnabled(Boolean fontSizeFixEnabled) { + this.getObject().setFontSizeFixEnabled(fontSizeFixEnabled); + return (T) this; + } + + /** + *

setImageBorderFixEnabled.

+ * + * @param imageBorderFixEnabled a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setImageBorderFixEnabled(Boolean imageBorderFixEnabled) { + this.getObject().setImageBorderFixEnabled(imageBorderFixEnabled); + return (T) this; + } + + /** + *

setMaxRowsPerSheet.

+ * + * @param maxRowsPerSheet a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setMaxRowsPerSheet(Integer maxRowsPerSheet) { + this.getObject().setMaxRowsPerSheet(maxRowsPerSheet); + return (T) this; + } + + /** + *

setIgnoreGraphics.

+ * + * @param ignoreGraphics a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setIgnoreGraphics(Boolean ignoreGraphics) { + this.getObject().setIgnoreGraphics(ignoreGraphics); + return (T) this; + } + + /** + *

setCollapseRowSpan.

+ * + * @param collapseRowSpan a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setCollapseRowSpan(Boolean collapseRowSpan) { + this.getObject().setCollapseRowSpan(collapseRowSpan); + return (T) this; + } + + /** + *

setIgnoreCellBorder.

+ * + * @param ignoreCellBorder a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setIgnoreCellBorder(Boolean ignoreCellBorder) { + this.getObject().setIgnoreCellBorder(ignoreCellBorder); + return (T) this; + } + + /** + *

setIgnoreCellBackground.

+ * + * @param ignoreCellBackground a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setIgnoreCellBackground(Boolean ignoreCellBackground) { + this.getObject().setIgnoreCellBackground(ignoreCellBackground); + return (T) this; + } + + /** + *

setPassword.

+ * + * @param password a {@link java.lang.String} object. + * @return a T object. + */ + public T setPassword(String password) { + this.getObject().setPassword(password); + return (T) this; + } + + /** + *

setIgnorePageMargins.

+ * + * @param ignorePageMargins a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setIgnorePageMargins(Boolean ignorePageMargins) { + this.getObject().setIgnorePageMargins(ignorePageMargins); + return (T) this; + } + + /** + *

setWrapText.

+ * + * @param wrapText a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setWrapText(Boolean wrapText) { + this.getObject().setWrapText(wrapText); + return (T) this; + } + + /** + *

setCellLocked.

+ * + * @param cellLocked a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setCellLocked(Boolean cellLocked) { + this.getObject().setCellLocked(cellLocked); + return (T) this; + } + + /** + *

setCellHidden.

+ * + * @param cellHidden a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setCellHidden(Boolean cellHidden) { + this.getObject().setCellHidden(cellHidden); + return (T) this; + } + + /** + *

setSheetHeaderLeft.

+ * + * @param sheetHeaderLeft a {@link java.lang.String} object. + * @return a T object. + */ + public T setSheetHeaderLeft(String sheetHeaderLeft) { + this.getObject().setSheetHeaderLeft(sheetHeaderLeft); + return (T) this; + } + + /** + *

setSheetHeaderCenter.

+ * + * @param sheetHeaderCenter a {@link java.lang.String} object. + * @return a T object. + */ + public T setSheetHeaderCenter(String sheetHeaderCenter) { + this.getObject().setSheetHeaderCenter(sheetHeaderCenter); + return (T) this; + } + + /** + *

setSheetHeaderRight.

+ * + * @param sheetHeaderRight a {@link java.lang.String} object. + * @return a T object. + */ + public T setSheetHeaderRight(String sheetHeaderRight) { + this.getObject().setSheetHeaderRight(sheetHeaderRight); + return (T) this; + } + + /** + *

setSheetFooterLeft.

+ * + * @param sheetFooterLeft a {@link java.lang.String} object. + * @return a T object. + */ + public T setSheetFooterLeft(String sheetFooterLeft) { + this.getObject().setSheetFooterLeft(sheetFooterLeft); + return (T) this; + } + + /** + *

setSheetFooterCenter.

+ * + * @param sheetFooterCenter a {@link java.lang.String} object. + * @return a T object. + */ + public T setSheetFooterCenter(String sheetFooterCenter) { + this.getObject().setSheetFooterCenter(sheetFooterCenter); + return (T) this; + } + + /** + *

setSheetFooterRight.

+ * + * @param sheetFooterRight a {@link java.lang.String} object. + * @return a T object. + */ + public T setSheetFooterRight(String sheetFooterRight) { + this.getObject().setSheetFooterRight(sheetFooterRight); + return (T) this; + } + + /** + *

setFormatPatternsMap.

+ * + * @param formatPatternsMap a {@link java.util.Map} object. + * @return a T object. + */ + public T setFormatPatternsMap(Map formatPatternsMap) { + this.getObject().setFormatPatternsMap(formatPatternsMap); + return (T) this; + } + + /** + *

setIgnoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.getObject().setIgnoreHyperLink(ignoreHyperLink); + return (T) this; + } + + /** + *

setIgnoreAnchors.

+ * + * @param ignoreAnchors a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setIgnoreAnchors(Boolean ignoreAnchors) { + this.getObject().setIgnoreAnchors(ignoreAnchors); + return (T) this; + } + + /** + *

setFitWidth.

+ * + * @param fitWidth a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setFitWidth(Integer fitWidth) { + this.getObject().setFitWidth(fitWidth); + return (T) this; + } + + /** + *

setFitHeight.

+ * + * @param fitHeight a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setFitHeight(Integer fitHeight) { + this.getObject().setFitHeight(fitHeight); + return (T) this; + } + + /** + *

setPageScale.

+ * + * @param pageScale a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setPageScale(Integer pageScale) { + this.getObject().setPageScale(pageScale); + return (T) this; + } + + /** + *

setSheetDirection.

+ * + * @param sheetDirection a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + * @return a T object. + */ + public T setSheetDirection(RunDirection sheetDirection) { + this.getObject().setSheetDirection(sheetDirection); + return (T) this; + } + + /** + *

setColumnWidthRatio.

+ * + * @param columnWidthRatio a {@link java.lang.Float} object. + * @return a T object. + */ + public T setColumnWidthRatio(Float columnWidthRatio) { + this.getObject().setColumnWidthRatio(columnWidthRatio); + return (T) this; + } + + /** + *

setUseTimeZone.

+ * + * @param useTimeZone a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setUseTimeZone(Boolean useTimeZone) { + this.getObject().setUseTimeZone(useTimeZone); + return (T) this; + } + + /** + *

setFirstPageNumber.

+ * + * @param firstPageNumber a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setFirstPageNumber(Integer firstPageNumber) { + this.getObject().setFirstPageNumber(firstPageNumber); + return (T) this; + } + + /** + *

setShowGridLines.

+ * + * @param showGridLines a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setShowGridLines(Boolean showGridLines) { + this.getObject().setShowGridLines(showGridLines); + return (T) this; + } + + /** + *

setImageAnchorType.

+ * + * @param imageAnchorType a {@link software.xdev.dynamicreports.report.constant.ImageAnchorType} object. + * @return a T object. + */ + public T setImageAnchorType(ImageAnchorType imageAnchorType) { + this.getObject().setImageAnchorType(imageAnchorType); + return (T) this; + } + + /** + *

setCreateCustomPalette.

+ * + * @param createCustomPalette a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setCreateCustomPalette(Boolean createCustomPalette) { + this.getObject().setCreateCustomPalette(createCustomPalette); + return (T) this; + } + + /** + *

setWorkbookTemplate.

+ * + * @param workbookTemplate a {@link java.lang.String} object. + * @return a T object. + */ + public T setWorkbookTemplate(String workbookTemplate) { + this.getObject().setWorkbookTemplate(workbookTemplate); + return (T) this; + } + + /** + *

setKeepWorkbookTemplateSheets.

+ * + * @param keepWorkbookTemplateSheets a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setKeepWorkbookTemplateSheets(Boolean keepWorkbookTemplateSheets) { + this.getObject().setKeepWorkbookTemplateSheets(keepWorkbookTemplateSheets); + return (T) this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/AbstractJasperExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/AbstractJasperExporterBuilder.java new file mode 100644 index 0000000..5b9e1cd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/AbstractJasperExporterBuilder.java @@ -0,0 +1,165 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.AbstractJasperExporter; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; + +import java.io.File; +import java.io.OutputStream; +import java.io.Writer; + +/** + *

Abstract AbstractJasperExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings("unchecked") +public abstract class AbstractJasperExporterBuilder, U extends AbstractJasperExporter> extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for AbstractJasperExporterBuilder.

+ * + * @param jasperExporter a U object. + */ + protected AbstractJasperExporterBuilder(U jasperExporter) { + super(jasperExporter); + } + + /** + *

setOutputWriter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a T object. + */ + protected T setOutputWriter(Writer outputWriter) { + getObject().setOutputWriter(outputWriter); + return (T) this; + } + + /** + *

setOutputStream.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a T object. + */ + protected T setOutputStream(OutputStream outputStream) { + getObject().setOutputStream(outputStream); + return (T) this; + } + + /** + *

setOutputFile.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a T object. + */ + protected T setOutputFile(File outputFile) { + getObject().setOutputFile(outputFile); + return (T) this; + } + + /** + *

setOutputFileName.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a T object. + */ + protected T setOutputFileName(String outputFileName) { + getObject().setOutputFileName(outputFileName); + return (T) this; + } + + /** + *

setPageIndex.

+ * + * @param pageIndex a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setPageIndex(Integer pageIndex) { + getObject().setPageIndex(pageIndex); + return (T) this; + } + + /** + *

setStartPageIndex.

+ * + * @param startPageIndex a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setStartPageIndex(Integer startPageIndex) { + getObject().setStartPageIndex(startPageIndex); + return (T) this; + } + + /** + *

setEndPageIndex.

+ * + * @param endPageIndex a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setEndPageIndex(Integer endPageIndex) { + getObject().setEndPageIndex(endPageIndex); + return (T) this; + } + + /** + *

setCharacterEncoding.

+ * + * @param characterEncoding a {@link java.lang.String} object. + * @return a T object. + */ + public T setCharacterEncoding(String characterEncoding) { + getObject().setCharacterEncoding(characterEncoding); + return (T) this; + } + + /** + *

setOffsetX.

+ * + * @param offsetX a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setOffsetX(Integer offsetX) { + getObject().setOffsetX(offsetX); + return (T) this; + } + + /** + *

setOffsetY.

+ * + * @param offsetY a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setOffsetY(Integer offsetY) { + getObject().setOffsetY(offsetY); + return (T) this; + } + + /** + *

getExporter.

+ * + * @return a U object. + */ + public U getExporter() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/ExporterBuilders.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/ExporterBuilders.java new file mode 100644 index 0000000..afd07a6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/ExporterBuilders.java @@ -0,0 +1,492 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import java.io.File; +import java.io.OutputStream; +import java.io.Writer; + + +/** + * A set of methods of creating exporters + * + * @author Ricardo Mariaca + */ +public class ExporterBuilders +{ + + // csv + + /** + *

csvExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + */ + public JasperCsvExporterBuilder csvExporter(final Writer outputWriter) + { + return Exporters.csvExporter(outputWriter); + } + + /** + *

csvExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + */ + public JasperCsvExporterBuilder csvExporter(final OutputStream outputStream) + { + return Exporters.csvExporter(outputStream); + } + + /** + *

csvExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + */ + public JasperCsvExporterBuilder csvExporter(final File outputFile) + { + return Exporters.csvExporter(outputFile); + } + + /** + *

csvExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + */ + public JasperCsvExporterBuilder csvExporter(final String outputFileName) + { + return Exporters.csvExporter(outputFileName); + } + + // docx + + /** + *

docxExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + */ + public JasperDocxExporterBuilder docxExporter(final Writer outputWriter) + { + return Exporters.docxExporter(outputWriter); + } + + /** + *

docxExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + */ + public JasperDocxExporterBuilder docxExporter(final OutputStream outputStream) + { + return Exporters.docxExporter(outputStream); + } + + /** + *

docxExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + */ + public JasperDocxExporterBuilder docxExporter(final File outputFile) + { + return Exporters.docxExporter(outputFile); + } + + /** + *

docxExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + */ + public JasperDocxExporterBuilder docxExporter(final String outputFileName) + { + return Exporters.docxExporter(outputFileName); + } + + // html + + /** + *

htmlExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder htmlExporter(final Writer outputWriter) + { + return Exporters.htmlExporter(outputWriter); + } + + /** + *

htmlExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder htmlExporter(final OutputStream outputStream) + { + return Exporters.htmlExporter(outputStream); + } + + /** + *

htmlExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder htmlExporter(final File outputFile) + { + return Exporters.htmlExporter(outputFile); + } + + /** + *

htmlExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder htmlExporter(final String outputFileName) + { + return Exporters.htmlExporter(outputFileName); + } + + // ods + + /** + *

odsExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder} object. + */ + public JasperOdsExporterBuilder odsExporter(final Writer outputWriter) + { + return Exporters.odsExporter(outputWriter); + } + + /** + *

odsExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder} object. + */ + public JasperOdsExporterBuilder odsExporter(final OutputStream outputStream) + { + return Exporters.odsExporter(outputStream); + } + + /** + *

odsExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder} object. + */ + public JasperOdsExporterBuilder odsExporter(final File outputFile) + { + return Exporters.odsExporter(outputFile); + } + + /** + *

odsExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder} object. + */ + public JasperOdsExporterBuilder odsExporter(final String outputFileName) + { + return Exporters.odsExporter(outputFileName); + } + + // odt + + /** + *

odtExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + */ + public JasperOdtExporterBuilder odtExporter(final Writer outputWriter) + { + return Exporters.odtExporter(outputWriter); + } + + /** + *

odtExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + */ + public JasperOdtExporterBuilder odtExporter(final OutputStream outputStream) + { + return Exporters.odtExporter(outputStream); + } + + /** + *

odtExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + */ + public JasperOdtExporterBuilder odtExporter(final File outputFile) + { + return Exporters.odtExporter(outputFile); + } + + /** + *

odtExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + */ + public JasperOdtExporterBuilder odtExporter(final String outputFileName) + { + return Exporters.odtExporter(outputFileName); + } + + // pdf + + /** + *

pdfExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder pdfExporter(final Writer outputWriter) + { + return Exporters.pdfExporter(outputWriter); + } + + /** + *

pdfExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder pdfExporter(final OutputStream outputStream) + { + return Exporters.pdfExporter(outputStream); + } + + /** + *

pdfExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder pdfExporter(final File outputFile) + { + return Exporters.pdfExporter(outputFile); + } + + /** + *

pdfExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder pdfExporter(final String outputFileName) + { + return Exporters.pdfExporter(outputFileName); + } + + // rtf + + /** + *

rtfExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder} object. + */ + public JasperRtfExporterBuilder rtfExporter(final Writer outputWriter) + { + return Exporters.rtfExporter(outputWriter); + } + + /** + *

rtfExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder} object. + */ + public JasperRtfExporterBuilder rtfExporter(final OutputStream outputStream) + { + return Exporters.rtfExporter(outputStream); + } + + /** + *

rtfExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder} object. + */ + public JasperRtfExporterBuilder rtfExporter(final File outputFile) + { + return Exporters.rtfExporter(outputFile); + } + + /** + *

rtfExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder} object. + */ + public JasperRtfExporterBuilder rtfExporter(final String outputFileName) + { + return Exporters.rtfExporter(outputFileName); + } + + // text + + /** + *

textExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public JasperTextExporterBuilder textExporter(final Writer outputWriter) + { + return Exporters.textExporter(outputWriter); + } + + /** + *

textExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public JasperTextExporterBuilder textExporter(final OutputStream outputStream) + { + return Exporters.textExporter(outputStream); + } + + /** + *

textExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public JasperTextExporterBuilder textExporter(final File outputFile) + { + return Exporters.textExporter(outputFile); + } + + /** + *

textExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public JasperTextExporterBuilder textExporter(final String outputFileName) + { + return Exporters.textExporter(outputFileName); + } + + // xlsx + + /** + *

xlsxExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder} object. + */ + public JasperXlsxExporterBuilder xlsxExporter(final Writer outputWriter) + { + return Exporters.xlsxExporter(outputWriter); + } + + /** + *

xlsxExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder} object. + */ + public JasperXlsxExporterBuilder xlsxExporter(final OutputStream outputStream) + { + return Exporters.xlsxExporter(outputStream); + } + + /** + *

xlsxExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder} object. + */ + public JasperXlsxExporterBuilder xlsxExporter(final File outputFile) + { + return Exporters.xlsxExporter(outputFile); + } + + /** + *

xlsxExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder} object. + */ + public JasperXlsxExporterBuilder xlsxExporter(final String outputFileName) + { + return Exporters.xlsxExporter(outputFileName); + } + + // pptx + + /** + *

pptxExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder} object. + */ + public JasperPptxExporterBuilder pptxExporter(final Writer outputWriter) + { + return Exporters.pptxExporter(outputWriter); + } + + /** + *

pptxExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder} object. + */ + public JasperPptxExporterBuilder pptxExporter(final OutputStream outputStream) + { + return Exporters.pptxExporter(outputStream); + } + + /** + *

pptxExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder} object. + */ + public JasperPptxExporterBuilder pptxExporter(final File outputFile) + { + return Exporters.pptxExporter(outputFile); + } + + /** + *

pptxExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder} object. + */ + public JasperPptxExporterBuilder pptxExporter(final String outputFileName) + { + return Exporters.pptxExporter(outputFileName); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/Exporters.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/Exporters.java new file mode 100644 index 0000000..6d66d06 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/Exporters.java @@ -0,0 +1,492 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import java.io.File; +import java.io.OutputStream; +import java.io.Writer; + + +/** + * A set of methods of creating exporters + * + * @author Ricardo Mariaca + */ +public class Exporters +{ + + // csv + + /** + *

csvExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + */ + public static JasperCsvExporterBuilder csvExporter(final Writer outputWriter) + { + return new JasperCsvExporterBuilder().setOutputWriter(outputWriter); + } + + /** + *

csvExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + */ + public static JasperCsvExporterBuilder csvExporter(final OutputStream outputStream) + { + return new JasperCsvExporterBuilder().setOutputStream(outputStream); + } + + /** + *

csvExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + */ + public static JasperCsvExporterBuilder csvExporter(final File outputFile) + { + return new JasperCsvExporterBuilder().setOutputFile(outputFile); + } + + /** + *

csvExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + */ + public static JasperCsvExporterBuilder csvExporter(final String outputFileName) + { + return new JasperCsvExporterBuilder().setOutputFileName(outputFileName); + } + + // docx + + /** + *

docxExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + */ + public static JasperDocxExporterBuilder docxExporter(final Writer outputWriter) + { + return new JasperDocxExporterBuilder().setOutputWriter(outputWriter); + } + + /** + *

docxExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + */ + public static JasperDocxExporterBuilder docxExporter(final OutputStream outputStream) + { + return new JasperDocxExporterBuilder().setOutputStream(outputStream); + } + + /** + *

docxExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + */ + public static JasperDocxExporterBuilder docxExporter(final File outputFile) + { + return new JasperDocxExporterBuilder().setOutputFile(outputFile); + } + + /** + *

docxExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + */ + public static JasperDocxExporterBuilder docxExporter(final String outputFileName) + { + return new JasperDocxExporterBuilder().setOutputFileName(outputFileName); + } + + // html + + /** + *

htmlExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public static JasperHtmlExporterBuilder htmlExporter(final Writer outputWriter) + { + return new JasperHtmlExporterBuilder().setOutputWriter(outputWriter); + } + + /** + *

htmlExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public static JasperHtmlExporterBuilder htmlExporter(final OutputStream outputStream) + { + return new JasperHtmlExporterBuilder().setOutputStream(outputStream); + } + + /** + *

htmlExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public static JasperHtmlExporterBuilder htmlExporter(final File outputFile) + { + return new JasperHtmlExporterBuilder().setOutputFile(outputFile); + } + + /** + *

htmlExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public static JasperHtmlExporterBuilder htmlExporter(final String outputFileName) + { + return new JasperHtmlExporterBuilder().setOutputFileName(outputFileName); + } + + // ods + + /** + *

odsExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder} object. + */ + public static JasperOdsExporterBuilder odsExporter(final Writer outputWriter) + { + return new JasperOdsExporterBuilder().setOutputWriter(outputWriter); + } + + /** + *

odsExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder} object. + */ + public static JasperOdsExporterBuilder odsExporter(final OutputStream outputStream) + { + return new JasperOdsExporterBuilder().setOutputStream(outputStream); + } + + /** + *

odsExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder} object. + */ + public static JasperOdsExporterBuilder odsExporter(final File outputFile) + { + return new JasperOdsExporterBuilder().setOutputFile(outputFile); + } + + /** + *

odsExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder} object. + */ + public static JasperOdsExporterBuilder odsExporter(final String outputFileName) + { + return new JasperOdsExporterBuilder().setOutputFileName(outputFileName); + } + + // odt + + /** + *

odtExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + */ + public static JasperOdtExporterBuilder odtExporter(final Writer outputWriter) + { + return new JasperOdtExporterBuilder().setOutputWriter(outputWriter); + } + + /** + *

odtExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + */ + public static JasperOdtExporterBuilder odtExporter(final OutputStream outputStream) + { + return new JasperOdtExporterBuilder().setOutputStream(outputStream); + } + + /** + *

odtExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + */ + public static JasperOdtExporterBuilder odtExporter(final File outputFile) + { + return new JasperOdtExporterBuilder().setOutputFile(outputFile); + } + + /** + *

odtExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + */ + public static JasperOdtExporterBuilder odtExporter(final String outputFileName) + { + return new JasperOdtExporterBuilder().setOutputFileName(outputFileName); + } + + // pdf + + /** + *

pdfExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public static JasperPdfExporterBuilder pdfExporter(final Writer outputWriter) + { + return new JasperPdfExporterBuilder().setOutputWriter(outputWriter); + } + + /** + *

pdfExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public static JasperPdfExporterBuilder pdfExporter(final OutputStream outputStream) + { + return new JasperPdfExporterBuilder().setOutputStream(outputStream); + } + + /** + *

pdfExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public static JasperPdfExporterBuilder pdfExporter(final File outputFile) + { + return new JasperPdfExporterBuilder().setOutputFile(outputFile); + } + + /** + *

pdfExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public static JasperPdfExporterBuilder pdfExporter(final String outputFileName) + { + return new JasperPdfExporterBuilder().setOutputFileName(outputFileName); + } + + // rtf + + /** + *

rtfExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder} object. + */ + public static JasperRtfExporterBuilder rtfExporter(final Writer outputWriter) + { + return new JasperRtfExporterBuilder().setOutputWriter(outputWriter); + } + + /** + *

rtfExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder} object. + */ + public static JasperRtfExporterBuilder rtfExporter(final OutputStream outputStream) + { + return new JasperRtfExporterBuilder().setOutputStream(outputStream); + } + + /** + *

rtfExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder} object. + */ + public static JasperRtfExporterBuilder rtfExporter(final File outputFile) + { + return new JasperRtfExporterBuilder().setOutputFile(outputFile); + } + + /** + *

rtfExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder} object. + */ + public static JasperRtfExporterBuilder rtfExporter(final String outputFileName) + { + return new JasperRtfExporterBuilder().setOutputFileName(outputFileName); + } + + // text + + /** + *

textExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public static JasperTextExporterBuilder textExporter(final Writer outputWriter) + { + return new JasperTextExporterBuilder().setOutputWriter(outputWriter); + } + + /** + *

textExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public static JasperTextExporterBuilder textExporter(final OutputStream outputStream) + { + return new JasperTextExporterBuilder().setOutputStream(outputStream); + } + + /** + *

textExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public static JasperTextExporterBuilder textExporter(final File outputFile) + { + return new JasperTextExporterBuilder().setOutputFile(outputFile); + } + + /** + *

textExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public static JasperTextExporterBuilder textExporter(final String outputFileName) + { + return new JasperTextExporterBuilder().setOutputFileName(outputFileName); + } + + // xlsx + + /** + *

xlsxExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder} object. + */ + public static JasperXlsxExporterBuilder xlsxExporter(final Writer outputWriter) + { + return new JasperXlsxExporterBuilder().setOutputWriter(outputWriter); + } + + /** + *

xlsxExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder} object. + */ + public static JasperXlsxExporterBuilder xlsxExporter(final OutputStream outputStream) + { + return new JasperXlsxExporterBuilder().setOutputStream(outputStream); + } + + /** + *

xlsxExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder} object. + */ + public static JasperXlsxExporterBuilder xlsxExporter(final File outputFile) + { + return new JasperXlsxExporterBuilder().setOutputFile(outputFile); + } + + /** + *

xlsxExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder} object. + */ + public static JasperXlsxExporterBuilder xlsxExporter(final String outputFileName) + { + return new JasperXlsxExporterBuilder().setOutputFileName(outputFileName); + } + + // pptx + + /** + *

pptxExporter.

+ * + * @param outputWriter a {@link java.io.Writer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder} object. + */ + public static JasperPptxExporterBuilder pptxExporter(final Writer outputWriter) + { + return new JasperPptxExporterBuilder().setOutputWriter(outputWriter); + } + + /** + *

pptxExporter.

+ * + * @param outputStream a {@link java.io.OutputStream} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder} object. + */ + public static JasperPptxExporterBuilder pptxExporter(final OutputStream outputStream) + { + return new JasperPptxExporterBuilder().setOutputStream(outputStream); + } + + /** + *

pptxExporter.

+ * + * @param outputFile a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder} object. + */ + public static JasperPptxExporterBuilder pptxExporter(final File outputFile) + { + return new JasperPptxExporterBuilder().setOutputFile(outputFile); + } + + /** + *

pptxExporter.

+ * + * @param outputFileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder} object. + */ + public static JasperPptxExporterBuilder pptxExporter(final String outputFileName) + { + return new JasperPptxExporterBuilder().setOutputFileName(outputFileName); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperCsvExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperCsvExporterBuilder.java new file mode 100644 index 0000000..afc33bc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperCsvExporterBuilder.java @@ -0,0 +1,60 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.JasperCsvExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperCsvExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperCsvExporterBuilder extends AbstractJasperExporterBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperCsvExporterBuilder.

+ */ + protected JasperCsvExporterBuilder() { + super(new JasperCsvExporter()); + } + + /** + *

setFieldDelimiter.

+ * + * @param fieldDelimiter a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + */ + public JasperCsvExporterBuilder setFieldDelimiter(String fieldDelimiter) { + this.getObject().setFieldDelimiter(fieldDelimiter); + return this; + } + + /** + *

setRecordDelimiter.

+ * + * @param recordDelimiter a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperCsvExporterBuilder} object. + */ + public JasperCsvExporterBuilder setRecordDelimiter(String recordDelimiter) { + this.getObject().setRecordDelimiter(recordDelimiter); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperDocxExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperDocxExporterBuilder.java new file mode 100644 index 0000000..63107be --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperDocxExporterBuilder.java @@ -0,0 +1,71 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.JasperDocxExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperDocxExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperDocxExporterBuilder extends AbstractJasperExporterBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperDocxExporterBuilder.

+ */ + protected JasperDocxExporterBuilder() { + super(new JasperDocxExporter()); + } + + /** + *

setFramesAsNestedTables.

+ * + * @param framesAsNestedTables a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + */ + public JasperDocxExporterBuilder setFramesAsNestedTables(Boolean framesAsNestedTables) { + this.getObject().setFramesAsNestedTables(framesAsNestedTables); + return this; + } + + /** + *

setFlexibleRowHeight.

+ * + * @param flexibleRowHeight a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + */ + public JasperDocxExporterBuilder setFlexibleRowHeight(Boolean flexibleRowHeight) { + this.getObject().setFlexibleRowHeight(flexibleRowHeight); + return this; + } + + /** + *

setIgnoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperDocxExporterBuilder} object. + */ + public JasperDocxExporterBuilder setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.getObject().setIgnoreHyperLink(ignoreHyperLink); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperHtmlExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperHtmlExporterBuilder.java new file mode 100644 index 0000000..34ef502 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperHtmlExporterBuilder.java @@ -0,0 +1,241 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.JasperHtmlExporter; +import software.xdev.dynamicreports.jasper.constant.SizeUnit; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperHtmlExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperHtmlExporterBuilder extends AbstractJasperExporterBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperHtmlExporterBuilder.

+ */ + protected JasperHtmlExporterBuilder() { + super(new JasperHtmlExporter()); + } + + /** + *

setOutputImagesToDir.

+ * + * @param outputImagesToDir a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setOutputImagesToDir(Boolean outputImagesToDir) { + this.getObject().setOutputImagesToDir(outputImagesToDir); + return this; + } + + /** + *

setImagesDirName.

+ * + * @param imagesDirName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setImagesDirName(String imagesDirName) { + this.getObject().setImagesDirName(imagesDirName); + return this; + } + + /** + *

setImagesURI.

+ * + * @param imagesURI a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setImagesURI(String imagesURI) { + this.getObject().setImagesURI(imagesURI); + return this; + } + + /** + *

setHtmlHeader.

+ * + * @param htmlHeader a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setHtmlHeader(String htmlHeader) { + this.getObject().setHtmlHeader(htmlHeader); + return this; + } + + /** + *

setBetweenPagesHtml.

+ * + * @param betweenPagesHtml a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setBetweenPagesHtml(String betweenPagesHtml) { + this.getObject().setBetweenPagesHtml(betweenPagesHtml); + return this; + } + + /** + *

setHtmlFooter.

+ * + * @param htmlFooter a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setHtmlFooter(String htmlFooter) { + this.getObject().setHtmlFooter(htmlFooter); + return this; + } + + /** + *

setRemoveEmptySpaceBetweenRows.

+ * + * @param removeEmptySpaceBetweenRows a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setRemoveEmptySpaceBetweenRows(Boolean removeEmptySpaceBetweenRows) { + this.getObject().setRemoveEmptySpaceBetweenRows(removeEmptySpaceBetweenRows); + return this; + } + + /** + *

setWhitePageBackground.

+ * + * @param whitePageBackground a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setWhitePageBackground(Boolean whitePageBackground) { + this.getObject().setWhitePageBackground(whitePageBackground); + return this; + } + + /** + *

setUsingImagesToAlign.

+ * + * @param usingImagesToAlign a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + * @deprecated To be removed. + */ + @Deprecated + public JasperHtmlExporterBuilder setUsingImagesToAlign(Boolean usingImagesToAlign) { + this.getObject().setUsingImagesToAlign(usingImagesToAlign); + return this; + } + + /** + *

setWrapBreakWord.

+ * + * @param wrapBreakWord a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setWrapBreakWord(Boolean wrapBreakWord) { + this.getObject().setWrapBreakWord(wrapBreakWord); + return this; + } + + /** + *

setSizeUnit.

+ * + * @param sizeUnit a {@link software.xdev.dynamicreports.jasper.constant.SizeUnit} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setSizeUnit(SizeUnit sizeUnit) { + this.getObject().setSizeUnit(sizeUnit); + return this; + } + + /** + *

setFramesAsNestedTables.

+ * + * @param framesAsNestedTables a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + * @deprecated To be removed. + */ + @Deprecated + public JasperHtmlExporterBuilder setFramesAsNestedTables(Boolean framesAsNestedTables) { + this.getObject().setFramesAsNestedTables(framesAsNestedTables); + return this; + } + + /** + *

setIgnorePageMargins.

+ * + * @param ignorePageMargins a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setIgnorePageMargins(Boolean ignorePageMargins) { + this.getObject().setIgnorePageMargins(ignorePageMargins); + return this; + } + + /** + *

setBorderCollapse.

+ * + * @param borderCollapse a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setBorderCollapse(String borderCollapse) { + this.getObject().setBorderCollapse(borderCollapse); + return this; + } + + /** + *

setAccessibleHtml.

+ * + * @param accessibleHtml a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setAccessibleHtml(Boolean accessibleHtml) { + this.getObject().setAccessibleHtml(accessibleHtml); + return this; + } + + /** + *

setZoomRatio.

+ * + * @param zoomRatio a {@link java.lang.Float} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setZoomRatio(Float zoomRatio) { + this.getObject().setZoomRatio(zoomRatio); + return this; + } + + /** + *

setIgnoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.getObject().setIgnoreHyperLink(ignoreHyperLink); + return this; + } + + /** + *

setFlushOutput.

+ * + * @param flushOutput a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperHtmlExporterBuilder} object. + */ + public JasperHtmlExporterBuilder setFlushOutput(Boolean flushOutput) { + this.getObject().setFlushOutput(flushOutput); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperOdsExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperOdsExporterBuilder.java new file mode 100644 index 0000000..1d085af --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperOdsExporterBuilder.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.JasperOdsExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperOdsExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperOdsExporterBuilder extends AbstractJasperExporterBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperOdsExporterBuilder.

+ */ + protected JasperOdsExporterBuilder() { + super(new JasperOdsExporter()); + } + + /** + *

setFlexibleRowHeight.

+ * + * @param flexibleRowHeight a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdsExporterBuilder} object. + */ + public JasperOdsExporterBuilder setFlexibleRowHeight(Boolean flexibleRowHeight) { + getObject().setFlexibleRowHeight(flexibleRowHeight); + return this; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperOdtExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperOdtExporterBuilder.java new file mode 100644 index 0000000..2a41eb0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperOdtExporterBuilder.java @@ -0,0 +1,60 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.JasperOdtExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperOdtExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperOdtExporterBuilder extends AbstractJasperExporterBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperOdtExporterBuilder.

+ */ + protected JasperOdtExporterBuilder() { + super(new JasperOdtExporter()); + } + + /** + *

setFlexibleRowHeight.

+ * + * @param flexibleRowHeight a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + */ + public JasperOdtExporterBuilder setFlexibleRowHeight(Boolean flexibleRowHeight) { + this.getObject().setFlexibleRowHeight(flexibleRowHeight); + return this; + } + + /** + *

setIgnoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperOdtExporterBuilder} object. + */ + public JasperOdtExporterBuilder setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.getObject().setIgnoreHyperLink(ignoreHyperLink); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperPdfExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperPdfExporterBuilder.java new file mode 100644 index 0000000..1e7827e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperPdfExporterBuilder.java @@ -0,0 +1,354 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.JasperPdfExporter; +import software.xdev.dynamicreports.jasper.constant.PdfPermission; +import software.xdev.dynamicreports.jasper.constant.PdfVersion; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.PdfPrintScaling; +import software.xdev.dynamicreports.report.constant.PdfaConformance; +import org.apache.commons.lang3.Validate; + +/** + *

JasperPdfExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperPdfExporterBuilder extends AbstractJasperExporterBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperPdfExporterBuilder.

+ */ + protected JasperPdfExporterBuilder() { + super(new JasperPdfExporter()); + } + + /** + *

setCreatingBatchModeBookmarks.

+ * + * @param creatingBatchModeBookmarks a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setCreatingBatchModeBookmarks(Boolean creatingBatchModeBookmarks) { + this.getObject().setCreatingBatchModeBookmarks(creatingBatchModeBookmarks); + return this; + } + + /** + *

setCompressed.

+ * + * @param compressed a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setCompressed(Boolean compressed) { + this.getObject().setCompressed(compressed); + return this; + } + + /** + *

setEncrypted.

+ * + * @param encrypted a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setEncrypted(Boolean encrypted) { + this.getObject().setEncrypted(encrypted); + return this; + } + + /** + *

setBitKey128.

+ * + * @param bitKey128 a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setBitKey128(Boolean bitKey128) { + this.getObject().setBitKey128(bitKey128); + return this; + } + + /** + *

setUserPassword.

+ * + * @param userPassword a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setUserPassword(String userPassword) { + this.getObject().setUserPassword(userPassword); + return this; + } + + /** + *

setOwnerPassword.

+ * + * @param ownerPassword a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setOwnerPassword(String ownerPassword) { + this.getObject().setOwnerPassword(ownerPassword); + return this; + } + + /** + *

permissions.

+ * + * @param permissions a {@link software.xdev.dynamicreports.jasper.constant.PdfPermission} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder permissions(PdfPermission... permissions) { + return addPermission(permissions); + } + + /** + *

addPermission.

+ * + * @param permissions a {@link software.xdev.dynamicreports.jasper.constant.PdfPermission} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder addPermission(PdfPermission... permissions) { + Validate.notNull(permissions, "permissions must not be null"); + Validate.noNullElements(permissions, "permissions must not contains null permission"); + for (PdfPermission permission : permissions) { + this.getObject().addPermission(permission); + } + return this; + } + + /** + *

setPdfVersion.

+ * + * @param pdfVersion a {@link software.xdev.dynamicreports.jasper.constant.PdfVersion} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setPdfVersion(PdfVersion pdfVersion) { + this.getObject().setPdfVersion(pdfVersion); + return this; + } + + /** + *

setMetadataTitle.

+ * + * @param metadataTitle a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setMetadataTitle(String metadataTitle) { + this.getObject().setMetadataTitle(metadataTitle); + return this; + } + + /** + *

setMetadataAuthor.

+ * + * @param metadataAuthor a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setMetadataAuthor(String metadataAuthor) { + this.getObject().setMetadataAuthor(metadataAuthor); + return this; + } + + /** + *

setMetadataSubject.

+ * + * @param metadataSubject a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setMetadataSubject(String metadataSubject) { + this.getObject().setMetadataSubject(metadataSubject); + return this; + } + + /** + *

setMetadataKeyWords.

+ * + * @param metadataKeyWords a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setMetadataKeyWords(String metadataKeyWords) { + this.getObject().setMetadataKeyWords(metadataKeyWords); + return this; + } + + /** + *

setMetadataCreator.

+ * + * @param metadataCreator a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setMetadataCreator(String metadataCreator) { + this.getObject().setMetadataCreator(metadataCreator); + return this; + } + + /** + *

setForceSvgShapes.

+ * + * @param forceSvgShapes a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setForceSvgShapes(Boolean forceSvgShapes) { + this.getObject().setForceSvgShapes(forceSvgShapes); + return this; + } + + /** + *

setPdfJavaScript.

+ * + * @param pdfJavaScript a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setPdfJavaScript(String pdfJavaScript) { + this.getObject().setPdfJavaScript(pdfJavaScript); + return this; + } + + /** + *

setTagged.

+ * + * @param tagged a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setTagged(Boolean tagged) { + this.getObject().setTagged(tagged); + return this; + } + + /** + *

setTagLanguage.

+ * + * @param tagLanguage a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setTagLanguage(String tagLanguage) { + this.getObject().setTagLanguage(tagLanguage); + return this; + } + + /** + *

setCollapseMissingBookmarkLevels.

+ * + * @param collapseMissingBookmarkLevels a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setCollapseMissingBookmarkLevels(Boolean collapseMissingBookmarkLevels) { + this.getObject().setCollapseMissingBookmarkLevels(collapseMissingBookmarkLevels); + return this; + } + + /** + *

setSizePageToContent.

+ * + * @param sizePageToContent a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setSizePageToContent(Boolean sizePageToContent) { + this.getObject().setSizePageToContent(sizePageToContent); + return this; + } + + /** + *

setIgnoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.getObject().setIgnoreHyperLink(ignoreHyperLink); + return this; + } + + /** + *

setForceLineBreakPolicy.

+ * + * @param forceLineBreakPolicy a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setForceLineBreakPolicy(Boolean forceLineBreakPolicy) { + this.getObject().setForceLineBreakPolicy(forceLineBreakPolicy); + return this; + } + + /** + *

setPrintScaling.

+ * + * @param printScaling a {@link software.xdev.dynamicreports.report.constant.PdfPrintScaling} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setPrintScaling(PdfPrintScaling printScaling) { + this.getObject().setPrintScaling(printScaling); + return this; + } + + /** + *

setPdfaConformance.

+ * + * @param pdfaConformance a {@link software.xdev.dynamicreports.report.constant.PdfaConformance} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setPdfaConformance(PdfaConformance pdfaConformance) { + this.getObject().setPdfaConformance(pdfaConformance); + return this; + } + + /** + *

setIccProfilePath.

+ * + * @param iccProfilePath a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setIccProfilePath(String iccProfilePath) { + this.getObject().setIccProfilePath(iccProfilePath); + return this; + } + + /** + *

setAllowedPermissionsHint.

+ * + * @param allowedPermissionsHint a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setAllowedPermissionsHint(String allowedPermissionsHint) { + this.getObject().setAllowedPermissionsHint(allowedPermissionsHint); + return this; + } + + /** + *

setDeniedPermissionsHint.

+ * + * @param deniedPermissionsHint a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setDeniedPermissionsHint(String deniedPermissionsHint) { + this.getObject().setDeniedPermissionsHint(deniedPermissionsHint); + return this; + } + + /** + *

setDisplayMetadataTitle.

+ * + * @param displayMetadataTitle a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPdfExporterBuilder} object. + */ + public JasperPdfExporterBuilder setDisplayMetadataTitle(Boolean displayMetadataTitle) { + this.getObject().setDisplayMetadataTitle(displayMetadataTitle); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperPptxExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperPptxExporterBuilder.java new file mode 100644 index 0000000..5da4216 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperPptxExporterBuilder.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.JasperPptxExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperPptxExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperPptxExporterBuilder extends AbstractJasperExporterBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperPptxExporterBuilder.

+ */ + protected JasperPptxExporterBuilder() { + super(new JasperPptxExporter()); + } + + /** + *

setIgnoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperPptxExporterBuilder} object. + */ + public JasperPptxExporterBuilder setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.getObject().setIgnoreHyperLink(ignoreHyperLink); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperRtfExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperRtfExporterBuilder.java new file mode 100644 index 0000000..2f36179 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperRtfExporterBuilder.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.JasperRtfExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperRtfExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperRtfExporterBuilder extends AbstractJasperExporterBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperRtfExporterBuilder.

+ */ + protected JasperRtfExporterBuilder() { + super(new JasperRtfExporter()); + } + + /** + *

setIgnoreHyperLink.

+ * + * @param ignoreHyperLink a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperRtfExporterBuilder} object. + */ + public JasperRtfExporterBuilder setIgnoreHyperLink(Boolean ignoreHyperLink) { + this.getObject().setIgnoreHyperLink(ignoreHyperLink); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperTextExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperTextExporterBuilder.java new file mode 100644 index 0000000..993d529 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperTextExporterBuilder.java @@ -0,0 +1,164 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.JasperTextExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperTextExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperTextExporterBuilder extends AbstractJasperExporterBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperTextExporterBuilder.

+ */ + protected JasperTextExporterBuilder() { + super(new JasperTextExporter()); + } + + /** + *

setCharacterWidth.

+ * + * @param characterWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + * @deprecated To be removed. Use setCharacterWidth(Float characterWidth) instead. + */ + @Deprecated + public JasperTextExporterBuilder setCharacterWidth(Integer characterWidth) { + return setCharacterWidth(characterWidth != null ? characterWidth.floatValue() : null); + } + + /** + *

setCharacterWidth.

+ * + * @param characterWidth a {@link java.lang.Float} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public JasperTextExporterBuilder setCharacterWidth(Float characterWidth) { + this.getObject().setCharacterWidth(characterWidth); + return this; + } + + /** + *

setCharacterHeight.

+ * + * @param characterHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + * @deprecated To be removed. Use setCharacterHeight(Float characterHeight) instead. + */ + @Deprecated + public JasperTextExporterBuilder setCharacterHeight(Integer characterHeight) { + return setCharacterHeight(characterHeight != null ? characterHeight.floatValue() : null); + } + + /** + *

setCharacterHeight.

+ * + * @param characterHeight a {@link java.lang.Float} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public JasperTextExporterBuilder setCharacterHeight(Float characterHeight) { + this.getObject().setCharacterHeight(characterHeight); + return this; + } + + /** + *

setPageWidth.

+ * + * @param pageWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + * @deprecated To be removed. Use setPageWidthInChars instead. + */ + @Deprecated + public JasperTextExporterBuilder setPageWidth(Integer pageWidth) { + return setPageWidthInChars(pageWidth); + } + + /** + *

setPageWidthInChars.

+ * + * @param pageWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public JasperTextExporterBuilder setPageWidthInChars(Integer pageWidth) { + this.getObject().setPageWidthInChars(pageWidth); + return this; + } + + /** + *

setPageHeight.

+ * + * @param pageHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + * @deprecated To be removed. Use setPageHeightInChars instead. + */ + @Deprecated + public JasperTextExporterBuilder setPageHeight(Integer pageHeight) { + return setPageHeightInChars(pageHeight); + } + + /** + *

setPageHeightInChars.

+ * + * @param pageHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public JasperTextExporterBuilder setPageHeightInChars(Integer pageHeight) { + this.getObject().setPageHeightInChars(pageHeight); + return this; + } + + /** + *

setBetweenPagesText.

+ * + * @param betweenPagesText a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + * @deprecated To be removed. Use setPageSeparator instead. + */ + @Deprecated + public JasperTextExporterBuilder setBetweenPagesText(String betweenPagesText) { + return setPageSeparator(betweenPagesText); + } + + /** + *

setPageSeparator.

+ * + * @param pageSeparator a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public JasperTextExporterBuilder setPageSeparator(String pageSeparator) { + this.getObject().setPageSeparator(pageSeparator); + return this; + } + + /** + *

setLineSeparator.

+ * + * @param lineSeparator a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperTextExporterBuilder} object. + */ + public JasperTextExporterBuilder setLineSeparator(String lineSeparator) { + this.getObject().setLineSeparator(lineSeparator); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperXlsxExporterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperXlsxExporterBuilder.java new file mode 100644 index 0000000..056db8b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/builder/export/JasperXlsxExporterBuilder.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.builder.export; + +import software.xdev.dynamicreports.jasper.base.export.JasperXlsxExporter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperXlsxExporterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperXlsxExporterBuilder extends AbstractJasperExcelExporterBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperXlsxExporterBuilder.

+ */ + protected JasperXlsxExporterBuilder() { + super(new JasperXlsxExporter()); + } + + /** + *

setMacroTemplate.

+ * + * @param macroTemplate a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.jasper.builder.export.JasperXlsxExporterBuilder} object. + */ + public JasperXlsxExporterBuilder setMacroTemplate(String macroTemplate) { + getObject().setMacroTemplate(macroTemplate); + return this; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/ImageType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/ImageType.java new file mode 100644 index 0000000..1db18de --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/ImageType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.constant; + +/** + *

ImageType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum ImageType { + GIF, PNG, JPG +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/JasperProperty.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/JasperProperty.java new file mode 100644 index 0000000..23248de --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/JasperProperty.java @@ -0,0 +1,487 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.constant; + +import net.sf.jasperreports.engine.JRAbstractExporter; +import net.sf.jasperreports.engine.JRTextElement; +import net.sf.jasperreports.engine.export.HtmlExporter; +import net.sf.jasperreports.engine.export.JRCsvMetadataExporter; +import net.sf.jasperreports.engine.export.JRPdfExporterTagHelper; +import net.sf.jasperreports.engine.export.JRXlsAbstractExporter; +import net.sf.jasperreports.engine.export.JRXlsAbstractMetadataExporter; +import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter; +import net.sf.jasperreports.engine.util.JRTextMeasurerUtil; +import net.sf.jasperreports.engine.xml.PrintSaxParserFactory; +import net.sf.jasperreports.export.CommonExportConfiguration; +import net.sf.jasperreports.export.CsvExporterConfiguration; +import net.sf.jasperreports.export.CsvMetadataReportConfiguration; +import net.sf.jasperreports.export.DocxReportConfiguration; +import net.sf.jasperreports.export.Graphics2DReportConfiguration; +import net.sf.jasperreports.export.HtmlExporterConfiguration; +import net.sf.jasperreports.export.HtmlReportConfiguration; +import net.sf.jasperreports.export.PdfExporterConfiguration; +import net.sf.jasperreports.export.PdfReportConfiguration; +import net.sf.jasperreports.export.ReportExportConfiguration; +import net.sf.jasperreports.export.TextReportConfiguration; +import net.sf.jasperreports.export.WriterExporterOutput; +import net.sf.jasperreports.export.XlsExporterConfiguration; +import net.sf.jasperreports.export.XlsMetadataReportConfiguration; +import net.sf.jasperreports.export.XlsReportConfiguration; + + +/** + *

JasperProperty class.

+ * + * @author Ricardo Mariaca + */ +public class JasperProperty +{ + + // export + /** + * @see WriterExporterOutput#PROPERTY_CHARACTER_ENCODING + */ + public static final String EXPORT_CHARACTER_ENCODING = WriterExporterOutput.PROPERTY_CHARACTER_ENCODING; + /** + * @see CommonExportConfiguration#PROPERTY_EXPORT_CONFIGURATION_OVERRIDE_REPORT_HINTS + * @deprecated Replaced by {@link EXPORT_CONFIGURATION_OVERRIDE_REPORT_HINTS}. + */ + @Deprecated + public static final String EXPORT_PARAMETERS_OVERRIDE_REPORT_HINTS = + CommonExportConfiguration.PROPERTY_EXPORT_CONFIGURATION_OVERRIDE_REPORT_HINTS; + /** + * @see CommonExportConfiguration#PROPERTY_EXPORT_CONFIGURATION_OVERRIDE_REPORT_HINTS + */ + public static final String EXPORT_CONFIGURATION_OVERRIDE_REPORT_HINTS = + CommonExportConfiguration.PROPERTY_EXPORT_CONFIGURATION_OVERRIDE_REPORT_HINTS; + /** + * @see ReportExportConfiguration#PROPERTY_IGNORE_PAGE_MARGINS + */ + public static final String EXPORT_IGNORE_PAGE_MARGINS = ReportExportConfiguration.PROPERTY_IGNORE_PAGE_MARGINS; + /** + * @see Graphics2DReportConfiguration#MINIMIZE_PRINTER_JOB_SIZE + */ + public static final String EXPORT_GRAPHICD2D_MINIMIZE_PRINTER_JOB_SIZE = + Graphics2DReportConfiguration.MINIMIZE_PRINTER_JOB_SIZE; + /** + * @see JRAbstractExporter#PROPERTY_DEFAULT_FILTER_FACTORY + */ + public static final String EXPORT_DEFAULT_FILTER_FACTORY = JRAbstractExporter.PROPERTY_DEFAULT_FILTER_FACTORY; + + // text + /** + * @see JRTextElement#PROPERTY_PRINT_KEEP_FULL_TEXT + */ + public static final String PRINT_KEEP_FULL_TEXT = JRTextElement.PROPERTY_PRINT_KEEP_FULL_TEXT; + /** + * @see JRTextElement#PROPERTY_TRUNCATE_AT_CHAR + */ + public static final String TEXT_TRUNCATE_AT_CHAR = JRTextElement.PROPERTY_TRUNCATE_AT_CHAR; + /** + * @see JRTextElement#PROPERTY_TRUNCATE_SUFFIX + */ + public static final String TEXT_TRUNCATE_SUFFIX = JRTextElement.PROPERTY_TRUNCATE_SUFFIX; + /** + * @see JRTextElement#PROPERTY_SAVE_LINE_BREAKS + */ + public static final String TEXT_SAVE_LINE_BREAKS = JRTextElement.PROPERTY_SAVE_LINE_BREAKS; + /** + * @see JRTextMeasurerUtil#PROPERTY_TEXT_MEASURER_FACTORY + */ + public static final String TEXT_MEASURER_FACTORY = JRTextMeasurerUtil.PROPERTY_TEXT_MEASURER_FACTORY; + /** + * @see TextReportConfiguration#PROPERTY_CHARACTER_WIDTH + */ + public static final String EXPORT_TEXT_CHARACTER_WIDTH = TextReportConfiguration.PROPERTY_CHARACTER_WIDTH; + /** + * @see TextReportConfiguration#PROPERTY_CHARACTER_HEIGHT + */ + public static final String EXPORT_TEXT_CHARACTER_HEIGHT = TextReportConfiguration.PROPERTY_CHARACTER_HEIGHT; + /** + * @see TextReportConfiguration#PROPERTY_PAGE_WIDTH + */ + public static final String EXPORT_TEXT_PAGE_WIDTH = TextReportConfiguration.PROPERTY_PAGE_WIDTH; + /** + * @see TextReportConfiguration#PROPERTY_PAGE_HEIGHT + */ + public static final String EXPORT_TEXT_PAGE_HEIGHT = TextReportConfiguration.PROPERTY_PAGE_HEIGHT; + + // pdf + /** + * @see JRPdfExporterTagHelper#PROPERTY_TAG_TABLE + */ + public static final String EXPORT_PDF_TAG_TABLE = JRPdfExporterTagHelper.PROPERTY_TAG_TABLE; + /** + * @see JRPdfExporterTagHelper#PROPERTY_TAG_TR + */ + public static final String EXPORT_PDF_TAG_TR = JRPdfExporterTagHelper.PROPERTY_TAG_TR; + /** + * @see JRPdfExporterTagHelper#PROPERTY_TAG_TH + */ + public static final String EXPORT_PDF_TAG_TH = JRPdfExporterTagHelper.PROPERTY_TAG_TH; + /** + * @see JRPdfExporterTagHelper#PROPERTY_TAG_TD + */ + public static final String EXPORT_PDF_TAG_TD = JRPdfExporterTagHelper.PROPERTY_TAG_TD; + /** + * @see JRPdfExporterTagHelper#PROPERTY_TAG_H1 + */ + public static final String EXPORT_PDF_TAG_H1 = JRPdfExporterTagHelper.PROPERTY_TAG_H1; + /** + * @see JRPdfExporterTagHelper#PROPERTY_TAG_H2 + */ + public static final String EXPORT_PDF_TAG_H2 = JRPdfExporterTagHelper.PROPERTY_TAG_H2; + /** + * @see JRPdfExporterTagHelper#PROPERTY_TAG_H3 + */ + public static final String EXPORT_PDF_TAG_H3 = JRPdfExporterTagHelper.PROPERTY_TAG_H3; + /** + * @see JRPdfExporterTagHelper#PROPERTY_TAG_COLSPAN + */ + public static final String EXPORT_PDF_TAG_COLSPAN = JRPdfExporterTagHelper.PROPERTY_TAG_COLSPAN; + /** + * @see JRPdfExporterTagHelper#PROPERTY_TAG_ROWSPAN + */ + public static final String EXPORT_PDF_TAG_ROWSPAN = JRPdfExporterTagHelper.PROPERTY_TAG_ROWSPAN; + /** + * @see PdfExporterConfiguration#PROPERTY_CREATE_BATCH_MODE_BOOKMARKS + */ + public static final String EXPORT_PDF_CREATE_BATCH_MODE_BOOKMARKS = + PdfExporterConfiguration.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS; + /** + * @see PdfExporterConfiguration#PROPERTY_COMPRESSED + */ + public static final String EXPORT_PDF_COMPRESSED = PdfExporterConfiguration.PROPERTY_COMPRESSED; + /** + * @see PdfExporterConfiguration#PROPERTY_ENCRYPTED + */ + public static final String EXPORT_PDF_ENCRYPTED = PdfExporterConfiguration.PROPERTY_ENCRYPTED; + /** + * @see PdfExporterConfiguration#PROPERTY_128_BIT_KEY + */ + public static final String EXPORT_PDF_128_BIT_KEY = PdfExporterConfiguration.PROPERTY_128_BIT_KEY; + /** + * @see PdfExporterConfiguration#PROPERTY_USER_PASSWORD + */ + public static final String EXPORT_PDF_USER_PASSWORD = PdfExporterConfiguration.PROPERTY_USER_PASSWORD; + /** + * @see PdfExporterConfiguration#PROPERTY_OWNER_PASSWORD + */ + public static final String EXPORT_PDF_OWNER_PASSWORD = PdfExporterConfiguration.PROPERTY_OWNER_PASSWORD; + /** + * @see PdfExporterConfiguration#PROPERTY_PDF_VERSION + */ + public static final String EXPORT_PDF_VERSION = PdfExporterConfiguration.PROPERTY_PDF_VERSION; + /** + * @see PdfReportConfiguration#PROPERTY_FORCE_SVG_SHAPES + */ + public static final String EXPORT_PDF_FORCE_SVG_SHAPES = PdfReportConfiguration.PROPERTY_FORCE_SVG_SHAPES; + /** + * @see PdfExporterConfiguration#PROPERTY_PDF_JAVASCRIPT + */ + public static final String EXPORT_PDF_JAVASCRIPT = PdfExporterConfiguration.PROPERTY_PDF_JAVASCRIPT; + /** + * @see PdfExporterConfiguration#PROPERTY_PRINT_SCALING + */ + public static final String EXPORT_PDF_PRINT_SCALING = PdfExporterConfiguration.PROPERTY_PRINT_SCALING; + /** + * @see PdfExporterConfiguration#PROPERTY_TAGGED + */ + public static final String EXPORT_PDF_TAGGED = PdfExporterConfiguration.PROPERTY_TAGGED; + /** + * @see PdfExporterConfiguration#PROPERTY_TAG_LANGUAGE + */ + public static final String EXPORT_PDF_TAG_LANGUAGE = PdfExporterConfiguration.PROPERTY_TAG_LANGUAGE; + /** + * @see PdfReportConfiguration#PROPERTY_COLLAPSE_MISSING_BOOKMARK_LEVELS + */ + public static final String EXPORT_PDF_COLLAPSE_MISSING_BOOKMARK_LEVELS = + PdfReportConfiguration.PROPERTY_COLLAPSE_MISSING_BOOKMARK_LEVELS; + /** + * @see PdfExporterConfiguration#PROPERTY_PDFA_CONFORMANCE + */ + public static final String EXPORT_PDF_PDFA_CONFORMANCE = PdfExporterConfiguration.PROPERTY_PDFA_CONFORMANCE; + /** + * @see PdfExporterConfiguration#PROPERTY_PDFA_ICC_PROFILE_PATH + */ + public static final String EXPORT_PDF_PDFA_ICC_PROFILE_PATH = + PdfExporterConfiguration.PROPERTY_PDFA_ICC_PROFILE_PATH; + + // html + /** + * @see HtmlExporter#PROPERTY_HTML_CLASS + */ + public static final String EXPORT_HTML_CLASS = HtmlExporter.PROPERTY_HTML_CLASS; + /** + * @see HtmlExporter#PROPERTY_HTML_ID + */ + public static final String EXPORT_HTML_ID = HtmlExporter.PROPERTY_HTML_ID; + /** + * @see HtmlReportConfiguration#PROPERTY_ACCESSIBLE + */ + public static final String EXPORT_HTML_ACCESSIBLE = HtmlReportConfiguration.PROPERTY_ACCESSIBLE; + /** + * @see HtmlReportConfiguration#PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS + */ + public static final String EXPORT_HTML_REMOVE_EMPTY_SPACE_BETWEEN_ROWS = + HtmlReportConfiguration.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS; + /** + * @see HtmlReportConfiguration#PROPERTY_WHITE_PAGE_BACKGROUND + */ + public static final String EXPORT_HTML_WHITE_PAGE_BACKGROUND = + HtmlReportConfiguration.PROPERTY_WHITE_PAGE_BACKGROUND; + /** + * @see HtmlReportConfiguration#PROPERTY_WRAP_BREAK_WORD + */ + public static final String EXPORT_HTML_WRAP_BREAK_WORD = HtmlReportConfiguration.PROPERTY_WRAP_BREAK_WORD; + /** + * @see HtmlReportConfiguration#PROPERTY_SIZE_UNIT + */ + public static final String EXPORT_HTML_SIZE_UNIT = HtmlReportConfiguration.PROPERTY_SIZE_UNIT; + /** + * @see HtmlExporterConfiguration#PROPERTY_FLUSH_OUTPUT + */ + public static final String EXPORT_HTML_FLUSH_OUTPUT = HtmlExporterConfiguration.PROPERTY_FLUSH_OUTPUT; + + // xls + /** + * @see XlsReportConfiguration#PROPERTY_ONE_PAGE_PER_SHEET + */ + public static final String EXPORT_XLS_ONE_PAGE_PER_SHEET = XlsReportConfiguration.PROPERTY_ONE_PAGE_PER_SHEET; + /** + * @see XlsReportConfiguration#PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS + */ + public static final String EXPORT_XLS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS = + XlsReportConfiguration.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS; + /** + * @see XlsReportConfiguration#PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS + */ + public static final String EXPORT_XLS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS = + XlsReportConfiguration.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS; + /** + * @see XlsReportConfiguration#PROPERTY_WHITE_PAGE_BACKGROUND + */ + public static final String EXPORT_XLS_WHITE_PAGE_BACKGROUND = + XlsReportConfiguration.PROPERTY_WHITE_PAGE_BACKGROUND; + /** + * @see XlsReportConfiguration#PROPERTY_DETECT_CELL_TYPE + */ + public static final String EXPORT_XLS_DETECT_CELL_TYPE = XlsReportConfiguration.PROPERTY_DETECT_CELL_TYPE; + /** + * @see XlsReportConfiguration#PROPERTY_SHEET_NAMES_PREFIX + */ + public static final String EXPORT_XLS_SHEET_NAMES_PREFIX = XlsReportConfiguration.PROPERTY_SHEET_NAMES_PREFIX; + /** + * @see XlsReportConfiguration#PROPERTY_FONT_SIZE_FIX_ENABLED + */ + public static final String EXPORT_XLS_FONT_SIZE_FIX_ENABLED = + XlsReportConfiguration.PROPERTY_FONT_SIZE_FIX_ENABLED; + /** + * @see XlsReportConfiguration#PROPERTY_IMAGE_BORDER_FIX_ENABLED + */ + public static final String EXPORT_XLS_IMAGE_BORDER_FIX_ENABLED = + XlsReportConfiguration.PROPERTY_IMAGE_BORDER_FIX_ENABLED; + /** + * @see XlsReportConfiguration#PROPERTY_MAXIMUM_ROWS_PER_SHEET + */ + public static final String EXPORT_XLS_MAXIMUM_ROWS_PER_SHEET = + XlsReportConfiguration.PROPERTY_MAXIMUM_ROWS_PER_SHEET; + /** + * @see XlsReportConfiguration#PROPERTY_IGNORE_GRAPHICS + */ + public static final String EXPORT_XLS_IGNORE_GRAPHICS = XlsReportConfiguration.PROPERTY_IGNORE_GRAPHICS; + /** + * @see XlsReportConfiguration#PROPERTY_COLLAPSE_ROW_SPAN + */ + public static final String EXPORT_XLS_COLLAPSE_ROW_SPAN = XlsReportConfiguration.PROPERTY_COLLAPSE_ROW_SPAN; + /** + * @see XlsReportConfiguration#PROPERTY_IGNORE_CELL_BORDER + */ + public static final String EXPORT_XLS_IGNORE_CELL_BORDER = XlsReportConfiguration.PROPERTY_IGNORE_CELL_BORDER; + /** + * @see XlsExporterConfiguration#PROPERTY_CREATE_CUSTOM_PALETTE + */ + public static final String EXPORT_XLS_CREATE_CUSTOM_PALETTE = + XlsExporterConfiguration.PROPERTY_CREATE_CUSTOM_PALETTE; + /** + * @see XlsReportConfiguration#PROPERTY_IGNORE_CELL_BACKGROUND + */ + public static final String EXPORT_XLS_IGNORE_CELL_BACKGROUND = + XlsReportConfiguration.PROPERTY_IGNORE_CELL_BACKGROUND; + /** + * @see XlsReportConfiguration#PROPERTY_PASSWORD + */ + public static final String EXPORT_XLS_PASSWORD = XlsReportConfiguration.PROPERTY_PASSWORD; + /** + * @see JRXlsAbstractExporter#PROPERTY_CELL_FORMULA + */ + public static final String EXPORT_XLS_CELL_FORMULA = JRXlsAbstractExporter.PROPERTY_CELL_FORMULA; + /** + * @see JRXlsAbstractExporter#PROPERTY_CELL_PATTERN + */ + public static final String EXPORT_XLS_CELL_PATTERN = JRXlsAbstractExporter.PROPERTY_CELL_PATTERN; + /** + * @see XlsReportConfiguration#PROPERTY_WRAP_TEXT + */ + public static final String EXPORT_XLS_WRAP_TEXT = XlsReportConfiguration.PROPERTY_WRAP_TEXT; + /** + * @see XlsReportConfiguration#PROPERTY_FIT_WIDTH + */ + public static final String EXPORT_XLS_FIT_WIDTH = XlsReportConfiguration.PROPERTY_FIT_WIDTH; + /** + * @see XlsReportConfiguration#PROPERTY_FIT_HEIGHT + */ + public static final String EXPORT_XLS_FIT_HEIGHT = XlsReportConfiguration.PROPERTY_FIT_HEIGHT; + /** + * @see XlsReportConfiguration#PROPERTY_CELL_LOCKED + */ + public static final String EXPORT_XLS_CELL_LOCKED = XlsReportConfiguration.PROPERTY_CELL_LOCKED; + /** + * @see XlsReportConfiguration#PROPERTY_CELL_HIDDEN + */ + public static final String EXPORT_XLS_CELL_HIDDEN = XlsReportConfiguration.PROPERTY_CELL_HIDDEN; + /** + * @see XlsReportConfiguration#PROPERTY_SHEET_HEADER_LEFT + */ + public static final String EXPORT_XLS_SHEET_HEADER_LEFT = XlsReportConfiguration.PROPERTY_SHEET_HEADER_LEFT; + /** + * @see XlsReportConfiguration#PROPERTY_SHEET_HEADER_CENTER + */ + public static final String EXPORT_XLS_SHEET_HEADER_CENTER = XlsReportConfiguration.PROPERTY_SHEET_HEADER_CENTER; + /** + * @see XlsReportConfiguration#PROPERTY_SHEET_HEADER_RIGHT + */ + public static final String EXPORT_XLS_SHEET_HEADER_RIGHT = XlsReportConfiguration.PROPERTY_SHEET_HEADER_RIGHT; + /** + * @see XlsReportConfiguration#PROPERTY_SHEET_FOOTER_LEFT + */ + public static final String EXPORT_XLS_SHEET_FOOTER_LEFT = XlsReportConfiguration.PROPERTY_SHEET_FOOTER_LEFT; + /** + * @see XlsReportConfiguration#PROPERTY_SHEET_FOOTER_CENTER + */ + public static final String EXPORT_XLS_SHEET_FOOTER_CENTER = XlsReportConfiguration.PROPERTY_SHEET_FOOTER_CENTER; + /** + * @see XlsReportConfiguration#PROPERTY_SHEET_FOOTER_RIGHT + */ + public static final String EXPORT_XLS_SHEET_FOOTER_RIGHT = XlsReportConfiguration.PROPERTY_SHEET_FOOTER_RIGHT; + /** + * @see XlsReportConfiguration#PROPERTY_SHEET_DIRECTION + */ + public static final String EXPORT_XLS_SHEET_DIRECTION = XlsReportConfiguration.PROPERTY_SHEET_DIRECTION; + /** + * @see XlsReportConfiguration#PROPERTY_FREEZE_ROW + */ + public static final String EXPORT_XLS_FREEZE_ROW = XlsReportConfiguration.PROPERTY_FREEZE_ROW; + /** + * @see XlsReportConfiguration#PROPERTY_FREEZE_COLUMN + */ + public static final String EXPORT_XLS_FREEZE_COLUMN = XlsReportConfiguration.PROPERTY_FREEZE_COLUMN; + /** + * @see JRXlsAbstractExporter#PROPERTY_FREEZE_ROW_EDGE + */ + public static final String EXPORT_XLS_FREEZE_ROW_EDGE = JRXlsAbstractExporter.PROPERTY_FREEZE_ROW_EDGE; + /** + * @see JRXlsAbstractExporter#PROPERTY_FREEZE_COLUMN_EDGE + */ + public static final String EXPORT_XLS_FREEZE_COLUMN_EDGE = JRXlsAbstractExporter.PROPERTY_FREEZE_COLUMN_EDGE; + /** + * @see JRXlsAbstractExporter#PROPERTY_BREAK_BEFORE_ROW + */ + public static final String EXPORT_XLS_BREAK_BEFORE_ROW = JRXlsAbstractExporter.PROPERTY_BREAK_BEFORE_ROW; + /** + * @see JRXlsAbstractExporter#PROPERTY_BREAK_AFTER_ROW + */ + public static final String EXPORT_XLS_BREAK_AFTER_ROW = JRXlsAbstractExporter.PROPERTY_BREAK_AFTER_ROW; + + // xls metadata + /** + * @see XlsMetadataReportConfiguration#PROPERTY_COLUMN_NAMES_PREFIX + */ + public static final String EXPORT_XLSMETADATA_COLUMN_NAMES_PREFIX = + XlsMetadataReportConfiguration.PROPERTY_COLUMN_NAMES_PREFIX; + /** + * @see XlsMetadataReportConfiguration#PROPERTY_WRITE_HEADER + */ + public static final String EXPORT_XLSMETADATA_WRITE_HEADER = XlsMetadataReportConfiguration.PROPERTY_WRITE_HEADER; + /** + * @see JRXlsAbstractMetadataExporter#PROPERTY_COLUMN_NAME + */ + public static final String EXPORT_XLSMETADATA_COLUMN_NAME = JRXlsAbstractMetadataExporter.PROPERTY_COLUMN_NAME; + /** + * @see JRXlsAbstractMetadataExporter#PROPERTY_REPEAT_VALUE + */ + public static final String EXPORT_XLSMETADATA_REPEAT_VALUE = JRXlsAbstractMetadataExporter.PROPERTY_REPEAT_VALUE; + /** + * @see JRXlsAbstractMetadataExporter#PROPERTY_DATA + */ + public static final String EXPORT_XLSMETADATA_DATA = JRXlsAbstractMetadataExporter.PROPERTY_DATA; + + // xml + /** + * @see PrintSaxParserFactory#EXPORT_XML_VALIDATION + */ + public static final String EXPORT_XML_VALIDATION = PrintSaxParserFactory.EXPORT_XML_VALIDATION; + + // csv + /** + * @see CsvExporterConfiguration#PROPERTY_FIELD_DELIMITER + */ + public static final String EXPORT_CSV_FIELD_DELIMITER = CsvExporterConfiguration.PROPERTY_FIELD_DELIMITER; + /** + * @see CsvExporterConfiguration#PROPERTY_RECORD_DELIMITER + */ + public static final String EXPORT_CSV_RECORD_DELIMITER = CsvExporterConfiguration.PROPERTY_RECORD_DELIMITER; + + // csv metadata + /** + * @see CsvMetadataReportConfiguration#PROPERTY_COLUMN_NAMES_PREFIX + */ + public static final String EXPORT_CSVMETADATA_COLUMN_NAMES_PREFIX = + CsvMetadataReportConfiguration.PROPERTY_COLUMN_NAMES_PREFIX; + /** + * @see CsvMetadataReportConfiguration#PROPERTY_WRITE_HEADER + */ + public static final String EXPORT_CSVMETADATA_WRITE_HEADER = CsvMetadataReportConfiguration.PROPERTY_WRITE_HEADER; + /** + * @see JRCsvMetadataExporter#PROPERTY_COLUMN_NAME + */ + public static final String EXPORT_CSVMETADATA_COLUMN_NAME = JRCsvMetadataExporter.PROPERTY_COLUMN_NAME; + /** + * @see JRCsvMetadataExporter#PROPERTY_REPEAT_VALUE + */ + public static final String EXPORT_CSVMETADATA_REPEAT_VALUE = JRCsvMetadataExporter.PROPERTY_REPEAT_VALUE; + /** + * @see JRCsvMetadataExporter#PROPERTY_DATA + */ + public static final String EXPORT_CSVMETADATA_DATA = JRCsvMetadataExporter.PROPERTY_DATA; + + // docx + /** + * @see JRDocxExporter#PROPERTY_HIDDEN_TEXT + */ + public static final String EXPORT_DOCX_HIDDEN_TEXT = JRDocxExporter.PROPERTY_HIDDEN_TEXT; + /** + * @see DocxReportConfiguration#PROPERTY_FRAMES_AS_NESTED_TABLES + */ + public static final String EXPORT_DOCX_FRAMES_AS_NESTED_TABLES = + DocxReportConfiguration.PROPERTY_FRAMES_AS_NESTED_TABLES; + /** + * @see DocxReportConfiguration#PROPERTY_FLEXIBLE_ROW_HEIGHT + */ + public static final String EXPORT_DOCX_FLEXIBLE_ROW_HEIGHT = DocxReportConfiguration.PROPERTY_FLEXIBLE_ROW_HEIGHT; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/PdfPermission.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/PdfPermission.java new file mode 100644 index 0000000..eec8de8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/PdfPermission.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.constant; + +/** + *

PdfPermission class.

+ * + * @author Ricardo Mariaca + * + */ +public enum PdfPermission { + PRINTING, MODIFY_CONTENTS, COPY, MODIFY_ANNOTATIONS, FILL_IN, SCREEN_READERS, ASSEMBLY, DEGRADED_PRINTING +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/PdfVersion.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/PdfVersion.java new file mode 100644 index 0000000..f2b8465 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/PdfVersion.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.constant; + +/** + *

PdfVersion class.

+ * + * @author Ricardo Mariaca + * + */ +public enum PdfVersion { + VERION_1_2, VERION_1_3, VERION_1_4, VERION_1_5, VERION_1_6, VERION_1_7 +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/SizeUnit.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/SizeUnit.java new file mode 100644 index 0000000..8ed0360 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/SizeUnit.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.constant; + +/** + *

SizeUnit class.

+ * + * @author Ricardo Mariaca + * + */ +public enum SizeUnit { + PIXEL, POINT +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/ValueType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/ValueType.java new file mode 100644 index 0000000..fadea55 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/constant/ValueType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.constant; + +/** + *

ValueType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum ValueType { + FIELD, VARIABLE, PARAMETER, SIMPLE_EXPRESSION, COMPLEX_EXPRESSION, SYSTEM_EXPRESSION +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/JasperReportHandler.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/JasperReportHandler.java new file mode 100644 index 0000000..1767ef5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/JasperReportHandler.java @@ -0,0 +1,55 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.JasperPrint; + +import java.util.List; + +/** + *

JasperReportHandler interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperReportHandler { + + /** + *

concatenate.

+ * + * @param jasperReportBuilders a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + */ + public void concatenate(JasperReportBuilder... jasperReportBuilders); + + /** + *

setContinuousPageNumbering.

+ * + * @param continuousPageNumbering a boolean. + */ + public void setContinuousPageNumbering(boolean continuousPageNumbering); + + /** + *

getPrintList.

+ * + * @return a {@link java.util.List} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public List getPrintList() throws DRException; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperICsvExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperICsvExporter.java new file mode 100644 index 0000000..eb3e132 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperICsvExporter.java @@ -0,0 +1,41 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +/** + *

JasperICsvExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperICsvExporter extends JasperIExporter { + + /** + *

getFieldDelimiter.

+ * + * @return a {@link java.lang.String} object. + */ + public String getFieldDelimiter(); + + /** + *

getRecordDelimiter.

+ * + * @return a {@link java.lang.String} object. + */ + public String getRecordDelimiter(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIDocxExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIDocxExporter.java new file mode 100644 index 0000000..03995c6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIDocxExporter.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +/** + *

JasperIDocxExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperIDocxExporter extends JasperIExporter { + + /** + *

getFramesAsNestedTables.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getFramesAsNestedTables(); + + /** + *

getFlexibleRowHeight.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getFlexibleRowHeight(); + + /** + *

getIgnoreHyperLink.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreHyperLink(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIExcelExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIExcelExporter.java new file mode 100644 index 0000000..d8017ab --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIExcelExporter.java @@ -0,0 +1,306 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +import software.xdev.dynamicreports.report.constant.ImageAnchorType; +import software.xdev.dynamicreports.report.constant.RunDirection; + +import java.util.List; +import java.util.Map; + +/** + *

JasperIExcelExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperIExcelExporter extends JasperIExporter { + + /** + *

getOnePagePerSheet.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getOnePagePerSheet(); + + /** + *

getRemoveEmptySpaceBetweenRows.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getRemoveEmptySpaceBetweenRows(); + + /** + *

getRemoveEmptySpaceBetweenColumns.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getRemoveEmptySpaceBetweenColumns(); + + /** + *

getWhitePageBackground.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getWhitePageBackground(); + + /** + *

getDetectCellType.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getDetectCellType(); + + /** + *

getSheetNames.

+ * + * @return a {@link java.util.List} object. + */ + public List getSheetNames(); + + /** + *

getFontSizeFixEnabled.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getFontSizeFixEnabled(); + + /** + *

getImageBorderFixEnabled.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getImageBorderFixEnabled(); + + /** + *

getMaxRowsPerSheet.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getMaxRowsPerSheet(); + + /** + *

getIgnoreGraphics.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreGraphics(); + + /** + *

getCollapseRowSpan.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getCollapseRowSpan(); + + /** + *

getIgnoreCellBorder.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreCellBorder(); + + /** + *

getIgnoreCellBackground.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreCellBackground(); + + /** + *

getPassword.

+ * + * @return a {@link java.lang.String} object. + */ + public String getPassword(); + + /** + *

getIgnorePageMargins.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnorePageMargins(); + + /** + *

getWrapText.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getWrapText(); + + /** + *

getCellLocked.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getCellLocked(); + + /** + *

getCellHidden.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getCellHidden(); + + /** + *

getSheetHeaderLeft.

+ * + * @return a {@link java.lang.String} object. + */ + public String getSheetHeaderLeft(); + + /** + *

getSheetHeaderCenter.

+ * + * @return a {@link java.lang.String} object. + */ + public String getSheetHeaderCenter(); + + /** + *

getSheetHeaderRight.

+ * + * @return a {@link java.lang.String} object. + */ + public String getSheetHeaderRight(); + + /** + *

getSheetFooterLeft.

+ * + * @return a {@link java.lang.String} object. + */ + public String getSheetFooterLeft(); + + /** + *

getSheetFooterCenter.

+ * + * @return a {@link java.lang.String} object. + */ + public String getSheetFooterCenter(); + + /** + *

getSheetFooterRight.

+ * + * @return a {@link java.lang.String} object. + */ + public String getSheetFooterRight(); + + /** + *

getFormatPatternsMap.

+ * + * @return a {@link java.util.Map} object. + */ + public Map getFormatPatternsMap(); + + /** + *

getIgnoreHyperLink.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreHyperLink(); + + /** + *

getIgnoreAnchors.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreAnchors(); + + /** + *

getFitWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getFitWidth(); + + /** + *

getFitHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getFitHeight(); + + /** + *

getPageScale.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageScale(); + + /** + *

getSheetDirection.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public RunDirection getSheetDirection(); + + /** + *

getColumnWidthRatio.

+ * + * @return a {@link java.lang.Float} object. + */ + public Float getColumnWidthRatio(); + + /** + *

getUseTimeZone.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getUseTimeZone(); + + /** + *

getFirstPageNumber.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getFirstPageNumber(); + + /** + *

getShowGridLines.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getShowGridLines(); + + /** + *

getImageAnchorType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ImageAnchorType} object. + */ + public ImageAnchorType getImageAnchorType(); + + /** + *

getCreateCustomPalette.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getCreateCustomPalette(); + + /** + *

getWorkbookTemplate.

+ * + * @return a {@link java.lang.String} object. + */ + public String getWorkbookTemplate(); + + /** + *

getKeepWorkbookTemplateSheets.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getKeepWorkbookTemplateSheets(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIExporter.java new file mode 100644 index 0000000..ac6709f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIExporter.java @@ -0,0 +1,103 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +import java.io.File; +import java.io.OutputStream; +import java.io.Serializable; +import java.io.Writer; + +/** + *

JasperIExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperIExporter extends Serializable { + + /** + *

getOutputWriter.

+ * + * @return a {@link java.io.Writer} object. + */ + public Writer getOutputWriter(); + + /** + *

getOutputStream.

+ * + * @return a {@link java.io.OutputStream} object. + */ + public OutputStream getOutputStream(); + + /** + *

getOutputFile.

+ * + * @return a {@link java.io.File} object. + */ + public File getOutputFile(); + + /** + *

getOutputFileName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getOutputFileName(); + + /** + *

getPageIndex.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageIndex(); + + /** + *

getStartPageIndex.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getStartPageIndex(); + + /** + *

getEndPageIndex.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getEndPageIndex(); + + /** + *

getCharacterEncoding.

+ * + * @return a {@link java.lang.String} object. + */ + public String getCharacterEncoding(); + + /** + *

getOffsetX.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getOffsetX(); + + /** + *

getOffsetY.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getOffsetY(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIHtmlExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIHtmlExporter.java new file mode 100644 index 0000000..71f28e9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIHtmlExporter.java @@ -0,0 +1,155 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +import software.xdev.dynamicreports.jasper.constant.SizeUnit; + +/** + *

JasperIHtmlExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperIHtmlExporter extends JasperIExporter { + + /** + *

getOutputImagesToDir.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getOutputImagesToDir(); + + /** + *

getImagesDirName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getImagesDirName(); + + /** + *

getImagesURI.

+ * + * @return a {@link java.lang.String} object. + */ + public String getImagesURI(); + + /** + *

getHtmlHeader.

+ * + * @return a {@link java.lang.String} object. + */ + public String getHtmlHeader(); + + /** + *

getBetweenPagesHtml.

+ * + * @return a {@link java.lang.String} object. + */ + public String getBetweenPagesHtml(); + + /** + *

getHtmlFooter.

+ * + * @return a {@link java.lang.String} object. + */ + public String getHtmlFooter(); + + /** + *

getRemoveEmptySpaceBetweenRows.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getRemoveEmptySpaceBetweenRows(); + + /** + *

getWhitePageBackground.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getWhitePageBackground(); + + /** + *

getUsingImagesToAlign.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getUsingImagesToAlign(); + + /** + *

getWrapBreakWord.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getWrapBreakWord(); + + /** + *

getSizeUnit.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.constant.SizeUnit} object. + */ + public SizeUnit getSizeUnit(); + + /** + *

getFramesAsNestedTables.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getFramesAsNestedTables(); + + /** + *

getIgnorePageMargins.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnorePageMargins(); + + /** + *

getBorderCollapse.

+ * + * @return a {@link java.lang.String} object. + */ + public String getBorderCollapse(); + + /** + *

getAccessibleHtml.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getAccessibleHtml(); + + /** + *

getZoomRatio.

+ * + * @return a {@link java.lang.Float} object. + */ + public Float getZoomRatio(); + + /** + *

getIgnoreHyperLink.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreHyperLink(); + + /** + *

getFlushOutput.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getFlushOutput(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIOdsExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIOdsExporter.java new file mode 100644 index 0000000..4ffe862 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIOdsExporter.java @@ -0,0 +1,34 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +/** + *

JasperIOdsExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperIOdsExporter extends JasperIExcelExporter { + + /** + *

getFlexibleRowHeight.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getFlexibleRowHeight(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIOdtExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIOdtExporter.java new file mode 100644 index 0000000..a0657c6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIOdtExporter.java @@ -0,0 +1,41 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +/** + *

JasperIOdtExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperIOdtExporter extends JasperIExporter { + + /** + *

getFlexibleRowHeight.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getFlexibleRowHeight(); + + /** + *

getIgnoreHyperLink.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreHyperLink(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIPdfExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIPdfExporter.java new file mode 100644 index 0000000..88e4dad --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIPdfExporter.java @@ -0,0 +1,223 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +import software.xdev.dynamicreports.jasper.constant.PdfPermission; +import software.xdev.dynamicreports.jasper.constant.PdfVersion; +import software.xdev.dynamicreports.report.constant.PdfPrintScaling; +import software.xdev.dynamicreports.report.constant.PdfaConformance; + +import java.util.List; + +/** + *

JasperIPdfExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperIPdfExporter extends JasperIExporter { + + /** + *

getCreatingBatchModeBookmarks.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getCreatingBatchModeBookmarks(); + + /** + *

getCompressed.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getCompressed(); + + /** + *

getEncrypted.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getEncrypted(); + + /** + *

getBitKey128.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getBitKey128(); + + /** + *

getUserPassword.

+ * + * @return a {@link java.lang.String} object. + */ + public String getUserPassword(); + + /** + *

getOwnerPassword.

+ * + * @return a {@link java.lang.String} object. + */ + public String getOwnerPassword(); + + /** + *

getPermissions.

+ * + * @return a {@link java.util.List} object. + */ + public List getPermissions(); + + /** + *

getPdfVersion.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.constant.PdfVersion} object. + */ + public PdfVersion getPdfVersion(); + + /** + *

getMetadataTitle.

+ * + * @return a {@link java.lang.String} object. + */ + public String getMetadataTitle(); + + /** + *

getMetadataAuthor.

+ * + * @return a {@link java.lang.String} object. + */ + public String getMetadataAuthor(); + + /** + *

getMetadataSubject.

+ * + * @return a {@link java.lang.String} object. + */ + public String getMetadataSubject(); + + /** + *

getMetadataKeyWords.

+ * + * @return a {@link java.lang.String} object. + */ + public String getMetadataKeyWords(); + + /** + *

getMetadataCreator.

+ * + * @return a {@link java.lang.String} object. + */ + public String getMetadataCreator(); + + /** + *

getForceSvgShapes.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getForceSvgShapes(); + + /** + *

getPdfJavaScript.

+ * + * @return a {@link java.lang.String} object. + */ + public String getPdfJavaScript(); + + /** + *

getTagged.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getTagged(); + + /** + *

getTagLanguage.

+ * + * @return a {@link java.lang.String} object. + */ + public String getTagLanguage(); + + /** + *

getCollapseMissingBookmarkLevels.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getCollapseMissingBookmarkLevels(); + + /** + *

getSizePageToContent.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getSizePageToContent(); + + /** + *

getIgnoreHyperLink.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreHyperLink(); + + /** + *

getForceLineBreakPolicy.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getForceLineBreakPolicy(); + + /** + *

getPrintScaling.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.PdfPrintScaling} object. + */ + public PdfPrintScaling getPrintScaling(); + + /** + *

getPdfaConformance.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.PdfaConformance} object. + */ + public PdfaConformance getPdfaConformance(); + + /** + *

getIccProfilePath.

+ * + * @return a {@link java.lang.String} object. + */ + public String getIccProfilePath(); + + /** + *

getAllowedPermissionsHint.

+ * + * @return a {@link java.lang.String} object. + */ + public String getAllowedPermissionsHint(); + + /** + *

getDeniedPermissionsHint.

+ * + * @return a {@link java.lang.String} object. + */ + public String getDeniedPermissionsHint(); + + /** + *

getDisplayMetadataTitle.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getDisplayMetadataTitle(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIPptxExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIPptxExporter.java new file mode 100644 index 0000000..a41d3db --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIPptxExporter.java @@ -0,0 +1,35 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +/** + *

JasperIPptxExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperIPptxExporter extends JasperIExporter { + + /** + *

getIgnoreHyperLink.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreHyperLink(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIRtfExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIRtfExporter.java new file mode 100644 index 0000000..6c7b278 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIRtfExporter.java @@ -0,0 +1,34 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +/** + *

JasperIRtfExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperIRtfExporter extends JasperIExporter { + + /** + *

getIgnoreHyperLink.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreHyperLink(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperITextExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperITextExporter.java new file mode 100644 index 0000000..bd63ae1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperITextExporter.java @@ -0,0 +1,76 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +/** + *

JasperITextExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperITextExporter extends JasperIExporter { + + /** + *

getCharacterWidth.

+ * + * @return a {@link java.lang.Float} object. + */ + public Float getCharacterWidth(); + + /** + *

getCharacterHeight.

+ * + * @return a {@link java.lang.Float} object. + */ + public Float getCharacterHeight(); + + /** + *

getPageWidthInChars.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageWidthInChars(); + + /** + *

getPageHeightInChars.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageHeightInChars(); + + /** + *

getPageSeparator.

+ * + * @return a {@link java.lang.String} object. + */ + public String getPageSeparator(); + + /** + *

getLineSeparator.

+ * + * @return a {@link java.lang.String} object. + */ + public String getLineSeparator(); + + /** + *

getTrimLineRight.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getTrimLineRight(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIXlsxExporter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIXlsxExporter.java new file mode 100644 index 0000000..05c68f0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/definition/export/JasperIXlsxExporter.java @@ -0,0 +1,34 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.definition.export; + +/** + *

JasperIXlsxExporter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperIXlsxExporter extends JasperIExcelExporter { + + /** + *

getMacroTemplate.

+ * + * @return a {@link java.lang.String} object. + */ + public String getMacroTemplate(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/exception/JasperDesignException.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/exception/JasperDesignException.java new file mode 100644 index 0000000..6da16df --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/exception/JasperDesignException.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.exception; + +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

JasperDesignException class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperDesignException extends RuntimeException { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperDesignException.

+ * + * @param message a {@link java.lang.String} object. + */ + public JasperDesignException(String message) { + super(message); + } + + /** + *

Constructor for JasperDesignException.

+ * + * @param message a {@link java.lang.String} object. + * @param cause a {@link java.lang.Throwable} object. + */ + public JasperDesignException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/AbstractExpressionTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/AbstractExpressionTransform.java new file mode 100644 index 0000000..e8888ca --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/AbstractExpressionTransform.java @@ -0,0 +1,429 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.DRIDesignField; +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; +import software.xdev.dynamicreports.design.definition.DRIDesignSort; +import software.xdev.dynamicreports.design.definition.DRIDesignVariable; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignJasperExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignParameterExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignPropertyExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSystemExpression; +import software.xdev.dynamicreports.jasper.base.JasperCustomValues; +import software.xdev.dynamicreports.jasper.constant.ValueType; +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import software.xdev.dynamicreports.report.constant.SystemExpression; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRGenericElementParameter; +import net.sf.jasperreports.engine.JRGroup; +import net.sf.jasperreports.engine.JRPropertyExpression; +import net.sf.jasperreports.engine.JRVariable; +import net.sf.jasperreports.engine.design.JRDesignExpression; +import net.sf.jasperreports.engine.design.JRDesignField; +import net.sf.jasperreports.engine.design.JRDesignGenericElementParameter; +import net.sf.jasperreports.engine.design.JRDesignPropertyExpression; +import net.sf.jasperreports.engine.design.JRDesignSortField; +import net.sf.jasperreports.engine.design.JRDesignVariable; +import net.sf.jasperreports.engine.type.SortFieldTypeEnum; + +import java.text.MessageFormat; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + *

Abstract AbstractExpressionTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractExpressionTransform { + private static final String VALUE = "$P'{'{0}'}'.getValue(\"{1}\")"; + private static final String FIELD_VALUE = "$F'{'{0}'}'"; + private static final String VARIABLE_VALUE = "$V'{'{0}'}'"; + private static final String PARAMETER_VALUE = "$P'{'{0}'}'"; + private static final String COMPLEX_VALUE = "$P'{'{0}'}'.getValue(\"{1}\", new Object[]'{'{2}'}')"; + + private Map expressions; + + /** + *

Constructor for AbstractExpressionTransform.

+ */ + public AbstractExpressionTransform() { + this.expressions = new HashMap(); + } + + /** + *

transform.

+ */ + public void transform() { + for (DRIDesignField field : getFields()) { + addField(field); + } + for (DRIDesignSystemExpression expression : getSystemExpressions()) { + addSystemExpression(expression); + } + for (DRIDesignJasperExpression expression : getJasperExpressions()) { + addJasperExpression(expression); + } + for (DRIDesignSimpleExpression expression : getSimpleExpressions()) { + addSimpleExpression(expression); + } + for (DRIDesignComplexExpression complexExpression : getComplexExpressions()) { + addComplexExpression(complexExpression); + } + for (DRIDesignVariable variable : getVariables()) { + addVariable(variable); + } + for (DRIDesignSort sort : getSorts()) { + addSort(sort); + } + } + + private void addSystemExpression(DRIDesignSystemExpression systemExpression) { + if (systemExpression == null) { + return; + } + getCustomValues().addValueType(systemExpression.getName(), ValueType.SYSTEM_EXPRESSION); + addExpression(systemExpression); + } + + private void addJasperExpression(DRIDesignJasperExpression jasperExpression) { + if (jasperExpression == null) { + return; + } + addExpression(jasperExpression); + } + + /** + *

addSimpleExpression.

+ * + * @param simpleExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression} object. + */ + protected void addSimpleExpression(DRIDesignSimpleExpression simpleExpression) { + if (simpleExpression == null) { + return; + } + getCustomValues().addSimpleExpression(simpleExpression); + addExpression(simpleExpression); + } + + private void addField(DRIDesignField field) { + try { + if (!field.isExternal()) { + addField(field(field)); + } + getCustomValues().addValueType(field.getName(), ValueType.FIELD); + addExpression(field); + } catch (JRException e) { + throw new JasperDesignException("Registration failed for field \"" + field.getName() + "\"", e); + } + } + + private void addVariable(DRIDesignVariable variable) { + try { + addVariable(variable(variable)); + getCustomValues().addValueType(variable.getName(), ValueType.VARIABLE); + addExpression(variable); + } catch (JRException e) { + throw new JasperDesignException("Registration failed for variable \"" + variable.getName() + "\"", e); + } + } + + /** + *

addComplexExpression.

+ * + * @param complexExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression} object. + */ + protected void addComplexExpression(DRIDesignComplexExpression complexExpression) { + if (complexExpression == null) { + return; + } + getCustomValues().addComplexExpression(complexExpression); + addExpression(complexExpression); + } + + private void addExpression(DRIDesignExpression expression) { + if (expressions.containsKey(expression.getName())) { + throw new JasperDesignException("Duplicate declaration of expression \"" + expression.getName() + "\""); + } + expressions.put(expression.getName(), expression(expression)); + } + + private void addSort(DRIDesignSort sort) { + try { + addSort(sort(sort)); + } catch (JRException e) { + throw new JasperDesignException("Registration failed for sort \"" + sort.getExpression().getName() + "\"", e); + } + } + + // field + private JRDesignField field(DRIDesignField field) { + JRDesignField jrField = new JRDesignField(); + jrField.setName(field.getName()); + jrField.setValueClass(field.getValueClass()); + jrField.setDescription(field.getDescription()); + return jrField; + } + + // variable + private JRDesignVariable variable(DRIDesignVariable variable) { + JRDesignExpression expression = getExpression(variable.getValueExpression()); + JRDesignExpression initialValueExpression = getExpression(variable.getInitialValueExpression()); + + JRDesignVariable jrVariable = new JRDesignVariable(); + jrVariable.setName(variable.getName()); + jrVariable.setExpression(expression); + jrVariable.setInitialValueExpression(initialValueExpression); + jrVariable.setValueClass(variable.getValueClass()); + jrVariable.setCalculation(ConstantTransform.calculation(variable.getCalculation())); + ResetType resetType = variable.getResetType(); + jrVariable.setResetType(ConstantTransform.variableResetType(resetType)); + if (resetType.equals(ResetType.GROUP) && variable.getResetGroup() != null) { + jrVariable.setResetGroup(getGroup(variable.getResetGroup())); + } + return jrVariable; + } + + /** + *

getGroup.

+ * + * @param group a {@link software.xdev.dynamicreports.design.definition.DRIDesignGroup} object. + * @return a {@link net.sf.jasperreports.engine.JRGroup} object. + */ + protected JRGroup getGroup(DRIDesignGroup group) { + return null; + } + + // simple expression + private JRDesignExpression expression(DRIDesignExpression simpleExpression) { + JRDesignExpression expression = new JRDesignExpression(); + expression.setText(getExpressionText(simpleExpression)); + return expression; + } + + private String getExpressionText(DRIDesignExpression expression) { + if (expression instanceof DRIDesignField) { + return toFieldValue(expression.getName()); + } else if (expression instanceof DRIDesignVariable) { + return toVariableValue(expression.getName()); + } else if (expression instanceof DRIDesignComplexExpression) { + DRIDesignComplexExpression complexExpression = (DRIDesignComplexExpression) expression; + String values = ""; + for (DRIDesignExpression valueExpression : complexExpression.getExpressions()) { + values += ", " + getExpressionText(valueExpression); + } + if (values.length() > 0) { + values = values.substring(2); + } + String parameterName = getExpressionParameterName(complexExpression.getParameterName()); + return MessageFormat.format(COMPLEX_VALUE, parameterName, expression.getName(), values); + } else if (expression instanceof DRIDesignSimpleExpression) { + String parameterName = getExpressionParameterName(((DRIDesignSimpleExpression) expression).getParameterName()); + return MessageFormat.format(VALUE, parameterName, expression.getName()); + } else if (expression instanceof DRIDesignSystemExpression) { + String name = ((DRIDesignSystemExpression) expression).getName(); + if (name.equals(SystemExpression.PAGE_NUMBER.name())) { + return toVariableValue(JRVariable.PAGE_NUMBER); + } else { + return toVariableValue(name); + } + // throw new JasperDesignException("System expression \"" + name + "\" not supported"); + } else if (expression instanceof DRIDesignJasperExpression) { + return ((DRIDesignJasperExpression) expression).getExpression(); + } else { + throw new JasperDesignException("Expression " + expression.getClass().getName() + " not supported"); + } + } + + private String getExpressionParameterName(String parameterName) { + if (parameterName == null) { + return JasperCustomValues.NAME; + } else { + return parameterName; + } + } + + private String toFieldValue(String expression) { + return MessageFormat.format(FIELD_VALUE, expression); + } + + private String toVariableValue(String expression) { + return MessageFormat.format(VARIABLE_VALUE, expression); + } + + /** + *

toParameterValue.

+ * + * @param expression a {@link java.lang.String} object. + * @return a {@link java.lang.String} object. + */ + protected String toParameterValue(String expression) { + return MessageFormat.format(PARAMETER_VALUE, expression); + } + + /** + *

getExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + * @return a {@link net.sf.jasperreports.engine.design.JRDesignExpression} object. + */ + public JRDesignExpression getExpression(DRIDesignExpression expression) { + if (expression == null) { + return null; + } + if (!expressions.containsKey(expression.getName())) { + throw new JasperDesignException("Expression \"" + expression.getName() + "\" is not registered"); + } + return expressions.get(expression.getName()); + } + + // sort + private JRDesignSortField sort(DRIDesignSort sort) { + DRIDesignExpression expression = sort.getExpression(); + String name; + SortFieldTypeEnum type; + if (expression instanceof DRIDesignField) { + name = expression.getName(); + type = SortFieldTypeEnum.FIELD; + } else if (expression instanceof DRIDesignVariable) { + name = expression.getName(); + type = SortFieldTypeEnum.VARIABLE; + } else { + throw new JasperDesignException("Sort expression \"" + expression.getName() + "\" not supported"); + } + + JRDesignSortField jrSort = new JRDesignSortField(); + jrSort.setName(name); + jrSort.setOrder(ConstantTransform.orderType(sort.getOrderType())); + jrSort.setType(type); + return jrSort; + } + + /** + *

getPropertyExpression.

+ * + * @param propertyExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignPropertyExpression} object. + * @return a {@link net.sf.jasperreports.engine.JRPropertyExpression} object. + */ + protected JRPropertyExpression getPropertyExpression(DRIDesignPropertyExpression propertyExpression) { + JRDesignPropertyExpression jrPropertyExpression = new JRDesignPropertyExpression(); + jrPropertyExpression.setName(propertyExpression.getName()); + jrPropertyExpression.setValueExpression(getExpression(propertyExpression.getValueExpression())); + return jrPropertyExpression; + } + + /** + *

getGenericElementParameterExpression.

+ * + * @param parameterExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignParameterExpression} object. + * @return a {@link net.sf.jasperreports.engine.JRGenericElementParameter} object. + */ + protected JRGenericElementParameter getGenericElementParameterExpression(DRIDesignParameterExpression parameterExpression) { + JRDesignGenericElementParameter jrParameterExpression = new JRDesignGenericElementParameter(); + jrParameterExpression.setName(parameterExpression.getName()); + jrParameterExpression.setValueExpression(getExpression(parameterExpression.getValueExpression())); + return jrParameterExpression; + } + + /** + *

getCustomValues.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.base.JasperCustomValues} object. + */ + protected abstract JasperCustomValues getCustomValues(); + + /** + *

getFields.

+ * + * @return a {@link java.util.Collection} object. + */ + protected abstract Collection getFields(); + + /** + *

getVariables.

+ * + * @return a {@link java.util.Collection} object. + */ + protected abstract Collection getVariables(); + + /** + *

getSystemExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + protected abstract Collection getSystemExpressions(); + + /** + *

getJasperExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + protected abstract Collection getJasperExpressions(); + + /** + *

getSimpleExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + protected abstract Collection getSimpleExpressions(); + + /** + *

getComplexExpressions.

+ * + * @return a {@link java.util.Collection} object. + */ + protected abstract Collection getComplexExpressions(); + + /** + *

getSorts.

+ * + * @return a {@link java.util.Collection} object. + */ + protected abstract Collection getSorts(); + + /** + *

addField.

+ * + * @param field a {@link net.sf.jasperreports.engine.design.JRDesignField} object. + * @throws net.sf.jasperreports.engine.JRException if any. + */ + protected abstract void addField(JRDesignField field) throws JRException; + + /** + *

addVariable.

+ * + * @param variable a {@link net.sf.jasperreports.engine.design.JRDesignVariable} object. + * @throws net.sf.jasperreports.engine.JRException if any. + */ + protected abstract void addVariable(JRDesignVariable variable) throws JRException; + + /** + *

addSort.

+ * + * @param sort a {@link net.sf.jasperreports.engine.design.JRDesignSortField} object. + * @throws net.sf.jasperreports.engine.JRException if any. + */ + protected abstract void addSort(JRDesignSortField sort) throws JRException; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/BandTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/BandTransform.java new file mode 100644 index 0000000..84db535 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/BandTransform.java @@ -0,0 +1,144 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import software.xdev.dynamicreports.design.definition.DRIDesignBand; +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; +import software.xdev.dynamicreports.design.definition.DRIDesignReport; +import software.xdev.dynamicreports.design.definition.DRIDesignTemplateDesign; +import software.xdev.dynamicreports.report.constant.ListType; +import net.sf.jasperreports.engine.JRElement; +import net.sf.jasperreports.engine.design.JRDesignBand; +import net.sf.jasperreports.engine.design.JRDesignElement; +import net.sf.jasperreports.engine.design.JRDesignSection; +import net.sf.jasperreports.engine.design.JasperDesign; + +/** + *

BandTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class BandTransform { + private JasperTransformAccessor accessor; + + /** + *

Constructor for BandTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.jasper.transformation.JasperTransformAccessor} object. + */ + public BandTransform(JasperTransformAccessor accessor) { + this.accessor = accessor; + } + + /** + *

transform.

+ */ + public void transform() { + DRIDesignReport report = accessor.getReport(); + JasperDesign design = accessor.getDesign(); + DRIDesignTemplateDesign templateDesign = report.getTemplateDesign(); + + if (templateDesign.getTitleComponentsCount() == 0 && report.getTitleBand() != null) { + design.setTitle(band(report.getTitleBand())); + } + if (templateDesign.getPageHeaderComponentsCount() == 0 && report.getPageHeaderBand() != null) { + design.setPageHeader(band(report.getPageHeaderBand())); + } + if (templateDesign.getPageFooterComponentsCount() == 0 && report.getPageFooterBand() != null) { + design.setPageFooter(band(report.getPageFooterBand())); + } + if (templateDesign.getColumnHeaderComponentsCount() == 0 && report.getColumnHeaderBand() != null) { + design.setColumnHeader(band(report.getColumnHeaderBand())); + } + if (templateDesign.getColumnFooterComponentsCount() == 0 && report.getColumnFooterBand() != null) { + design.setColumnFooter(band(report.getColumnFooterBand())); + } + for (DRIDesignGroup group : report.getGroups()) { + if (group.getHeaderBands() != null) { + JRDesignBand jrTitleAndValueBand = null; + for (DRIDesignBand band : group.getHeaderBands()) { + JRDesignBand jrBand = band(band); + if (band.getName() != null && band.getName().equals("groupHeaderTitleAndValue")) { + jrTitleAndValueBand = jrBand; + } + if (jrBand != null) { + if (band.getName() != null && band.getName().equals("subtotalGroupHeader") && jrTitleAndValueBand != null && group.isHeaderWithSubtotal()) { + if (jrTitleAndValueBand.getHeight() < jrBand.getHeight()) { + jrTitleAndValueBand.setHeight(jrBand.getHeight()); + } + for (JRElement jrElement : jrBand.getElements()) { + jrTitleAndValueBand.addElement(jrElement); + } + continue; + } + ((JRDesignSection) accessor.getGroupTransform().getGroup(group).getGroupHeaderSection()).addBand(jrBand); + } + } + } + if (group.getFooterBands() != null) { + for (DRIDesignBand band : group.getFooterBands()) { + JRDesignBand jrBand = band(band); + if (jrBand != null) { + ((JRDesignSection) accessor.getGroupTransform().getGroup(group).getGroupFooterSection()).addBand(jrBand); + } + } + } + } + for (DRIDesignBand band : report.getDetailBands()) { + JRDesignBand jrBand = band(band); + if (jrBand != null) { + ((JRDesignSection) design.getDetailSection()).addBand(jrBand); + } + } + if (templateDesign.getLastPageFooterComponentsCount() == 0 && report.getLastPageFooterBand() != null) { + design.setLastPageFooter(band(report.getLastPageFooterBand())); + } + if (templateDesign.getSummaryComponentsCount() == 0 && report.getSummaryBand() != null) { + design.setSummary(band(report.getSummaryBand())); + } + if (templateDesign.getNoDataComponentsCount() == 0 && report.getNoDataBand() != null) { + design.setNoData(band(report.getNoDataBand())); + } + if (templateDesign.getBackgroundComponentsCount() == 0 && report.getBackgroundBand() != null) { + design.setBackground(band(report.getBackgroundBand())); + } + } + + // band + private JRDesignBand band(DRIDesignBand band) { + if (band == null) { + return null; + } + JRDesignBand jrBand = new JRDesignBand(); + if (band.getBandComponent() != null) { + if (band.getPrintWhenExpression() != null) { + jrBand.setPrintWhenExpression(accessor.getExpressionTransform().getExpression(band.getPrintWhenExpression())); + } else { + jrBand.setPrintWhenExpression(accessor.getExpressionTransform().getExpression(band.getBandComponent().getPrintWhenExpression())); + } + jrBand.setSplitType(ConstantTransform.splitType(band.getSplitType())); + JRDesignElement[] jrElements = accessor.getComponentTransform().component(band.getBandComponent(), ListType.VERTICAL); + for (JRDesignElement jrElement : jrElements) { + jrBand.addElement(jrElement); + } + } + jrBand.setHeight(band.getHeight()); + return jrBand; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ComponentTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ComponentTransform.java new file mode 100644 index 0000000..1af5e28 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ComponentTransform.java @@ -0,0 +1,462 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; + +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.design.constant.EvaluationTime; +import software.xdev.dynamicreports.design.definition.DRIDesignHyperLink; +import software.xdev.dynamicreports.design.definition.DRIDesignTableOfContentsHeading; +import software.xdev.dynamicreports.design.definition.component.DRIDesignBreak; +import software.xdev.dynamicreports.design.definition.component.DRIDesignComponent; +import software.xdev.dynamicreports.design.definition.component.DRIDesignEllipse; +import software.xdev.dynamicreports.design.definition.component.DRIDesignFiller; +import software.xdev.dynamicreports.design.definition.component.DRIDesignGenericElement; +import software.xdev.dynamicreports.design.definition.component.DRIDesignImage; +import software.xdev.dynamicreports.design.definition.component.DRIDesignLine; +import software.xdev.dynamicreports.design.definition.component.DRIDesignList; +import software.xdev.dynamicreports.design.definition.component.DRIDesignMap; +import software.xdev.dynamicreports.design.definition.component.DRIDesignRectangle; +import software.xdev.dynamicreports.design.definition.component.DRIDesignSubreport; +import software.xdev.dynamicreports.design.definition.component.DRIDesignTextField; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstab; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignParameterExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignPropertyExpression; +import software.xdev.dynamicreports.design.exception.DRDesignReportException; +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import software.xdev.dynamicreports.jasper.transformation.expression.JasperSubreportParametersExpression; +import software.xdev.dynamicreports.jasper.transformation.expression.SubreportExpression; +import software.xdev.dynamicreports.jasper.transformation.expression.SubreportParametersExpression; +import software.xdev.dynamicreports.jasper.transformation.expression.SubreportWidthExpression; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.component.CustomComponentTransform; +import software.xdev.dynamicreports.report.component.CustomComponents; +import software.xdev.dynamicreports.report.component.DRIDesignCustomComponent; +import software.xdev.dynamicreports.report.constant.ComponentPositionType; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.StretchType; +import net.sf.jasperreports.components.ComponentsExtensionsRegistryFactory; +import net.sf.jasperreports.components.map.StandardMapComponent; +import net.sf.jasperreports.engine.JRGenericElementType; +import net.sf.jasperreports.engine.component.ComponentKey; +import net.sf.jasperreports.engine.design.JRDesignBreak; +import net.sf.jasperreports.engine.design.JRDesignComponentElement; +import net.sf.jasperreports.engine.design.JRDesignElement; +import net.sf.jasperreports.engine.design.JRDesignEllipse; +import net.sf.jasperreports.engine.design.JRDesignFrame; +import net.sf.jasperreports.engine.design.JRDesignGenericElement; +import net.sf.jasperreports.engine.design.JRDesignImage; +import net.sf.jasperreports.engine.design.JRDesignLine; +import net.sf.jasperreports.engine.design.JRDesignRectangle; +import net.sf.jasperreports.engine.design.JRDesignStaticText; +import net.sf.jasperreports.engine.design.JRDesignStyle; +import net.sf.jasperreports.engine.design.JRDesignSubreport; +import net.sf.jasperreports.engine.design.JRDesignTextField; +import net.sf.jasperreports.engine.type.HyperlinkTargetEnum; +import net.sf.jasperreports.engine.type.HyperlinkTypeEnum; +import net.sf.jasperreports.engine.type.OnErrorTypeEnum; + +/** + *

ComponentTransform class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class ComponentTransform { + private final JasperTransformAccessor accessor; + + /** + *

Constructor for ComponentTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.jasper.transformation.JasperTransformAccessor} object. + */ + public ComponentTransform(final JasperTransformAccessor accessor) { + this.accessor = accessor; + } + + /** + *

component.

+ * + * @param component a {@link software.xdev.dynamicreports.design.definition.component.DRIDesignComponent} object. + * @param listType a {@link software.xdev.dynamicreports.report.constant.ListType} object. + * @return an array of {@link net.sf.jasperreports.engine.design.JRDesignElement} objects. + */ + protected JRDesignElement[] component(final DRIDesignComponent component, final ListType listType) { + final JRDesignElement[] jrElements; + if (component instanceof DRIDesignList) { + jrElements = this.list((DRIDesignList) component); + } else if (component instanceof DRIDesignTextField) { + final JRDesignElement jrElement = this.textField((DRIDesignTextField) component); + jrElements = this.component(jrElement, component, listType); + } else if (component instanceof DRIDesignFiller) { + final JRDesignElement jrElement = this.filler((DRIDesignFiller) component); + jrElements = this.component(jrElement, component, listType); + } else if (component instanceof DRIDesignImage) { + final JRDesignElement jrElement = this.image((DRIDesignImage) component); + jrElements = this.component(jrElement, component, listType); + } else if (component instanceof DRIDesignSubreport) { + final JRDesignElement jrElement = this.subreport((DRIDesignSubreport) component, component.getWidth()); + jrElements = this.component(jrElement, component, listType); + } else if (component instanceof DRIDesignLine) { + final JRDesignElement jrElement = this.line((DRIDesignLine) component); + jrElements = this.component(jrElement, component, listType); + } else if (component instanceof DRIDesignEllipse) { + final JRDesignElement jrElement = this.ellipse((DRIDesignEllipse) component); + jrElements = this.component(jrElement, component, listType); + } else if (component instanceof DRIDesignRectangle) { + final JRDesignElement jrElement = this.rectangle((DRIDesignRectangle) component); + jrElements = this.component(jrElement, component, listType); + } else if (component instanceof DRIDesignBreak) { + final JRDesignElement jrElement = this.breakComponent((DRIDesignBreak) component); + jrElements = this.component(jrElement, component, listType); + } else if (component instanceof DRIDesignGenericElement) { + final JRDesignElement jrElement = this.genericElement((DRIDesignGenericElement) component); + jrElements = this.component(jrElement, component, listType); + } else if (component instanceof DRIDesignCrosstab) { + final JRDesignElement jrElement = + this.accessor.getCrosstabTransform().transform((DRIDesignCrosstab) component); + jrElements = this.component(jrElement, component, listType); + } else if (component instanceof DRIDesignMap) { + final JRDesignElement jrElement = this.map((DRIDesignMap) component); + jrElements = this.component(jrElement, component, listType); + } else if (component instanceof DRIDesignCustomComponent) { + final JRDesignElement jrElement = this.customComponent(component); + jrElements = this.component(jrElement, component, listType); + } else { + throw new JasperDesignException("Component " + component.getClass().getName() + " not supported"); + } + + return jrElements; + } + + private JRDesignElement[] component(final JRDesignElement jrElement, final DRIDesignComponent component, final ListType listType) { + StretchType stretchType = component.getStretchType(); + if (stretchType == null) { + if (component instanceof DRIDesignSubreport || component instanceof DRIDesignLine || component instanceof DRIDesignBreak || component instanceof DRIDesignCrosstab || + component instanceof DRIDesignList) { + stretchType = StretchType.NO_STRETCH; + } else { + stretchType = this.detectStretchType(listType); + } + } + + ComponentPositionType positionType = component.getPositionType(); + if (positionType == null) { + positionType = ComponentPositionType.FLOAT; + } + + jrElement.setPositionType(ConstantTransform.componentPositionType(positionType)); + jrElement.setStretchType(ConstantTransform.stretchType(stretchType)); + jrElement.setPrintInFirstWholeBand(component.isPrintInFirstWholeBand()); + jrElement.setPrintWhenDetailOverflows(component.isPrintWhenDetailOverflows()); + if (component.getPrintWhenGroupChanges() != null) { + jrElement.setPrintWhenGroupChanges(this.accessor.getGroupTransform().getGroup(component.getPrintWhenGroupChanges())); + } + jrElement.setKey(component.getUniqueName()); + jrElement.setX(component.getX()); + jrElement.setY(component.getY()); + jrElement.setWidth(component.getWidth()); + jrElement.setHeight(component.getHeight()); + + if (component.getStyle() != null) { + jrElement.setStyle(this.accessor.getStyleTransform().getStyle(component.getStyle())); + } + jrElement.setPrintWhenExpression(this.accessor.getExpressionTransform().getExpression(component.getPrintWhenExpression())); + jrElement.setRemoveLineWhenBlank(component.isRemoveLineWhenBlank()); + + for (final DRIDesignPropertyExpression propertyExpression : component.getPropertyExpressions()) { + jrElement.addPropertyExpression(this.accessor.getExpressionTransform().getPropertyExpression(propertyExpression)); + } + + final DRIDesignTableOfContentsHeading tocHeading = component.getTableOfContentsHeading(); + if (tocHeading != null) { + final DRDesignTextField referenceField = (DRDesignTextField) tocHeading.getReferenceField(); + referenceField.setX(component.getX()); + referenceField.setY(component.getY()); + final JRDesignElement jrReferenceElement = this.textField(referenceField); + this.component(jrReferenceElement, referenceField, listType); + return new JRDesignElement[] {jrReferenceElement, jrElement}; + } else { + return new JRDesignElement[] {jrElement}; + } + } + + private StretchType detectStretchType(final ListType listType) { + if (listType == null || listType.equals(ListType.VERTICAL)) { + return StretchType.NO_STRETCH; + } + + return StretchType.ELEMENT_GROUP_HEIGHT; + } + + // list + private JRDesignElement[] list(final DRIDesignList list) { + switch (list.getComponentGroupType()) { + case FRAME: + final JRDesignFrame frame = new JRDesignFrame(); + final JRDesignElement[] jrElems = this.component(frame, list, list.getType()); + + final DRDesignComponent background = (DRDesignComponent) list.getBackgroundComponent(); + if (background != null) { + final JRDesignElement jrBackground = this.component(background, list.getType())[0]; + frame.addElement(jrBackground); + } + + for (final DRIDesignComponent element : list.getComponents()) { + final JRDesignElement[] jrElements = this.component(element, list.getType()); + for (final JRDesignElement jrElement : jrElements) { + frame.addElement(jrElement); + } + } + return jrElems; + case NONE: + final List jrElementList = new ArrayList<>(); + for (final DRIDesignComponent element : list.getComponents()) { + final JRDesignElement[] jrElements = this.component(element, list.getType()); + for (final JRDesignElement jrElement : jrElements) { + jrElementList.add(jrElement); + } + } + return jrElementList.toArray(new JRDesignElement[jrElementList.size()]); + default: + throw new JasperDesignException("ComponentGroupType " + list.getComponentGroupType().getClass().getName() + " not supported"); + } + } + + // textField + private JRDesignElement textField(final DRIDesignTextField textField) { + final JRDesignTextField jrTextField = new JRDesignTextField(); + + jrTextField.setAnchorNameExpression(this.accessor.getExpressionTransform().getExpression(textField.getAnchorNameExpression())); + if (textField.getBookmarkLevel() != null) { + jrTextField.setBookmarkLevel(textField.getBookmarkLevel()); + } + + final DRIDesignHyperLink hyperLink = textField.getHyperLink(); + if (hyperLink != null) { + jrTextField.setHyperlinkAnchorExpression(this.accessor.getExpressionTransform().getExpression(hyperLink.getAnchorExpression())); + jrTextField.setHyperlinkPageExpression(this.accessor.getExpressionTransform().getExpression(hyperLink.getPageExpression())); + jrTextField.setHyperlinkReferenceExpression(this.accessor.getExpressionTransform().getExpression(hyperLink.getReferenceExpression())); + jrTextField.setHyperlinkTooltipExpression(this.accessor.getExpressionTransform().getExpression(hyperLink.getTooltipExpression())); + if (hyperLink.getType() != null) { + final HyperlinkTypeEnum hyperLinkType = ConstantTransform.hyperLinkType(hyperLink.getType()); + if (hyperLinkType != null) { + jrTextField.setHyperlinkType(hyperLinkType); + } else { + jrTextField.setLinkType(hyperLink.getType()); + } + } + if (hyperLink.getTarget() != null) { + final HyperlinkTargetEnum hyperLinkTarget = ConstantTransform.hyperLinkTarget(hyperLink.getTarget()); + if (hyperLinkTarget != null) { + jrTextField.setHyperlinkTarget(hyperLinkTarget); + } else { + jrTextField.setLinkTarget(hyperLink.getTarget()); + } + } + } + + final EvaluationTime evaluationTime = textField.getEvaluationTime(); + jrTextField.setEvaluationTime(ConstantTransform.evaluationTime(evaluationTime)); + if (evaluationTime != null && evaluationTime.equals(EvaluationTime.GROUP) && textField.getEvaluationGroup() != null) { + jrTextField.setEvaluationGroup(this.accessor.getGroupTransform().getGroup(textField.getEvaluationGroup())); + } + + if (textField.getTextAdjust() != null) { + jrTextField.setTextAdjust(ConstantTransform.textAdjust(textField.getTextAdjust())); + } else { + jrTextField.setStretchWithOverflow(textField.isStretchWithOverflow()); + } + + final String pattern = textField.getPattern(); + if (!StringUtils.isBlank(pattern)) { + jrTextField.setPattern(pattern); + } + jrTextField.setPatternExpression(this.accessor.getExpressionTransform().getExpression(textField.getPatternExpression())); + jrTextField.setHorizontalTextAlign(ConstantTransform.horizontalTextAlignment(textField.getHorizontalTextAlignment())); + jrTextField.setExpression(this.accessor.getExpressionTransform().getExpression(textField.getValueExpression())); + jrTextField.setPrintRepeatedValues(textField.isPrintRepeatedValues()); + jrTextField.setMarkup(ConstantTransform.markup(textField.getMarkup())); + jrTextField.setBlankWhenNull(true); + + return jrTextField; + } + + // filler + private JRDesignElement filler(final DRIDesignFiller filler) { + final JRDesignStaticText jrDesignStaticText = new JRDesignStaticText(); + return jrDesignStaticText; + } + + // image + private JRDesignElement image(final DRIDesignImage image) { + final JRDesignImage jrImage = new JRDesignImage(new JRDesignStyle().getDefaultStyleProvider()); + + jrImage.setAnchorNameExpression(this.accessor.getExpressionTransform().getExpression(image.getAnchorNameExpression())); + if (image.getBookmarkLevel() != null) { + jrImage.setBookmarkLevel(image.getBookmarkLevel()); + } + + final DRIDesignHyperLink hyperLink = image.getHyperLink(); + if (hyperLink != null) { + jrImage.setHyperlinkAnchorExpression(this.accessor.getExpressionTransform().getExpression(hyperLink.getAnchorExpression())); + jrImage.setHyperlinkPageExpression(this.accessor.getExpressionTransform().getExpression(hyperLink.getPageExpression())); + jrImage.setHyperlinkReferenceExpression(this.accessor.getExpressionTransform().getExpression(hyperLink.getReferenceExpression())); + jrImage.setHyperlinkTooltipExpression(this.accessor.getExpressionTransform().getExpression(hyperLink.getTooltipExpression())); + if (hyperLink.getType() != null) { + final HyperlinkTypeEnum hyperLinkType = ConstantTransform.hyperLinkType(hyperLink.getType()); + if (hyperLinkType != null) { + jrImage.setHyperlinkType(hyperLinkType); + } else { + jrImage.setLinkType(hyperLink.getType()); + } + } + if (hyperLink.getTarget() != null) { + final HyperlinkTargetEnum hyperLinkTarget = ConstantTransform.hyperLinkTarget(hyperLink.getTarget()); + if (hyperLinkTarget != null) { + jrImage.setHyperlinkTarget(hyperLinkTarget); + } else { + jrImage.setLinkTarget(hyperLink.getTarget()); + } + } + } + + jrImage.setOnErrorType(OnErrorTypeEnum.BLANK); + jrImage.setScaleImage(ConstantTransform.imageScale(image.getImageScale())); + jrImage.setHorizontalImageAlign(ConstantTransform.horizontalImageAlignment(image.getHorizontalImageAlignment())); + jrImage.setExpression(this.accessor.getExpressionTransform().getExpression(image.getImageExpression())); + if (image.getUsingCache() != null) { + jrImage.setUsingCache(image.getUsingCache()); + } + if (image.getLazy() != null) { + jrImage.setLazy(image.getLazy()); + } + + return jrImage; + } + + // subreport + private JRDesignElement subreport(final DRIDesignSubreport subreport, final Integer width) { + final JRDesignSubreport jrSubreport = new JRDesignSubreport(new JRDesignStyle().getDefaultStyleProvider()); + jrSubreport.setConnectionExpression(this.accessor.getExpressionTransform().getExpression(subreport.getConnectionExpression())); + jrSubreport.setDataSourceExpression(this.accessor.getExpressionTransform().getExpression(subreport.getDataSourceExpression())); + jrSubreport.setRunToBottom(subreport.getRunToBottom()); + + if (ReportBuilder.class.isAssignableFrom(subreport.getReportExpression().getValueClass())) { + final SubreportWidthExpression pageWidthExpression = new SubreportWidthExpression(width); + this.accessor.getExpressionTransform().addSimpleExpression(pageWidthExpression); + final SubreportExpression subreportExpression = new SubreportExpression(pageWidthExpression, subreport.getReportExpression(), width); + this.accessor.getExpressionTransform().addComplexExpression(subreportExpression); + jrSubreport.setExpression(this.accessor.getExpressionTransform().getExpression(subreportExpression)); + + final SubreportParametersExpression parametersExpression = new SubreportParametersExpression(subreportExpression, subreport.getParametersExpression()); + this.accessor.getExpressionTransform().addComplexExpression(parametersExpression); + jrSubreport.setParametersMapExpression(this.accessor.getExpressionTransform().getExpression(parametersExpression)); + } else { + jrSubreport.setExpression(this.accessor.getExpressionTransform().getExpression(subreport.getReportExpression())); + + final JasperSubreportParametersExpression parametersExpression = new JasperSubreportParametersExpression(subreport.getParametersExpression()); + this.accessor.getExpressionTransform().addComplexExpression(parametersExpression); + jrSubreport.setParametersMapExpression(this.accessor.getExpressionTransform().getExpression(parametersExpression)); + } + + return jrSubreport; + } + + // line + private JRDesignElement line(final DRIDesignLine line) { + final JRDesignLine jrDesignLine = new JRDesignLine(); + jrDesignLine.setDirection(ConstantTransform.lineDirection(line.getDirection())); + this.accessor.getStyleTransform().pen(jrDesignLine.getLinePen(), line.getPen()); + return jrDesignLine; + } + + // ellipse + private JRDesignElement ellipse(final DRIDesignEllipse ellipse) { + final JRDesignEllipse jrDesignEllipse = new JRDesignEllipse(new JRDesignStyle().getDefaultStyleProvider()); + this.accessor.getStyleTransform().pen(jrDesignEllipse.getLinePen(), ellipse.getPen()); + return jrDesignEllipse; + } + + // rectangle + private JRDesignElement rectangle(final DRIDesignRectangle rectangle) { + final JRDesignRectangle jrDesignRectangle = new JRDesignRectangle(); + jrDesignRectangle.setRadius(rectangle.getRadius()); + this.accessor.getStyleTransform().pen(jrDesignRectangle.getLinePen(), rectangle.getPen()); + return jrDesignRectangle; + } + + // break + private JRDesignElement breakComponent(final DRIDesignBreak breakComponent) { + final JRDesignBreak jrDesignBreak = new JRDesignBreak(); + jrDesignBreak.setType(ConstantTransform.breakType(breakComponent.getType())); + return jrDesignBreak; + } + + // generic element + private JRDesignElement genericElement(final DRIDesignGenericElement genericElement) { + final JRDesignGenericElement jrDesignGenericElement = new JRDesignGenericElement(new JRDesignStyle().getDefaultStyleProvider()); + final JRGenericElementType genericType = new JRGenericElementType(genericElement.getGenericElementNamespace(), genericElement.getGenericElementName()); + jrDesignGenericElement.setGenericType(genericType); + final EvaluationTime evaluationTime = genericElement.getEvaluationTime(); + jrDesignGenericElement.setEvaluationTime(ConstantTransform.evaluationTime(evaluationTime)); + if (evaluationTime != null && evaluationTime.equals(EvaluationTime.GROUP) && genericElement.getEvaluationGroup() != null) { + jrDesignGenericElement.setEvaluationGroupName(this.accessor.getGroupTransform().getGroup(genericElement.getEvaluationGroup()).getName()); + } + for (final DRIDesignParameterExpression parameterExpression : genericElement.getParameterExpressions()) { + jrDesignGenericElement.addParameter(this.accessor.getExpressionTransform().getGenericElementParameterExpression(parameterExpression)); + } + return jrDesignGenericElement; + } + + // map + private JRDesignElement map(final DRIDesignMap map) { + final StandardMapComponent jrMap = new StandardMapComponent(); + final EvaluationTime evaluationTime = map.getEvaluationTime(); + jrMap.setEvaluationTime(ConstantTransform.evaluationTime(evaluationTime)); + if (evaluationTime != null && evaluationTime.equals(EvaluationTime.GROUP) && map.getEvaluationGroup() != null) { + jrMap.setEvaluationGroup(this.accessor.getGroupTransform().getGroup(map.getEvaluationGroup()).getName()); + } + jrMap.setLatitudeExpression(this.accessor.getExpressionTransform().getExpression(map.getLatitudeExpression())); + jrMap.setLongitudeExpression(this.accessor.getExpressionTransform().getExpression(map.getLongitudeExpression())); + jrMap.setZoomExpression(this.accessor.getExpressionTransform().getExpression(map.getZoomExpression())); + + final JRDesignComponentElement jrComponent = new JRDesignComponentElement(); + jrComponent.setComponent(jrMap); + jrComponent.setComponentKey(new ComponentKey(ComponentsExtensionsRegistryFactory.NAMESPACE, "jr", "map")); + + return jrComponent; + } + + // custom component + private JRDesignElement customComponent(final DRIDesignComponent component) { + @SuppressWarnings("rawtypes") final CustomComponentTransform componentTransfom = CustomComponents.getComponentTransform(component); + if (componentTransfom == null) { + throw new DRDesignReportException("Component " + component.getClass().getName() + " not supported"); + } + @SuppressWarnings("unchecked") final JRDesignComponentElement jrComponent = (JRDesignComponentElement) componentTransfom.jasperComponent( + this.accessor, component); + return jrComponent; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ConstantTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ConstantTransform.java new file mode 100644 index 0000000..c66bd26 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ConstantTransform.java @@ -0,0 +1,1241 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import java.util.List; + +import org.apache.commons.lang3.EnumUtils; +import org.jfree.data.time.Day; +import org.jfree.data.time.Hour; +import org.jfree.data.time.Millisecond; +import org.jfree.data.time.Minute; +import org.jfree.data.time.Month; +import org.jfree.data.time.Quarter; +import org.jfree.data.time.Second; +import org.jfree.data.time.Week; +import org.jfree.data.time.Year; + +import com.lowagie.text.pdf.PdfWriter; + +import software.xdev.dynamicreports.design.constant.EvaluationTime; +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.jasper.constant.PdfPermission; +import software.xdev.dynamicreports.jasper.constant.PdfVersion; +import software.xdev.dynamicreports.jasper.constant.SizeUnit; +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import software.xdev.dynamicreports.report.constant.BreakType; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.ComponentPositionType; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; +import software.xdev.dynamicreports.report.constant.CrosstabTotalPosition; +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.HyperLinkTarget; +import software.xdev.dynamicreports.report.constant.HyperLinkType; +import software.xdev.dynamicreports.report.constant.ImageAnchorType; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.constant.LineDirection; +import software.xdev.dynamicreports.report.constant.LineSpacing; +import software.xdev.dynamicreports.report.constant.LineStyle; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.OrderType; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PdfPrintScaling; +import software.xdev.dynamicreports.report.constant.PdfaConformance; +import software.xdev.dynamicreports.report.constant.RectangleAnchor; +import software.xdev.dynamicreports.report.constant.Rotation; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.constant.StretchType; +import software.xdev.dynamicreports.report.constant.TabStopAlignment; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.constant.TimePeriod; +import software.xdev.dynamicreports.report.constant.VerticalImageAlignment; +import software.xdev.dynamicreports.report.constant.VerticalTextAlignment; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import net.sf.jasperreports.crosstabs.type.CrosstabPercentageEnum; +import net.sf.jasperreports.crosstabs.type.CrosstabTotalPositionEnum; +import net.sf.jasperreports.engine.analytics.dataset.BucketOrder; +import net.sf.jasperreports.engine.export.type.ImageAnchorTypeEnum; +import net.sf.jasperreports.engine.type.BreakTypeEnum; +import net.sf.jasperreports.engine.type.CalculationEnum; +import net.sf.jasperreports.engine.type.DatasetResetTypeEnum; +import net.sf.jasperreports.engine.type.EvaluationTimeEnum; +import net.sf.jasperreports.engine.type.FooterPositionEnum; +import net.sf.jasperreports.engine.type.HorizontalImageAlignEnum; +import net.sf.jasperreports.engine.type.HorizontalTextAlignEnum; +import net.sf.jasperreports.engine.type.HyperlinkTargetEnum; +import net.sf.jasperreports.engine.type.HyperlinkTypeEnum; +import net.sf.jasperreports.engine.type.LineDirectionEnum; +import net.sf.jasperreports.engine.type.LineSpacingEnum; +import net.sf.jasperreports.engine.type.LineStyleEnum; +import net.sf.jasperreports.engine.type.OrientationEnum; +import net.sf.jasperreports.engine.type.PositionTypeEnum; +import net.sf.jasperreports.engine.type.PrintOrderEnum; +import net.sf.jasperreports.engine.type.ResetTypeEnum; +import net.sf.jasperreports.engine.type.RotationEnum; +import net.sf.jasperreports.engine.type.RunDirectionEnum; +import net.sf.jasperreports.engine.type.ScaleImageEnum; +import net.sf.jasperreports.engine.type.SortOrderEnum; +import net.sf.jasperreports.engine.type.SplitTypeEnum; +import net.sf.jasperreports.engine.type.StretchTypeEnum; +import net.sf.jasperreports.engine.type.TabStopAlignEnum; +import net.sf.jasperreports.engine.type.TextAdjustEnum; +import net.sf.jasperreports.engine.type.VerticalImageAlignEnum; +import net.sf.jasperreports.engine.type.VerticalTextAlignEnum; +import net.sf.jasperreports.engine.type.WhenNoDataTypeEnum; +import net.sf.jasperreports.engine.type.WhenResourceMissingTypeEnum; +import net.sf.jasperreports.export.type.HtmlSizeUnitEnum; +import net.sf.jasperreports.export.type.PdfPrintScalingEnum; +import net.sf.jasperreports.export.type.PdfVersionEnum; +import net.sf.jasperreports.export.type.PdfaConformanceEnum; + + +/** + *

ConstantTransform class.

+ * + * @author Ricardo Mariaca + */ +public class ConstantTransform +{ + + /** + *

lineStyle.

+ * + * @param lineStyle a {@link software.xdev.dynamicreports.report.constant.LineStyle} object. + * @return a {@link net.sf.jasperreports.engine.type.LineStyleEnum} object. + */ + protected static LineStyleEnum lineStyle(final LineStyle lineStyle) + { + if(lineStyle == null) + { + return null; + } + + switch(lineStyle) + { + case SOLID: + return LineStyleEnum.SOLID; + case DASHED: + return LineStyleEnum.DASHED; + case DOTTED: + return LineStyleEnum.DOTTED; + case DOUBLE: + return LineStyleEnum.DOUBLE; + default: + throw new JasperDesignException("Line style " + lineStyle.name() + " not supported"); + } + } + + /** + *

imageScale.

+ * + * @param imageScale a {@link software.xdev.dynamicreports.report.constant.ImageScale} object. + * @return a {@link net.sf.jasperreports.engine.type.ScaleImageEnum} object. + */ + @SuppressWarnings("deprecation") + protected static ScaleImageEnum imageScale(final ImageScale imageScale) + { + if(imageScale == null) + { + return null; + } + + switch(imageScale) + { + case CLIP: + case NO_RESIZE: + return ScaleImageEnum.CLIP; + case FILL_FRAME: + case FILL: + return ScaleImageEnum.FILL_FRAME; + case RETAIN_SHAPE: + case FILL_PROPORTIONALLY: + return ScaleImageEnum.RETAIN_SHAPE; + case REAL_HEIGHT: + return ScaleImageEnum.REAL_HEIGHT; + case REAL_SIZE: + return ScaleImageEnum.REAL_SIZE; + default: + throw new JasperDesignException("Image scale " + imageScale.name() + " not supported"); + } + } + + /** + *

imageAnchorType.

+ * + * @param imageAnchorType a {@link software.xdev.dynamicreports.report.constant.ImageAnchorType} object. + * @return a {@link net.sf.jasperreports.engine.export.type.ImageAnchorTypeEnum} object. + */ + protected static ImageAnchorTypeEnum imageAnchorType(final ImageAnchorType imageAnchorType) + { + if(imageAnchorType == null) + { + return null; + } + + switch(imageAnchorType) + { + case MOVE_SIZE: + return ImageAnchorTypeEnum.MOVE_SIZE; + case MOVE_NO_SIZE: + return ImageAnchorTypeEnum.MOVE_NO_SIZE; + case NO_MOVE_NO_SIZE: + return ImageAnchorTypeEnum.NO_MOVE_NO_SIZE; + default: + throw new JasperDesignException("Image anchor type " + imageAnchorType.name() + " not supported"); + } + } + + /** + *

horizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + * @return a {@link net.sf.jasperreports.engine.type.HorizontalTextAlignEnum} object. + */ + protected static HorizontalTextAlignEnum horizontalTextAlignment(final HorizontalTextAlignment horizontalTextAlignment) + { + if(horizontalTextAlignment == null) + { + return null; + } + + switch(horizontalTextAlignment) + { + case LEFT: + return HorizontalTextAlignEnum.LEFT; + case CENTER: + return HorizontalTextAlignEnum.CENTER; + case RIGHT: + return HorizontalTextAlignEnum.RIGHT; + case JUSTIFIED: + return HorizontalTextAlignEnum.JUSTIFIED; + default: + throw new JasperDesignException( + "Horizontal text alignment " + horizontalTextAlignment.name() + " not supported"); + } + } + + /** + *

verticalTextAlignment.

+ * + * @param verticalTextAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalTextAlignment} object. + * @return a {@link net.sf.jasperreports.engine.type.VerticalTextAlignEnum} object. + */ + protected static VerticalTextAlignEnum verticalTextAlignment(final VerticalTextAlignment verticalTextAlignment) + { + if(verticalTextAlignment == null) + { + return null; + } + + switch(verticalTextAlignment) + { + case TOP: + return VerticalTextAlignEnum.TOP; + case MIDDLE: + return VerticalTextAlignEnum.MIDDLE; + case BOTTOM: + return VerticalTextAlignEnum.BOTTOM; + case JUSTIFIED: + return VerticalTextAlignEnum.JUSTIFIED; + default: + throw new JasperDesignException( + "Vertical text alignment " + verticalTextAlignment.name() + " not supported"); + } + } + + /** + *

horizontalImageAlignment.

+ * + * @param horizontalImageAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + * @return a {@link net.sf.jasperreports.engine.type.HorizontalImageAlignEnum} object. + */ + protected static HorizontalImageAlignEnum horizontalImageAlignment(final HorizontalImageAlignment horizontalImageAlignment) + { + if(horizontalImageAlignment == null) + { + return null; + } + + switch(horizontalImageAlignment) + { + case LEFT: + return HorizontalImageAlignEnum.LEFT; + case CENTER: + return HorizontalImageAlignEnum.CENTER; + case RIGHT: + return HorizontalImageAlignEnum.RIGHT; + default: + throw new JasperDesignException( + "Horizontal image alignment " + horizontalImageAlignment.name() + " not supported"); + } + } + + /** + *

verticalImageAlignment.

+ * + * @param verticalImageAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalImageAlignment} object. + * @return a {@link net.sf.jasperreports.engine.type.VerticalImageAlignEnum} object. + */ + protected static VerticalImageAlignEnum verticalImageAlignment(final VerticalImageAlignment verticalImageAlignment) + { + if(verticalImageAlignment == null) + { + return null; + } + + switch(verticalImageAlignment) + { + case TOP: + return VerticalImageAlignEnum.TOP; + case MIDDLE: + return VerticalImageAlignEnum.MIDDLE; + case BOTTOM: + return VerticalImageAlignEnum.BOTTOM; + default: + throw new JasperDesignException( + "Vertical image alignment " + verticalImageAlignment.name() + " not supported"); + } + } + + /** + *

rotation.

+ * + * @param rotation a {@link software.xdev.dynamicreports.report.constant.Rotation} object. + * @return a {@link net.sf.jasperreports.engine.type.RotationEnum} object. + */ + protected static RotationEnum rotation(final Rotation rotation) + { + if(rotation == null) + { + return null; + } + + switch(rotation) + { + case NONE: + return RotationEnum.NONE; + case LEFT: + return RotationEnum.LEFT; + case RIGHT: + return RotationEnum.RIGHT; + case UPSIDE_DOWN: + return RotationEnum.UPSIDE_DOWN; + default: + throw new JasperDesignException("Rotation " + rotation.name() + " not supported"); + } + } + + /** + *

whenNoDataType.

+ * + * @param whenNoDataType a {@link software.xdev.dynamicreports.report.constant.WhenNoDataType} object. + * @return a {@link net.sf.jasperreports.engine.type.WhenNoDataTypeEnum} object. + */ + protected static WhenNoDataTypeEnum whenNoDataType(final WhenNoDataType whenNoDataType) + { + switch(whenNoDataType) + { + case NO_PAGES: + return WhenNoDataTypeEnum.NO_PAGES; + case BLANK_PAGE: + return WhenNoDataTypeEnum.BLANK_PAGE; + case ALL_SECTIONS_NO_DETAIL: + return WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL; + case NO_DATA_SECTION: + return WhenNoDataTypeEnum.NO_DATA_SECTION; + default: + throw new JasperDesignException("When no data type " + whenNoDataType.name() + " not supported"); + } + } + + /** + *

whenNoDataType.

+ * + * @param whenNoDataType a {@link net.sf.jasperreports.engine.type.WhenNoDataTypeEnum} object. + * @return a {@link software.xdev.dynamicreports.report.constant.WhenNoDataType} object. + */ + public static WhenNoDataType whenNoDataType(final WhenNoDataTypeEnum whenNoDataType) + { + if(whenNoDataType == null) + { + return null; + } + switch(whenNoDataType) + { + case NO_PAGES: + return WhenNoDataType.NO_PAGES; + case BLANK_PAGE: + return WhenNoDataType.BLANK_PAGE; + case ALL_SECTIONS_NO_DETAIL: + return WhenNoDataType.ALL_SECTIONS_NO_DETAIL; + case NO_DATA_SECTION: + return WhenNoDataType.NO_DATA_SECTION; + default: + throw new JasperDesignException("When no data type " + whenNoDataType.name() + " not supported"); + } + } + + /** + *

whenResourceMissingType.

+ * + * @param whenResourceMissingType a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + * @return a {@link net.sf.jasperreports.engine.type.WhenResourceMissingTypeEnum} object. + */ + protected static WhenResourceMissingTypeEnum whenResourceMissingType(final WhenResourceMissingType whenResourceMissingType) + { + switch(whenResourceMissingType) + { + case NULL: + return WhenResourceMissingTypeEnum.NULL; + case EMPTY: + return WhenResourceMissingTypeEnum.EMPTY; + case KEY: + return WhenResourceMissingTypeEnum.KEY; + case ERROR: + return WhenResourceMissingTypeEnum.ERROR; + default: + throw new JasperDesignException( + "When resource missing type " + whenResourceMissingType.name() + " not supported"); + } + } + + /** + *

whenResourceMissingType.

+ * + * @param whenResourceMissingType a {@link net.sf.jasperreports.engine.type.WhenResourceMissingTypeEnum} object. + * @return a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + */ + public static WhenResourceMissingType whenResourceMissingType(final WhenResourceMissingTypeEnum whenResourceMissingType) + { + switch(whenResourceMissingType) + { + case NULL: + return WhenResourceMissingType.NULL; + case EMPTY: + return WhenResourceMissingType.EMPTY; + case KEY: + return WhenResourceMissingType.KEY; + case ERROR: + return WhenResourceMissingType.ERROR; + default: + throw new JasperDesignException( + "When resource missing type " + whenResourceMissingType.name() + " not supported"); + } + } + + /** + *

pageOrientation.

+ * + * @param orientation a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + * @return a {@link net.sf.jasperreports.engine.type.OrientationEnum} object. + */ + protected static OrientationEnum pageOrientation(final PageOrientation orientation) + { + switch(orientation) + { + case PORTRAIT: + return OrientationEnum.PORTRAIT; + case LANDSCAPE: + return OrientationEnum.LANDSCAPE; + default: + throw new JasperDesignException("Page orientation " + orientation.name() + " not supported"); + } + } + + /** + *

pageOrientation.

+ * + * @param orientation a {@link net.sf.jasperreports.engine.type.OrientationEnum} object. + * @return a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + */ + public static PageOrientation pageOrientation(final OrientationEnum orientation) + { + switch(orientation) + { + case PORTRAIT: + return PageOrientation.PORTRAIT; + case LANDSCAPE: + return PageOrientation.LANDSCAPE; + default: + throw new JasperDesignException("Page orientation " + orientation.name() + " not supported"); + } + } + + /** + *

variableResetType.

+ * + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @return a {@link net.sf.jasperreports.engine.type.ResetTypeEnum} object. + */ + public static ResetTypeEnum variableResetType(final ResetType resetType) + { + if(resetType == null) + { + return ResetTypeEnum.NONE; + } + + switch(resetType) + { + case NONE: + return ResetTypeEnum.NONE; + case REPORT: + return ResetTypeEnum.REPORT; + case PAGE: + return ResetTypeEnum.PAGE; + case COLUMN: + return ResetTypeEnum.COLUMN; + case GROUP: + return ResetTypeEnum.GROUP; + default: + throw new JasperDesignException("Variable reset type " + resetType.name() + " not supported"); + } + } + + public static DatasetResetTypeEnum variableDatabaseResetType(final ResetType resetType) + { + return switch(variableResetType(resetType)) + { + case REPORT -> DatasetResetTypeEnum.REPORT; + case PAGE -> DatasetResetTypeEnum.PAGE; + case COLUMN -> DatasetResetTypeEnum.COLUMN; + case GROUP -> DatasetResetTypeEnum.GROUP; + case NONE -> DatasetResetTypeEnum.NONE; + default -> throw new IllegalStateException("ResetType " + resetType + " can't be processed"); + }; + } + + /** + *

evaluationTime.

+ * + * @param evaluationTime a {@link software.xdev.dynamicreports.design.constant.EvaluationTime} object. + * @return a {@link net.sf.jasperreports.engine.type.EvaluationTimeEnum} object. + */ + public static EvaluationTimeEnum evaluationTime(final EvaluationTime evaluationTime) + { + if(evaluationTime == null) + { + return EvaluationTimeEnum.NOW; + } + + switch(evaluationTime) + { + case NOW: + return EvaluationTimeEnum.NOW; + case REPORT: + return EvaluationTimeEnum.REPORT; + case PAGE: + return EvaluationTimeEnum.PAGE; + case COLUMN: + return EvaluationTimeEnum.COLUMN; + case GROUP: + return EvaluationTimeEnum.GROUP; + case BAND: + return EvaluationTimeEnum.BAND; + case AUTO: + return EvaluationTimeEnum.AUTO; + default: + throw new JasperDesignException("Evaluation time " + evaluationTime.name() + " not supported"); + } + } + + /** + *

splitType.

+ * + * @param splitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link net.sf.jasperreports.engine.type.SplitTypeEnum} object. + */ + protected static SplitTypeEnum splitType(final SplitType splitType) + { + if(splitType == null) + { + return null; + } + switch(splitType) + { + case IMMEDIATE: + return SplitTypeEnum.IMMEDIATE; + case PREVENT: + return SplitTypeEnum.PREVENT; + case STRETCH: + return SplitTypeEnum.STRETCH; + default: + throw new JasperDesignException("Split type " + splitType.name() + " not supported"); + } + } + + /** + *

timePeriodType.

+ * + * @param timePeriodType a {@link software.xdev.dynamicreports.report.constant.TimePeriod} object. + * @return a {@link java.lang.Class} object. + */ + protected static Class timePeriodType(final TimePeriod timePeriodType) + { + switch(timePeriodType) + { + case YEAR: + return Year.class; + case QUARTER: + return Quarter.class; + case MONTH: + return Month.class; + case WEEK: + return Week.class; + case DAY: + return Day.class; + case HOUR: + return Hour.class; + case MINUTE: + return Minute.class; + case SECOND: + return Second.class; + case MILLISECOND: + return Millisecond.class; + default: + throw new JasperDesignException("Time period type " + timePeriodType.name() + " not supported"); + } + } + + /** + *

calculation.

+ * + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @return a {@link net.sf.jasperreports.engine.type.CalculationEnum} object. + */ + protected static CalculationEnum calculation(final Calculation calculation) + { + switch(calculation) + { + case NOTHING: + return CalculationEnum.NOTHING; + case COUNT: + return CalculationEnum.COUNT; + case SUM: + return CalculationEnum.SUM; + case AVERAGE: + return CalculationEnum.AVERAGE; + case LOWEST: + return CalculationEnum.LOWEST; + case HIGHEST: + return CalculationEnum.HIGHEST; + case STANDARD_DEVIATION: + return CalculationEnum.STANDARD_DEVIATION; + case VARIANCE: + return CalculationEnum.VARIANCE; + case FIRST: + return CalculationEnum.FIRST; + case DISTINCT_COUNT: + return CalculationEnum.DISTINCT_COUNT; + default: + throw new JasperDesignException("Calculation " + calculation.name() + " not supported"); + } + } + + /** + *

sizeUnit.

+ * + * @param sizeUnit a {@link software.xdev.dynamicreports.jasper.constant.SizeUnit} object. + * @return a {@link net.sf.jasperreports.export.type.HtmlSizeUnitEnum} object. + */ + protected static HtmlSizeUnitEnum sizeUnit(final SizeUnit sizeUnit) + { + switch(sizeUnit) + { + case PIXEL: + return HtmlSizeUnitEnum.PIXEL; + case POINT: + return HtmlSizeUnitEnum.POINT; + default: + throw new JasperDesignException("SizeUnit " + sizeUnit.name() + " not supported"); + } + } + + /** + *

pdfVersion.

+ * + * @param pdfVersion a {@link software.xdev.dynamicreports.jasper.constant.PdfVersion} object. + * @return a {@link net.sf.jasperreports.export.type.PdfVersionEnum} object. + */ + protected static PdfVersionEnum pdfVersion(final PdfVersion pdfVersion) + { + switch(pdfVersion) + { + case VERION_1_2: + return PdfVersionEnum.VERSION_1_2; + case VERION_1_3: + return PdfVersionEnum.VERSION_1_3; + case VERION_1_4: + return PdfVersionEnum.VERSION_1_4; + case VERION_1_5: + return PdfVersionEnum.VERSION_1_5; + case VERION_1_6: + return PdfVersionEnum.VERSION_1_6; + case VERION_1_7: + return PdfVersionEnum.VERSION_1_7; + default: + throw new JasperDesignException("PdfVersion " + pdfVersion.name() + " not supported"); + } + } + + /** + *

pdfPermission.

+ * + * @param permissions a {@link java.util.List} object. + * @return a {@link java.lang.Integer} object. + */ + protected static Integer pdfPermission(final List permissions) + { + final int permission = 0; + for(final PdfPermission pdfPermission : permissions) + { + switch(pdfPermission) + { + case PRINTING: + return permission | PdfWriter.ALLOW_PRINTING; + case MODIFY_CONTENTS: + return permission | PdfWriter.ALLOW_MODIFY_CONTENTS; + case COPY: + return permission | PdfWriter.ALLOW_COPY; + case MODIFY_ANNOTATIONS: + return permission | PdfWriter.ALLOW_MODIFY_ANNOTATIONS; + case FILL_IN: + return permission | PdfWriter.ALLOW_FILL_IN; + case SCREEN_READERS: + return permission | PdfWriter.ALLOW_SCREENREADERS; + case ASSEMBLY: + return permission | PdfWriter.ALLOW_ASSEMBLY; + case DEGRADED_PRINTING: + return permission | PdfWriter.ALLOW_DEGRADED_PRINTING; + default: + throw new JasperDesignException("PdfPermission " + pdfPermission.name() + " not supported"); + } + } + return permission; + } + + /** + *

pdfPrintScaling.

+ * + * @param pdfPrintScaling a {@link software.xdev.dynamicreports.report.constant.PdfPrintScaling} object. + * @return a {@link net.sf.jasperreports.export.type.PdfPrintScalingEnum} object. + */ + protected static PdfPrintScalingEnum pdfPrintScaling(final PdfPrintScaling pdfPrintScaling) + { + switch(pdfPrintScaling) + { + case NONE: + return PdfPrintScalingEnum.NONE; + case DEFAULT: + return PdfPrintScalingEnum.DEFAULT; + default: + throw new JasperDesignException("Pdf print scaling " + pdfPrintScaling.name() + " not supported"); + } + } + + /** + *

pdfaConformance.

+ * + * @param pdfaConformance a {@link software.xdev.dynamicreports.report.constant.PdfaConformance} object. + * @return a {@link net.sf.jasperreports.export.type.PdfaConformanceEnum} object. + */ + protected static PdfaConformanceEnum pdfaConformance(final PdfaConformance pdfaConformance) + { + switch(pdfaConformance) + { + case NONE: + return PdfaConformanceEnum.NONE; + case PDFA_1A: + return PdfaConformanceEnum.PDFA_1A; + case PDFA_1B: + return PdfaConformanceEnum.PDFA_1B; + default: + throw new JasperDesignException("Pdfa conformance " + pdfaConformance.name() + " not supported"); + } + } + + /** + *

lineDirection.

+ * + * @param lineDirection a {@link software.xdev.dynamicreports.report.constant.LineDirection} object. + * @return a {@link net.sf.jasperreports.engine.type.LineDirectionEnum} object. + */ + public static LineDirectionEnum lineDirection(final LineDirection lineDirection) + { + if(lineDirection == null) + { + return null; + } + + switch(lineDirection) + { + case TOP_DOWN: + return LineDirectionEnum.TOP_DOWN; + case BOTTOM_UP: + return LineDirectionEnum.BOTTOM_UP; + default: + throw new JasperDesignException("LineDirection " + lineDirection.name() + " not supported"); + } + } + + /** + *

markup.

+ * + * @param markup a {@link software.xdev.dynamicreports.report.constant.Markup} object. + * @return a {@link java.lang.String} object. + */ + public static String markup(final Markup markup) + { + if(markup == null) + { + return null; + } + + switch(markup) + { + case NONE: + return "none"; + case STYLED: + return "styled"; + case RTF: + return "rtf"; + case HTML: + return "html"; + default: + throw new JasperDesignException("Markup " + markup.name() + " not supported"); + } + } + + /** + *

lineSpacing.

+ * + * @param lineSpacing a {@link software.xdev.dynamicreports.report.constant.LineSpacing} object. + * @return a {@link net.sf.jasperreports.engine.type.LineSpacingEnum} object. + */ + public static LineSpacingEnum lineSpacing(final LineSpacing lineSpacing) + { + if(lineSpacing == null) + { + return null; + } + + switch(lineSpacing) + { + case SINGLE: + return LineSpacingEnum.SINGLE; + case ONE_AND_HALF: + return LineSpacingEnum.ONE_AND_HALF; + case DOUBLE: + return LineSpacingEnum.DOUBLE; + case AT_LEAST: + return LineSpacingEnum.AT_LEAST; + case FIXED: + return LineSpacingEnum.FIXED; + case PROPORTIONAL: + return LineSpacingEnum.PROPORTIONAL; + default: + throw new JasperDesignException("LineSpacing " + lineSpacing.name() + " not supported"); + } + } + + /** + *

breakType.

+ * + * @param breakType a {@link software.xdev.dynamicreports.report.constant.BreakType} object. + * @return a {@link net.sf.jasperreports.engine.type.BreakTypeEnum} object. + */ + public static BreakTypeEnum breakType(final BreakType breakType) + { + if(breakType == null) + { + return null; + } + + switch(breakType) + { + case PAGE: + return BreakTypeEnum.PAGE; + case COLUMN: + return BreakTypeEnum.COLUMN; + default: + throw new JasperDesignException("BreakType " + breakType.name() + " not supported"); + } + } + + /** + *

runDirection.

+ * + * @param runDirection a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + * @return a {@link net.sf.jasperreports.engine.type.RunDirectionEnum} object. + */ + public static RunDirectionEnum runDirection(final RunDirection runDirection) + { + if(runDirection == null) + { + return null; + } + + switch(runDirection) + { + case LEFT_TO_RIGHT: + return RunDirectionEnum.LTR; + case RIGHT_TO_LEFT: + return RunDirectionEnum.RTL; + default: + throw new JasperDesignException("RunDirection " + runDirection.name() + " not supported"); + } + } + + /** + *

crosstabTotalPosition.

+ * + * @param totalPosition a {@link software.xdev.dynamicreports.report.constant.CrosstabTotalPosition} object. + * @return a {@link net.sf.jasperreports.crosstabs.type.CrosstabTotalPositionEnum} object. + */ + public static CrosstabTotalPositionEnum crosstabTotalPosition(final CrosstabTotalPosition totalPosition) + { + if(totalPosition == null) + { + return CrosstabTotalPositionEnum.NONE; + } + + switch(totalPosition) + { + case START: + return CrosstabTotalPositionEnum.START; + case END: + return CrosstabTotalPositionEnum.END; + default: + throw new JasperDesignException("CrosstabTotalPosition " + totalPosition.name() + " not supported"); + } + } + + /** + *

crosstabPercentageType.

+ * + * @param percentageType a {@link software.xdev.dynamicreports.report.constant.CrosstabPercentageType} object. + * @return a {@link net.sf.jasperreports.crosstabs.type.CrosstabPercentageEnum} object. + */ + public static CrosstabPercentageEnum crosstabPercentageType(final CrosstabPercentageType percentageType) + { + if(percentageType == null) + { + return null; + } + + switch(percentageType) + { + case NONE: + return CrosstabPercentageEnum.NONE; + case GRAND_TOTAL: + return CrosstabPercentageEnum.GRAND_TOTAL; + default: + throw new JasperDesignException("CrosstabPercentageType " + percentageType.name() + " not supported"); + } + } + + /** + *

orderType.

+ * + * @param orderType a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + * @return a {@link net.sf.jasperreports.engine.type.SortOrderEnum} object. + */ + public static SortOrderEnum orderType(final OrderType orderType) + { + if(orderType == null) + { + return null; + } + + switch(orderType) + { + case ASCENDING: + return SortOrderEnum.ASCENDING; + case DESCENDING: + return SortOrderEnum.DESCENDING; + default: + throw new JasperDesignException("OrderType " + orderType.name() + " not supported"); + } + } + + /** + *

bucketOrderType.

+ * + * @param orderType a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + * @return a {@link net.sf.jasperreports.engine.analytics.dataset.BucketOrder} object. + */ + public static BucketOrder bucketOrderType(final OrderType orderType) + { + if(orderType == null) + { + return null; + } + + switch(orderType) + { + case ASCENDING: + return BucketOrder.ASCENDING; + case DESCENDING: + return BucketOrder.DESCENDING; + default: + throw new JasperDesignException("OrderType " + orderType.name() + " not supported"); + } + } + + /** + *

componentPositionType.

+ * + * @param componentPositionType a {@link software.xdev.dynamicreports.report.constant.ComponentPositionType} object. + * @return a {@link net.sf.jasperreports.engine.type.PositionTypeEnum} object. + */ + public static PositionTypeEnum componentPositionType(final ComponentPositionType componentPositionType) + { + switch(componentPositionType) + { + case FLOAT: + return PositionTypeEnum.FLOAT; + case FIX_RELATIVE_TO_TOP: + return PositionTypeEnum.FIX_RELATIVE_TO_TOP; + case FIX_RELATIVE_TO_BOTTOM: + return PositionTypeEnum.FIX_RELATIVE_TO_BOTTOM; + default: + throw new JasperDesignException( + "ComponentPositionType " + componentPositionType.name() + " not supported"); + } + } + + /** + *

stretchType.

+ * + * @param stretchType a {@link software.xdev.dynamicreports.report.constant.StretchType} object. + * @return a {@link net.sf.jasperreports.engine.type.StretchTypeEnum} object. + */ + @SuppressWarnings("deprecation") + public static StretchTypeEnum stretchType(final StretchType stretchType) + { + if(stretchType == null) + { + return StretchTypeEnum.NO_STRETCH; + } + + switch(stretchType) + { + case NO_STRETCH: + return StretchTypeEnum.NO_STRETCH; + case RELATIVE_TO_BAND_HEIGHT: + return StretchTypeEnum.CONTAINER_HEIGHT; + case RELATIVE_TO_TALLEST_OBJECT: + return StretchTypeEnum.ELEMENT_GROUP_HEIGHT; + case ELEMENT_GROUP_HEIGHT: + return StretchTypeEnum.ELEMENT_GROUP_HEIGHT; + case ELEMENT_GROUP_BOTTOM: + return StretchTypeEnum.ELEMENT_GROUP_BOTTOM; + case CONTAINER_HEIGHT: + return StretchTypeEnum.CONTAINER_HEIGHT; + case CONTAINER_BOTTOM: + return StretchTypeEnum.CONTAINER_BOTTOM; + default: + throw new JasperDesignException("StretchType " + stretchType.name() + " not supported"); + } + } + + /** + *

hyperLinkType.

+ * + * @param hyperLinkType a {@link java.lang.String} object. + * @return a {@link net.sf.jasperreports.engine.type.HyperlinkTypeEnum} object. + */ + public static HyperlinkTypeEnum hyperLinkType(final String hyperLinkType) + { + if(hyperLinkType == null || !EnumUtils.isValidEnum(HyperLinkType.class, hyperLinkType)) + { + return null; + } + + final HyperLinkType type = HyperLinkType.valueOf(hyperLinkType); + switch(type) + { + case NONE: + return HyperlinkTypeEnum.NONE; + case REFERENCE: + return HyperlinkTypeEnum.REFERENCE; + case LOCAL_ANCHOR: + return HyperlinkTypeEnum.LOCAL_ANCHOR; + case LOCAL_PAGE: + return HyperlinkTypeEnum.LOCAL_PAGE; + case REMOTE_ANCHOR: + return HyperlinkTypeEnum.REMOTE_ANCHOR; + case REMOTE_PAGE: + return HyperlinkTypeEnum.REMOTE_PAGE; + default: + throw new JasperDesignException("HyperLinkType " + type.name() + " not supported"); + } + } + + /** + *

hyperLinkTarget.

+ * + * @param hyperLinkTarget a {@link java.lang.String} object. + * @return a {@link net.sf.jasperreports.engine.type.HyperlinkTargetEnum} object. + */ + public static HyperlinkTargetEnum hyperLinkTarget(final String hyperLinkTarget) + { + if(hyperLinkTarget == null || !EnumUtils.isValidEnum(HyperLinkTarget.class, hyperLinkTarget)) + { + return null; + } + + final HyperLinkTarget target = HyperLinkTarget.valueOf(hyperLinkTarget); + switch(target) + { + case NONE: + return HyperlinkTargetEnum.NONE; + case SELF: + return HyperlinkTargetEnum.SELF; + case BLANK: + return HyperlinkTargetEnum.BLANK; + case PARENT: + return HyperlinkTargetEnum.PARENT; + case TOP: + return HyperlinkTargetEnum.TOP; + default: + throw new JasperDesignException("HyperLinkTarget " + target.name() + " not supported"); + } + } + + /** + *

groupFooterPosition.

+ * + * @param footerPosition a {@link software.xdev.dynamicreports.report.constant.GroupFooterPosition} object. + * @return a {@link net.sf.jasperreports.engine.type.FooterPositionEnum} object. + */ + public static FooterPositionEnum groupFooterPosition(final GroupFooterPosition footerPosition) + { + switch(footerPosition) + { + case NORMAL: + return FooterPositionEnum.NORMAL; + case COLLATE_AT_BOTTOM: + return FooterPositionEnum.COLLATE_AT_BOTTOM; + case FORCE_AT_BOTTOM: + return FooterPositionEnum.FORCE_AT_BOTTOM; + case STACK_AT_BOTTOM: + return FooterPositionEnum.STACK_AT_BOTTOM; + default: + throw new JasperDesignException("GroupFooterPosition " + footerPosition.name() + " not supported"); + } + } + + /** + *

tabStopAlignment.

+ * + * @param alignment a {@link software.xdev.dynamicreports.report.constant.TabStopAlignment} object. + * @return a {@link net.sf.jasperreports.engine.type.TabStopAlignEnum} object. + */ + public static TabStopAlignEnum tabStopAlignment(final TabStopAlignment alignment) + { + switch(alignment) + { + case LEFT: + return TabStopAlignEnum.LEFT; + case CENTER: + return TabStopAlignEnum.CENTER; + case RIGHT: + return TabStopAlignEnum.RIGHT; + default: + throw new JasperDesignException("TabStopAlignment " + alignment.name() + " not supported"); + } + } + + /** + *

printOrder.

+ * + * @param printOrder a {@link software.xdev.dynamicreports.report.constant.Orientation} object. + * @return a {@link net.sf.jasperreports.engine.type.PrintOrderEnum} object. + */ + protected static PrintOrderEnum printOrder(final Orientation printOrder) + { + switch(printOrder) + { + case HORIZONTAL: + return PrintOrderEnum.HORIZONTAL; + case VERTICAL: + return PrintOrderEnum.VERTICAL; + default: + throw new JasperDesignException("PrintOrder " + printOrder.name() + " not supported"); + } + } + + /** + *

rectangleAnchor.

+ * + * @param rectangleAnchor a {@link software.xdev.dynamicreports.report.constant.RectangleAnchor} object. + * @return a {@link org.jfree.ui.RectangleAnchor} object. + */ + public static org.jfree.ui.RectangleAnchor rectangleAnchor(final RectangleAnchor rectangleAnchor) + { + switch(rectangleAnchor) + { + case CENTER: + return org.jfree.ui.RectangleAnchor.CENTER; + case TOP: + return org.jfree.ui.RectangleAnchor.TOP; + case TOP_LEFT: + return org.jfree.ui.RectangleAnchor.TOP_LEFT; + case TOP_RIGHT: + return org.jfree.ui.RectangleAnchor.TOP_RIGHT; + case BOTTOM: + return org.jfree.ui.RectangleAnchor.BOTTOM; + case BOTTOM_LEFT: + return org.jfree.ui.RectangleAnchor.BOTTOM_LEFT; + case BOTTOM_RIGHT: + return org.jfree.ui.RectangleAnchor.BOTTOM_RIGHT; + case LEFT: + return org.jfree.ui.RectangleAnchor.LEFT; + case RIGHT: + return org.jfree.ui.RectangleAnchor.RIGHT; + default: + throw new JasperDesignException("RectangleAnchor " + rectangleAnchor.name() + " not supported"); + } + } + + /** + *

textAdjust.

+ * + * @param textAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + * @return a {@link net.sf.jasperreports.engine.type.TextAdjustEnum} object. + */ + public static TextAdjustEnum textAdjust(final TextAdjust textAdjust) + { + switch(textAdjust) + { + case CUT_TEXT: + return TextAdjustEnum.CUT_TEXT; + case SCALE_FONT: + return TextAdjustEnum.SCALE_FONT; + case STRETCH_HEIGHT: + return TextAdjustEnum.STRETCH_HEIGHT; + default: + throw new JasperDesignException("TextAdjust " + textAdjust.name() + " not supported"); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/CrosstabTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/CrosstabTransform.java new file mode 100644 index 0000000..3b31c16 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/CrosstabTransform.java @@ -0,0 +1,289 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import java.util.Map; + +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstab; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabCell; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabCellContent; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabColumnGroup; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabDataset; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabGroup; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabMeasure; +import software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstabRowGroup; +import software.xdev.dynamicreports.jasper.base.JasperCustomValues; +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import software.xdev.dynamicreports.jasper.transformation.expression.CrosstabParametersExpression; +import software.xdev.dynamicreports.report.constant.ListType; +import net.sf.jasperreports.crosstabs.design.JRDesignCellContents; +import net.sf.jasperreports.crosstabs.design.JRDesignCrosstab; +import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabBucket; +import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabCell; +import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabColumnGroup; +import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabDataset; +import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabGroup; +import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabMeasure; +import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabParameter; +import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabRowGroup; +import net.sf.jasperreports.crosstabs.type.CrosstabColumnPositionEnum; +import net.sf.jasperreports.crosstabs.type.CrosstabRowPositionEnum; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.design.JRDesignElement; + + +/** + *

CrosstabTransform class.

+ * + * @author Ricardo Mariaca + */ +public class CrosstabTransform +{ + private final JasperTransformAccessor accessor; + + /** + *

Constructor for CrosstabTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.jasper.transformation.JasperTransformAccessor} object. + */ + public CrosstabTransform(final JasperTransformAccessor accessor) + { + this.accessor = accessor; + } + + /** + *

transform.

+ * + * @param crosstab a {@link software.xdev.dynamicreports.design.definition.crosstab.DRIDesignCrosstab} object. + * @return a {@link net.sf.jasperreports.engine.design.JRDesignElement} object. + */ + protected JRDesignElement transform(final DRIDesignCrosstab crosstab) + { + final JRDesignCrosstab jrCrosstab = new JRDesignCrosstab(); + + this.dataset(crosstab.getDataset(), jrCrosstab.getDesignDataset()); + this.accessor.transformToDataset(crosstab.getDataset().getSubDataset()); + if(crosstab.isRepeatColumnHeaders() != null) + { + jrCrosstab.setRepeatColumnHeaders(crosstab.isRepeatColumnHeaders()); + } + if(crosstab.isRepeatRowHeaders() != null) + { + jrCrosstab.setRepeatRowHeaders(crosstab.isRepeatRowHeaders()); + } + if(crosstab.getColumnBreakOffset() != null) + { + jrCrosstab.setColumnBreakOffset(crosstab.getColumnBreakOffset()); + } + jrCrosstab.setIgnoreWidth(crosstab.getIgnoreWidth()); + jrCrosstab.setRunDirection(ConstantTransform.runDirection(crosstab.getRunDirection())); + jrCrosstab.setWhenNoDataCell(this.cellContent(crosstab.getWhenNoDataCell())); + jrCrosstab.setHeaderCell(this.cellContent(crosstab.getHeaderCell())); + for(final DRIDesignCrosstabColumnGroup columnGroup : crosstab.getColumnGroups()) + { + this.addColumnGroup(jrCrosstab, columnGroup); + } + for(final DRIDesignCrosstabRowGroup rowGroup : crosstab.getRowGroups()) + { + this.addRowGroup(jrCrosstab, rowGroup); + } + for(final DRIDesignCrosstabCell cell : crosstab.getCells()) + { + this.addCell(jrCrosstab, cell); + } + for(final DRIDesignCrosstabMeasure measure : crosstab.getMeasures()) + { + this.addMeasure(jrCrosstab, measure); + } + + this.registerScriptletCrosstabParameter(jrCrosstab); + this.accessor.transformToMainDataset(); + + final Map crosstabParameters; + if(crosstab.getDataset().getSubDataset() == null) + { + crosstabParameters = this.accessor.getParameters(); + } + else + { + crosstabParameters = + this.accessor.getDatasetTransform().getDatasetParameters(crosstab.getDataset().getSubDataset()); + } + final CrosstabParametersExpression parametersExpression = new CrosstabParametersExpression(crosstabParameters); + this.accessor.getExpressionTransform().addSimpleExpression(parametersExpression); + jrCrosstab.setParametersMapExpression(this.accessor.getExpressionTransform() + .getExpression(parametersExpression)); + + return jrCrosstab; + } + + private void registerScriptletCrosstabParameter(final JRDesignCrosstab jrCrosstab) + { + final JRDesignCrosstabParameter jrParameter = new JRDesignCrosstabParameter(); + jrParameter.setName(JasperCustomValues.NAME); + jrParameter.setValueClass(JasperCustomValues.class); + + try + { + jrCrosstab.addParameter(jrParameter); + } + catch(final JRException e) + { + throw new JasperDesignException("Registration failed for scriptlet crosstab parameter", e); + } + } + + // dataset + private void dataset(final DRIDesignCrosstabDataset dataset, final JRDesignCrosstabDataset jrDataset) + { + jrDataset.setDatasetRun(this.accessor.getDatasetTransform().datasetRun(dataset.getSubDataset())); + if(dataset.getDataPreSorted() != null) + { + jrDataset.setDataPreSorted(dataset.getDataPreSorted()); + } + final ResetType resetType = dataset.getResetType(); + jrDataset.setResetType(ConstantTransform.variableDatabaseResetType(resetType)); + if(resetType.equals(ResetType.GROUP) && dataset.getResetGroup() != null) + { + jrDataset.setResetGroup(this.accessor.getGroupTransform().getGroup(dataset.getResetGroup())); + } + } + + private JRDesignCellContents cellContent(final DRIDesignCrosstabCellContent cellContent) + { + if(cellContent == null || cellContent.getComponent() == null) + { + return null; + } + + final JRDesignCellContents jrCellContents = new JRDesignCellContents(); + final JRDesignElement[] jrElements = + this.accessor.getComponentTransform().component(cellContent.getComponent(), ListType.VERTICAL); + for(final JRDesignElement jrElement : jrElements) + { + jrCellContents.addElement(jrElement); + } + jrCellContents.setStyle(this.accessor.getStyleTransform().getStyle(cellContent.getStyle())); + return jrCellContents; + } + + private void group(final JRDesignCrosstabGroup jrGroup, final DRIDesignCrosstabGroup group) + { + jrGroup.setName(group.getName()); + jrGroup.setTotalPosition(ConstantTransform.crosstabTotalPosition(group.getTotalPosition())); + jrGroup.setBucket(this.bucket(group)); + jrGroup.setHeader(this.cellContent(group.getHeader())); + jrGroup.setTotalHeader(this.cellContent(group.getTotalHeader())); + } + + private JRDesignCrosstabBucket bucket(final DRIDesignCrosstabGroup group) + { + final JRDesignCrosstabBucket jrBucket = new JRDesignCrosstabBucket(); + if(group.getOrderType() != null) + { + jrBucket.setOrder(ConstantTransform.bucketOrderType(group.getOrderType())); + } + jrBucket.setExpression(this.accessor.getExpressionTransform().getExpression(group.getExpression())); + jrBucket.setOrderByExpression(this.accessor.getExpressionTransform() + .getExpression(group.getOrderByExpression())); + jrBucket.setComparatorExpression(this.accessor.getExpressionTransform() + .getExpression(group.getComparatorExpression())); + jrBucket.setValueClassName(group.getExpression().getValueClass().getName()); + return jrBucket; + } + + private void addColumnGroup(final JRDesignCrosstab jrCrosstab, final DRIDesignCrosstabColumnGroup columnGroup) + { + final JRDesignCrosstabColumnGroup jrColumnGroup = new JRDesignCrosstabColumnGroup(); + this.group(jrColumnGroup, columnGroup); + jrColumnGroup.setHeight(columnGroup.getHeight()); + jrColumnGroup.setPosition(CrosstabColumnPositionEnum.STRETCH); + + try + { + jrCrosstab.addColumnGroup(jrColumnGroup); + } + catch(final JRException e) + { + throw new JasperDesignException( + "Registration failed for crosstab column group \"" + columnGroup.getName() + "\"", + e); + } + } + + private void addRowGroup(final JRDesignCrosstab jrCrosstab, final DRIDesignCrosstabRowGroup rowGroup) + { + final JRDesignCrosstabRowGroup jrRowGroup = new JRDesignCrosstabRowGroup(); + this.group(jrRowGroup, rowGroup); + jrRowGroup.setWidth(rowGroup.getWidth()); + jrRowGroup.setPosition(CrosstabRowPositionEnum.STRETCH); + + try + { + jrCrosstab.addRowGroup(jrRowGroup); + } + catch(final JRException e) + { + throw new JasperDesignException( + "Registration failed for crosstab row group \"" + rowGroup.getName() + "\"", + e); + } + } + + private void addCell(final JRDesignCrosstab jrCrosstab, final DRIDesignCrosstabCell cell) + { + final JRDesignCrosstabCell jrCell = new JRDesignCrosstabCell(); + jrCell.setWidth(cell.getContent().getWidth()); + jrCell.setHeight(cell.getContent().getHeight()); + jrCell.setRowTotalGroup(cell.getRowTotalGroup()); + jrCell.setColumnTotalGroup(cell.getColumnTotalGroup()); + jrCell.setContents(this.cellContent(cell.getContent())); + + try + { + jrCrosstab.addCell(jrCell); + } + catch(final JRException e) + { + throw new JasperDesignException("Registration failed for crosstab cell \"" + cell.getName() + "\"", e); + } + } + + private void addMeasure(final JRDesignCrosstab jrCrosstab, final DRIDesignCrosstabMeasure measure) + { + final JRDesignCrosstabMeasure jrMeasure = new JRDesignCrosstabMeasure(); + jrMeasure.setName(measure.getName()); + jrMeasure.setValueExpression(this.accessor.getExpressionTransform() + .getExpression(measure.getValueExpression())); + jrMeasure.setValueClassName(measure.getValueClass().getName()); + jrMeasure.setCalculation(ConstantTransform.calculation(measure.getCalculation())); + jrMeasure.setPercentageType(ConstantTransform.crosstabPercentageType(measure.getPercentageType())); + + try + { + jrCrosstab.addMeasure(jrMeasure); + } + catch(final JRException e) + { + throw new JasperDesignException( + "Registration failed for crosstab measure \"" + measure.getName() + "\"", + e); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/DatasetExpressionTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/DatasetExpressionTransform.java new file mode 100644 index 0000000..998f80d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/DatasetExpressionTransform.java @@ -0,0 +1,126 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.design.definition.DRIDesignField; +import software.xdev.dynamicreports.design.definition.DRIDesignSort; +import software.xdev.dynamicreports.design.definition.DRIDesignVariable; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignJasperExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSystemExpression; +import software.xdev.dynamicreports.jasper.base.JasperCustomValues; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.design.JRDesignDataset; +import net.sf.jasperreports.engine.design.JRDesignField; +import net.sf.jasperreports.engine.design.JRDesignSortField; +import net.sf.jasperreports.engine.design.JRDesignVariable; + +import java.util.Collection; + +/** + *

DatasetExpressionTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class DatasetExpressionTransform extends AbstractExpressionTransform { + private DRIDesignDataset dataset; + private JRDesignDataset jrDataset; + private JasperCustomValues customValues; + + /** + *

Constructor for DatasetExpressionTransform.

+ * + * @param dataset a {@link software.xdev.dynamicreports.design.definition.DRIDesignDataset} object. + * @param jrDataset a {@link net.sf.jasperreports.engine.design.JRDesignDataset} object. + * @param customValues a {@link software.xdev.dynamicreports.jasper.base.JasperCustomValues} object. + */ + public DatasetExpressionTransform(DRIDesignDataset dataset, JRDesignDataset jrDataset, JasperCustomValues customValues) { + this.dataset = dataset; + this.jrDataset = jrDataset; + this.customValues = customValues; + } + + /** {@inheritDoc} */ + @Override + protected JasperCustomValues getCustomValues() { + return customValues; + } + + /** {@inheritDoc} */ + @Override + protected Collection getFields() { + return dataset.getFields(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getVariables() { + return dataset.getVariables(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getSystemExpressions() { + return dataset.getSystemExpressions(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getJasperExpressions() { + return dataset.getJasperExpressions(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getSimpleExpressions() { + return dataset.getSimpleExpressions(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getComplexExpressions() { + return dataset.getComplexExpressions(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getSorts() { + return dataset.getSorts(); + } + + /** {@inheritDoc} */ + @Override + protected void addField(JRDesignField field) throws JRException { + jrDataset.addField(field); + } + + /** {@inheritDoc} */ + @Override + protected void addVariable(JRDesignVariable variable) throws JRException { + jrDataset.addVariable(variable); + } + + /** {@inheritDoc} */ + @Override + protected void addSort(JRDesignSortField sort) throws JRException { + jrDataset.addSortField(sort); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/DatasetTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/DatasetTransform.java new file mode 100644 index 0000000..94f03ce --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/DatasetTransform.java @@ -0,0 +1,154 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.jasper.base.JasperCustomValues; +import software.xdev.dynamicreports.jasper.base.JasperScriptlet; +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import software.xdev.dynamicreports.jasper.transformation.expression.DatasetParametersExpression; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.design.JRDesignDataset; +import net.sf.jasperreports.engine.design.JRDesignDatasetRun; +import net.sf.jasperreports.engine.design.JRDesignParameter; + +import java.util.HashMap; +import java.util.Map; + +/** + *

DatasetTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class DatasetTransform { + private JasperTransformAccessor accessor; + private Map> datasetParameters; + private Map datasetExpressions; + + /** + *

Constructor for DatasetTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.jasper.transformation.JasperTransformAccessor} object. + */ + public DatasetTransform(JasperTransformAccessor accessor) { + this.accessor = accessor; + datasetParameters = new HashMap>(); + datasetExpressions = new HashMap(); + } + + /** + *

transform.

+ */ + public void transform() { + for (DRIDesignDataset dataset : accessor.getReport().getDatasets()) { + addDataset(dataset); + } + } + + private void addDataset(DRIDesignDataset dataset) { + try { + accessor.getDesign().addDataset(dataset(dataset)); + } catch (JRException e) { + throw new JasperDesignException("Registration failed for dataset \"" + dataset.getName() + "\"", e); + } + } + + // dataset + private JRDesignDataset dataset(DRIDesignDataset dataset) { + Map parameters = new HashMap(); + datasetParameters.put(dataset, parameters); + JRDesignDataset jrDataset = new JRDesignDataset(false); + jrDataset.setName(dataset.getName()); + if (dataset.getQuery() != null) { + jrDataset.setQuery(accessor.getReportTransform().query(dataset.getQuery())); + } + JasperCustomValues customValues = new JasperCustomValues(accessor.getReport().getProperties()); + DatasetExpressionTransform datasetExpressionTransform = new DatasetExpressionTransform(dataset, jrDataset, customValues); + datasetExpressionTransform.transform(); + datasetExpressions.put(dataset, datasetExpressionTransform); + if (!customValues.isEmpty()) { + addParameter(jrDataset, parameters, JasperCustomValues.NAME, JasperCustomValues.class, customValues); + addScriptlet(jrDataset, parameters, JasperScriptlet.NAME); + } + jrDataset.setFilterExpression(datasetExpressionTransform.getExpression(dataset.getFilterExpression())); + return jrDataset; + } + + private void addParameter(JRDesignDataset jrDataset, Map parameters, String name, Class parameterClass, T value) { + JRDesignParameter jrParameter = new JRDesignParameter(); + jrParameter.setName(name); + jrParameter.setValueClass(parameterClass); + try { + jrDataset.addParameter(jrParameter); + } catch (JRException e) { + throw new JasperDesignException("Registration failed for parameter \"" + name + "\"", e); + } + parameters.put(jrParameter.getName(), value); + } + + private void addScriptlet(JRDesignDataset jrDataset, Map parameters, String name) { + try { + jrDataset.addScriptlet(accessor.getReportTransform().scriptlet(name, JasperScriptlet.class)); + } catch (JRException e) { + throw new JasperDesignException("Registration failed for scriptlet \"" + name + "\"", e); + } + } + + /** + *

datasetRun.

+ * + * @param dataset a {@link software.xdev.dynamicreports.design.definition.DRIDesignDataset} object. + * @return a {@link net.sf.jasperreports.engine.design.JRDesignDatasetRun} object. + */ + public JRDesignDatasetRun datasetRun(DRIDesignDataset dataset) { + if (dataset == null) { + return null; + } + + JRDesignDatasetRun jrDatasetRun = new JRDesignDatasetRun(); + jrDatasetRun.setDatasetName(dataset.getName()); + jrDatasetRun.setConnectionExpression(accessor.getExpressionTransform().getExpression(dataset.getConnectionExpression())); + jrDatasetRun.setDataSourceExpression(accessor.getExpressionTransform().getExpression(dataset.getDataSourceExpression())); + DatasetParametersExpression parametersExpression = new DatasetParametersExpression(datasetParameters.get(dataset)); + accessor.getExpressionTransform().addSimpleExpression(parametersExpression); + jrDatasetRun.setParametersMapExpression(accessor.getExpressionTransform().getExpression(parametersExpression)); + return jrDatasetRun; + } + + /** + *

Getter for the field datasetParameters.

+ * + * @param dataset a {@link software.xdev.dynamicreports.design.definition.DRIDesignDataset} object. + * @return a {@link java.util.Map} object. + */ + protected Map getDatasetParameters(DRIDesignDataset dataset) { + return datasetParameters.get(dataset); + } + + /** + *

getDatasetExpressionTransform.

+ * + * @param dataset a {@link software.xdev.dynamicreports.design.definition.DRIDesignDataset} object. + * @return a {@link software.xdev.dynamicreports.jasper.transformation.DatasetExpressionTransform} object. + */ + public DatasetExpressionTransform getDatasetExpressionTransform(DRIDesignDataset dataset) { + return datasetExpressions.get(dataset); + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ExporterTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ExporterTransform.java new file mode 100644 index 0000000..fcbaa76 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ExporterTransform.java @@ -0,0 +1,877 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import java.io.File; + +import net.sf.jasperreports.engine.export.FileHtmlResourceHandler; +import net.sf.jasperreports.engine.export.HtmlExporter; +import net.sf.jasperreports.engine.export.HtmlResourceHandler; +import net.sf.jasperreports.engine.export.JRCsvExporter; +import net.sf.jasperreports.engine.export.JRPdfExporter; +import net.sf.jasperreports.engine.export.JRRtfExporter; +import net.sf.jasperreports.engine.export.JRTextExporter; +import net.sf.jasperreports.engine.export.oasis.JROdsExporter; +import net.sf.jasperreports.engine.export.oasis.JROdtExporter; +import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter; +import net.sf.jasperreports.engine.export.ooxml.JRPptxExporter; +import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter; +import net.sf.jasperreports.export.AbstractXlsExporterConfiguration; +import net.sf.jasperreports.export.AbstractXlsReportConfiguration; +import net.sf.jasperreports.export.Exporter; +import net.sf.jasperreports.export.SimpleCsvExporterConfiguration; +import net.sf.jasperreports.export.SimpleCsvReportConfiguration; +import net.sf.jasperreports.export.SimpleDocxExporterConfiguration; +import net.sf.jasperreports.export.SimpleDocxReportConfiguration; +import net.sf.jasperreports.export.SimpleHtmlExporterConfiguration; +import net.sf.jasperreports.export.SimpleHtmlExporterOutput; +import net.sf.jasperreports.export.SimpleHtmlReportConfiguration; +import net.sf.jasperreports.export.SimpleOdsExporterConfiguration; +import net.sf.jasperreports.export.SimpleOdsReportConfiguration; +import net.sf.jasperreports.export.SimpleOdtExporterConfiguration; +import net.sf.jasperreports.export.SimpleOdtReportConfiguration; +import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput; +import net.sf.jasperreports.export.SimplePdfExporterConfiguration; +import net.sf.jasperreports.export.SimplePdfReportConfiguration; +import net.sf.jasperreports.export.SimplePptxExporterConfiguration; +import net.sf.jasperreports.export.SimplePptxReportConfiguration; +import net.sf.jasperreports.export.SimpleReportExportConfiguration; +import net.sf.jasperreports.export.SimpleRtfExporterConfiguration; +import net.sf.jasperreports.export.SimpleRtfReportConfiguration; +import net.sf.jasperreports.export.SimpleTextExporterConfiguration; +import net.sf.jasperreports.export.SimpleTextReportConfiguration; +import net.sf.jasperreports.export.SimpleWriterExporterOutput; +import net.sf.jasperreports.export.SimpleXlsxExporterConfiguration; +import net.sf.jasperreports.export.SimpleXlsxReportConfiguration; +import net.sf.jasperreports.web.util.WebHtmlResourceHandler; +import software.xdev.dynamicreports.design.transformation.StyleResolver; +import software.xdev.dynamicreports.jasper.definition.export.JasperICsvExporter; +import software.xdev.dynamicreports.jasper.definition.export.JasperIDocxExporter; +import software.xdev.dynamicreports.jasper.definition.export.JasperIExcelExporter; +import software.xdev.dynamicreports.jasper.definition.export.JasperIExporter; +import software.xdev.dynamicreports.jasper.definition.export.JasperIHtmlExporter; +import software.xdev.dynamicreports.jasper.definition.export.JasperIOdsExporter; +import software.xdev.dynamicreports.jasper.definition.export.JasperIOdtExporter; +import software.xdev.dynamicreports.jasper.definition.export.JasperIPdfExporter; +import software.xdev.dynamicreports.jasper.definition.export.JasperIPptxExporter; +import software.xdev.dynamicreports.jasper.definition.export.JasperIRtfExporter; +import software.xdev.dynamicreports.jasper.definition.export.JasperITextExporter; +import software.xdev.dynamicreports.jasper.definition.export.JasperIXlsxExporter; +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import software.xdev.dynamicreports.report.base.style.DRFont; +import software.xdev.dynamicreports.report.defaults.Defaults; +import software.xdev.dynamicreports.report.exception.DRException; + + +/** + *

ExporterTransform class.

+ * + * @author Ricardo Mariaca + */ +public class ExporterTransform +{ + private final JasperIExporter jasperExporter; + + /** + *

Constructor for ExporterTransform.

+ * + * @param jasperExporter a {@link software.xdev.dynamicreports.jasper.definition.export.JasperIExporter} object. + */ + public ExporterTransform(final JasperIExporter jasperExporter) + { + this.jasperExporter = jasperExporter; + } + + /** + *

transform.

+ * + * @return a {@link net.sf.jasperreports.export.Exporter} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public Exporter transform() throws DRException + { + final Exporter jrExporter; + + if(this.jasperExporter instanceof JasperICsvExporter) + { + jrExporter = this.csv((JasperICsvExporter)this.jasperExporter); + } + else if(this.jasperExporter instanceof JasperIDocxExporter) + { + jrExporter = this.docx((JasperIDocxExporter)this.jasperExporter); + } + else if(this.jasperExporter instanceof JasperIXlsxExporter) + { + jrExporter = this.xlsx((JasperIXlsxExporter)this.jasperExporter); + } + else if(this.jasperExporter instanceof JasperIHtmlExporter) + { + jrExporter = this.html((JasperIHtmlExporter)this.jasperExporter); + } + else if(this.jasperExporter instanceof JasperIOdsExporter) + { + jrExporter = this.ods((JasperIOdsExporter)this.jasperExporter); + } + else if(this.jasperExporter instanceof JasperIOdtExporter) + { + jrExporter = this.odt((JasperIOdtExporter)this.jasperExporter); + } + else if(this.jasperExporter instanceof JasperIPdfExporter) + { + jrExporter = this.pdf((JasperIPdfExporter)this.jasperExporter); + } + else if(this.jasperExporter instanceof JasperIRtfExporter) + { + jrExporter = this.rtf((JasperIRtfExporter)this.jasperExporter); + } + else if(this.jasperExporter instanceof JasperITextExporter) + { + jrExporter = this.text((JasperITextExporter)this.jasperExporter); + } + else if(this.jasperExporter instanceof JasperIPptxExporter) + { + jrExporter = this.pptx((JasperIPptxExporter)this.jasperExporter); + } + else + { + throw new JasperDesignException("Exporter " + this.jasperExporter.getClass().getName() + " not supported"); + } + + return jrExporter; + } + + private SimpleWriterExporterOutput simpleWriterExporterOutput(final JasperIExporter jasperExporter) + { + if(jasperExporter.getOutputWriter() != null) + { + return new SimpleWriterExporterOutput(jasperExporter.getOutputWriter()); + } + if(jasperExporter.getOutputStream() != null) + { + if(jasperExporter.getCharacterEncoding() != null) + { + return new SimpleWriterExporterOutput( + jasperExporter.getOutputStream(), + jasperExporter.getCharacterEncoding()); + } + else + { + return new SimpleWriterExporterOutput(jasperExporter.getOutputStream()); + } + } + if(jasperExporter.getOutputFile() != null) + { + if(jasperExporter.getCharacterEncoding() != null) + { + return new SimpleWriterExporterOutput( + jasperExporter.getOutputFile(), + jasperExporter.getCharacterEncoding()); + } + else + { + return new SimpleWriterExporterOutput(jasperExporter.getOutputFile()); + } + } + if(jasperExporter.getOutputFileName() != null) + { + if(jasperExporter.getCharacterEncoding() != null) + { + return new SimpleWriterExporterOutput( + jasperExporter.getOutputFileName(), + jasperExporter.getCharacterEncoding()); + } + else + { + return new SimpleWriterExporterOutput(jasperExporter.getOutputFileName()); + } + } + return null; + } + + private SimpleOutputStreamExporterOutput simpleOutputStreamExporterOutput(final JasperIExporter jasperExporter) + { + if(jasperExporter.getOutputStream() != null) + { + return new SimpleOutputStreamExporterOutput(jasperExporter.getOutputStream()); + } + if(jasperExporter.getOutputFile() != null) + { + return new SimpleOutputStreamExporterOutput(jasperExporter.getOutputFile()); + } + if(jasperExporter.getOutputFileName() != null) + { + return new SimpleOutputStreamExporterOutput(jasperExporter.getOutputFileName()); + } + return null; + } + + private SimpleHtmlExporterOutput simpleHtmlExporterOutput(final JasperIExporter jasperExporter) + { + if(jasperExporter.getOutputWriter() != null) + { + return new SimpleHtmlExporterOutput(jasperExporter.getOutputWriter()); + } + if(jasperExporter.getOutputStream() != null) + { + if(jasperExporter.getCharacterEncoding() != null) + { + return new SimpleHtmlExporterOutput( + jasperExporter.getOutputStream(), + jasperExporter.getCharacterEncoding()); + } + else + { + return new SimpleHtmlExporterOutput(jasperExporter.getOutputStream()); + } + } + if(jasperExporter.getOutputFile() != null) + { + if(jasperExporter.getCharacterEncoding() != null) + { + return new SimpleHtmlExporterOutput( + jasperExporter.getOutputFile(), + jasperExporter.getCharacterEncoding()); + } + else + { + return new SimpleHtmlExporterOutput(jasperExporter.getOutputFile()); + } + } + if(jasperExporter.getOutputFileName() != null) + { + if(jasperExporter.getCharacterEncoding() != null) + { + return new SimpleHtmlExporterOutput( + jasperExporter.getOutputFileName(), + jasperExporter.getCharacterEncoding()); + } + else + { + return new SimpleHtmlExporterOutput(jasperExporter.getOutputFileName()); + } + } + return null; + } + + private void reportExportConfiguration( + final SimpleReportExportConfiguration reportExportConfiguration, + final JasperIExporter jasperExporter) + { + if(jasperExporter.getPageIndex() != null) + { + reportExportConfiguration.setPageIndex(jasperExporter.getPageIndex()); + } + if(jasperExporter.getStartPageIndex() != null) + { + reportExportConfiguration.setStartPageIndex(jasperExporter.getStartPageIndex()); + } + if(jasperExporter.getEndPageIndex() != null) + { + reportExportConfiguration.setEndPageIndex(jasperExporter.getEndPageIndex()); + } + if(jasperExporter.getOffsetX() != null) + { + reportExportConfiguration.setOffsetX(jasperExporter.getOffsetX()); + } + if(jasperExporter.getOffsetY() != null) + { + reportExportConfiguration.setOffsetY(jasperExporter.getOffsetY()); + } + } + + private JRPptxExporter pptx(final JasperIPptxExporter jasperExporter) + { + final SimpleOutputStreamExporterOutput exporterOutput = this.simpleOutputStreamExporterOutput(jasperExporter); + final SimplePptxReportConfiguration reportExportConfiguration = new SimplePptxReportConfiguration(); + this.reportExportConfiguration(reportExportConfiguration, jasperExporter); + if(jasperExporter.getIgnoreHyperLink() != null) + { + reportExportConfiguration.setIgnoreHyperlink(jasperExporter.getIgnoreHyperLink()); + } + final SimplePptxExporterConfiguration exporterConfiguration = new SimplePptxExporterConfiguration(); + + final JRPptxExporter jrExporter = new JRPptxExporter(); + jrExporter.setExporterOutput(exporterOutput); + jrExporter.setConfiguration(reportExportConfiguration); + jrExporter.setConfiguration(exporterConfiguration); + return jrExporter; + } + + private JRTextExporter text(final JasperITextExporter jasperExporter) + { + final SimpleWriterExporterOutput exporterOutput = this.simpleWriterExporterOutput(jasperExporter); + final SimpleTextReportConfiguration reportExportConfiguration = new SimpleTextReportConfiguration(); + this.reportExportConfiguration(reportExportConfiguration, jasperExporter); + if(jasperExporter.getCharacterWidth() != null) + { + reportExportConfiguration.setCharWidth(jasperExporter.getCharacterWidth()); + } + else + { + final DRFont font = Defaults.getDefaults().getFont(); + reportExportConfiguration.setCharWidth((float)StyleResolver.getFontWidth(font)); + } + if(jasperExporter.getCharacterHeight() != null) + { + reportExportConfiguration.setCharHeight(jasperExporter.getCharacterHeight()); + } + else + { + final DRFont font = Defaults.getDefaults().getFont(); + reportExportConfiguration.setCharHeight((float)StyleResolver.getFontHeight(font)); + } + if(jasperExporter.getPageWidthInChars() != null) + { + reportExportConfiguration.setPageWidthInChars(jasperExporter.getPageWidthInChars()); + } + if(jasperExporter.getPageHeightInChars() != null) + { + reportExportConfiguration.setPageHeightInChars(jasperExporter.getPageHeightInChars()); + } + final SimpleTextExporterConfiguration exporterConfiguration = new SimpleTextExporterConfiguration(); + if(jasperExporter.getPageSeparator() != null) + { + exporterConfiguration.setPageSeparator(jasperExporter.getPageSeparator()); + } + if(jasperExporter.getLineSeparator() != null) + { + exporterConfiguration.setLineSeparator(jasperExporter.getLineSeparator()); + } + if(jasperExporter.getTrimLineRight() != null) + { + exporterConfiguration.setTrimLineRight(jasperExporter.getTrimLineRight()); + } + + final JRTextExporter jrExporter = new JRTextExporter(); + jrExporter.setExporterOutput(exporterOutput); + jrExporter.setConfiguration(reportExportConfiguration); + jrExporter.setConfiguration(exporterConfiguration); + return jrExporter; + } + + private JRRtfExporter rtf(final JasperIRtfExporter jasperExporter) + { + final SimpleWriterExporterOutput exporterOutput = this.simpleWriterExporterOutput(jasperExporter); + final SimpleRtfReportConfiguration reportExportConfiguration = new SimpleRtfReportConfiguration(); + this.reportExportConfiguration(reportExportConfiguration, jasperExporter); + if(jasperExporter.getIgnoreHyperLink() != null) + { + reportExportConfiguration.setIgnoreHyperlink(jasperExporter.getIgnoreHyperLink()); + } + final SimpleRtfExporterConfiguration exporterConfiguration = new SimpleRtfExporterConfiguration(); + + final JRRtfExporter jrExporter = new JRRtfExporter(); + jrExporter.setExporterOutput(exporterOutput); + jrExporter.setConfiguration(reportExportConfiguration); + jrExporter.setConfiguration(exporterConfiguration); + return jrExporter; + } + + private JRPdfExporter pdf(final JasperIPdfExporter jasperExporter) + { + final SimpleOutputStreamExporterOutput exporterOutput = this.simpleOutputStreamExporterOutput(jasperExporter); + final SimplePdfReportConfiguration reportExportConfiguration = new SimplePdfReportConfiguration(); + this.reportExportConfiguration(reportExportConfiguration, jasperExporter); + if(jasperExporter.getForceSvgShapes() != null) + { + reportExportConfiguration.setForceSvgShapes(jasperExporter.getForceSvgShapes()); + } + if(jasperExporter.getCollapseMissingBookmarkLevels() != null) + { + reportExportConfiguration.setCollapseMissingBookmarkLevels(jasperExporter.getCollapseMissingBookmarkLevels()); + } + if(jasperExporter.getSizePageToContent() != null) + { + reportExportConfiguration.setSizePageToContent(jasperExporter.getSizePageToContent()); + } + if(jasperExporter.getIgnoreHyperLink() != null) + { + reportExportConfiguration.setIgnoreHyperlink(jasperExporter.getIgnoreHyperLink()); + } + if(jasperExporter.getForceLineBreakPolicy() != null) + { + reportExportConfiguration.setForceLineBreakPolicy(jasperExporter.getForceLineBreakPolicy()); + } + final SimplePdfExporterConfiguration exporterConfiguration = new SimplePdfExporterConfiguration(); + if(jasperExporter.getCreatingBatchModeBookmarks() != null) + { + exporterConfiguration.setCreatingBatchModeBookmarks(jasperExporter.getCreatingBatchModeBookmarks()); + } + if(jasperExporter.getCompressed() != null) + { + exporterConfiguration.setCompressed(jasperExporter.getCompressed()); + } + if(jasperExporter.getEncrypted() != null) + { + exporterConfiguration.setEncrypted(jasperExporter.getEncrypted()); + } + if(jasperExporter.getBitKey128() != null) + { + exporterConfiguration.set128BitKey(jasperExporter.getBitKey128()); + } + if(jasperExporter.getUserPassword() != null) + { + exporterConfiguration.setUserPassword(jasperExporter.getUserPassword()); + } + if(jasperExporter.getOwnerPassword() != null) + { + exporterConfiguration.setOwnerPassword(jasperExporter.getOwnerPassword()); + } + if(jasperExporter.getPermissions() != null && !jasperExporter.getPermissions().isEmpty()) + { + exporterConfiguration.setPermissions(ConstantTransform.pdfPermission(jasperExporter.getPermissions())); + } + if(jasperExporter.getPdfVersion() != null) + { + exporterConfiguration.setPdfVersion(ConstantTransform.pdfVersion(jasperExporter.getPdfVersion())); + } + if(jasperExporter.getMetadataTitle() != null) + { + exporterConfiguration.setMetadataTitle(jasperExporter.getMetadataTitle()); + } + if(jasperExporter.getMetadataAuthor() != null) + { + exporterConfiguration.setMetadataAuthor(jasperExporter.getMetadataAuthor()); + } + if(jasperExporter.getMetadataSubject() != null) + { + exporterConfiguration.setMetadataSubject(jasperExporter.getMetadataSubject()); + } + if(jasperExporter.getMetadataKeyWords() != null) + { + exporterConfiguration.setMetadataKeywords(jasperExporter.getMetadataKeyWords()); + } + if(jasperExporter.getMetadataCreator() != null) + { + exporterConfiguration.setMetadataCreator(jasperExporter.getMetadataCreator()); + } + if(jasperExporter.getPdfJavaScript() != null) + { + exporterConfiguration.setPdfJavaScript(jasperExporter.getPdfJavaScript()); + } + if(jasperExporter.getTagged() != null) + { + exporterConfiguration.setTagged(jasperExporter.getTagged()); + } + if(jasperExporter.getTagLanguage() != null) + { + exporterConfiguration.setTagLanguage(jasperExporter.getTagLanguage()); + } + if(jasperExporter.getPrintScaling() != null) + { + exporterConfiguration.setPrintScaling(ConstantTransform.pdfPrintScaling(jasperExporter.getPrintScaling())); + } + if(jasperExporter.getPdfaConformance() != null) + { + exporterConfiguration.setPdfaConformance(ConstantTransform.pdfaConformance(jasperExporter.getPdfaConformance())); + } + if(jasperExporter.getIccProfilePath() != null) + { + exporterConfiguration.setIccProfilePath(jasperExporter.getIccProfilePath()); + } + if(jasperExporter.getAllowedPermissionsHint() != null) + { + exporterConfiguration.setAllowedPermissionsHint(jasperExporter.getAllowedPermissionsHint()); + } + if(jasperExporter.getDeniedPermissionsHint() != null) + { + exporterConfiguration.setDeniedPermissionsHint(jasperExporter.getDeniedPermissionsHint()); + } + if(jasperExporter.getDisplayMetadataTitle() != null) + { + exporterConfiguration.setDisplayMetadataTitle(jasperExporter.getDisplayMetadataTitle()); + } + + final JRPdfExporter jrExporter = new JRPdfExporter(); + jrExporter.setExporterOutput(exporterOutput); + jrExporter.setConfiguration(reportExportConfiguration); + jrExporter.setConfiguration(exporterConfiguration); + return jrExporter; + } + + private JROdtExporter odt(final JasperIOdtExporter jasperExporter) + { + final SimpleOutputStreamExporterOutput exporterOutput = this.simpleOutputStreamExporterOutput(jasperExporter); + final SimpleOdtReportConfiguration reportExportConfiguration = new SimpleOdtReportConfiguration(); + this.reportExportConfiguration(reportExportConfiguration, jasperExporter); + if(jasperExporter.getFlexibleRowHeight() != null) + { + reportExportConfiguration.setFlexibleRowHeight(jasperExporter.getFlexibleRowHeight()); + } + if(jasperExporter.getIgnoreHyperLink() != null) + { + reportExportConfiguration.setIgnoreHyperlink(jasperExporter.getIgnoreHyperLink()); + } + final SimpleOdtExporterConfiguration exporterConfiguration = new SimpleOdtExporterConfiguration(); + + final JROdtExporter jrExporter = new JROdtExporter(); + jrExporter.setExporterOutput(exporterOutput); + jrExporter.setConfiguration(reportExportConfiguration); + jrExporter.setConfiguration(exporterConfiguration); + return jrExporter; + } + + private JROdsExporter ods(final JasperIOdsExporter jasperExporter) + { + final SimpleOutputStreamExporterOutput exporterOutput = this.simpleOutputStreamExporterOutput(jasperExporter); + final SimpleOdsReportConfiguration reportExportConfiguration = new SimpleOdsReportConfiguration(); + this.reportExcelExportConfiguration(reportExportConfiguration, jasperExporter); + if(jasperExporter.getFlexibleRowHeight() != null) + { + reportExportConfiguration.setFlexibleRowHeight(jasperExporter.getFlexibleRowHeight()); + } + final SimpleOdsExporterConfiguration exporterConfiguration = new SimpleOdsExporterConfiguration(); + this.reportExcelExporterConfiguration(exporterConfiguration, jasperExporter); + + final JROdsExporter jrExporter = new JROdsExporter(); + jrExporter.setExporterOutput(exporterOutput); + jrExporter.setConfiguration(reportExportConfiguration); + jrExporter.setConfiguration(exporterConfiguration); + return jrExporter; + } + + private HtmlExporter html(final JasperIHtmlExporter jasperExporter) + { + final SimpleHtmlExporterOutput exporterOutput = this.simpleHtmlExporterOutput(jasperExporter); + final Boolean outputImagesToDir = jasperExporter.getOutputImagesToDir(); + final String imagesUri = jasperExporter.getImagesURI(); + HtmlResourceHandler imageHandler = null; + if(outputImagesToDir == null || outputImagesToDir) + { + File imagesDir = null; + final String imagesDirName = jasperExporter.getImagesDirName(); + if(imagesDirName != null) + { + imagesDir = new File(imagesDirName); + } + if(imagesDir != null) + { + imageHandler = new FileHtmlResourceHandler( + imagesDir, + imagesUri == null ? imagesDir.getName() + "/{0}" : imagesUri + "{0}"); + } + } + if(imageHandler == null && imagesUri != null) + { + imageHandler = new WebHtmlResourceHandler(imagesUri + "{0}"); + } + if(imageHandler != null) + { + exporterOutput.setImageHandler(imageHandler); + } + final SimpleHtmlReportConfiguration reportExportConfiguration = new SimpleHtmlReportConfiguration(); + this.reportExportConfiguration(reportExportConfiguration, jasperExporter); + if(jasperExporter.getRemoveEmptySpaceBetweenRows() != null) + { + reportExportConfiguration.setRemoveEmptySpaceBetweenRows(jasperExporter.getRemoveEmptySpaceBetweenRows()); + } + if(jasperExporter.getWhitePageBackground() != null) + { + reportExportConfiguration.setWhitePageBackground(jasperExporter.getWhitePageBackground()); + } + if(jasperExporter.getWrapBreakWord() != null) + { + reportExportConfiguration.setWrapBreakWord(jasperExporter.getWrapBreakWord()); + } + if(jasperExporter.getSizeUnit() != null) + { + reportExportConfiguration.setSizeUnit(ConstantTransform.sizeUnit(jasperExporter.getSizeUnit())); + } + if(jasperExporter.getIgnorePageMargins() != null) + { + reportExportConfiguration.setIgnorePageMargins(jasperExporter.getIgnorePageMargins()); + } + if(jasperExporter.getBorderCollapse() != null) + { + reportExportConfiguration.setBorderCollapse(jasperExporter.getBorderCollapse()); + } + if(jasperExporter.getAccessibleHtml() != null) + { + reportExportConfiguration.setAccessibleHtml(jasperExporter.getAccessibleHtml()); + } + if(jasperExporter.getZoomRatio() != null) + { + reportExportConfiguration.setZoomRatio(jasperExporter.getZoomRatio()); + } + if(jasperExporter.getIgnoreHyperLink() != null) + { + reportExportConfiguration.setIgnoreHyperlink(jasperExporter.getIgnoreHyperLink()); + } + final SimpleHtmlExporterConfiguration exporterConfiguration = new SimpleHtmlExporterConfiguration(); + if(jasperExporter.getHtmlHeader() != null) + { + exporterConfiguration.setHtmlHeader(jasperExporter.getHtmlHeader()); + } + if(jasperExporter.getBetweenPagesHtml() != null) + { + exporterConfiguration.setBetweenPagesHtml(jasperExporter.getBetweenPagesHtml()); + } + if(jasperExporter.getHtmlFooter() != null) + { + exporterConfiguration.setHtmlFooter(jasperExporter.getHtmlFooter()); + } + if(jasperExporter.getFlushOutput() != null) + { + exporterConfiguration.setFlushOutput(jasperExporter.getFlushOutput()); + } + + final HtmlExporter jrExporter = new HtmlExporter(); + jrExporter.setExporterOutput(exporterOutput); + jrExporter.setConfiguration(reportExportConfiguration); + jrExporter.setConfiguration(exporterConfiguration); + return jrExporter; + } + + private void reportExcelExportConfiguration( + final AbstractXlsReportConfiguration reportExportConfiguration, + final JasperIExcelExporter jasperExporter) + { + this.reportExportConfiguration(reportExportConfiguration, jasperExporter); + if(jasperExporter.getOnePagePerSheet() != null) + { + reportExportConfiguration.setOnePagePerSheet(jasperExporter.getOnePagePerSheet()); + } + if(jasperExporter.getRemoveEmptySpaceBetweenRows() != null) + { + reportExportConfiguration.setRemoveEmptySpaceBetweenRows(jasperExporter.getRemoveEmptySpaceBetweenRows()); + } + if(jasperExporter.getRemoveEmptySpaceBetweenColumns() != null) + { + reportExportConfiguration.setRemoveEmptySpaceBetweenColumns(jasperExporter.getRemoveEmptySpaceBetweenColumns()); + } + if(jasperExporter.getWhitePageBackground() != null) + { + reportExportConfiguration.setWhitePageBackground(jasperExporter.getWhitePageBackground()); + } + if(jasperExporter.getDetectCellType() != null) + { + reportExportConfiguration.setDetectCellType(jasperExporter.getDetectCellType()); + } + if(jasperExporter.getSheetNames() != null && !jasperExporter.getSheetNames().isEmpty()) + { + final String[] sheetNames = + jasperExporter.getSheetNames().toArray(new String[jasperExporter.getSheetNames().size()]); + reportExportConfiguration.setSheetNames(sheetNames); + } + if(jasperExporter.getFontSizeFixEnabled() != null) + { + reportExportConfiguration.setFontSizeFixEnabled(jasperExporter.getFontSizeFixEnabled()); + } + if(jasperExporter.getImageBorderFixEnabled() != null) + { + reportExportConfiguration.setImageBorderFixEnabled(jasperExporter.getImageBorderFixEnabled()); + } + if(jasperExporter.getMaxRowsPerSheet() != null) + { + reportExportConfiguration.setMaxRowsPerSheet(jasperExporter.getMaxRowsPerSheet()); + } + if(jasperExporter.getIgnoreGraphics() != null) + { + reportExportConfiguration.setIgnoreGraphics(jasperExporter.getIgnoreGraphics()); + } + if(jasperExporter.getCollapseRowSpan() != null) + { + reportExportConfiguration.setCollapseRowSpan(jasperExporter.getCollapseRowSpan()); + } + if(jasperExporter.getIgnoreCellBorder() != null) + { + reportExportConfiguration.setIgnoreCellBorder(jasperExporter.getIgnoreCellBorder()); + } + if(jasperExporter.getIgnoreCellBackground() != null) + { + reportExportConfiguration.setIgnoreCellBackground(jasperExporter.getIgnoreCellBackground()); + } + if(jasperExporter.getPassword() != null) + { + reportExportConfiguration.setPassword(jasperExporter.getPassword()); + } + if(jasperExporter.getIgnorePageMargins() != null) + { + reportExportConfiguration.setIgnorePageMargins(jasperExporter.getIgnorePageMargins()); + } + if(jasperExporter.getWrapText() != null) + { + reportExportConfiguration.setWrapText(jasperExporter.getWrapText()); + } + if(jasperExporter.getCellLocked() != null) + { + reportExportConfiguration.setCellLocked(jasperExporter.getCellLocked()); + } + if(jasperExporter.getCellHidden() != null) + { + reportExportConfiguration.setCellHidden(jasperExporter.getCellHidden()); + } + if(jasperExporter.getSheetHeaderLeft() != null) + { + reportExportConfiguration.setSheetHeaderLeft(jasperExporter.getSheetHeaderLeft()); + } + if(jasperExporter.getSheetHeaderCenter() != null) + { + reportExportConfiguration.setSheetHeaderCenter(jasperExporter.getSheetHeaderCenter()); + } + if(jasperExporter.getSheetHeaderRight() != null) + { + reportExportConfiguration.setSheetHeaderRight(jasperExporter.getSheetHeaderRight()); + } + if(jasperExporter.getSheetFooterLeft() != null) + { + reportExportConfiguration.setSheetFooterLeft(jasperExporter.getSheetFooterLeft()); + } + if(jasperExporter.getSheetFooterCenter() != null) + { + reportExportConfiguration.setSheetFooterCenter(jasperExporter.getSheetFooterCenter()); + } + if(jasperExporter.getSheetFooterRight() != null) + { + reportExportConfiguration.setSheetFooterRight(jasperExporter.getSheetFooterRight()); + } + if(jasperExporter.getFormatPatternsMap() != null) + { + reportExportConfiguration.setFormatPatternsMap(jasperExporter.getFormatPatternsMap()); + } + if(jasperExporter.getIgnoreHyperLink() != null) + { + reportExportConfiguration.setIgnoreHyperlink(jasperExporter.getIgnoreHyperLink()); + } + if(jasperExporter.getIgnoreAnchors() != null) + { + reportExportConfiguration.setIgnoreAnchors(jasperExporter.getIgnoreAnchors()); + } + if(jasperExporter.getFitWidth() != null) + { + reportExportConfiguration.setFitWidth(jasperExporter.getFitWidth()); + } + if(jasperExporter.getFitHeight() != null) + { + reportExportConfiguration.setFitHeight(jasperExporter.getFitHeight()); + } + if(jasperExporter.getPageScale() != null) + { + reportExportConfiguration.setPageScale(jasperExporter.getPageScale()); + } + if(jasperExporter.getSheetDirection() != null) + { + reportExportConfiguration.setSheetDirection(ConstantTransform.runDirection(jasperExporter.getSheetDirection())); + } + if(jasperExporter.getColumnWidthRatio() != null) + { + reportExportConfiguration.setColumnWidthRatio(jasperExporter.getColumnWidthRatio()); + } + if(jasperExporter.getUseTimeZone() != null) + { + reportExportConfiguration.setUseTimeZone(jasperExporter.getUseTimeZone()); + } + if(jasperExporter.getFirstPageNumber() != null) + { + reportExportConfiguration.setFirstPageNumber(jasperExporter.getFirstPageNumber()); + } + if(jasperExporter.getShowGridLines() != null) + { + reportExportConfiguration.setShowGridLines(jasperExporter.getShowGridLines()); + } + if(jasperExporter.getImageAnchorType() != null) + { + reportExportConfiguration.setImageAnchorType(ConstantTransform.imageAnchorType(jasperExporter.getImageAnchorType())); + } + } + + private void reportExcelExporterConfiguration( + final AbstractXlsExporterConfiguration exporterConfiguration, + final JasperIExcelExporter jasperExporter) + { + if(jasperExporter.getCreateCustomPalette() != null) + { + exporterConfiguration.setCreateCustomPalette(jasperExporter.getCreateCustomPalette()); + } + if(jasperExporter.getWorkbookTemplate() != null) + { + exporterConfiguration.setWorkbookTemplate(jasperExporter.getWorkbookTemplate()); + } + if(jasperExporter.getKeepWorkbookTemplateSheets() != null) + { + exporterConfiguration.setKeepWorkbookTemplateSheets(jasperExporter.getKeepWorkbookTemplateSheets()); + } + } + + private JRXlsxExporter xlsx(final JasperIXlsxExporter jasperExporter) + { + final SimpleOutputStreamExporterOutput exporterOutput = this.simpleOutputStreamExporterOutput(jasperExporter); + final SimpleXlsxReportConfiguration reportExportConfiguration = new SimpleXlsxReportConfiguration(); + this.reportExcelExportConfiguration(reportExportConfiguration, jasperExporter); + final SimpleXlsxExporterConfiguration exporterConfiguration = new SimpleXlsxExporterConfiguration(); + this.reportExcelExporterConfiguration(exporterConfiguration, jasperExporter); + if(jasperExporter.getMacroTemplate() != null) + { + exporterConfiguration.setMacroTemplate(jasperExporter.getMacroTemplate()); + } + + final JRXlsxExporter jrExporter = new JRXlsxExporter(); + jrExporter.setExporterOutput(exporterOutput); + jrExporter.setConfiguration(reportExportConfiguration); + jrExporter.setConfiguration(exporterConfiguration); + return jrExporter; + } + + private JRDocxExporter docx(final JasperIDocxExporter jasperExporter) + { + final SimpleOutputStreamExporterOutput exporterOutput = this.simpleOutputStreamExporterOutput(jasperExporter); + final SimpleDocxReportConfiguration reportExportConfiguration = new SimpleDocxReportConfiguration(); + this.reportExportConfiguration(reportExportConfiguration, jasperExporter); + if(jasperExporter.getFramesAsNestedTables() != null) + { + reportExportConfiguration.setFramesAsNestedTables(jasperExporter.getFramesAsNestedTables()); + } + if(jasperExporter.getFlexibleRowHeight() != null) + { + reportExportConfiguration.setFlexibleRowHeight(jasperExporter.getFlexibleRowHeight()); + } + if(jasperExporter.getIgnoreHyperLink() != null) + { + reportExportConfiguration.setIgnoreHyperlink(jasperExporter.getIgnoreHyperLink()); + } + final SimpleDocxExporterConfiguration exporterConfiguration = new SimpleDocxExporterConfiguration(); + + final JRDocxExporter jrExporter = new JRDocxExporter(); + jrExporter.setExporterOutput(exporterOutput); + jrExporter.setConfiguration(reportExportConfiguration); + jrExporter.setConfiguration(exporterConfiguration); + return jrExporter; + } + + private JRCsvExporter csv(final JasperICsvExporter jasperExporter) + { + final SimpleWriterExporterOutput exporterOutput = this.simpleWriterExporterOutput(jasperExporter); + final SimpleCsvReportConfiguration reportExportConfiguration = new SimpleCsvReportConfiguration(); + this.reportExportConfiguration(reportExportConfiguration, jasperExporter); + final SimpleCsvExporterConfiguration exporterConfiguration = new SimpleCsvExporterConfiguration(); + if(jasperExporter.getFieldDelimiter() != null) + { + exporterConfiguration.setFieldDelimiter(jasperExporter.getFieldDelimiter()); + } + if(jasperExporter.getRecordDelimiter() != null) + { + exporterConfiguration.setRecordDelimiter(jasperExporter.getRecordDelimiter()); + } + + final JRCsvExporter jrExporter = new JRCsvExporter(); + jrExporter.setExporterOutput(exporterOutput); + jrExporter.setConfiguration(reportExportConfiguration); + jrExporter.setConfiguration(exporterConfiguration); + return jrExporter; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/GroupTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/GroupTransform.java new file mode 100644 index 0000000..63bc745 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/GroupTransform.java @@ -0,0 +1,98 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.design.JRDesignGroup; + +/** + *

GroupTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class GroupTransform { + private JasperTransformAccessor accessor; + + /** + *

Constructor for GroupTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.jasper.transformation.JasperTransformAccessor} object. + */ + public GroupTransform(JasperTransformAccessor accessor) { + this.accessor = accessor; + } + + /** + *

transform.

+ */ + public void transform() { + for (DRIDesignGroup group : accessor.getReport().getGroups()) { + addGroup(group); + } + } + + private void addGroup(DRIDesignGroup group) { + try { + JRDesignGroup jrGroup = group(group); + accessor.getDesign().addGroup(jrGroup); + } catch (JRException e) { + throw new JasperDesignException("Registration failed for group \"" + group.getName() + "\"", e); + } + } + + private JRDesignGroup group(DRIDesignGroup group) { + JRDesignGroup jrGroup = new JRDesignGroup(); + jrGroup.setName(group.getName()); + jrGroup.setReprintHeaderOnEachPage(group.isReprintHeaderOnEachPage()); + jrGroup.setStartNewColumn(group.isStartInNewColumn()); + jrGroup.setStartNewPage(group.isStartInNewPage()); + jrGroup.setResetPageNumber(group.isResetPageNumber()); + if (group.getMinHeightToStartNewPage() != null) { + jrGroup.setMinHeightToStartNewPage(group.getMinHeightToStartNewPage()); + } + jrGroup.setFooterPosition(ConstantTransform.groupFooterPosition(group.getFooterPosition())); + jrGroup.setKeepTogether(group.isKeepTogether()); + return jrGroup; + } + + /** + *

transformExpressions.

+ */ + public void transformExpressions() { + for (DRIDesignGroup group : accessor.getReport().getGroups()) { + getGroup(group).setExpression(accessor.getExpressionTransform().getExpression(group.getGroupExpression())); + } + } + + /** + *

getGroup.

+ * + * @param group a {@link software.xdev.dynamicreports.design.definition.DRIDesignGroup} object. + * @return a {@link net.sf.jasperreports.engine.design.JRDesignGroup} object. + */ + public JRDesignGroup getGroup(DRIDesignGroup group) { + JRDesignGroup jrGroup = (JRDesignGroup) accessor.getDesign().getGroupsMap().get(group.getName()); + if (jrGroup == null) { + throw new JasperDesignException("Group " + group.getName() + " is not registered"); + } + return jrGroup; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/JasperTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/JasperTransform.java new file mode 100644 index 0000000..cbe916d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/JasperTransform.java @@ -0,0 +1,198 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import java.util.Map; + +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.design.definition.DRIDesignReport; +import software.xdev.dynamicreports.jasper.base.JasperCustomValues; +import software.xdev.dynamicreports.jasper.base.JasperReportDesign; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.design.JasperDesign; + +/** + *

JasperTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperTransform implements JasperTransformAccessor { + private final DRIDesignReport report; + private final JasperReportDesign jasperReportDesign; + private ReportTransform reportTransform; + private MainDatasetExpressionTransform mainDatasetExpressionTransform; + private BandTransform bandTransform; + private ComponentTransform componentTransform; + private GroupTransform groupTransform; + private StyleTransform styleTransform; + private CrosstabTransform crosstabTransform; + private DatasetTransform datasetTransform; + private AbstractExpressionTransform expressionTransform; + + /** + *

Constructor for JasperTransform.

+ * + * @param report a {@link software.xdev.dynamicreports.design.definition.DRIDesignReport} object. + * @param jasperReportDesign a {@link software.xdev.dynamicreports.jasper.base.JasperReportDesign} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public JasperTransform(final DRIDesignReport report, final JasperReportDesign jasperReportDesign) throws DRException { + this.report = report; + this.jasperReportDesign = jasperReportDesign; + this.init(); + } + + private void init() throws DRException { + this.reportTransform = new ReportTransform(this); + this.mainDatasetExpressionTransform = new MainDatasetExpressionTransform(this); + this.groupTransform = new GroupTransform(this); + this.bandTransform = new BandTransform(this); + this.componentTransform = new ComponentTransform(this); + this.styleTransform = new StyleTransform(this); + this.crosstabTransform = new CrosstabTransform(this); + this.datasetTransform = new DatasetTransform(this); + this.transformToMainDataset(); + } + + /** + *

transform.

+ */ + public void transform() { + this.reportTransform.transform(); + this.datasetTransform.transform(); + this.groupTransform.transform(); + this.mainDatasetExpressionTransform.transform(); + this.reportTransform.transformExpressions(); + this.groupTransform.transformExpressions(); + this.styleTransform.transform(); + this.bandTransform.transform(); + this.reportTransform.addDependencies(); + } + + /** {@inheritDoc} */ + @Override + public ReportTransform getReportTransform() { + return this.reportTransform; + } + + /** {@inheritDoc} */ + @Override + public CrosstabTransform getCrosstabTransform() { + return this.crosstabTransform; + } + + /** {@inheritDoc} */ + @Override + public ComponentTransform getComponentTransform() { + return this.componentTransform; + } + + /** {@inheritDoc} */ + @Override + public void transformToMainDataset() { + this.transformToDataset(null); + } + + /** {@inheritDoc} */ + @Override + public void transformToDataset(final DRIDesignDataset dataset) { + if (dataset != null) { + this.expressionTransform = this.datasetTransform.getDatasetExpressionTransform(dataset); + } else { + this.expressionTransform = this.mainDatasetExpressionTransform; + } + } + + /** {@inheritDoc} */ + @Override + public AbstractExpressionTransform getExpressionTransform() { + return this.expressionTransform; + } + + /** {@inheritDoc} */ + @Override + public AbstractExpressionTransform getExpressionTransform(final DRIDesignDataset dataset) { + if (dataset == null) { + return this.mainDatasetExpressionTransform; + } else { + return this.getDatasetTransform().getDatasetExpressionTransform(dataset); + } + } + + /** {@inheritDoc} */ + @Override + public GroupTransform getGroupTransform() { + return this.groupTransform; + } + + /** {@inheritDoc} */ + @Override + public StyleTransform getStyleTransform() { + return this.styleTransform; + } + + /** {@inheritDoc} */ + @Override + public DatasetTransform getDatasetTransform() { + return this.datasetTransform; + } + + /** {@inheritDoc} */ + @Override + public DRIDesignReport getReport() { + return this.report; + } + + /** {@inheritDoc} */ + @Override + public JasperCustomValues getCustomValues() { + return this.jasperReportDesign.getCustomValues(); + } + + /** {@inheritDoc} */ + @Override + public JasperDesign getDesign() { + return this.jasperReportDesign.getDesign(); + } + + /** {@inheritDoc} */ + @Override + public Map getParameters() { + return this.jasperReportDesign.getParameters(); + } + + /** {@inheritDoc} */ + @Override + public Map getParameterValues() { + return this.report.getParameterValues(); + } + + /** {@inheritDoc} */ + @Override + public Integer getStartPageNumber() { + return this.jasperReportDesign.getStartPageNumber(); + } + + /** {@inheritDoc} */ + @Override + public ReportParameters getMasterReportParameters() { + return this.jasperReportDesign.getMasterReportParameters(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/JasperTransformAccessor.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/JasperTransformAccessor.java new file mode 100644 index 0000000..7b35c68 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/JasperTransformAccessor.java @@ -0,0 +1,153 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import java.util.Map; + +import software.xdev.dynamicreports.design.definition.DRIDesignDataset; +import software.xdev.dynamicreports.design.definition.DRIDesignReport; +import software.xdev.dynamicreports.jasper.base.JasperCustomValues; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import net.sf.jasperreports.engine.design.JasperDesign; + +/** + *

JasperTransformAccessor interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface JasperTransformAccessor { + + /** + *

getReport.

+ * + * @return a {@link software.xdev.dynamicreports.design.definition.DRIDesignReport} object. + */ + public DRIDesignReport getReport(); + + /** + *

getDesign.

+ * + * @return a {@link net.sf.jasperreports.engine.design.JasperDesign} object. + */ + public JasperDesign getDesign(); + + /** + *

getCustomValues.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.base.JasperCustomValues} object. + */ + public JasperCustomValues getCustomValues(); + + /** + *

getParameters.

+ * + * @return a {@link java.util.Map} object. + */ + public Map getParameters(); + + /** + *

getParameterValues.

+ * + * @return a {@link java.util.Map} object. + */ + public Map getParameterValues(); + + /** + *

getStartPageNumber.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getStartPageNumber(); + + /** + *

getMasterReportParameters.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public ReportParameters getMasterReportParameters(); + + /** + *

getReportTransform.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.transformation.ReportTransform} object. + */ + public ReportTransform getReportTransform(); + + /** + *

transformToMainDataset.

+ */ + public void transformToMainDataset(); + + /** + *

transformToDataset.

+ * + * @param dataset a {@link software.xdev.dynamicreports.design.definition.DRIDesignDataset} object. + */ + public void transformToDataset(DRIDesignDataset dataset); + + /** + *

getExpressionTransform.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.transformation.AbstractExpressionTransform} object. + */ + public AbstractExpressionTransform getExpressionTransform(); + + /** + *

getExpressionTransform.

+ * + * @param dataset a {@link software.xdev.dynamicreports.design.definition.DRIDesignDataset} object. + * @return a {@link software.xdev.dynamicreports.jasper.transformation.AbstractExpressionTransform} object. + */ + public AbstractExpressionTransform getExpressionTransform(DRIDesignDataset dataset); + + /** + *

getGroupTransform.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.transformation.GroupTransform} object. + */ + public GroupTransform getGroupTransform(); + + /** + *

getComponentTransform.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.transformation.ComponentTransform} object. + */ + public ComponentTransform getComponentTransform(); + + /** + *

getStyleTransform.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.transformation.StyleTransform} object. + */ + public StyleTransform getStyleTransform(); + + /** + *

getCrosstabTransform.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.transformation.CrosstabTransform} object. + */ + public CrosstabTransform getCrosstabTransform(); + + /** + *

getDatasetTransform.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.transformation.DatasetTransform} object. + */ + public DatasetTransform getDatasetTransform(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/MainDatasetExpressionTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/MainDatasetExpressionTransform.java new file mode 100644 index 0000000..972f2db --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/MainDatasetExpressionTransform.java @@ -0,0 +1,126 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import software.xdev.dynamicreports.design.definition.DRIDesignField; +import software.xdev.dynamicreports.design.definition.DRIDesignGroup; +import software.xdev.dynamicreports.design.definition.DRIDesignSort; +import software.xdev.dynamicreports.design.definition.DRIDesignVariable; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignJasperExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSimpleExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignSystemExpression; +import software.xdev.dynamicreports.jasper.base.JasperCustomValues; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRGroup; +import net.sf.jasperreports.engine.design.JRDesignField; +import net.sf.jasperreports.engine.design.JRDesignSortField; +import net.sf.jasperreports.engine.design.JRDesignVariable; + +import java.util.Collection; + +/** + *

MainDatasetExpressionTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class MainDatasetExpressionTransform extends AbstractExpressionTransform { + private JasperTransformAccessor accessor; + + /** + *

Constructor for MainDatasetExpressionTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.jasper.transformation.JasperTransformAccessor} object. + */ + public MainDatasetExpressionTransform(JasperTransformAccessor accessor) { + this.accessor = accessor; + } + + /** {@inheritDoc} */ + @Override + protected JasperCustomValues getCustomValues() { + return accessor.getCustomValues(); + } + + /** {@inheritDoc} */ + @Override + protected JRGroup getGroup(DRIDesignGroup group) { + return accessor.getGroupTransform().getGroup(group); + } + + /** {@inheritDoc} */ + @Override + protected Collection getFields() { + return accessor.getReport().getFields(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getVariables() { + return accessor.getReport().getVariables(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getSystemExpressions() { + return accessor.getReport().getSystemExpressions(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getJasperExpressions() { + return accessor.getReport().getJasperExpressions(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getSimpleExpressions() { + return accessor.getReport().getSimpleExpressions(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getComplexExpressions() { + return accessor.getReport().getComplexExpressions(); + } + + /** {@inheritDoc} */ + @Override + protected Collection getSorts() { + return accessor.getReport().getSorts(); + } + + /** {@inheritDoc} */ + @Override + protected void addField(JRDesignField field) throws JRException { + accessor.getDesign().addField(field); + } + + /** {@inheritDoc} */ + @Override + protected void addVariable(JRDesignVariable variable) throws JRException { + accessor.getDesign().addVariable(variable); + } + + /** {@inheritDoc} */ + @Override + protected void addSort(JRDesignSortField sort) throws JRException { + accessor.getDesign().addSortField(sort); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ReportTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ReportTransform.java new file mode 100644 index 0000000..4dcb05a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/ReportTransform.java @@ -0,0 +1,294 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import software.xdev.dynamicreports.design.definition.DRIDesignHyperLink; +import software.xdev.dynamicreports.design.definition.DRIDesignMargin; +import software.xdev.dynamicreports.design.definition.DRIDesignPage; +import software.xdev.dynamicreports.design.definition.DRIDesignParameter; +import software.xdev.dynamicreports.design.definition.DRIDesignQuery; +import software.xdev.dynamicreports.design.definition.DRIDesignReport; +import software.xdev.dynamicreports.jasper.base.CustomScriptlet; +import software.xdev.dynamicreports.jasper.base.JasperCustomValues; +import software.xdev.dynamicreports.jasper.base.JasperReportParameters; +import software.xdev.dynamicreports.jasper.base.JasperScriptlet; +import software.xdev.dynamicreports.jasper.base.StartPageNumberScriptlet; +import software.xdev.dynamicreports.jasper.base.tableofcontents.JasperTocHeading; +import software.xdev.dynamicreports.jasper.constant.ValueType; +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import software.xdev.dynamicreports.report.definition.DRIScriptlet; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import net.sf.jasperreports.engine.JRAbstractScriptlet; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRParameter; +import net.sf.jasperreports.engine.JRScriptlet; +import net.sf.jasperreports.engine.design.JRDesignHyperlink; +import net.sf.jasperreports.engine.design.JRDesignParameter; +import net.sf.jasperreports.engine.design.JRDesignQuery; +import net.sf.jasperreports.engine.design.JRDesignScriptlet; +import net.sf.jasperreports.engine.design.JasperDesign; +import net.sf.jasperreports.engine.type.HyperlinkTargetEnum; +import net.sf.jasperreports.engine.type.HyperlinkTypeEnum; + +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Properties; + +/** + *

ReportTransform class.

+ * + * @author Ricardo Mariaca + * + */ +public class ReportTransform { + private JasperTransformAccessor accessor; + + /** + *

Constructor for ReportTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.jasper.transformation.JasperTransformAccessor} object. + */ + public ReportTransform(JasperTransformAccessor accessor) { + this.accessor = accessor; + } + + /** + *

transform.

+ */ + public void transform() { + DRIDesignReport report = accessor.getReport(); + JasperDesign design = accessor.getDesign(); + Map parameters = accessor.getParameters(); + + if (report.isTableOfContents()) { + Map tocHeadings = report.getTableOfContentsHeadings(); + if (tocHeadings == null) { + tocHeadings = new LinkedHashMap(); + } + accessor.getCustomValues().setTocHeadings(tocHeadings); + } + + design.setName(report.getReportName()); + parameters.put(JRParameter.REPORT_LOCALE, report.getLocale()); + parameters.put(JRParameter.REPORT_RESOURCE_BUNDLE, report.getResourceBundle()); + design.setResourceBundle(report.getResourceBundleName()); + design.setIgnorePagination(report.isIgnorePagination()); + setProperties(report.getProperties()); + if (report.getQuery() != null) { + design.setQuery(query(report.getQuery())); + } + page(); + design.setWhenNoDataType(ConstantTransform.whenNoDataType(report.getWhenNoDataType())); + design.setWhenResourceMissingType(ConstantTransform.whenResourceMissingType(report.getWhenResourceMissingType())); + design.setTitleNewPage(report.isTitleOnANewPage()); + design.setSummaryNewPage(report.isSummaryOnANewPage()); + design.setSummaryWithPageHeaderAndFooter(report.isSummaryWithPageHeaderAndFooter()); + design.setFloatColumnFooter(report.isFloatColumnFooter()); + design.setPrintOrder(ConstantTransform.printOrder(report.getPrintOrder())); + design.setColumnDirection(ConstantTransform.runDirection(report.getColumnDirection())); + design.setLanguage(report.getLanguage()); + + for (DRIDesignParameter parameter : report.getParameters()) { + addParameter(parameter); + } + + if (accessor.getStartPageNumber() != null) { + addScriptlet("startPageNumber", StartPageNumberScriptlet.class); + accessor.getCustomValues().setStartPageNumber(accessor.getStartPageNumber()); + } + + for (DRIScriptlet scriptlet : report.getScriptlets()) { + addScriptlet(scriptlet); + } + } + + /** + *

transformExpressions.

+ */ + public void transformExpressions() { + accessor.getDesign().setFilterExpression(accessor.getExpressionTransform().getExpression(accessor.getReport().getFilterExpression())); + } + + /** + *

addDependencies.

+ */ + public void addDependencies() { + DRIDesignReport report = accessor.getReport(); + if (!accessor.getCustomValues().isEmpty() || !report.getScriptlets().isEmpty() || accessor.getCustomValues().getStartPageNumber() != null || report.isTableOfContents()) { + addParameter(JasperCustomValues.NAME, JasperCustomValues.class, accessor.getCustomValues()); + } + if (accessor.getMasterReportParameters() != null) { + addParameter(JasperReportParameters.MASTER_REPORT_PARAMETERS, ReportParameters.class, accessor.getMasterReportParameters()); + } + if (!accessor.getCustomValues().isEmpty() || !report.getScriptlets().isEmpty()) { + addScriptlet(JasperScriptlet.NAME, JasperScriptlet.class); + } + } + + private void addParameter(String name, Class parameterClass, T value) { + if (!accessor.getDesign().getParametersMap().containsKey(name)) { + try { + JRDesignParameter jrParameter = new JRDesignParameter(); + jrParameter.setName(name); + jrParameter.setValueClass(parameterClass); + accessor.getDesign().addParameter(jrParameter); + } catch (JRException e) { + throw new JasperDesignException("Registration failed for parameter \"" + name + "\"", e); + } + } else { + JRParameter jrParameter = accessor.getDesign().getParametersMap().get(name); + if (!parameterClass.isAssignableFrom(jrParameter.getValueClass())) { + throw new JasperDesignException("Registration failed for parameter \"" + name + "\", parameter is not instance of " + parameterClass.getName()); + } + } + if (value != null) { + accessor.getParameters().put(name, value); + } + } + + private void addParameter(DRIDesignParameter parameter) { + try { + if (!parameter.isExternal()) { + accessor.getDesign().addParameter(parameter(parameter)); + } + accessor.getCustomValues().addValueType(parameter.getName(), ValueType.PARAMETER); + if (parameter.getValue() != null) { + accessor.getParameters().put(parameter.getName(), parameter.getValue()); + } + } catch (JRException e) { + throw new JasperDesignException("Registration failed for parameter \"" + parameter.getName() + "\"", e); + } + } + + private void setProperties(Properties properties) { + for ( + Iterator iterator = properties.keySet().iterator(); iterator.hasNext(); ) { + String key = (String) iterator.next(); + accessor.getDesign().setProperty(key, properties.getProperty(key)); + } + } + + private void addScriptlet(DRIScriptlet scriptlet) { + CustomScriptlet customScriptlet = new CustomScriptlet(scriptlet); + addScriptlet(scriptlet.getName(), customScriptlet.getClass()); + accessor.getParameters().put(scriptlet.getName() + JRScriptlet.SCRIPTLET_PARAMETER_NAME_SUFFIX, customScriptlet); + } + + private void addScriptlet(String name, Class scriptletClass) { + try { + accessor.getDesign().addScriptlet(scriptlet(name, scriptletClass)); + } catch (JRException e) { + throw new JasperDesignException("Registration failed for scriptlet \"" + name + "\"", e); + } + } + + /** + *

hyperLink.

+ * + * @param hyperLink a {@link software.xdev.dynamicreports.design.definition.DRIDesignHyperLink} object. + * @return a {@link net.sf.jasperreports.engine.design.JRDesignHyperlink} object. + */ + public JRDesignHyperlink hyperLink(DRIDesignHyperLink hyperLink) { + if (hyperLink == null) { + return null; + } + + JRDesignHyperlink jrHyperLink = new JRDesignHyperlink(); + jrHyperLink.setHyperlinkAnchorExpression(accessor.getExpressionTransform().getExpression(hyperLink.getAnchorExpression())); + jrHyperLink.setHyperlinkPageExpression(accessor.getExpressionTransform().getExpression(hyperLink.getPageExpression())); + jrHyperLink.setHyperlinkReferenceExpression(accessor.getExpressionTransform().getExpression(hyperLink.getReferenceExpression())); + jrHyperLink.setHyperlinkTooltipExpression(accessor.getExpressionTransform().getExpression(hyperLink.getTooltipExpression())); + if (hyperLink.getType() != null) { + HyperlinkTypeEnum hyperLinkType = ConstantTransform.hyperLinkType(hyperLink.getType()); + if (hyperLinkType != null) { + jrHyperLink.setHyperlinkType(hyperLinkType); + } else { + jrHyperLink.setLinkType(hyperLink.getType()); + } + } + if (hyperLink.getTarget() != null) { + HyperlinkTargetEnum hyperLinkTarget = ConstantTransform.hyperLinkTarget(hyperLink.getTarget()); + if (hyperLinkTarget != null) { + jrHyperLink.setHyperlinkTarget(hyperLinkTarget); + } else { + jrHyperLink.setLinkTarget(hyperLink.getTarget()); + } + } + + return jrHyperLink; + } + + // page + private void page() { + DRIDesignPage page = accessor.getReport().getPage(); + DRIDesignMargin margin = page.getMargin(); + JasperDesign design = accessor.getDesign(); + + design.setPageWidth(page.getWidth()); + design.setPageHeight(page.getHeight()); + design.setOrientation(ConstantTransform.pageOrientation(page.getOrientation())); + design.setLeftMargin(margin.getLeft()); + design.setRightMargin(margin.getRight()); + design.setTopMargin(margin.getTop()); + design.setBottomMargin(margin.getBottom()); + design.setColumnCount(page.getColumnsPerPage()); + design.setColumnSpacing(page.getColumnSpace()); + design.setColumnWidth(page.getColumnWidth()); + } + + // parameter + private JRDesignParameter parameter(DRIDesignParameter parameter) { + JRDesignParameter jrParameter = new JRDesignParameter(); + jrParameter.setName(parameter.getName()); + jrParameter.setValueClass(parameter.getValueClass()); + return jrParameter; + } + + // scriptlet + + /** + *

scriptlet.

+ * + * @param name a {@link java.lang.String} object. + * @param scriptletClass a {@link java.lang.Class} object. + * @return a {@link net.sf.jasperreports.engine.design.JRDesignScriptlet} object. + */ + protected JRDesignScriptlet scriptlet(String name, Class scriptletClass) { + JRDesignScriptlet jrScriptlet = new JRDesignScriptlet(); + jrScriptlet.setName(name); + jrScriptlet.setValueClass(scriptletClass); + return jrScriptlet; + } + + // query + + /** + *

query.

+ * + * @param query a {@link software.xdev.dynamicreports.design.definition.DRIDesignQuery} object. + * @return a {@link net.sf.jasperreports.engine.design.JRDesignQuery} object. + */ + protected JRDesignQuery query(DRIDesignQuery query) { + JRDesignQuery jrQuery = new JRDesignQuery(); + jrQuery.setText(query.getText()); + jrQuery.setLanguage(query.getLanguage()); + return jrQuery; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/StyleTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/StyleTransform.java new file mode 100644 index 0000000..adb6f0a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/StyleTransform.java @@ -0,0 +1,238 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation; + +import software.xdev.dynamicreports.design.definition.style.DRIDesignBaseStyle; +import software.xdev.dynamicreports.design.definition.style.DRIDesignBorder; +import software.xdev.dynamicreports.design.definition.style.DRIDesignConditionalStyle; +import software.xdev.dynamicreports.design.definition.style.DRIDesignFont; +import software.xdev.dynamicreports.design.definition.style.DRIDesignPadding; +import software.xdev.dynamicreports.design.definition.style.DRIDesignParagraph; +import software.xdev.dynamicreports.design.definition.style.DRIDesignPen; +import software.xdev.dynamicreports.design.definition.style.DRIDesignStyle; +import software.xdev.dynamicreports.design.definition.style.DRIDesignTabStop; +import software.xdev.dynamicreports.jasper.exception.JasperDesignException; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRLineBox; +import net.sf.jasperreports.engine.JRParagraph; +import net.sf.jasperreports.engine.JRPen; +import net.sf.jasperreports.engine.TabStop; +import net.sf.jasperreports.engine.base.JRBaseFont; +import net.sf.jasperreports.engine.base.JRBaseStyle; +import net.sf.jasperreports.engine.design.JRDesignConditionalStyle; +import net.sf.jasperreports.engine.design.JRDesignExpression; +import net.sf.jasperreports.engine.design.JRDesignStyle; +import net.sf.jasperreports.engine.type.ModeEnum; + +/** + *

StyleTransform class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class StyleTransform { + private final JasperTransformAccessor accessor; + + /** + *

Constructor for StyleTransform.

+ * + * @param accessor a {@link software.xdev.dynamicreports.jasper.transformation.JasperTransformAccessor} object. + */ + public StyleTransform(final JasperTransformAccessor accessor) { + this.accessor = accessor; + } + + /** + *

transform.

+ */ + public void transform() { + for (final DRIDesignStyle style : accessor.getReport().getStyles()) { + addStyle(style); + } + } + + private void addStyle(final DRIDesignStyle style) { + try { + accessor.getDesign().addStyle(style(style)); + } catch (final JRException e) { + throw new JasperDesignException("Registration failed for style \"" + style.getName() + "\"", e); + } + } + + // style + private JRDesignStyle style(final DRIDesignStyle style) { + final JRDesignStyle jrStyle = new JRDesignStyle(); + abstractStyle(jrStyle, style); + + jrStyle.setName(style.getName()); + final DRIDesignStyle parentStyle = style.getParentStyle(); + if (parentStyle != null) { + style(parentStyle); + jrStyle.setParentStyleNameReference(parentStyle.getName()); + } + for (final DRIDesignConditionalStyle conditionalStyle : style.getConditionalStyles()) { + jrStyle.addConditionalStyle(conditionalStyle(conditionalStyle)); + } + return jrStyle; + } + + private JRDesignConditionalStyle conditionalStyle(final DRIDesignConditionalStyle conditionalStyle) { + final JRDesignConditionalStyle jrConditionalStyle = new JRDesignConditionalStyle(); + abstractStyle(jrConditionalStyle, conditionalStyle); + + final AbstractExpressionTransform expressionTransform = accessor.getExpressionTransform(conditionalStyle.getDataset()); + final JRDesignExpression expression = expressionTransform.getExpression(conditionalStyle.getConditionExpression()); + jrConditionalStyle.setConditionExpression(expression); + + return jrConditionalStyle; + } + + private void abstractStyle(final JRBaseStyle baseStyle, final DRIDesignBaseStyle style) { + baseStyle.setForecolor(style.getForegroundColor()); + baseStyle.setBackcolor(style.getBackgroundColor()); + if (style.getBackgroundColor() != null) { + baseStyle.setMode(ModeEnum.OPAQUE); + } + baseStyle.setRadius(style.getRadius()); + baseStyle.setScaleImage(ConstantTransform.imageScale(style.getImageScale())); + baseStyle.setHorizontalTextAlign(ConstantTransform.horizontalTextAlignment(style.getHorizontalTextAlignment())); + baseStyle.setVerticalTextAlign(ConstantTransform.verticalTextAlignment(style.getVerticalTextAlignment())); + baseStyle.setHorizontalImageAlign(ConstantTransform.horizontalImageAlignment(style.getHorizontalImageAlignment())); + baseStyle.setVerticalImageAlign(ConstantTransform.verticalImageAlignment(style.getVerticalImageAlignment())); + border(baseStyle.getLineBox(), style.getBorder()); + padding(baseStyle.getLineBox(), style.getPadding()); + font(baseStyle, style.getFont()); + baseStyle.setRotation(ConstantTransform.rotation(style.getRotation())); + baseStyle.setPattern(style.getPattern()); + baseStyle.setMarkup(ConstantTransform.markup(style.getMarkup())); + baseStyle.setBlankWhenNull(Boolean.TRUE); + paragraph(baseStyle.getParagraph(), style.getParagraph()); + pen(baseStyle.getLinePen(), style.getLinePen()); + } + + private void paragraph(final JRParagraph jrParagraph, final DRIDesignParagraph paragraph) { + jrParagraph.setLineSpacing(ConstantTransform.lineSpacing(paragraph.getLineSpacing())); + jrParagraph.setLineSpacingSize(paragraph.getLineSpacingSize()); + jrParagraph.setFirstLineIndent(paragraph.getFirstLineIndent()); + jrParagraph.setLeftIndent(paragraph.getLeftIndent()); + jrParagraph.setRightIndent(paragraph.getRightIndent()); + jrParagraph.setSpacingBefore(paragraph.getSpacingBefore()); + jrParagraph.setSpacingAfter(paragraph.getSpacingAfter()); + jrParagraph.setTabStopWidth(paragraph.getTabStopWidth()); + for (final DRIDesignTabStop tabStop : paragraph.getTabStops()) { + final TabStop jrTabStop = new TabStop(); + jrTabStop.setPosition(tabStop.getPosition()); + jrTabStop.setAlignment(ConstantTransform.tabStopAlignment(tabStop.getAlignment())); + jrParagraph.addTabStop(jrTabStop); + } + } + + /** + *

pen.

+ * + * @param jrPen a {@link net.sf.jasperreports.engine.JRPen} object. + * @param pen a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignPen} object. + */ + protected void pen(final JRPen jrPen, final DRIDesignPen pen) { + if (pen == null) { + return; + } + + jrPen.setLineColor(pen.getLineColor()); + jrPen.setLineStyle(ConstantTransform.lineStyle(pen.getLineStyle())); + jrPen.setLineWidth(pen.getLineWidth()); + } + + private void border(final JRLineBox lineBox, final DRIDesignBorder border) { + if (border == null) { + return; + } + + pen(lineBox.getLeftPen(), border.getLeftPen()); + pen(lineBox.getRightPen(), border.getRightPen()); + pen(lineBox.getTopPen(), border.getTopPen()); + pen(lineBox.getBottomPen(), border.getBottomPen()); + } + + private void padding(final JRLineBox lineBox, final DRIDesignPadding padding) { + if (padding == null) { + return; + } + + lineBox.setLeftPadding(padding.getLeft()); + lineBox.setRightPadding(padding.getRight()); + lineBox.setTopPadding(padding.getTop()); + lineBox.setBottomPadding(padding.getBottom()); + } + + private void font(final JRBaseStyle baseStyle, final DRIDesignFont font) { + if (font == null) { + return; + } + + baseStyle.setFontName(font.getFontName()); + baseStyle.setBold(font.getBold()); + baseStyle.setItalic(font.getItalic()); + baseStyle.setFontSize(font.getFontSize() == null ? null : font.getFontSize().floatValue()); + baseStyle.setStrikeThrough(font.getStrikeThrough()); + baseStyle.setUnderline(font.getUnderline()); + baseStyle.setPdfFontName(font.getPdfFontName()); + baseStyle.setPdfEncoding(font.getPdfEncoding()); + baseStyle.setPdfEmbedded(font.getPdfEmbedded()); + } + + /** + *

font.

+ * + * @param font a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignFont} object. + * @return a {@link net.sf.jasperreports.engine.base.JRBaseFont} object. + */ + protected JRBaseFont font(final DRIDesignFont font) { + if (font == null) { + return null; + } + + final JRBaseFont jrFont = new JRBaseFont(); + jrFont.setFontName(font.getFontName()); + jrFont.setBold(font.getBold()); + jrFont.setItalic(font.getItalic()); + jrFont.setFontSize(font.getFontSize() == null ? null : font.getFontSize().floatValue()); + jrFont.setStrikeThrough(font.getStrikeThrough()); + jrFont.setUnderline(font.getUnderline()); + jrFont.setPdfFontName(font.getPdfFontName()); + jrFont.setPdfEncoding(font.getPdfEncoding()); + jrFont.setPdfEmbedded(font.getPdfEmbedded()); + return jrFont; + } + + /** + *

getStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.design.definition.style.DRIDesignStyle} object. + * @return a {@link net.sf.jasperreports.engine.design.JRDesignStyle} object. + */ + protected JRDesignStyle getStyle(final DRIDesignStyle style) { + if (style == null) { + return null; + } + if (!accessor.getDesign().getStylesMap().containsKey(style.getName())) { + throw new JasperDesignException("Style \"" + style.getName() + "\" is not registered"); + } + return (JRDesignStyle) accessor.getDesign().getStylesMap().get(style.getName()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/CrosstabParametersExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/CrosstabParametersExpression.java new file mode 100644 index 0000000..1dcdbc9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/CrosstabParametersExpression.java @@ -0,0 +1,63 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation.expression; + +import software.xdev.dynamicreports.design.base.expression.AbstractDesignSimpleExpression; +import software.xdev.dynamicreports.jasper.base.JasperReportParameters; +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +import java.util.HashMap; +import java.util.Map; + +/** + *

CrosstabParametersExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class CrosstabParametersExpression extends AbstractDesignSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Map parameters; + + /** + *

Constructor for CrosstabParametersExpression.

+ * + * @param parameters a {@link java.util.Map} object. + */ + public CrosstabParametersExpression(Map parameters) { + super(ReportUtils.generateUniqueName("crosstabParametersExpression")); + this.parameters = parameters; + } + + /** {@inheritDoc} */ + @Override + public Object evaluate(ReportParameters reportParameters) { + Map parameters = new HashMap(this.parameters); + parameters.put(JasperReportParameters.MASTER_REPORT_PARAMETERS, reportParameters); + return parameters; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return Map.class; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/DatasetParametersExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/DatasetParametersExpression.java new file mode 100644 index 0000000..9337157 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/DatasetParametersExpression.java @@ -0,0 +1,63 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation.expression; + +import software.xdev.dynamicreports.design.base.expression.AbstractDesignSimpleExpression; +import software.xdev.dynamicreports.jasper.base.JasperReportParameters; +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +import java.util.HashMap; +import java.util.Map; + +/** + *

DatasetParametersExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class DatasetParametersExpression extends AbstractDesignSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Map parameters; + + /** + *

Constructor for DatasetParametersExpression.

+ * + * @param parameters a {@link java.util.Map} object. + */ + public DatasetParametersExpression(Map parameters) { + super(ReportUtils.generateUniqueName("datasetParametersExpression")); + this.parameters = parameters; + } + + /** {@inheritDoc} */ + @Override + public Object evaluate(ReportParameters reportParameters) { + Map parameters = new HashMap(this.parameters); + parameters.put(JasperReportParameters.MASTER_REPORT_PARAMETERS, reportParameters); + return parameters; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return Map.class; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/JasperSubreportParametersExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/JasperSubreportParametersExpression.java new file mode 100644 index 0000000..ee938e3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/JasperSubreportParametersExpression.java @@ -0,0 +1,71 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation.expression; + +import software.xdev.dynamicreports.design.base.expression.AbstractDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.jasper.base.JasperReportParameters; +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *

JasperSubreportParametersExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperSubreportParametersExpression extends AbstractDesignComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for JasperSubreportParametersExpression.

+ * + * @param parametersExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public JasperSubreportParametersExpression(DRIDesignExpression parametersExpression) { + super(ReportUtils.generateUniqueName("jasperSubreportParametersExpression")); + if (parametersExpression != null) { + addExpression(parametersExpression); + } + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public Object evaluate(List values, ReportParameters reportParameters) { + Map parameters = null; + if (!values.isEmpty()) { + parameters = (Map) values.get(0); + } else { + parameters = new HashMap(); + } + parameters.put(JasperReportParameters.MASTER_REPORT_PARAMETERS, reportParameters); + return parameters; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return Map.class; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/SubreportExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/SubreportExpression.java new file mode 100644 index 0000000..9a55f70 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/SubreportExpression.java @@ -0,0 +1,133 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation.expression; + +import software.xdev.dynamicreports.design.base.DRDesignReport; +import software.xdev.dynamicreports.design.base.expression.AbstractDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.DRIDesignReport; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.jasper.base.JasperReportDesign; +import software.xdev.dynamicreports.jasper.transformation.JasperTransform; +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRICustomValues; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JasperCompileManager; +import net.sf.jasperreports.engine.JasperReport; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *

SubreportExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class SubreportExpression extends AbstractDesignComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + private static final Log log = LogFactory.getLog(SubreportExpression.class); + + private String name; + private Integer pageWidth; + private ReportBuilder reportBuilder; + private Map, JasperReportDesign> reportDesigns; + private Map, JasperReport> jasperReports; + + /** + *

Constructor for SubreportExpression.

+ * + * @param pageWidthExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + * @param reportExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + * @param pageWidthExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + * @param pageWidth a {@link java.lang.Integer} object. + */ + public SubreportExpression(DRIDesignExpression pageWidthExpression, DRIDesignExpression reportExpression, Integer pageWidth) { + addExpression(pageWidthExpression); + addExpression(reportExpression); + this.pageWidth = pageWidth; + this.name = ReportUtils.generateUniqueName("subreportExpression"); + reportDesigns = new HashMap, JasperReportDesign>(); + jasperReports = new HashMap, JasperReport>(); + } + + /** {@inheritDoc} */ + @Override + public Object evaluate(List values, ReportParameters reportParameters) { + reportBuilder = (ReportBuilder) values.get(1); + if (jasperReports.containsKey(reportBuilder)) { + return jasperReports.get(reportBuilder); + } + try { + DRICustomValues customValues = (DRICustomValues) reportParameters.getParameterValue(DRICustomValues.NAME); + DRIDesignReport report = new DRDesignReport(reportBuilder.build(), pageWidth, customValues.getTocHeadings()); + JasperReportDesign reportDesign = new JasperReportDesign(report, reportParameters, null); + JasperTransform jasperTransform = new JasperTransform(report, reportDesign); + jasperTransform.transform(); + JasperReport jasperReport = JasperCompileManager.compileReport(reportDesign.getDesign()); + reportDesigns.put(reportBuilder, reportDesign); + jasperReports.put(reportBuilder, jasperReport); + return jasperReport; + } catch (JRException e) { + if (log.isErrorEnabled()) { + log.error("Error encountered while creating subreport design", e); + } + } catch (DRException e) { + if (log.isErrorEnabled()) { + log.error("Error encountered while creating subreport design", e); + } + } + return null; + } + + /** + *

getReportDesign.

+ * + * @return a {@link software.xdev.dynamicreports.jasper.base.JasperReportDesign} object. + */ + public JasperReportDesign getReportDesign() { + return reportDesigns.get(reportBuilder); + } + + /** + *

Getter for the field reportBuilder.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportBuilder} object. + */ + public ReportBuilder getReportBuilder() { + return reportBuilder; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return JasperReport.class; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/SubreportParametersExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/SubreportParametersExpression.java new file mode 100644 index 0000000..3d0adf0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/SubreportParametersExpression.java @@ -0,0 +1,77 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation.expression; + +import software.xdev.dynamicreports.design.base.expression.AbstractDesignComplexExpression; +import software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression; +import software.xdev.dynamicreports.jasper.base.JasperReportParameters; +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *

SubreportParametersExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class SubreportParametersExpression extends AbstractDesignComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private SubreportExpression subreportExpression; + + /** + *

Constructor for SubreportParametersExpression.

+ * + * @param subreportExpression a {@link software.xdev.dynamicreports.jasper.transformation.expression.SubreportExpression} object. + * @param parametersExpression a {@link software.xdev.dynamicreports.design.definition.expression.DRIDesignExpression} object. + */ + public SubreportParametersExpression(SubreportExpression subreportExpression, DRIDesignExpression parametersExpression) { + super(ReportUtils.generateUniqueName("subreportParametersExpression")); + this.subreportExpression = subreportExpression; + if (parametersExpression != null) { + addExpression(parametersExpression); + } + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public Object evaluate(List values, ReportParameters reportParameters) { + Map parameters = new HashMap(); + parameters.putAll(subreportExpression.getReportDesign().getParameters()); + if (subreportExpression.getReportBuilder().getReport().getParameterValues() != null) { + parameters.putAll(subreportExpression.getReportBuilder().getReport().getParameterValues()); + } + if (!values.isEmpty()) { + parameters.putAll((Map) values.get(0)); + } + parameters.put(JasperReportParameters.MASTER_REPORT_PARAMETERS, reportParameters); + return parameters; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return Map.class; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/SubreportWidthExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/SubreportWidthExpression.java new file mode 100644 index 0000000..b94443a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/jasper/transformation/expression/SubreportWidthExpression.java @@ -0,0 +1,59 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.transformation.expression; + +import software.xdev.dynamicreports.design.base.expression.AbstractDesignSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRICustomValues; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

SubreportWidthExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class SubreportWidthExpression extends AbstractDesignSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer pageWidth; + + /** + *

Constructor for SubreportWidthExpression.

+ * + * @param pageWidth a {@link java.lang.Integer} object. + */ + public SubreportWidthExpression(Integer pageWidth) { + this.pageWidth = pageWidth; + } + + /** {@inheritDoc} */ + @Override + public Object evaluate(ReportParameters reportParameters) { + DRICustomValues customValues = (DRICustomValues) reportParameters.getParameterValue(DRICustomValues.NAME); + customValues.setSubreportWidth(pageWidth); + return pageWidth; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return Integer.class; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/ReportUtils.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/ReportUtils.java new file mode 100644 index 0000000..f056a29 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/ReportUtils.java @@ -0,0 +1,132 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report; + +import software.xdev.dynamicreports.report.constant.Calculation; + +import java.lang.reflect.ParameterizedType; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +/** + *

+ * ReportUtils class. + *

+ * + * @author Ricardo Mariaca + * + */ +public class ReportUtils { + private static final Lock LOCK = new ReentrantLock(); + private static int counter; + + /** + *

+ * generateUniqueName. + *

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link java.lang.String} object. + */ + public static String generateUniqueName(String name) { + try { + LOCK.lock(); + return generateName(name); + } finally { + LOCK.unlock(); + } + } + + /** + *

+ * getVariableValueClass. + *

+ * + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param valueClass a {@link java.lang.Class} object. + * @return a {@link java.lang.Class} object. + */ + public static Class getVariableValueClass(Calculation calculation, Class valueClass) { + if (calculation.equals(Calculation.COUNT) || calculation.equals(Calculation.DISTINCT_COUNT)) { + return Long.class; + } + if (calculation.equals(Calculation.AVERAGE) || calculation.equals(Calculation.STANDARD_DEVIATION) || calculation.equals(Calculation.VARIANCE)) { + return Number.class; + } + return valueClass; + } + + /** + *

+ * getGenericClass. + *

+ * + * @param object a {@link java.lang.Object} object. + * @param index a int. + * @return a {@link java.lang.Class} object. + */ + public static Class getGenericClass(Object object, int index) { + ParameterizedType genericSuperclass = getParameterizedType(object.getClass()); + if (genericSuperclass == null) { + return String.class; + } + Class rawType = getRawType(genericSuperclass.getActualTypeArguments()[index]); + if (rawType == null) { + return String.class; + } + return rawType; + } + + /** + * Setter for testing purposes only. + * + * @param counter the counter value + */ + static void setCounter(int counter) { + ReportUtils.counter = counter; + } + + private static ParameterizedType getParameterizedType(Class classs) { + if (classs == null) { + return null; + } + if (classs.getGenericSuperclass() instanceof ParameterizedType) { + return (ParameterizedType) classs.getGenericSuperclass(); + } + return getParameterizedType((Class) classs.getGenericSuperclass()); + } + + private static Class getRawType(Object typeArgument) { + if (typeArgument instanceof ParameterizedType) { + return getRawType(((ParameterizedType) typeArgument).getRawType()); + } else { + if (typeArgument instanceof Class) { + return (Class) typeArgument; + } else { + return null; + } + } + } + + private static String generateName(String name) { + if (counter == Integer.MAX_VALUE) { + counter = 0; + } + return name + "_" + counter++ + "_"; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/AbstractScriptlet.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/AbstractScriptlet.java new file mode 100644 index 0000000..f16930c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/AbstractScriptlet.java @@ -0,0 +1,106 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.definition.DRIScriptlet; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract AbstractScriptlet class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractScriptlet implements DRIScriptlet { + private String name; + + /** + *

Constructor for AbstractScriptlet.

+ */ + public AbstractScriptlet() { + this.name = ReportUtils.generateUniqueName("scriptlet"); + } + + /** + *

Constructor for AbstractScriptlet.

+ * + * @param name a {@link java.lang.String} object. + */ + public AbstractScriptlet(String name) { + Validate.notEmpty(name, "name must not be empty"); + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public void afterColumnInit(ReportParameters reportParameters) { + } + + /** {@inheritDoc} */ + @Override + public void afterDetailEval(ReportParameters reportParameters) { + } + + /** {@inheritDoc} */ + @Override + public void afterGroupInit(String groupName, ReportParameters reportParameters) { + } + + /** {@inheritDoc} */ + @Override + public void afterPageInit(ReportParameters reportParameters) { + } + + /** {@inheritDoc} */ + @Override + public void afterReportInit(ReportParameters reportParameters) { + } + + /** {@inheritDoc} */ + @Override + public void beforeColumnInit(ReportParameters reportParameters) { + } + + /** {@inheritDoc} */ + @Override + public void beforeDetailEval(ReportParameters reportParameters) { + } + + /** {@inheritDoc} */ + @Override + public void beforeGroupInit(String groupName, ReportParameters reportParameters) { + } + + /** {@inheritDoc} */ + @Override + public void beforePageInit(ReportParameters reportParameters) { + } + + /** {@inheritDoc} */ + @Override + public void beforeReportInit(ReportParameters reportParameters) { + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/AbstractTemplateDesign.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/AbstractTemplateDesign.java new file mode 100644 index 0000000..c50bc3d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/AbstractTemplateDesign.java @@ -0,0 +1,207 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.DRIMargin; +import software.xdev.dynamicreports.report.definition.DRITemplateDesign; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.List; + +/** + *

Abstract AbstractTemplateDesign class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractTemplateDesign implements DRITemplateDesign { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getReportName() { + return null; + } + + /** {@inheritDoc} */ + @Override + public List> getFields() { + return null; + } + + /** {@inheritDoc} */ + @Override + public boolean isDefinedParameter(String name) { + return false; + } + + /** {@inheritDoc} */ + @Override + public String getResourceBundleName() { + return null; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnorePagination() { + return null; + } + + /** {@inheritDoc} */ + @Override + public WhenNoDataType getWhenNoDataType() { + return null; + } + + /** {@inheritDoc} */ + @Override + public WhenResourceMissingType getWhenResourceMissingType() { + return null; + } + + /** {@inheritDoc} */ + @Override + public Boolean getTitleOnANewPage() { + return null; + } + + /** {@inheritDoc} */ + @Override + public Boolean getSummaryOnANewPage() { + return null; + } + + /** {@inheritDoc} */ + @Override + public Boolean getSummaryWithPageHeaderAndFooter() { + return null; + } + + /** {@inheritDoc} */ + @Override + public Boolean getFloatColumnFooter() { + return null; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageWidth() { + return null; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageHeight() { + return null; + } + + /** {@inheritDoc} */ + @Override + public PageOrientation getPageOrientation() { + return null; + } + + /** {@inheritDoc} */ + @Override + public DRIMargin getPageMargin() { + return null; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageColumnsPerPage() { + return null; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageColumnSpace() { + return null; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageColumnWidth() { + return null; + } + + /** {@inheritDoc} */ + @Override + public int getTitleComponentsCount() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public int getPageHeaderComponentsCount() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public int getPageFooterComponentsCount() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public int getColumnHeaderComponentsCount() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public int getColumnFooterComponentsCount() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public int getLastPageFooterComponentsCount() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public int getSummaryComponentsCount() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public int getNoDataComponentsCount() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public int getBackgroundComponentsCount() { + return 0; + } + + /** {@inheritDoc} */ + @Override + public T getDesign() throws DRException { + return null; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRBand.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRBand.java new file mode 100644 index 0000000..c1fe700 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRBand.java @@ -0,0 +1,92 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.base.component.DRComponent; +import software.xdev.dynamicreports.report.base.component.DRList; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.definition.DRIBand; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRBand class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRBand implements DRIBand { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private SplitType splitType; + private DRList list; + private DRIExpression printWhenExpression; + + /** + *

Constructor for DRBand.

+ */ + public DRBand() { + this.list = new DRList(ListType.VERTICAL); + } + + /** {@inheritDoc} */ + @Override + public SplitType getSplitType() { + return splitType; + } + + /** + *

Setter for the field splitType.

+ * + * @param splitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setSplitType(SplitType splitType) { + this.splitType = splitType; + } + + /** {@inheritDoc} */ + @Override + public DRList getList() { + return list; + } + + /** + *

addComponent.

+ * + * @param component a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void addComponent(DRComponent component) { + list.addComponent(component); + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getPrintWhenExpression() { + return printWhenExpression; + } + + /** + *

Setter for the field printWhenExpression.

+ * + * @param printWhenExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setPrintWhenExpression(DRIExpression printWhenExpression) { + this.printWhenExpression = printWhenExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRDataset.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRDataset.java new file mode 100644 index 0000000..af39302 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRDataset.java @@ -0,0 +1,199 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIDataset; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +import java.sql.Connection; +import java.util.ArrayList; +import java.util.List; + +/** + *

DRDataset class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDataset implements DRIDataset { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private List> fields; + private List> variables; + private List sorts; + private DRQuery query; + private DRIExpression connectionExpression; + private DRIExpression dataSourceExpression; + private DRIExpression filterExpression; + + /** + *

Constructor for DRDataset.

+ */ + public DRDataset() { + init(); + } + + private void init() { + this.fields = new ArrayList>(); + this.variables = new ArrayList>(); + this.sorts = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public List> getFields() { + return fields; + } + + /** + *

Setter for the field fields.

+ * + * @param fields a {@link java.util.List} object. + */ + public void setFields(List> fields) { + Validate.notNull(fields, "fields must not be null"); + Validate.noNullElements(fields, "fields must not contains null field"); + this.fields = fields; + } + + /** + *

addField.

+ * + * @param field a {@link software.xdev.dynamicreports.report.base.DRField} object. + */ + public void addField(DRField field) { + Validate.notNull(field, "field must not be null"); + this.fields.add(field); + } + + /** {@inheritDoc} */ + @Override + public List> getVariables() { + return variables; + } + + /** + *

Setter for the field variables.

+ * + * @param variables a {@link java.util.List} object. + */ + public void setVariables(List> variables) { + Validate.notNull(variables, "variables must not be null"); + Validate.noNullElements(variables, "variables must not contains null variable"); + this.variables = variables; + } + + /** + *

addVariable.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.base.DRVariable} object. + */ + public void addVariable(DRVariable variable) { + Validate.notNull(variable, "variable must not be null"); + this.variables.add(variable); + } + + /** {@inheritDoc} */ + @Override + public List getSorts() { + return sorts; + } + + /** + *

Setter for the field sorts.

+ * + * @param sorts a {@link java.util.List} object. + */ + public void setSorts(List sorts) { + Validate.notNull(sorts, "sorts must not be null"); + Validate.noNullElements(sorts, "sorts must not contains null sort"); + this.sorts = sorts; + } + + /** + *

addSort.

+ * + * @param sort a {@link software.xdev.dynamicreports.report.base.DRSort} object. + */ + public void addSort(DRSort sort) { + Validate.notNull(sort, "sort must not be null"); + this.sorts.add(sort); + } + + /** {@inheritDoc} */ + @Override + public DRQuery getQuery() { + return query; + } + + /** + *

Setter for the field query.

+ * + * @param query a {@link software.xdev.dynamicreports.report.base.DRQuery} object. + */ + public void setQuery(DRQuery query) { + this.query = query; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getConnectionExpression() { + return connectionExpression; + } + + /** + *

Setter for the field connectionExpression.

+ * + * @param connectionExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setConnectionExpression(DRIExpression connectionExpression) { + this.connectionExpression = connectionExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getDataSourceExpression() { + return dataSourceExpression; + } + + /** + *

Setter for the field dataSourceExpression.

+ * + * @param dataSourceExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setDataSourceExpression(DRIExpression dataSourceExpression) { + this.dataSourceExpression = dataSourceExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getFilterExpression() { + return filterExpression; + } + + /** + *

Setter for the field filterExpression.

+ * + * @param filterExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setFilterExpression(DRIExpression filterExpression) { + this.filterExpression = filterExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRField.java new file mode 100644 index 0000000..ac5e071 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRField.java @@ -0,0 +1,93 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import org.apache.commons.lang3.Validate; + +/** + *

DRField class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRField implements DRIField { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private Class valueClass; + private DRIDataType dataType; + private String description; + + /** + *

Constructor for DRField.

+ * + * @param name a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + */ + public DRField(String name, Class valueClass) { + Validate.notEmpty(name, "name must not be empty"); + Validate.notNull(valueClass, "valueClass must not be null"); + this.name = name; + this.valueClass = valueClass; + } + + /** {@inheritDoc} */ + @Override + public DRIDataType getDataType() { + return dataType; + } + + /** + *

Setter for the field dataType.

+ * + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + */ + public void setDataType(DRIDataType dataType) { + this.dataType = dataType; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return valueClass; + } + + /** {@inheritDoc} */ + @Override + public String getDescription() { + return description; + } + + /** + *

Setter for the field description.

+ * + * @param description a {@link java.lang.String} object. + */ + public void setDescription(String description) { + this.description = description; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRGroup.java new file mode 100644 index 0000000..67de268 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRGroup.java @@ -0,0 +1,386 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.definition.DRIGroup; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import org.apache.commons.lang3.Validate; + +/** + *

DRGroup class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRGroup implements DRIGroup { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRTextField valueField; + private DRIExpression titleExpression; + private DRIReportStyle titleStyle; + private Integer titleWidth; + private GroupHeaderLayout headerLayout; + private Boolean hideColumn; + private Boolean groupByDataType; + private Boolean showColumnHeaderAndFooter; + private Boolean addToTableOfContents; + private DRIExpression printSubtotalsWhenExpression; + private Integer padding; + private Boolean startInNewPage; + private Boolean startInNewColumn; + private Boolean reprintHeaderOnEachPage; + private Boolean resetPageNumber; + private Integer minHeightToStartNewPage; + private GroupFooterPosition footerPosition; + private Boolean keepTogether; + private Boolean headerWithSubtotal; + private DRBand headerBand; + private DRBand footerBand; + + /** + *

Constructor for DRGroup.

+ * + * @param valueField a {@link software.xdev.dynamicreports.report.base.component.DRTextField} object. + */ + public DRGroup(DRTextField valueField) { + this(ReportUtils.generateUniqueName("group"), valueField); + } + + /** + *

Constructor for DRGroup.

+ * + * @param name a {@link java.lang.String} object. + * @param valueField a {@link software.xdev.dynamicreports.report.base.component.DRTextField} object. + */ + public DRGroup(String name, DRTextField valueField) { + Validate.notEmpty(name, "name must not be empty"); + Validate.notNull(valueField, "valueField must not be null"); + this.name = name; + this.valueField = valueField; + init(); + } + + private void init() { + headerBand = new DRBand(); + footerBand = new DRBand(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public DRTextField getValueField() { + return valueField; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getTitleExpression() { + return titleExpression; + } + + /** + *

Setter for the field titleExpression.

+ * + * @param titleExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setTitleExpression(DRIExpression titleExpression) { + this.titleExpression = titleExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getTitleStyle() { + return titleStyle; + } + + /** + *

Setter for the field titleStyle.

+ * + * @param titleStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setTitleStyle(DRIReportStyle titleStyle) { + this.titleStyle = titleStyle; + } + + /** {@inheritDoc} */ + @Override + public Integer getTitleWidth() { + return titleWidth; + } + + /** + *

Setter for the field titleWidth.

+ * + * @param titleWidth a {@link java.lang.Integer} object. + */ + public void setTitleWidth(Integer titleWidth) { + this.titleWidth = titleWidth; + } + + /** {@inheritDoc} */ + @Override + public GroupHeaderLayout getHeaderLayout() { + return headerLayout; + } + + /** + *

Setter for the field headerLayout.

+ * + * @param headerLayout a {@link software.xdev.dynamicreports.report.constant.GroupHeaderLayout} object. + */ + public void setHeaderLayout(GroupHeaderLayout headerLayout) { + this.headerLayout = headerLayout; + } + + /** {@inheritDoc} */ + @Override + public Boolean getHideColumn() { + return hideColumn; + } + + /** + *

Setter for the field hideColumn.

+ * + * @param hideColumn a {@link java.lang.Boolean} object. + */ + public void setHideColumn(Boolean hideColumn) { + this.hideColumn = hideColumn; + } + + /** {@inheritDoc} */ + @Override + public Boolean getGroupByDataType() { + return groupByDataType; + } + + /** + *

Setter for the field groupByDataType.

+ * + * @param groupByDataType a {@link java.lang.Boolean} object. + */ + public void setGroupByDataType(Boolean groupByDataType) { + this.groupByDataType = groupByDataType; + } + + /** {@inheritDoc} */ + @Override + public Boolean getShowColumnHeaderAndFooter() { + return showColumnHeaderAndFooter; + } + + /** + *

Setter for the field showColumnHeaderAndFooter.

+ * + * @param showColumnHeaderAndFooter a {@link java.lang.Boolean} object. + */ + public void setShowColumnHeaderAndFooter(Boolean showColumnHeaderAndFooter) { + this.showColumnHeaderAndFooter = showColumnHeaderAndFooter; + } + + /** {@inheritDoc} */ + @Override + public Boolean getAddToTableOfContents() { + return addToTableOfContents; + } + + /** + *

Setter for the field addToTableOfContents.

+ * + * @param addToTableOfContents a {@link java.lang.Boolean} object. + */ + public void setAddToTableOfContents(Boolean addToTableOfContents) { + this.addToTableOfContents = addToTableOfContents; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getPrintSubtotalsWhenExpression() { + return printSubtotalsWhenExpression; + } + + /** + *

Setter for the field printSubtotalsWhenExpression.

+ * + * @param printSubtotalsWhenExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setPrintSubtotalsWhenExpression(DRIExpression printSubtotalsWhenExpression) { + this.printSubtotalsWhenExpression = printSubtotalsWhenExpression; + } + + /** {@inheritDoc} */ + @Override + public Integer getPadding() { + return padding; + } + + /** + *

Setter for the field padding.

+ * + * @param padding a {@link java.lang.Integer} object. + */ + public void setPadding(Integer padding) { + if (padding != null) { + Validate.isTrue(padding >= 0, "padding must be >= 0"); + } + this.padding = padding; + } + + /** {@inheritDoc} */ + @Override + public Boolean getStartInNewPage() { + return startInNewPage; + } + + /** + *

Setter for the field startInNewPage.

+ * + * @param startInNewPage a {@link java.lang.Boolean} object. + */ + public void setStartInNewPage(Boolean startInNewPage) { + this.startInNewPage = startInNewPage; + } + + /** {@inheritDoc} */ + @Override + public Boolean getStartInNewColumn() { + return startInNewColumn; + } + + /** + *

Setter for the field startInNewColumn.

+ * + * @param startInNewColumn a {@link java.lang.Boolean} object. + */ + public void setStartInNewColumn(Boolean startInNewColumn) { + this.startInNewColumn = startInNewColumn; + } + + /** {@inheritDoc} */ + @Override + public Boolean getReprintHeaderOnEachPage() { + return reprintHeaderOnEachPage; + } + + /** + *

Setter for the field reprintHeaderOnEachPage.

+ * + * @param reprintHeaderOnEachPage a {@link java.lang.Boolean} object. + */ + public void setReprintHeaderOnEachPage(Boolean reprintHeaderOnEachPage) { + this.reprintHeaderOnEachPage = reprintHeaderOnEachPage; + } + + /** {@inheritDoc} */ + @Override + public Boolean getResetPageNumber() { + return resetPageNumber; + } + + /** + *

Setter for the field resetPageNumber.

+ * + * @param resetPageNumber a {@link java.lang.Boolean} object. + */ + public void setResetPageNumber(Boolean resetPageNumber) { + this.resetPageNumber = resetPageNumber; + } + + /** {@inheritDoc} */ + @Override + public Integer getMinHeightToStartNewPage() { + return minHeightToStartNewPage; + } + + /** + *

Setter for the field minHeightToStartNewPage.

+ * + * @param minHeightToStartNewPage a {@link java.lang.Integer} object. + */ + public void setMinHeightToStartNewPage(Integer minHeightToStartNewPage) { + this.minHeightToStartNewPage = minHeightToStartNewPage; + } + + /** {@inheritDoc} */ + @Override + public GroupFooterPosition getFooterPosition() { + return footerPosition; + } + + /** + *

Setter for the field footerPosition.

+ * + * @param footerPosition a {@link software.xdev.dynamicreports.report.constant.GroupFooterPosition} object. + */ + public void setFooterPosition(GroupFooterPosition footerPosition) { + this.footerPosition = footerPosition; + } + + /** {@inheritDoc} */ + @Override + public Boolean getKeepTogether() { + return keepTogether; + } + + /** + *

Setter for the field keepTogether.

+ * + * @param keepTogether a {@link java.lang.Boolean} object. + */ + public void setKeepTogether(Boolean keepTogether) { + this.keepTogether = keepTogether; + } + + /** {@inheritDoc} */ + @Override + public Boolean getHeaderWithSubtotal() { + return headerWithSubtotal; + } + + /** + *

Setter for the field headerWithSubtotal.

+ * + * @param headerWithSubtotal a {@link java.lang.Boolean} object. + */ + public void setHeaderWithSubtotal(Boolean headerWithSubtotal) { + this.headerWithSubtotal = headerWithSubtotal; + } + + /** {@inheritDoc} */ + @Override + public DRBand getHeaderBand() { + return headerBand; + } + + /** {@inheritDoc} */ + @Override + public DRBand getFooterBand() { + return footerBand; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRHyperLink.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRHyperLink.java new file mode 100644 index 0000000..e3df2cd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRHyperLink.java @@ -0,0 +1,129 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIHyperLink; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRHyperLink class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRHyperLink implements DRIHyperLink { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression anchorExpression; + private DRIExpression pageExpression; + private DRIExpression referenceExpression; + private DRIExpression tooltipExpression; + private String hyperLinkType; + private String hyperLinkTarget; + + /** {@inheritDoc} */ + @Override + public DRIExpression getAnchorExpression() { + return anchorExpression; + } + + /** + *

Setter for the field anchorExpression.

+ * + * @param anchorExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setAnchorExpression(DRIExpression anchorExpression) { + this.anchorExpression = anchorExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getPageExpression() { + return pageExpression; + } + + /** + *

Setter for the field pageExpression.

+ * + * @param pageExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setPageExpression(DRIExpression pageExpression) { + this.pageExpression = pageExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getReferenceExpression() { + return referenceExpression; + } + + /** + *

Setter for the field referenceExpression.

+ * + * @param referenceExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setReferenceExpression(DRIExpression referenceExpression) { + this.referenceExpression = referenceExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getTooltipExpression() { + return tooltipExpression; + } + + /** + *

Setter for the field tooltipExpression.

+ * + * @param tooltipExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setTooltipExpression(DRIExpression tooltipExpression) { + this.tooltipExpression = tooltipExpression; + } + + /** {@inheritDoc} */ + @Override + public String getType() { + return hyperLinkType; + } + + /** + *

setType.

+ * + * @param hyperLinkType a {@link java.lang.String} object. + */ + public void setType(String hyperLinkType) { + this.hyperLinkType = hyperLinkType; + } + + /** {@inheritDoc} */ + @Override + public String getTarget() { + return hyperLinkTarget; + } + + /** + *

setTarget.

+ * + * @param hyperLinkTarget a {@link java.lang.String} object. + */ + public void setTarget(String hyperLinkTarget) { + this.hyperLinkTarget = hyperLinkTarget; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRMargin.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRMargin.java new file mode 100644 index 0000000..fb5b9d6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRMargin.java @@ -0,0 +1,120 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIMargin; +import org.apache.commons.lang3.Validate; + +/** + *

DRMargin class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRMargin implements DRIMargin { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int top; + private int left; + private int bottom; + private int right; + + /** + *

Constructor for DRMargin.

+ */ + public DRMargin() { + } + + /** + *

Constructor for DRMargin.

+ * + * @param margin a int. + */ + public DRMargin(int margin) { + Validate.isTrue(margin >= 0, "margin must be >= 0"); + top = margin; + left = margin; + bottom = margin; + right = margin; + } + + /** {@inheritDoc} */ + @Override + public int getTop() { + return top; + } + + /** + *

Setter for the field top.

+ * + * @param top a int. + */ + public void setTop(int top) { + Validate.isTrue(top >= 0, "top must be >= 0"); + this.top = top; + } + + /** {@inheritDoc} */ + @Override + public int getLeft() { + return left; + } + + /** + *

Setter for the field left.

+ * + * @param left a int. + */ + public void setLeft(int left) { + Validate.isTrue(left >= 0, "left must be >= 0"); + this.left = left; + } + + /** {@inheritDoc} */ + @Override + public int getBottom() { + return bottom; + } + + /** + *

Setter for the field bottom.

+ * + * @param bottom a int. + */ + public void setBottom(int bottom) { + Validate.isTrue(bottom >= 0, "bottom must be >= 0"); + this.bottom = bottom; + } + + /** {@inheritDoc} */ + @Override + public int getRight() { + return right; + } + + /** + *

Setter for the field right.

+ * + * @param right a int. + */ + public void setRight(int right) { + Validate.isTrue(right >= 0, "right must be >= 0"); + this.right = right; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRPage.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRPage.java new file mode 100644 index 0000000..10c21d3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRPage.java @@ -0,0 +1,203 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.definition.DRIPage; +import org.apache.commons.lang3.Validate; + +/** + *

DRPage class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRPage implements DRIPage { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer width; + private Integer height; + private PageOrientation orientation; + private DRMargin margin; + private Integer columnsPerPage; + private Integer columnSpace; + private Boolean ignorePageWidth; + + /** + *

setPageFormat.

+ * + * @param pageType a {@link software.xdev.dynamicreports.report.constant.PageType} object. + * @param orientation a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + */ + public void setPageFormat(PageType pageType, PageOrientation orientation) { + Validate.notNull(pageType, "pageType must not be null"); + setPageFormat(pageType.getWidth(), pageType.getHeight(), orientation); + } + + /** + *

setPageFormat.

+ * + * @param width a {@link java.lang.Integer} object. + * @param height a {@link java.lang.Integer} object. + * @param orientation a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + */ + public void setPageFormat(Integer width, Integer height, PageOrientation orientation) { + Validate.isTrue(width >= 0, "width must be >= 0"); + Validate.isTrue(height >= 0, "height must be >= 0"); + Validate.notNull(orientation, "orientation must not be null"); + if (orientation.equals(PageOrientation.PORTRAIT)) { + setWidth(width); + setHeight(height); + } else { + setWidth(height); + setHeight(width); + } + setOrientation(orientation); + } + + /** + * {@inheritDoc} + *

+ * Returns the page width. + */ + @Override + public Integer getWidth() { + return width; + } + + /** + * Sets the page width. + * + * @param width the page width >= 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public void setWidth(Integer width) { + if (width != null) { + Validate.isTrue(width >= 0, "width must be >= 0"); + } + this.width = width; + } + + /** + * {@inheritDoc} + *

+ * Returns the page height. + */ + @Override + public Integer getHeight() { + return height; + } + + /** + * Sets the page height. + * + * @param height the page height >= 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public void setHeight(Integer height) { + if (height != null) { + Validate.isTrue(height >= 0, "height must be >= 0"); + } + this.height = height; + } + + /** {@inheritDoc} */ + @Override + public PageOrientation getOrientation() { + return orientation; + } + + /** + *

Setter for the field orientation.

+ * + * @param orientation a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + */ + public void setOrientation(PageOrientation orientation) { + this.orientation = orientation; + } + + /** {@inheritDoc} */ + @Override + public DRMargin getMargin() { + return margin; + } + + /** + *

Setter for the field margin.

+ * + * @param margin a {@link software.xdev.dynamicreports.report.base.DRMargin} object. + */ + public void setMargin(DRMargin margin) { + this.margin = margin; + } + + /** {@inheritDoc} */ + @Override + public Integer getColumnsPerPage() { + return columnsPerPage; + } + + /** + *

Setter for the field columnsPerPage.

+ * + * @param columnsPerPage a {@link java.lang.Integer} object. + */ + public void setColumnsPerPage(Integer columnsPerPage) { + if (columnsPerPage != null) { + Validate.isTrue(columnsPerPage >= 1, "columnsPerPage must be >= 1"); + } + this.columnsPerPage = columnsPerPage; + } + + /** {@inheritDoc} */ + @Override + public Integer getColumnSpace() { + return columnSpace; + } + + /** + *

Setter for the field columnSpace.

+ * + * @param columnSpace a {@link java.lang.Integer} object. + */ + public void setColumnSpace(Integer columnSpace) { + if (columnSpace != null) { + Validate.isTrue(columnSpace >= 0, "columnSpace must be >= 0"); + } + this.columnSpace = columnSpace; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnorePageWidth() { + return ignorePageWidth; + } + + /** + *

Setter for the field ignorePageWidth.

+ * + * @param ignorePageWidth a {@link java.lang.Boolean} object. + */ + public void setIgnorePageWidth(Boolean ignorePageWidth) { + this.ignorePageWidth = ignorePageWidth; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRParameter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRParameter.java new file mode 100644 index 0000000..df1065a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRParameter.java @@ -0,0 +1,82 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIParameter; +import org.apache.commons.lang3.Validate; + +/** + *

DRParameter class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRParameter implements DRIParameter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private Class valueClass; + private T value; + + @SuppressWarnings("unchecked") + /** + *

Constructor for DRParameter.

+ * + * @param name a {@link java.lang.String} object. + * @param value a T object. + */ + public DRParameter(String name, T value) { + Validate.notEmpty(name, "name must not be empty"); + Validate.notNull(value, "value must not be null"); + this.name = name; + this.valueClass = (Class) value.getClass(); + this.value = value; + } + + /** + *

Constructor for DRParameter.

+ * + * @param name a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + */ + public DRParameter(String name, Class valueClass) { + Validate.notEmpty(name, "name must not be empty"); + Validate.notNull(valueClass, "valueClass must not be null"); + this.name = name; + this.valueClass = valueClass; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return valueClass; + } + + /** {@inheritDoc} */ + @Override + public T getValue() { + return value; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRQuery.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRQuery.java new file mode 100644 index 0000000..1a9418f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRQuery.java @@ -0,0 +1,60 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIQuery; +import org.apache.commons.lang3.Validate; + +/** + *

DRQuery class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRQuery implements DRIQuery { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String text; + private String language; + + /** + *

Constructor for DRQuery.

+ * + * @param text a {@link java.lang.String} object. + * @param language a {@link java.lang.String} object. + */ + public DRQuery(String text, String language) { + Validate.notNull(text, "text must not be null"); + Validate.notNull(language, "language must not be null"); + this.text = text; + this.language = language; + } + + /** {@inheritDoc} */ + @Override + public String getText() { + return text; + } + + /** {@inheritDoc} */ + @Override + public String getLanguage() { + return language; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRReport.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRReport.java new file mode 100644 index 0000000..364a69d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRReport.java @@ -0,0 +1,1362 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.base.column.DRColumn; +import software.xdev.dynamicreports.report.base.grid.DRColumnGrid; +import software.xdev.dynamicreports.report.base.style.DRConditionalStyle; +import software.xdev.dynamicreports.report.base.style.DRSimpleStyle; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.DRIReport; +import software.xdev.dynamicreports.report.definition.DRIScriptlet; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer; +import software.xdev.dynamicreports.report.definition.DRITemplateDesign; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.style.DRIFont; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; + + +/** + *

DRReport class.

+ * + * @author Ricardo Mariaca + */ +public class DRReport implements DRIReport +{ + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRReportTemplate template; + private List templateStyles; + private DRITemplateDesign templateDesign; + private String reportName; + private Locale locale; + private ResourceBundle resourceBundle; + private String resourceBundleName; + private Boolean ignorePagination; + private Boolean showColumnTitle; + private Boolean showColumnValues; + private List> columns; + private List groups; + private List> subtotals; + private List> fields; + private List> variables; + private List sorts; + private List> parameters; + private Map parameterValues; + private List scriptlets; + private Properties properties; + private DRQuery query; + private DRPage page; + private WhenNoDataType whenNoDataType; + private WhenResourceMissingType whenResourceMissingType; + private Boolean titleOnANewPage; + private Boolean summaryOnANewPage; + private Boolean summaryWithPageHeaderAndFooter; + private Boolean floatColumnFooter; + private Orientation printOrder; + private RunDirection columnDirection; + private String language; + private Boolean useFieldNameAsDescription; + private Boolean highlightDetailOddRows; + private DRSimpleStyle detailOddRowStyle; + private Boolean highlightDetailEvenRows; + private DRSimpleStyle detailEvenRowStyle; + private List detailRowHighlighters; + private DRColumnGrid columnGrid; + private Boolean tableOfContents; + private DRITableOfContentsCustomizer tableOfContentsCustomizer; + private DRIExpression filterExpression; + + private DRIFont defaultFont; + private DRIReportStyle textStyle; + private DRIReportStyle columnTitleStyle; + private DRIReportStyle columnStyle; + private DRIReportStyle groupTitleStyle; + private DRIReportStyle groupStyle; + private DRIReportStyle subtotalStyle; + private DRIReportStyle imageStyle; + + private DRBand titleBand; + private DRBand pageHeaderBand; + private DRBand pageFooterBand; + private DRBand columnHeaderBand; + private DRBand columnFooterBand; + private DRBand detailBand; + private DRBand detailHeaderBand; + private DRBand detailFooterBand; + private DRBand lastPageFooterBand; + private DRBand summaryBand; + private DRBand noDataBand; + private DRBand backgroundBand; + + /** + *

Constructor for DRReport.

+ */ + public DRReport() + { + this.init(); + } + + private void init() + { + this.template = new DRReportTemplate(); + this.templateStyles = new ArrayList<>(); + this.columns = new ArrayList<>(); + this.groups = new ArrayList<>(); + this.subtotals = new ArrayList<>(); + this.fields = new ArrayList<>(); + this.variables = new ArrayList<>(); + this.sorts = new ArrayList<>(); + this.parameters = new ArrayList<>(); + this.scriptlets = new ArrayList<>(); + this.detailRowHighlighters = new ArrayList<>(); + this.properties = new Properties(); + this.page = new DRPage(); + + this.titleBand = new DRBand(); + this.pageHeaderBand = new DRBand(); + this.pageFooterBand = new DRBand(); + this.columnHeaderBand = new DRBand(); + this.columnFooterBand = new DRBand(); + this.detailBand = new DRBand(); + this.detailHeaderBand = new DRBand(); + this.detailFooterBand = new DRBand(); + this.lastPageFooterBand = new DRBand(); + this.summaryBand = new DRBand(); + this.noDataBand = new DRBand(); + this.backgroundBand = new DRBand(); + } + + /** + * {@inheritDoc} + */ + @Override + public DRReportTemplate getTemplate() + { + return this.template; + } + + /** + *

Setter for the field template.

+ * + * @param template a {@link software.xdev.dynamicreports.report.base.DRReportTemplate} object. + */ + public void setTemplate(final DRReportTemplate template) + { + Validate.notNull(template, "template must not be null"); + this.template = template; + } + + /** + * {@inheritDoc} + */ + @Override + public List getTemplateStyles() + { + return this.templateStyles; + } + + /** + *

Setter for the field templateStyles.

+ * + * @param templateStyles a {@link java.util.List} object. + */ + public void setTemplateStyles(final List templateStyles) + { + this.templateStyles = templateStyles; + } + + /** + *

addTemplateStyle.

+ * + * @param templateStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIStyle} object. + */ + public void addTemplateStyle(final DRIStyle templateStyle) + { + Validate.notNull(templateStyle, "templateStyle must not be null"); + Validate.notNull(templateStyle.getName(), "templateStyle name must not be null"); + this.templateStyles.add(templateStyle); + } + + /** + * {@inheritDoc} + */ + @Override + public DRITemplateDesign getTemplateDesign() + { + return this.templateDesign; + } + + /** + *

Setter for the field templateDesign.

+ * + * @param templateDesign a {@link software.xdev.dynamicreports.report.definition.DRITemplateDesign} object. + */ + public void setTemplateDesign(final DRITemplateDesign templateDesign) + { + Validate.notNull(templateDesign, "templateDesign must not be null"); + this.templateDesign = templateDesign; + } + + /** + * {@inheritDoc} + */ + @Override + public String getReportName() + { + return this.reportName; + } + + /** + *

Setter for the field reportName.

+ * + * @param reportName a {@link java.lang.String} object. + */ + public void setReportName(final String reportName) + { + this.reportName = reportName; + } + + /** + * {@inheritDoc} + */ + @Override + public Locale getLocale() + { + return this.locale; + } + + /** + *

Setter for the field locale.

+ * + * @param locale a {@link java.util.Locale} object. + */ + public void setLocale(final Locale locale) + { + this.locale = locale; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceBundle getResourceBundle() + { + return this.resourceBundle; + } + + /** + *

Setter for the field resourceBundle.

+ * + * @param resourceBundle a {@link java.util.ResourceBundle} object. + */ + public void setResourceBundle(final ResourceBundle resourceBundle) + { + this.resourceBundle = resourceBundle; + } + + /** + * {@inheritDoc} + */ + @Override + public String getResourceBundleName() + { + return this.resourceBundleName; + } + + /** + *

Setter for the field resourceBundleName.

+ * + * @param resourceBundleName a {@link java.lang.String} object. + */ + public void setResourceBundleName(final String resourceBundleName) + { + this.resourceBundleName = resourceBundleName; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getShowColumnTitle() + { + return this.showColumnTitle; + } + + /** + *

Setter for the field showColumnTitle.

+ * + * @param showColumnTitle a {@link java.lang.Boolean} object. + */ + public void setShowColumnTitle(final Boolean showColumnTitle) + { + this.showColumnTitle = showColumnTitle; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getShowColumnValues() + { + return this.showColumnValues; + } + + /** + *

Setter for the field showColumnValues.

+ * + * @param showColumnValues a {@link java.lang.Boolean} object. + */ + public void setShowColumnValues(final Boolean showColumnValues) + { + this.showColumnValues = showColumnValues; + } + + /** + * {@inheritDoc} + */ + @Override + public List> getColumns() + { + return this.columns; + } + + /** + *

Setter for the field columns.

+ * + * @param columns a {@link java.util.List} object. + */ + public void setColumns(final List> columns) + { + Validate.notNull(columns, "columns must not be null"); + Validate.noNullElements(columns, "columns must not contains null column"); + this.columns = columns; + } + + /** + *

addColumn.

+ * + * @param column a {@link software.xdev.dynamicreports.report.base.column.DRColumn} object. + */ + public void addColumn(final DRColumn column) + { + Validate.notNull(column, "column must not be null"); + this.columns.add(column); + } + + /** + * {@inheritDoc} + */ + @Override + public List getGroups() + { + return this.groups; + } + + /** + *

Setter for the field groups.

+ * + * @param groups a {@link java.util.List} object. + */ + public void setGroups(final List groups) + { + Validate.notNull(groups, "groups must not be null"); + Validate.noNullElements(groups, "groups must not contains null group"); + this.groups = groups; + } + + /** + *

addGroup.

+ * + * @param group a {@link software.xdev.dynamicreports.report.base.DRGroup} object. + */ + public void addGroup(final DRGroup group) + { + Validate.notNull(group, "group must not be null"); + this.groups.add(group); + } + + /** + * {@inheritDoc} + */ + @Override + public List> getFields() + { + return this.fields; + } + + /** + *

Setter for the field fields.

+ * + * @param fields a {@link java.util.List} object. + */ + public void setFields(final List> fields) + { + Validate.notNull(fields, "fields must not be null"); + Validate.noNullElements(fields, "fields must not contains null field"); + this.fields = fields; + } + + /** + *

addField.

+ * + * @param field a {@link software.xdev.dynamicreports.report.base.DRField} object. + */ + public void addField(final DRField field) + { + Validate.notNull(field, "field must not be null"); + this.fields.add(field); + } + + /** + * {@inheritDoc} + */ + @Override + public List> getVariables() + { + return this.variables; + } + + /** + *

Setter for the field variables.

+ * + * @param variables a {@link java.util.List} object. + */ + public void setVariables(final List> variables) + { + Validate.notNull(variables, "variables must not be null"); + Validate.noNullElements(variables, "variables must not contains null variable"); + this.variables = variables; + } + + /** + *

addVariable.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.base.DRVariable} object. + */ + public void addVariable(final DRVariable variable) + { + Validate.notNull(variable, "variable must not be null"); + this.variables.add(variable); + } + + /** + * {@inheritDoc} + */ + @Override + public List getSorts() + { + return this.sorts; + } + + /** + *

Setter for the field sorts.

+ * + * @param sorts a {@link java.util.List} object. + */ + public void setSorts(final List sorts) + { + Validate.notNull(sorts, "sorts must not be null"); + Validate.noNullElements(sorts, "sorts must not contains null sort"); + this.sorts = sorts; + } + + /** + *

addSort.

+ * + * @param sort a {@link software.xdev.dynamicreports.report.base.DRSort} object. + */ + public void addSort(final DRSort sort) + { + Validate.notNull(sort, "sort must not be null"); + this.sorts.add(sort); + } + + /** + * {@inheritDoc} + */ + @Override + public List> getSubtotals() + { + return this.subtotals; + } + + /** + *

Setter for the field subtotals.

+ * + * @param subtotals a {@link java.util.List} object. + */ + public void setSubtotals(final List> subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + this.subtotals = subtotals; + } + + /** + *

addSubtotal.

+ * + * @param subtotal a {@link software.xdev.dynamicreports.report.base.DRSubtotal} object. + */ + public void addSubtotal(final DRSubtotal subtotal) + { + Validate.notNull(subtotal, "subtotal must not be null"); + this.subtotals.add(subtotal); + } + + /** + * {@inheritDoc} + */ + @Override + public List> getParameters() + { + return this.parameters; + } + + /** + *

Setter for the field parameters.

+ * + * @param parameters a {@link java.util.List} object. + */ + public void setParameters(final List> parameters) + { + Validate.notNull(parameters, "parameters must not be null"); + Validate.noNullElements(parameters, "parameters must not contains null parameter"); + this.parameters = parameters; + } + + /** + *

addParameter.

+ * + * @param parameter a {@link software.xdev.dynamicreports.report.base.DRParameter} object. + */ + public void addParameter(final DRParameter parameter) + { + Validate.notNull(parameter, "parameter must not be null"); + this.parameters.add(parameter); + } + + /** + * {@inheritDoc} + */ + @Override + public Map getParameterValues() + { + return this.parameterValues; + } + + /** + *

Setter for the field parameterValues.

+ * + * @param parameterValues a {@link java.util.Map} object. + */ + public void setParameterValues(final Map parameterValues) + { + this.parameterValues = parameterValues; + } + + /** + *

addParameterValue.

+ * + * @param name a {@link java.lang.String} object. + * @param value a {@link java.lang.Object} object. + */ + public void addParameterValue(final String name, final Object value) + { + Validate.notNull(name, "parameter name must not be null"); + if(this.parameterValues == null) + { + this.parameterValues = new HashMap<>(); + } + this.parameterValues.put(name, value); + } + + /** + * {@inheritDoc} + */ + @Override + public List getScriptlets() + { + return this.scriptlets; + } + + /** + *

Setter for the field scriptlets.

+ * + * @param scriptlets a {@link java.util.List} object. + */ + public void setScriptlets(final List scriptlets) + { + Validate.notNull(scriptlets, "scriptlets must not be null"); + Validate.noNullElements(scriptlets, "scriptlets must not contains null scriptlet"); + this.scriptlets = scriptlets; + } + + /** + *

addScriptlet.

+ * + * @param scriptlet a {@link software.xdev.dynamicreports.report.definition.DRIScriptlet} object. + */ + public void addScriptlet(final DRIScriptlet scriptlet) + { + Validate.notNull(scriptlet, "scriptlet must not be null"); + this.scriptlets.add(scriptlet); + } + + /** + * {@inheritDoc} + */ + @Override + public Properties getProperties() + { + return this.properties; + } + + /** + *

Setter for the field properties.

+ * + * @param properties a {@link java.util.Properties} object. + */ + public void setProperties(final Properties properties) + { + Validate.notNull(properties, "properties must not be null"); + this.properties = properties; + } + + /** + *

addProperty.

+ * + * @param key a {@link java.lang.String} object. + * @param value a {@link java.lang.String} object. + */ + public void addProperty(final String key, final String value) + { + Validate.notNull(key, "key must not be null"); + this.properties.setProperty(key, value); + } + + /** + * {@inheritDoc} + */ + @Override + public DRQuery getQuery() + { + return this.query; + } + + /** + *

Setter for the field query.

+ * + * @param query a {@link software.xdev.dynamicreports.report.base.DRQuery} object. + */ + public void setQuery(final DRQuery query) + { + this.query = query; + } + + /** + * {@inheritDoc} + */ + @Override + public DRPage getPage() + { + return this.page; + } + + /** + *

Setter for the field page.

+ * + * @param page a {@link software.xdev.dynamicreports.report.base.DRPage} object. + */ + public void setPage(final DRPage page) + { + Validate.notNull(page, "page must not be null"); + this.page = page; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getIgnorePagination() + { + return this.ignorePagination; + } + + /** + *

Setter for the field ignorePagination.

+ * + * @param ignorePagination a {@link java.lang.Boolean} object. + */ + public void setIgnorePagination(final Boolean ignorePagination) + { + this.ignorePagination = ignorePagination; + } + + /** + * {@inheritDoc} + */ + @Override + public WhenNoDataType getWhenNoDataType() + { + return this.whenNoDataType; + } + + /** + *

Setter for the field whenNoDataType.

+ * + * @param whenNoDataType a {@link software.xdev.dynamicreports.report.constant.WhenNoDataType} object. + */ + public void setWhenNoDataType(final WhenNoDataType whenNoDataType) + { + this.whenNoDataType = whenNoDataType; + } + + /** + * {@inheritDoc} + */ + @Override + public WhenResourceMissingType getWhenResourceMissingType() + { + return this.whenResourceMissingType; + } + + /** + *

Setter for the field whenResourceMissingType.

+ * + * @param whenResourceMissingType a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + */ + public void setWhenResourceMissingType(final WhenResourceMissingType whenResourceMissingType) + { + this.whenResourceMissingType = whenResourceMissingType; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getTitleOnANewPage() + { + return this.titleOnANewPage; + } + + /** + *

Setter for the field titleOnANewPage.

+ * + * @param titleOnANewPage a {@link java.lang.Boolean} object. + */ + public void setTitleOnANewPage(final Boolean titleOnANewPage) + { + this.titleOnANewPage = titleOnANewPage; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getSummaryOnANewPage() + { + return this.summaryOnANewPage; + } + + /** + *

Setter for the field summaryOnANewPage.

+ * + * @param summaryOnANewPage a {@link java.lang.Boolean} object. + */ + public void setSummaryOnANewPage(final Boolean summaryOnANewPage) + { + this.summaryOnANewPage = summaryOnANewPage; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getSummaryWithPageHeaderAndFooter() + { + return this.summaryWithPageHeaderAndFooter; + } + + /** + *

Setter for the field summaryWithPageHeaderAndFooter.

+ * + * @param summaryWithPageHeaderAndFooter a {@link java.lang.Boolean} object. + */ + public void setSummaryWithPageHeaderAndFooter(final Boolean summaryWithPageHeaderAndFooter) + { + this.summaryWithPageHeaderAndFooter = summaryWithPageHeaderAndFooter; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getFloatColumnFooter() + { + return this.floatColumnFooter; + } + + /** + *

Setter for the field floatColumnFooter.

+ * + * @param floatColumnFooter a {@link java.lang.Boolean} object. + */ + public void setFloatColumnFooter(final Boolean floatColumnFooter) + { + this.floatColumnFooter = floatColumnFooter; + } + + /** + * {@inheritDoc} + */ + @Override + public Orientation getPrintOrder() + { + return this.printOrder; + } + + /** + *

Setter for the field printOrder.

+ * + * @param printOrder a {@link software.xdev.dynamicreports.report.constant.Orientation} object. + */ + public void setPrintOrder(final Orientation printOrder) + { + this.printOrder = printOrder; + } + + /** + * {@inheritDoc} + */ + @Override + public RunDirection getColumnDirection() + { + return this.columnDirection; + } + + /** + *

Setter for the field columnDirection.

+ * + * @param columnDirection a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public void setColumnDirection(final RunDirection columnDirection) + { + this.columnDirection = columnDirection; + } + + /** + * {@inheritDoc} + */ + @Override + public String getLanguage() + { + return this.language; + } + + /** + *

Setter for the field language.

+ * + * @param language a {@link java.lang.String} object. + */ + public void setLanguage(final String language) + { + this.language = language; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getUseFieldNameAsDescription() + { + return this.useFieldNameAsDescription; + } + + /** + *

Setter for the field useFieldNameAsDescription.

+ * + * @param useFieldNameAsDescription a {@link java.lang.Boolean} object. + */ + public void setUseFieldNameAsDescription(final Boolean useFieldNameAsDescription) + { + this.useFieldNameAsDescription = useFieldNameAsDescription; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIFont getDefaultFont() + { + return this.defaultFont; + } + + /** + *

Setter for the field defaultFont.

+ * + * @param defaultFont a {@link software.xdev.dynamicreports.report.definition.style.DRIFont} object. + */ + public void setDefaultFont(final DRIFont defaultFont) + { + this.defaultFont = defaultFont; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getTextStyle() + { + return this.textStyle; + } + + /** + *

Setter for the field textStyle.

+ * + * @param textStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setTextStyle(final DRIReportStyle textStyle) + { + this.textStyle = textStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getColumnTitleStyle() + { + return this.columnTitleStyle; + } + + /** + *

Setter for the field columnTitleStyle.

+ * + * @param columnTitleStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setColumnTitleStyle(final DRIReportStyle columnTitleStyle) + { + this.columnTitleStyle = columnTitleStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getColumnStyle() + { + return this.columnStyle; + } + + /** + *

Setter for the field columnStyle.

+ * + * @param columnStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setColumnStyle(final DRIReportStyle columnStyle) + { + this.columnStyle = columnStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getGroupTitleStyle() + { + return this.groupTitleStyle; + } + + /** + *

Setter for the field groupTitleStyle.

+ * + * @param groupTitleStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setGroupTitleStyle(final DRIReportStyle groupTitleStyle) + { + this.groupTitleStyle = groupTitleStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getGroupStyle() + { + return this.groupStyle; + } + + /** + *

Setter for the field groupStyle.

+ * + * @param groupStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setGroupStyle(final DRIReportStyle groupStyle) + { + this.groupStyle = groupStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getSubtotalStyle() + { + return this.subtotalStyle; + } + + /** + *

Setter for the field subtotalStyle.

+ * + * @param subtotalStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setSubtotalStyle(final DRIReportStyle subtotalStyle) + { + this.subtotalStyle = subtotalStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getImageStyle() + { + return this.imageStyle; + } + + /** + *

Setter for the field imageStyle.

+ * + * @param imageStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setImageStyle(final DRIReportStyle imageStyle) + { + this.imageStyle = imageStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getHighlightDetailOddRows() + { + return this.highlightDetailOddRows; + } + + /** + *

Setter for the field highlightDetailOddRows.

+ * + * @param highlightDetailOddRows a {@link java.lang.Boolean} object. + */ + public void setHighlightDetailOddRows(final Boolean highlightDetailOddRows) + { + this.highlightDetailOddRows = highlightDetailOddRows; + } + + /** + * {@inheritDoc} + */ + @Override + public DRSimpleStyle getDetailOddRowStyle() + { + return this.detailOddRowStyle; + } + + /** + *

Setter for the field detailOddRowStyle.

+ * + * @param detailOddRowStyle a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public void setDetailOddRowStyle(final DRSimpleStyle detailOddRowStyle) + { + this.detailOddRowStyle = detailOddRowStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getHighlightDetailEvenRows() + { + return this.highlightDetailEvenRows; + } + + /** + *

Setter for the field highlightDetailEvenRows.

+ * + * @param highlightDetailEvenRows a {@link java.lang.Boolean} object. + */ + public void setHighlightDetailEvenRows(final Boolean highlightDetailEvenRows) + { + this.highlightDetailEvenRows = highlightDetailEvenRows; + } + + /** + * {@inheritDoc} + */ + @Override + public DRSimpleStyle getDetailEvenRowStyle() + { + return this.detailEvenRowStyle; + } + + /** + *

Setter for the field detailEvenRowStyle.

+ * + * @param detailEvenRowStyle a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public void setDetailEvenRowStyle(final DRSimpleStyle detailEvenRowStyle) + { + this.detailEvenRowStyle = detailEvenRowStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public List getDetailRowHighlighters() + { + return this.detailRowHighlighters; + } + + /** + *

Setter for the field detailRowHighlighters.

+ * + * @param detailRowHighlighters a {@link java.util.List} object. + */ + public void setDetailRowHighlighters(final List detailRowHighlighters) + { + Validate.notNull(detailRowHighlighters, "detailRowHighlighters must not be null"); + Validate.noNullElements( + detailRowHighlighters, + "detailRowHighlighters must not contains null detailRowHighlighter"); + this.detailRowHighlighters = detailRowHighlighters; + } + + /** + *

addDetailRowHighlighter.

+ * + * @param detailRowHighlighter a {@link software.xdev.dynamicreports.report.base.style.DRConditionalStyle} object. + */ + public void addDetailRowHighlighter(final DRConditionalStyle detailRowHighlighter) + { + Validate.notNull(detailRowHighlighter, "detailRowHighlighter must not be null"); + this.detailRowHighlighters.add(detailRowHighlighter); + } + + /** + * {@inheritDoc} + */ + @Override + public DRColumnGrid getColumnGrid() + { + return this.columnGrid; + } + + /** + *

Setter for the field columnGrid.

+ * + * @param columnGrid a {@link software.xdev.dynamicreports.report.base.grid.DRColumnGrid} object. + */ + public void setColumnGrid(final DRColumnGrid columnGrid) + { + this.columnGrid = columnGrid; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getTableOfContents() + { + return this.tableOfContents; + } + + /** + *

Setter for the field tableOfContents.

+ * + * @param tableOfContents a {@link java.lang.Boolean} object. + */ + public void setTableOfContents(final Boolean tableOfContents) + { + this.tableOfContents = tableOfContents; + } + + /** + * {@inheritDoc} + */ + @Override + public DRITableOfContentsCustomizer getTableOfContentsCustomizer() + { + return this.tableOfContentsCustomizer; + } + + /** + *

Setter for the field tableOfContentsCustomizer.

+ * + * @param tableOfContentsCustomizer a {@link software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer} + * object. + */ + public void setTableOfContentsCustomizer(final DRITableOfContentsCustomizer tableOfContentsCustomizer) + { + this.tableOfContentsCustomizer = tableOfContentsCustomizer; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIExpression getFilterExpression() + { + return this.filterExpression; + } + + /** + *

Setter for the field filterExpression.

+ * + * @param filterExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setFilterExpression(final DRIExpression filterExpression) + { + this.filterExpression = filterExpression; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getTitleBand() + { + return this.titleBand; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getPageHeaderBand() + { + return this.pageHeaderBand; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getPageFooterBand() + { + return this.pageFooterBand; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getColumnHeaderBand() + { + return this.columnHeaderBand; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getColumnFooterBand() + { + return this.columnFooterBand; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getDetailBand() + { + return this.detailBand; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getDetailHeaderBand() + { + return this.detailHeaderBand; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getDetailFooterBand() + { + return this.detailFooterBand; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getLastPageFooterBand() + { + return this.lastPageFooterBand; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getSummaryBand() + { + return this.summaryBand; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getNoDataBand() + { + return this.noDataBand; + } + + /** + * {@inheritDoc} + */ + @Override + public DRBand getBackgroundBand() + { + return this.backgroundBand; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRReportTemplate.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRReportTemplate.java new file mode 100644 index 0000000..993b5db --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRReportTemplate.java @@ -0,0 +1,2497 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.base.component.DRComponent; +import software.xdev.dynamicreports.report.base.style.DRSimpleStyle; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.constant.Position; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.DRIReportTemplate; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer; +import software.xdev.dynamicreports.report.definition.style.DRIFont; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; + + +/** + *

DRReportTemplate class.

+ * + * @author Ricardo Mariaca + */ +public class DRReportTemplate implements DRIReportTemplate +{ + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + // table of contents + public Boolean tableOfContents; + public DRITableOfContentsCustomizer tableOfContentsCustomizer; + private List templateStyles; + private Locale locale; + private Boolean showColumnTitle; + private Boolean showColumnValues; + private Boolean ignorePagination; + private WhenNoDataType whenNoDataType; + private WhenResourceMissingType whenResourceMissingType; + private Boolean titleOnANewPage; + private Boolean summaryOnANewPage; + private Boolean summaryWithPageHeaderAndFooter; + private Boolean floatColumnFooter; + private Orientation printOrder; + private RunDirection columnDirection; + private String language; + private Boolean useFieldNameAsDescription; + // style + private Boolean highlightDetailOddRows; + private DRSimpleStyle detailOddRowStyle; + private Boolean highlightDetailEvenRows; + private DRSimpleStyle detailEvenRowStyle; + private DRIFont defaultFont; + private DRIReportStyle textStyle; + private DRIReportStyle columnTitleStyle; + private DRIReportStyle columnStyle; + private DRIReportStyle groupTitleStyle; + private DRIReportStyle groupStyle; + private DRIReportStyle subtotalStyle; + private DRIReportStyle imageStyle; + // page + private Integer pageWidth; + private Integer pageHeight; + private PageOrientation pageOrientation; + private DRMargin pageMargin; + private Integer pageColumnsPerPage; + private Integer pageColumnSpace; + private Boolean ignorePageWidth; + // column + private Boolean columnPrintRepeatedDetailValues; + private Integer columnWidth; + // group + private GroupHeaderLayout groupHeaderLayout; + private Boolean groupHideColumn; + private Boolean groupShowColumnHeaderAndFooter; + private Integer groupPadding; + private Boolean groupStartInNewPage; + private Boolean groupStartInNewColumn; + private Boolean groupReprintHeaderOnEachPage; + private Boolean groupResetPageNumber; + private GroupFooterPosition groupFooterPosition; + private Boolean groupKeepTogether; + private Boolean groupHeaderWithSubtotal; + // subtotal + private Position subtotalLabelPosition; + // text field + private Integer textFieldWidth; + // image + private Integer imageWidth; + private Integer imageHeight; + // list + private Integer listgap; + // multi page list + private Integer multiPageListWidth; + private Integer multiPageListHeight; + // subreport + private Integer subreportWidth; + private Integer subreportHeight; + // crosstab + private Integer crosstabWidth; + private Integer crosstabHeight; + private Boolean crosstabHighlightOddRows; + private DRSimpleStyle crosstabOddRowStyle; + private Boolean crosstabHighlightEvenRows; + private DRSimpleStyle crosstabEvenRowStyle; + private DRIReportStyle crosstabGroupStyle; + private DRIReportStyle crosstabGroupTotalStyle; + private DRIReportStyle crosstabGrandTotalStyle; + private DRIReportStyle crosstabCellStyle; + private DRIReportStyle crosstabMeasureTitleStyle; + // boolean + private BooleanComponentType booleanComponentType; + private Boolean booleanEmptyWhenNullValue; + private Integer booleanImageWidth; + private Integer booleanImageHeight; + private DRIReportStyle booleanColumnStyle; + // split + private SplitType defaultSplitType; + private SplitType titleSplitType; + private SplitType pageHeaderSplitType; + private SplitType pageFooterSplitType; + private SplitType columnHeaderSplitType; + private SplitType columnFooterSplitType; + private SplitType groupHeaderSplitType; + private SplitType groupFooterSplitType; + private SplitType detailHeaderSplitType; + private SplitType detailSplitType; + private SplitType detailFooterSplitType; + private SplitType lastPageFooterSplitType; + private SplitType summarySplitType; + private SplitType noDataSplitType; + private SplitType backgroundSplitType; + // band style + private DRIReportStyle titleStyle; + private DRIReportStyle pageHeaderStyle; + private DRIReportStyle pageFooterStyle; + private DRIReportStyle columnHeaderStyle; + private DRIReportStyle columnFooterStyle; + private DRIReportStyle groupHeaderStyle; + private DRIReportStyle groupFooterStyle; + private DRIReportStyle detailHeaderStyle; + private DRIReportStyle detailStyle; + private DRIReportStyle detailFooterStyle; + private DRIReportStyle lastPageFooterStyle; + private DRIReportStyle summaryStyle; + private DRIReportStyle noDataStyle; + private DRIReportStyle backgroundStyle; + // band background component + private DRComponent titleBackgroundComponent; + private DRComponent pageHeaderBackgroundComponent; + private DRComponent pageFooterBackgroundComponent; + private DRComponent columnHeaderBackgroundComponent; + private DRComponent columnFooterBackgroundComponent; + private DRComponent groupHeaderBackgroundComponent; + private DRComponent groupFooterBackgroundComponent; + private DRComponent detailHeaderBackgroundComponent; + private DRComponent detailBackgroundComponent; + private DRComponent detailFooterBackgroundComponent; + private DRComponent lastPageFooterBackgroundComponent; + private DRComponent summaryBackgroundComponent; + private DRComponent noDataBackgroundComponent; + private DRComponent backgroundBackgroundComponent; + + /** + *

Constructor for DRReportTemplate.

+ */ + public DRReportTemplate() + { + this.templateStyles = new ArrayList<>(); + } + + /** + * {@inheritDoc} + */ + @Override + public List getTemplateStyles() + { + return this.templateStyles; + } + + /** + *

Setter for the field templateStyles.

+ * + * @param templateStyles a {@link java.util.List} object. + */ + public void setTemplateStyles(final List templateStyles) + { + this.templateStyles = templateStyles; + } + + /** + *

addTemplateStyle.

+ * + * @param templateStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIStyle} object. + */ + public void addTemplateStyle(final DRIStyle templateStyle) + { + Validate.notNull(templateStyle, "templateStyle must not be null"); + Validate.notNull(templateStyle.getName(), "templateStyle name must not be null"); + this.templateStyles.add(templateStyle); + } + + /** + * {@inheritDoc} + */ + @Override + public Locale getLocale() + { + return this.locale; + } + + /** + *

Setter for the field locale.

+ * + * @param locale a {@link java.util.Locale} object. + */ + public void setLocale(final Locale locale) + { + this.locale = locale; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getShowColumnTitle() + { + return this.showColumnTitle; + } + + /** + *

Setter for the field showColumnTitle.

+ * + * @param showColumnTitle a {@link java.lang.Boolean} object. + */ + public void setShowColumnTitle(final Boolean showColumnTitle) + { + this.showColumnTitle = showColumnTitle; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getShowColumnValues() + { + return this.showColumnValues; + } + + /** + *

Setter for the field showColumnValues.

+ * + * @param showColumnValues a {@link java.lang.Boolean} object. + */ + public void setShowColumnValues(final Boolean showColumnValues) + { + this.showColumnValues = showColumnValues; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getIgnorePagination() + { + return this.ignorePagination; + } + + /** + *

Setter for the field ignorePagination.

+ * + * @param ignorePagination a {@link java.lang.Boolean} object. + */ + public void setIgnorePagination(final Boolean ignorePagination) + { + this.ignorePagination = ignorePagination; + } + + /** + * {@inheritDoc} + */ + @Override + public WhenNoDataType getWhenNoDataType() + { + return this.whenNoDataType; + } + + /** + *

Setter for the field whenNoDataType.

+ * + * @param whenNoDataType a {@link software.xdev.dynamicreports.report.constant.WhenNoDataType} object. + */ + public void setWhenNoDataType(final WhenNoDataType whenNoDataType) + { + this.whenNoDataType = whenNoDataType; + } + + /** + * {@inheritDoc} + */ + @Override + public WhenResourceMissingType getWhenResourceMissingType() + { + return this.whenResourceMissingType; + } + + /** + *

Setter for the field whenResourceMissingType.

+ * + * @param whenResourceMissingType a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + */ + public void setWhenResourceMissingType(final WhenResourceMissingType whenResourceMissingType) + { + this.whenResourceMissingType = whenResourceMissingType; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getTitleOnANewPage() + { + return this.titleOnANewPage; + } + + /** + *

Setter for the field titleOnANewPage.

+ * + * @param titleOnANewPage a {@link java.lang.Boolean} object. + */ + public void setTitleOnANewPage(final Boolean titleOnANewPage) + { + this.titleOnANewPage = titleOnANewPage; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getSummaryOnANewPage() + { + return this.summaryOnANewPage; + } + + /** + *

Setter for the field summaryOnANewPage.

+ * + * @param summaryOnANewPage a {@link java.lang.Boolean} object. + */ + public void setSummaryOnANewPage(final Boolean summaryOnANewPage) + { + this.summaryOnANewPage = summaryOnANewPage; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getSummaryWithPageHeaderAndFooter() + { + return this.summaryWithPageHeaderAndFooter; + } + + /** + *

Setter for the field summaryWithPageHeaderAndFooter.

+ * + * @param summaryWithPageHeaderAndFooter a {@link java.lang.Boolean} object. + */ + public void setSummaryWithPageHeaderAndFooter(final Boolean summaryWithPageHeaderAndFooter) + { + this.summaryWithPageHeaderAndFooter = summaryWithPageHeaderAndFooter; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getFloatColumnFooter() + { + return this.floatColumnFooter; + } + + /** + *

Setter for the field floatColumnFooter.

+ * + * @param floatColumnFooter a {@link java.lang.Boolean} object. + */ + public void setFloatColumnFooter(final Boolean floatColumnFooter) + { + this.floatColumnFooter = floatColumnFooter; + } + + /** + * {@inheritDoc} + */ + @Override + public Orientation getPrintOrder() + { + return this.printOrder; + } + + /** + *

Setter for the field printOrder.

+ * + * @param printOrder a {@link software.xdev.dynamicreports.report.constant.Orientation} object. + */ + public void setPrintOrder(final Orientation printOrder) + { + this.printOrder = printOrder; + } + + /** + * {@inheritDoc} + */ + @Override + public RunDirection getColumnDirection() + { + return this.columnDirection; + } + + /** + *

Setter for the field columnDirection.

+ * + * @param columnDirection a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public void setColumnDirection(final RunDirection columnDirection) + { + this.columnDirection = columnDirection; + } + + /** + * {@inheritDoc} + */ + @Override + public String getLanguage() + { + return this.language; + } + + /** + *

Setter for the field language.

+ * + * @param language a {@link java.lang.String} object. + */ + public void setLanguage(final String language) + { + this.language = language; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getUseFieldNameAsDescription() + { + return this.useFieldNameAsDescription; + } + + /** + *

Setter for the field useFieldNameAsDescription.

+ * + * @param useFieldNameAsDescription a {@link java.lang.Boolean} object. + */ + public void setUseFieldNameAsDescription(final Boolean useFieldNameAsDescription) + { + this.useFieldNameAsDescription = useFieldNameAsDescription; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getHighlightDetailOddRows() + { + return this.highlightDetailOddRows; + } + + /** + *

Setter for the field highlightDetailOddRows.

+ * + * @param highlightDetailOddRows a {@link java.lang.Boolean} object. + */ + public void setHighlightDetailOddRows(final Boolean highlightDetailOddRows) + { + this.highlightDetailOddRows = highlightDetailOddRows; + } + + /** + * {@inheritDoc} + */ + @Override + public DRSimpleStyle getDetailOddRowStyle() + { + return this.detailOddRowStyle; + } + + /** + *

Setter for the field detailOddRowStyle.

+ * + * @param detailOddRowStyle a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public void setDetailOddRowStyle(final DRSimpleStyle detailOddRowStyle) + { + this.detailOddRowStyle = detailOddRowStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getHighlightDetailEvenRows() + { + return this.highlightDetailEvenRows; + } + + /** + *

Setter for the field highlightDetailEvenRows.

+ * + * @param highlightDetailEvenRows a {@link java.lang.Boolean} object. + */ + public void setHighlightDetailEvenRows(final Boolean highlightDetailEvenRows) + { + this.highlightDetailEvenRows = highlightDetailEvenRows; + } + + /** + * {@inheritDoc} + */ + @Override + public DRSimpleStyle getDetailEvenRowStyle() + { + return this.detailEvenRowStyle; + } + + /** + *

Setter for the field detailEvenRowStyle.

+ * + * @param detailEvenRowStyle a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public void setDetailEvenRowStyle(final DRSimpleStyle detailEvenRowStyle) + { + this.detailEvenRowStyle = detailEvenRowStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIFont getDefaultFont() + { + return this.defaultFont; + } + + /** + *

Setter for the field defaultFont.

+ * + * @param defaultFont a {@link software.xdev.dynamicreports.report.definition.style.DRIFont} object. + */ + public void setDefaultFont(final DRIFont defaultFont) + { + this.defaultFont = defaultFont; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getTextStyle() + { + return this.textStyle; + } + + /** + *

Setter for the field textStyle.

+ * + * @param textStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setTextStyle(final DRIReportStyle textStyle) + { + this.textStyle = textStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getColumnTitleStyle() + { + return this.columnTitleStyle; + } + + /** + *

Setter for the field columnTitleStyle.

+ * + * @param columnTitleStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setColumnTitleStyle(final DRIReportStyle columnTitleStyle) + { + this.columnTitleStyle = columnTitleStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getColumnStyle() + { + return this.columnStyle; + } + + /** + *

Setter for the field columnStyle.

+ * + * @param columnStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setColumnStyle(final DRIReportStyle columnStyle) + { + this.columnStyle = columnStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getGroupTitleStyle() + { + return this.groupTitleStyle; + } + + /** + *

Setter for the field groupTitleStyle.

+ * + * @param groupTitleStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setGroupTitleStyle(final DRIReportStyle groupTitleStyle) + { + this.groupTitleStyle = groupTitleStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getGroupStyle() + { + return this.groupStyle; + } + + /** + *

Setter for the field groupStyle.

+ * + * @param groupStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setGroupStyle(final DRIReportStyle groupStyle) + { + this.groupStyle = groupStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getSubtotalStyle() + { + return this.subtotalStyle; + } + + /** + *

Setter for the field subtotalStyle.

+ * + * @param subtotalStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setSubtotalStyle(final DRIReportStyle subtotalStyle) + { + this.subtotalStyle = subtotalStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getImageStyle() + { + return this.imageStyle; + } + + /** + *

Setter for the field imageStyle.

+ * + * @param imageStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setImageStyle(final DRIReportStyle imageStyle) + { + this.imageStyle = imageStyle; + } + + /** + *

setPageFormat.

+ * + * @param pageType a {@link software.xdev.dynamicreports.report.constant.PageType} object. + * @param orientation a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + */ + public void setPageFormat(final PageType pageType, final PageOrientation orientation) + { + Validate.notNull(pageType, "pageType must not be null"); + Validate.notNull(orientation, "orientation must not be null"); + if(orientation.equals(PageOrientation.PORTRAIT)) + { + this.setPageWidth(pageType.getWidth()); + this.setPageHeight(pageType.getHeight()); + } + else + { + this.setPageWidth(pageType.getHeight()); + this.setPageHeight(pageType.getWidth()); + } + this.setPageOrientation(orientation); + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getPageWidth() + { + return this.pageWidth; + } + + private void setPageWidth(final Integer pageWidth) + { + if(pageWidth != null) + { + Validate.isTrue(pageWidth >= 0, "pageWidth must be >= 0"); + } + this.pageWidth = pageWidth; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getPageHeight() + { + return this.pageHeight; + } + + private void setPageHeight(final Integer pageHeight) + { + if(pageHeight != null) + { + Validate.isTrue(pageHeight >= 0, "pageHeight must be >= 0"); + } + this.pageHeight = pageHeight; + } + + /** + * {@inheritDoc} + */ + @Override + public PageOrientation getPageOrientation() + { + return this.pageOrientation; + } + + private void setPageOrientation(final PageOrientation pageOrientation) + { + this.pageOrientation = pageOrientation; + } + + /** + * {@inheritDoc} + */ + @Override + public DRMargin getPageMargin() + { + return this.pageMargin; + } + + /** + *

Setter for the field pageMargin.

+ * + * @param pageMargin a {@link software.xdev.dynamicreports.report.base.DRMargin} object. + */ + public void setPageMargin(final DRMargin pageMargin) + { + this.pageMargin = pageMargin; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getPageColumnsPerPage() + { + return this.pageColumnsPerPage; + } + + /** + *

Setter for the field pageColumnsPerPage.

+ * + * @param pageColumnsPerPage a {@link java.lang.Integer} object. + */ + public void setPageColumnsPerPage(final Integer pageColumnsPerPage) + { + if(pageColumnsPerPage != null) + { + Validate.isTrue(pageColumnsPerPage >= 1, "pageColumnsPerPage must be >= 1"); + } + this.pageColumnsPerPage = pageColumnsPerPage; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getPageColumnSpace() + { + return this.pageColumnSpace; + } + + /** + *

Setter for the field pageColumnSpace.

+ * + * @param pageColumnSpace a {@link java.lang.Integer} object. + */ + public void setPageColumnSpace(final Integer pageColumnSpace) + { + if(pageColumnSpace != null) + { + Validate.isTrue(pageColumnSpace >= 0, "pageColumnSpace must be >= 0"); + } + this.pageColumnSpace = pageColumnSpace; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getIgnorePageWidth() + { + return this.ignorePageWidth; + } + + /** + *

Setter for the field ignorePageWidth.

+ * + * @param ignorePageWidth a {@link java.lang.Boolean} object. + */ + public void setIgnorePageWidth(final Boolean ignorePageWidth) + { + this.ignorePageWidth = ignorePageWidth; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getColumnPrintRepeatedDetailValues() + { + return this.columnPrintRepeatedDetailValues; + } + + /** + *

Setter for the field columnPrintRepeatedDetailValues.

+ * + * @param columnPrintRepeatedDetailValues a {@link java.lang.Boolean} object. + */ + public void setColumnPrintRepeatedDetailValues(final Boolean columnPrintRepeatedDetailValues) + { + this.columnPrintRepeatedDetailValues = columnPrintRepeatedDetailValues; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getColumnWidth() + { + return this.columnWidth; + } + + /** + *

Setter for the field columnWidth.

+ * + * @param columnWidth a {@link java.lang.Integer} object. + */ + public void setColumnWidth(final Integer columnWidth) + { + if(columnWidth != null) + { + Validate.isTrue(columnWidth >= 0, "columnWidth must be >= 0"); + } + this.columnWidth = columnWidth; + } + + /** + * {@inheritDoc} + */ + @Override + public GroupHeaderLayout getGroupHeaderLayout() + { + return this.groupHeaderLayout; + } + + /** + *

Setter for the field groupHeaderLayout.

+ * + * @param groupHeaderLayout a {@link software.xdev.dynamicreports.report.constant.GroupHeaderLayout} object. + */ + public void setGroupHeaderLayout(final GroupHeaderLayout groupHeaderLayout) + { + this.groupHeaderLayout = groupHeaderLayout; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getGroupHideColumn() + { + return this.groupHideColumn; + } + + /** + *

Setter for the field groupHideColumn.

+ * + * @param groupHideColumn a {@link java.lang.Boolean} object. + */ + public void setGroupHideColumn(final Boolean groupHideColumn) + { + this.groupHideColumn = groupHideColumn; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getGroupShowColumnHeaderAndFooter() + { + return this.groupShowColumnHeaderAndFooter; + } + + /** + *

Setter for the field groupShowColumnHeaderAndFooter.

+ * + * @param groupShowColumnHeaderAndFooter a {@link java.lang.Boolean} object. + */ + public void setGroupShowColumnHeaderAndFooter(final Boolean groupShowColumnHeaderAndFooter) + { + this.groupShowColumnHeaderAndFooter = groupShowColumnHeaderAndFooter; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getGroupPadding() + { + return this.groupPadding; + } + + /** + *

Setter for the field groupPadding.

+ * + * @param groupPadding a {@link java.lang.Integer} object. + */ + public void setGroupPadding(final Integer groupPadding) + { + if(groupPadding != null) + { + Validate.isTrue(groupPadding >= 0, "groupPadding must be >= 0"); + } + this.groupPadding = groupPadding; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getGroupStartInNewPage() + { + return this.groupStartInNewPage; + } + + /** + *

Setter for the field groupStartInNewPage.

+ * + * @param groupStartInNewPage a {@link java.lang.Boolean} object. + */ + public void setGroupStartInNewPage(final Boolean groupStartInNewPage) + { + this.groupStartInNewPage = groupStartInNewPage; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getGroupStartInNewColumn() + { + return this.groupStartInNewColumn; + } + + /** + *

Setter for the field groupStartInNewColumn.

+ * + * @param groupStartInNewColumn a {@link java.lang.Boolean} object. + */ + public void setGroupStartInNewColumn(final Boolean groupStartInNewColumn) + { + this.groupStartInNewColumn = groupStartInNewColumn; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getGroupReprintHeaderOnEachPage() + { + return this.groupReprintHeaderOnEachPage; + } + + /** + *

Setter for the field groupReprintHeaderOnEachPage.

+ * + * @param groupReprintHeaderOnEachPage a {@link java.lang.Boolean} object. + */ + public void setGroupReprintHeaderOnEachPage(final Boolean groupReprintHeaderOnEachPage) + { + this.groupReprintHeaderOnEachPage = groupReprintHeaderOnEachPage; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getGroupResetPageNumber() + { + return this.groupResetPageNumber; + } + + /** + *

Setter for the field groupResetPageNumber.

+ * + * @param groupResetPageNumber a {@link java.lang.Boolean} object. + */ + public void setGroupResetPageNumber(final Boolean groupResetPageNumber) + { + this.groupResetPageNumber = groupResetPageNumber; + } + + /** + * {@inheritDoc} + */ + @Override + public GroupFooterPosition getGroupFooterPosition() + { + return this.groupFooterPosition; + } + + /** + *

Setter for the field groupFooterPosition.

+ * + * @param groupFooterPosition a {@link software.xdev.dynamicreports.report.constant.GroupFooterPosition} object. + */ + public void setGroupFooterPosition(final GroupFooterPosition groupFooterPosition) + { + this.groupFooterPosition = groupFooterPosition; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getGroupKeepTogether() + { + return this.groupKeepTogether; + } + + /** + *

Setter for the field groupKeepTogether.

+ * + * @param groupKeepTogether a {@link java.lang.Boolean} object. + */ + public void setGroupKeepTogether(final Boolean groupKeepTogether) + { + this.groupKeepTogether = groupKeepTogether; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getGroupHeaderWithSubtotal() + { + return this.groupHeaderWithSubtotal; + } + + /** + *

Setter for the field groupHeaderWithSubtotal.

+ * + * @param groupHeaderWithSubtotal a {@link java.lang.Boolean} object. + */ + public void setGroupHeaderWithSubtotal(final Boolean groupHeaderWithSubtotal) + { + this.groupHeaderWithSubtotal = groupHeaderWithSubtotal; + } + + /** + * {@inheritDoc} + */ + @Override + public Position getSubtotalLabelPosition() + { + return this.subtotalLabelPosition; + } + + /** + *

Setter for the field subtotalLabelPosition.

+ * + * @param subtotalLabelPosition a {@link software.xdev.dynamicreports.report.constant.Position} object. + */ + public void setSubtotalLabelPosition(final Position subtotalLabelPosition) + { + this.subtotalLabelPosition = subtotalLabelPosition; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getTableOfContents() + { + return this.tableOfContents; + } + + /** + *

Setter for the field tableOfContents.

+ * + * @param tableOfContents a {@link java.lang.Boolean} object. + */ + public void setTableOfContents(final Boolean tableOfContents) + { + this.tableOfContents = tableOfContents; + } + + /** + * {@inheritDoc} + */ + @Override + public DRITableOfContentsCustomizer getTableOfContentsCustomizer() + { + return this.tableOfContentsCustomizer; + } + + /** + *

Setter for the field tableOfContentsCustomizer.

+ * + * @param tableOfContentsCustomizer a {@link software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer} + * object. + */ + public void setTableOfContentsCustomizer(final DRITableOfContentsCustomizer tableOfContentsCustomizer) + { + this.tableOfContentsCustomizer = tableOfContentsCustomizer; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getTextFieldWidth() + { + return this.textFieldWidth; + } + + /** + *

Setter for the field textFieldWidth.

+ * + * @param textFieldWidth a {@link java.lang.Integer} object. + */ + public void setTextFieldWidth(final Integer textFieldWidth) + { + if(textFieldWidth != null) + { + Validate.isTrue(textFieldWidth >= 0, "textFieldWidth must be >= 0"); + } + this.textFieldWidth = textFieldWidth; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getImageHeight() + { + return this.imageHeight; + } + + /** + *

Setter for the field imageHeight.

+ * + * @param imageHeight a {@link java.lang.Integer} object. + */ + public void setImageHeight(final Integer imageHeight) + { + if(imageHeight != null) + { + Validate.isTrue(imageHeight >= 0, "imageHeight must be >= 0"); + } + this.imageHeight = imageHeight; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getImageWidth() + { + return this.imageWidth; + } + + /** + *

Setter for the field imageWidth.

+ * + * @param imageWidth a {@link java.lang.Integer} object. + */ + public void setImageWidth(final Integer imageWidth) + { + if(imageWidth != null) + { + Validate.isTrue(imageWidth >= 0, "imageWidth must be >= 0"); + } + this.imageWidth = imageWidth; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getListgap() + { + return this.listgap; + } + + /** + *

Setter for the field listgap.

+ * + * @param listgap a {@link java.lang.Integer} object. + */ + public void setListgap(final Integer listgap) + { + if(listgap != null) + { + Validate.isTrue(listgap >= 0, "listgap must be >= 0"); + } + this.listgap = listgap; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getMultiPageListWidth() + { + return this.multiPageListWidth; + } + + /** + *

Setter for the field multiPageListWidth.

+ * + * @param multiPageListWidth a {@link java.lang.Integer} object. + */ + public void setMultiPageListWidth(final Integer multiPageListWidth) + { + this.multiPageListWidth = multiPageListWidth; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getMultiPageListHeight() + { + return this.multiPageListHeight; + } + + /** + *

Setter for the field multiPageListHeight.

+ * + * @param multiPageListHeight a {@link java.lang.Integer} object. + */ + public void setMultiPageListHeight(final Integer multiPageListHeight) + { + this.multiPageListHeight = multiPageListHeight; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getSubreportHeight() + { + return this.subreportHeight; + } + + /** + *

Setter for the field subreportHeight.

+ * + * @param subreportHeight a {@link java.lang.Integer} object. + */ + public void setSubreportHeight(final Integer subreportHeight) + { + if(subreportHeight != null) + { + Validate.isTrue(subreportHeight >= 0, "subreportHeight must be >= 0"); + } + this.subreportHeight = subreportHeight; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getSubreportWidth() + { + return this.subreportWidth; + } + + /** + *

Setter for the field subreportWidth.

+ * + * @param subreportWidth a {@link java.lang.Integer} object. + */ + public void setSubreportWidth(final Integer subreportWidth) + { + if(subreportWidth != null) + { + Validate.isTrue(subreportWidth >= 0, "subreportWidth must be >= 0"); + } + this.subreportWidth = subreportWidth; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getCrosstabHeight() + { + return this.crosstabHeight; + } + + /** + *

Setter for the field crosstabHeight.

+ * + * @param crosstabHeight a {@link java.lang.Integer} object. + */ + public void setCrosstabHeight(final Integer crosstabHeight) + { + if(crosstabHeight != null) + { + Validate.isTrue(crosstabHeight >= 0, "crosstabHeight must be >= 0"); + } + this.crosstabHeight = crosstabHeight; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getCrosstabWidth() + { + return this.crosstabWidth; + } + + /** + *

Setter for the field crosstabWidth.

+ * + * @param crosstabWidth a {@link java.lang.Integer} object. + */ + public void setCrosstabWidth(final Integer crosstabWidth) + { + if(crosstabWidth != null) + { + Validate.isTrue(crosstabWidth >= 0, "crosstabWidth must be >= 0"); + } + this.crosstabWidth = crosstabWidth; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getCrosstabHighlightOddRows() + { + return this.crosstabHighlightOddRows; + } + + /** + *

Setter for the field crosstabHighlightOddRows.

+ * + * @param crosstabHighlightOddRows a {@link java.lang.Boolean} object. + */ + public void setCrosstabHighlightOddRows(final Boolean crosstabHighlightOddRows) + { + this.crosstabHighlightOddRows = crosstabHighlightOddRows; + } + + /** + * {@inheritDoc} + */ + @Override + public DRSimpleStyle getCrosstabOddRowStyle() + { + return this.crosstabOddRowStyle; + } + + /** + *

Setter for the field crosstabOddRowStyle.

+ * + * @param crosstabOddRowStyle a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public void setCrosstabOddRowStyle(final DRSimpleStyle crosstabOddRowStyle) + { + this.crosstabOddRowStyle = crosstabOddRowStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getCrosstabHighlightEvenRows() + { + return this.crosstabHighlightEvenRows; + } + + /** + *

Setter for the field crosstabHighlightEvenRows.

+ * + * @param crosstabHighlightEvenRows a {@link java.lang.Boolean} object. + */ + public void setCrosstabHighlightEvenRows(final Boolean crosstabHighlightEvenRows) + { + this.crosstabHighlightEvenRows = crosstabHighlightEvenRows; + } + + /** + * {@inheritDoc} + */ + @Override + public DRSimpleStyle getCrosstabEvenRowStyle() + { + return this.crosstabEvenRowStyle; + } + + /** + *

Setter for the field crosstabEvenRowStyle.

+ * + * @param crosstabEvenRowStyle a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public void setCrosstabEvenRowStyle(final DRSimpleStyle crosstabEvenRowStyle) + { + this.crosstabEvenRowStyle = crosstabEvenRowStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getCrosstabGroupStyle() + { + return this.crosstabGroupStyle; + } + + /** + *

Setter for the field crosstabGroupStyle.

+ * + * @param crosstabGroupStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setCrosstabGroupStyle(final DRIReportStyle crosstabGroupStyle) + { + this.crosstabGroupStyle = crosstabGroupStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getCrosstabGroupTotalStyle() + { + return this.crosstabGroupTotalStyle; + } + + /** + *

Setter for the field crosstabGroupTotalStyle.

+ * + * @param crosstabGroupTotalStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setCrosstabGroupTotalStyle(final DRIReportStyle crosstabGroupTotalStyle) + { + this.crosstabGroupTotalStyle = crosstabGroupTotalStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getCrosstabGrandTotalStyle() + { + return this.crosstabGrandTotalStyle; + } + + /** + *

Setter for the field crosstabGrandTotalStyle.

+ * + * @param crosstabGrandTotalStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setCrosstabGrandTotalStyle(final DRIReportStyle crosstabGrandTotalStyle) + { + this.crosstabGrandTotalStyle = crosstabGrandTotalStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getCrosstabCellStyle() + { + return this.crosstabCellStyle; + } + + /** + *

Setter for the field crosstabCellStyle.

+ * + * @param crosstabCellStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setCrosstabCellStyle(final DRIReportStyle crosstabCellStyle) + { + this.crosstabCellStyle = crosstabCellStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getCrosstabMeasureTitleStyle() + { + return this.crosstabMeasureTitleStyle; + } + + /** + *

Setter for the field crosstabMeasureTitleStyle.

+ * + * @param crosstabMeasureTitleStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setCrosstabMeasureTitleStyle(final DRIReportStyle crosstabMeasureTitleStyle) + { + this.crosstabMeasureTitleStyle = crosstabMeasureTitleStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public BooleanComponentType getBooleanComponentType() + { + return this.booleanComponentType; + } + + /** + *

Setter for the field booleanComponentType.

+ * + * @param booleanComponentType a {@link software.xdev.dynamicreports.report.constant.BooleanComponentType} object. + */ + public void setBooleanComponentType(final BooleanComponentType booleanComponentType) + { + this.booleanComponentType = booleanComponentType; + } + + /** + * {@inheritDoc} + */ + @Override + public Boolean getBooleanEmptyWhenNullValue() + { + return this.booleanEmptyWhenNullValue; + } + + /** + *

Setter for the field booleanEmptyWhenNullValue.

+ * + * @param booleanEmptyWhenNullValue a {@link java.lang.Boolean} object. + */ + public void setBooleanEmptyWhenNullValue(final Boolean booleanEmptyWhenNullValue) + { + this.booleanEmptyWhenNullValue = booleanEmptyWhenNullValue; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getBooleanImageWidth() + { + return this.booleanImageWidth; + } + + /** + *

Setter for the field booleanImageWidth.

+ * + * @param booleanImageWidth a {@link java.lang.Integer} object. + */ + public void setBooleanImageWidth(final Integer booleanImageWidth) + { + this.booleanImageWidth = booleanImageWidth; + } + + /** + * {@inheritDoc} + */ + @Override + public Integer getBooleanImageHeight() + { + return this.booleanImageHeight; + } + + /** + *

Setter for the field booleanImageHeight.

+ * + * @param booleanImageHeight a {@link java.lang.Integer} object. + */ + public void setBooleanImageHeight(final Integer booleanImageHeight) + { + this.booleanImageHeight = booleanImageHeight; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getBooleanColumnStyle() + { + return this.booleanColumnStyle; + } + + /** + *

Setter for the field booleanColumnStyle.

+ * + * @param booleanColumnStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setBooleanColumnStyle(final DRIReportStyle booleanColumnStyle) + { + this.booleanColumnStyle = booleanColumnStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getDefaultSplitType() + { + return this.defaultSplitType; + } + + /** + *

Setter for the field defaultSplitType.

+ * + * @param defaultSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setDefaultSplitType(final SplitType defaultSplitType) + { + this.defaultSplitType = defaultSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getTitleSplitType() + { + return this.titleSplitType; + } + + /** + *

Setter for the field titleSplitType.

+ * + * @param titleSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setTitleSplitType(final SplitType titleSplitType) + { + this.titleSplitType = titleSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getPageHeaderSplitType() + { + return this.pageHeaderSplitType; + } + + /** + *

Setter for the field pageHeaderSplitType.

+ * + * @param pageHeaderSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setPageHeaderSplitType(final SplitType pageHeaderSplitType) + { + this.pageHeaderSplitType = pageHeaderSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getPageFooterSplitType() + { + return this.pageFooterSplitType; + } + + /** + *

Setter for the field pageFooterSplitType.

+ * + * @param pageFooterSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setPageFooterSplitType(final SplitType pageFooterSplitType) + { + this.pageFooterSplitType = pageFooterSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getColumnHeaderSplitType() + { + return this.columnHeaderSplitType; + } + + /** + *

Setter for the field columnHeaderSplitType.

+ * + * @param columnHeaderSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setColumnHeaderSplitType(final SplitType columnHeaderSplitType) + { + this.columnHeaderSplitType = columnHeaderSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getColumnFooterSplitType() + { + return this.columnFooterSplitType; + } + + /** + *

Setter for the field columnFooterSplitType.

+ * + * @param columnFooterSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setColumnFooterSplitType(final SplitType columnFooterSplitType) + { + this.columnFooterSplitType = columnFooterSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getGroupHeaderSplitType() + { + return this.groupHeaderSplitType; + } + + /** + *

Setter for the field groupHeaderSplitType.

+ * + * @param groupHeaderSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setGroupHeaderSplitType(final SplitType groupHeaderSplitType) + { + this.groupHeaderSplitType = groupHeaderSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getGroupFooterSplitType() + { + return this.groupFooterSplitType; + } + + /** + *

Setter for the field groupFooterSplitType.

+ * + * @param groupFooterSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setGroupFooterSplitType(final SplitType groupFooterSplitType) + { + this.groupFooterSplitType = groupFooterSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getDetailHeaderSplitType() + { + return this.detailHeaderSplitType; + } + + /** + *

Setter for the field detailHeaderSplitType.

+ * + * @param detailHeaderSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setDetailHeaderSplitType(final SplitType detailHeaderSplitType) + { + this.detailHeaderSplitType = detailHeaderSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getDetailSplitType() + { + return this.detailSplitType; + } + + /** + *

Setter for the field detailSplitType.

+ * + * @param detailSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setDetailSplitType(final SplitType detailSplitType) + { + this.detailSplitType = detailSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getDetailFooterSplitType() + { + return this.detailFooterSplitType; + } + + /** + *

Setter for the field detailFooterSplitType.

+ * + * @param detailFooterSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setDetailFooterSplitType(final SplitType detailFooterSplitType) + { + this.detailFooterSplitType = detailFooterSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getLastPageFooterSplitType() + { + return this.lastPageFooterSplitType; + } + + /** + *

Setter for the field lastPageFooterSplitType.

+ * + * @param lastPageFooterSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setLastPageFooterSplitType(final SplitType lastPageFooterSplitType) + { + this.lastPageFooterSplitType = lastPageFooterSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getSummarySplitType() + { + return this.summarySplitType; + } + + /** + *

Setter for the field summarySplitType.

+ * + * @param summarySplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setSummarySplitType(final SplitType summarySplitType) + { + this.summarySplitType = summarySplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getNoDataSplitType() + { + return this.noDataSplitType; + } + + /** + *

Setter for the field noDataSplitType.

+ * + * @param noDataSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setNoDataSplitType(final SplitType noDataSplitType) + { + this.noDataSplitType = noDataSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public SplitType getBackgroundSplitType() + { + return this.backgroundSplitType; + } + + /** + *

Setter for the field backgroundSplitType.

+ * + * @param backgroundSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setBackgroundSplitType(final SplitType backgroundSplitType) + { + this.backgroundSplitType = backgroundSplitType; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getTitleStyle() + { + return this.titleStyle; + } + + /** + *

Setter for the field titleStyle.

+ * + * @param titleStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setTitleStyle(final DRIReportStyle titleStyle) + { + this.titleStyle = titleStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getPageHeaderStyle() + { + return this.pageHeaderStyle; + } + + /** + *

Setter for the field pageHeaderStyle.

+ * + * @param pageHeaderStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setPageHeaderStyle(final DRIReportStyle pageHeaderStyle) + { + this.pageHeaderStyle = pageHeaderStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getPageFooterStyle() + { + return this.pageFooterStyle; + } + + /** + *

Setter for the field pageFooterStyle.

+ * + * @param pageFooterStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setPageFooterStyle(final DRIReportStyle pageFooterStyle) + { + this.pageFooterStyle = pageFooterStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getColumnHeaderStyle() + { + return this.columnHeaderStyle; + } + + /** + *

Setter for the field columnHeaderStyle.

+ * + * @param columnHeaderStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setColumnHeaderStyle(final DRIReportStyle columnHeaderStyle) + { + this.columnHeaderStyle = columnHeaderStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getColumnFooterStyle() + { + return this.columnFooterStyle; + } + + /** + *

Setter for the field columnFooterStyle.

+ * + * @param columnFooterStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setColumnFooterStyle(final DRIReportStyle columnFooterStyle) + { + this.columnFooterStyle = columnFooterStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getGroupHeaderStyle() + { + return this.groupHeaderStyle; + } + + /** + *

Setter for the field groupHeaderStyle.

+ * + * @param groupHeaderStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setGroupHeaderStyle(final DRIReportStyle groupHeaderStyle) + { + this.groupHeaderStyle = groupHeaderStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getGroupFooterStyle() + { + return this.groupFooterStyle; + } + + /** + *

Setter for the field groupFooterStyle.

+ * + * @param groupFooterStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setGroupFooterStyle(final DRIReportStyle groupFooterStyle) + { + this.groupFooterStyle = groupFooterStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getDetailHeaderStyle() + { + return this.detailHeaderStyle; + } + + /** + *

Setter for the field detailHeaderStyle.

+ * + * @param detailHeaderStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setDetailHeaderStyle(final DRIReportStyle detailHeaderStyle) + { + this.detailHeaderStyle = detailHeaderStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getDetailStyle() + { + return this.detailStyle; + } + + /** + *

Setter for the field detailStyle.

+ * + * @param detailStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setDetailStyle(final DRIReportStyle detailStyle) + { + this.detailStyle = detailStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getDetailFooterStyle() + { + return this.detailFooterStyle; + } + + /** + *

Setter for the field detailFooterStyle.

+ * + * @param detailFooterStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setDetailFooterStyle(final DRIReportStyle detailFooterStyle) + { + this.detailFooterStyle = detailFooterStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getLastPageFooterStyle() + { + return this.lastPageFooterStyle; + } + + /** + *

Setter for the field lastPageFooterStyle.

+ * + * @param lastPageFooterStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setLastPageFooterStyle(final DRIReportStyle lastPageFooterStyle) + { + this.lastPageFooterStyle = lastPageFooterStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getSummaryStyle() + { + return this.summaryStyle; + } + + /** + *

Setter for the field summaryStyle.

+ * + * @param summaryStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setSummaryStyle(final DRIReportStyle summaryStyle) + { + this.summaryStyle = summaryStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getNoDataStyle() + { + return this.noDataStyle; + } + + /** + *

Setter for the field noDataStyle.

+ * + * @param noDataStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setNoDataStyle(final DRIReportStyle noDataStyle) + { + this.noDataStyle = noDataStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRIReportStyle getBackgroundStyle() + { + return this.backgroundStyle; + } + + /** + *

Setter for the field backgroundStyle.

+ * + * @param backgroundStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setBackgroundStyle(final DRIReportStyle backgroundStyle) + { + this.backgroundStyle = backgroundStyle; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getTitleBackgroundComponent() + { + return this.titleBackgroundComponent; + } + + /** + *

Setter for the field titleBackgroundComponent.

+ * + * @param titleBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setTitleBackgroundComponent(final DRComponent titleBackgroundComponent) + { + this.titleBackgroundComponent = titleBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getPageHeaderBackgroundComponent() + { + return this.pageHeaderBackgroundComponent; + } + + /** + *

Setter for the field pageHeaderBackgroundComponent.

+ * + * @param pageHeaderBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setPageHeaderBackgroundComponent(final DRComponent pageHeaderBackgroundComponent) + { + this.pageHeaderBackgroundComponent = pageHeaderBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getPageFooterBackgroundComponent() + { + return this.pageFooterBackgroundComponent; + } + + /** + *

Setter for the field pageFooterBackgroundComponent.

+ * + * @param pageFooterBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setPageFooterBackgroundComponent(final DRComponent pageFooterBackgroundComponent) + { + this.pageFooterBackgroundComponent = pageFooterBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getColumnHeaderBackgroundComponent() + { + return this.columnHeaderBackgroundComponent; + } + + /** + *

Setter for the field columnHeaderBackgroundComponent.

+ * + * @param columnHeaderBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setColumnHeaderBackgroundComponent(final DRComponent columnHeaderBackgroundComponent) + { + this.columnHeaderBackgroundComponent = columnHeaderBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getColumnFooterBackgroundComponent() + { + return this.columnFooterBackgroundComponent; + } + + /** + *

Setter for the field columnFooterBackgroundComponent.

+ * + * @param columnFooterBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setColumnFooterBackgroundComponent(final DRComponent columnFooterBackgroundComponent) + { + this.columnFooterBackgroundComponent = columnFooterBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getGroupHeaderBackgroundComponent() + { + return this.groupHeaderBackgroundComponent; + } + + /** + *

Setter for the field groupHeaderBackgroundComponent.

+ * + * @param groupHeaderBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setGroupHeaderBackgroundComponent(final DRComponent groupHeaderBackgroundComponent) + { + this.groupHeaderBackgroundComponent = groupHeaderBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getGroupFooterBackgroundComponent() + { + return this.groupFooterBackgroundComponent; + } + + /** + *

Setter for the field groupFooterBackgroundComponent.

+ * + * @param groupFooterBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setGroupFooterBackgroundComponent(final DRComponent groupFooterBackgroundComponent) + { + this.groupFooterBackgroundComponent = groupFooterBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getDetailHeaderBackgroundComponent() + { + return this.detailHeaderBackgroundComponent; + } + + /** + *

Setter for the field detailHeaderBackgroundComponent.

+ * + * @param detailHeaderBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setDetailHeaderBackgroundComponent(final DRComponent detailHeaderBackgroundComponent) + { + this.detailHeaderBackgroundComponent = detailHeaderBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getDetailBackgroundComponent() + { + return this.detailBackgroundComponent; + } + + /** + *

Setter for the field detailBackgroundComponent.

+ * + * @param detailBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setDetailBackgroundComponent(final DRComponent detailBackgroundComponent) + { + this.detailBackgroundComponent = detailBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getDetailFooterBackgroundComponent() + { + return this.detailFooterBackgroundComponent; + } + + /** + *

Setter for the field detailFooterBackgroundComponent.

+ * + * @param detailFooterBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setDetailFooterBackgroundComponent(final DRComponent detailFooterBackgroundComponent) + { + this.detailFooterBackgroundComponent = detailFooterBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getLastPageFooterBackgroundComponent() + { + return this.lastPageFooterBackgroundComponent; + } + + /** + *

Setter for the field lastPageFooterBackgroundComponent.

+ * + * @param lastPageFooterBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} + * object. + */ + public void setLastPageFooterBackgroundComponent(final DRComponent lastPageFooterBackgroundComponent) + { + this.lastPageFooterBackgroundComponent = lastPageFooterBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getSummaryBackgroundComponent() + { + return this.summaryBackgroundComponent; + } + + /** + *

Setter for the field summaryBackgroundComponent.

+ * + * @param summaryBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setSummaryBackgroundComponent(final DRComponent summaryBackgroundComponent) + { + this.summaryBackgroundComponent = summaryBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getNoDataBackgroundComponent() + { + return this.noDataBackgroundComponent; + } + + /** + *

Setter for the field noDataBackgroundComponent.

+ * + * @param noDataBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setNoDataBackgroundComponent(final DRComponent noDataBackgroundComponent) + { + this.noDataBackgroundComponent = noDataBackgroundComponent; + } + + /** + * {@inheritDoc} + */ + @Override + public DRComponent getBackgroundBackgroundComponent() + { + return this.backgroundBackgroundComponent; + } + + /** + *

Setter for the field backgroundBackgroundComponent.

+ * + * @param backgroundBackgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setBackgroundBackgroundComponent(final DRComponent backgroundBackgroundComponent) + { + this.backgroundBackgroundComponent = backgroundBackgroundComponent; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRSort.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRSort.java new file mode 100644 index 0000000..56a109d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRSort.java @@ -0,0 +1,67 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.OrderType; +import software.xdev.dynamicreports.report.definition.DRISort; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRSort class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRSort implements DRISort { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression expression; + private OrderType orderType; + + /** {@inheritDoc} */ + @Override + public DRIExpression getExpression() { + return expression; + } + + /** + *

Setter for the field expression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setExpression(DRIExpression expression) { + this.expression = expression; + } + + /** {@inheritDoc} */ + @Override + public OrderType getOrderType() { + return orderType; + } + + /** + *

Setter for the field orderType.

+ * + * @param orderType a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + */ + public void setOrderType(OrderType orderType) { + this.orderType = orderType; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRSubtotal.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRSubtotal.java new file mode 100644 index 0000000..6f6b670 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRSubtotal.java @@ -0,0 +1,204 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.base.column.DRColumn; +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.Position; +import software.xdev.dynamicreports.report.constant.SubtotalPosition; +import software.xdev.dynamicreports.report.definition.DRISubtotal; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import org.apache.commons.lang3.Validate; + +/** + *

DRSubtotal class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRSubtotal implements DRISubtotal { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRColumn showInColumn; + private DRTextField valueField; + private SubtotalPosition position; + private DRGroup group; + + private DRIExpression labelExpression; + private DRIReportStyle labelStyle; + private Position labelPosition; + private Integer labelWidth; + private ComponentDimensionType labelWidthType; + + /** + *

Constructor for DRSubtotal.

+ * + * @param showInColumn a {@link software.xdev.dynamicreports.report.base.column.DRColumn} object. + */ + public DRSubtotal(DRColumn showInColumn) { + setShowInColumn(showInColumn); + init(); + } + + private void init() { + valueField = new DRTextField(); + } + + /** {@inheritDoc} */ + @Override + public DRColumn getShowInColumn() { + return showInColumn; + } + + /** + *

Setter for the field showInColumn.

+ * + * @param showInColumn a {@link software.xdev.dynamicreports.report.base.column.DRColumn} object. + */ + public void setShowInColumn(DRColumn showInColumn) { + Validate.notNull(showInColumn, "showInColumn must not be null"); + this.showInColumn = showInColumn; + } + + /** {@inheritDoc} */ + @Override + public DRTextField getValueField() { + return valueField; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getLabelExpression() { + return labelExpression; + } + + /** + *

Setter for the field labelExpression.

+ * + * @param labelExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setLabelExpression(DRIExpression labelExpression) { + this.labelExpression = labelExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getLabelStyle() { + return labelStyle; + } + + /** + *

Setter for the field labelStyle.

+ * + * @param labelStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setLabelStyle(DRIReportStyle labelStyle) { + this.labelStyle = labelStyle; + } + + /** {@inheritDoc} */ + @Override + public Position getLabelPosition() { + return labelPosition; + } + + /** + *

Setter for the field labelPosition.

+ * + * @param labelPosition a {@link software.xdev.dynamicreports.report.constant.Position} object. + */ + public void setLabelPosition(Position labelPosition) { + this.labelPosition = labelPosition; + } + + /** {@inheritDoc} */ + @Override + public Integer getLabelWidth() { + return labelWidth; + } + + /** + *

Setter for the field labelWidth.

+ * + * @param labelWidth a {@link java.lang.Integer} object. + */ + public void setLabelWidth(Integer labelWidth) { + this.labelWidth = labelWidth; + } + + /** {@inheritDoc} */ + @Override + public ComponentDimensionType getLabelWidthType() { + return labelWidthType; + } + + /** + *

Setter for the field labelWidthType.

+ * + * @param labelWidthType a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public void setLabelWidthType(ComponentDimensionType labelWidthType) { + this.labelWidthType = labelWidthType; + } + + /** {@inheritDoc} */ + @Override + public SubtotalPosition getPosition() { + return position; + } + + /** + *

Setter for the field position.

+ * + * @param position a {@link software.xdev.dynamicreports.report.constant.SubtotalPosition} object. + */ + public void setPosition(SubtotalPosition position) { + Validate.notNull(position, "position must not be null"); + this.position = position; + } + + /** {@inheritDoc} */ + @Override + public DRGroup getGroup() { + return group; + } + + /** + *

Setter for the field group.

+ * + * @param group a {@link software.xdev.dynamicreports.report.base.DRGroup} object. + */ + public void setGroup(DRGroup group) { + this.group = group; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return valueField.getValueExpression().getName(); + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return valueField.getValueExpression().getValueClass(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRTableOfContentsHeading.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRTableOfContentsHeading.java new file mode 100644 index 0000000..201320f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRTableOfContentsHeading.java @@ -0,0 +1,82 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsHeading; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRTableOfContentsHeading class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRTableOfContentsHeading implements DRITableOfContentsHeading { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRTableOfContentsHeading parentHeading; + private DRIExpression labelExpression; + private DRIExpression customValueExpression; + + /** {@inheritDoc} */ + @Override + public DRTableOfContentsHeading getParentHeading() { + return parentHeading; + } + + /** + *

Setter for the field parentHeading.

+ * + * @param parentHeading a {@link software.xdev.dynamicreports.report.base.DRTableOfContentsHeading} object. + */ + public void setParentHeading(DRTableOfContentsHeading parentHeading) { + this.parentHeading = parentHeading; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getLabelExpression() { + return labelExpression; + } + + /** + *

Setter for the field labelExpression.

+ * + * @param labelExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setLabelExpression(DRIExpression labelExpression) { + this.labelExpression = labelExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getCustomValueExpression() { + return customValueExpression; + } + + /** + *

Setter for the field customValueExpression.

+ * + * @param customValueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setCustomValueExpression(DRIExpression customValueExpression) { + this.customValueExpression = customValueExpression; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRVariable.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRVariable.java new file mode 100644 index 0000000..217cff7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/DRVariable.java @@ -0,0 +1,139 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.definition.DRIVariable; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + *

DRVariable class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRVariable implements DRIVariable { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRIExpression valueExpression; + private DRIExpression initialValueExpression; + private Calculation calculation; + private Evaluation resetType; + private DRGroup resetGroup; + + /** + *

Constructor for DRVariable.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + public DRVariable(DRIExpression valueExpression, Calculation calculation) { + this(ReportUtils.generateUniqueName("variable"), valueExpression, calculation); + } + + /** + *

Constructor for DRVariable.

+ * + * @param name a {@link java.lang.String} object. + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + public DRVariable(String name, DRIExpression valueExpression, Calculation calculation) { + Validate.notEmpty(name, "name must not be empty"); + Validate.notNull(valueExpression, "valueExpression must not be null"); + Validate.notNull(calculation, "calculation must not be null"); + this.name = name; + this.valueExpression = valueExpression; + this.calculation = calculation; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getInitialValueExpression() { + return initialValueExpression; + } + + /** + *

Setter for the field initialValueExpression.

+ * + * @param initialValueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setInitialValueExpression(DRIExpression initialValueExpression) { + this.initialValueExpression = initialValueExpression; + } + + /** {@inheritDoc} */ + @Override + public Calculation getCalculation() { + return calculation; + } + + /** {@inheritDoc} */ + @Override + public Evaluation getResetType() { + return resetType; + } + + /** + *

Setter for the field resetType.

+ * + * @param resetType a {@link software.xdev.dynamicreports.report.constant.Evaluation} object. + */ + public void setResetType(Evaluation resetType) { + this.resetType = resetType; + } + + /** {@inheritDoc} */ + @Override + public DRGroup getResetGroup() { + return resetGroup; + } + + /** + *

Setter for the field resetGroup.

+ * + * @param resetGroup a {@link software.xdev.dynamicreports.report.base.DRGroup} object. + */ + public void setResetGroup(DRGroup resetGroup) { + this.resetGroup = resetGroup; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getValueExpression() { + return valueExpression; + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public Class getValueClass() { + return (Class) ReportUtils.getVariableValueClass(getCalculation(), valueExpression.getValueClass()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/column/DRBooleanColumn.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/column/DRBooleanColumn.java new file mode 100644 index 0000000..9cb8fc3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/column/DRBooleanColumn.java @@ -0,0 +1,54 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.column; + +import software.xdev.dynamicreports.report.base.component.DRBooleanField; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.column.DRIBooleanColumn; +import software.xdev.dynamicreports.report.definition.component.DRIBooleanField; + +/** + *

DRBooleanColumn class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRBooleanColumn extends DRColumn implements DRIBooleanColumn { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for DRBooleanColumn.

+ * + * @param booleanField a {@link software.xdev.dynamicreports.report.base.component.DRBooleanField} object. + */ + public DRBooleanColumn(DRBooleanField booleanField) { + super(booleanField); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return getComponent().getValueExpression().getName(); + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return Boolean.class; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/column/DRColumn.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/column/DRColumn.java new file mode 100644 index 0000000..e9b35bf --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/column/DRColumn.java @@ -0,0 +1,225 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.column; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.column.DRIColumn; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +/** + *

DRColumn class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class DRColumn implements DRIColumn { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private final String name; + private T component; + + private DRIExpression titleExpression; + private DRIReportStyle titleStyle; + private Integer titleHeight; + private ComponentDimensionType titleHeightType; + private Integer titleRows; + private Boolean titleStretchWithOverflow; + private TextAdjust titleTextAdjust; + private List titlePropertyExpressions; + + /** + *

Constructor for DRColumn.

+ */ + protected DRColumn() { + this.name = ReportUtils.generateUniqueName("column"); + titlePropertyExpressions = new ArrayList<>(); + } + + /** + *

Constructor for DRColumn.

+ * + * @param component a T object. + */ + public DRColumn(final T component) { + Validate.notNull(component, "component must not be null"); + this.name = ReportUtils.generateUniqueName("column"); + this.component = component; + titlePropertyExpressions = new ArrayList<>(); + } + + /** {@inheritDoc} */ + @Override + public T getComponent() { + return component; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getTitleExpression() { + return titleExpression; + } + + /** + *

Setter for the field titleExpression.

+ * + * @param titleExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setTitleExpression(final DRIExpression titleExpression) { + this.titleExpression = titleExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getTitleStyle() { + return titleStyle; + } + + /** + *

Setter for the field titleStyle.

+ * + * @param titleStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setTitleStyle(final DRIReportStyle titleStyle) { + this.titleStyle = titleStyle; + } + + /** {@inheritDoc} */ + @Override + public Integer getTitleHeight() { + return titleHeight; + } + + /** + *

Setter for the field titleHeight.

+ * + * @param titleHeight a {@link java.lang.Integer} object. + */ + public void setTitleHeight(final Integer titleHeight) { + if (titleHeight != null) { + Validate.isTrue(titleHeight >= 0, "titleHeight must be >= 0"); + } + this.titleHeight = titleHeight; + } + + /** {@inheritDoc} */ + @Override + public ComponentDimensionType getTitleHeightType() { + return titleHeightType; + } + + /** + *

Setter for the field titleHeightType.

+ * + * @param titleHeightType a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public void setTitleHeightType(final ComponentDimensionType titleHeightType) { + this.titleHeightType = titleHeightType; + } + + /** {@inheritDoc} */ + @Override + public Integer getTitleRows() { + return titleRows; + } + + /** + *

Setter for the field titleRows.

+ * + * @param titleRows a {@link java.lang.Integer} object. + */ + public void setTitleRows(final Integer titleRows) { + if (titleRows != null) { + Validate.isTrue(titleRows >= 0, "titleRows must be >= 0"); + } + this.titleRows = titleRows; + } + + /** {@inheritDoc} */ + @Override + public Boolean getTitleStretchWithOverflow() { + return titleStretchWithOverflow; + } + + /** + *

Setter for the field titleStretchWithOverflow.

+ * + * @param titleStretchWithOverflow a {@link java.lang.Boolean} object. + * @deprecated replaced by {@link #setTitleTextAdjust(TextAdjust)} + */ + @Deprecated + public void setTitleStretchWithOverflow(final Boolean titleStretchWithOverflow) { + this.titleStretchWithOverflow = titleStretchWithOverflow; + } + + /** {@inheritDoc} */ + @Override + public TextAdjust getTitleTextAdjust() { + return titleTextAdjust; + } + + /** + *

Setter for the field titleTextAdjust.

+ * + * @param titleStretchWithOverflow a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + public void setTitleTextAdjust(final TextAdjust titleTextAdjust) { + this.titleTextAdjust = titleTextAdjust; + } + + /** {@inheritDoc} */ + @Override + public List getTitlePropertyExpressions() { + return titlePropertyExpressions; + } + + /** + *

Setter for the field titlePropertyExpressions.

+ * + * @param titlePropertyExpressions a {@link java.util.List} object. + */ + public void setTitlePropertyExpressions(final List titlePropertyExpressions) { + this.titlePropertyExpressions = titlePropertyExpressions; + } + + /** + *

addTitlePropertyExpression.

+ * + * @param propertyExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression} object. + */ + public void addTitlePropertyExpression(final DRIPropertyExpression propertyExpression) { + Validate.notNull(propertyExpression, "propertyExpression must not be null"); + this.titlePropertyExpressions.add(propertyExpression); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/column/DRValueColumn.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/column/DRValueColumn.java new file mode 100644 index 0000000..b613621 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/column/DRValueColumn.java @@ -0,0 +1,71 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.column; + +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.column.DRIValueColumn; +import software.xdev.dynamicreports.report.definition.component.DRITextField; + +/** + *

DRValueColumn class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRValueColumn extends DRColumn> implements DRIValueColumn { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Boolean printRepeatedDetailValues; + + /** + *

Constructor for DRValueColumn.

+ * + * @param valueField a {@link software.xdev.dynamicreports.report.base.component.DRTextField} object. + */ + public DRValueColumn(DRTextField valueField) { + super(valueField); + } + + /** {@inheritDoc} */ + @Override + public Boolean getPrintRepeatedDetailValues() { + return printRepeatedDetailValues; + } + + /** + *

Setter for the field printRepeatedDetailValues.

+ * + * @param printRepeatedDetailValues a {@link java.lang.Boolean} object. + */ + public void setPrintRepeatedDetailValues(Boolean printRepeatedDetailValues) { + this.printRepeatedDetailValues = printRepeatedDetailValues; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return getComponent().getValueExpression().getName(); + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return getComponent().getValueExpression().getValueClass(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRBooleanField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRBooleanField.java new file mode 100644 index 0000000..da43dcc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRBooleanField.java @@ -0,0 +1,156 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.definition.component.DRIBooleanField; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + *

DRBooleanField class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRBooleanField extends DRHyperLinkComponent implements DRIBooleanField { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression valueExpression; + private BooleanComponentType componentType; + private Boolean emptyWhenNullValue; + private Integer imageWidth; + private Integer imageHeight; + private HorizontalImageAlignment horizontalImageAlignment; + private HorizontalTextAlignment horizontalTextAlignment; + + /** {@inheritDoc} */ + @Override + public DRIExpression getValueExpression() { + return valueExpression; + } + + /** + *

Setter for the field valueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setValueExpression(DRIExpression valueExpression) { + Validate.notNull(valueExpression, "valueExpression must not be null"); + this.valueExpression = valueExpression; + } + + /** {@inheritDoc} */ + @Override + public BooleanComponentType getComponentType() { + return componentType; + } + + /** + *

Setter for the field componentType.

+ * + * @param componentType a {@link software.xdev.dynamicreports.report.constant.BooleanComponentType} object. + */ + public void setComponentType(BooleanComponentType componentType) { + this.componentType = componentType; + } + + /** {@inheritDoc} */ + @Override + public Boolean getEmptyWhenNullValue() { + return emptyWhenNullValue; + } + + /** + *

Setter for the field emptyWhenNullValue.

+ * + * @param emptyWhenNullValue a {@link java.lang.Boolean} object. + */ + public void setEmptyWhenNullValue(Boolean emptyWhenNullValue) { + this.emptyWhenNullValue = emptyWhenNullValue; + } + + /** {@inheritDoc} */ + @Override + public Integer getImageWidth() { + return imageWidth; + } + + /** + *

Setter for the field imageWidth.

+ * + * @param imageWidth a {@link java.lang.Integer} object. + */ + public void setImageWidth(Integer imageWidth) { + if (imageWidth != null) { + Validate.isTrue(imageWidth >= 0, "imageWidth must be >= 0"); + } + this.imageWidth = imageWidth; + } + + /** {@inheritDoc} */ + @Override + public Integer getImageHeight() { + return imageHeight; + } + + /** + *

Setter for the field imageHeight.

+ * + * @param imageHeight a {@link java.lang.Integer} object. + */ + public void setImageHeight(Integer imageHeight) { + if (imageHeight != null) { + Validate.isTrue(imageHeight >= 0, "imageHeight must be >= 0"); + } + this.imageHeight = imageHeight; + } + + /** {@inheritDoc} */ + @Override + public HorizontalImageAlignment getHorizontalImageAlignment() { + return horizontalImageAlignment; + } + + /** + *

Setter for the field horizontalImageAlignment.

+ * + * @param horizontalImageAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public void setHorizontalImageAlignment(HorizontalImageAlignment horizontalImageAlignment) { + this.horizontalImageAlignment = horizontalImageAlignment; + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return horizontalTextAlignment; + } + + /** + *

Setter for the field horizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public void setHorizontalTextAlignment(HorizontalTextAlignment horizontalTextAlignment) { + this.horizontalTextAlignment = horizontalTextAlignment; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRBreak.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRBreak.java new file mode 100644 index 0000000..07fdfb9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRBreak.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.BreakType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIBreak; + +/** + *

DRBreak class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRBreak extends DRComponent implements DRIBreak { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private BreakType breakType; + + /** {@inheritDoc} */ + @Override + public BreakType getType() { + return breakType; + } + + /** + *

setType.

+ * + * @param breakType a {@link software.xdev.dynamicreports.report.constant.BreakType} object. + */ + public void setType(BreakType breakType) { + this.breakType = breakType; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRComponent.java new file mode 100644 index 0000000..7352648 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRComponent.java @@ -0,0 +1,145 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.base.DRTableOfContentsHeading; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import org.apache.commons.lang3.Validate; + +import java.util.ArrayList; +import java.util.List; + +/** + *

Abstract DRComponent class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class DRComponent implements DRIComponent { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIReportStyle style; + private DRIExpression printWhenExpression; + private Boolean removeLineWhenBlank; + private List propertyExpressions; + private DRTableOfContentsHeading tableOfContentsHeading; + + /** + *

Constructor for DRComponent.

+ */ + public DRComponent() { + init(); + } + + /** + *

init.

+ */ + protected void init() { + propertyExpressions = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getStyle() { + return style; + } + + /** + *

Setter for the field style.

+ * + * @param style a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setStyle(DRIReportStyle style) { + this.style = style; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getPrintWhenExpression() { + return printWhenExpression; + } + + /** + *

Setter for the field printWhenExpression.

+ * + * @param printWhenExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setPrintWhenExpression(DRIExpression printWhenExpression) { + this.printWhenExpression = printWhenExpression; + } + + /** {@inheritDoc} */ + @Override + public Boolean getRemoveLineWhenBlank() { + return removeLineWhenBlank; + } + + /** + *

Setter for the field removeLineWhenBlank.

+ * + * @param removeLineWhenBlank a {@link java.lang.Boolean} object. + */ + public void setRemoveLineWhenBlank(Boolean removeLineWhenBlank) { + this.removeLineWhenBlank = removeLineWhenBlank; + } + + /** {@inheritDoc} */ + @Override + public List getPropertyExpressions() { + return propertyExpressions; + } + + /** + *

Setter for the field propertyExpressions.

+ * + * @param propertyExpressions a {@link java.util.List} object. + */ + public void setPropertyExpressions(List propertyExpressions) { + this.propertyExpressions = propertyExpressions; + } + + /** + *

addPropertyExpression.

+ * + * @param propertyExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression} object. + */ + public void addPropertyExpression(DRIPropertyExpression propertyExpression) { + Validate.notNull(propertyExpression, "propertyExpression must not be null"); + this.propertyExpressions.add(propertyExpression); + } + + /** {@inheritDoc} */ + @Override + public DRTableOfContentsHeading getTableOfContentsHeading() { + return tableOfContentsHeading; + } + + /** + *

Setter for the field tableOfContentsHeading.

+ * + * @param tableOfContentsHeading a {@link software.xdev.dynamicreports.report.base.DRTableOfContentsHeading} object. + */ + public void setTableOfContentsHeading(DRTableOfContentsHeading tableOfContentsHeading) { + this.tableOfContentsHeading = tableOfContentsHeading; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRCurrentDate.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRCurrentDate.java new file mode 100644 index 0000000..ca92c2e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRCurrentDate.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRICurrentDate; + +/** + *

DRCurrentDate class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRCurrentDate extends DRFormatField implements DRICurrentDate { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String pattern; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return pattern; + } + + /** + *

Setter for the field pattern.

+ * + * @param pattern a {@link java.lang.String} object. + */ + public void setPattern(String pattern) { + this.pattern = pattern; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRDimensionComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRDimensionComponent.java new file mode 100644 index 0000000..9d80667 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRDimensionComponent.java @@ -0,0 +1,187 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.ComponentPositionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.StretchType; +import software.xdev.dynamicreports.report.definition.DRIGroup; +import software.xdev.dynamicreports.report.definition.component.DRIDimensionComponent; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract DRDimensionComponent class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class DRDimensionComponent extends DRComponent implements DRIDimensionComponent { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer width; + private Integer height; + private ComponentDimensionType widthType; + private ComponentDimensionType heightType; + private ComponentPositionType positionType; + private StretchType stretchType; + private Boolean printInFirstWholeBand; + private Boolean printWhenDetailOverflows; + private DRIGroup printWhenGroupChanges; + + /** {@inheritDoc} */ + @Override + public Integer getWidth() { + return width; + } + + /** + *

Setter for the field width.

+ * + * @param width a {@link java.lang.Integer} object. + */ + public void setWidth(Integer width) { + if (width != null) { + Validate.isTrue(width >= 0, "width must be >= 0"); + } + this.width = width; + } + + /** {@inheritDoc} */ + @Override + public Integer getHeight() { + return height; + } + + /** + *

Setter for the field height.

+ * + * @param height a {@link java.lang.Integer} object. + */ + public void setHeight(Integer height) { + if (height != null) { + Validate.isTrue(height >= 0, "height must be >= 0"); + } + this.height = height; + } + + /** {@inheritDoc} */ + @Override + public ComponentDimensionType getWidthType() { + return widthType; + } + + /** + *

Setter for the field widthType.

+ * + * @param widthType a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public void setWidthType(ComponentDimensionType widthType) { + this.widthType = widthType; + } + + /** {@inheritDoc} */ + @Override + public ComponentDimensionType getHeightType() { + return heightType; + } + + /** + *

Setter for the field heightType.

+ * + * @param heightType a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public void setHeightType(ComponentDimensionType heightType) { + this.heightType = heightType; + } + + /** {@inheritDoc} */ + @Override + public ComponentPositionType getPositionType() { + return positionType; + } + + /** + *

Setter for the field positionType.

+ * + * @param positionType a {@link software.xdev.dynamicreports.report.constant.ComponentPositionType} object. + */ + public void setPositionType(ComponentPositionType positionType) { + this.positionType = positionType; + } + + /** {@inheritDoc} */ + @Override + public StretchType getStretchType() { + return stretchType; + } + + /** + *

Setter for the field stretchType.

+ * + * @param stretchType a {@link software.xdev.dynamicreports.report.constant.StretchType} object. + */ + public void setStretchType(StretchType stretchType) { + this.stretchType = stretchType; + } + + /** {@inheritDoc} */ + @Override + public Boolean getPrintInFirstWholeBand() { + return printInFirstWholeBand; + } + + /** + *

Setter for the field printInFirstWholeBand.

+ * + * @param printInFirstWholeBand a {@link java.lang.Boolean} object. + */ + public void setPrintInFirstWholeBand(Boolean printInFirstWholeBand) { + this.printInFirstWholeBand = printInFirstWholeBand; + } + + /** {@inheritDoc} */ + @Override + public Boolean getPrintWhenDetailOverflows() { + return printWhenDetailOverflows; + } + + /** + *

Setter for the field printWhenDetailOverflows.

+ * + * @param printWhenDetailOverflows a {@link java.lang.Boolean} object. + */ + public void setPrintWhenDetailOverflows(Boolean printWhenDetailOverflows) { + this.printWhenDetailOverflows = printWhenDetailOverflows; + } + + /** {@inheritDoc} */ + @Override + public DRIGroup getPrintWhenGroupChanges() { + return printWhenGroupChanges; + } + + /** + *

Setter for the field printWhenGroupChanges.

+ * + * @param printWhenGroupChanges a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + */ + public void setPrintWhenGroupChanges(DRIGroup printWhenGroupChanges) { + this.printWhenGroupChanges = printWhenGroupChanges; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DREllipse.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DREllipse.java new file mode 100644 index 0000000..bc40ee0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DREllipse.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.base.style.DRPen; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIEllipse; + +/** + *

DREllipse class.

+ * + * @author Ricardo Mariaca + * + */ +public class DREllipse extends DRDimensionComponent implements DRIEllipse { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRPen pen; + + /** {@inheritDoc} */ + @Override + public DRPen getPen() { + return pen; + } + + /** + *

Setter for the field pen.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.base.style.DRPen} object. + */ + public void setPen(DRPen pen) { + this.pen = pen; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRFiller.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRFiller.java new file mode 100644 index 0000000..3582410 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRFiller.java @@ -0,0 +1,31 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIFiller; + +/** + *

DRFiller class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRFiller extends DRDimensionComponent implements DRIFiller { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRFormatField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRFormatField.java new file mode 100644 index 0000000..e4db3de --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRFormatField.java @@ -0,0 +1,68 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.definition.component.DRIFormatField; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract DRFormatField class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class DRFormatField extends DRHyperLinkComponent implements DRIFormatField { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression formatExpression; + private HorizontalTextAlignment horizontalTextAlignment; + + /** {@inheritDoc} */ + @Override + public DRIExpression getFormatExpression() { + return formatExpression; + } + + /** + *

Setter for the field formatExpression.

+ * + * @param formatExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setFormatExpression(DRIExpression formatExpression) { + Validate.notNull(formatExpression, "formatExpression must not be null"); + this.formatExpression = formatExpression; + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return horizontalTextAlignment; + } + + /** + *

Setter for the field horizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public void setHorizontalTextAlignment(HorizontalTextAlignment horizontalTextAlignment) { + this.horizontalTextAlignment = horizontalTextAlignment; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRGenericElement.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRGenericElement.java new file mode 100644 index 0000000..075fdd8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRGenericElement.java @@ -0,0 +1,117 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIGenericElement; +import software.xdev.dynamicreports.report.definition.expression.DRIParameterExpression; +import org.apache.commons.lang3.Validate; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRGenericElement class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRGenericElement extends DRDimensionComponent implements DRIGenericElement { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String genericElementNamespace; + private String genericElementName; + private List parameterExpressions; + + /** + *

Constructor for DRGenericElement.

+ * + * @param namespace a {@link java.lang.String} object. + * @param namespace a {@link java.lang.String} object. + * @param name a {@link java.lang.String} object. + */ + public DRGenericElement(String namespace, String name) { + Validate.notEmpty(namespace, "namespace must not be empty"); + Validate.notEmpty(name, "name must not be empty"); + genericElementNamespace = namespace; + genericElementName = name; + } + + /** {@inheritDoc} */ + @Override + protected void init() { + super.init(); + parameterExpressions = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public String getGenericElementNamespace() { + return genericElementNamespace; + } + + /** + *

Setter for the field genericElementNamespace.

+ * + * @param genericElementNamespace a {@link java.lang.String} object. + */ + public void setGenericElementNamespace(String genericElementNamespace) { + this.genericElementNamespace = genericElementNamespace; + } + + /** {@inheritDoc} */ + @Override + public String getGenericElementName() { + return genericElementName; + } + + /** + *

Setter for the field genericElementName.

+ * + * @param genericElementName a {@link java.lang.String} object. + */ + public void setGenericElementName(String genericElementName) { + this.genericElementName = genericElementName; + } + + /** {@inheritDoc} */ + @Override + public List getParameterExpressions() { + return parameterExpressions; + } + + /** + *

Setter for the field parameterExpressions.

+ * + * @param parameterExpressions a {@link java.util.List} object. + */ + public void setParameterExpressions(List parameterExpressions) { + this.parameterExpressions = parameterExpressions; + } + + /** + *

addParameterExpression.

+ * + * @param parameterExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIParameterExpression} object. + */ + public void addParameterExpression(DRIParameterExpression parameterExpression) { + Validate.notNull(parameterExpression, "parameterExpression must not be null"); + this.parameterExpressions.add(parameterExpression); + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRHyperLinkComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRHyperLinkComponent.java new file mode 100644 index 0000000..a39ca39 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRHyperLinkComponent.java @@ -0,0 +1,82 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.base.DRHyperLink; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIHyperLinkComponent; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

Abstract DRHyperLinkComponent class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class DRHyperLinkComponent extends DRDimensionComponent implements DRIHyperLinkComponent { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression anchorNameExpression; + private Integer bookmarkLevel; + private DRHyperLink hyperLink; + + /** {@inheritDoc} */ + @Override + public DRIExpression getAnchorNameExpression() { + return anchorNameExpression; + } + + /** + *

Setter for the field anchorNameExpression.

+ * + * @param anchorNameExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setAnchorNameExpression(DRIExpression anchorNameExpression) { + this.anchorNameExpression = anchorNameExpression; + } + + /** {@inheritDoc} */ + @Override + public Integer getBookmarkLevel() { + return bookmarkLevel; + } + + /** + *

Setter for the field bookmarkLevel.

+ * + * @param bookmarkLevel a {@link java.lang.Integer} object. + */ + public void setBookmarkLevel(Integer bookmarkLevel) { + this.bookmarkLevel = bookmarkLevel; + } + + /** {@inheritDoc} */ + @Override + public DRHyperLink getHyperLink() { + return hyperLink; + } + + /** + *

Setter for the field hyperLink.

+ * + * @param hyperLink a {@link software.xdev.dynamicreports.report.base.DRHyperLink} object. + */ + public void setHyperLink(DRHyperLink hyperLink) { + this.hyperLink = hyperLink; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRImage.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRImage.java new file mode 100644 index 0000000..837a0b4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRImage.java @@ -0,0 +1,117 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.definition.component.DRIImage; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + *

DRImage class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRImage extends DRHyperLinkComponent implements DRIImage { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private ImageScale imageScale; + private DRIExpression imageExpression; + private Boolean usingCache; + private Boolean lazy; + private HorizontalImageAlignment horizontalImageAlignment; + + /** {@inheritDoc} */ + @Override + public DRIExpression getImageExpression() { + return imageExpression; + } + + /** + *

Setter for the field imageExpression.

+ * + * @param imageExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setImageExpression(DRIExpression imageExpression) { + Validate.notNull(imageExpression, "imageExpression must not be null"); + this.imageExpression = imageExpression; + } + + /** {@inheritDoc} */ + @Override + public ImageScale getImageScale() { + return imageScale; + } + + /** + *

Setter for the field imageScale.

+ * + * @param imageScale a {@link software.xdev.dynamicreports.report.constant.ImageScale} object. + */ + public void setImageScale(ImageScale imageScale) { + this.imageScale = imageScale; + } + + /** {@inheritDoc} */ + @Override + public Boolean getUsingCache() { + return usingCache; + } + + /** + *

Setter for the field usingCache.

+ * + * @param usingCache a {@link java.lang.Boolean} object. + */ + public void setUsingCache(Boolean usingCache) { + this.usingCache = usingCache; + } + + /** {@inheritDoc} */ + @Override + public Boolean getLazy() { + return lazy; + } + + /** + *

Setter for the field lazy.

+ * + * @param lazy a {@link java.lang.Boolean} object. + */ + public void setLazy(Boolean lazy) { + this.lazy = lazy; + } + + /** {@inheritDoc} */ + @Override + public HorizontalImageAlignment getHorizontalImageAlignment() { + return horizontalImageAlignment; + } + + /** + *

Setter for the field horizontalImageAlignment.

+ * + * @param horizontalImageAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public void setHorizontalImageAlignment(HorizontalImageAlignment horizontalImageAlignment) { + this.horizontalImageAlignment = horizontalImageAlignment; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRLine.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRLine.java new file mode 100644 index 0000000..f2d6e4b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRLine.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.base.style.DRPen; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.LineDirection; +import software.xdev.dynamicreports.report.definition.component.DRILine; + +/** + *

DRLine class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRLine extends DRDimensionComponent implements DRILine { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private LineDirection direction; + private DRPen pen; + + /** {@inheritDoc} */ + @Override + public LineDirection getDirection() { + return direction; + } + + /** + *

Setter for the field direction.

+ * + * @param direction a {@link software.xdev.dynamicreports.report.constant.LineDirection} object. + */ + public void setDirection(LineDirection direction) { + this.direction = direction; + } + + /** {@inheritDoc} */ + @Override + public DRPen getPen() { + return pen; + } + + /** + *

Setter for the field pen.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.base.style.DRPen} object. + */ + public void setPen(DRPen pen) { + this.pen = pen; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRList.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRList.java new file mode 100644 index 0000000..451a0c8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRList.java @@ -0,0 +1,152 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import software.xdev.dynamicreports.report.definition.component.DRIList; +import org.apache.commons.lang3.Validate; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRList class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRList extends DRDimensionComponent implements DRIList { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private List listCells; + private ListType type; + private Integer gap; + private DRComponent backgroundComponent; + + /** + *

Constructor for DRList.

+ */ + public DRList() { + this(ListType.HORIZONTAL); + } + + /** + *

Constructor for DRList.

+ * + * @param type a {@link software.xdev.dynamicreports.report.constant.ListType} object. + */ + public DRList(ListType type) { + setType(type); + } + + /** {@inheritDoc} */ + @Override + protected void init() { + super.init(); + this.listCells = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public List getListCells() { + return listCells; + } + + /** + *

addComponent.

+ * + * @param component a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void addComponent(DRComponent component) { + listCells.add(new DRListCell(component)); + } + + /** + *

addCell.

+ * + * @param cell a {@link software.xdev.dynamicreports.report.base.component.DRListCell} object. + */ + public void addCell(DRListCell cell) { + Validate.notNull(cell, "cell must not be null"); + listCells.add(cell); + } + + /** + *

addComponent.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + * @param component a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void addComponent(HorizontalCellComponentAlignment horizontalAlignment, VerticalCellComponentAlignment verticalAlignment, DRComponent component) { + listCells.add(new DRListCell(horizontalAlignment, verticalAlignment, component)); + } + + /** {@inheritDoc} */ + @Override + public ListType getType() { + return type; + } + + /** + *

Setter for the field type.

+ * + * @param type a {@link software.xdev.dynamicreports.report.constant.ListType} object. + */ + public void setType(ListType type) { + Validate.notNull(type, "type must not be null"); + this.type = type; + } + + /** {@inheritDoc} */ + @Override + public Integer getGap() { + return gap; + } + + /** + *

Setter for the field gap.

+ * + * @param gap a {@link java.lang.Integer} object. + */ + public void setGap(Integer gap) { + if (gap != null) { + Validate.isTrue(gap >= 0, "gap must be >= 0"); + } + this.gap = gap; + } + + /** {@inheritDoc} */ + @Override + public DRComponent getBackgroundComponent() { + return backgroundComponent; + } + + /** + *

Setter for the field backgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void setBackgroundComponent(DRComponent backgroundComponent) { + this.backgroundComponent = backgroundComponent; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRListCell.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRListCell.java new file mode 100644 index 0000000..62b3cc9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRListCell.java @@ -0,0 +1,97 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import software.xdev.dynamicreports.report.definition.component.DRIListCell; +import org.apache.commons.lang3.Validate; + +/** + *

DRListCell class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRListCell implements DRIListCell { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private HorizontalCellComponentAlignment horizontalAlignment; + private VerticalCellComponentAlignment verticalAlignment; + private DRComponent component; + + /** + *

Constructor for DRListCell.

+ * + * @param component a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public DRListCell(DRComponent component) { + Validate.notNull(component, "component must not be null"); + this.component = component; + } + + /** + *

Constructor for DRListCell.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + * @param component a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public DRListCell(HorizontalCellComponentAlignment horizontalAlignment, VerticalCellComponentAlignment verticalAlignment, DRComponent component) { + this(component); + this.horizontalAlignment = horizontalAlignment; + this.verticalAlignment = verticalAlignment; + } + + /** {@inheritDoc} */ + @Override + public HorizontalCellComponentAlignment getHorizontalAlignment() { + return horizontalAlignment; + } + + /** + *

Setter for the field horizontalAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + */ + public void setHorizontalAlignment(HorizontalCellComponentAlignment horizontalAlignment) { + this.horizontalAlignment = horizontalAlignment; + } + + /** {@inheritDoc} */ + @Override + public VerticalCellComponentAlignment getVerticalAlignment() { + return verticalAlignment; + } + + /** + *

Setter for the field verticalAlignment.

+ * + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + */ + public void setVerticalAlignment(VerticalCellComponentAlignment verticalAlignment) { + this.verticalAlignment = verticalAlignment; + } + + /** {@inheritDoc} */ + @Override + public DRComponent getComponent() { + return component; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRMap.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRMap.java new file mode 100644 index 0000000..8af41c8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRMap.java @@ -0,0 +1,81 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIMap; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRMap class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRMap extends DRDimensionComponent implements DRIMap { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + public DRIExpression latitudeExpression; + public DRIExpression longitudeExpression; + public DRIExpression zoomExpression; + + /** {@inheritDoc} */ + @Override + public DRIExpression getLatitudeExpression() { + return latitudeExpression; + } + + /** + *

Setter for the field latitudeExpression.

+ * + * @param latitudeExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setLatitudeExpression(DRIExpression latitudeExpression) { + this.latitudeExpression = latitudeExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getLongitudeExpression() { + return longitudeExpression; + } + + /** + *

Setter for the field longitudeExpression.

+ * + * @param longitudeExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setLongitudeExpression(DRIExpression longitudeExpression) { + this.longitudeExpression = longitudeExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getZoomExpression() { + return zoomExpression; + } + + /** + *

Setter for the field zoomExpression.

+ * + * @param zoomExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setZoomExpression(DRIExpression zoomExpression) { + this.zoomExpression = zoomExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRMultiPageList.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRMultiPageList.java new file mode 100644 index 0000000..f6badcb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRMultiPageList.java @@ -0,0 +1,86 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.component.DRIMultiPageList; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRMultiPageList class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRMultiPageList extends DRDimensionComponent implements DRIMultiPageList { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private List components; + private SplitType splitType; + + /** + *

Constructor for DRMultiPageList.

+ */ + public DRMultiPageList() { + components = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public List getComponents() { + return components; + } + + /** + *

Setter for the field components.

+ * + * @param components a {@link java.util.List} object. + */ + public void setComponents(List components) { + this.components = components; + } + + /** + *

addComponent.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public void addComponent(DRIComponent component) { + components.add(component); + } + + /** {@inheritDoc} */ + @Override + public SplitType getSplitType() { + return splitType; + } + + /** + *

Setter for the field splitType.

+ * + * @param splitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public void setSplitType(SplitType splitType) { + this.splitType = splitType; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRPageNumber.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRPageNumber.java new file mode 100644 index 0000000..57fc7bc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRPageNumber.java @@ -0,0 +1,32 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIPageNumber; + +/** + *

DRPageNumber class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRPageNumber extends DRFormatField implements DRIPageNumber { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRPageXofY.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRPageXofY.java new file mode 100644 index 0000000..36a587b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRPageXofY.java @@ -0,0 +1,98 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIPageXofY; + +/** + *

DRPageXofY class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRPageXofY extends DRFormatField implements DRIPageXofY { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer pageXWidth; + private ComponentDimensionType pageXWidthType; + private Integer pageYWidth; + private ComponentDimensionType pageYWidthType; + + /** {@inheritDoc} */ + @Override + public Integer getPageXWidth() { + return pageXWidth; + } + + /** + *

Setter for the field pageXWidth.

+ * + * @param pageXWidth a {@link java.lang.Integer} object. + */ + public void setPageXWidth(Integer pageXWidth) { + this.pageXWidth = pageXWidth; + } + + /** {@inheritDoc} */ + @Override + public ComponentDimensionType getPageXWidthType() { + return pageXWidthType; + } + + /** + *

Setter for the field pageXWidthType.

+ * + * @param pageXWidthType a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public void setPageXWidthType(ComponentDimensionType pageXWidthType) { + this.pageXWidthType = pageXWidthType; + } + + /** {@inheritDoc} */ + @Override + public Integer getPageYWidth() { + return pageYWidth; + } + + /** + *

Setter for the field pageYWidth.

+ * + * @param pageYWidth a {@link java.lang.Integer} object. + */ + public void setPageYWidth(Integer pageYWidth) { + this.pageYWidth = pageYWidth; + } + + /** {@inheritDoc} */ + @Override + public ComponentDimensionType getPageYWidthType() { + return pageYWidthType; + } + + /** + *

Setter for the field pageYWidthType.

+ * + * @param pageYWidthType a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public void setPageYWidthType(ComponentDimensionType pageYWidthType) { + this.pageYWidthType = pageYWidthType; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRRectangle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRRectangle.java new file mode 100644 index 0000000..328ab2a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRRectangle.java @@ -0,0 +1,65 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.base.style.DRPen; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIRectangle; + +/** + *

DRRectangle class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRRectangle extends DRDimensionComponent implements DRIRectangle { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer radius; + private DRPen pen; + + /** {@inheritDoc} */ + @Override + public Integer getRadius() { + return radius; + } + + /** + *

Setter for the field radius.

+ * + * @param radius a {@link java.lang.Integer} object. + */ + public void setRadius(Integer radius) { + this.radius = radius; + } + + /** {@inheritDoc} */ + @Override + public DRPen getPen() { + return pen; + } + + /** + *

Setter for the field pen.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.base.style.DRPen} object. + */ + public void setPen(DRPen pen) { + this.pen = pen; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRSubreport.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRSubreport.java new file mode 100644 index 0000000..60262e3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRSubreport.java @@ -0,0 +1,118 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRISubreport; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +import java.sql.Connection; +import java.util.Map; + +/** + *

DRSubreport class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRSubreport extends DRDimensionComponent implements DRISubreport { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression reportExpression; + private DRIExpression> parametersExpression; + private DRIExpression connectionExpression; + private DRIExpression dataSourceExpression; + private Boolean runToBottom; + + /** {@inheritDoc} */ + @Override + public DRIExpression getReportExpression() { + return reportExpression; + } + + /** + *

Setter for the field reportExpression.

+ * + * @param reportExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setReportExpression(DRIExpression reportExpression) { + Validate.notNull(reportExpression, "reportExpression must not be null"); + this.reportExpression = reportExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression> getParametersExpression() { + return parametersExpression; + } + + /** + *

Setter for the field parametersExpression.

+ * + * @param parametersExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setParametersExpression(DRIExpression> parametersExpression) { + this.parametersExpression = parametersExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getConnectionExpression() { + return connectionExpression; + } + + /** + *

Setter for the field connectionExpression.

+ * + * @param connectionExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setConnectionExpression(DRIExpression connectionExpression) { + this.connectionExpression = connectionExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getDataSourceExpression() { + return dataSourceExpression; + } + + /** + *

Setter for the field dataSourceExpression.

+ * + * @param dataSourceExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setDataSourceExpression(DRIExpression dataSourceExpression) { + this.dataSourceExpression = dataSourceExpression; + } + + /** {@inheritDoc} */ + @Override + public Boolean getRunToBottom() { + return runToBottom; + } + + /** + *

Setter for the field runToBottom.

+ * + * @param runToBottom a {@link java.lang.Boolean} object. + */ + public void setRunToBottom(Boolean runToBottom) { + this.runToBottom = runToBottom; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRTextField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRTextField.java new file mode 100644 index 0000000..dd3139c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRTextField.java @@ -0,0 +1,285 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.base.DRGroup; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.component.DRITextField; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; + +/** + *

DRTextField class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class DRTextField extends DRHyperLinkComponent implements DRITextField { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression valueExpression; + private String pattern; + private DRIExpression patternExpression; + private HorizontalTextAlignment horizontalTextAlignment; + private DRIValueFormatter valueFormatter; + private DRIDataType dataType; + private Integer columns; + private Integer rows; + private Evaluation evaluationTime; + private DRGroup evaluationGroup; + private Markup markup; + private Boolean stretchWithOverflow; + private Boolean printRepeatedValues; + private TextAdjust textAdjust; + + /** {@inheritDoc} */ + @Override + public DRIExpression getValueExpression() { + return valueExpression; + } + + /** + *

Setter for the field valueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setValueExpression(final DRIExpression valueExpression) { + Validate.notNull(valueExpression, "valueExpression must not be null"); + this.valueExpression = valueExpression; + } + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return pattern; + } + + /** + *

Setter for the field pattern.

+ * + * @param pattern a {@link java.lang.String} object. + */ + public void setPattern(final String pattern) { + this.pattern = pattern; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getPatternExpression() { + return patternExpression; + } + + /** + *

Setter for the field patternExpression.

+ * + * @param patternExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setPatternExpression(final DRIExpression patternExpression) { + this.patternExpression = patternExpression; + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return horizontalTextAlignment; + } + + /** + *

Setter for the field horizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public void setHorizontalTextAlignment(final HorizontalTextAlignment horizontalTextAlignment) { + this.horizontalTextAlignment = horizontalTextAlignment; + } + + /** {@inheritDoc} */ + @Override + public DRIValueFormatter getValueFormatter() { + return valueFormatter; + } + + /** + *

Setter for the field valueFormatter.

+ * + * @param valueFormatter a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + */ + public void setValueFormatter(final DRIValueFormatter valueFormatter) { + this.valueFormatter = valueFormatter; + } + + /** {@inheritDoc} */ + @Override + public DRIDataType getDataType() { + return dataType; + } + + /** + *

Setter for the field dataType.

+ * + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + */ + public void setDataType(final DRIDataType dataType) { + this.dataType = dataType; + } + + /** + * {@inheritDoc} + *

+ * Returns the number of columns. + */ + @Override + public Integer getColumns() { + return columns; + } + + /** + * This method is used to define the width of a column. The width is set to the columns multiplied by width of the character m for the font used + * + * @param columns the number of columns >= 0 + * @throws java.lang.IllegalArgumentException if columns is < 0 + */ + public void setColumns(final Integer columns) { + if (columns != null) { + Validate.isTrue(columns >= 0, "columns must be >= 0"); + } + this.columns = columns; + } + + /** + * {@inheritDoc} + *

+ * Returns the number of rows. + */ + @Override + public Integer getRows() { + return rows; + } + + /** + * This method is used to define the height of a column. The height is set to the rows multiplied by height of the font + * + * @param rows the number of rows >= 0 + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public void setRows(final Integer rows) { + if (rows != null) { + Validate.isTrue(rows >= 0, "rows must be >= 0"); + } + this.rows = rows; + } + + /** {@inheritDoc} */ + @Override + public Evaluation getEvaluationTime() { + return evaluationTime; + } + + /** + *

Setter for the field evaluationTime.

+ * + * @param evaluationTime a {@link software.xdev.dynamicreports.report.constant.Evaluation} object. + */ + public void setEvaluationTime(final Evaluation evaluationTime) { + this.evaluationTime = evaluationTime; + } + + /** {@inheritDoc} */ + @Override + public DRGroup getEvaluationGroup() { + return evaluationGroup; + } + + /** + *

Setter for the field evaluationGroup.

+ * + * @param evaluationGroup a {@link software.xdev.dynamicreports.report.base.DRGroup} object. + */ + public void setEvaluationGroup(final DRGroup evaluationGroup) { + this.evaluationGroup = evaluationGroup; + } + + /** {@inheritDoc} */ + @Override + public Markup getMarkup() { + return markup; + } + + /** + *

Setter for the field markup.

+ * + * @param markup a {@link software.xdev.dynamicreports.report.constant.Markup} object. + */ + public void setMarkup(final Markup markup) { + this.markup = markup; + } + + /** {@inheritDoc} */ + @Override + public Boolean getStretchWithOverflow() { + return stretchWithOverflow; + } + + /** + *

Setter for the field stretchWithOverflow.

+ * + * @param stretchWithOverflow a {@link java.lang.Boolean} object. + * @deprecated replaced {@link #setTextAdjust(TextAdjust)} + */ + @Deprecated + public void setStretchWithOverflow(final Boolean stretchWithOverflow) { + this.stretchWithOverflow = stretchWithOverflow; + } + + /** {@inheritDoc} */ + @Override + public Boolean getPrintRepeatedValues() { + return printRepeatedValues; + } + + /** + *

Setter for the field printRepeatedValues.

+ * + * @param printRepeatedValues a {@link java.lang.Boolean} object. + */ + public void setPrintRepeatedValues(final Boolean printRepeatedValues) { + this.printRepeatedValues = printRepeatedValues; + } + + /** {@inheritDoc} */ + @Override + public TextAdjust getTextAdjust() { + return this.textAdjust; + } + + /** + *

Setter for the field textAdjust.

+ * + * @param setTextAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + public void setTextAdjust(final TextAdjust textAdjust) { + this.textAdjust = textAdjust; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRTotalPages.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRTotalPages.java new file mode 100644 index 0000000..6b49a81 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRTotalPages.java @@ -0,0 +1,32 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRITotalPages; + +/** + *

DRTotalPages class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRTotalPages extends DRFormatField implements DRITotalPages { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRXyList.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRXyList.java new file mode 100644 index 0000000..eb3f3fd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRXyList.java @@ -0,0 +1,72 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIXyList; +import org.apache.commons.lang3.Validate; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRXyList class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRXyList extends DRDimensionComponent implements DRIXyList { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private List xyListCells; + + /** {@inheritDoc} */ + @Override + protected void init() { + super.init(); + this.xyListCells = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public List getXyListCells() { + return xyListCells; + } + + /** + *

addCell.

+ * + * @param cell a {@link software.xdev.dynamicreports.report.base.component.DRXyListCell} object. + */ + public void addCell(DRXyListCell cell) { + Validate.notNull(cell, "cell must not be null"); + xyListCells.add(cell); + } + + /** + *

addComponent.

+ * + * @param x a {@link java.lang.Integer} object. + * @param y a {@link java.lang.Integer} object. + * @param component a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void addComponent(Integer x, Integer y, DRComponent component) { + xyListCells.add(new DRXyListCell(x, y, component)); + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRXyListCell.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRXyListCell.java new file mode 100644 index 0000000..a919a89 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/component/DRXyListCell.java @@ -0,0 +1,88 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.component; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIXyListCell; +import org.apache.commons.lang3.Validate; + +/** + *

DRXyListCell class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRXyListCell implements DRIXyListCell { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer x; + private Integer y; + private DRComponent component; + + /** + *

Constructor for DRXyListCell.

+ * + * @param x a {@link java.lang.Integer} object. + * @param y a {@link java.lang.Integer} object. + * @param component a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public DRXyListCell(Integer x, Integer y, DRComponent component) { + Validate.notNull(x, "x must not be null"); + Validate.notNull(y, "y must not be null"); + Validate.notNull(component, "component must not be null"); + this.x = x; + this.y = y; + this.component = component; + } + + /** {@inheritDoc} */ + @Override + public Integer getX() { + return x; + } + + /** + *

Setter for the field x.

+ * + * @param x a {@link java.lang.Integer} object. + */ + public void setX(Integer x) { + this.x = x; + } + + /** {@inheritDoc} */ + @Override + public Integer getY() { + return y; + } + + /** + *

Setter for the field y.

+ * + * @param y a {@link java.lang.Integer} object. + */ + public void setY(Integer y) { + this.y = y; + } + + /** {@inheritDoc} */ + @Override + public DRComponent getComponent() { + return component; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstab.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstab.java new file mode 100644 index 0000000..cd963a0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstab.java @@ -0,0 +1,403 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.crosstab; + +import software.xdev.dynamicreports.report.base.component.DRDimensionComponent; +import software.xdev.dynamicreports.report.base.style.DRSimpleStyle; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstab; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabMeasure; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabVariable; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import org.apache.commons.lang3.Validate; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRCrosstab class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRCrosstab extends DRDimensionComponent implements DRICrosstab { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRCrosstabDataset dataset; + private Boolean repeatColumnHeaders; + private Boolean repeatRowHeaders; + private Integer columnBreakOffset; + private Boolean ignoreWidth; + private RunDirection runDirection; + private Integer cellWidth; + private Integer cellHeight; + private Boolean highlightOddRows; + private DRSimpleStyle oddRowStyle; + private Boolean highlightEvenRows; + private DRSimpleStyle evenRowStyle; + private DRIReportStyle groupStyle; + private DRIReportStyle groupTotalStyle; + private DRIReportStyle grandTotalStyle; + private DRIReportStyle cellStyle; + private DRIReportStyle measureTitleStyle; + private DRCrosstabCellContent whenNoDataCell; + private DRCrosstabCellContent headerCell; + private List> columnGroups; + private List> rowGroups; + private List> variables; + private List> measures; + + /** {@inheritDoc} */ + @Override + protected void init() { + super.init(); + dataset = new DRCrosstabDataset(); + columnGroups = new ArrayList>(); + rowGroups = new ArrayList>(); + variables = new ArrayList>(); + measures = new ArrayList>(); + + whenNoDataCell = new DRCrosstabCellContent(); + headerCell = new DRCrosstabCellContent(); + } + + /** {@inheritDoc} */ + @Override + public DRCrosstabDataset getDataset() { + return dataset; + } + + /** {@inheritDoc} */ + @Override + public Boolean isRepeatColumnHeaders() { + return repeatColumnHeaders; + } + + /** + *

Setter for the field repeatColumnHeaders.

+ * + * @param repeatColumnHeaders a {@link java.lang.Boolean} object. + */ + public void setRepeatColumnHeaders(Boolean repeatColumnHeaders) { + this.repeatColumnHeaders = repeatColumnHeaders; + } + + /** {@inheritDoc} */ + @Override + public Boolean isRepeatRowHeaders() { + return repeatRowHeaders; + } + + /** + *

Setter for the field repeatRowHeaders.

+ * + * @param repeatRowHeaders a {@link java.lang.Boolean} object. + */ + public void setRepeatRowHeaders(Boolean repeatRowHeaders) { + this.repeatRowHeaders = repeatRowHeaders; + } + + /** {@inheritDoc} */ + @Override + public Integer getColumnBreakOffset() { + return columnBreakOffset; + } + + /** + *

Setter for the field columnBreakOffset.

+ * + * @param columnBreakOffset a {@link java.lang.Integer} object. + */ + public void setColumnBreakOffset(Integer columnBreakOffset) { + this.columnBreakOffset = columnBreakOffset; + } + + /** {@inheritDoc} */ + @Override + public Boolean getIgnoreWidth() { + return ignoreWidth; + } + + /** + *

Setter for the field ignoreWidth.

+ * + * @param ignoreWidth a {@link java.lang.Boolean} object. + */ + public void setIgnoreWidth(Boolean ignoreWidth) { + this.ignoreWidth = ignoreWidth; + } + + /** {@inheritDoc} */ + @Override + public RunDirection getRunDirection() { + return runDirection; + } + + /** + *

Setter for the field runDirection.

+ * + * @param runDirection a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public void setRunDirection(RunDirection runDirection) { + this.runDirection = runDirection; + } + + /** {@inheritDoc} */ + @Override + public DRCrosstabCellContent getWhenNoDataCell() { + return whenNoDataCell; + } + + /** {@inheritDoc} */ + @Override + public DRCrosstabCellContent getHeaderCell() { + return headerCell; + } + + /** {@inheritDoc} */ + @Override + public List> getColumnGroups() { + return columnGroups; + } + + /** {@inheritDoc} */ + @Override + public Integer getCellWidth() { + return cellWidth; + } + + /** + *

Setter for the field cellWidth.

+ * + * @param cellWidth a {@link java.lang.Integer} object. + */ + public void setCellWidth(Integer cellWidth) { + this.cellWidth = cellWidth; + } + + /** {@inheritDoc} */ + @Override + public Integer getCellHeight() { + return cellHeight; + } + + /** + *

Setter for the field cellHeight.

+ * + * @param cellHeight a {@link java.lang.Integer} object. + */ + public void setCellHeight(Integer cellHeight) { + this.cellHeight = cellHeight; + } + + /** {@inheritDoc} */ + @Override + public Boolean getHighlightOddRows() { + return highlightOddRows; + } + + /** + *

Setter for the field highlightOddRows.

+ * + * @param highlightOddRows a {@link java.lang.Boolean} object. + */ + public void setHighlightOddRows(Boolean highlightOddRows) { + this.highlightOddRows = highlightOddRows; + } + + /** {@inheritDoc} */ + @Override + public DRSimpleStyle getOddRowStyle() { + return oddRowStyle; + } + + /** + *

Setter for the field oddRowStyle.

+ * + * @param oddRowStyle a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public void setOddRowStyle(DRSimpleStyle oddRowStyle) { + this.oddRowStyle = oddRowStyle; + } + + /** {@inheritDoc} */ + @Override + public Boolean getHighlightEvenRows() { + return highlightEvenRows; + } + + /** + *

Setter for the field highlightEvenRows.

+ * + * @param highlightEvenRows a {@link java.lang.Boolean} object. + */ + public void setHighlightEvenRows(Boolean highlightEvenRows) { + this.highlightEvenRows = highlightEvenRows; + } + + /** {@inheritDoc} */ + @Override + public DRSimpleStyle getEvenRowStyle() { + return evenRowStyle; + } + + /** + *

Setter for the field evenRowStyle.

+ * + * @param evenRowStyle a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public void setEvenRowStyle(DRSimpleStyle evenRowStyle) { + this.evenRowStyle = evenRowStyle; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getGroupStyle() { + return groupStyle; + } + + /** + *

Setter for the field groupStyle.

+ * + * @param groupStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setGroupStyle(DRIReportStyle groupStyle) { + this.groupStyle = groupStyle; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getGroupTotalStyle() { + return groupTotalStyle; + } + + /** + *

Setter for the field groupTotalStyle.

+ * + * @param groupTotalStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setGroupTotalStyle(DRIReportStyle groupTotalStyle) { + this.groupTotalStyle = groupTotalStyle; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getGrandTotalStyle() { + return grandTotalStyle; + } + + /** + *

Setter for the field grandTotalStyle.

+ * + * @param grandTotalStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setGrandTotalStyle(DRIReportStyle grandTotalStyle) { + this.grandTotalStyle = grandTotalStyle; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getCellStyle() { + return cellStyle; + } + + /** + *

Setter for the field cellStyle.

+ * + * @param cellStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setCellStyle(DRIReportStyle cellStyle) { + this.cellStyle = cellStyle; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getMeasureTitleStyle() { + return measureTitleStyle; + } + + /** + *

Setter for the field measureTitleStyle.

+ * + * @param measureTitleStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setMeasureTitleStyle(DRIReportStyle measureTitleStyle) { + this.measureTitleStyle = measureTitleStyle; + } + + /** + *

addColumnGroup.

+ * + * @param columnGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup} object. + */ + public void addColumnGroup(DRICrosstabColumnGroup columnGroup) { + Validate.notNull(columnGroup, "columnGroup must not be null"); + this.columnGroups.add(columnGroup); + } + + /** {@inheritDoc} */ + @Override + public List> getRowGroups() { + return rowGroups; + } + + /** + *

addRowGroup.

+ * + * @param rowGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup} object. + */ + public void addRowGroup(DRICrosstabRowGroup rowGroup) { + Validate.notNull(rowGroup, "rowGroup must not be null"); + this.rowGroups.add(rowGroup); + } + + /** {@inheritDoc} */ + @Override + public List> getVariables() { + return variables; + } + + /** + *

addVariable.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabVariable} object. + */ + public void addVariable(DRICrosstabVariable variable) { + Validate.notNull(variable, "variable must not be null"); + this.variables.add(variable); + } + + /** {@inheritDoc} */ + @Override + public List> getMeasures() { + return measures; + } + + /** + *

addMeasure.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabMeasure} object. + */ + public void addMeasure(DRICrosstabMeasure measure) { + Validate.notNull(measure, "measure must not be null"); + this.measures.add(measure); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabCellContent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabCellContent.java new file mode 100644 index 0000000..2fe7330 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabCellContent.java @@ -0,0 +1,75 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.crosstab; + +import software.xdev.dynamicreports.report.base.component.DRComponent; +import software.xdev.dynamicreports.report.base.component.DRList; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabCellContent; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +/** + *

DRCrosstabCellContent class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRCrosstabCellContent implements DRICrosstabCellContent { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRList list; + private DRIReportStyle style; + + /** + *

Constructor for DRCrosstabCellContent.

+ */ + public DRCrosstabCellContent() { + this.list = new DRList(ListType.VERTICAL); + } + + /** {@inheritDoc} */ + @Override + public DRList getList() { + return list; + } + + /** + *

addComponent.

+ * + * @param component a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + public void addComponent(DRComponent component) { + list.addComponent(component); + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getStyle() { + return style; + } + + /** + *

Setter for the field style.

+ * + * @param style a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setStyle(DRIReportStyle style) { + this.style = style; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabCellStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabCellStyle.java new file mode 100644 index 0000000..92eee68 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabCellStyle.java @@ -0,0 +1,105 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.crosstab; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabCellStyle; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +/** + *

DRCrosstabCellStyle class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRCrosstabCellStyle implements DRICrosstabCellStyle { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRICrosstabRowGroup rowGroup; + private DRICrosstabColumnGroup columnGroup; + private DRIReportStyle style; + + /** + *

Constructor for DRCrosstabCellStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRCrosstabCellStyle(DRIReportStyle style) { + this(style, null, null); + } + + /** + *

Constructor for DRCrosstabCellStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + * @param rowGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup} object. + * @param columnGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup} object. + */ + public DRCrosstabCellStyle(DRIReportStyle style, DRICrosstabRowGroup rowGroup, DRICrosstabColumnGroup columnGroup) { + this.style = style; + this.rowGroup = rowGroup; + this.columnGroup = columnGroup; + } + + /** {@inheritDoc} */ + @Override + public DRICrosstabRowGroup getRowGroup() { + return rowGroup; + } + + /** + *

Setter for the field rowGroup.

+ * + * @param rowGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup} object. + */ + public void setRowGroup(DRICrosstabRowGroup rowGroup) { + this.rowGroup = rowGroup; + } + + /** {@inheritDoc} */ + @Override + public DRICrosstabColumnGroup getColumnGroup() { + return columnGroup; + } + + /** + *

Setter for the field columnGroup.

+ * + * @param columnGroup a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup} object. + */ + public void setColumnGroup(DRICrosstabColumnGroup columnGroup) { + this.columnGroup = columnGroup; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getStyle() { + return style; + } + + /** + *

Setter for the field style.

+ * + * @param style a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setStyle(DRIReportStyle style) { + this.style = style; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabColumnGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabColumnGroup.java new file mode 100644 index 0000000..020b724 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabColumnGroup.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.crosstab; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup; + +/** + *

DRCrosstabColumnGroup class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRCrosstabColumnGroup extends DRCrosstabGroup implements DRICrosstabColumnGroup { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer headerHeight; + private Integer totalHeaderWidth; + + /** {@inheritDoc} */ + @Override + public Integer getHeaderHeight() { + return headerHeight; + } + + /** + *

Setter for the field headerHeight.

+ * + * @param headerHeight a {@link java.lang.Integer} object. + */ + public void setHeaderHeight(Integer headerHeight) { + this.headerHeight = headerHeight; + } + + /** {@inheritDoc} */ + @Override + public Integer getTotalHeaderWidth() { + return totalHeaderWidth; + } + + /** + *

Setter for the field totalHeaderWidth.

+ * + * @param totalHeaderWidth a {@link java.lang.Integer} object. + */ + public void setTotalHeaderWidth(Integer totalHeaderWidth) { + this.totalHeaderWidth = totalHeaderWidth; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabDataset.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabDataset.java new file mode 100644 index 0000000..2532e95 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabDataset.java @@ -0,0 +1,65 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.crosstab; + +import software.xdev.dynamicreports.report.base.DRDataset; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabDataset; + +/** + *

DRCrosstabDataset class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRCrosstabDataset implements DRICrosstabDataset { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRDataset subDataset; + private Boolean dataPreSorted; + + /** {@inheritDoc} */ + @Override + public DRDataset getSubDataset() { + return subDataset; + } + + /** + *

Setter for the field subDataset.

+ * + * @param subDataset a {@link software.xdev.dynamicreports.report.base.DRDataset} object. + */ + public void setSubDataset(DRDataset subDataset) { + this.subDataset = subDataset; + } + + /** {@inheritDoc} */ + @Override + public Boolean getDataPreSorted() { + return dataPreSorted; + } + + /** + *

Setter for the field dataPreSorted.

+ * + * @param dataPreSorted a {@link java.lang.Boolean} object. + */ + public void setDataPreSorted(Boolean dataPreSorted) { + this.dataPreSorted = dataPreSorted; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabGroup.java new file mode 100644 index 0000000..2bff21d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabGroup.java @@ -0,0 +1,416 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.crosstab; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.base.DRHyperLink; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.CrosstabTotalPosition; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.OrderType; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabGroup; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +/** + *

Abstract DRCrosstabGroup class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public abstract class DRCrosstabGroup implements DRICrosstabGroup { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private final String name; + private String headerPattern; + private HorizontalTextAlignment headerHorizontalTextAlignment; + private DRIValueFormatter headerValueFormatter; + private Boolean headerStretchWithOverflow; + private TextAdjust headerTextAdjust; + private DRHyperLink headerHyperLink; + private DRIReportStyle headerStyle; + private List headerPropertyExpressions; + private Boolean showTotal; + private CrosstabTotalPosition totalPosition; + private DRIExpression totalHeaderExpression; + private Boolean totalHeaderStretchWithOverflow; + private TextAdjust totalHeaderTextAdjust; + private DRIReportStyle totalHeaderStyle; + private List totalHeaderPropertyExpressions; + private DRIExpression expression; + private DRIDataType dataType; + private DRIExpression> orderByExpression; + private OrderType orderType; + private DRIExpression> comparatorExpression; + + /** + *

Constructor for DRCrosstabGroup.

+ */ + public DRCrosstabGroup() { + this.name = ReportUtils.generateUniqueName("crosstabGroup"); + headerPropertyExpressions = new ArrayList<>(); + totalHeaderPropertyExpressions = new ArrayList<>(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public String getHeaderPattern() { + return headerPattern; + } + + /** + *

Setter for the field headerPattern.

+ * + * @param headerPattern a {@link java.lang.String} object. + */ + public void setHeaderPattern(final String headerPattern) { + this.headerPattern = headerPattern; + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHeaderHorizontalTextAlignment() { + return headerHorizontalTextAlignment; + } + + /** + *

Setter for the field headerHorizontalTextAlignment.

+ * + * @param headerHorizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public void setHeaderHorizontalTextAlignment(final HorizontalTextAlignment headerHorizontalTextAlignment) { + this.headerHorizontalTextAlignment = headerHorizontalTextAlignment; + } + + /** {@inheritDoc} */ + @Override + public DRIValueFormatter getHeaderValueFormatter() { + return headerValueFormatter; + } + + /** + *

Setter for the field headerValueFormatter.

+ * + * @param headerValueFormatter a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + */ + public void setHeaderValueFormatter(final DRIValueFormatter headerValueFormatter) { + this.headerValueFormatter = headerValueFormatter; + } + + /** {@inheritDoc} */ + @Override + public Boolean getHeaderStretchWithOverflow() { + return headerStretchWithOverflow; + } + + /** + *

Setter for the field headerStretchWithOverflow.

+ * + * @param headerStretchWithOverflow a {@link java.lang.Boolean} object. + * @deprecated replaced by {@link #setHeaderTextAdjust(TextAdjust)} + */ + @Deprecated + public void setHeaderStretchWithOverflow(final Boolean headerStretchWithOverflow) { + this.headerStretchWithOverflow = headerStretchWithOverflow; + } + + /** {@inheritDoc} */ + @Override + public TextAdjust getHeaderTextAdjust() { + return this.headerTextAdjust; + } + + /** + *

Setter for the field setHeaderTextAdjust.

+ * + * @param headerTextAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + public void setHeaderTextAdjust(final TextAdjust headerTextAdjust) { + this.headerTextAdjust = headerTextAdjust; + } + + /** {@inheritDoc} */ + @Override + public DRHyperLink getHeaderHyperLink() { + return headerHyperLink; + } + + /** + *

Setter for the field headerHyperLink.

+ * + * @param headerHyperLink a {@link software.xdev.dynamicreports.report.base.DRHyperLink} object. + */ + public void setHeaderHyperLink(final DRHyperLink headerHyperLink) { + this.headerHyperLink = headerHyperLink; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getHeaderStyle() { + return headerStyle; + } + + /** + *

Setter for the field headerStyle.

+ * + * @param headerStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setHeaderStyle(final DRIReportStyle headerStyle) { + this.headerStyle = headerStyle; + } + + /** {@inheritDoc} */ + @Override + public List getHeaderPropertyExpressions() { + return headerPropertyExpressions; + } + + /** + *

Setter for the field headerPropertyExpressions.

+ * + * @param headerPropertyExpressions a {@link java.util.List} object. + */ + public void setHeaderPropertyExpressions(final List headerPropertyExpressions) { + this.headerPropertyExpressions = headerPropertyExpressions; + } + + /** + *

addHeaderPropertyExpression.

+ * + * @param headerPropertyExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression} object. + */ + public void addHeaderPropertyExpression(final DRIPropertyExpression headerPropertyExpression) { + Validate.notNull(headerPropertyExpression, "headerPropertyExpression must not be null"); + this.headerPropertyExpressions.add(headerPropertyExpression); + } + + /** {@inheritDoc} */ + @Override + public Boolean getShowTotal() { + return showTotal; + } + + /** + *

Setter for the field showTotal.

+ * + * @param showTotal a {@link java.lang.Boolean} object. + */ + public void setShowTotal(final Boolean showTotal) { + this.showTotal = showTotal; + } + + /** {@inheritDoc} */ + @Override + public CrosstabTotalPosition getTotalPosition() { + return totalPosition; + } + + /** + *

Setter for the field totalPosition.

+ * + * @param totalPosition a {@link software.xdev.dynamicreports.report.constant.CrosstabTotalPosition} object. + */ + public void setTotalPosition(final CrosstabTotalPosition totalPosition) { + this.totalPosition = totalPosition; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getTotalHeaderExpression() { + return totalHeaderExpression; + } + + /** + *

Setter for the field totalHeaderExpression.

+ * + * @param totalHeaderExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setTotalHeaderExpression(final DRIExpression totalHeaderExpression) { + this.totalHeaderExpression = totalHeaderExpression; + } + + /** {@inheritDoc} */ + @Override + public Boolean getTotalHeaderStretchWithOverflow() { + return totalHeaderStretchWithOverflow; + } + + /** + *

Setter for the field totalHeaderStretchWithOverflow.

+ * + * @param totalHeaderStretchWithOverflow a {@link java.lang.Boolean} object. + * @deprecated replaced by {@link #setTotalHeaderTextAdjust(TextAdjust)} + */ + @Deprecated + public void setTotalHeaderStretchWithOverflow(final Boolean totalHeaderStretchWithOverflow) { + this.totalHeaderStretchWithOverflow = totalHeaderStretchWithOverflow; + } + + /** {@inheritDoc} */ + @Override + public TextAdjust getTotalHeaderTextAdjust() { + return this.totalHeaderTextAdjust; + } + + /** + *

Setter for the field totalHeaderTextAdjust.

+ * + * @param headerTextAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + public void setTotalHeaderTextAdjust(final TextAdjust headerTextAdjust) { + this.totalHeaderTextAdjust = headerTextAdjust; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getTotalHeaderStyle() { + return totalHeaderStyle; + } + + /** + *

Setter for the field totalHeaderStyle.

+ * + * @param totalHeaderStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setTotalHeaderStyle(final DRIReportStyle totalHeaderStyle) { + this.totalHeaderStyle = totalHeaderStyle; + } + + /** {@inheritDoc} */ + @Override + public List getTotalHeaderPropertyExpressions() { + return totalHeaderPropertyExpressions; + } + + /** + *

Setter for the field totalHeaderPropertyExpressions.

+ * + * @param totalHeaderPropertyExpressions a {@link java.util.List} object. + */ + public void setTotalHeaderPropertyExpressions(final List totalHeaderPropertyExpressions) { + this.totalHeaderPropertyExpressions = totalHeaderPropertyExpressions; + } + + /** + *

addTotalHeaderPropertyExpression.

+ * + * @param totalHeaderPropertyExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression} object. + */ + public void addTotalHeaderPropertyExpression(final DRIPropertyExpression totalHeaderPropertyExpression) { + Validate.notNull(totalHeaderPropertyExpression, "totalHeaderPropertyExpression must not be null"); + this.totalHeaderPropertyExpressions.add(totalHeaderPropertyExpression); + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getExpression() { + return expression; + } + + /** + *

Setter for the field expression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setExpression(final DRIExpression expression) { + Validate.notNull(expression, "expression must not be null"); + this.expression = expression; + } + + /** {@inheritDoc} */ + @Override + public DRIDataType getDataType() { + return dataType; + } + + /** + *

Setter for the field dataType.

+ * + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + */ + public void setDataType(final DRIDataType dataType) { + this.dataType = dataType; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression> getOrderByExpression() { + return orderByExpression; + } + + /** + *

Setter for the field orderByExpression.

+ * + * @param orderByExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setOrderByExpression(final DRIExpression> orderByExpression) { + this.orderByExpression = orderByExpression; + } + + /** {@inheritDoc} */ + @Override + public OrderType getOrderType() { + return orderType; + } + + /** + *

Setter for the field orderType.

+ * + * @param orderType a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + */ + public void setOrderType(final OrderType orderType) { + this.orderType = orderType; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression> getComparatorExpression() { + return comparatorExpression; + } + + /** + *

Setter for the field comparatorExpression.

+ * + * @param comparatorExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setComparatorExpression(final DRIExpression> comparatorExpression) { + this.comparatorExpression = comparatorExpression; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return getExpression().getValueClass(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabMeasure.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabMeasure.java new file mode 100644 index 0000000..be4a854 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabMeasure.java @@ -0,0 +1,262 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.crosstab; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.base.DRHyperLink; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabCellStyle; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabMeasure; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +/** + *

DRCrosstabMeasure class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class DRCrosstabMeasure implements DRICrosstabMeasure { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private final String name; + private final DRIExpression expression; + private DRIDataType dataType; + private String pattern; + private HorizontalTextAlignment horizontalTextAlignment; + private DRIValueFormatter valueFormatter; + private Boolean stretchWithOverflow; + private TextAdjust textAdjust; + private DRHyperLink hyperLink; + private List propertyExpressions; + private List styles; + private DRIExpression titleExpression; + private DRIReportStyle titleStyle; + + /** + *

Constructor for DRCrosstabMeasure.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRCrosstabMeasure(final DRIExpression expression) { + Validate.notNull(expression, "expression must not be null"); + this.expression = expression; + this.name = ReportUtils.generateUniqueName("crosstabMeasure"); + this.styles = new ArrayList<>(); + propertyExpressions = new ArrayList<>(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getExpression() { + return expression; + } + + /** {@inheritDoc} */ + @Override + public DRIDataType getDataType() { + return dataType; + } + + /** + *

Setter for the field dataType.

+ * + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + */ + public void setDataType(final DRIDataType dataType) { + this.dataType = dataType; + } + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return pattern; + } + + /** + *

Setter for the field pattern.

+ * + * @param pattern a {@link java.lang.String} object. + */ + public void setPattern(final String pattern) { + this.pattern = pattern; + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return horizontalTextAlignment; + } + + /** + *

Setter for the field horizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public void setHorizontalTextAlignment(final HorizontalTextAlignment horizontalTextAlignment) { + this.horizontalTextAlignment = horizontalTextAlignment; + } + + /** {@inheritDoc} */ + @Override + public DRIValueFormatter getValueFormatter() { + return valueFormatter; + } + + /** + *

Setter for the field valueFormatter.

+ * + * @param valueFormatter a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + */ + public void setValueFormatter(final DRIValueFormatter valueFormatter) { + this.valueFormatter = valueFormatter; + } + + /** {@inheritDoc} */ + @Override + public Boolean getStretchWithOverflow() { + return stretchWithOverflow; + } + + /** + *

Setter for the field stretchWithOverflow.

+ * + * @param stretchWithOverflow a {@link java.lang.Boolean} object. + * @deprecated replaced by {@link #setTextAdjust(TextAdjust)} + */ + @Deprecated + public void setStretchWithOverflow(final Boolean stretchWithOverflow) { + this.stretchWithOverflow = stretchWithOverflow; + } + + /** {@inheritDoc} */ + @Override + public TextAdjust getTextAdjust() { + return this.textAdjust; + } + + /** + *

Setter for the field textAdjust.

+ * + * @param textAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + public void setTextAdjust(final TextAdjust textAdjust) { + this.textAdjust = textAdjust; + } + + /** {@inheritDoc} */ + @Override + public DRHyperLink getHyperLink() { + return hyperLink; + } + + /** + *

Setter for the field hyperLink.

+ * + * @param hyperLink a {@link software.xdev.dynamicreports.report.base.DRHyperLink} object. + */ + public void setHyperLink(final DRHyperLink hyperLink) { + this.hyperLink = hyperLink; + } + + /** {@inheritDoc} */ + @Override + public List getPropertyExpressions() { + return propertyExpressions; + } + + /** + *

Setter for the field propertyExpressions.

+ * + * @param propertyExpressions a {@link java.util.List} object. + */ + public void setPropertyExpressions(final List propertyExpressions) { + this.propertyExpressions = propertyExpressions; + } + + /** + *

addPropertyExpression.

+ * + * @param propertyExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression} object. + */ + public void addPropertyExpression(final DRIPropertyExpression propertyExpression) { + Validate.notNull(propertyExpression, "propertyExpression must not be null"); + this.propertyExpressions.add(propertyExpression); + } + + /** {@inheritDoc} */ + @Override + public List getStyles() { + return styles; + } + + /** + *

setStyle.

+ * + * @param styles a {@link java.util.List} object. + */ + public void setStyle(final List styles) { + this.styles = styles; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getTitleExpression() { + return titleExpression; + } + + /** + *

Setter for the field titleExpression.

+ * + * @param titleExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setTitleExpression(final DRIExpression titleExpression) { + this.titleExpression = titleExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getTitleStyle() { + return titleStyle; + } + + /** + *

Setter for the field titleStyle.

+ * + * @param titleStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setTitleStyle(final DRIReportStyle titleStyle) { + this.titleStyle = titleStyle; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabRowGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabRowGroup.java new file mode 100644 index 0000000..f8a0a2d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabRowGroup.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.crosstab; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup; + +/** + *

DRCrosstabRowGroup class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRCrosstabRowGroup extends DRCrosstabGroup implements DRICrosstabRowGroup { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer headerWidth; + private Integer totalHeaderHeight; + + /** {@inheritDoc} */ + @Override + public Integer getHeaderWidth() { + return headerWidth; + } + + /** + *

Setter for the field headerWidth.

+ * + * @param headerWidth a {@link java.lang.Integer} object. + */ + public void setHeaderWidth(Integer headerWidth) { + this.headerWidth = headerWidth; + } + + /** {@inheritDoc} */ + @Override + public Integer getTotalHeaderHeight() { + return totalHeaderHeight; + } + + /** + *

Setter for the field totalHeaderHeight.

+ * + * @param totalHeaderHeight a {@link java.lang.Integer} object. + */ + public void setTotalHeaderHeight(Integer totalHeaderHeight) { + this.totalHeaderHeight = totalHeaderHeight; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabVariable.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabVariable.java new file mode 100644 index 0000000..9a25bde --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/crosstab/DRCrosstabVariable.java @@ -0,0 +1,98 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.crosstab; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; +import software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabVariable; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + *

DRCrosstabVariable class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRCrosstabVariable implements DRICrosstabVariable { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRIExpression valueExpression; + private Calculation calculation; + private CrosstabPercentageType percentageType; + + /** + *

Constructor for DRCrosstabVariable.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + public DRCrosstabVariable(DRIExpression valueExpression, Calculation calculation) { + Validate.notNull(valueExpression, "valueExpression must not be null"); + Validate.notNull(calculation, "calculation must not be null"); + this.valueExpression = valueExpression; + this.calculation = calculation; + this.name = ReportUtils.generateUniqueName("crosstabMeasure"); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getValueExpression() { + return valueExpression; + } + + /** {@inheritDoc} */ + @Override + public Calculation getCalculation() { + return calculation; + } + + /** {@inheritDoc} */ + @Override + public CrosstabPercentageType getPercentageType() { + return percentageType; + } + + /** + *

Setter for the field percentageType.

+ * + * @param percentageType a {@link software.xdev.dynamicreports.report.constant.CrosstabPercentageType} object. + */ + public void setPercentageType(CrosstabPercentageType percentageType) { + this.percentageType = percentageType; + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public Class getValueClass() { + if (percentageType != null && percentageType.equals(CrosstabPercentageType.GRAND_TOTAL) && !calculation.equals(Calculation.COUNT) && !calculation.equals(Calculation.DISTINCT_COUNT)) { + return (Class) Double.class; + } + return (Class) ReportUtils.getVariableValueClass(getCalculation(), valueExpression.getValueClass()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/datatype/AbstractDataType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/datatype/AbstractDataType.java new file mode 100644 index 0000000..41f3980 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/datatype/AbstractDataType.java @@ -0,0 +1,104 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.datatype; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.Locale; + +/** + *

Abstract AbstractDataType class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractDataType implements DRIDataType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return null; + } + + /** {@inheritDoc} */ + @Override + public DRIValueFormatter getValueFormatter() { + return null; + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return null; + } + + /** {@inheritDoc} */ + @Override + public String valueToString(U value, Locale locale) { + if (value != null) { + return value.toString(); + } + return null; + } + + /** {@inheritDoc} */ + @Override + public String valueToString(DRIValue value, ReportParameters reportParameters) { + return valueToString(reportParameters.getValue(value), reportParameters.getLocale()); + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public String valueToString(String name, ReportParameters reportParameters) { + return valueToString((U) reportParameters.getValue(name), reportParameters.getLocale()); + } + + /** {@inheritDoc} */ + @Override + public T stringToValue(String value, Locale locale) throws DRException { + return null; + } + + /** {@inheritDoc} */ + @Override + public T stringToValue(DRIValue value, ReportParameters reportParameters) throws DRException { + return stringToValue(reportParameters.getValue(value), reportParameters.getLocale()); + } + + /** {@inheritDoc} */ + @Override + public T stringToValue(String name, ReportParameters reportParameters) throws DRException { + return stringToValue((String) reportParameters.getValue(name), reportParameters.getLocale()); + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public Class getValueClass() { + return (Class) ReportUtils.getGenericClass(this, 1); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/datatype/DRDataType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/datatype/DRDataType.java new file mode 100644 index 0000000..e40b103 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/datatype/DRDataType.java @@ -0,0 +1,117 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; + +/** + *

DRDataType class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDataType extends AbstractDataType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String pattern; + private HorizontalTextAlignment horizontalTextAlignment; + private DRIValueFormatter valueFormatter; + + /** + *

Constructor for DRDataType.

+ */ + public DRDataType() { + } + + /** + *

Constructor for DRDataType.

+ * + * @param pattern a {@link java.lang.String} object. + */ + public DRDataType(String pattern) { + this.pattern = pattern; + } + + /** + *

Constructor for DRDataType.

+ * + * @param pattern a {@link java.lang.String} object. + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public DRDataType(String pattern, HorizontalTextAlignment horizontalTextAlignment) { + this.pattern = pattern; + this.horizontalTextAlignment = horizontalTextAlignment; + } + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return pattern; + } + + /** + *

Setter for the field pattern.

+ * + * @param pattern a {@link java.lang.String} object. + */ + public void setPattern(String pattern) { + this.pattern = pattern; + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return horizontalTextAlignment; + } + + /** + *

Setter for the field horizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public void setHorizontalTextAlignment(HorizontalTextAlignment horizontalTextAlignment) { + this.horizontalTextAlignment = horizontalTextAlignment; + } + + /** {@inheritDoc} */ + @Override + public DRIValueFormatter getValueFormatter() { + return valueFormatter; + } + + /** + *

Setter for the field valueFormatter.

+ * + * @param valueFormatter a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + */ + public void setValueFormatter(DRIValueFormatter valueFormatter) { + this.valueFormatter = valueFormatter; + } + + /** + *

toString.

+ * + * @param value a T object. + * @return a {@link java.lang.String} object. + */ + public String toString(T value) { + return String.valueOf(value); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/expression/AbstractSimpleExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/expression/AbstractSimpleExpression.java new file mode 100644 index 0000000..bac8636 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/expression/AbstractSimpleExpression.java @@ -0,0 +1,65 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.expression; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRISimpleExpression; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract AbstractSimpleExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractSimpleExpression implements DRISimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + + /** + *

Constructor for AbstractSimpleExpression.

+ */ + protected AbstractSimpleExpression() { + this.name = ReportUtils.generateUniqueName("simpleExpression"); + } + + /** + *

Constructor for AbstractSimpleExpression.

+ * + * @param name a {@link java.lang.String} object. + */ + protected AbstractSimpleExpression(String name) { + Validate.notEmpty(name, "name must not be empty"); + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public Class getValueClass() { + return (Class) ReportUtils.getGenericClass(this, 0); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/expression/AbstractSystemExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/expression/AbstractSystemExpression.java new file mode 100644 index 0000000..e41cba1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/expression/AbstractSystemExpression.java @@ -0,0 +1,58 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.expression; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRISystemExpression; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract AbstractSystemExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractSystemExpression implements DRISystemExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + + /** + *

Constructor for AbstractSystemExpression.

+ * + * @param name a {@link java.lang.String} object. + */ + protected AbstractSystemExpression(String name) { + Validate.notEmpty(name, "name must not be empty"); + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public Class getValueClass() { + return (Class) ReportUtils.getGenericClass(this, 0); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/expression/AbstractValueFormatter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/expression/AbstractValueFormatter.java new file mode 100644 index 0000000..9617d57 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/expression/AbstractValueFormatter.java @@ -0,0 +1,68 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.expression; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract AbstractValueFormatter class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractValueFormatter implements DRIValueFormatter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + + /** + *

Constructor for AbstractValueFormatter.

+ */ + protected AbstractValueFormatter() { + this.name = ReportUtils.generateUniqueName("valueFormatter"); + } + + /** + *

Constructor for AbstractValueFormatter.

+ * + * @param name a {@link java.lang.String} object. + */ + protected AbstractValueFormatter(String name) { + Validate.notEmpty(name, "name must not be empty"); + this.name = name; + } + + /** + *

Getter for the field name.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public Class getValueClass() { + return (Class) ReportUtils.getGenericClass(this, 0); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnGrid.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnGrid.java new file mode 100644 index 0000000..2822ab3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnGrid.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.grid; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGrid; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent; + +/** + *

DRColumnGrid class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRColumnGrid implements DRIColumnGrid { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRColumnGridList list; + + /** + *

Constructor for DRColumnGrid.

+ */ + public DRColumnGrid() { + this(ListType.HORIZONTAL); + } + + /** + *

Constructor for DRColumnGrid.

+ * + * @param type a {@link software.xdev.dynamicreports.report.constant.ListType} object. + */ + public DRColumnGrid(ListType type) { + this.list = new DRColumnGridList(type); + } + + /** {@inheritDoc} */ + @Override + public DRColumnGridList getList() { + return list; + } + + /** + *

addComponent.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent} object. + */ + public void addComponent(DRIColumnGridComponent component) { + list.addComponent(component); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnGridList.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnGridList.java new file mode 100644 index 0000000..b61454c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnGridList.java @@ -0,0 +1,128 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.grid; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGridList; +import org.apache.commons.lang3.Validate; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRColumnGridList class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRColumnGridList implements DRIColumnGridList { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private List listCells; + private ListType type; + private int gap; + + /** + *

Constructor for DRColumnGridList.

+ */ + public DRColumnGridList() { + this(ListType.HORIZONTAL); + } + + /** + *

Constructor for DRColumnGridList.

+ * + * @param type a {@link software.xdev.dynamicreports.report.constant.ListType} object. + */ + public DRColumnGridList(ListType type) { + setType(type); + this.listCells = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public List getListCells() { + return listCells; + } + + /** + *

addComponent.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent} object. + */ + public void addComponent(DRIColumnGridComponent component) { + listCells.add(new DRColumnGridListCell(component)); + } + + /** + *

addCell.

+ * + * @param cell a {@link software.xdev.dynamicreports.report.base.grid.DRColumnGridListCell} object. + */ + public void addCell(DRColumnGridListCell cell) { + Validate.notNull(cell, "cell must not be null"); + listCells.add(cell); + } + + /** + *

addComponent.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + * @param component a {@link software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent} object. + */ + public void addComponent(HorizontalCellComponentAlignment horizontalAlignment, VerticalCellComponentAlignment verticalAlignment, DRIColumnGridComponent component) { + listCells.add(new DRColumnGridListCell(horizontalAlignment, verticalAlignment, component)); + } + + /** {@inheritDoc} */ + @Override + public ListType getType() { + return type; + } + + /** + *

Setter for the field type.

+ * + * @param type a {@link software.xdev.dynamicreports.report.constant.ListType} object. + */ + public void setType(ListType type) { + Validate.notNull(type, "type must not be null"); + this.type = type; + } + + /** {@inheritDoc} */ + @Override + public int getGap() { + return gap; + } + + /** + *

Setter for the field gap.

+ * + * @param gap a int. + */ + public void setGap(int gap) { + Validate.notNull(gap < 0, "gap must be >= 0"); + this.gap = gap; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnGridListCell.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnGridListCell.java new file mode 100644 index 0000000..783687e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnGridListCell.java @@ -0,0 +1,98 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.grid; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGridListCell; +import org.apache.commons.lang3.Validate; + +/** + *

DRColumnGridListCell class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRColumnGridListCell implements DRIColumnGridListCell { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private HorizontalCellComponentAlignment horizontalAlignment; + private VerticalCellComponentAlignment verticalAlignment; + private DRIColumnGridComponent component; + + /** + *

Constructor for DRColumnGridListCell.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent} object. + */ + public DRColumnGridListCell(DRIColumnGridComponent component) { + Validate.notNull(component, "component must not be null"); + this.component = component; + } + + /** + *

Constructor for DRColumnGridListCell.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + * @param component a {@link software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent} object. + */ + public DRColumnGridListCell(HorizontalCellComponentAlignment horizontalAlignment, VerticalCellComponentAlignment verticalAlignment, DRIColumnGridComponent component) { + this(component); + this.horizontalAlignment = horizontalAlignment; + this.verticalAlignment = verticalAlignment; + } + + /** {@inheritDoc} */ + @Override + public HorizontalCellComponentAlignment getHorizontalAlignment() { + return horizontalAlignment; + } + + /** + *

Setter for the field horizontalAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + */ + public void setHorizontalAlignment(HorizontalCellComponentAlignment horizontalAlignment) { + this.horizontalAlignment = horizontalAlignment; + } + + /** {@inheritDoc} */ + @Override + public VerticalCellComponentAlignment getVerticalAlignment() { + return verticalAlignment; + } + + /** + *

Setter for the field verticalAlignment.

+ * + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + */ + public void setVerticalAlignment(VerticalCellComponentAlignment verticalAlignment) { + this.verticalAlignment = verticalAlignment; + } + + /** {@inheritDoc} */ + @Override + public DRIColumnGridComponent getComponent() { + return component; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnTitleGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnTitleGroup.java new file mode 100644 index 0000000..928efcc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/grid/DRColumnTitleGroup.java @@ -0,0 +1,291 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.grid; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnTitleGroup; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +/** + *

DRColumnTitleGroup class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class DRColumnTitleGroup implements DRIColumnTitleGroup { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private final DRColumnGridList list; + + private DRIExpression titleExpression; + private DRIReportStyle titleStyle; + private Integer titleWidth; + private ComponentDimensionType titleWidthType; + private Integer titleColumns; + private Integer titleHeight; + private ComponentDimensionType titleHeightType; + private Integer titleRows; + private Boolean titleStretchWithOverflow; + private TextAdjust titleTextAdjust; + private List titlePropertyExpressions; + + /** + *

Constructor for DRColumnTitleGroup.

+ */ + public DRColumnTitleGroup() { + this.list = new DRColumnGridList(ListType.HORIZONTAL); + titlePropertyExpressions = new ArrayList<>(); + } + + /** {@inheritDoc} */ + @Override + public DRColumnGridList getList() { + return list; + } + + /** + *

addComponent.

+ * + * @param component a {@link software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent} object. + */ + public void addComponent(final DRIColumnGridComponent component) { + list.addComponent(component); + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getTitleExpression() { + return titleExpression; + } + + /** + *

Setter for the field titleExpression.

+ * + * @param titleExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setTitleExpression(final DRIExpression titleExpression) { + this.titleExpression = titleExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getTitleStyle() { + return titleStyle; + } + + /** + *

Setter for the field titleStyle.

+ * + * @param titleStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setTitleStyle(final DRIReportStyle titleStyle) { + this.titleStyle = titleStyle; + } + + /** + * {@inheritDoc} + *

+ * Returns the column title width. + */ + @Override + public Integer getTitleWidth() { + return titleWidth; + } + + /** + * Sets the column title width. + * + * @param titleWidth the column title width >= 0 + * @throws java.lang.IllegalArgumentException if titleWidth is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public void setTitleWidth(final Integer titleWidth) { + if (titleWidth != null) { + Validate.isTrue(titleWidth >= 0, "titleWidth must be >= 0"); + } + this.titleWidth = titleWidth; + } + + /** {@inheritDoc} */ + @Override + public ComponentDimensionType getTitleWidthType() { + return titleWidthType; + } + + /** + *

Setter for the field titleWidthType.

+ * + * @param titleWidthType a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public void setTitleWidthType(final ComponentDimensionType titleWidthType) { + this.titleWidthType = titleWidthType; + } + + /** + * {@inheritDoc} + *

+ * Returns the number of title columns. + */ + @Override + public Integer getTitleColumns() { + return titleColumns; + } + + /** + * This method is used to define the width of a column title. The width is set to the columns multiplied by width of the character m for the font used + * + * @param titleColumns the number of columns >= 0 + * @throws java.lang.IllegalArgumentException if columns is < 0 + */ + public void setTitleColumns(final Integer titleColumns) { + if (titleColumns != null) { + Validate.isTrue(titleColumns >= 0, "titleColumns must be >= 0"); + } + this.titleColumns = titleColumns; + } + + /** + * {@inheritDoc} + *

+ * Returns the column title height. + */ + @Override + public Integer getTitleHeight() { + return titleHeight; + } + + /** + * Sets the column title height. + * + * @param titleHeight the column title height >= 0 + * @throws java.lang.IllegalArgumentException if titleHeight is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public void setTitleHeight(final Integer titleHeight) { + if (titleHeight != null) { + Validate.isTrue(titleHeight >= 0, "titleHeight must be >= 0"); + } + this.titleHeight = titleHeight; + } + + /** {@inheritDoc} */ + @Override + public ComponentDimensionType getTitleHeightType() { + return titleHeightType; + } + + /** + *

Setter for the field titleHeightType.

+ * + * @param titleHeightType a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public void setTitleHeightType(final ComponentDimensionType titleHeightType) { + this.titleHeightType = titleHeightType; + } + + /** + * {@inheritDoc} + *

+ * Returns the number of title rows. + */ + @Override + public Integer getTitleRows() { + return titleRows; + } + + /** + * This method is used to define the height of a column title. The height is set to the rows multiplied by height of the font + * + * @param titleRows the number of rows >= 0 + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public void setTitleRows(final Integer titleRows) { + if (titleRows != null) { + Validate.isTrue(titleRows >= 0, "titleRows must be >= 0"); + } + this.titleRows = titleRows; + } + + /** {@inheritDoc} */ + @Override + public Boolean getTitleStretchWithOverflow() { + return titleStretchWithOverflow; + } + + /** + *

Setter for the field titleStretchWithOverflow.

+ * + * @param titleStretchWithOverflow a {@link java.lang.Boolean} object. + * @deprecated replaced by {@link #getTitleTextAdjust()} + */ + @Deprecated + public void setTitleStretchWithOverflow(final Boolean titleStretchWithOverflow) { + this.titleStretchWithOverflow = titleStretchWithOverflow; + } + + /** {@inheritDoc} */ + @Override + public TextAdjust getTitleTextAdjust() { + return this.titleTextAdjust; + } + + /** + *

Setter for the field titleTextAdjust.

+ * + * @param textAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + public void setTitleTextAdjust(final TextAdjust textAdjust) { + this.titleTextAdjust = textAdjust; + } + + /** {@inheritDoc} */ + @Override + public List getTitlePropertyExpressions() { + return titlePropertyExpressions; + } + + /** + *

Setter for the field titlePropertyExpressions.

+ * + * @param titlePropertyExpressions a {@link java.util.List} object. + */ + public void setTitlePropertyExpressions(final List titlePropertyExpressions) { + this.titlePropertyExpressions = titlePropertyExpressions; + } + + /** + *

addTitlePropertyExpression.

+ * + * @param propertyExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression} object. + */ + public void addTitlePropertyExpression(final DRIPropertyExpression propertyExpression) { + Validate.notNull(propertyExpression, "propertyExpression must not be null"); + this.titlePropertyExpressions.add(propertyExpression); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRBaseStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRBaseStyle.java new file mode 100644 index 0000000..f36f52f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRBaseStyle.java @@ -0,0 +1,316 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.style; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.Rotation; +import software.xdev.dynamicreports.report.constant.VerticalImageAlignment; +import software.xdev.dynamicreports.report.constant.VerticalTextAlignment; +import software.xdev.dynamicreports.report.definition.style.DRIBaseStyle; + +import java.awt.Color; + +/** + *

Abstract DRBaseStyle class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class DRBaseStyle implements DRIBaseStyle { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Color foregroundColor; + private Color backgroundColor; + private Integer radius; + private ImageScale imageScale; + private HorizontalImageAlignment horizontalImageAlignment; + private VerticalImageAlignment verticalImageAlignment; + private HorizontalTextAlignment horizontalTextAlignment; + private VerticalTextAlignment verticalTextAlignment; + private DRBorder border; + private DRPadding padding; + private DRFont font; + private Rotation rotation; + private String pattern; + private Markup markup; + private DRParagraph paragraph; + private DRPen linePen; + + /** + *

Constructor for DRBaseStyle.

+ */ + public DRBaseStyle() { + init(); + } + + /** + *

init.

+ */ + protected void init() { + font = new DRFont(); + border = new DRBorder(); + padding = new DRPadding(); + paragraph = new DRParagraph(); + linePen = new DRPen(); + } + + /** {@inheritDoc} */ + @Override + public Color getForegroundColor() { + return foregroundColor; + } + + /** + *

Setter for the field foregroundColor.

+ * + * @param foregroundColor a {@link java.awt.Color} object. + */ + public void setForegroundColor(Color foregroundColor) { + this.foregroundColor = foregroundColor; + } + + /** {@inheritDoc} */ + @Override + public Color getBackgroundColor() { + return backgroundColor; + } + + /** + *

Setter for the field backgroundColor.

+ * + * @param backgroundColor a {@link java.awt.Color} object. + */ + public void setBackgroundColor(Color backgroundColor) { + this.backgroundColor = backgroundColor; + } + + /** {@inheritDoc} */ + @Override + public Integer getRadius() { + return radius; + } + + /** + *

Setter for the field radius.

+ * + * @param radius a {@link java.lang.Integer} object. + */ + public void setRadius(Integer radius) { + this.radius = radius; + } + + /** {@inheritDoc} */ + @Override + public ImageScale getImageScale() { + return imageScale; + } + + /** + *

Setter for the field imageScale.

+ * + * @param imageScale a {@link software.xdev.dynamicreports.report.constant.ImageScale} object. + */ + public void setImageScale(ImageScale imageScale) { + this.imageScale = imageScale; + } + + /** {@inheritDoc} */ + @Override + public HorizontalImageAlignment getHorizontalImageAlignment() { + return horizontalImageAlignment; + } + + /** + *

Setter for the field horizontalImageAlignment.

+ * + * @param horizontalImageAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public void setHorizontalImageAlignment(HorizontalImageAlignment horizontalImageAlignment) { + this.horizontalImageAlignment = horizontalImageAlignment; + } + + /** {@inheritDoc} */ + @Override + public VerticalImageAlignment getVerticalImageAlignment() { + return verticalImageAlignment; + } + + /** + *

Setter for the field verticalImageAlignment.

+ * + * @param verticalImageAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalImageAlignment} object. + */ + public void setVerticalImageAlignment(VerticalImageAlignment verticalImageAlignment) { + this.verticalImageAlignment = verticalImageAlignment; + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return horizontalTextAlignment; + } + + /** + *

Setter for the field horizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public void setHorizontalTextAlignment(HorizontalTextAlignment horizontalTextAlignment) { + this.horizontalTextAlignment = horizontalTextAlignment; + } + + /** {@inheritDoc} */ + @Override + public VerticalTextAlignment getVerticalTextAlignment() { + return verticalTextAlignment; + } + + /** + *

Setter for the field verticalTextAlignment.

+ * + * @param verticalTextAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalTextAlignment} object. + */ + public void setVerticalTextAlignment(VerticalTextAlignment verticalTextAlignment) { + this.verticalTextAlignment = verticalTextAlignment; + } + + /** {@inheritDoc} */ + @Override + public DRBorder getBorder() { + return border; + } + + /** + *

Setter for the field border.

+ * + * @param border a {@link software.xdev.dynamicreports.report.base.style.DRBorder} object. + */ + public void setBorder(DRBorder border) { + this.border = border; + } + + /** {@inheritDoc} */ + @Override + public DRPadding getPadding() { + return padding; + } + + /** + *

Setter for the field padding.

+ * + * @param padding a {@link software.xdev.dynamicreports.report.base.style.DRPadding} object. + */ + public void setPadding(DRPadding padding) { + this.padding = padding; + } + + /** {@inheritDoc} */ + @Override + public DRFont getFont() { + return font; + } + + /** + *

Setter for the field font.

+ * + * @param font a {@link software.xdev.dynamicreports.report.base.style.DRFont} object. + */ + public void setFont(DRFont font) { + this.font = font; + } + + /** {@inheritDoc} */ + @Override + public Rotation getRotation() { + return rotation; + } + + /** + *

Setter for the field rotation.

+ * + * @param rotation a {@link software.xdev.dynamicreports.report.constant.Rotation} object. + */ + public void setRotation(Rotation rotation) { + this.rotation = rotation; + } + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return pattern; + } + + /** + *

Setter for the field pattern.

+ * + * @param pattern a {@link java.lang.String} object. + */ + public void setPattern(String pattern) { + this.pattern = pattern; + } + + /** {@inheritDoc} */ + @Override + public Markup getMarkup() { + return markup; + } + + /** + *

Setter for the field markup.

+ * + * @param markup a {@link software.xdev.dynamicreports.report.constant.Markup} object. + */ + public void setMarkup(Markup markup) { + this.markup = markup; + } + + /** {@inheritDoc} */ + @Override + public DRParagraph getParagraph() { + return paragraph; + } + + /** + *

Setter for the field paragraph.

+ * + * @param paragraph a {@link software.xdev.dynamicreports.report.base.style.DRParagraph} object. + */ + public void setParagraph(DRParagraph paragraph) { + this.paragraph = paragraph; + } + + /** {@inheritDoc} */ + @Override + public DRPen getLinePen() { + return linePen; + } + + /** + *

Setter for the field linePen.

+ * + * @param linePen a {@link software.xdev.dynamicreports.report.base.style.DRPen} object. + */ + public void setLinePen(DRPen linePen) { + this.linePen = linePen; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRBorder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRBorder.java new file mode 100644 index 0000000..552ade0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRBorder.java @@ -0,0 +1,118 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.style; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.style.DRIBorder; + +/** + *

DRBorder class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRBorder implements DRIBorder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRPen topPen; + private DRPen leftPen; + private DRPen bottomPen; + private DRPen rightPen; + + /** + *

Constructor for DRBorder.

+ */ + public DRBorder() { + topPen = new DRPen(); + leftPen = new DRPen(); + bottomPen = new DRPen(); + rightPen = new DRPen(); + } + + /** + *

Constructor for DRBorder.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.base.style.DRPen} object. + */ + public DRBorder(DRPen pen) { + topPen = pen; + leftPen = pen; + bottomPen = pen; + rightPen = pen; + } + + /** {@inheritDoc} */ + @Override + public DRPen getTopPen() { + return topPen; + } + + /** + *

Setter for the field topPen.

+ * + * @param topPen a {@link software.xdev.dynamicreports.report.base.style.DRPen} object. + */ + public void setTopPen(DRPen topPen) { + this.topPen = topPen; + } + + /** {@inheritDoc} */ + @Override + public DRPen getLeftPen() { + return leftPen; + } + + /** + *

Setter for the field leftPen.

+ * + * @param leftPen a {@link software.xdev.dynamicreports.report.base.style.DRPen} object. + */ + public void setLeftPen(DRPen leftPen) { + this.leftPen = leftPen; + } + + /** {@inheritDoc} */ + @Override + public DRPen getBottomPen() { + return bottomPen; + } + + /** + *

Setter for the field bottomPen.

+ * + * @param bottomPen a {@link software.xdev.dynamicreports.report.base.style.DRPen} object. + */ + public void setBottomPen(DRPen bottomPen) { + this.bottomPen = bottomPen; + } + + /** {@inheritDoc} */ + @Override + public DRPen getRightPen() { + return rightPen; + } + + /** + *

Setter for the field rightPen.

+ * + * @param rightPen a {@link software.xdev.dynamicreports.report.base.style.DRPen} object. + */ + public void setRightPen(DRPen rightPen) { + this.rightPen = rightPen; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRConditionalStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRConditionalStyle.java new file mode 100644 index 0000000..ba504ed --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRConditionalStyle.java @@ -0,0 +1,51 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.style; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.style.DRIConditionalStyle; +import org.apache.commons.lang3.Validate; + +/** + *

DRConditionalStyle class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRConditionalStyle extends DRBaseStyle implements DRIConditionalStyle { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression conditionExpression; + + /** + *

Constructor for DRConditionalStyle.

+ * + * @param conditionExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRConditionalStyle(DRIExpression conditionExpression) { + Validate.notNull(conditionExpression, "conditionExpression must not be null"); + this.conditionExpression = conditionExpression; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getConditionExpression() { + return conditionExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRFont.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRFont.java new file mode 100644 index 0000000..e14b1a5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRFont.java @@ -0,0 +1,215 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.style; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.style.DRIFont; +import org.apache.commons.lang3.Validate; + +/** + *

DRFont class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRFont implements DRIFont { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String fontName; + private Integer fontSize; + private Boolean bold; + private Boolean italic; + private Boolean underline; + private Boolean strikeThrough; + private String pdfFontName; + private String pdfEncoding; + private Boolean pdfEmbedded; + + /** + *

Constructor for DRFont.

+ */ + public DRFont() { + } + + /** + *

Constructor for DRFont.

+ * + * @param fontName a {@link java.lang.String} object. + * @param fontSize a int. + */ + public DRFont(String fontName, int fontSize) { + this.fontName = fontName; + this.setFontSize(fontSize); + } + + /** + *

Constructor for DRFont.

+ * + * @param fontName a {@link java.lang.String} object. + * @param bold a boolean. + * @param italic a boolean. + * @param fontSize a int. + */ + public DRFont(String fontName, boolean bold, boolean italic, int fontSize) { + this.fontName = fontName; + this.bold = bold; + this.italic = italic; + this.setFontSize(fontSize); + } + + /** {@inheritDoc} */ + @Override + public String getFontName() { + return fontName; + } + + /** + *

Setter for the field fontName.

+ * + * @param fontName a {@link java.lang.String} object. + */ + public void setFontName(String fontName) { + this.fontName = fontName; + } + + /** {@inheritDoc} */ + @Override + public Boolean getBold() { + return bold; + } + + /** + *

Setter for the field bold.

+ * + * @param bold a {@link java.lang.Boolean} object. + */ + public void setBold(Boolean bold) { + this.bold = bold; + } + + /** {@inheritDoc} */ + @Override + public Boolean getItalic() { + return italic; + } + + /** + *

Setter for the field italic.

+ * + * @param italic a {@link java.lang.Boolean} object. + */ + public void setItalic(Boolean italic) { + this.italic = italic; + } + + /** {@inheritDoc} */ + @Override + public Boolean getUnderline() { + return underline; + } + + /** + *

Setter for the field underline.

+ * + * @param underline a {@link java.lang.Boolean} object. + */ + public void setUnderline(Boolean underline) { + this.underline = underline; + } + + /** {@inheritDoc} */ + @Override + public Boolean getStrikeThrough() { + return strikeThrough; + } + + /** + *

Setter for the field strikeThrough.

+ * + * @param strikeThrough a {@link java.lang.Boolean} object. + */ + public void setStrikeThrough(Boolean strikeThrough) { + this.strikeThrough = strikeThrough; + } + + /** {@inheritDoc} */ + @Override + public Integer getFontSize() { + return fontSize; + } + + /** + *

Setter for the field fontSize.

+ * + * @param fontSize a {@link java.lang.Integer} object. + */ + public void setFontSize(Integer fontSize) { + if (fontSize != null) { + Validate.isTrue(fontSize >= 0, "fontSize must be >= 0"); + } + this.fontSize = fontSize; + } + + /** {@inheritDoc} */ + @Override + public String getPdfFontName() { + return pdfFontName; + } + + /** + *

Setter for the field pdfFontName.

+ * + * @param pdfFontName a {@link java.lang.String} object. + */ + @Deprecated + public void setPdfFontName(String pdfFontName) { + this.pdfFontName = pdfFontName; + } + + /** {@inheritDoc} */ + @Override + public String getPdfEncoding() { + return pdfEncoding; + } + + /** + *

Setter for the field pdfEncoding.

+ * + * @param pdfEncoding a {@link java.lang.String} object. + */ + @Deprecated + public void setPdfEncoding(String pdfEncoding) { + this.pdfEncoding = pdfEncoding; + } + + /** {@inheritDoc} */ + @Override + public Boolean getPdfEmbedded() { + return pdfEmbedded; + } + + /** + *

Setter for the field pdfEmbedded.

+ * + * @param pdfEmbedded a {@link java.lang.Boolean} object. + */ + @Deprecated + public void setPdfEmbedded(Boolean pdfEmbedded) { + this.pdfEmbedded = pdfEmbedded; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRPadding.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRPadding.java new file mode 100644 index 0000000..1701c34 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRPadding.java @@ -0,0 +1,130 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.style; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.style.DRIPadding; +import org.apache.commons.lang3.Validate; + +/** + *

DRPadding class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRPadding implements DRIPadding { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Integer top; + private Integer left; + private Integer bottom; + private Integer right; + + /** + *

Constructor for DRPadding.

+ */ + public DRPadding() { + } + + /** + *

Constructor for DRPadding.

+ * + * @param padding a {@link java.lang.Integer} object. + */ + public DRPadding(Integer padding) { + if (padding != null) { + Validate.isTrue(padding >= 0, "padding must be >= 0"); + } + top = padding; + left = padding; + bottom = padding; + right = padding; + } + + /** {@inheritDoc} */ + @Override + public Integer getTop() { + return top; + } + + /** + *

Setter for the field top.

+ * + * @param top a {@link java.lang.Integer} object. + */ + public void setTop(Integer top) { + if (top != null) { + Validate.isTrue(top >= 0, "top must be >= 0"); + } + this.top = top; + } + + /** {@inheritDoc} */ + @Override + public Integer getLeft() { + return left; + } + + /** + *

Setter for the field left.

+ * + * @param left a {@link java.lang.Integer} object. + */ + public void setLeft(Integer left) { + if (left != null) { + Validate.isTrue(left >= 0, "left must be >= 0"); + } + this.left = left; + } + + /** {@inheritDoc} */ + @Override + public Integer getBottom() { + return bottom; + } + + /** + *

Setter for the field bottom.

+ * + * @param bottom a {@link java.lang.Integer} object. + */ + public void setBottom(Integer bottom) { + if (bottom != null) { + Validate.isTrue(bottom >= 0, "bottom must be >= 0"); + } + this.bottom = bottom; + } + + /** {@inheritDoc} */ + @Override + public Integer getRight() { + return right; + } + + /** + *

Setter for the field right.

+ * + * @param right a {@link java.lang.Integer} object. + */ + public void setRight(Integer right) { + if (right != null) { + Validate.isTrue(right >= 0, "right must be >= 0"); + } + this.right = right; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRParagraph.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRParagraph.java new file mode 100644 index 0000000..a282a43 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRParagraph.java @@ -0,0 +1,188 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.style; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.LineSpacing; +import software.xdev.dynamicreports.report.definition.style.DRIParagraph; +import software.xdev.dynamicreports.report.definition.style.DRITabStop; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRParagraph class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRParagraph implements DRIParagraph { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private LineSpacing lineSpacing; + private Float lineSpacingSize; + private Integer firstLineIndent; + private Integer leftIndent; + private Integer rightIndent; + private Integer spacingBefore; + private Integer spacingAfter; + private Integer tabStopWidth; + private List tabStops; + + /** + *

Constructor for DRParagraph.

+ */ + public DRParagraph() { + tabStops = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public LineSpacing getLineSpacing() { + return lineSpacing; + } + + /** + *

Setter for the field lineSpacing.

+ * + * @param lineSpacing a {@link software.xdev.dynamicreports.report.constant.LineSpacing} object. + */ + public void setLineSpacing(LineSpacing lineSpacing) { + this.lineSpacing = lineSpacing; + } + + /** {@inheritDoc} */ + @Override + public Float getLineSpacingSize() { + return lineSpacingSize; + } + + /** + *

Setter for the field lineSpacingSize.

+ * + * @param lineSpacingSize a {@link java.lang.Float} object. + */ + public void setLineSpacingSize(Float lineSpacingSize) { + this.lineSpacingSize = lineSpacingSize; + } + + /** {@inheritDoc} */ + @Override + public Integer getFirstLineIndent() { + return firstLineIndent; + } + + /** + *

Setter for the field firstLineIndent.

+ * + * @param firstLineIndent a {@link java.lang.Integer} object. + */ + public void setFirstLineIndent(Integer firstLineIndent) { + this.firstLineIndent = firstLineIndent; + } + + /** {@inheritDoc} */ + @Override + public Integer getLeftIndent() { + return leftIndent; + } + + /** + *

Setter for the field leftIndent.

+ * + * @param leftIndent a {@link java.lang.Integer} object. + */ + public void setLeftIndent(Integer leftIndent) { + this.leftIndent = leftIndent; + } + + /** {@inheritDoc} */ + @Override + public Integer getRightIndent() { + return rightIndent; + } + + /** + *

Setter for the field rightIndent.

+ * + * @param rightIndent a {@link java.lang.Integer} object. + */ + public void setRightIndent(Integer rightIndent) { + this.rightIndent = rightIndent; + } + + /** {@inheritDoc} */ + @Override + public Integer getSpacingBefore() { + return spacingBefore; + } + + /** + *

Setter for the field spacingBefore.

+ * + * @param spacingBefore a {@link java.lang.Integer} object. + */ + public void setSpacingBefore(Integer spacingBefore) { + this.spacingBefore = spacingBefore; + } + + /** {@inheritDoc} */ + @Override + public Integer getSpacingAfter() { + return spacingAfter; + } + + /** + *

Setter for the field spacingAfter.

+ * + * @param spacingAfter a {@link java.lang.Integer} object. + */ + public void setSpacingAfter(Integer spacingAfter) { + this.spacingAfter = spacingAfter; + } + + /** {@inheritDoc} */ + @Override + public Integer getTabStopWidth() { + return tabStopWidth; + } + + /** + *

Setter for the field tabStopWidth.

+ * + * @param tabStopWidth a {@link java.lang.Integer} object. + */ + public void setTabStopWidth(Integer tabStopWidth) { + this.tabStopWidth = tabStopWidth; + } + + /** {@inheritDoc} */ + @Override + public List getTabStops() { + return tabStops; + } + + /** + *

Setter for the field tabStops.

+ * + * @param tabStops a {@link java.util.List} object. + */ + public void setTabStops(List tabStops) { + this.tabStops = tabStops; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRPen.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRPen.java new file mode 100644 index 0000000..7773c57 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRPen.java @@ -0,0 +1,104 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.style; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.LineStyle; +import software.xdev.dynamicreports.report.definition.style.DRIPen; +import org.apache.commons.lang3.Validate; + +import java.awt.Color; + +/** + *

DRPen class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRPen implements DRIPen { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private Float lineWidth; + private LineStyle lineStyle; + private Color lineColor; + + /** + *

Constructor for DRPen.

+ */ + public DRPen() { + } + + /** + *

Constructor for DRPen.

+ * + * @param lineWidth a {@link java.lang.Float} object. + * @param lineStyle a {@link software.xdev.dynamicreports.report.constant.LineStyle} object. + */ + public DRPen(Float lineWidth, LineStyle lineStyle) { + this.setLineWidth(lineWidth); + this.lineStyle = lineStyle; + } + + /** {@inheritDoc} */ + @Override + public Float getLineWidth() { + return lineWidth; + } + + /** + *

Setter for the field lineWidth.

+ * + * @param lineWidth a {@link java.lang.Float} object. + */ + public void setLineWidth(Float lineWidth) { + if (lineWidth != null) { + Validate.isTrue(lineWidth >= 0, "lineWidth must be >= 0"); + } + this.lineWidth = lineWidth; + } + + /** {@inheritDoc} */ + @Override + public LineStyle getLineStyle() { + return lineStyle; + } + + /** + *

Setter for the field lineStyle.

+ * + * @param lineStyle a {@link software.xdev.dynamicreports.report.constant.LineStyle} object. + */ + public void setLineStyle(LineStyle lineStyle) { + this.lineStyle = lineStyle; + } + + /** {@inheritDoc} */ + @Override + public Color getLineColor() { + return lineColor; + } + + /** + *

Setter for the field lineColor.

+ * + * @param lineColor a {@link java.awt.Color} object. + */ + public void setLineColor(Color lineColor) { + this.lineColor = lineColor; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRSimpleStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRSimpleStyle.java new file mode 100644 index 0000000..37c0bda --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRSimpleStyle.java @@ -0,0 +1,32 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.style; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.style.DRISimpleStyle; + +/** + *

DRSimpleStyle class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRSimpleStyle extends DRBaseStyle implements DRISimpleStyle { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRStyle.java new file mode 100644 index 0000000..3e19baa --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRStyle.java @@ -0,0 +1,104 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.style; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; +import org.apache.commons.lang3.Validate; + +import java.util.ArrayList; +import java.util.List; + +/** + *

DRStyle class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRStyle extends DRBaseStyle implements DRIStyle { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRIReportStyle parentStyle; + private List conditionalStyles; + + /** {@inheritDoc} */ + @Override + protected void init() { + super.init(); + conditionalStyles = new ArrayList(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

Setter for the field name.

+ * + * @param name a {@link java.lang.String} object. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public DRIReportStyle getParentStyle() { + return parentStyle; + } + + /** + *

Setter for the field parentStyle.

+ * + * @param parentStyle a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public void setParentStyle(DRIReportStyle parentStyle) { + this.parentStyle = parentStyle; + } + + /** {@inheritDoc} */ + @Override + public List getConditionalStyles() { + return conditionalStyles; + } + + /** + *

Setter for the field conditionalStyles.

+ * + * @param conditionalStyles a {@link java.util.List} object. + */ + public void setConditionalStyles(List conditionalStyles) { + Validate.notNull(conditionalStyles, "conditionalStyles must not be null"); + Validate.noNullElements(conditionalStyles, "conditionalStyles must not contains null conditionalStyle"); + this.conditionalStyles = conditionalStyles; + } + + /** + *

addConditionalStyle.

+ * + * @param conditionalStyle a {@link software.xdev.dynamicreports.report.base.style.DRConditionalStyle} object. + */ + public void addConditionalStyle(DRConditionalStyle conditionalStyle) { + Validate.notNull(conditionalStyle, "conditionalStyle must not be null"); + this.conditionalStyles.add(conditionalStyle); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRTabStop.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRTabStop.java new file mode 100644 index 0000000..8ff6e61 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRTabStop.java @@ -0,0 +1,65 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.style; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.TabStopAlignment; +import software.xdev.dynamicreports.report.definition.style.DRITabStop; + +/** + *

DRTabStop class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRTabStop implements DRITabStop { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int position; + private TabStopAlignment alignment; + + /** {@inheritDoc} */ + @Override + public int getPosition() { + return position; + } + + /** + *

Setter for the field position.

+ * + * @param position a int. + */ + public void setPosition(int position) { + this.position = position; + } + + /** {@inheritDoc} */ + @Override + public TabStopAlignment getAlignment() { + return alignment; + } + + /** + *

Setter for the field alignment.

+ * + * @param alignment a {@link software.xdev.dynamicreports.report.constant.TabStopAlignment} object. + */ + public void setAlignment(TabStopAlignment alignment) { + this.alignment = alignment; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRTemplateStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRTemplateStyle.java new file mode 100644 index 0000000..98315af --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/base/style/DRTemplateStyle.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.base.style; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.style.DRITemplateStyle; + +/** + *

DRTemplateStyle class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRTemplateStyle implements DRITemplateStyle { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + + /** + *

Constructor for DRTemplateStyle.

+ * + * @param name a {@link java.lang.String} object. + */ + public DRTemplateStyle(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/AbstractBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/AbstractBuilder.java new file mode 100644 index 0000000..eb7a215 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/AbstractBuilder.java @@ -0,0 +1,72 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import software.xdev.dynamicreports.report.constant.Constants; + +import java.io.Serializable; + +/** + *

Abstract AbstractBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractBuilder, U> implements Serializable { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + protected boolean builded; + private U object; + + /** + *

Constructor for AbstractBuilder.

+ * + * @param object a U object. + */ + protected AbstractBuilder(U object) { + this.object = object; + this.builded = false; + } + + /** + *

build.

+ * + * @return a U object. + */ + public U build() { + if (!builded) { + configure(); + builded = true; + } + return object; + } + + /** + *

Getter for the field object.

+ * + * @return a U object. + */ + protected U getObject() { + return object; + } + + /** + *

configure.

+ */ + protected void configure() { + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/DatasetBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/DatasetBuilder.java new file mode 100644 index 0000000..4c1ceee --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/DatasetBuilder.java @@ -0,0 +1,292 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import software.xdev.dynamicreports.report.base.DRDataset; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.QueryLanguage; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import net.sf.jasperreports.engine.JRDataSource; +import org.apache.commons.lang3.Validate; + +import java.sql.Connection; + +/** + *

DatasetBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class DatasetBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for DatasetBuilder.

+ */ + protected DatasetBuilder() { + super(new DRDataset()); + } + + // field + + /** + *

fields.

+ * + * @param fields a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder fields(FieldBuilder... fields) { + return addField(fields); + } + + /** + *

addField.

+ * + * @param name a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder addField(String name, Class valueClass) { + return addField(DynamicReports.field(name, valueClass)); + } + + /** + *

addField.

+ * + * @param name a {@link java.lang.String} object. + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + * @param a U object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder addField(String name, DRIDataType dataType) { + return addField(DynamicReports.field(name, dataType)); + } + + /** + *

addField.

+ * + * @param fields a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder addField(FieldBuilder... fields) { + Validate.notNull(fields, "fields must not be null"); + Validate.noNullElements(fields, "fields must not contains null field"); + for (FieldBuilder field : fields) { + getObject().addField(field.build()); + } + return this; + } + + // variable + + /** + *

variables.

+ * + * @param variables a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder variables(VariableBuilder... variables) { + return addVariable(variables); + } + + /** + *

addVariable.

+ * + * @param variables a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder addVariable(VariableBuilder... variables) { + Validate.notNull(variables, "variables must not be null"); + Validate.noNullElements(variables, "variables must not contains null variable"); + for (VariableBuilder variable : variables) { + getObject().addVariable(variable.getVariable()); + } + return this; + } + + // sort + + /** + *

sortBy.

+ * + * @param sortColumns a {@link software.xdev.dynamicreports.report.builder.column.TextColumnBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder sortBy(TextColumnBuilder... sortColumns) { + Validate.notNull(sortColumns, "sortColumns must not be null"); + Validate.noNullElements(sortColumns, "sortColumns must not contains null sortColumn"); + for (TextColumnBuilder sortColumn : sortColumns) { + sortBy(DynamicReports.asc(sortColumn)); + } + return this; + } + + /** + *

sortBy.

+ * + * @param sorts a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder sortBy(SortBuilder... sorts) { + return addSort(sorts); + } + + /** + *

addSort.

+ * + * @param sorts a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder addSort(SortBuilder... sorts) { + Validate.notNull(sorts, "sorts must not be null"); + Validate.noNullElements(sorts, "sorts must not contains null sort"); + for (SortBuilder sort : sorts) { + getObject().addSort(sort.build()); + } + return this; + } + + // query + + /** + *

setQuery.

+ * + * @param text a {@link java.lang.String} object. + * @param language a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder setQuery(String text, String language) { + Validate.notNull(text, "text must not be null"); + Validate.notNull(language, "language must not be null"); + return setQuery(DynamicReports.query(text, language)); + } + + /** + *

setQuery.

+ * + * @param sql a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder setQuery(String sql) { + Validate.notNull(sql, "sql must not be null"); + return setQuery(DynamicReports.query(sql, QueryLanguage.SQL)); + } + + /** + *

setQuery.

+ * + * @param query a {@link software.xdev.dynamicreports.report.builder.QueryBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder setQuery(QueryBuilder query) { + Validate.notNull(query, "query must not be null"); + getObject().setQuery(query.build()); + return this; + } + + // connection + + /** + *

setConnection.

+ * + * @param connection a {@link java.sql.Connection} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder setConnection(Connection connection) { + getObject().setConnectionExpression(Expressions.value(connection)); + return this; + } + + /** + *

setConnection.

+ * + * @param connectionExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder setConnection(DRIExpression connectionExpression) { + getObject().setConnectionExpression(connectionExpression); + return this; + } + + // datasource + + /** + *

setDataSource.

+ * + * @param dataSource a {@link net.sf.jasperreports.engine.JRDataSource} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder setDataSource(JRDataSource dataSource) { + getObject().setDataSourceExpression(Expressions.dataSource(dataSource)); + return this; + } + + /** + *

setDataSource.

+ * + * @param dataSourceExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder setDataSource(DRIExpression dataSourceExpression) { + getObject().setDataSourceExpression(dataSourceExpression); + return this; + } + + // filter + + /** + *

setFilterExpression.

+ * + * @param filterExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder setFilterExpression(DRIExpression filterExpression) { + getObject().setFilterExpression(filterExpression); + return this; + } + + /** + *

setDataSource.

+ * + * @param sql a {@link java.lang.String} object. + * @param connection a {@link java.sql.Connection} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder setDataSource(String sql, Connection connection) { + Validate.notNull(sql, "sql must not be null"); + return setDataSource(DynamicReports.query(sql, QueryLanguage.SQL), connection); + } + + /** + *

setDataSource.

+ * + * @param query a {@link software.xdev.dynamicreports.report.builder.QueryBuilder} object. + * @param connection a {@link java.sql.Connection} object. + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public DatasetBuilder setDataSource(QueryBuilder query, Connection connection) { + Validate.notNull(query, "query must not be null"); + Validate.notNull(connection, "connection must not be null"); + setQuery(query); + setConnection(connection); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/DynamicReports.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/DynamicReports.java new file mode 100644 index 0000000..105ebd0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/DynamicReports.java @@ -0,0 +1,549 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.jasper.builder.export.ExporterBuilders; +import software.xdev.dynamicreports.jasper.definition.JasperReportHandler; +import software.xdev.dynamicreports.report.builder.column.ColumnBuilders; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.builder.component.ComponentBuilders; +import software.xdev.dynamicreports.report.builder.condition.ConditionBuilders; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilders; +import software.xdev.dynamicreports.report.builder.datatype.DataTypeBuilders; +import software.xdev.dynamicreports.report.builder.datatype.DataTypes; +import software.xdev.dynamicreports.report.builder.expression.ExpressionBuilders; +import software.xdev.dynamicreports.report.builder.grid.GridBuilders; +import software.xdev.dynamicreports.report.builder.group.GroupBuilders; +import software.xdev.dynamicreports.report.builder.style.StyleBuilders; +import software.xdev.dynamicreports.report.builder.subtotal.SubtotalBuilders; +import software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder; +import software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsHeadingBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.OrderType; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + *

DynamicReports class.

+ * + * @author Ricardo Mariaca + * + */ +public class DynamicReports { + /** + * A set of methods of creating report columns.
It is used to display data in a multi-column layout. + */ + public static final ColumnBuilders col = new ColumnBuilders(); + /** + * A set of methods of customizing columns layout. + */ + public static final GridBuilders grid = new GridBuilders(); + /** + * A set of methods of creating report groups. + */ + public static final GroupBuilders grp = new GroupBuilders(); + /** + * A set of methods of creating column subtotals. + */ + public static final SubtotalBuilders sbt = new SubtotalBuilders(); + /** + * A set of methods of creating and customizing styles. + */ + public static final StyleBuilders stl = new StyleBuilders(); + /** + * A set of methods of creating components. + */ + public static final ComponentBuilders cmp = new ComponentBuilders(); + /** + * A set of build in expressions.
Expressions are used to define various calculations, conditions, text field content, specific report groups, etc. + */ + public static final ExpressionBuilders exp = new ExpressionBuilders(); + /** + * A set of build in condition expressions. + */ + public static final ConditionBuilders cnd = new ConditionBuilders(); + /** + * A set of build in data types. + */ + public static final DataTypeBuilders type = new DataTypeBuilders(); + /** + * A set of methods of creating exporters. + */ + public static final ExporterBuilders export = new ExporterBuilders(); + /** + * A set of methods of creating and customizing crosstabs. + */ + public static final CrosstabBuilders ctab = new CrosstabBuilders(); + + /** + * Creates a new report builder. The most used report builder for creating reports. It allows constructing and customizing the whole report content. + * + * @return a report builder + */ + public static JasperReportBuilder report() { + return new JasperReportBuilder(); + } + + /** + * Creates a new concatenated report builder. This report builder allows concatenating several separated reports into one single document. + * + * @return a report builder + */ + public static JasperConcatenatedReportBuilder concatenatedReport() { + return new JasperConcatenatedReportBuilder(); + } + + /** + * Creates a new concatenated report builder. This report builder allows concatenating several separated reports into one single document. + * + * @param jasperReportHandler a {@link software.xdev.dynamicreports.jasper.definition.JasperReportHandler} object. + * @return a report builder + */ + public static JasperConcatenatedReportBuilder concatenatedReport(final JasperReportHandler jasperReportHandler) { + return new JasperConcatenatedReportBuilder(jasperReportHandler); + } + + // field + + /** + *

field.

+ * + * @param name a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public static FieldBuilder field(final String name, final Class valueClass) { + final FieldBuilder fieldBuilder = new FieldBuilder<>(name, valueClass); + try { + final DRIDataType dataType = DataTypes.detectType(valueClass); + fieldBuilder.setDataType(dataType); + } catch (final DRException e) { + } + return fieldBuilder; + } + + /** + *

field.

+ * + * @param name a {@link java.lang.String} object. + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public static FieldBuilder field(final String name, final DRIDataType dataType) { + Validate.notNull(dataType, "dataType must not be null"); + final FieldBuilder fieldBuilder = new FieldBuilder(name, dataType.getValueClass()); + fieldBuilder.setDataType(dataType); + return fieldBuilder; + } + + // variable + + /** + *

variable.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + public static VariableBuilder variable(final ValueColumnBuilder column, final Calculation calculation) { + Validate.notNull(column, "column must not be null"); + return new VariableBuilder<>(column, calculation); + } + + /** + *

variable.

+ * + * @param name a {@link java.lang.String} object. + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + public static VariableBuilder variable(final String name, final ValueColumnBuilder column, final Calculation calculation) { + Validate.notNull(column, "column must not be null"); + return new VariableBuilder<>(name, column, calculation); + } + + /** + *

variable.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + public static VariableBuilder variable(final FieldBuilder field, final Calculation calculation) { + Validate.notNull(field, "field must not be null"); + return new VariableBuilder<>(field, calculation); + } + + /** + *

variable.

+ * + * @param name a {@link java.lang.String} object. + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + public static VariableBuilder variable(final String name, final FieldBuilder field, final Calculation calculation) { + return new VariableBuilder<>(name, field, calculation); + } + + /** + *

variable.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + public static VariableBuilder variable(final String fieldName, final Class valueClass, final Calculation calculation) { + return new VariableBuilder<>(field(fieldName, valueClass), calculation); + } + + /** + *

variable.

+ * + * @param name a {@link java.lang.String} object. + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + public static VariableBuilder variable(final String name, final String fieldName, final Class valueClass, final Calculation calculation) { + return new VariableBuilder<>(name, field(fieldName, valueClass), calculation); + } + + /** + *

variable.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + public static VariableBuilder variable(final DRIExpression expression, final Calculation calculation) { + return new VariableBuilder<>(expression, calculation); + } + + /** + *

variable.

+ * + * @param name a {@link java.lang.String} object. + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + public static VariableBuilder variable(final String name, final DRIExpression expression, final Calculation calculation) { + return new VariableBuilder<>(name, expression, calculation); + } + + // sort + + /** + *

asc.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.TextColumnBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + */ + public static SortBuilder asc(final TextColumnBuilder column) { + return new SortBuilder(column).setOrderType(OrderType.ASCENDING); + } + + /** + *

asc.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + */ + public static SortBuilder asc(final FieldBuilder field) { + return new SortBuilder(field).setOrderType(OrderType.ASCENDING); + } + + /** + *

asc.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @return a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + */ + public static SortBuilder asc(final String fieldName, final Class valueClass) { + return new SortBuilder(field(fieldName, valueClass)).setOrderType(OrderType.ASCENDING); + } + + /** + *

asc.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + */ + public static SortBuilder asc(final VariableBuilder variable) { + return new SortBuilder(variable).setOrderType(OrderType.ASCENDING); + } + + /** + *

asc.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + */ + public static SortBuilder asc(final DRIExpression expression) { + return new SortBuilder(expression).setOrderType(OrderType.ASCENDING); + } + + /** + *

desc.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.TextColumnBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + */ + public static SortBuilder desc(final TextColumnBuilder column) { + return new SortBuilder(column).setOrderType(OrderType.DESCENDING); + } + + /** + *

desc.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + */ + public static SortBuilder desc(final FieldBuilder field) { + return new SortBuilder(field).setOrderType(OrderType.DESCENDING); + } + + /** + *

desc.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @return a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + */ + public static SortBuilder desc(final String fieldName, final Class valueClass) { + return new SortBuilder(field(fieldName, valueClass)).setOrderType(OrderType.DESCENDING); + } + + /** + *

desc.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + */ + public static SortBuilder desc(final VariableBuilder variable) { + return new SortBuilder(variable).setOrderType(OrderType.DESCENDING); + } + + /** + *

desc.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + */ + public static SortBuilder desc(final DRIExpression expression) { + return new SortBuilder(expression).setOrderType(OrderType.DESCENDING); + } + + // hyperLink + + /** + *

hyperLink.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public static HyperLinkBuilder hyperLink() { + return new HyperLinkBuilder(); + } + + /** + *

hyperLink.

+ * + * @param link a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public static HyperLinkBuilder hyperLink(final String link) { + return new HyperLinkBuilder(link); + } + + /** + *

hyperLink.

+ * + * @param linkExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public static HyperLinkBuilder hyperLink(final DRIExpression linkExpression) { + return new HyperLinkBuilder(linkExpression); + } + + // margin + + /** + *

margin.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.MarginBuilder} object. + */ + public static MarginBuilder margin() { + return new MarginBuilder(); + } + + /** + *

margin.

+ * + * @param margin a int. + * @return a {@link software.xdev.dynamicreports.report.builder.MarginBuilder} object. + */ + public static MarginBuilder margin(final int margin) { + return new MarginBuilder(margin); + } + + // parameter + + /** + *

parameter.

+ * + * @param name a {@link java.lang.String} object. + * @param value a T object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.ParameterBuilder} object. + */ + public static ParameterBuilder parameter(final String name, final T value) { + return new ParameterBuilder<>(name, value); + } + + /** + *

parameter.

+ * + * @param name a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.ParameterBuilder} object. + */ + public static ParameterBuilder parameter(final String name, final Class valueClass) { + return new ParameterBuilder<>(name, valueClass); + } + + // query + + /** + *

query.

+ * + * @param text a {@link java.lang.String} object. + * @param language a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.QueryBuilder} object. + */ + public static QueryBuilder query(final String text, final String language) { + return new QueryBuilder(text, language); + } + + // units + + /** + *

cm.

+ * + * @param value a {@link java.lang.Number} object. + * @return a int. + */ + public static int cm(final Number value) { + return Units.cm(value); + } + + /** + *

inch.

+ * + * @param value a {@link java.lang.Number} object. + * @return a int. + */ + public static int inch(final Number value) { + return Units.inch(value); + } + + /** + *

mm.

+ * + * @param value a {@link java.lang.Number} object. + * @return a int. + */ + public static int mm(final Number value) { + return Units.mm(value); + } + + // template + + /** + *

template.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public static ReportTemplateBuilder template() { + return new ReportTemplateBuilder(); + } + + // table of contents + + /** + *

tableOfContentsCustomizer.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder} object. + */ + public static TableOfContentsCustomizerBuilder tableOfContentsCustomizer() { + return new TableOfContentsCustomizerBuilder(); + } + + /** + *

tableOfContentsHeading.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsHeadingBuilder} object. + */ + public static TableOfContentsHeadingBuilder tableOfContentsHeading() { + return new TableOfContentsHeadingBuilder(); + } + + /** + *

tableOfContentsHeading.

+ * + * @param label a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsHeadingBuilder} object. + */ + public static TableOfContentsHeadingBuilder tableOfContentsHeading(final String label) { + return new TableOfContentsHeadingBuilder().setLabel(label); + } + + // dataset + + /** + *

dataset.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + */ + public static DatasetBuilder dataset() { + return new DatasetBuilder(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/FieldBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/FieldBuilder.java new file mode 100644 index 0000000..fd55f19 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/FieldBuilder.java @@ -0,0 +1,80 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import software.xdev.dynamicreports.report.base.DRField; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; + +/** + *

FieldBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class FieldBuilder extends AbstractBuilder, DRField> implements DRIValue { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for FieldBuilder.

+ * + * @param name a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + */ + protected FieldBuilder(String name, Class valueClass) { + super(new DRField(name, valueClass)); + } + + /** + *

setDataType.

+ * + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + public FieldBuilder setDataType(DRIDataType dataType) { + getObject().setDataType(dataType); + return this; + } + + /** + *

setDescription.

+ * + * @param description a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + public FieldBuilder setDescription(String description) { + getObject().setDescription(description); + return this; + } + + /** + *

getField.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRField} object. + */ + public DRField getField() { + return build(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return getField().getName(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/HyperLinkBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/HyperLinkBuilder.java new file mode 100644 index 0000000..a66ca24 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/HyperLinkBuilder.java @@ -0,0 +1,228 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import software.xdev.dynamicreports.report.base.DRHyperLink; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HyperLinkTarget; +import software.xdev.dynamicreports.report.constant.HyperLinkType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + *

HyperLinkBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class HyperLinkBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for HyperLinkBuilder.

+ */ + protected HyperLinkBuilder() { + super(new DRHyperLink()); + } + + /** + *

Constructor for HyperLinkBuilder.

+ * + * @param link a {@link java.lang.String} object. + */ + protected HyperLinkBuilder(String link) { + super(new DRHyperLink()); + setLink(link); + } + + /** + *

Constructor for HyperLinkBuilder.

+ * + * @param linkExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected HyperLinkBuilder(DRIExpression linkExpression) { + super(new DRHyperLink()); + setLink(linkExpression); + } + + /** + *

setLink.

+ * + * @param link a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setLink(String link) { + Validate.notNull(link, "link must not be null"); + return setLink(Expressions.text(link)); + } + + /** + *

setLink.

+ * + * @param linkExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setLink(DRIExpression linkExpression) { + Validate.notNull(linkExpression, "linkExpression must not be null"); + getObject().setReferenceExpression(linkExpression); + getObject().setType(HyperLinkType.REFERENCE.name()); + return this; + } + + /** + *

setAnchor.

+ * + * @param anchor a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setAnchor(String anchor) { + getObject().setAnchorExpression(Expressions.text(anchor)); + return this; + } + + /** + *

setAnchor.

+ * + * @param anchorExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setAnchor(DRIExpression anchorExpression) { + getObject().setAnchorExpression(anchorExpression); + return this; + } + + /** + *

setPage.

+ * + * @param page a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setPage(Integer page) { + getObject().setPageExpression(Expressions.value(page)); + return this; + } + + /** + *

setPage.

+ * + * @param pageExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setPage(DRIExpression pageExpression) { + getObject().setPageExpression(pageExpression); + return this; + } + + /** + *

setReference.

+ * + * @param reference a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setReference(String reference) { + getObject().setReferenceExpression(Expressions.text(reference)); + return this; + } + + /** + *

setReference.

+ * + * @param referenceExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setReference(DRIExpression referenceExpression) { + getObject().setReferenceExpression(referenceExpression); + return this; + } + + /** + *

setTooltip.

+ * + * @param tooltip a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setTooltip(String tooltip) { + getObject().setTooltipExpression(Expressions.text(tooltip)); + return this; + } + + /** + *

setTooltip.

+ * + * @param tooltipExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setTooltip(DRIExpression tooltipExpression) { + getObject().setTooltipExpression(tooltipExpression); + return this; + } + + /** + *

setType.

+ * + * @param hyperLinkType a {@link software.xdev.dynamicreports.report.constant.HyperLinkType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setType(HyperLinkType hyperLinkType) { + getObject().setType(hyperLinkType.name()); + return this; + } + + /** + *

setType.

+ * + * @param hyperLinkType a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setType(String hyperLinkType) { + getObject().setType(hyperLinkType); + return this; + } + + /** + *

setTarget.

+ * + * @param hyperLinkTarget a {@link software.xdev.dynamicreports.report.constant.HyperLinkTarget} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setTarget(HyperLinkTarget hyperLinkTarget) { + getObject().setTarget(hyperLinkTarget.name()); + return this; + } + + /** + *

setTarget.

+ * + * @param hyperLinkTarget a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + */ + public HyperLinkBuilder setTarget(String hyperLinkTarget) { + getObject().setTarget(hyperLinkTarget); + return this; + } + + /** + *

getHyperLink.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRHyperLink} object. + */ + public DRHyperLink getHyperLink() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/MarginBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/MarginBuilder.java new file mode 100644 index 0000000..b5d7ce9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/MarginBuilder.java @@ -0,0 +1,100 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import software.xdev.dynamicreports.report.base.DRMargin; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

MarginBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class MarginBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for MarginBuilder.

+ */ + protected MarginBuilder() { + super(new DRMargin()); + } + + /** + *

Constructor for MarginBuilder.

+ * + * @param margin a int. + */ + protected MarginBuilder(int margin) { + super(new DRMargin(margin)); + } + + /** + *

setTop.

+ * + * @param top a int. + * @return a {@link software.xdev.dynamicreports.report.builder.MarginBuilder} object. + */ + public MarginBuilder setTop(int top) { + getObject().setTop(top); + return this; + } + + /** + *

setLeft.

+ * + * @param left a int. + * @return a {@link software.xdev.dynamicreports.report.builder.MarginBuilder} object. + */ + public MarginBuilder setLeft(int left) { + getObject().setLeft(left); + return this; + } + + /** + *

setBottom.

+ * + * @param bottom a int. + * @return a {@link software.xdev.dynamicreports.report.builder.MarginBuilder} object. + */ + public MarginBuilder setBottom(int bottom) { + getObject().setBottom(bottom); + return this; + } + + /** + *

setRight.

+ * + * @param right a int. + * @return a {@link software.xdev.dynamicreports.report.builder.MarginBuilder} object. + */ + public MarginBuilder setRight(int right) { + getObject().setRight(right); + return this; + } + + /** + *

getMargin.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRMargin} object. + */ + public DRMargin getMargin() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/ParameterBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/ParameterBuilder.java new file mode 100644 index 0000000..a136a63 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/ParameterBuilder.java @@ -0,0 +1,60 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import software.xdev.dynamicreports.report.base.DRParameter; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

ParameterBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class ParameterBuilder extends AbstractBuilder, DRParameter> { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for ParameterBuilder.

+ * + * @param name a {@link java.lang.String} object. + * @param value a T object. + */ + protected ParameterBuilder(String name, T value) { + super(new DRParameter(name, value)); + } + + /** + *

Constructor for ParameterBuilder.

+ * + * @param name a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + */ + protected ParameterBuilder(String name, Class valueClass) { + super(new DRParameter(name, valueClass)); + } + + /** + *

getParameter.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRParameter} object. + */ + public DRParameter getParameter() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/QueryBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/QueryBuilder.java new file mode 100644 index 0000000..de178d5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/QueryBuilder.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import software.xdev.dynamicreports.report.base.DRQuery; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

QueryBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class QueryBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for QueryBuilder.

+ * + * @param text a {@link java.lang.String} object. + * @param language a {@link java.lang.String} object. + */ + protected QueryBuilder(String text, String language) { + super(new DRQuery(text, language)); + } + + /** + *

getQuery.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRQuery} object. + */ + public DRQuery getQuery() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/ReportBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/ReportBuilder.java new file mode 100644 index 0000000..da1a8bb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/ReportBuilder.java @@ -0,0 +1,2198 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.base.DRGroup; +import software.xdev.dynamicreports.report.base.DRReport; +import software.xdev.dynamicreports.report.base.grid.DRColumnGrid; +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.builder.component.ComponentBuilder; +import software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.builder.group.Groups; +import software.xdev.dynamicreports.report.builder.style.ConditionalStyleBuilder; +import software.xdev.dynamicreports.report.builder.style.FontBuilder; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.builder.style.SimpleStyleBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.PercentageSubtotalBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.SubtotalBuilder; +import software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.constant.QueryLanguage; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.constant.SubtotalPosition; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.DRIScriptlet; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + + +/** + *

ReportBuilder class.

+ * + * @author Ricardo Mariaca + */ +@SuppressWarnings("unchecked") +public class ReportBuilder> extends AbstractBuilder +{ + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + public ReportBuilder() + { + super(new DRReport()); + } + + public T setReportName(final String reportName) + { + this.getObject().setReportName(reportName); + return (T)this; + } + + public T setLocale(final Locale locale) + { + this.getObject().setLocale(locale); + return (T)this; + } + + public T setResourceBundle(final ResourceBundle resourceBundle) + { + this.getObject().setResourceBundle(resourceBundle); + return (T)this; + } + + public T setResourceBundle(final String resourceBundleName) + { + this.getObject().setResourceBundleName(resourceBundleName); + return (T)this; + } + + public T setShowColumnTitle(final Boolean showColumnTitle) + { + this.getObject().setShowColumnTitle(showColumnTitle); + return (T)this; + } + + public T setShowColumnValues(final Boolean showColumnValues) + { + this.getObject().setShowColumnValues(showColumnValues); + return (T)this; + } + + public T setPageFormat(final PageType pageType) + { + return this.setPageFormat(pageType, PageOrientation.PORTRAIT); + } + + public T setPageFormat(final PageType pageType, final PageOrientation orientation) + { + this.getObject().getPage().setPageFormat(pageType, orientation); + return (T)this; + } + + public T setPageFormat(final Integer width, final Integer height, final PageOrientation orientation) + { + this.getObject().getPage().setPageFormat(width, height, orientation); + return (T)this; + } + + public T setPageMargin(final MarginBuilder margin) + { + Validate.notNull(margin, "margin must not be null"); + this.getObject().getPage().setMargin(margin.build()); + return (T)this; + } + + public T setPageColumnsPerPage(final Integer columnsPerPage) + { + this.getObject().getPage().setColumnsPerPage(columnsPerPage); + return (T)this; + } + + public T setPageColumnSpace(final Integer columnSpace) + { + this.getObject().getPage().setColumnSpace(columnSpace); + return (T)this; + } + + public T ignorePageWidth() + { + return this.setIgnorePageWidth(true); + } + + public T setIgnorePageWidth(final Boolean ignorePageWidth) + { + this.getObject().getPage().setIgnorePageWidth(ignorePageWidth); + return (T)this; + } + + public T ignorePagination() + { + return this.setIgnorePagination(true); + } + + public T setIgnorePagination(final Boolean ignorePagination) + { + this.getObject().setIgnorePagination(ignorePagination); + return (T)this; + } + + public T setWhenNoDataType(final WhenNoDataType whenNoDataType) + { + this.getObject().setWhenNoDataType(whenNoDataType); + return (T)this; + } + + public T setWhenResourceMissingType(final WhenResourceMissingType whenResourceMissingType) + { + this.getObject().setWhenResourceMissingType(whenResourceMissingType); + return (T)this; + } + + /** + * Prints the title band on a separate page. + * + * @return a report builder + */ + public T titleOnANewPage() + { + return this.setTitleOnANewPage(true); + } + + /** + * Sets whether or not the title band is printed on a separate page. + * + * @param titleOnANewPage print the title band on a separate page + * @return a report builder + */ + public T setTitleOnANewPage(final Boolean titleOnANewPage) + { + this.getObject().setTitleOnANewPage(titleOnANewPage); + return (T)this; + } + + /** + * Prints the summary band on a separate page. + * + * @return a report builder + */ + public T summaryOnANewPage() + { + return this.setSummaryOnANewPage(true); + } + + /** + * Sets whether or not the summary band is printed on a separate page. + * + * @param summaryOnANewPage print the summary band on a separate page + * @return a report builder + */ + public T setSummaryOnANewPage(final Boolean summaryOnANewPage) + { + this.getObject().setSummaryOnANewPage(summaryOnANewPage); + return (T)this; + } + + /** + * Prints the summary band with the page header and footer. + * + * @return a report builder + */ + public T summaryWithPageHeaderAndFooter() + { + return this.setSummaryWithPageHeaderAndFooter(true); + } + + /** + * Sets whether or not the summary band is printed with the page header and footer. + * + * @param summaryWithPageHeaderAndFooter print the summary band with the page header and footer + * @return a report builder + */ + public T setSummaryWithPageHeaderAndFooter(final Boolean summaryWithPageHeaderAndFooter) + { + this.getObject().setSummaryWithPageHeaderAndFooter(summaryWithPageHeaderAndFooter); + return (T)this; + } + + /** + * Prints the column footer band at the bottom of the column. + * + * @return a report builder + */ + public T floatColumnFooter() + { + return this.setFloatColumnFooter(true); + } + + /** + * Sets whether or not the column footer band is printed at the bottom of the column + * + * @param floatColumnFooter print the column footer at the bottom of the column + * @return a report builder + */ + public T setFloatColumnFooter(final Boolean floatColumnFooter) + { + this.getObject().setFloatColumnFooter(floatColumnFooter); + return (T)this; + } + + public T setPrintOrder(final Orientation printOrder) + { + this.getObject().setPrintOrder(printOrder); + return (T)this; + } + + public T setColumnDirection(final RunDirection columnDirection) + { + this.getObject().setColumnDirection(columnDirection); + return (T)this; + } + + public T setLanguage(final String language) + { + this.getObject().setLanguage(language); + return (T)this; + } + + public T setUseFieldNameAsDescription(final Boolean useFieldNameAsDescription) + { + this.getObject().setUseFieldNameAsDescription(useFieldNameAsDescription); + return (T)this; + } + + public T scriptlets(final DRIScriptlet... scriptlets) + { + return this.addScriptlet(scriptlets); + } + + public T addScriptlet(final DRIScriptlet... scriptlets) + { + Validate.notNull(scriptlets, "scriptlets must not be null"); + Validate.noNullElements(scriptlets, "scriptlets must not contains null scriptlet"); + for(final DRIScriptlet scriptlet : scriptlets) + { + this.getObject().addScriptlet(scriptlet); + } + return (T)this; + } + + public T setProperties(final Properties properties) + { + this.getObject().setProperties(properties); + return (T)this; + } + + public T addProperty(final String key, final String value) + { + this.getObject().addProperty(key, value); + return (T)this; + } + + public T setQuery(final String text, final String language) + { + Validate.notNull(text, "text must not be null"); + Validate.notNull(language, "language must not be null"); + return this.setQuery(DynamicReports.query(text, language)); + } + + public T setQuery(final String sql) + { + Validate.notNull(sql, "sql must not be null"); + return this.setQuery(DynamicReports.query(sql, QueryLanguage.SQL)); + } + + public T setQuery(final QueryBuilder query) + { + Validate.notNull(query, "query must not be null"); + this.getObject().setQuery(query.build()); + return (T)this; + } + + public T columnGrid(final ListType type) + { + this.getObject().setColumnGrid(new DRColumnGrid(type)); + return (T)this; + } + + public T columnGrid(final ColumnGridComponentBuilder... components) + { + return this.columnGrid(ListType.HORIZONTAL, components); + } + + public T columnGrid(final ListType type, final ColumnGridComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + final DRColumnGrid columnGrid = new DRColumnGrid(type); + for(final ColumnGridComponentBuilder component : components) + { + columnGrid.addComponent(component.build()); + } + this.getObject().setColumnGrid(columnGrid); + return (T)this; + } + + // template + public T setTemplate(final ReportTemplateBuilder template) + { + Validate.notNull(template, "template must not be null"); + this.getObject().setTemplate(template.build()); + return (T)this; + } + + // template style + public T templateStyles(final TemplateStylesBuilder... templateStyles) + { + return this.addTemplateStyle(templateStyles); + } + + public T addTemplateStyle(final TemplateStylesBuilder... templateStyles) + { + Validate.notNull(templateStyles, "templateStyles must not be null"); + Validate.noNullElements(templateStyles, "templateStyles must not contains null templateStyle"); + for(final TemplateStylesBuilder templateStyle : templateStyles) + { + for(final StyleBuilder style : templateStyle.getStyles()) + { + this.addTemplateStyle(style); + } + } + return (T)this; + } + + public T templateStyles(final StyleBuilder... templateStyles) + { + return this.addTemplateStyle(templateStyles); + } + + public T addTemplateStyle(final StyleBuilder... templateStyles) + { + Validate.notNull(templateStyles, "templateStyles must not be null"); + Validate.noNullElements(templateStyles, "templateStyles must not contains null templateStyle"); + for(final StyleBuilder templateStyle : templateStyles) + { + this.getObject().addTemplateStyle(templateStyle.build()); + } + return (T)this; + } + + // parameter + public T parameters(final ParameterBuilder... parameters) + { + return this.addParameter(parameters); + } + + public T addParameter(final String name, final Object value) + { + return this.addParameter(DynamicReports.parameter(name, value)); + } + + public T addParameter(final String name, final Class valueClass) + { + return this.addParameter(DynamicReports.parameter(name, valueClass)); + } + + public T addParameter(final ParameterBuilder... parameters) + { + Validate.notNull(parameters, "parameters must not be null"); + Validate.noNullElements(parameters, "parameters must not contains null parameter"); + for(final ParameterBuilder parameter : parameters) + { + this.getObject().addParameter(parameter.build()); + } + return (T)this; + } + + public T setParameter(final String name, final Object value) + { + this.getObject().addParameterValue(name, value); + return (T)this; + } + + public T setParameters(final Map parameters) + { + this.getObject().setParameterValues(parameters); + return (T)this; + } + + // field + public T fields(final FieldBuilder... fields) + { + return this.addField(fields); + } + + public T addField(final String name, final Class valueClass) + { + return this.addField(DynamicReports.field(name, valueClass)); + } + + public T addField(final String name, final DRIDataType dataType) + { + return this.addField(DynamicReports.field(name, dataType)); + } + + public T addField(final FieldBuilder... fields) + { + Validate.notNull(fields, "fields must not be null"); + Validate.noNullElements(fields, "fields must not contains null field"); + for(final FieldBuilder field : fields) + { + this.getObject().addField(field.build()); + } + return (T)this; + } + + // variable + public T variables(final VariableBuilder... variables) + { + return this.addVariable(variables); + } + + public T addVariable(final VariableBuilder... variables) + { + Validate.notNull(variables, "variables must not be null"); + Validate.noNullElements(variables, "variables must not contains null variable"); + for(final VariableBuilder variable : variables) + { + this.getObject().addVariable(variable.getVariable()); + } + return (T)this; + } + + /** + * Adds a sort field to the dataset + * + * @param sortColumns columns to be sorted + * @return a report builder + */ + public T sortBy(final TextColumnBuilder... sortColumns) + { + Validate.notNull(sortColumns, "sortColumns must not be null"); + Validate.noNullElements(sortColumns, "sortColumns must not contains null sortColumn"); + for(final TextColumnBuilder sortColumn : sortColumns) + { + this.sortBy(DynamicReports.asc(sortColumn)); + } + return (T)this; + } + + /** + * Adds a sort field to the dataset + * + * @param sorts the sort definitions + * @return a report builder + */ + public T sortBy(final SortBuilder... sorts) + { + return this.addSort(sorts); + } + + /** + * Adds a sort field to the dataset + * + * @param sorts the sort definitions + * @return a report builder + */ + public T addSort(final SortBuilder... sorts) + { + Validate.notNull(sorts, "sorts must not be null"); + Validate.noNullElements(sorts, "sorts must not contains null sort"); + for(final SortBuilder sort : sorts) + { + this.getObject().addSort(sort.build()); + } + return (T)this; + } + + // column + public T columns(final ColumnBuilder... columns) + { + return this.addColumn(columns); + } + + public T addColumn(final ColumnBuilder... columns) + { + Validate.notNull(columns, "columns must not be null"); + Validate.noNullElements(columns, "columns must not contains null column"); + for(final ColumnBuilder column : columns) + { + this.getObject().addColumn(column.build()); + } + return (T)this; + } + + // style + public T setDefaultFont(final FontBuilder defaultFont) + { + if(defaultFont != null) + { + this.getObject().setDefaultFont(defaultFont.build()); + } + else + { + this.getObject().setDefaultFont(null); + } + return (T)this; + } + + public T setTextStyle(final ReportStyleBuilder textStyle) + { + if(textStyle != null) + { + this.getObject().setTextStyle(textStyle.build()); + } + else + { + this.getObject().setTextStyle(null); + } + return (T)this; + } + + public T setColumnTitleStyle(final ReportStyleBuilder columnTitleStyle) + { + if(columnTitleStyle != null) + { + this.getObject().setColumnTitleStyle(columnTitleStyle.build()); + } + else + { + this.getObject().setColumnTitleStyle(null); + } + return (T)this; + } + + public T setColumnStyle(final ReportStyleBuilder columnStyle) + { + if(columnStyle != null) + { + this.getObject().setColumnStyle(columnStyle.build()); + } + else + { + this.getObject().setColumnStyle(null); + } + return (T)this; + } + + public T setGroupTitleStyle(final ReportStyleBuilder groupTitleStyle) + { + if(groupTitleStyle != null) + { + this.getObject().setGroupTitleStyle(groupTitleStyle.build()); + } + else + { + this.getObject().setGroupTitleStyle(null); + } + return (T)this; + } + + public T setGroupStyle(final ReportStyleBuilder groupStyle) + { + if(groupStyle != null) + { + this.getObject().setGroupStyle(groupStyle.build()); + } + else + { + this.getObject().setGroupStyle(null); + } + return (T)this; + } + + public T setSubtotalStyle(final ReportStyleBuilder subtotalStyle) + { + if(subtotalStyle != null) + { + this.getObject().setSubtotalStyle(subtotalStyle.build()); + } + else + { + this.getObject().setSubtotalStyle(null); + } + return (T)this; + } + + public T setImageStyle(final ReportStyleBuilder imageStyle) + { + if(imageStyle != null) + { + this.getObject().setImageStyle(imageStyle.build()); + } + else + { + this.getObject().setImageStyle(null); + } + return (T)this; + } + + // row highlighter + public T highlightDetailOddRows() + { + return this.setHighlightDetailOddRows(true); + } + + public T setHighlightDetailOddRows(final Boolean highlightDetailOddRows) + { + this.getObject().setHighlightDetailOddRows(highlightDetailOddRows); + return (T)this; + } + + public T setDetailOddRowStyle(final SimpleStyleBuilder detailOddRowStyle) + { + if(detailOddRowStyle != null) + { + this.getObject().setDetailOddRowStyle(detailOddRowStyle.build()); + } + else + { + this.getObject().setDetailOddRowStyle(null); + } + return (T)this; + } + + public T highlightDetailEvenRows() + { + return this.setHighlightDetailEvenRows(true); + } + + public T setHighlightDetailEvenRows(final Boolean highlightDetailEvenRows) + { + this.getObject().setHighlightDetailEvenRows(highlightDetailEvenRows); + return (T)this; + } + + public T setDetailEvenRowStyle(final SimpleStyleBuilder detailEvenRowStyle) + { + if(detailEvenRowStyle != null) + { + this.getObject().setDetailEvenRowStyle(detailEvenRowStyle.build()); + } + else + { + this.getObject().setDetailEvenRowStyle(null); + } + return (T)this; + } + + public T detailRowHighlighters(final ConditionalStyleBuilder... detailRowHighlighters) + { + return this.addDetailRowHighlighter(detailRowHighlighters); + } + + public T addDetailRowHighlighter(final ConditionalStyleBuilder... detailRowHighlighters) + { + Validate.notNull(detailRowHighlighters, "detailRowHighlighters must not be null"); + Validate.noNullElements( + detailRowHighlighters, + "detailRowHighlighters must not contains null detailRowHighlighter"); + for(final ConditionalStyleBuilder conditionalStyleBuilder : detailRowHighlighters) + { + this.getObject().addDetailRowHighlighter(conditionalStyleBuilder.build()); + } + return (T)this; + } + + // subtotal + public T subtotalsAtTitle(final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtTitle(subtotals); + } + + public T addSubtotalAtTitle(final SubtotalBuilder... subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.TITLE).build()); + } + return (T)this; + } + + public T subtotalsAtPageHeader(final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtPageHeader(subtotals); + } + + public T addSubtotalAtPageHeader(final SubtotalBuilder... subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.PAGE_HEADER).build()); + } + return (T)this; + } + + public T subtotalsAtPageFooter(final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtPageFooter(subtotals); + } + + public T addSubtotalAtPageFooter(final SubtotalBuilder... subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.PAGE_FOOTER).build()); + } + return (T)this; + } + + public T subtotalsAtColumnHeader(final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtColumnHeader(subtotals); + } + + public T addSubtotalAtColumnHeader(final SubtotalBuilder... subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.COLUMN_HEADER).build()); + } + return (T)this; + } + + public T subtotalsAtColumnFooter(final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtColumnFooter(subtotals); + } + + public T addSubtotalAtColumnFooter(final SubtotalBuilder... subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.COLUMN_FOOTER).build()); + } + return (T)this; + } + + public T subtotalsAtGroupHeader(final GroupBuilder group, final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtGroupHeader(group, subtotals); + } + + public T addSubtotalAtGroupHeader(final GroupBuilder group, final SubtotalBuilder... subtotals) + { + Validate.notNull(group, "group must not be null"); + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.GROUP_HEADER).setGroup(group).build()); + } + return (T)this; + } + + public T subtotalsAtGroupFooter(final GroupBuilder group, final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtGroupFooter(group, subtotals); + } + + public T addSubtotalAtGroupFooter(final GroupBuilder group, final SubtotalBuilder... subtotals) + { + Validate.notNull(group, "group must not be null"); + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.GROUP_FOOTER).setGroup(group).build()); + } + return (T)this; + } + + public T subtotalsAtFirstGroupHeader(final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtFirstGroupHeader(subtotals); + } + + public T addSubtotalAtFirstGroupHeader(final SubtotalBuilder... subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.FIRST_GROUP_HEADER).build()); + } + return (T)this; + } + + public T subtotalsAtFirstGroupFooter(final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtFirstGroupFooter(subtotals); + } + + public T addSubtotalAtFirstGroupFooter(final SubtotalBuilder... subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.FIRST_GROUP_FOOTER).build()); + } + return (T)this; + } + + public T subtotalsAtLastGroupHeader(final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtLastGroupHeader(subtotals); + } + + public T addSubtotalAtLastGroupHeader(final SubtotalBuilder... subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.LAST_GROUP_HEADER).build()); + } + return (T)this; + } + + public T subtotalsAtLastGroupFooter(final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtLastGroupFooter(subtotals); + } + + public T addSubtotalAtLastGroupFooter(final SubtotalBuilder... subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.LAST_GROUP_FOOTER).build()); + } + return (T)this; + } + + public T subtotalsAtLastPageFooter(final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtLastPageFooter(subtotals); + } + + public T addSubtotalAtLastPageFooter(final SubtotalBuilder... subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.LAST_PAGE_FOOTER).build()); + } + return (T)this; + } + + public T subtotalsAtSummary(final SubtotalBuilder... subtotals) + { + return this.addSubtotalAtSummary(subtotals); + } + + public T addSubtotalAtSummary(final SubtotalBuilder... subtotals) + { + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final SubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.SUMMARY).build()); + } + return (T)this; + } + + public T subtotalsOfPercentageAtGroupHeader(final GroupBuilder group, final PercentageSubtotalBuilder... subtotals) + { + return this.addSubtotalOfPercentageAtGroupHeader(group, subtotals); + } + + public T addSubtotalOfPercentageAtGroupHeader(final GroupBuilder group, final PercentageSubtotalBuilder... subtotals) + { + Validate.notNull(group, "group must not be null"); + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final PercentageSubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.GROUP_HEADER).setGroup(group).build()); + } + return (T)this; + } + + public T subtotalsOfPercentageAtGroupFooter(final GroupBuilder group, final PercentageSubtotalBuilder... subtotals) + { + return this.addSubtotalOfPercentageAtGroupFooter(group, subtotals); + } + + public T addSubtotalOfPercentageAtGroupFooter(final GroupBuilder group, final PercentageSubtotalBuilder... subtotals) + { + Validate.notNull(group, "group must not be null"); + Validate.notNull(subtotals, "subtotals must not be null"); + Validate.noNullElements(subtotals, "subtotals must not contains null subtotal"); + for(final PercentageSubtotalBuilder subtotal : subtotals) + { + this.getObject().addSubtotal(subtotal.setPosition(SubtotalPosition.GROUP_FOOTER).setGroup(group).build()); + } + return (T)this; + } + + // group + public T groupBy(final ValueColumnBuilder... groupColumns) + { + Validate.notNull(groupColumns, "groupColumns must not be null"); + Validate.noNullElements(groupColumns, "groupColumns must not contains null groupColumn"); + for(final ValueColumnBuilder groupColumn : groupColumns) + { + this.addGroup(Groups.group(groupColumn)); + } + return (T)this; + } + + public T groupBy(final GroupBuilder... groups) + { + return this.addGroup(groups); + } + + public T addGroup(final GroupBuilder... groups) + { + Validate.notNull(groups, "groups must not be null"); + Validate.noNullElements(groups, "groups must not contains null group"); + for(final GroupBuilder group : groups) + { + this.getObject().addGroup(group.build()); + } + return (T)this; + } + + // table of contents + public T tableOfContents() + { + return this.setTableOfContents(true); + } + + public T tableOfContents(final TableOfContentsCustomizerBuilder tableOfContentsCustomizer) + { + return this.setTableOfContents(tableOfContentsCustomizer); + } + + public T tableOfContents(final DRITableOfContentsCustomizer tableOfContentsCustomizer) + { + return this.setTableOfContents(tableOfContentsCustomizer); + } + + public T setTableOfContents(final Boolean tableOfContents) + { + this.getObject().setTableOfContents(tableOfContents); + return (T)this; + } + + public T setTableOfContents(final TableOfContentsCustomizerBuilder tableOfContentsCustomizer) + { + this.getObject().setTableOfContentsCustomizer(tableOfContentsCustomizer.build()); + return this.setTableOfContents(true); + } + + public T setTableOfContents(final DRITableOfContentsCustomizer tableOfContentsCustomizer) + { + this.getObject().setTableOfContentsCustomizer(tableOfContentsCustomizer); + return this.setTableOfContents(true); + } + + /** + * Sets a dataset filter expression. The expression must be a type of Boolean + * + * @param filterExpression the filter expression + * @return a report builder + */ + public T setFilterExpression(final DRIExpression filterExpression) + { + this.getObject().setFilterExpression(filterExpression); + return (T)this; + } + + // title + + /** + * Sets the title band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the title split type + * @return a report builder + */ + public T setTitleSplitType(final SplitType splitType) + { + this.getObject().getTitleBand().setSplitType(splitType); + return (T)this; + } + + public T setTitlePrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getTitleBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a title band style + * + * @param style the title band style + * @return a report builder + */ + public T setTitleStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getTitleBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getTitleBand().getList().setStyle(null); + } + return (T)this; + } + + public T setTitleBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getTitleBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the title band. The band is printed on the first page and only once. + * + * @param components the title components + * @return a report builder + */ + public T title(final ComponentBuilder... components) + { + return this.addTitle(components); + } + + /** + * Adds components to the title band. The band is printed on the first page and only once. + * + * @param components the title components + * @return a report builder + */ + public T addTitle(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getTitleBand().addComponent(component.build()); + } + return (T)this; + } + + // page header band + + /** + * Sets the page header band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the page header split type + * @return a report builder + */ + public T setPageHeaderSplitType(final SplitType splitType) + { + this.getObject().getPageHeaderBand().setSplitType(splitType); + return (T)this; + } + + public T setPageHeaderPrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getPageHeaderBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a page header band style + * + * @param style the page header band style + * @return a report builder + */ + public T setPageHeaderStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getPageHeaderBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getPageHeaderBand().getList().setStyle(null); + } + return (T)this; + } + + public T setPageHeaderBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getPageHeaderBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the page header band. The band is printed on each page at the top of the page. + * + * @param components the page header components + * @return a report builder + */ + public T pageHeader(final ComponentBuilder... components) + { + return this.addPageHeader(components); + } + + /** + * Adds components to the page header band. The band is printed on each page at the top of the page. + * + * @param components the page header components + * @return a report builder + */ + public T addPageHeader(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getPageHeaderBand().addComponent(component.build()); + } + return (T)this; + } + + // page footer band + + /** + * Sets the page footer band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the page footer split type + * @return a report builder + */ + public T setPageFooterSplitType(final SplitType splitType) + { + this.getObject().getPageFooterBand().setSplitType(splitType); + return (T)this; + } + + public T setPageFooterPrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getPageFooterBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a page footer band style + * + * @param style the page footer band style + * @return a report builder + */ + public T setPageFooterStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getPageFooterBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getPageFooterBand().getList().setStyle(null); + } + return (T)this; + } + + public T setPageFooterBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getPageFooterBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the page footer band. The band is printed on each page at the bottom of the page. + * + * @param components the page footer components + * @return a report builder + */ + public T pageFooter(final ComponentBuilder... components) + { + return this.addPageFooter(components); + } + + /** + * Adds components to the page footer band. The band is printed on each page at the bottom of the page. + * + * @param components the page footer components + * @return a report builder + */ + public T addPageFooter(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getPageFooterBand().addComponent(component.build()); + } + return (T)this; + } + + // column header band + + /** + * Sets the column header band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the column header split type + * @return a report builder + */ + public T setColumnHeaderSplitType(final SplitType splitType) + { + this.getObject().getColumnHeaderBand().setSplitType(splitType); + return (T)this; + } + + public T setColumnHeaderPrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getColumnHeaderBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a column header band style + * + * @param style the column header band style + * @return a report builder + */ + public T setColumnHeaderStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getColumnHeaderBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getColumnHeaderBand().getList().setStyle(null); + } + return (T)this; + } + + public T setColumnHeaderBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getColumnHeaderBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the column header band. The band is printed on each page at the top of the page and it's + * placed below the page header band. + * + * @param components the column header components + * @return a report builder + */ + public T columnHeader(final ComponentBuilder... components) + { + return this.addColumnHeader(components); + } + + /** + * Adds components to the column header band. The band is printed on each page at the top of the page and it's + * placed below the page header band. + * + * @param components the column header components + * @return a report builder + */ + public T addColumnHeader(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getColumnHeaderBand().addComponent(component.build()); + } + return (T)this; + } + + // column footer band + + /** + * Sets the column footer band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the column footer split type + * @return a report builder + */ + public T setColumnFooterSplitType(final SplitType splitType) + { + this.getObject().getColumnFooterBand().setSplitType(splitType); + return (T)this; + } + + public T setColumnFooterPrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getColumnFooterBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a column footer band style + * + * @param style the column footer band style + * @return a report builder + */ + public T setColumnFooterStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getColumnFooterBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getColumnFooterBand().getList().setStyle(null); + } + return (T)this; + } + + public T setColumnFooterBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getColumnFooterBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the column footer band. The band is printed on each page at the bottom of the page and it's + * placed above the page footer band. + * + * @param components the column footer components + * @return a report builder + */ + public T columnFooter(final ComponentBuilder... components) + { + return this.addColumnFooter(components); + } + + /** + * Adds components to the column footer band. The band is printed on each page at the bottom of the page and it's + * placed above the page footer band. + * + * @param components the column footer components + * @return a report builder + */ + public T addColumnFooter(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getColumnFooterBand().addComponent(component.build()); + } + return (T)this; + } + + // group header band + + /** + * Sets the group header band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param group the group to which to apply the split type + * @param splitType the group header split type + * @return a report builder + */ + public T setGroupHeaderSplitType(final GroupBuilder group, final SplitType splitType) + { + Validate.notNull(group, "group must not be null"); + final int index = this.getObject().getGroups().indexOf(group.getGroup()); + Validate.isTrue(index >= 0, "group must be registered"); + final DRGroup drGroup = this.getObject().getGroups().get(index); + drGroup.getHeaderBand().setSplitType(splitType); + return (T)this; + } + + public T setGroupHeaderPrintWhenExpression(final GroupBuilder group, final DRIExpression printWhenExpression) + { + Validate.notNull(group, "group must not be null"); + final int index = this.getObject().getGroups().indexOf(group.getGroup()); + Validate.isTrue(index >= 0, "group must be registered"); + final DRGroup drGroup = this.getObject().getGroups().get(index); + drGroup.getHeaderBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a group header band style + * + * @param group the group to which to apply the style + * @param style the group header band style + * @return a report builder + */ + public T setGroupHeaderStyle(final GroupBuilder group, final ReportStyleBuilder style) + { + Validate.notNull(group, "group must not be null"); + final int index = this.getObject().getGroups().indexOf(group.getGroup()); + Validate.isTrue(index >= 0, "group must be registered"); + final DRGroup drGroup = this.getObject().getGroups().get(index); + if(style != null) + { + drGroup.getHeaderBand().getList().setStyle(style.build()); + } + else + { + drGroup.getHeaderBand().getList().setStyle(null); + } + return (T)this; + } + + public T setGroupHeaderBackgroundComponent(final GroupBuilder group, final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + Validate.notNull(group, "group must not be null"); + final int index = this.getObject().getGroups().indexOf(group.getGroup()); + Validate.isTrue(index >= 0, "group must be registered"); + final DRGroup drGroup = this.getObject().getGroups().get(index); + drGroup.getHeaderBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the group header band. The band is printed for each data group. It's placed above the grouped + * data and between the column header and footer. + * + * @param group the group to which to add the components + * @param components the group header components + * @return a report builder + */ + public T groupHeader(final GroupBuilder group, final ComponentBuilder... components) + { + return this.addGroupHeader(group, components); + } + + /** + * Adds components to the group header band. The band is printed for each data group. It's placed above the grouped + * data and between the column header and footer. + * + * @param group the group to which to add the components + * @param components the group header components + * @return a report builder + */ + public T addGroupHeader(final GroupBuilder group, final ComponentBuilder... components) + { + Validate.notNull(group, "group must not be null"); + final int index = this.getObject().getGroups().indexOf(group.getGroup()); + Validate.isTrue(index >= 0, "group must be registered"); + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + final DRGroup drGroup = this.getObject().getGroups().get(index); + for(final ComponentBuilder component : components) + { + drGroup.getHeaderBand().addComponent(component.build()); + } + return (T)this; + } + + // group footer band + + /** + * Sets the group footer band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param group the group to which to apply the split type + * @param splitType the group footer split type + * @return a report builder + */ + public T setGroupFooterSplitType(final GroupBuilder group, final SplitType splitType) + { + Validate.notNull(group, "group must not be null"); + final int index = this.getObject().getGroups().indexOf(group.getGroup()); + Validate.isTrue(index >= 0, "group must be registered"); + final DRGroup drGroup = this.getObject().getGroups().get(index); + drGroup.getFooterBand().setSplitType(splitType); + return (T)this; + } + + public T setGroupFooterPrintWhenExpression(final GroupBuilder group, final DRIExpression printWhenExpression) + { + Validate.notNull(group, "group must not be null"); + final int index = this.getObject().getGroups().indexOf(group.getGroup()); + Validate.isTrue(index >= 0, "group must be registered"); + final DRGroup drGroup = this.getObject().getGroups().get(index); + drGroup.getFooterBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a group footer band style + * + * @param group the group to which to apply the style + * @param style the group footer band style + * @return a report builder + */ + public T setGroupFooterStyle(final GroupBuilder group, final ReportStyleBuilder style) + { + Validate.notNull(group, "group must not be null"); + final int index = this.getObject().getGroups().indexOf(group.getGroup()); + Validate.isTrue(index >= 0, "group must be registered"); + final DRGroup drGroup = this.getObject().getGroups().get(index); + if(style != null) + { + drGroup.getFooterBand().getList().setStyle(style.build()); + } + else + { + drGroup.getFooterBand().getList().setStyle(null); + } + return (T)this; + } + + public T setGroupFooterBackgroundComponent(final GroupBuilder group, final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + Validate.notNull(group, "group must not be null"); + final int index = this.getObject().getGroups().indexOf(group.getGroup()); + Validate.isTrue(index >= 0, "group must be registered"); + final DRGroup drGroup = this.getObject().getGroups().get(index); + drGroup.getFooterBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the group footer band. The band is printed for each data group. It's placed below the grouped + * data and between the column header and footer. + * + * @param group the group to which to add the components + * @param components the group footer components + * @return a report builder + */ + public T groupFooter(final GroupBuilder group, final ComponentBuilder... components) + { + return this.addGroupFooter(group, components); + } + + /** + * Adds components to the group footer band. The band is printed for each data group. It's placed below the grouped + * data and between the column header and footer. + * + * @param group the group to which to add the components + * @param components the group footer components + * @return a report builder + */ + public T addGroupFooter(final GroupBuilder group, final ComponentBuilder... components) + { + Validate.notNull(group, "group must not be null"); + final int index = this.getObject().getGroups().indexOf(group.getGroup()); + Validate.isTrue(index >= 0, "group must be registered"); + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + final DRGroup drGroup = this.getObject().getGroups().get(index); + for(final ComponentBuilder component : components) + { + drGroup.getFooterBand().addComponent(component.build()); + } + return (T)this; + } + + // detail band + + /** + * Sets the detail band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the detail split type + * @return a report builder + */ + public T setDetailSplitType(final SplitType splitType) + { + this.getObject().getDetailBand().setSplitType(splitType); + return (T)this; + } + + public T setDetailPrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getDetailBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a detail band style + * + * @param style the detail band style + * @return a report builder + */ + public T setDetailStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getDetailBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getDetailBand().getList().setStyle(null); + } + return (T)this; + } + + public T setDetailBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getDetailBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the detail band. The band is printed for each record row in the data source and it's placed + * between the column header and footer band. + * + * @param components the detail components + * @return a report builder + */ + public T detail(final ComponentBuilder... components) + { + return this.addDetail(components); + } + + /** + * Adds components to the detail band. The band is printed for each record row in the data source and it's placed + * between the column header and footer band. + * + * @param components the detail components + * @return a report builder + */ + public T addDetail(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getDetailBand().addComponent(component.build()); + } + return (T)this; + } + + // detail header band + + /** + * Sets the detail header band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the detail header split type + * @return a report builder + */ + public T setDetailHeaderSplitType(final SplitType splitType) + { + this.getObject().getDetailHeaderBand().setSplitType(splitType); + return (T)this; + } + + public T setDetailHeaderPrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getDetailHeaderBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a detail header band style + * + * @param style the detail header band style + * @return a report builder + */ + public T setDetailHeaderStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getDetailHeaderBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getDetailHeaderBand().getList().setStyle(null); + } + return (T)this; + } + + public T setDetailHeaderBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getDetailHeaderBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the detail header band. The band is printed for each record row in the data source and it's + * placed above the detail band. + * + * @param components the detail header components + * @return a report builder + */ + public T detailHeader(final ComponentBuilder... components) + { + return this.addDetailHeader(components); + } + + /** + * Adds components to the detail header band. The band is printed for each record row in the data source and it's + * placed above the detail band. + * + * @param components the detail header components + * @return a report builder + */ + public T addDetailHeader(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getDetailHeaderBand().addComponent(component.build()); + } + return (T)this; + } + + // detail footer band + + /** + * Sets the detail footer band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the detail footer split type + * @return a report builder + */ + public T setDetailFooterSplitType(final SplitType splitType) + { + this.getObject().getDetailFooterBand().setSplitType(splitType); + return (T)this; + } + + public T setDetailFooterPrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getDetailFooterBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a detail footer band style + * + * @param style the detail footer band style + * @return a report builder + */ + public T setDetailFooterStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getDetailFooterBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getDetailFooterBand().getList().setStyle(null); + } + return (T)this; + } + + public T setDetailFooterBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getDetailFooterBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the detail footer band. The band is printed for each record row in the data source and it's + * placed below the detail band. + * + * @param components the detail footer components + * @return a report builder + */ + public T detailFooter(final ComponentBuilder... components) + { + return this.addDetailFooter(components); + } + + /** + * Adds components to the detail footer band. The band is printed for each record row in the data source and it's + * placed below the detail band. + * + * @param components the detail footer components + * @return a report builder + */ + public T addDetailFooter(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getDetailFooterBand().addComponent(component.build()); + } + return (T)this; + } + + // last page footer band + + /** + * Sets the last page footer band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the last page footer split type + * @return a report builder + */ + public T setLastPageFooterSplitType(final SplitType splitType) + { + this.getObject().getLastPageFooterBand().setSplitType(splitType); + return (T)this; + } + + public T setLastPageFooterPrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getLastPageFooterBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a last page footer band style + * + * @param style the last page footer band style + * @return a report builder + */ + public T setLastPageFooterStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getLastPageFooterBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getLastPageFooterBand().getList().setStyle(null); + } + return (T)this; + } + + public T setLastPageFooterBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getLastPageFooterBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the last page footer band. The band is printed only on the last page at the bottom of the + * page. + * + * @param components the last page footer components + * @return a report builder + */ + public T lastPageFooter(final ComponentBuilder... components) + { + return this.addLastPageFooter(components); + } + + /** + * Adds components to the last page footer band. The band is printed only on the last page at the bottom of the + * page. + * + * @param components the last page footer components + * @return a report builder + */ + public T addLastPageFooter(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getLastPageFooterBand().addComponent(component.build()); + } + return (T)this; + } + + // summary band + + /** + * Sets the summary band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the summary split type + * @return a report builder + */ + public T setSummarySplitType(final SplitType splitType) + { + this.getObject().getSummaryBand().setSplitType(splitType); + return (T)this; + } + + public T setSummaryPrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getSummaryBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a summary band style + * + * @param style the summary band style + * @return a report builder + */ + public T setSummaryStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getSummaryBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getSummaryBand().getList().setStyle(null); + } + return (T)this; + } + + public T setSummaryBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getSummaryBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the summary band. The band is printed on the last page and only once. + * + * @param components the summary components + * @return a report builder + */ + public T summary(final ComponentBuilder... components) + { + return this.addSummary(components); + } + + /** + * Adds components to the summary band. The band is printed on the last page and only once. + * + * @param components the summary components + * @return a report builder + */ + public T addSummary(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getSummaryBand().addComponent(component.build()); + } + return (T)this; + } + + // no data band + + /** + * Sets the no data band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the no data split type + * @return a report builder + */ + public T setNoDataSplitType(final SplitType splitType) + { + this.getObject().getNoDataBand().setSplitType(splitType); + return (T)this; + } + + public T setNoDataPrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getNoDataBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a no data band style + * + * @param style the no data band style + * @return a report builder + */ + public T setNoDataStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getNoDataBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getNoDataBand().getList().setStyle(null); + } + return (T)this; + } + + public T setNoDataBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getNoDataBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the no data band. The band is printed only when the data source is empty. It's used to show + * the information that there are not any data in the report. + * + * @param components the no data components + * @return a report builder + */ + public T noData(final ComponentBuilder... components) + { + return this.addNoData(components); + } + + /** + * Adds components to the no data band. The band is printed only when the data source is empty. It's used to show + * the information that there are not any data in the report. + * + * @param components the no data components + * @return a report builder + */ + public T addNoData(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getNoDataBand().addComponent(component.build()); + } + return (T)this; + } + + // background band + + /** + * Sets the background band split type.
+ * SplitType.PREVENT - prevents the band from splitting
+ * SplitType.STRETCH - the band can be split, but never within its declared height
+ * SplitType.IMMEDIATE - the band can be split + * + * @param splitType the background split type + * @return a report builder + */ + public T setBackgroundSplitType(final SplitType splitType) + { + this.getObject().getBackgroundBand().setSplitType(splitType); + return (T)this; + } + + public T setBackgroundPrintWhenExpression(final DRIExpression printWhenExpression) + { + this.getObject().getBackgroundBand().setPrintWhenExpression(printWhenExpression); + return (T)this; + } + + /** + * Sets a background band style + * + * @param style the background band style + * @return a report builder + */ + public T setBackgroundStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().getBackgroundBand().getList().setStyle(style.build()); + } + else + { + this.getObject().getBackgroundBand().getList().setStyle(null); + } + return (T)this; + } + + public T setBackgroundBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().getBackgroundBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T)this; + } + + /** + * Adds components to the background band. The band is printed on each page. It's mostly used for adding watermarks + * to the report. + * + * @param components the background components + * @return a report builder + */ + public T background(final ComponentBuilder... components) + { + return this.addBackground(components); + } + + /** + * Adds components to the background band. The band is printed on each page. It's mostly used for adding watermarks + * to the report. + * + * @param components the background components + * @return a report builder + */ + public T addBackground(final ComponentBuilder... components) + { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for(final ComponentBuilder component : components) + { + this.getObject().getBackgroundBand().addComponent(component.build()); + } + return (T)this; + } + + public DRReport getReport() + { + return this.build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/ReportTemplateBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/ReportTemplateBuilder.java new file mode 100644 index 0000000..bd8d501 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/ReportTemplateBuilder.java @@ -0,0 +1,1910 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import java.util.Locale; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.base.DRReportTemplate; +import software.xdev.dynamicreports.report.builder.component.ComponentBuilder; +import software.xdev.dynamicreports.report.builder.style.FontBuilder; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.builder.style.SimpleStyleBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder; +import software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.constant.Position; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer; + + +/** + *

ReportTemplateBuilder class.

+ * + * @author Ricardo Mariaca + */ +public class ReportTemplateBuilder extends AbstractBuilder +{ + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for ReportTemplateBuilder.

+ */ + protected ReportTemplateBuilder() + { + super(new DRReportTemplate()); + } + + // template style + + /** + *

templateStyles.

+ * + * @param templateStyles a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder templateStyles(final TemplateStylesBuilder... templateStyles) + { + return this.addTemplateStyle(templateStyles); + } + + /** + *

addTemplateStyle.

+ * + * @param templateStyles a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder addTemplateStyle(final TemplateStylesBuilder... templateStyles) + { + Validate.notNull(templateStyles, "templateStyles must not be null"); + Validate.noNullElements(templateStyles, "templateStyles must not contains null templateStyle"); + for(final TemplateStylesBuilder templateStyle : templateStyles) + { + for(final StyleBuilder style : templateStyle.getStyles()) + { + this.addTemplateStyle(style); + } + } + return this; + } + + /** + *

templateStyles.

+ * + * @param templateStyles a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder templateStyles(final StyleBuilder... templateStyles) + { + return this.addTemplateStyle(templateStyles); + } + + /** + *

addTemplateStyle.

+ * + * @param templateStyles a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder addTemplateStyle(final StyleBuilder... templateStyles) + { + Validate.notNull(templateStyles, "templateStyles must not be null"); + Validate.noNullElements(templateStyles, "templateStyles must not contains null templateStyle"); + for(final StyleBuilder templateStyle : templateStyles) + { + this.getObject().addTemplateStyle(templateStyle.build()); + } + return this; + } + + /** + *

setLocale.

+ * + * @param locale a {@link java.util.Locale} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setLocale(final Locale locale) + { + this.getObject().setLocale(locale); + return this; + } + + /** + *

setShowColumnTitle.

+ * + * @param showColumnTitle a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setShowColumnTitle(final Boolean showColumnTitle) + { + this.getObject().setShowColumnTitle(showColumnTitle); + return this; + } + + /** + *

setShowColumnValues.

+ * + * @param showColumnValues a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setShowColumnValues(final Boolean showColumnValues) + { + this.getObject().setShowColumnValues(showColumnValues); + return this; + } + + /** + *

ignorePagination.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder ignorePagination() + { + return this.setIgnorePagination(true); + } + + /** + *

setIgnorePagination.

+ * + * @param ignorePagination a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setIgnorePagination(final Boolean ignorePagination) + { + this.getObject().setIgnorePagination(ignorePagination); + return this; + } + + /** + *

setWhenNoDataType.

+ * + * @param whenNoDataType a {@link software.xdev.dynamicreports.report.constant.WhenNoDataType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setWhenNoDataType(final WhenNoDataType whenNoDataType) + { + this.getObject().setWhenNoDataType(whenNoDataType); + return this; + } + + /** + *

setWhenResourceMissingType.

+ * + * @param whenResourceMissingType a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setWhenResourceMissingType(final WhenResourceMissingType whenResourceMissingType) + { + this.getObject().setWhenResourceMissingType(whenResourceMissingType); + return this; + } + + /** + *

titleOnANewPage.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder titleOnANewPage() + { + return this.setTitleOnANewPage(true); + } + + /** + *

setTitleOnANewPage.

+ * + * @param titleOnANewPage a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setTitleOnANewPage(final Boolean titleOnANewPage) + { + this.getObject().setTitleOnANewPage(titleOnANewPage); + return this; + } + + /** + *

summaryOnANewPage.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder summaryOnANewPage() + { + return this.setSummaryOnANewPage(true); + } + + /** + *

setSummaryOnANewPage.

+ * + * @param summaryOnANewPage a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setSummaryOnANewPage(final Boolean summaryOnANewPage) + { + this.getObject().setSummaryOnANewPage(summaryOnANewPage); + return this; + } + + /** + *

summaryWithPageHeaderAndFooter.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder summaryWithPageHeaderAndFooter() + { + return this.setSummaryWithPageHeaderAndFooter(true); + } + + /** + *

setSummaryWithPageHeaderAndFooter.

+ * + * @param summaryWithPageHeaderAndFooter a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setSummaryWithPageHeaderAndFooter(final Boolean summaryWithPageHeaderAndFooter) + { + this.getObject().setSummaryWithPageHeaderAndFooter(summaryWithPageHeaderAndFooter); + return this; + } + + /** + *

floatColumnFooter.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder floatColumnFooter() + { + return this.setFloatColumnFooter(true); + } + + /** + *

setFloatColumnFooter.

+ * + * @param floatColumnFooter a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setFloatColumnFooter(final Boolean floatColumnFooter) + { + this.getObject().setFloatColumnFooter(floatColumnFooter); + return this; + } + + /** + *

setPrintOrder.

+ * + * @param printOrder a {@link software.xdev.dynamicreports.report.constant.Orientation} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPrintOrder(final Orientation printOrder) + { + this.getObject().setPrintOrder(printOrder); + return this; + } + + /** + *

setColumnDirection.

+ * + * @param columnDirection a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setColumnDirection(final RunDirection columnDirection) + { + this.getObject().setColumnDirection(columnDirection); + return this; + } + + /** + *

setLanguage.

+ * + * @param language a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setLanguage(final String language) + { + this.getObject().setLanguage(language); + return this; + } + + /** + *

setUseFieldNameAsDescription.

+ * + * @param useFieldNameAsDescription a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setUseFieldNameAsDescription(final Boolean useFieldNameAsDescription) + { + this.getObject().setUseFieldNameAsDescription(useFieldNameAsDescription); + return this; + } + + /** + *

highlightDetailOddRows.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder highlightDetailOddRows() + { + return this.setHighlightDetailOddRows(true); + } + + /** + *

setHighlightDetailOddRows.

+ * + * @param highlightDetailOddRows a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setHighlightDetailOddRows(final Boolean highlightDetailOddRows) + { + this.getObject().setHighlightDetailOddRows(highlightDetailOddRows); + return this; + } + + /** + *

setDetailOddRowStyle.

+ * + * @param detailOddRowStyle a {@link software.xdev.dynamicreports.report.builder.style.SimpleStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDetailOddRowStyle(final SimpleStyleBuilder detailOddRowStyle) + { + if(detailOddRowStyle != null) + { + this.getObject().setDetailOddRowStyle(detailOddRowStyle.build()); + } + else + { + this.getObject().setDetailOddRowStyle(null); + } + return this; + } + + /** + *

highlightDetailEvenRows.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder highlightDetailEvenRows() + { + return this.setHighlightDetailEvenRows(true); + } + + /** + *

setHighlightDetailEvenRows.

+ * + * @param highlightDetailEvenRows a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setHighlightDetailEvenRows(final Boolean highlightDetailEvenRows) + { + this.getObject().setHighlightDetailEvenRows(highlightDetailEvenRows); + return this; + } + + /** + *

setDetailEvenRowStyle.

+ * + * @param detailEvenRowStyle a {@link software.xdev.dynamicreports.report.builder.style.SimpleStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDetailEvenRowStyle(final SimpleStyleBuilder detailEvenRowStyle) + { + if(detailEvenRowStyle != null) + { + this.getObject().setDetailEvenRowStyle(detailEvenRowStyle.build()); + } + else + { + this.getObject().setDetailEvenRowStyle(null); + } + return this; + } + + /** + *

setDefaultFont.

+ * + * @param defaultFont a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDefaultFont(final FontBuilder defaultFont) + { + if(defaultFont != null) + { + this.getObject().setDefaultFont(defaultFont.build()); + } + else + { + this.getObject().setDefaultFont(null); + } + return this; + } + + /** + *

setTextStyle.

+ * + * @param textStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setTextStyle(final ReportStyleBuilder textStyle) + { + if(textStyle != null) + { + this.getObject().setTextStyle(textStyle.build()); + } + else + { + this.getObject().setTextStyle(null); + } + return this; + } + + /** + *

setColumnTitleStyle.

+ * + * @param columnTitleStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setColumnTitleStyle(final ReportStyleBuilder columnTitleStyle) + { + if(columnTitleStyle != null) + { + this.getObject().setColumnTitleStyle(columnTitleStyle.build()); + } + else + { + this.getObject().setColumnTitleStyle(null); + } + return this; + } + + /** + *

setColumnStyle.

+ * + * @param columnStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setColumnStyle(final ReportStyleBuilder columnStyle) + { + if(columnStyle != null) + { + this.getObject().setColumnStyle(columnStyle.build()); + } + else + { + this.getObject().setColumnStyle(null); + } + return this; + } + + /** + *

setGroupTitleStyle.

+ * + * @param groupTitleStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupTitleStyle(final ReportStyleBuilder groupTitleStyle) + { + if(groupTitleStyle != null) + { + this.getObject().setGroupTitleStyle(groupTitleStyle.build()); + } + else + { + this.getObject().setGroupTitleStyle(null); + } + return this; + } + + /** + *

setGroupStyle.

+ * + * @param groupStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupStyle(final ReportStyleBuilder groupStyle) + { + if(groupStyle != null) + { + this.getObject().setGroupStyle(groupStyle.build()); + } + else + { + this.getObject().setGroupStyle(null); + } + return this; + } + + /** + *

setSubtotalStyle.

+ * + * @param subtotalStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setSubtotalStyle(final ReportStyleBuilder subtotalStyle) + { + if(subtotalStyle != null) + { + this.getObject().setSubtotalStyle(subtotalStyle.build()); + } + else + { + this.getObject().setSubtotalStyle(null); + } + return this; + } + + /** + *

setImageStyle.

+ * + * @param imageStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setImageStyle(final ReportStyleBuilder imageStyle) + { + if(imageStyle != null) + { + this.getObject().setImageStyle(imageStyle.build()); + } + else + { + this.getObject().setImageStyle(null); + } + return this; + } + + /** + *

setPageFormat.

+ * + * @param pageType a {@link software.xdev.dynamicreports.report.constant.PageType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPageFormat(final PageType pageType) + { + return this.setPageFormat(pageType, PageOrientation.PORTRAIT); + } + + /** + *

setPageFormat.

+ * + * @param pageType a {@link software.xdev.dynamicreports.report.constant.PageType} object. + * @param orientation a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPageFormat(final PageType pageType, final PageOrientation orientation) + { + this.getObject().setPageFormat(pageType, orientation); + return this; + } + + /** + *

setPageMargin.

+ * + * @param pageMargin a {@link software.xdev.dynamicreports.report.builder.MarginBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPageMargin(final MarginBuilder pageMargin) + { + if(pageMargin != null) + { + this.getObject().setPageMargin(pageMargin.build()); + } + else + { + this.getObject().setPageMargin(null); + } + return this; + } + + /** + *

setPageColumnsPerPage.

+ * + * @param pageColumnsPerPage a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPageColumnsPerPage(final Integer pageColumnsPerPage) + { + this.getObject().setPageColumnsPerPage(pageColumnsPerPage); + return this; + } + + /** + *

setPageColumnSpace.

+ * + * @param pageColumnSpace a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPageColumnSpace(final Integer pageColumnSpace) + { + this.getObject().setPageColumnSpace(pageColumnSpace); + return this; + } + + /** + *

setIgnorePageWidth.

+ * + * @param ignorePageWidth a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setIgnorePageWidth(final Boolean ignorePageWidth) + { + this.getObject().setIgnorePageWidth(ignorePageWidth); + return this; + } + + /** + *

setColumnPrintRepeatedDetailValues.

+ * + * @param columnPrintRepeatedDetailValues a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setColumnPrintRepeatedDetailValues(final Boolean columnPrintRepeatedDetailValues) + { + this.getObject().setColumnPrintRepeatedDetailValues(columnPrintRepeatedDetailValues); + return this; + } + + /** + *

setColumnWidth.

+ * + * @param columnWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setColumnWidth(final Integer columnWidth) + { + this.getObject().setColumnWidth(columnWidth); + return this; + } + + /** + *

setGroupHeaderLayout.

+ * + * @param groupHeaderLayout a {@link software.xdev.dynamicreports.report.constant.GroupHeaderLayout} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupHeaderLayout(final GroupHeaderLayout groupHeaderLayout) + { + this.getObject().setGroupHeaderLayout(groupHeaderLayout); + return this; + } + + /** + *

setGroupHideColumn.

+ * + * @param groupHideColumn a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupHideColumn(final Boolean groupHideColumn) + { + this.getObject().setGroupHideColumn(groupHideColumn); + return this; + } + + /** + *

setGroupShowColumnHeaderAndFooter.

+ * + * @param groupShowColumnHeaderAndFooter a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupShowColumnHeaderAndFooter(final Boolean groupShowColumnHeaderAndFooter) + { + this.getObject().setGroupShowColumnHeaderAndFooter(groupShowColumnHeaderAndFooter); + return this; + } + + /** + *

setGroupPadding.

+ * + * @param groupPadding a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupPadding(final Integer groupPadding) + { + this.getObject().setGroupPadding(groupPadding); + return this; + } + + /** + *

setGroupStartInNewPage.

+ * + * @param groupStartInNewPage a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupStartInNewPage(final Boolean groupStartInNewPage) + { + this.getObject().setGroupStartInNewPage(groupStartInNewPage); + return this; + } + + /** + *

setGroupStartInNewColumn.

+ * + * @param groupStartInNewColumn a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupStartInNewColumn(final Boolean groupStartInNewColumn) + { + this.getObject().setGroupStartInNewColumn(groupStartInNewColumn); + return this; + } + + /** + *

setGroupReprintHeaderOnEachPage.

+ * + * @param groupReprintHeaderOnEachPage a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupReprintHeaderOnEachPage(final Boolean groupReprintHeaderOnEachPage) + { + this.getObject().setGroupReprintHeaderOnEachPage(groupReprintHeaderOnEachPage); + return this; + } + + /** + *

setGroupResetPageNumber.

+ * + * @param groupResetPageNumber a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupResetPageNumber(final Boolean groupResetPageNumber) + { + this.getObject().setGroupResetPageNumber(groupResetPageNumber); + return this; + } + + /** + *

setGroupFooterPosition.

+ * + * @param groupFooterPosition a {@link software.xdev.dynamicreports.report.constant.GroupFooterPosition} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupFooterPosition(final GroupFooterPosition groupFooterPosition) + { + this.getObject().setGroupFooterPosition(groupFooterPosition); + return this; + } + + /** + *

setGroupKeepTogether.

+ * + * @param groupKeepTogether a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupKeepTogether(final Boolean groupKeepTogether) + { + this.getObject().setGroupKeepTogether(groupKeepTogether); + return this; + } + + /** + *

setGroupHeaderWithSubtotal.

+ * + * @param groupHeaderWithSubtotal a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupHeaderWithSubtotal(final Boolean groupHeaderWithSubtotal) + { + this.getObject().setGroupHeaderWithSubtotal(groupHeaderWithSubtotal); + return this; + } + + /** + *

setSubtotalLabelPosition.

+ * + * @param subtotalLabelPosition a {@link software.xdev.dynamicreports.report.constant.Position} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setSubtotalLabelPosition(final Position subtotalLabelPosition) + { + this.getObject().setSubtotalLabelPosition(subtotalLabelPosition); + return this; + } + + /** + *

tableOfContents.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder tableOfContents() + { + return this.setTableOfContents(true); + } + + /** + *

setTableOfContents.

+ * + * @param tableOfContents a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setTableOfContents(final Boolean tableOfContents) + { + this.getObject().setTableOfContents(tableOfContents); + return this; + } + + /** + *

setTableOfContentsCustomizer.

+ * + * @param tableOfContentsCustomizer a + * {@link + * + * + * + * + * + * + * + * software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder} + * object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setTableOfContentsCustomizer(final TableOfContentsCustomizerBuilder tableOfContentsCustomizer) + { + this.getObject().setTableOfContentsCustomizer(tableOfContentsCustomizer.build()); + return this; + } + + /** + *

setTableOfContentsCustomizer.

+ * + * @param tableOfContentsCustomizer a {@link software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer} + * object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setTableOfContentsCustomizer(final DRITableOfContentsCustomizer tableOfContentsCustomizer) + { + this.getObject().setTableOfContentsCustomizer(tableOfContentsCustomizer); + return this; + } + + /** + *

setTextFieldWidth.

+ * + * @param textFieldWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setTextFieldWidth(final Integer textFieldWidth) + { + this.getObject().setTextFieldWidth(textFieldWidth); + return this; + } + + /** + *

setImageHeight.

+ * + * @param imageHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setImageHeight(final Integer imageHeight) + { + this.getObject().setImageHeight(imageHeight); + return this; + } + + /** + *

setImageWidth.

+ * + * @param imageWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setImageWidth(final Integer imageWidth) + { + this.getObject().setImageWidth(imageWidth); + return this; + } + + /** + *

setListgap.

+ * + * @param listgap a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setListgap(final Integer listgap) + { + this.getObject().setListgap(listgap); + return this; + } + + /** + *

setMultiPageListHeight.

+ * + * @param multiPageListHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setMultiPageListHeight(final Integer multiPageListHeight) + { + this.getObject().setMultiPageListHeight(multiPageListHeight); + return this; + } + + /** + *

setMultiPageListWidth.

+ * + * @param multiPageListWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setMultiPageListWidth(final Integer multiPageListWidth) + { + this.getObject().setMultiPageListWidth(multiPageListWidth); + return this; + } + + /** + *

setSubreportHeight.

+ * + * @param subreportHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setSubreportHeight(final Integer subreportHeight) + { + this.getObject().setSubreportHeight(subreportHeight); + return this; + } + + /** + *

setSubreportWidth.

+ * + * @param subreportWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setSubreportWidth(final Integer subreportWidth) + { + this.getObject().setSubreportWidth(subreportWidth); + return this; + } + + /** + *

setCrosstabHeight.

+ * + * @param crosstabHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setCrosstabHeight(final Integer crosstabHeight) + { + this.getObject().setCrosstabHeight(crosstabHeight); + return this; + } + + /** + *

setCrosstabWidth.

+ * + * @param crosstabWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setCrosstabWidth(final Integer crosstabWidth) + { + this.getObject().setCrosstabWidth(crosstabWidth); + return this; + } + + /** + *

crosstabHighlightOddRows.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder crosstabHighlightOddRows() + { + return this.setCrosstabHighlightOddRows(true); + } + + /** + *

setCrosstabHighlightOddRows.

+ * + * @param crosstabHighlightOddRows a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setCrosstabHighlightOddRows(final Boolean crosstabHighlightOddRows) + { + this.getObject().setCrosstabHighlightOddRows(crosstabHighlightOddRows); + return this; + } + + /** + *

setCrosstabOddRowStyle.

+ * + * @param crosstabOddRowStyle a {@link software.xdev.dynamicreports.report.builder.style.SimpleStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setCrosstabOddRowStyle(final SimpleStyleBuilder crosstabOddRowStyle) + { + if(crosstabOddRowStyle != null) + { + this.getObject().setCrosstabOddRowStyle(crosstabOddRowStyle.build()); + } + else + { + this.getObject().setCrosstabOddRowStyle(null); + } + return this; + } + + /** + *

crosstabHighlightEvenRows.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder crosstabHighlightEvenRows() + { + return this.setCrosstabHighlightEvenRows(true); + } + + /** + *

setCrosstabHighlightEvenRows.

+ * + * @param crosstabHighlightEvenRows a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setCrosstabHighlightEvenRows(final Boolean crosstabHighlightEvenRows) + { + this.getObject().setCrosstabHighlightEvenRows(crosstabHighlightEvenRows); + return this; + } + + /** + *

setCrosstabEvenRowStyle.

+ * + * @param crosstabEvenRowStyle a {@link software.xdev.dynamicreports.report.builder.style.SimpleStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setCrosstabEvenRowStyle(final SimpleStyleBuilder crosstabEvenRowStyle) + { + if(crosstabEvenRowStyle != null) + { + this.getObject().setCrosstabEvenRowStyle(crosstabEvenRowStyle.build()); + } + else + { + this.getObject().setCrosstabEvenRowStyle(null); + } + return this; + } + + /** + *

setCrosstabGroupStyle.

+ * + * @param crosstabGroupStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setCrosstabGroupStyle(final ReportStyleBuilder crosstabGroupStyle) + { + if(crosstabGroupStyle != null) + { + this.getObject().setCrosstabGroupStyle(crosstabGroupStyle.build()); + } + else + { + this.getObject().setCrosstabGroupStyle(null); + } + return this; + } + + /** + *

setCrosstabGroupTotalStyle.

+ * + * @param crosstabGroupTotalStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setCrosstabGroupTotalStyle(final ReportStyleBuilder crosstabGroupTotalStyle) + { + if(crosstabGroupTotalStyle != null) + { + this.getObject().setCrosstabGroupTotalStyle(crosstabGroupTotalStyle.build()); + } + else + { + this.getObject().setCrosstabGroupTotalStyle(null); + } + return this; + } + + /** + *

setCrosstabGrandTotalStyle.

+ * + * @param crosstabGrandTotalStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setCrosstabGrandTotalStyle(final ReportStyleBuilder crosstabGrandTotalStyle) + { + if(crosstabGrandTotalStyle != null) + { + this.getObject().setCrosstabGrandTotalStyle(crosstabGrandTotalStyle.build()); + } + else + { + this.getObject().setCrosstabGrandTotalStyle(null); + } + return this; + } + + /** + *

setCrosstabCellStyle.

+ * + * @param crosstabCellStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setCrosstabCellStyle(final ReportStyleBuilder crosstabCellStyle) + { + if(crosstabCellStyle != null) + { + this.getObject().setCrosstabCellStyle(crosstabCellStyle.build()); + } + else + { + this.getObject().setCrosstabCellStyle(null); + } + return this; + } + + /** + *

setCrosstabMeasureTitleStyle.

+ * + * @param crosstabMeasureTitleStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setCrosstabMeasureTitleStyle(final ReportStyleBuilder crosstabMeasureTitleStyle) + { + if(crosstabMeasureTitleStyle != null) + { + this.getObject().setCrosstabMeasureTitleStyle(crosstabMeasureTitleStyle.build()); + } + else + { + this.getObject().setCrosstabMeasureTitleStyle(null); + } + return this; + } + + /** + *

setBooleanComponentType.

+ * + * @param booleanComponentType a {@link software.xdev.dynamicreports.report.constant.BooleanComponentType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setBooleanComponentType(final BooleanComponentType booleanComponentType) + { + this.getObject().setBooleanComponentType(booleanComponentType); + return this; + } + + /** + *

setBooleanEmptyWhenNullValue.

+ * + * @param booleanEmptyWhenNullValue a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setBooleanEmptyWhenNullValue(final Boolean booleanEmptyWhenNullValue) + { + this.getObject().setBooleanEmptyWhenNullValue(booleanEmptyWhenNullValue); + return this; + } + + /** + * Use setBooleanImageWidth(Integer booleanImageWidth) + * + * @param booleanColumnImageWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + @Deprecated + public ReportTemplateBuilder setBooleanColumnImageWidth(final Integer booleanColumnImageWidth) + { + return this.setBooleanImageWidth(booleanColumnImageWidth); + } + + /** + *

setBooleanImageWidth.

+ * + * @param booleanImageWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setBooleanImageWidth(final Integer booleanImageWidth) + { + this.getObject().setBooleanImageWidth(booleanImageWidth); + return this; + } + + /** + * Use setBooleanImageHeight(Integer booleanImageHeight) + * + * @param booleanColumnImageHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + @Deprecated + public ReportTemplateBuilder setBooleanColumnImageHeight(final Integer booleanColumnImageHeight) + { + return this.setBooleanImageHeight(booleanColumnImageHeight); + } + + /** + *

setBooleanImageHeight.

+ * + * @param booleanImageHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setBooleanImageHeight(final Integer booleanImageHeight) + { + this.getObject().setBooleanImageHeight(booleanImageHeight); + return this; + } + + /** + *

setBooleanColumnStyle.

+ * + * @param cooleanColumnStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setBooleanColumnStyle(final ReportStyleBuilder cooleanColumnStyle) + { + if(cooleanColumnStyle != null) + { + this.getObject().setBooleanColumnStyle(cooleanColumnStyle.build()); + } + else + { + this.getObject().setBooleanColumnStyle(null); + } + return this; + } + + // band split type + + /** + *

setDefaultSplitType.

+ * + * @param defaultSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDefaultSplitType(final SplitType defaultSplitType) + { + this.getObject().setDefaultSplitType(defaultSplitType); + return this; + } + + /** + *

setTitleSplitType.

+ * + * @param titleSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setTitleSplitType(final SplitType titleSplitType) + { + this.getObject().setTitleSplitType(titleSplitType); + return this; + } + + /** + *

setPageHeaderSplitType.

+ * + * @param pageHeaderSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPageHeaderSplitType(final SplitType pageHeaderSplitType) + { + this.getObject().setPageHeaderSplitType(pageHeaderSplitType); + return this; + } + + /** + *

setPageFooterSplitType.

+ * + * @param pageFooterSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPageFooterSplitType(final SplitType pageFooterSplitType) + { + this.getObject().setPageFooterSplitType(pageFooterSplitType); + return this; + } + + /** + *

setColumnHeaderSplitType.

+ * + * @param columnHeaderSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setColumnHeaderSplitType(final SplitType columnHeaderSplitType) + { + this.getObject().setColumnHeaderSplitType(columnHeaderSplitType); + return this; + } + + /** + *

setColumnFooterSplitType.

+ * + * @param columnFooterSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setColumnFooterSplitType(final SplitType columnFooterSplitType) + { + this.getObject().setColumnFooterSplitType(columnFooterSplitType); + return this; + } + + /** + *

setGroupHeaderSplitType.

+ * + * @param groupHeaderSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupHeaderSplitType(final SplitType groupHeaderSplitType) + { + this.getObject().setGroupHeaderSplitType(groupHeaderSplitType); + return this; + } + + /** + *

setGroupFooterSplitType.

+ * + * @param groupFooterSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupFooterSplitType(final SplitType groupFooterSplitType) + { + this.getObject().setGroupFooterSplitType(groupFooterSplitType); + return this; + } + + /** + *

setDetailHeaderSplitType.

+ * + * @param detailHeaderSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDetailHeaderSplitType(final SplitType detailHeaderSplitType) + { + this.getObject().setDetailHeaderSplitType(detailHeaderSplitType); + return this; + } + + /** + *

setDetailSplitType.

+ * + * @param detailSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDetailSplitType(final SplitType detailSplitType) + { + this.getObject().setDetailSplitType(detailSplitType); + return this; + } + + /** + *

setDetailFooterSplitType.

+ * + * @param detailFooterSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDetailFooterSplitType(final SplitType detailFooterSplitType) + { + this.getObject().setDetailFooterSplitType(detailFooterSplitType); + return this; + } + + /** + *

setLastPageFooterSplitType.

+ * + * @param lastPageFooterSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setLastPageFooterSplitType(final SplitType lastPageFooterSplitType) + { + this.getObject().setLastPageFooterSplitType(lastPageFooterSplitType); + return this; + } + + /** + *

setSummarySplitType.

+ * + * @param summarySplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setSummarySplitType(final SplitType summarySplitType) + { + this.getObject().setSummarySplitType(summarySplitType); + return this; + } + + /** + *

setNoDataSplitType.

+ * + * @param noDataSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setNoDataSplitType(final SplitType noDataSplitType) + { + this.getObject().setNoDataSplitType(noDataSplitType); + return this; + } + + /** + *

setBackgroundSplitType.

+ * + * @param backgroundSplitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setBackgroundSplitType(final SplitType backgroundSplitType) + { + this.getObject().setBackgroundSplitType(backgroundSplitType); + return this; + } + + // band style + + /** + *

setTitleStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setTitleStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setTitleStyle(style.build()); + } + else + { + this.getObject().setTitleStyle(null); + } + return this; + } + + /** + *

setPageHeaderStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPageHeaderStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setPageHeaderStyle(style.build()); + } + else + { + this.getObject().setPageHeaderStyle(null); + } + return this; + } + + /** + *

setPageFooterStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPageFooterStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setPageFooterStyle(style.build()); + } + else + { + this.getObject().setPageFooterStyle(null); + } + return this; + } + + /** + *

setColumnHeaderStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setColumnHeaderStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setColumnHeaderStyle(style.build()); + } + else + { + this.getObject().setColumnHeaderStyle(null); + } + return this; + } + + /** + *

setColumnFooterStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setColumnFooterStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setColumnFooterStyle(style.build()); + } + else + { + this.getObject().setColumnFooterStyle(null); + } + return this; + } + + /** + *

setGroupHeaderStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupHeaderStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setGroupHeaderStyle(style.build()); + } + else + { + this.getObject().setGroupHeaderStyle(null); + } + return this; + } + + /** + *

setGroupFooterStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupFooterStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setGroupFooterStyle(style.build()); + } + else + { + this.getObject().setGroupFooterStyle(null); + } + return this; + } + + /** + *

setDetailHeaderStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDetailHeaderStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setDetailHeaderStyle(style.build()); + } + else + { + this.getObject().setDetailHeaderStyle(null); + } + return this; + } + + /** + *

setDetailStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDetailStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setDetailStyle(style.build()); + } + else + { + this.getObject().setDetailStyle(null); + } + return this; + } + + /** + *

setDetailFooterStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDetailFooterStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setDetailFooterStyle(style.build()); + } + else + { + this.getObject().setDetailFooterStyle(null); + } + return this; + } + + /** + *

setLastPageFooterStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setLastPageFooterStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setLastPageFooterStyle(style.build()); + } + else + { + this.getObject().setLastPageFooterStyle(null); + } + return this; + } + + /** + *

setSummaryStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setSummaryStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setSummaryStyle(style.build()); + } + else + { + this.getObject().setSummaryStyle(null); + } + return this; + } + + /** + *

setNoDataStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setNoDataStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setNoDataStyle(style.build()); + } + else + { + this.getObject().setNoDataStyle(null); + } + return this; + } + + /** + *

setBackgroundStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setBackgroundStyle(final ReportStyleBuilder style) + { + if(style != null) + { + this.getObject().setBackgroundStyle(style.build()); + } + else + { + this.getObject().setBackgroundStyle(null); + } + return this; + } + + /** + *

setTitleBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setTitleBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setTitleBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setPageHeaderBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPageHeaderBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setPageHeaderBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setPageFooterBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setPageFooterBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setPageFooterBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setColumnHeaderBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setColumnHeaderBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setColumnHeaderBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setColumnFooterBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setColumnFooterBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setColumnFooterBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setGroupHeaderBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupHeaderBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setGroupHeaderBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setGroupFooterBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setGroupFooterBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setGroupFooterBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setDetailHeaderBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDetailHeaderBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setDetailHeaderBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setDetailBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDetailBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setDetailBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setDetailFooterBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setDetailFooterBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setDetailFooterBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setLastPageFooterBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setLastPageFooterBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setLastPageFooterBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setSummaryBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setSummaryBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setSummaryBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setNoDataBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setNoDataBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setNoDataBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setBackgroundBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.ReportTemplateBuilder} object. + */ + public ReportTemplateBuilder setBackgroundBackgroundComponent(final ComponentBuilder backgroundComponent) + { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + this.getObject().setBackgroundBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

getReportTemplate.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRReportTemplate} object. + */ + public DRReportTemplate getReportTemplate() + { + return this.build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/SortBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/SortBuilder.java new file mode 100644 index 0000000..18de84f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/SortBuilder.java @@ -0,0 +1,89 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import software.xdev.dynamicreports.report.base.DRSort; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.OrderType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + *

SortBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class SortBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for SortBuilder.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.TextColumnBuilder} object. + */ + protected SortBuilder(TextColumnBuilder column) { + super(new DRSort()); + Validate.notNull(column, "column must not be null"); + getObject().setExpression(column.build()); + } + + /** + *

Constructor for SortBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + protected SortBuilder(FieldBuilder field) { + super(new DRSort()); + Validate.notNull(field, "field must not be null"); + getObject().setExpression(field.build()); + } + + /** + *

Constructor for SortBuilder.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + protected SortBuilder(VariableBuilder variable) { + super(new DRSort()); + Validate.notNull(variable, "variable must not be null"); + getObject().setExpression(variable.build()); + } + + /** + *

Constructor for SortBuilder.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected SortBuilder(DRIExpression expression) { + super(new DRSort()); + getObject().setExpression(expression); + } + + /** + *

setOrderType.

+ * + * @param orderType a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.SortBuilder} object. + */ + public SortBuilder setOrderType(OrderType orderType) { + getObject().setOrderType(orderType); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/Units.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/Units.java new file mode 100644 index 0000000..a18e971 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/Units.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +/** + * A set of methods of converting unit values to pixels. + * + * @author Ricardo Mariaca + * + */ +public class Units { + + /** + * Converts a value in centimeters to pixels. + * + * @param value - the value in centimeters + * @return pixels + */ + public static int cm(Number value) { + return unit(value, 28.3464); + } + + /** + * Converts a value in inches to pixels. + * + * @param value - the value in inches + * @return pixels + */ + public static int inch(Number value) { + return unit(value, 72); + } + + /** + * Converts a value in milimeters to pixels. + * + * @param value - the value in milimeters + * @return pixels + */ + public static int mm(Number value) { + return unit(value, 2.83464); + } + + private static int unit(Number value, double unitValue) { + if (value != null) { + return (int) ((value.doubleValue()) * unitValue); + } + return 0; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/VariableBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/VariableBuilder.java new file mode 100644 index 0000000..12fcb9e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/VariableBuilder.java @@ -0,0 +1,160 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder; + +import software.xdev.dynamicreports.report.base.DRVariable; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIJasperExpression; + +/** + *

VariableBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class VariableBuilder extends AbstractBuilder, DRVariable> implements DRIValue { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + // column + + /** + *

Constructor for VariableBuilder.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected VariableBuilder(ValueColumnBuilder column, Calculation calculation) { + super(new DRVariable(column.build(), calculation)); + } + + /** + *

Constructor for VariableBuilder.

+ * + * @param name a {@link java.lang.String} object. + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected VariableBuilder(String name, ValueColumnBuilder column, Calculation calculation) { + super(new DRVariable(name, column.build(), calculation)); + } + + // field + + /** + *

Constructor for VariableBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected VariableBuilder(FieldBuilder field, Calculation calculation) { + super(new DRVariable(field.getField(), calculation)); + } + + /** + *

Constructor for VariableBuilder.

+ * + * @param name a {@link java.lang.String} object. + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected VariableBuilder(String name, FieldBuilder field, Calculation calculation) { + super(new DRVariable(name, field.getField(), calculation)); + } + + // simple expression + + /** + *

Constructor for VariableBuilder.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected VariableBuilder(DRIExpression expression, Calculation calculation) { + super(new DRVariable(expression, calculation)); + } + + /** + *

Constructor for VariableBuilder.

+ * + * @param name a {@link java.lang.String} object. + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected VariableBuilder(String name, DRIExpression expression, Calculation calculation) { + super(new DRVariable(name, expression, calculation)); + } + + /** + *

setInitialValueExpression.

+ * + * @param initialValueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIJasperExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + public VariableBuilder setInitialValueExpression(DRIJasperExpression initialValueExpression) { + getObject().setInitialValueExpression(initialValueExpression); + return this; + } + + /** + *

setResetType.

+ * + * @param resetType a {@link software.xdev.dynamicreports.report.constant.Evaluation} object. + * @return a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + public VariableBuilder setResetType(Evaluation resetType) { + getObject().setResetType(resetType); + return this; + } + + /** + *

setResetGroup.

+ * + * @param resetGroup a {@link software.xdev.dynamicreports.report.builder.group.GroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + public VariableBuilder setResetGroup(GroupBuilder resetGroup) { + if (resetGroup != null) { + getObject().setResetGroup(resetGroup.getGroup()); + setResetType(Evaluation.GROUP); + } else { + getObject().setResetGroup(null); + } + return this; + } + + /** + *

getVariable.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRVariable} object. + */ + public DRVariable getVariable() { + return build(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return getVariable().getName(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/BooleanColumnBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/BooleanColumnBuilder.java new file mode 100644 index 0000000..f361333 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/BooleanColumnBuilder.java @@ -0,0 +1,248 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.column; + +import software.xdev.dynamicreports.report.base.column.DRBooleanColumn; +import software.xdev.dynamicreports.report.base.component.DRBooleanField; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + * It shows a boolean value either as a text or as an image. + * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings("deprecation") +public class BooleanColumnBuilder extends ColumnBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for BooleanColumnBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + protected BooleanColumnBuilder(FieldBuilder field) { + super(new DRBooleanColumn(new DRBooleanField())); + Validate.notNull(field, "field must not be null"); + getComponent().setValueExpression(field.getField()); + } + + /** + *

Constructor for BooleanColumnBuilder.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected BooleanColumnBuilder(DRIExpression valueExpression) { + super(new DRBooleanColumn(new DRBooleanField())); + getComponent().setValueExpression(valueExpression); + } + + /** + * Sets the preferred width of a column. + * + * @param width the column preferred width >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public BooleanColumnBuilder setWidth(Integer width) { + getComponent().setWidth(width); + return this; + } + + /** + * Sets the fixed width of a column. + * + * @param width the column fixed width >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public BooleanColumnBuilder setFixedWidth(Integer width) { + getComponent().setWidth(width); + getComponent().setWidthType(ComponentDimensionType.FIXED); + return this; + } + + /** + * Sets the minimum width of a column. + * + * @param width the column minimum width >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public BooleanColumnBuilder setMinWidth(Integer width) { + getComponent().setWidth(width); + getComponent().setWidthType(ComponentDimensionType.EXPAND); + return this; + } + + /** + * Sets the preferred height of a column. + * + * @param height the column preferred height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public BooleanColumnBuilder setHeight(Integer height) { + getComponent().setHeight(height); + return this; + } + + /** + * Sets the fixed height of a column. + * + * @param height the column fixed height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public BooleanColumnBuilder setFixedHeight(Integer height) { + getComponent().setHeight(height); + getComponent().setHeightType(ComponentDimensionType.FIXED); + return this; + } + + /** + * Sets the minimum height of a column. + * + * @param height the column minimum height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public BooleanColumnBuilder setMinHeight(Integer height) { + getComponent().setHeight(height); + getComponent().setHeightType(ComponentDimensionType.EXPAND); + return this; + } + + /** + * Sets the boolean presentation type.
+ * BooleanComponentType.TEXT_* - shows a text value
+ * BooleanComponentType.IMAGE_* - shows an image + * + * @param booleanComponentType the component type + * @return a column builder + */ + public BooleanColumnBuilder setComponentType(BooleanComponentType booleanComponentType) { + getComponent().setComponentType(booleanComponentType); + return this; + } + + /** + *

setEmptyWhenNullValue.

+ * + * @param emptyWhenNullValue a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.column.BooleanColumnBuilder} object. + */ + public BooleanColumnBuilder setEmptyWhenNullValue(Boolean emptyWhenNullValue) { + getComponent().setEmptyWhenNullValue(emptyWhenNullValue); + return this; + } + + /** + * Sets the boolean image dimension. Has effect only when the boolean value is presented as an image. + * + * @param width the image width + * @param height the image height + * @return a column builder + */ + public BooleanColumnBuilder setImageDimension(Integer width, Integer height) { + getComponent().setImageWidth(width); + getComponent().setImageHeight(height); + return this; + } + + /** + * Sets the boolean image width. Has effect only when the boolean value is presented as an image. + * + * @param width the image width + * @return a column builder + */ + public BooleanColumnBuilder setImageWidth(Integer width) { + getComponent().setImageWidth(width); + return this; + } + + /** + * Sets the boolean image height. Has effect only when the boolean value is presented as an image. + * + * @param height the image height + * @return a column builder + */ + public BooleanColumnBuilder setImageHeight(Integer height) { + getComponent().setImageHeight(height); + return this; + } + + /** + * Sets the column value horizontal alignment. + * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalAlignment} object. + * @return a column builder + * @deprecated use setHorizontalImageAlignment instead + */ + @Deprecated + public BooleanColumnBuilder setHorizontalAlignment(HorizontalAlignment horizontalAlignment) { + if (horizontalAlignment != null) { + getComponent().setHorizontalImageAlignment(HorizontalImageAlignment.valueOf(horizontalAlignment.name())); + } else { + getComponent().setHorizontalImageAlignment(null); + } + return this; + } + + /** + * Sets the column value horizontal image alignment. + * + * @param horizontalImageAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + * @return a column builder + */ + public BooleanColumnBuilder setHorizontalImageAlignment(HorizontalImageAlignment horizontalImageAlignment) { + getComponent().setHorizontalImageAlignment(horizontalImageAlignment); + return this; + } + + /** + * Sets the column value horizontal text alignment. + * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + * @return a column builder + */ + public BooleanColumnBuilder setHorizontalTextAlignment(HorizontalTextAlignment horizontalTextAlignment) { + getComponent().setHorizontalTextAlignment(horizontalTextAlignment); + return this; + } + + /** {@inheritDoc} */ + @Override + protected DRBooleanField getComponent() { + return (DRBooleanField) getObject().getComponent(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ColumnBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ColumnBuilder.java new file mode 100644 index 0000000..022b067 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ColumnBuilder.java @@ -0,0 +1,269 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.column; + +import software.xdev.dynamicreports.report.base.column.DRColumn; +import software.xdev.dynamicreports.report.base.component.DRComponent; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; + +/** + *

Abstract ColumnBuilder class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +@SuppressWarnings("unchecked") +public abstract class ColumnBuilder, U extends DRColumn> extends AbstractBuilder implements ColumnGridComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for ColumnBuilder.

+ * + * @param column a U object. + */ + protected ColumnBuilder(final U column) { + super(column); + } + + /** + * Sets the column title. + * + * @param titleExpression the title expression + * @return a column builder + */ + public T setTitle(final DRIExpression titleExpression) { + getObject().setTitleExpression(titleExpression); + return (T) this; + } + + /** + * Sets the column title. + * + * @param title the title + * @return a column builder + */ + public T setTitle(final String title) { + getObject().setTitleExpression(Expressions.text(title)); + return (T) this; + } + + /** + * Sets the column title style. + * + * @param titleStyle the title style + * @return a column builder + */ + public T setTitleStyle(final ReportStyleBuilder titleStyle) { + if (titleStyle != null) { + getObject().setTitleStyle(titleStyle.getStyle()); + } else { + getObject().setTitleStyle(null); + } + return (T) this; + } + + /** + * Sets the column value style. + * + * @param style the value style + * @return a column builder + */ + public T setStyle(final ReportStyleBuilder style) { + if (style != null) { + getComponent().setStyle(style.getStyle()); + } else { + getComponent().setStyle(null); + } + return (T) this; + } + + /** + * Sets the print when expression. The expression must be a type of Boolean and it decides whether or not a column value will be printed. + * + * @param printWhenExpression the print expression + * @return a column builder + */ + public T setPrintWhenExpression(final DRIExpression printWhenExpression) { + getComponent().setPrintWhenExpression(printWhenExpression); + return (T) this; + } + + /** + * This method is used to define the preferred height of a column title. The height is set to the rows multiplied by height of the font + * + * @param rows the number of preferred rows >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public T setTitleRows(final Integer rows) { + getObject().setTitleRows(rows); + return (T) this; + } + + /** + * This method is used to define the fixed height of a column title. The height is set to the rows multiplied by height of the font + * + * @param rows the number of fixed rows >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public T setTitleFixedRows(final Integer rows) { + getObject().setTitleRows(rows); + getObject().setTitleHeightType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + * This method is used to define the minimum height of a column title. The height is set to the rows multiplied by height of the font + * + * @param rows the number of minimum rows >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public T setTitleMinRows(final Integer rows) { + getObject().setTitleRows(rows); + getObject().setTitleHeightType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + * Sets the preferred height of a column title. + * + * @param height the column title preferred height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setTitleHeight(final Integer height) { + getObject().setTitleHeight(height); + return (T) this; + } + + /** + * Sets the fixed height of a column title. + * + * @param height the column title fixed height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setTitleFixedHeight(final Integer height) { + getObject().setTitleHeight(height); + getObject().setTitleHeightType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + * Sets the minimum height of a column title. + * + * @param height the column title minimum height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setTitleMinHeight(final Integer height) { + getObject().setTitleHeight(height); + getObject().setTitleHeightType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + *

setTitleStretchWithOverflow.

+ * + * @param stretchWithOverflow a {@link java.lang.Boolean} object. + * @return a T object. + * @deprecated replaced by {@link #setTitleTextAdjust(TextAdjust)} + */ + @Deprecated + public T setTitleStretchWithOverflow(final Boolean stretchWithOverflow) { + getObject().setTitleStretchWithOverflow(stretchWithOverflow); + return (T) this; + } + + /** + *

setTitleTextAdjust.

+ * + * @param textAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + * @return a T object. + */ + public T setTitleTextAdjust(final TextAdjust textAdjust) { + getObject().setTitleTextAdjust(textAdjust); + return (T) this; + } + + /** + * Adds a jasper property to the column title. + * + * @param propertyExpression the property expression + * @return a column builder + */ + public T addTitleProperty(final DRIPropertyExpression propertyExpression) { + getObject().addTitlePropertyExpression(propertyExpression); + return (T) this; + } + + /** + * Adds a jasper property to the column title. + * + * @param name the property name + * @param valueExpression the property value expression + * @return a column builder + */ + public T addTitleProperty(final String name, final DRIExpression valueExpression) { + getObject().addTitlePropertyExpression(Expressions.property(name, valueExpression)); + return (T) this; + } + + /** + * Adds a jasper property to the column title. + * + * @param name the property name + * @param value the property value + * @return a column builder + */ + public T addTitleProperty(final String name, final String value) { + getObject().addTitlePropertyExpression(Expressions.property(name, value)); + return (T) this; + } + + /** + *

getComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.component.DRComponent} object. + */ + protected DRComponent getComponent() { + return (DRComponent) getObject().getComponent(); + } + + /** + *

getColumn.

+ * + * @return a U object. + */ + public U getColumn() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ColumnBuilders.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ColumnBuilders.java new file mode 100644 index 0000000..1359c15 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ColumnBuilders.java @@ -0,0 +1,380 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.column; + +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.component.ComponentBuilder; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + * A set of methods of creating report columns.
It is used to display data in a multi-column layout. + * + * @author Ricardo Mariaca + * + */ +public class ColumnBuilders { + + // text + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param fieldName the name of the field + * @param valueClass the field value class + * @param a T object. + * @return a column builder + */ + public TextColumnBuilder column(String fieldName, Class valueClass) { + return Columns.column(fieldName, valueClass); + } + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param title the column title + * @param fieldName the name of the field + * @param valueClass the field value class + * @param a T object. + * @return a column builder + */ + public TextColumnBuilder column(String title, String fieldName, Class valueClass) { + return Columns.column(title, fieldName, valueClass); + } + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param fieldName the name of the field + * @param dataType the field data type + * @param a T object. + * @return a column builder + */ + public TextColumnBuilder column(String fieldName, DRIDataType dataType) { + return Columns.column(fieldName, dataType); + } + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param title the column title + * @param fieldName the name of the field + * @param dataType the field data type + * @param a T object. + * @return a column builder + */ + public TextColumnBuilder column(String title, String fieldName, DRIDataType dataType) { + return Columns.column(title, fieldName, dataType); + } + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param field the field definition + * @param a T object. + * @return a column builder + */ + public TextColumnBuilder column(FieldBuilder field) { + return Columns.column(field); + } + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param title the column title + * @param field the field definition + * @param a T object. + * @return a column builder + */ + public TextColumnBuilder column(String title, FieldBuilder field) { + return Columns.column(title, field); + } + + // expression + + /** + * Creates a new expression column.
The column values are defined in an expression. + * + * @param expression the value expression + * @param a T object. + * @return a column builder + */ + public TextColumnBuilder column(DRIExpression expression) { + return Columns.column(expression); + } + + /** + * Creates a new expression column.
The column values are defined in an expression. + * + * @param title the column title + * @param expression the value expression + * @param a T object. + * @return a column builder + */ + public TextColumnBuilder column(String title, DRIExpression expression) { + return Columns.column(title, expression); + } + + // percentage + + /** + * Creates a new percentage column.
It calculates percentage values from column values. + * + * @param column the column definition + * @return a column builder + */ + public PercentageColumnBuilder percentageColumn(ValueColumnBuilder column) { + return Columns.percentageColumn(column); + } + + /** + * Creates a new percentage column.
It calculates percentage values from column values. + * + * @param title the column title + * @param column the column definition + * @return a column builder + */ + public PercentageColumnBuilder percentageColumn(String title, ValueColumnBuilder column) { + return Columns.percentageColumn(title, column); + } + + /** + * Creates a new percentage column.
It calculates percentage values from field values. + * + * @param fieldName the name of the field + * @param valueClass the field value class + * @return a column builder + */ + public PercentageColumnBuilder percentageColumn(String fieldName, Class valueClass) { + return Columns.percentageColumn(fieldName, valueClass); + } + + /** + * Creates a new percentage column.
It calculates percentage values from field values. + * + * @param title the column title + * @param fieldName the name of the field + * @param valueClass the field value class + * @return a column builder + */ + public PercentageColumnBuilder percentageColumn(String title, String fieldName, Class valueClass) { + return Columns.percentageColumn(title, fieldName, valueClass); + } + + /** + * Creates a new percentage column.
It calculates percentage values from field values. + * + * @param field the field definition + * @return a column builder + */ + public PercentageColumnBuilder percentageColumn(FieldBuilder field) { + return Columns.percentageColumn(field); + } + + /** + * Creates a new percentage column.
It calculates percentage values from field values. + * + * @param title the column title + * @param field the field definition + * @return a column builder + */ + public PercentageColumnBuilder percentageColumn(String title, FieldBuilder field) { + return Columns.percentageColumn(title, field); + } + + /*public PercentageColumnBuilder percentageColumn(DRISimpleExpression expression) { + return Columns.percentageColumn(expression); + } + + public PercentageColumnBuilder percentageColumn(String title, DRISimpleExpression expression) { + return Columns.percentageColumn(title, expression); + }*/ + + // column row number + + /** + * Creates a new row number column.
It displays row numbers, the row number is reset on each new column. + * + * @return a column builder + */ + public TextColumnBuilder columnRowNumberColumn() { + return Columns.columnRowNumberColumn(); + } + + /** + * Creates a new row number column.
It displays row numbers, the row number is reset on each new column. + * + * @param title the column title + * @return a column builder + */ + public TextColumnBuilder columnRowNumberColumn(String title) { + return Columns.columnRowNumberColumn(title); + } + + // page row number + + /** + * Creates a new row number column.
It displays row numbers, the row number is reset on each new page. + * + * @return a column builder + */ + public TextColumnBuilder pageRowNumberColumn() { + return Columns.pageRowNumberColumn(); + } + + /** + * Creates a new row number column.
It displays row numbers, the row number is reset on each new page. + * + * @param title the column title + * @return a column builder + */ + public TextColumnBuilder pageRowNumberColumn(String title) { + return Columns.pageRowNumberColumn(title); + } + + // report row number + + /** + * Creates a new row number column.
It displays row numbers. + * + * @return a column builder + */ + public TextColumnBuilder reportRowNumberColumn() { + return Columns.reportRowNumberColumn(); + } + + /** + * Creates a new row number column.
It displays row numbers. + * + * @param title the column title + * @return a column builder + */ + public TextColumnBuilder reportRowNumberColumn(String title) { + return Columns.reportRowNumberColumn(title); + } + + // component + + /** + * Creates a new component column.
It is used to display custom components (e.g. images or complex content) in columns. + * + * @param component the component definition + * @return a column builder + */ + public ComponentColumnBuilder componentColumn(ComponentBuilder component) { + return Columns.componentColumn(component); + } + + /** + * Creates a new component column.
It is used to display custom components (e.g. images or complex content) in columns. + * + * @param title the column title + * @param component the component definition + * @return a column builder + */ + public ComponentColumnBuilder componentColumn(String title, ComponentBuilder component) { + return Columns.componentColumn(title, component); + } + + // boolean + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param fieldName the name of the field + * @return a column builder + */ + public BooleanColumnBuilder booleanColumn(String fieldName) { + return Columns.booleanColumn(fieldName); + } + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param title the column title + * @param fieldName the name of the field + * @return a column builder + */ + public BooleanColumnBuilder booleanColumn(String title, String fieldName) { + return Columns.booleanColumn(title, fieldName); + } + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param field the field definition + * @return a column builder + */ + public BooleanColumnBuilder booleanColumn(FieldBuilder field) { + return Columns.booleanColumn(field); + } + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param title the column title + * @param field the field definition + * @return a column builder + */ + public BooleanColumnBuilder booleanColumn(String title, FieldBuilder field) { + return Columns.booleanColumn(title, field); + } + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param expression the boolean value expression + * @return a column builder + */ + public BooleanColumnBuilder booleanColumn(DRIExpression expression) { + return Columns.booleanColumn(expression); + } + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param title the column title + * @param expression the boolean value expression + * @return a column builder + */ + public BooleanColumnBuilder booleanColumn(String title, DRIExpression expression) { + return Columns.booleanColumn(title, expression); + } + + // empty column + + /** + * Creates a new empty column.
+ * + * @return a column builder + */ + public TextColumnBuilder emptyColumn() { + return Columns.emptyColumn(); + } + + /** + * Creates a new empty column.
+ * + * @param showTitle show column title + * @param showDetailRows show detail rows + * @return a column builder + */ + public TextColumnBuilder emptyColumn(boolean showTitle, boolean showDetailRows) { + return Columns.emptyColumn(showTitle, showDetailRows); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/Columns.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/Columns.java new file mode 100644 index 0000000..c6641ba --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/Columns.java @@ -0,0 +1,408 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.column; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.builder.DynamicReports; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.component.ComponentBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + * A set of methods of creating report columns.
It is used to display data in a multi-column layout. + * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class Columns { + + // text + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param fieldName the name of the field + * @param valueClass the field value class + * @param a T object. + * @return a column builder + */ + @SuppressWarnings("unchecked") + public static TextColumnBuilder column(final String fieldName, final Class valueClass) { + return (TextColumnBuilder) column(DynamicReports.field(fieldName, valueClass)); + } + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param title the column title + * @param fieldName the name of the field + * @param valueClass the field value class + * @param a T object. + * @return a column builder + */ + @SuppressWarnings("unchecked") + public static TextColumnBuilder column(final String title, final String fieldName, final Class valueClass) { + return (TextColumnBuilder) column(title, DynamicReports.field(fieldName, valueClass)); + } + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param fieldName the name of the field + * @param dataType the field data type + * @param a T object. + * @return a column builder + */ + public static TextColumnBuilder column(final String fieldName, final DRIDataType dataType) { + Validate.notNull(dataType, "dataType must not be null"); + final TextColumnBuilder textColumnBuilder = new TextColumnBuilder<>(DynamicReports.field(fieldName, dataType.getValueClass())); + textColumnBuilder.setDataType(dataType); + return textColumnBuilder; + } + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param title the column title + * @param fieldName the name of the field + * @param dataType the field data type + * @param a T object. + * @return a column builder + */ + public static TextColumnBuilder column(final String title, final String fieldName, final DRIDataType dataType) { + final TextColumnBuilder textColumnBuilder = column(fieldName, dataType); + textColumnBuilder.setTitle(title); + return textColumnBuilder; + } + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param field the field definition + * @param a T object. + * @return a column builder + */ + public static TextColumnBuilder column(final FieldBuilder field) { + final TextColumnBuilder textColumnBuilder = new TextColumnBuilder<>(field); + if (field.getField().getDataType() != null) { + textColumnBuilder.setDataType(field.getField().getDataType()); + } + return textColumnBuilder; + } + + /** + * Creates a new column.
It is used to show values from the data source. + * + * @param title the column title + * @param field the field definition + * @param a T object. + * @return a column builder + */ + public static TextColumnBuilder column(final String title, final FieldBuilder field) { + return column(field).setTitle(title); + } + + // expression + + /** + * Creates a new expression column.
The column values are defined in an expression. + * + * @param expression the value expression + * @param a T object. + * @return a column builder + */ + public static TextColumnBuilder column(final DRIExpression expression) { + final TextColumnBuilder textColumnBuilder = new TextColumnBuilder<>(expression); + if (expression instanceof DRIField && ((DRIField) expression).getDataType() != null) { + textColumnBuilder.setDataType(((DRIField) expression).getDataType()); + } + return textColumnBuilder; + } + + /** + * Creates a new expression column.
The column values are defined in an expression. + * + * @param title the column title + * @param expression the value expression + * @param a T object. + * @return a column builder + */ + public static TextColumnBuilder column(final String title, final DRIExpression expression) { + return column(expression).setTitle(title); + } + + // percentage + + /** + * Creates a new percentage column.
It calculates percentage values from column values. + * + * @param column the column definition + * @return a column builder + */ + public static PercentageColumnBuilder percentageColumn(final ValueColumnBuilder column) { + return new PercentageColumnBuilder(column); + } + + /** + * Creates a new percentage column.
It calculates percentage values from column values. + * + * @param title the column title + * @param column the column definition + * @return a column builder + */ + public static PercentageColumnBuilder percentageColumn(final String title, final ValueColumnBuilder column) { + return percentageColumn(column).setTitle(title); + } + + /** + * Creates a new percentage column.
It calculates percentage values from field values. + * + * @param fieldName the name of the field + * @param valueClass the field value class + * @return a column builder + */ + public static PercentageColumnBuilder percentageColumn(final String fieldName, final Class valueClass) { + return percentageColumn(DynamicReports.field(fieldName, valueClass)); + } + + /** + * Creates a new percentage column.
It calculates percentage values from field values. + * + * @param title the column title + * @param fieldName the name of the field + * @param valueClass the field value class + * @return a column builder + */ + public static PercentageColumnBuilder percentageColumn(final String title, final String fieldName, final Class valueClass) { + return percentageColumn(fieldName, valueClass).setTitle(title); + } + + /** + * Creates a new percentage column.
It calculates percentage values from field values. + * + * @param field the field definition + * @return a column builder + */ + public static PercentageColumnBuilder percentageColumn(final FieldBuilder field) { + return new PercentageColumnBuilder(field); + } + + /** + * Creates a new percentage column.
It calculates percentage values from field values. + * + * @param title the column title + * @param field the field definition + * @return a column builder + */ + public static PercentageColumnBuilder percentageColumn(final String title, final FieldBuilder field) { + return percentageColumn(field).setTitle(title); + } + + /*public static PercentageColumnBuilder percentageColumn(DRISimpleExpression expression) { + return new PercentageColumnBuilder(expression); + } + + public static PercentageColumnBuilder percentageColumn(String title, DRISimpleExpression expression) { + return percentageColumn(expression).setTitle(title); + }*/ + + // column row number + + /** + * Creates a new row number column.
It displays row numbers, the row number is reset on each new column. + * + * @return a column builder + */ + public static TextColumnBuilder columnRowNumberColumn() { + return column(Expressions.columnRowNumber()); + } + + /** + * Creates a new row number column.
It displays row numbers, the row number is reset on each new column. + * + * @param title the column title + * @return a column builder + */ + public static TextColumnBuilder columnRowNumberColumn(final String title) { + return columnRowNumberColumn().setTitle(title); + } + + // page row number + + /** + * Creates a new row number column.
It displays row numbers, the row number is reset on each new page. + * + * @return a column builder + */ + public static TextColumnBuilder pageRowNumberColumn() { + return column(Expressions.pageRowNumber()); + } + + /** + * Creates a new row number column.
It displays row numbers, the row number is reset on each new page. + * + * @param title the column title + * @return a column builder + */ + public static TextColumnBuilder pageRowNumberColumn(final String title) { + return pageRowNumberColumn().setTitle(title); + } + + // report row number + + /** + * Creates a new row number column.
It displays row numbers. + * + * @return a column builder + */ + public static TextColumnBuilder reportRowNumberColumn() { + return column(Expressions.reportRowNumber()); + } + + /** + * Creates a new row number column.
It displays row numbers. + * + * @param title the column title + * @return a column builder + */ + public static TextColumnBuilder reportRowNumberColumn(final String title) { + return reportRowNumberColumn().setTitle(title); + } + + // component + + /** + * Creates a new component column.
It is used to display custom components (e.g. images or complex content) in columns. + * + * @param component the component definition + * @return a column builder + */ + public static ComponentColumnBuilder componentColumn(final ComponentBuilder component) { + Validate.notNull(component, "component must not be null"); + return new ComponentColumnBuilder(component); + } + + /** + * Creates a new component column.
It is used to display custom components (e.g. images or complex content) in columns. + * + * @param title the column title + * @param component the component definition + * @return a column builder + */ + public static ComponentColumnBuilder componentColumn(final String title, final ComponentBuilder component) { + return componentColumn(component).setTitle(title); + } + + // boolean + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param fieldName the name of the field + * @return a column builder + */ + public static BooleanColumnBuilder booleanColumn(final String fieldName) { + return booleanColumn(DynamicReports.field(fieldName, Boolean.class)); + } + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param title the column title + * @param fieldName the name of the field + * @return a column builder + */ + public static BooleanColumnBuilder booleanColumn(final String title, final String fieldName) { + return booleanColumn(title, DynamicReports.field(fieldName, Boolean.class)); + } + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param field the field definition + * @return a column builder + */ + public static BooleanColumnBuilder booleanColumn(final FieldBuilder field) { + return new BooleanColumnBuilder(field); + } + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param title the column title + * @param field the field definition + * @return a column builder + */ + public static BooleanColumnBuilder booleanColumn(final String title, final FieldBuilder field) { + return booleanColumn(field).setTitle(title); + } + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param expression the boolean value expression + * @return a column builder + */ + public static BooleanColumnBuilder booleanColumn(final DRIExpression expression) { + return new BooleanColumnBuilder(expression); + } + + /** + * Creates a new boolean column.
It shows a boolean value either as a text or as an image. + * + * @param title the column title + * @param expression the boolean value expression + * @return a column builder + */ + public static BooleanColumnBuilder booleanColumn(final String title, final DRIExpression expression) { + return booleanColumn(expression).setTitle(title); + } + + // empty column + + /** + * Creates a new empty column.
+ * + * @return a column builder + */ + public static TextColumnBuilder emptyColumn() { + return emptyColumn(false, false); + } + + /** + * Creates a new empty column.
+ * + * @param showTitle show column title + * @param showDetailRows show detail rows + * @return a column builder + */ + public static TextColumnBuilder emptyColumn(final boolean showTitle, final boolean showDetailRows) { + final TextColumnBuilder column = column(Expressions.text(null)); + if (showTitle) { + column.setTitle(""); + } + if (!showDetailRows) { + column.setPrintWhenExpression(Expressions.value(false)); + } + return column; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ComponentColumnBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ComponentColumnBuilder.java new file mode 100644 index 0000000..4e6df09 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ComponentColumnBuilder.java @@ -0,0 +1,135 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.column; + +import software.xdev.dynamicreports.report.base.column.DRColumn; +import software.xdev.dynamicreports.report.base.component.DRComponent; +import software.xdev.dynamicreports.report.base.component.DRDimensionComponent; +import software.xdev.dynamicreports.report.builder.component.ComponentBuilder; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.component.DRIDimensionComponent; +import software.xdev.dynamicreports.report.exception.DRReportException; + +/** + * It is used to display custom components (e.g. images or complex content) in columns. + * + * @author Ricardo Mariaca + * + */ +public class ComponentColumnBuilder extends ColumnBuilder> { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for ComponentColumnBuilder.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + */ + protected ComponentColumnBuilder(ComponentBuilder component) { + super(new DRColumn(component.getComponent())); + } + + /** + * Sets the preferred width of a column. + * + * @param width the column preferred width >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ComponentColumnBuilder setWidth(Integer width) { + getDimensionComponent().setWidth(width); + return this; + } + + /** + * Sets the fixed width of a column. + * + * @param width the column fixed width >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ComponentColumnBuilder setFixedWidth(Integer width) { + getDimensionComponent().setWidth(width); + getDimensionComponent().setWidthType(ComponentDimensionType.FIXED); + return this; + } + + /** + * Sets the minimum width of a column. + * + * @param width the column minimum width >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ComponentColumnBuilder setMinWidth(Integer width) { + getDimensionComponent().setWidth(width); + getDimensionComponent().setWidthType(ComponentDimensionType.EXPAND); + return this; + } + + /** + * Sets the preferred height of a column. + * + * @param height the column preferred height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ComponentColumnBuilder setHeight(Integer height) { + getDimensionComponent().setHeight(height); + return this; + } + + /** + * Sets the fixed height of a column. + * + * @param height the column fixed height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ComponentColumnBuilder setFixedHeight(Integer height) { + getDimensionComponent().setHeight(height); + getDimensionComponent().setHeightType(ComponentDimensionType.FIXED); + return this; + } + + /** + * Sets the minimum height of a column. + * + * @param height the column minimum height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ComponentColumnBuilder setMinHeight(Integer height) { + getDimensionComponent().setHeight(height); + getDimensionComponent().setHeightType(ComponentDimensionType.EXPAND); + return this; + } + + private DRDimensionComponent getDimensionComponent() { + if (!(getObject().getComponent() instanceof DRIDimensionComponent)) { + throw new DRReportException("Column component" + getObject().getComponent().getClass().getName() + "is not a dimension component."); + } + return (DRDimensionComponent) getObject().getComponent(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/PercentageColumnBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/PercentageColumnBuilder.java new file mode 100644 index 0000000..0ee3364 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/PercentageColumnBuilder.java @@ -0,0 +1,133 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.column; + +import software.xdev.dynamicreports.report.base.DRGroup; +import software.xdev.dynamicreports.report.base.DRVariable; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.datatype.DataTypes; +import software.xdev.dynamicreports.report.builder.expression.PercentageExpression; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.constant.PercentageTotalType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.exception.DRReportException; +import org.apache.commons.lang3.Validate; + +/** + * It calculates percentage values from the field or column values. + * + * @author Ricardo Mariaca + * + */ +public class PercentageColumnBuilder extends ValueColumnBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression actualExpression; + private PercentageTotalType totalType; + private DRGroup totalGroup; + + /** + *

Constructor for PercentageColumnBuilder.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + */ + protected PercentageColumnBuilder(ValueColumnBuilder column) { + Validate.notNull(column, "column must not be null"); + this.actualExpression = column.build(); + } + + /** + *

Constructor for PercentageColumnBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + protected PercentageColumnBuilder(FieldBuilder field) { + Validate.notNull(field, "field must not be null"); + this.actualExpression = field.getField(); + } + + /*protected PercentageColumnBuilder(DRISimpleExpression valueExpression) { + Validate.notNull(valueExpression, "valueExpression must not be null"); + this.actualExpression = valueExpression; + }*/ + + /** + * Sets the total type. Has effect only when the report contains at least one group. + * + * @param totalType the total type + * @return a column builder + */ + public PercentageColumnBuilder setTotalType(PercentageTotalType totalType) { + this.totalType = totalType; + return this; + } + + /** + * Sets the total group. Has effect only when the report contains at least one group. + * + * @param totalGroup the total group + * @return a column builder + */ + public PercentageColumnBuilder setTotalGroup(GroupBuilder totalGroup) { + if (totalGroup != null) { + this.totalGroup = totalGroup.getGroup(); + setTotalType(PercentageTotalType.GROUP); + } else { + this.totalGroup = null; + } + + return this; + } + + /** {@inheritDoc} */ + @Override + protected void configure() { + if (getComponent().getDataType() == null) { + getComponent().setDataType(DataTypes.percentageType()); + } + + DRVariable totalExpression = new DRVariable(actualExpression, Calculation.SUM); + if (totalType != null) { + switch (totalType) { + case REPORT: + totalExpression.setResetType(Evaluation.REPORT); + break; + case GROUP: + totalExpression.setResetType(Evaluation.GROUP); + break; + case FIRST_GROUP: + totalExpression.setResetType(Evaluation.FIRST_GROUP); + break; + case LAST_GROUP: + totalExpression.setResetType(Evaluation.LAST_GROUP); + break; + default: + throw new DRReportException("Percentage total type " + totalType.name() + " not supported."); + } + } else { + totalExpression.setResetType(Evaluation.LAST_GROUP); + } + totalExpression.setResetGroup(totalGroup); + + setValueExpression(new PercentageExpression(actualExpression, totalExpression)); + super.configure(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/TextColumnBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/TextColumnBuilder.java new file mode 100644 index 0000000..27b4d24 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/TextColumnBuilder.java @@ -0,0 +1,199 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.column; + +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.expression.AddExpression; +import software.xdev.dynamicreports.report.builder.expression.DivideExpression; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.builder.expression.MultiplyExpression; +import software.xdev.dynamicreports.report.builder.expression.SubtractExpression; +import software.xdev.dynamicreports.report.builder.expression.ValueExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +import java.math.BigDecimal; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * It is used to show values from the data source. + * + * @author Ricardo Mariaca + * + */ +public class TextColumnBuilder extends ValueColumnBuilder, T> implements DRIValue { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for TextColumnBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + protected TextColumnBuilder(FieldBuilder field) { + Validate.notNull(field, "field must not be null"); + setValueExpression(field.getField()); + } + + /** + *

Constructor for TextColumnBuilder.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected TextColumnBuilder(DRIExpression valueExpression) { + setValueExpression(valueExpression); + } + + // add + + /** + * Creates a new column by adding a column value to this column instance. + * + * @param column the column builder + * @return a column builder + */ + @SuppressWarnings("unchecked") + public TextColumnBuilder add(TextColumnBuilder column) { + Validate.isTrue(Number.class.isAssignableFrom(getObject().getValueClass()), "Only Number column can multiply"); + DRIExpression value1Expression = (DRIExpression) this.getComponent().getValueExpression(); + DRIExpression value2Expression = column.getComponent().getValueExpression(); + AddExpression exp = new AddExpression(value1Expression, value2Expression); + return new TextColumnBuilder(exp).setDataType(type.bigDecimalType()); + } + + /** + * Creates a new column by adding a value to this column instance. + * + * @param number the value + * @return a column builder + */ + @SuppressWarnings("unchecked") + public TextColumnBuilder add(Number number) { + Validate.isTrue(Number.class.isAssignableFrom(getObject().getValueClass()), "Only Number column can multiply"); + DRIExpression value1Expression = (DRIExpression) this.getComponent().getValueExpression(); + ValueExpression value2Expression = Expressions.number(number); + AddExpression exp = new AddExpression(value1Expression, value2Expression); + return new TextColumnBuilder(exp).setDataType(type.bigDecimalType()); + } + + // subtract + + /** + * Creates a new column by subtracting a column value from this column instance. + * + * @param column the column builder + * @return a column builder + */ + @SuppressWarnings("unchecked") + public TextColumnBuilder subtract(TextColumnBuilder column) { + Validate.isTrue(Number.class.isAssignableFrom(getObject().getValueClass()), "Only Number column can subtract"); + DRIExpression value1Expression = (DRIExpression) this.getComponent().getValueExpression(); + DRIExpression value2Expression = column.getComponent().getValueExpression(); + SubtractExpression exp = new SubtractExpression(value1Expression, value2Expression); + return new TextColumnBuilder(exp).setDataType(type.bigDecimalType()); + } + + /** + * Creates a new column by subtracting a value from this column instance. + * + * @param number the value + * @return a column builder + */ + @SuppressWarnings("unchecked") + public TextColumnBuilder subtract(Number number) { + Validate.isTrue(Number.class.isAssignableFrom(getObject().getValueClass()), "Only Number column can subtract"); + DRIExpression value1Expression = (DRIExpression) this.getComponent().getValueExpression(); + ValueExpression value2Expression = Expressions.number(number); + SubtractExpression exp = new SubtractExpression(value1Expression, value2Expression); + return new TextColumnBuilder(exp).setDataType(type.bigDecimalType()); + } + + // multiply + + /** + * Creates a new column by multiplying this column instance with a column value. + * + * @param column the column builder + * @return a column builder + */ + @SuppressWarnings("unchecked") + public TextColumnBuilder multiply(TextColumnBuilder column) { + Validate.isTrue(Number.class.isAssignableFrom(getObject().getValueClass()), "Only Number column can multiply"); + DRIExpression value1Expression = (DRIExpression) this.getComponent().getValueExpression(); + DRIExpression value2Expression = column.getComponent().getValueExpression(); + MultiplyExpression exp = new MultiplyExpression(value1Expression, value2Expression); + return new TextColumnBuilder(exp).setDataType(type.bigDecimalType()); + } + + /** + * Creates a new column by multiplying this column instance with a value. + * + * @param number the value + * @return a column builder + */ + @SuppressWarnings("unchecked") + public TextColumnBuilder multiply(Number number) { + Validate.isTrue(Number.class.isAssignableFrom(getObject().getValueClass()), "Only Number column can multiply"); + DRIExpression value1Expression = (DRIExpression) this.getComponent().getValueExpression(); + ValueExpression value2Expression = Expressions.number(number); + MultiplyExpression exp = new MultiplyExpression(value1Expression, value2Expression); + return new TextColumnBuilder(exp).setDataType(type.bigDecimalType()); + } + + // divide + + /** + * Creates a new column by dividing this column instance with a column value. + * + * @param column the column builder + * @param scale a int. + * @return a column builder + */ + @SuppressWarnings("unchecked") + public TextColumnBuilder divide(int scale, TextColumnBuilder column) { + Validate.isTrue(Number.class.isAssignableFrom(getObject().getValueClass()), "Only Number column can divide"); + DRIExpression value1Expression = (DRIExpression) this.getComponent().getValueExpression(); + DRIExpression value2Expression = column.getComponent().getValueExpression(); + DivideExpression exp = new DivideExpression(scale, value1Expression, value2Expression); + return new TextColumnBuilder(exp).setDataType(type.bigDecimalType()); + } + + /** + * Creates a new column by dividing this column instance with a value. + * + * @param number the value + * @param scale a int. + * @return a column builder + */ + @SuppressWarnings("unchecked") + public TextColumnBuilder divide(int scale, Number number) { + Validate.isTrue(Number.class.isAssignableFrom(getObject().getValueClass()), "Only Number column can divide"); + DRIExpression value1Expression = (DRIExpression) this.getComponent().getValueExpression(); + ValueExpression value2Expression = Expressions.number(number); + DivideExpression exp = new DivideExpression(scale, value1Expression, value2Expression); + return new TextColumnBuilder(exp).setDataType(type.bigDecimalType()); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return getObject().getName(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ValueColumnBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ValueColumnBuilder.java new file mode 100644 index 0000000..1b34f0a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/column/ValueColumnBuilder.java @@ -0,0 +1,454 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.column; + +import software.xdev.dynamicreports.report.base.column.DRValueColumn; +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.builder.HyperLinkBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; + +/** + *

Abstract ValueColumnBuilder class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +@SuppressWarnings( {"unchecked", "deprecation"}) +public abstract class ValueColumnBuilder, U> extends ColumnBuilder> { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for ValueColumnBuilder.

+ */ + protected ValueColumnBuilder() { + super(new DRValueColumn<>(new DRTextField())); + } + + /** + *

setValueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected void setValueExpression(final DRIExpression valueExpression) { + getComponent().setValueExpression(valueExpression); + } + + /** + * Specifies whether or not print a value if the value is the same as the previous value. + * + * @param printRepeatedDetailValues print repeated detail values + * @return a column builder + */ + public T setPrintRepeatedDetailValues(final Boolean printRepeatedDetailValues) { + getObject().setPrintRepeatedDetailValues(printRepeatedDetailValues); + return (T) this; + } + + /** + * Sets the column value horizontal alignment. + * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalAlignment} object. + * @return a column builder + * @deprecated use setHorizontalTextAlignment instead + */ + @Deprecated + public T setHorizontalAlignment(final HorizontalAlignment horizontalAlignment) { + if (horizontalAlignment != null) { + getComponent().setHorizontalTextAlignment(HorizontalTextAlignment.valueOf(horizontalAlignment.name())); + } else { + getComponent().setHorizontalTextAlignment(null); + } + + return (T) this; + } + + /** + * Sets the column value horizontal text alignment. + * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + * @return a column builder + */ + public T setHorizontalTextAlignment(final HorizontalTextAlignment horizontalTextAlignment) { + getComponent().setHorizontalTextAlignment(horizontalTextAlignment); + return (T) this; + } + + /** + * Sets the column value format pattern. + * + * @param pattern the format pattern + * @return a column builder + */ + public T setPattern(final String pattern) { + getComponent().setPattern(pattern); + return (T) this; + } + + /** + * Sets the column value format pattern. The expression must be a type of String. + * + * @param patternExpression the format pattern expression + * @return a column builder + */ + public T setPattern(final DRIExpression patternExpression) { + getComponent().setPatternExpression(patternExpression); + return (T) this; + } + + /** + * Sets the column value formatter expression. + * + * @param valueFormatter the value formatter expression + * @return a column builder + */ + public T setValueFormatter(final DRIValueFormatter valueFormatter) { + getComponent().setValueFormatter(valueFormatter); + return (T) this; + } + + /** + * Sets the column data type. + * + * @param dataType the data type + * @return a column builder + */ + public T setDataType(final DRIDataType dataType) { + getComponent().setDataType(dataType); + return (T) this; + } + + /** + * This method is used to define the preferred width of a column. The width is set to the columns multiplied by width of the character m for the font used + * + * @param columns the number of preferred columns >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if columns is < 0 + */ + public T setColumns(final Integer columns) { + getComponent().setColumns(columns); + return (T) this; + } + + /** + * This method is used to define the fixed width of a column. The width is set to the columns multiplied by width of the character m for the font used + * + * @param columns the number of fixed columns >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if columns is < 0 + */ + public T setFixedColumns(final Integer columns) { + getComponent().setColumns(columns); + getComponent().setWidthType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + * This method is used to define the minimum width of a column. The width is set to the columns multiplied by width of the character m for the font used + * + * @param columns the number of minimum columns >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if columns is < 0 + */ + public T setMinColumns(final Integer columns) { + getComponent().setColumns(columns); + getComponent().setWidthType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + * This method is used to define the preferred height of a column. The height is set to the rows multiplied by height of the font + * + * @param rows the number of preferred rows >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public T setRows(final Integer rows) { + getComponent().setRows(rows); + return (T) this; + } + + /** + * This method is used to define the fixed height of a column. The height is set to the rows multiplied by height of the font + * + * @param rows the number of fixed rows >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public T setFixedRows(final Integer rows) { + getComponent().setRows(rows); + getComponent().setHeightType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + * This method is used to define the minimum height of a column. The height is set to the rows multiplied by height of the font + * + * @param rows the number of minimum rows >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public T setMinRows(final Integer rows) { + getComponent().setRows(rows); + getComponent().setHeightType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + *

setAnchorName.

+ * + * @param anchorName a {@link java.lang.String} object. + * @return a T object. + */ + public T setAnchorName(final String anchorName) { + getComponent().setAnchorNameExpression(Expressions.text(anchorName)); + return (T) this; + } + + /** + *

setAnchorName.

+ * + * @param anchorNameExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setAnchorName(final DRIExpression anchorNameExpression) { + getComponent().setAnchorNameExpression(anchorNameExpression); + return (T) this; + } + + /** + *

setBookmarkLevel.

+ * + * @param bookmarkLevel a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setBookmarkLevel(final Integer bookmarkLevel) { + getComponent().setBookmarkLevel(bookmarkLevel); + return (T) this; + } + + /** + * Sets the column value hyperlink. + * + * @param hyperLink the value hyperlink + * @return a column builder + */ + public T setHyperLink(final HyperLinkBuilder hyperLink) { + if (hyperLink != null) { + getComponent().setHyperLink(hyperLink.getHyperLink()); + } else { + getComponent().setHyperLink(null); + } + return (T) this; + } + + /** + * Sets the preferred width of a column. + * + * @param width the column preferred width >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setWidth(final Integer width) { + getComponent().setWidth(width); + return (T) this; + } + + /** + * Sets the fixed width of a column. + * + * @param width the column fixed width >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setFixedWidth(final Integer width) { + getComponent().setWidth(width); + getComponent().setWidthType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + * Sets the minimum width of a column. + * + * @param width the column minimum width >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setMinWidth(final Integer width) { + getComponent().setWidth(width); + getComponent().setWidthType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + * Sets the preferred height of a column. + * + * @param height the column preferred height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setHeight(final Integer height) { + getComponent().setHeight(height); + return (T) this; + } + + /** + * Sets the fixed height of a column. + * + * @param height the column fixed height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setFixedHeight(final Integer height) { + getComponent().setHeight(height); + getComponent().setHeightType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + * Sets the minimum height of a column. + * + * @param height the column minimum height >= 0 + * @return a column builder + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setMinHeight(final Integer height) { + getComponent().setHeight(height); + getComponent().setHeightType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + *

setStretchWithOverflow.

+ * + * @param stretchWithOverflow a {@link java.lang.Boolean} object. + * @return a T object. + * @deprecated replaced by {@link #setTextAdjust(TextAdjust)} + */ + @Deprecated + public T setStretchWithOverflow(final Boolean stretchWithOverflow) { + getComponent().setStretchWithOverflow(stretchWithOverflow); + return (T) this; + } + + /** + *

setTextAdjust.

+ * + * @param textAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + * @return a T object. + */ + public T setTextAdjust(final TextAdjust textAdjust) { + getComponent().setTextAdjust(textAdjust); + return (T) this; + } + + /** + *

printInFirstWholeBand.

+ * + * @return a T object. + */ + public T printInFirstWholeBand() { + return setPrintInFirstWholeBand(true); + } + + /** + *

setPrintInFirstWholeBand.

+ * + * @param printInFirstWholeBand a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setPrintInFirstWholeBand(final Boolean printInFirstWholeBand) { + getComponent().setPrintInFirstWholeBand(printInFirstWholeBand); + return (T) this; + } + + /** + *

printWhenDetailOverflows.

+ * + * @return a T object. + */ + public T printWhenDetailOverflows() { + return setPrintWhenDetailOverflows(true); + } + + /** + *

setPrintWhenDetailOverflows.

+ * + * @param printWhenDetailOverflows a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setPrintWhenDetailOverflows(final Boolean printWhenDetailOverflows) { + getComponent().setPrintWhenDetailOverflows(printWhenDetailOverflows); + return (T) this; + } + + /** + * Adds a jasper property to the column value. + * + * @param propertyExpression the property expression + * @return a column builder + */ + public T addProperty(final DRIPropertyExpression propertyExpression) { + getComponent().addPropertyExpression(propertyExpression); + return (T) this; + } + + /** + * Adds a jasper property to the column value. + * + * @param name the property name + * @param valueExpression the property value expression + * @return a column builder + */ + public T addProperty(final String name, final DRIExpression valueExpression) { + getComponent().addPropertyExpression(Expressions.property(name, valueExpression)); + return (T) this; + } + + /** + * Adds a jasper property to the column value. + * + * @param name the property name + * @param value the property value + * @return a column builder + */ + public T addProperty(final String name, final String value) { + getComponent().addPropertyExpression(Expressions.property(name, value)); + return (T) this; + } + + /** {@inheritDoc} */ + @Override + protected DRTextField getComponent() { + return (DRTextField) getObject().getComponent(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/AbstractFormatFieldBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/AbstractFormatFieldBuilder.java new file mode 100644 index 0000000..a0cafc7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/AbstractFormatFieldBuilder.java @@ -0,0 +1,95 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRFormatField; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

Abstract AbstractFormatFieldBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings( {"unchecked", "deprecation"}) +public abstract class AbstractFormatFieldBuilder, U extends DRFormatField> extends HyperLinkComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for AbstractFormatFieldBuilder.

+ * + * @param formatField a U object. + */ + protected AbstractFormatFieldBuilder(U formatField) { + super(formatField); + } + + /** + *

setFormatExpression.

+ * + * @param format a {@link java.lang.String} object. + * @return a T object. + */ + public T setFormatExpression(String format) { + getObject().setFormatExpression(Expressions.text(format)); + return (T) this; + } + + /** + *

setFormatExpression.

+ * + * @param formatExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setFormatExpression(DRIExpression formatExpression) { + getObject().setFormatExpression(formatExpression); + return (T) this; + } + + /** + *

setHorizontalAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalAlignment} object. + * @return a T object. + * @deprecated use setHorizontalTextAlignment instead + */ + @Deprecated + public T setHorizontalAlignment(HorizontalAlignment horizontalAlignment) { + if (horizontalAlignment != null) { + getObject().setHorizontalTextAlignment(HorizontalTextAlignment.valueOf(horizontalAlignment.name())); + } else { + getObject().setHorizontalTextAlignment(null); + } + return (T) this; + } + + /** + *

setHorizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + * @return a T object. + */ + public T setHorizontalTextAlignment(HorizontalTextAlignment horizontalTextAlignment) { + getObject().setHorizontalTextAlignment(horizontalTextAlignment); + return (T) this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/BooleanFieldBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/BooleanFieldBuilder.java new file mode 100644 index 0000000..889811a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/BooleanFieldBuilder.java @@ -0,0 +1,177 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRBooleanField; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + *

BooleanFieldBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings("deprecation") +public class BooleanFieldBuilder extends HyperLinkComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for BooleanFieldBuilder.

+ */ + protected BooleanFieldBuilder() { + super(new DRBooleanField()); + } + + /** + *

setValue.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public BooleanFieldBuilder setValue(FieldBuilder field) { + Validate.notNull(field, "field must not be null"); + getObject().setValueExpression(field.getField()); + return this; + } + + /** + *

setValue.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public BooleanFieldBuilder setValue(DRIExpression valueExpression) { + getObject().setValueExpression(valueExpression); + return this; + } + + /** + *

setValue.

+ * + * @param value a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public BooleanFieldBuilder setValue(Boolean value) { + getObject().setValueExpression(Expressions.value(value)); + return this; + } + + /** + *

setComponentType.

+ * + * @param booleanComponentType a {@link software.xdev.dynamicreports.report.constant.BooleanComponentType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public BooleanFieldBuilder setComponentType(BooleanComponentType booleanComponentType) { + getObject().setComponentType(booleanComponentType); + return this; + } + + /** + *

setEmptyWhenNullValue.

+ * + * @param emptyWhenNullValue a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public BooleanFieldBuilder setEmptyWhenNullValue(Boolean emptyWhenNullValue) { + getObject().setEmptyWhenNullValue(emptyWhenNullValue); + return this; + } + + /** + * Sets the boolean image dimension. Has effect only when the boolean value is presented as an image. + * + * @param width the image width + * @param height the image height + * @return a column builder + */ + public BooleanFieldBuilder setImageDimension(Integer width, Integer height) { + getObject().setImageWidth(width); + getObject().setImageHeight(height); + return this; + } + + /** + * Sets the boolean image width. Has effect only when the boolean value is presented as an image. + * + * @param width the image width + * @return a column builder + */ + public BooleanFieldBuilder setImageWidth(Integer width) { + getObject().setImageWidth(width); + return this; + } + + /** + * Sets the boolean image height. Has effect only when the boolean value is presented as an image. + * + * @param height the image height + * @return a column builder + */ + public BooleanFieldBuilder setImageHeight(Integer height) { + getObject().setImageHeight(height); + return this; + } + + /** + *

setHorizontalImageAlignment.

+ * + * @param horizontalImageAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public BooleanFieldBuilder setHorizontalImageAlignment(HorizontalImageAlignment horizontalImageAlignment) { + getObject().setHorizontalImageAlignment(horizontalImageAlignment); + return this; + } + + /** + *

setHorizontalAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalAlignment} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + * @deprecated use setHorizontalImageAlignment instead + */ + @Deprecated + public BooleanFieldBuilder setHorizontalAlignment(HorizontalAlignment horizontalAlignment) { + if (horizontalAlignment != null) { + getObject().setHorizontalImageAlignment(HorizontalImageAlignment.valueOf(horizontalAlignment.name())); + } else { + getObject().setHorizontalImageAlignment(null); + } + return this; + } + + /** + *

setHorizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public BooleanFieldBuilder setHorizontalTextAlignment(HorizontalTextAlignment horizontalTextAlignment) { + getObject().setHorizontalTextAlignment(horizontalTextAlignment); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/BreakBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/BreakBuilder.java new file mode 100644 index 0000000..4cb591d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/BreakBuilder.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRBreak; +import software.xdev.dynamicreports.report.constant.BreakType; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

BreakBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class BreakBuilder extends ComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for BreakBuilder.

+ */ + protected BreakBuilder() { + super(new DRBreak()); + } + + /** + *

setType.

+ * + * @param breakType a {@link software.xdev.dynamicreports.report.constant.BreakType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BreakBuilder} object. + */ + public BreakBuilder setType(BreakType breakType) { + getObject().setType(breakType); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/ComponentBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/ComponentBuilder.java new file mode 100644 index 0000000..8737ab5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/ComponentBuilder.java @@ -0,0 +1,162 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRComponent; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.builder.DynamicReports; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsHeadingBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract ComponentBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings("unchecked") +public abstract class ComponentBuilder, U extends DRComponent> extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for ComponentBuilder.

+ * + * @param object a U object. + */ + protected ComponentBuilder(U object) { + super(object); + } + + /** + *

setStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a T object. + */ + public T setStyle(ReportStyleBuilder style) { + if (style != null) { + getObject().setStyle(style.getStyle()); + } else { + getObject().setStyle(null); + } + return (T) this; + } + + /** + *

setPrintWhenExpression.

+ * + * @param printWhenExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setPrintWhenExpression(DRIExpression printWhenExpression) { + getObject().setPrintWhenExpression(printWhenExpression); + return (T) this; + } + + /** + *

removeLineWhenBlank.

+ * + * @return a T object. + */ + public T removeLineWhenBlank() { + return setRemoveLineWhenBlank(true); + } + + /** + *

setRemoveLineWhenBlank.

+ * + * @param removeLineWhenBlank a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setRemoveLineWhenBlank(Boolean removeLineWhenBlank) { + getObject().setRemoveLineWhenBlank(removeLineWhenBlank); + return (T) this; + } + + /** + *

addProperty.

+ * + * @param propertyExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression} object. + * @return a T object. + */ + public T addProperty(DRIPropertyExpression propertyExpression) { + getComponent().addPropertyExpression(propertyExpression); + return (T) this; + } + + /** + *

addProperty.

+ * + * @param name a {@link java.lang.String} object. + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T addProperty(String name, DRIExpression valueExpression) { + getComponent().addPropertyExpression(Expressions.property(name, valueExpression)); + return (T) this; + } + + /** + *

addProperty.

+ * + * @param name a {@link java.lang.String} object. + * @param value a {@link java.lang.String} object. + * @return a T object. + */ + public T addProperty(String name, String value) { + getComponent().addPropertyExpression(Expressions.property(name, value)); + return (T) this; + } + + /** + *

setTableOfContentsHeading.

+ * + * @param label a {@link java.lang.String} object. + * @return a T object. + */ + public T setTableOfContentsHeading(String label) { + TableOfContentsHeadingBuilder tocHeading = DynamicReports.tableOfContentsHeading(label); + return setTableOfContentsHeading(tocHeading); + } + + /** + *

setTableOfContentsHeading.

+ * + * @param tocHeading a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsHeadingBuilder} object. + * @return a T object. + */ + public T setTableOfContentsHeading(TableOfContentsHeadingBuilder tocHeading) { + Validate.notNull(tocHeading, "tocHeading must not be null"); + getComponent().setTableOfContentsHeading(tocHeading.build()); + return (T) this; + } + + /** + *

getComponent.

+ * + * @return a U object. + */ + public U getComponent() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/ComponentBuilders.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/ComponentBuilders.java new file mode 100644 index 0000000..62a0a70 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/ComponentBuilders.java @@ -0,0 +1,641 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.VariableBuilder; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import net.sf.jasperreports.engine.JasperReport; +import net.sf.jasperreports.renderers.Renderable; + +import java.awt.Image; +import java.io.InputStream; +import java.net.URL; +import java.util.Date; + +/** + * A set of methods of creating components + * + * @author Ricardo Mariaca + * + */ +public class ComponentBuilders { + + // horizontal list + + /** + *

horizontalList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder horizontalList() { + return Components.horizontalList(); + } + + /** + *

horizontalList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder horizontalList(ComponentBuilder... components) { + return Components.horizontalList(components); + } + + /** + *

horizontalList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder horizontalList(HorizontalListCellBuilder... cells) { + return Components.horizontalList(cells); + } + + /** + *

hListCell.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + */ + public HorizontalListCellBuilder hListCell(ComponentBuilder component) { + return Components.hListCell(component); + } + + // horizontal flow list + + /** + *

horizontalFlowList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder horizontalFlowList() { + return Components.horizontalFlowList(); + } + + /** + *

horizontalFlowList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder horizontalFlowList(ComponentBuilder... components) { + return Components.horizontalFlowList(components); + } + + /** + *

horizontalFlowList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder horizontalFlowList(HorizontalListCellBuilder... cells) { + return Components.horizontalFlowList(cells); + } + + // vertical list + + /** + *

verticalList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public VerticalListBuilder verticalList() { + return Components.verticalList(); + } + + /** + *

verticalList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public VerticalListBuilder verticalList(ComponentBuilder... components) { + return Components.verticalList(components); + } + + /** + *

verticalList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public VerticalListBuilder verticalList(VerticalListCellBuilder... cells) { + return Components.verticalList(cells); + } + + /** + *

vListCell.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + */ + public VerticalListCellBuilder vListCell(ComponentBuilder component) { + return Components.vListCell(component); + } + + // xy list + + /** + *

xyList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.XyListBuilder} object. + */ + public XyListBuilder xyList() { + return Components.xyList(); + } + + /** + *

xyList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.XyListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.XyListBuilder} object. + */ + public XyListBuilder xyList(XyListCellBuilder... cells) { + return Components.xyList(cells); + } + + /** + *

xyListCell.

+ * + * @param x a {@link java.lang.Integer} object. + * @param y a {@link java.lang.Integer} object. + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.XyListCellBuilder} object. + */ + public XyListCellBuilder xyListCell(Integer x, Integer y, ComponentBuilder component) { + return Components.xyListCell(x, y, component); + } + + /** + *

xyListCell.

+ * + * @param x a {@link java.lang.Integer} object. + * @param y a {@link java.lang.Integer} object. + * @param width a {@link java.lang.Integer} object. + * @param height a {@link java.lang.Integer} object. + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.XyListCellBuilder} object. + */ + public XyListCellBuilder xyListCell(Integer x, Integer y, Integer width, Integer height, ComponentBuilder component) { + return Components.xyListCell(x, y, width, height, component); + } + + // multi page list + + /** + *

multiPageList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.MultiPageListBuilder} object. + */ + public MultiPageListBuilder multiPageList() { + return Components.multiPageList(); + } + + /** + *

multiPageList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MultiPageListBuilder} object. + */ + public MultiPageListBuilder multiPageList(ComponentBuilder... components) { + return Components.multiPageList(components); + } + + /** + *

currentDate.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.CurrentDateBuilder} object. + */ + public CurrentDateBuilder currentDate() { + return Components.currentDate(); + } + + /** + *

pageNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageNumberBuilder} object. + */ + public PageNumberBuilder pageNumber() { + return Components.pageNumber(); + } + + /** + *

pageXofY.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXofYBuilder} object. + */ + public PageXofYBuilder pageXofY() { + return Components.pageXofY(); + } + + /** + *

pageXslashY.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXslashYBuilder} object. + */ + public PageXslashYBuilder pageXslashY() { + return Components.pageXslashY(); + } + + /** + *

totalPages.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.TotalPagesBuilder} object. + */ + public TotalPagesBuilder totalPages() { + return Components.totalPages(); + } + + // text + + /** + *

text.

+ * + * @param text a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder text(String text) { + return Components.text(text); + } + + /** + *

text.

+ * + * @param date a {@link java.util.Date} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder text(Date date) { + return Components.text(date); + } + + /** + *

text.

+ * + * @param number a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder text(T number) { + return Components.text(number); + } + + /** + *

text.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder text(FieldBuilder field) { + return Components.text(field); + } + + /** + *

text.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder text(VariableBuilder variable) { + return Components.text(variable); + } + + /** + *

text.

+ * + * @param textExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder text(DRIExpression textExpression) { + return Components.text(textExpression); + } + + // filler + + /** + *

filler.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.FillerBuilder} object. + */ + public FillerBuilder filler() { + return Components.filler(); + } + + /** + *

horizontalGap.

+ * + * @param width a int. + * @return a {@link software.xdev.dynamicreports.report.builder.component.FillerBuilder} object. + */ + public FillerBuilder horizontalGap(int width) { + return Components.horizontalGap(width); + } + + /** + *

verticalGap.

+ * + * @param height a int. + * @return a {@link software.xdev.dynamicreports.report.builder.component.FillerBuilder} object. + */ + public FillerBuilder verticalGap(int height) { + return Components.verticalGap(height); + } + + /** + *

gap.

+ * + * @param width a int. + * @param height a int. + * @return a {@link software.xdev.dynamicreports.report.builder.component.FillerBuilder} object. + */ + public FillerBuilder gap(int width, int height) { + return Components.gap(width, height); + } + + // image + + /** + *

image.

+ * + * @param imageExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder image(DRIExpression imageExpression) { + return Components.image(imageExpression); + } + + /** + *

image.

+ * + * @param imagePath a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder image(String imagePath) { + return Components.image(imagePath); + } + + /** + *

image.

+ * + * @param image a {@link java.awt.Image} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder image(Image image) { + return Components.image(image); + } + + /** + *

image.

+ * + * @param imageInputStream a {@link java.io.InputStream} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder image(InputStream imageInputStream) { + return Components.image(imageInputStream); + } + + /** + *

image.

+ * + * @param imageUrl a {@link java.net.URL} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder image(URL imageUrl) { + return Components.image(imageUrl); + } + + /** + *

image.

+ * + * @param image a {@link net.sf.jasperreports.renderers.Renderable} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder image(Renderable image) { + return Components.image(image); + } + + /** + *

image.

+ * + * @param image a {@link net.sf.jasperreports.engine.Renderable} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + * @deprecated use image(net.sf.jasperreports.renderers.Renderable image) instead + */ + @Deprecated + public ImageBuilder image(net.sf.jasperreports.engine.Renderable image) { + return Components.image(image); + } + + // subreport + + /** + *

subreport.

+ * + * @param reportBuilder a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder subreport(JasperReportBuilder reportBuilder) { + return Components.subreport(reportBuilder); + } + + /** + *

subreport.

+ * + * @param jasperReport a {@link net.sf.jasperreports.engine.JasperReport} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder subreport(JasperReport jasperReport) { + return Components.subreport(jasperReport); + } + + /** + *

subreport.

+ * + * @param reportExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder subreport(DRIExpression reportExpression) { + return Components.subreport(reportExpression); + } + + // line + + /** + *

line.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.LineBuilder} object. + */ + public LineBuilder line() { + return Components.line(); + } + + // break + + /** + *

pageBreak.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.BreakBuilder} object. + */ + public BreakBuilder pageBreak() { + return Components.pageBreak(); + } + + /** + *

columnBreak.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.BreakBuilder} object. + */ + public BreakBuilder columnBreak() { + return Components.columnBreak(); + } + + // generic element + + /** + *

genericElement.

+ * + * @param namespace a {@link java.lang.String} object. + * @param namespace a {@link java.lang.String} object. + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.GenericElementBuilder} object. + */ + public GenericElementBuilder genericElement(String namespace, String name) { + return Components.genericElement(namespace, name); + } + + // boolean + + /** + *

booleanField.

+ * + * @param value a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public BooleanFieldBuilder booleanField(Boolean value) { + return Components.booleanField(value); + } + + /** + *

booleanField.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public BooleanFieldBuilder booleanField(FieldBuilder field) { + return Components.booleanField(field); + } + + /** + *

booleanField.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public BooleanFieldBuilder booleanField(DRIExpression valueExpression) { + return Components.booleanField(valueExpression); + } + + // ellipse + + /** + *

ellipse.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.EllipseBuilder} object. + */ + public EllipseBuilder ellipse() { + return Components.ellipse(); + } + + // rectangle + + /** + *

rectangle.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.RectangleBuilder} object. + */ + public RectangleBuilder rectangle() { + return Components.rectangle(); + } + + /** + *

roundRectangle.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.RectangleBuilder} object. + */ + public RectangleBuilder roundRectangle() { + return Components.roundRectangle(); + } + + /** + *

roundRectangle.

+ * + * @param radius a int. + * @return a {@link software.xdev.dynamicreports.report.builder.component.RectangleBuilder} object. + */ + public RectangleBuilder roundRectangle(int radius) { + return Components.roundRectangle(radius); + } + + // map + + /** + *

map.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.MapBuilder} object. + */ + public MapBuilder map() { + return Components.map(); + } + + /** + *

map.

+ * + * @param latitude a {@link java.lang.Float} object. + * @param longitude a {@link java.lang.Float} object. + * @param zoom a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MapBuilder} object. + */ + public MapBuilder map(Float latitude, Float longitude, Integer zoom) { + return Components.map(latitude, longitude, zoom); + } + + // alignment + + /** + *

centerHorizontal.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder centerHorizontal(ComponentBuilder component) { + return Components.centerHorizontal(component); + } + + /** + *

centerVertical.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public VerticalListBuilder centerVertical(ComponentBuilder component) { + return Components.centerVertical(component); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/Components.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/Components.java new file mode 100644 index 0000000..e091eaf --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/Components.java @@ -0,0 +1,668 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.VariableBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.BreakType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import net.sf.jasperreports.engine.JasperReport; +import net.sf.jasperreports.renderers.Renderable; +import org.apache.commons.lang3.Validate; + +import java.awt.Image; +import java.io.InputStream; +import java.net.URL; +import java.util.Date; + +/** + * A set of methods of creating components + * + * @author Ricardo Mariaca + * + */ +public class Components { + + // horizontal list + + /** + *

horizontalList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public static HorizontalListBuilder horizontalList() { + return new HorizontalListBuilder(); + } + + /** + *

horizontalList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public static HorizontalListBuilder horizontalList(ComponentBuilder... components) { + return new HorizontalListBuilder().add(components); + } + + /** + *

horizontalList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public static HorizontalListBuilder horizontalList(HorizontalListCellBuilder... cells) { + return new HorizontalListBuilder().add(cells); + } + + /** + *

hListCell.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + */ + public static HorizontalListCellBuilder hListCell(ComponentBuilder component) { + Validate.notNull(component, "component must not be null"); + return new HorizontalListCellBuilder(component); + } + + // horizontal flow list + + /** + *

horizontalFlowList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public static HorizontalListBuilder horizontalFlowList() { + return new HorizontalFlowListBuilder(); + } + + /** + *

horizontalFlowList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public static HorizontalListBuilder horizontalFlowList(ComponentBuilder... components) { + return new HorizontalFlowListBuilder().add(components); + } + + /** + *

horizontalFlowList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public static HorizontalListBuilder horizontalFlowList(HorizontalListCellBuilder... cells) { + return new HorizontalFlowListBuilder().add(cells); + } + + // vertical list + + /** + *

verticalList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public static VerticalListBuilder verticalList() { + return new VerticalListBuilder(); + } + + /** + *

verticalList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public static VerticalListBuilder verticalList(ComponentBuilder... components) { + return new VerticalListBuilder().add(components); + } + + /** + *

verticalList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public static VerticalListBuilder verticalList(VerticalListCellBuilder... cells) { + return new VerticalListBuilder().add(cells); + } + + /** + *

vListCell.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + */ + public static VerticalListCellBuilder vListCell(ComponentBuilder component) { + Validate.notNull(component, "component must not be null"); + return new VerticalListCellBuilder(component); + } + + // xy list + + /** + *

xyList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.XyListBuilder} object. + */ + public static XyListBuilder xyList() { + return new XyListBuilder(); + } + + /** + *

xyList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.XyListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.XyListBuilder} object. + */ + public static XyListBuilder xyList(XyListCellBuilder... cells) { + return new XyListBuilder().add(cells); + } + + /** + *

xyListCell.

+ * + * @param x a {@link java.lang.Integer} object. + * @param y a {@link java.lang.Integer} object. + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.XyListCellBuilder} object. + */ + public static XyListCellBuilder xyListCell(Integer x, Integer y, ComponentBuilder component) { + Validate.notNull(component, "component must not be null"); + return new XyListCellBuilder(x, y, component); + } + + /** + *

xyListCell.

+ * + * @param x a {@link java.lang.Integer} object. + * @param y a {@link java.lang.Integer} object. + * @param width a {@link java.lang.Integer} object. + * @param height a {@link java.lang.Integer} object. + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.XyListCellBuilder} object. + */ + public static XyListCellBuilder xyListCell(Integer x, Integer y, Integer width, Integer height, ComponentBuilder component) { + Validate.notNull(component, "component must not be null"); + return new XyListCellBuilder(x, y, width, height, component); + } + + // multi page list + + /** + *

multiPageList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.MultiPageListBuilder} object. + */ + public static MultiPageListBuilder multiPageList() { + return new MultiPageListBuilder(); + } + + /** + *

multiPageList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MultiPageListBuilder} object. + */ + public static MultiPageListBuilder multiPageList(ComponentBuilder... components) { + return new MultiPageListBuilder().add(components); + } + + /** + *

currentDate.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.CurrentDateBuilder} object. + */ + public static CurrentDateBuilder currentDate() { + return new CurrentDateBuilder(); + } + + /** + *

pageNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageNumberBuilder} object. + */ + public static PageNumberBuilder pageNumber() { + return new PageNumberBuilder(); + } + + /** + *

pageXofY.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXofYBuilder} object. + */ + public static PageXofYBuilder pageXofY() { + return new PageXofYBuilder(); + } + + /** + *

pageXslashY.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXslashYBuilder} object. + */ + public static PageXslashYBuilder pageXslashY() { + return new PageXslashYBuilder(); + } + + /** + *

totalPages.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.TotalPagesBuilder} object. + */ + public static TotalPagesBuilder totalPages() { + return new TotalPagesBuilder(); + } + + // text + + /** + *

text.

+ * + * @param text a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public static TextFieldBuilder text(String text) { + return new TextFieldBuilder().setText(text); + } + + /** + *

text.

+ * + * @param date a {@link java.util.Date} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public static TextFieldBuilder text(Date date) { + return new TextFieldBuilder().setText(date); + } + + /** + *

text.

+ * + * @param number a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public static TextFieldBuilder text(T number) { + return new TextFieldBuilder().setText(number); + } + + /** + *

text.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public static TextFieldBuilder text(FieldBuilder field) { + return new TextFieldBuilder().setText(field); + } + + /** + *

text.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public static TextFieldBuilder text(VariableBuilder variable) { + return new TextFieldBuilder().setText(variable); + } + + /** + *

text.

+ * + * @param textExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public static TextFieldBuilder text(DRIExpression textExpression) { + return new TextFieldBuilder().setText(textExpression); + } + + // filler + + /** + *

filler.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.FillerBuilder} object. + */ + public static FillerBuilder filler() { + return new FillerBuilder(); + } + + /** + *

horizontalGap.

+ * + * @param width a int. + * @return a {@link software.xdev.dynamicreports.report.builder.component.FillerBuilder} object. + */ + public static FillerBuilder horizontalGap(int width) { + return new FillerBuilder().setFixedWidth(width); + } + + /** + *

verticalGap.

+ * + * @param height a int. + * @return a {@link software.xdev.dynamicreports.report.builder.component.FillerBuilder} object. + */ + public static FillerBuilder verticalGap(int height) { + return new FillerBuilder().setFixedHeight(height); + } + + /** + *

gap.

+ * + * @param width a int. + * @param height a int. + * @return a {@link software.xdev.dynamicreports.report.builder.component.FillerBuilder} object. + */ + public static FillerBuilder gap(int width, int height) { + return new FillerBuilder().setFixedDimension(width, height); + } + + // image + + /** + *

image.

+ * + * @param imageExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public static ImageBuilder image(DRIExpression imageExpression) { + return new ImageBuilder().setImage(imageExpression); + } + + /** + *

image.

+ * + * @param imagePath a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public static ImageBuilder image(String imagePath) { + return new ImageBuilder().setImage(imagePath); + } + + /** + *

image.

+ * + * @param image a {@link java.awt.Image} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public static ImageBuilder image(Image image) { + return new ImageBuilder().setImage(image); + } + + /** + *

image.

+ * + * @param imageInputStream a {@link java.io.InputStream} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public static ImageBuilder image(InputStream imageInputStream) { + return new ImageBuilder().setImage(imageInputStream); + } + + /** + *

image.

+ * + * @param imageUrl a {@link java.net.URL} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public static ImageBuilder image(URL imageUrl) { + return new ImageBuilder().setImage(imageUrl); + } + + /** + *

image.

+ * + * @param image a {@link net.sf.jasperreports.renderers.Renderable} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public static ImageBuilder image(Renderable image) { + return new ImageBuilder().setImage(Expressions.value(image, Renderable.class)); + } + + /** + *

image.

+ * + * @param image a {@link net.sf.jasperreports.engine.Renderable} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + * @deprecated use image(net.sf.jasperreports.renderers.Renderable image) instead + */ + @Deprecated + public static ImageBuilder image(net.sf.jasperreports.engine.Renderable image) { + return new ImageBuilder().setImage(Expressions.value(image, net.sf.jasperreports.engine.Renderable.class)); + } + + // subreport + + /** + *

subreport.

+ * + * @param reportBuilder a {@link software.xdev.dynamicreports.jasper.builder.JasperReportBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public static SubreportBuilder subreport(JasperReportBuilder reportBuilder) { + SubreportBuilder subreport = new SubreportBuilder(); + subreport.setReport(reportBuilder); + if (reportBuilder.getConnection() != null) { + subreport.setConnection(reportBuilder.getConnection()); + } + if (reportBuilder.getDataSource() != null) { + subreport.setDataSource(reportBuilder.getDataSource()); + } + return subreport; + } + + /** + *

subreport.

+ * + * @param jasperReport a {@link net.sf.jasperreports.engine.JasperReport} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public static SubreportBuilder subreport(JasperReport jasperReport) { + return new SubreportBuilder().setReport(jasperReport); + } + + /** + *

subreport.

+ * + * @param reportExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public static SubreportBuilder subreport(DRIExpression reportExpression) { + return new SubreportBuilder().setReport(reportExpression); + } + + // line + + /** + *

line.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.LineBuilder} object. + */ + public static LineBuilder line() { + return new LineBuilder(); + } + + // break + + /** + *

pageBreak.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.BreakBuilder} object. + */ + public static BreakBuilder pageBreak() { + return new BreakBuilder().setType(BreakType.PAGE); + } + + /** + *

columnBreak.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.BreakBuilder} object. + */ + public static BreakBuilder columnBreak() { + return new BreakBuilder().setType(BreakType.COLUMN); + } + + // generic element + + /** + *

genericElement.

+ * + * @param namespace a {@link java.lang.String} object. + * @param namespace a {@link java.lang.String} object. + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.GenericElementBuilder} object. + */ + public static GenericElementBuilder genericElement(String namespace, String name) { + return new GenericElementBuilder(namespace, name); + } + + // boolean + + /** + *

booleanField.

+ * + * @param value a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public static BooleanFieldBuilder booleanField(Boolean value) { + return new BooleanFieldBuilder().setValue(value); + } + + /** + *

booleanField.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public static BooleanFieldBuilder booleanField(FieldBuilder field) { + return new BooleanFieldBuilder().setValue(field); + } + + /** + *

booleanField.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.BooleanFieldBuilder} object. + */ + public static BooleanFieldBuilder booleanField(DRIExpression valueExpression) { + return new BooleanFieldBuilder().setValue(valueExpression); + } + + // ellipse + + /** + *

ellipse.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.EllipseBuilder} object. + */ + public static EllipseBuilder ellipse() { + return new EllipseBuilder(); + } + + // rectangle + + /** + *

rectangle.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.RectangleBuilder} object. + */ + public static RectangleBuilder rectangle() { + return new RectangleBuilder(); + } + + /** + *

roundRectangle.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.RectangleBuilder} object. + */ + public static RectangleBuilder roundRectangle() { + return new RectangleBuilder().setRadius(10); + } + + /** + *

roundRectangle.

+ * + * @param radius a int. + * @return a {@link software.xdev.dynamicreports.report.builder.component.RectangleBuilder} object. + */ + public static RectangleBuilder roundRectangle(int radius) { + return new RectangleBuilder().setRadius(radius); + } + + // map + + /** + *

map.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.MapBuilder} object. + */ + public static MapBuilder map() { + return new MapBuilder(); + } + + /** + *

map.

+ * + * @param latitude a {@link java.lang.Float} object. + * @param longitude a {@link java.lang.Float} object. + * @param zoom a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MapBuilder} object. + */ + public static MapBuilder map(Float latitude, Float longitude, Integer zoom) { + MapBuilder mapBuilder = new MapBuilder(); + mapBuilder.setLatitude(latitude); + mapBuilder.setLongitude(longitude); + mapBuilder.setZoom(zoom); + return mapBuilder; + } + + // alignment + + /** + *

centerHorizontal.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public static HorizontalListBuilder centerHorizontal(ComponentBuilder component) { + HorizontalListBuilder list = horizontalList(); + list.add(filler().setWidth(1)); + list.add(component); + list.add(filler().setWidth(1)); + return list; + } + + /** + *

centerVertical.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public static VerticalListBuilder centerVertical(ComponentBuilder component) { + VerticalListBuilder list = verticalList(); + list.add(filler().setHeight(1)); + list.add(component); + list.add(filler().setHeight(1)); + return list; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/CurrentDateBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/CurrentDateBuilder.java new file mode 100644 index 0000000..c058b92 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/CurrentDateBuilder.java @@ -0,0 +1,59 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRCurrentDate; +import software.xdev.dynamicreports.report.builder.expression.SystemMessageExpression; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

CurrentDateBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class CurrentDateBuilder extends AbstractFormatFieldBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for CurrentDateBuilder.

+ */ + protected CurrentDateBuilder() { + super(new DRCurrentDate()); + } + + /** + *

setPattern.

+ * + * @param pattern a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.CurrentDateBuilder} object. + */ + public CurrentDateBuilder setPattern(String pattern) { + getObject().setPattern(pattern); + return this; + } + + /** {@inheritDoc} */ + @Override + protected void configure() { + if (getObject().getFormatExpression() == null) { + setFormatExpression(new SystemMessageExpression("current_date")); + } + super.configure(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/DimensionComponentBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/DimensionComponentBuilder.java new file mode 100644 index 0000000..5377643 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/DimensionComponentBuilder.java @@ -0,0 +1,278 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRDimensionComponent; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.ComponentPositionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.StretchType; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract DimensionComponentBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings("unchecked") +public abstract class DimensionComponentBuilder, U extends DRDimensionComponent> extends ComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for DimensionComponentBuilder.

+ * + * @param component a U object. + */ + public DimensionComponentBuilder(U component) { + super(component); + } + + /** + * Sets the component preferred dimension. + * + * @param width the component preferred width >= 0 + * @param height the component preferred height >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setDimension(Integer width, Integer height) { + getObject().setWidth(width); + getObject().setHeight(height); + return (T) this; + } + + /** + * Sets the component fixed dimension. + * + * @param width the component fixed width >= 0 + * @param height the component fixed height >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setFixedDimension(Integer width, Integer height) { + getObject().setWidth(width); + getObject().setHeight(height); + getObject().setWidthType(ComponentDimensionType.FIXED); + getObject().setHeightType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + * Sets the component minimum dimension. + * + * @param width the component minimum width >= 0 + * @param height the component minimum height >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @throws java.lang.IllegalArgumentException if width is < 0 + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setMinDimension(Integer width, Integer height) { + getObject().setWidth(width); + getObject().setHeight(height); + getObject().setWidthType(ComponentDimensionType.EXPAND); + getObject().setHeightType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + * Sets the component preferred width. + * + * @param width the component preferred width >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setWidth(Integer width) { + getObject().setWidth(width); + return (T) this; + } + + /** + * Sets the component fixed width. + * + * @param width the component fixed width >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setFixedWidth(Integer width) { + getObject().setWidth(width); + getObject().setWidthType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + * Sets the component minimum width. + * + * @param width the component minimum width >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setMinWidth(Integer width) { + getObject().setWidth(width); + getObject().setWidthType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + * Sets the component preferred height. + * + * @param height the component preferred height >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setHeight(Integer height) { + getObject().setHeight(height); + return (T) this; + } + + /** + * Sets the component fixed height. + * + * @param height the component fixed height >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setFixedHeight(Integer height) { + getObject().setHeight(height); + getObject().setHeightType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + * Sets the component minimum height. + * + * @param height the component minimum height >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setMinHeight(Integer height) { + getObject().setHeight(height); + getObject().setHeightType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + *

setPositionType.

+ * + * @param positionType a {@link software.xdev.dynamicreports.report.constant.ComponentPositionType} object. + * @return a T object. + */ + public T setPositionType(ComponentPositionType positionType) { + getObject().setPositionType(positionType); + return (T) this; + } + + /** + *

setStretchType.

+ * + * @param stretchType a {@link software.xdev.dynamicreports.report.constant.StretchType} object. + * @return a T object. + */ + public T setStretchType(StretchType stretchType) { + getObject().setStretchType(stretchType); + return (T) this; + } + + /** + *

setPrintInFirstWholeBand.

+ * + * @param printInFirstWholeBand a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setPrintInFirstWholeBand(Boolean printInFirstWholeBand) { + getObject().setPrintInFirstWholeBand(printInFirstWholeBand); + return (T) this; + } + + /** + *

setPrintWhenDetailOverflows.

+ * + * @param printWhenDetailOverflows a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setPrintWhenDetailOverflows(Boolean printWhenDetailOverflows) { + getObject().setPrintWhenDetailOverflows(printWhenDetailOverflows); + return (T) this; + } + + /** + *

setPrintWhenGroupChanges.

+ * + * @param group a {@link software.xdev.dynamicreports.report.builder.group.GroupBuilder} object. + * @return a T object. + */ + public T setPrintWhenGroupChanges(GroupBuilder group) { + Validate.notNull(group, "group must not be null"); + getObject().setPrintWhenGroupChanges(group.getGroup()); + return (T) this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/EllipseBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/EllipseBuilder.java new file mode 100644 index 0000000..54a922d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/EllipseBuilder.java @@ -0,0 +1,54 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DREllipse; +import software.xdev.dynamicreports.report.builder.style.PenBuilder; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

EllipseBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class EllipseBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for EllipseBuilder.

+ */ + protected EllipseBuilder() { + super(new DREllipse()); + } + + /** + *

setPen.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.EllipseBuilder} object. + */ + public EllipseBuilder setPen(PenBuilder pen) { + if (pen != null) { + getObject().setPen(pen.build()); + } else { + getObject().setPen(null); + } + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/FillerBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/FillerBuilder.java new file mode 100644 index 0000000..842b35a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/FillerBuilder.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRFiller; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

FillerBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class FillerBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for FillerBuilder.

+ */ + protected FillerBuilder() { + super(new DRFiller()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/GenericElementBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/GenericElementBuilder.java new file mode 100644 index 0000000..b9355a0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/GenericElementBuilder.java @@ -0,0 +1,80 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRGenericElement; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIParameterExpression; + +/** + *

GenericElementBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class GenericElementBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for GenericElementBuilder.

+ * + * @param namespace a {@link java.lang.String} object. + * @param namespace a {@link java.lang.String} object. + * @param name a {@link java.lang.String} object. + */ + protected GenericElementBuilder(String namespace, String name) { + super(new DRGenericElement(namespace, name)); + } + + /** + *

addParameter.

+ * + * @param parameterExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIParameterExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.GenericElementBuilder} object. + */ + public GenericElementBuilder addParameter(DRIParameterExpression parameterExpression) { + getComponent().addParameterExpression(parameterExpression); + return this; + } + + /** + *

addParameter.

+ * + * @param name a {@link java.lang.String} object. + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.GenericElementBuilder} object. + */ + public GenericElementBuilder addParameter(String name, DRIExpression valueExpression) { + getComponent().addParameterExpression(Expressions.parameter(name, valueExpression)); + return this; + } + + /** + *

addParameter.

+ * + * @param name a {@link java.lang.String} object. + * @param value a {@link java.lang.Object} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.GenericElementBuilder} object. + */ + public GenericElementBuilder addParameter(String name, Object value) { + getComponent().addParameterExpression(Expressions.parameter(name, value)); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HorizontalFlowListBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HorizontalFlowListBuilder.java new file mode 100644 index 0000000..6079b25 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HorizontalFlowListBuilder.java @@ -0,0 +1,42 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

HorizontalFlowListBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class HorizontalFlowListBuilder extends HorizontalListBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for HorizontalFlowListBuilder.

+ */ + protected HorizontalFlowListBuilder() { + } + + /** {@inheritDoc} */ + @Override + protected void init() { + newFlowRow(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HorizontalListBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HorizontalListBuilder.java new file mode 100644 index 0000000..4c3a816 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HorizontalListBuilder.java @@ -0,0 +1,257 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRList; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.StretchType; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import org.apache.commons.lang3.Validate; + +/** + *

HorizontalListBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class HorizontalListBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRList row; + + /** + *

Constructor for HorizontalListBuilder.

+ */ + protected HorizontalListBuilder() { + super(new DRList(ListType.VERTICAL)); + init(); + } + + /** + *

init.

+ */ + protected void init() { + newRow(); + } + + /** + *

add.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder add(ComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for (ComponentBuilder component : components) { + row.addComponent(component.getComponent()); + } + return this; + } + + /** + *

add.

+ * + * @param gap a int. + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder add(int gap, ComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + for (ComponentBuilder component : components) { + add(Components.hListCell(Components.filler().setWidth(gap)).widthFixed()); + add(component); + } + return this; + } + + /** + *

add.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder add(HorizontalListCellBuilder... cells) { + Validate.notNull(cells, "cells must not be null"); + Validate.noNullElements(cells, "cells must not contains null cell"); + for (HorizontalListCellBuilder cell : cells) { + row.addCell(cell.build()); + } + return this; + } + + /** + *

add.

+ * + * @param gap a int. + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder add(int gap, HorizontalListCellBuilder... cells) { + Validate.notNull(cells, "cells must not be null"); + for (HorizontalListCellBuilder cell : cells) { + add(Components.hListCell(Components.filler().setWidth(gap)).widthFixed(), cell); + } + return this; + } + + /** + *

newRow.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder newRow() { + return newRow(0); + } + + /** + *

newRow.

+ * + * @param verticalGap a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder newRow(Integer verticalGap) { + return newRow(verticalGap, ListType.HORIZONTAL); + } + + /** + *

newFlowRow.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder newFlowRow() { + return newFlowRow(0); + } + + /** + *

newFlowRow.

+ * + * @param verticalGap a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder newFlowRow(Integer verticalGap) { + return newRow(verticalGap, ListType.HORIZONTAL_FLOW); + } + + private HorizontalListBuilder newRow(Integer verticalGap, ListType listType) { + if (verticalGap != null) { + Validate.isTrue(verticalGap >= 0, "verticalGap must be >= 0"); + } + if (verticalGap != null && verticalGap > 0) { + getObject().addComponent(HorizontalCellComponentAlignment.CENTER, VerticalCellComponentAlignment.TOP, Components.filler().setHeight(verticalGap).build()); + } + row = new DRList(listType); + getObject().addComponent(row); + return this; + } + + /** + *

setGap.

+ * + * @param gap a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder setGap(Integer gap) { + row.setGap(gap); + return this; + } + + /** {@inheritDoc} */ + @Override + public HorizontalListBuilder setStyle(ReportStyleBuilder style) { + if (style != null) { + row.setStyle(style.build()); + } else { + row.setStyle(null); + } + return this; + } + + /** + *

setBaseStretchType.

+ * + * @param stretchType a {@link software.xdev.dynamicreports.report.constant.StretchType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder setBaseStretchType(StretchType stretchType) { + row.setStretchType(stretchType); + return this; + } + + /** + *

setBaseGap.

+ * + * @param gap a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder setBaseGap(Integer gap) { + getObject().setGap(gap); + return this; + } + + /** + *

setBaseStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder setBaseStyle(ReportStyleBuilder style) { + if (style != null) { + getObject().setStyle(style.build()); + } else { + getObject().setStyle(null); + } + return this; + } + + /** + *

setBaseBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder setBaseBackgroundComponent(ComponentBuilder backgroundComponent) { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + getObject().setBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

setBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder} object. + */ + public HorizontalListBuilder setBackgroundComponent(ComponentBuilder backgroundComponent) { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + row.setBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

getList.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.component.DRList} object. + */ + public DRList getList() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HorizontalListCellBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HorizontalListCellBuilder.java new file mode 100644 index 0000000..7681dfb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HorizontalListCellBuilder.java @@ -0,0 +1,126 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRListCell; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; + +/** + *

HorizontalListCellBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class HorizontalListCellBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for HorizontalListCellBuilder.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + */ + protected HorizontalListCellBuilder(ComponentBuilder component) { + super(new DRListCell(component.build())); + } + + // width + + /** + *

widthFixed.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + */ + public HorizontalListCellBuilder widthFixed() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.LEFT); + return this; + } + + /** + *

widthFloat.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + */ + public HorizontalListCellBuilder widthFloat() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.FLOAT); + return this; + } + + /** + *

widthExpand.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + */ + public HorizontalListCellBuilder widthExpand() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.EXPAND); + return this; + } + + // height + + /** + *

heightFixedOnTop.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + */ + public HorizontalListCellBuilder heightFixedOnTop() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.TOP); + return this; + } + + /** + *

heightFixedOnMiddle.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + */ + public HorizontalListCellBuilder heightFixedOnMiddle() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.MIDDLE); + return this; + } + + /** + *

heightFixedOnBottom.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + */ + public HorizontalListCellBuilder heightFixedOnBottom() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.BOTTOM); + return this; + } + + /** + *

heightExpand.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.HorizontalListCellBuilder} object. + */ + public HorizontalListCellBuilder heightExpand() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.EXPAND); + return this; + } + + /** + *

getListCell.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.component.DRListCell} object. + */ + public DRListCell getListCell() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HyperLinkComponentBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HyperLinkComponentBuilder.java new file mode 100644 index 0000000..dffe1c4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/HyperLinkComponentBuilder.java @@ -0,0 +1,92 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRHyperLinkComponent; +import software.xdev.dynamicreports.report.builder.HyperLinkBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

Abstract HyperLinkComponentBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings("unchecked") +public abstract class HyperLinkComponentBuilder, U extends DRHyperLinkComponent> extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for HyperLinkComponentBuilder.

+ * + * @param component a U object. + */ + public HyperLinkComponentBuilder(U component) { + super(component); + } + + /** + *

setAnchorName.

+ * + * @param anchorName a {@link java.lang.String} object. + * @return a T object. + */ + public T setAnchorName(String anchorName) { + getObject().setAnchorNameExpression(Expressions.text(anchorName)); + return (T) this; + } + + /** + *

setAnchorName.

+ * + * @param anchorNameExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setAnchorName(DRIExpression anchorNameExpression) { + getObject().setAnchorNameExpression(anchorNameExpression); + return (T) this; + } + + /** + *

setBookmarkLevel.

+ * + * @param bookmarkLevel a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setBookmarkLevel(Integer bookmarkLevel) { + getObject().setBookmarkLevel(bookmarkLevel); + return (T) this; + } + + /** + *

setHyperLink.

+ * + * @param hyperLink a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + * @return a T object. + */ + public T setHyperLink(HyperLinkBuilder hyperLink) { + if (hyperLink != null) { + getObject().setHyperLink(hyperLink.getHyperLink()); + } else { + getObject().setHyperLink(null); + } + return (T) this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/ImageBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/ImageBuilder.java new file mode 100644 index 0000000..76d4e07 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/ImageBuilder.java @@ -0,0 +1,168 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRImage; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.awt.Image; +import java.io.InputStream; +import java.net.URL; + +/** + *

ImageBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings("deprecation") +public class ImageBuilder extends HyperLinkComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for ImageBuilder.

+ */ + protected ImageBuilder() { + super(new DRImage()); + } + + /** + *

setImage.

+ * + * @param imageExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder setImage(DRIExpression imageExpression) { + getObject().setImageExpression(imageExpression); + return this; + } + + /** + *

setImage.

+ * + * @param imagePath a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder setImage(String imagePath) { + getObject().setImageExpression(Expressions.text(imagePath)); + getObject().setUsingCache(true); + return this; + } + + /** + *

setImage.

+ * + * @param image a {@link java.awt.Image} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder setImage(Image image) { + getObject().setImageExpression(Expressions.image(image)); + getObject().setUsingCache(true); + return this; + } + + /** + *

setImage.

+ * + * @param imageInputStream a {@link java.io.InputStream} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder setImage(InputStream imageInputStream) { + getObject().setImageExpression(Expressions.inputStream(imageInputStream)); + getObject().setUsingCache(true); + return this; + } + + /** + *

setImage.

+ * + * @param imageUrl a {@link java.net.URL} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder setImage(URL imageUrl) { + getObject().setImageExpression(Expressions.url(imageUrl)); + getObject().setUsingCache(true); + return this; + } + + /** + *

setImageScale.

+ * + * @param imageScale a {@link software.xdev.dynamicreports.report.constant.ImageScale} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder setImageScale(ImageScale imageScale) { + getObject().setImageScale(imageScale); + return this; + } + + /** + *

setUsingCache.

+ * + * @param usingCache a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder setUsingCache(Boolean usingCache) { + getObject().setUsingCache(usingCache); + return this; + } + + /** + *

setLazy.

+ * + * @param lazy a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder setLazy(Boolean lazy) { + getObject().setLazy(lazy); + return this; + } + + /** + *

setHorizontalAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalAlignment} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + * @deprecated use setHorizontalImageAlignment instead + */ + @Deprecated + public ImageBuilder setHorizontalAlignment(HorizontalAlignment horizontalAlignment) { + if (horizontalAlignment != null) { + getObject().setHorizontalImageAlignment(HorizontalImageAlignment.valueOf(horizontalAlignment.name())); + } else { + getObject().setHorizontalImageAlignment(null); + } + return this; + } + + /** + *

setHorizontalImageAlignment.

+ * + * @param horizontalImageAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ImageBuilder} object. + */ + public ImageBuilder setHorizontalImageAlignment(HorizontalImageAlignment horizontalImageAlignment) { + getObject().setHorizontalImageAlignment(horizontalImageAlignment); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/LineBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/LineBuilder.java new file mode 100644 index 0000000..c9c9fa8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/LineBuilder.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRLine; +import software.xdev.dynamicreports.report.builder.style.PenBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.LineDirection; + +/** + *

LineBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class LineBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for LineBuilder.

+ */ + protected LineBuilder() { + super(new DRLine()); + } + + /** + *

setDirection.

+ * + * @param lineDirection a {@link software.xdev.dynamicreports.report.constant.LineDirection} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.LineBuilder} object. + */ + public LineBuilder setDirection(LineDirection lineDirection) { + getObject().setDirection(lineDirection); + return this; + } + + /** + *

setPen.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.LineBuilder} object. + */ + public LineBuilder setPen(PenBuilder pen) { + if (pen != null) { + getObject().setPen(pen.build()); + } else { + getObject().setPen(null); + } + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/MapBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/MapBuilder.java new file mode 100644 index 0000000..0702c40 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/MapBuilder.java @@ -0,0 +1,106 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRMap; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

MapBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class MapBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for MapBuilder.

+ */ + protected MapBuilder() { + super(new DRMap()); + } + + /** + *

setLatitude.

+ * + * @param latitude a {@link java.lang.Float} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MapBuilder} object. + */ + public MapBuilder setLatitude(Float latitude) { + getObject().setLatitudeExpression(Expressions.value(latitude)); + return this; + } + + /** + *

setLatitude.

+ * + * @param latitudeExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MapBuilder} object. + */ + public MapBuilder setLatitude(DRIExpression latitudeExpression) { + getObject().setLatitudeExpression(latitudeExpression); + return this; + } + + /** + *

setLongitude.

+ * + * @param longitude a {@link java.lang.Float} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MapBuilder} object. + */ + public MapBuilder setLongitude(Float longitude) { + getObject().setLongitudeExpression(Expressions.value(longitude)); + return this; + } + + /** + *

setLongitude.

+ * + * @param longitudeExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MapBuilder} object. + */ + public MapBuilder setLongitude(DRIExpression longitudeExpression) { + getObject().setLongitudeExpression(longitudeExpression); + return this; + } + + /** + *

setZoom.

+ * + * @param zoom a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MapBuilder} object. + */ + public MapBuilder setZoom(Integer zoom) { + getObject().setZoomExpression(Expressions.value(zoom)); + return this; + } + + /** + *

setZoom.

+ * + * @param zoomExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MapBuilder} object. + */ + public MapBuilder setZoom(DRIExpression zoomExpression) { + getObject().setZoomExpression(zoomExpression); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/MultiPageListBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/MultiPageListBuilder.java new file mode 100644 index 0000000..6be902f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/MultiPageListBuilder.java @@ -0,0 +1,90 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRMultiPageList; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import org.apache.commons.lang3.Validate; + +/** + *

MultiPageListBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class MultiPageListBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for MultiPageListBuilder.

+ */ + protected MultiPageListBuilder() { + super(new DRMultiPageList()); + } + + /** + *

add.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MultiPageListBuilder} object. + */ + public MultiPageListBuilder add(ComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for (ComponentBuilder component : components) { + getObject().addComponent(component.build()); + } + return this; + } + + /** + *

newPage.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.MultiPageListBuilder} object. + */ + public MultiPageListBuilder newPage() { + BreakBuilder pageBreak = Components.pageBreak(); + pageBreak.setPrintWhenExpression(new PageBreakExpression()); + getObject().addComponent(pageBreak.build()); + return this; + } + + /** + *

setSplitType.

+ * + * @param splitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.MultiPageListBuilder} object. + */ + public MultiPageListBuilder setSplitType(SplitType splitType) { + getObject().setSplitType(splitType); + return this; + } + + private class PageBreakExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + @Override + public Boolean evaluate(ReportParameters reportParameters) { + return reportParameters.getMasterParameters().getPageRowNumber() > 0; + } + + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/PageNumberBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/PageNumberBuilder.java new file mode 100644 index 0000000..032590f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/PageNumberBuilder.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRPageNumber; +import software.xdev.dynamicreports.report.builder.expression.SystemMessageExpression; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

PageNumberBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class PageNumberBuilder extends AbstractFormatFieldBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for PageNumberBuilder.

+ */ + protected PageNumberBuilder() { + super(new DRPageNumber()); + } + + /** {@inheritDoc} */ + @Override + protected void configure() { + if (getObject().getFormatExpression() == null) { + setFormatExpression(new SystemMessageExpression("page_number")); + } + super.configure(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/PageXofYBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/PageXofYBuilder.java new file mode 100644 index 0000000..55a7232 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/PageXofYBuilder.java @@ -0,0 +1,131 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRPageXofY; +import software.xdev.dynamicreports.report.builder.expression.SystemMessageExpression; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

PageXofYBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class PageXofYBuilder extends AbstractFormatFieldBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for PageXofYBuilder.

+ */ + protected PageXofYBuilder() { + super(new DRPageXofY()); + } + + /** + * Sets the pageX component preferred width. + * + * @param width the pageX component preferred width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXofYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXofYBuilder setPageXWidth(Integer width) { + getObject().setPageXWidth(width); + return this; + } + + /** + * Sets the pageX component fixed width. + * + * @param width the pageX component fixed width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXofYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXofYBuilder setPageXFixedWidth(Integer width) { + getObject().setPageXWidth(width); + getObject().setPageXWidthType(ComponentDimensionType.FIXED); + return this; + } + + /** + * Sets the pageX component minimum width. + * + * @param width the pageX component minimum width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXofYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXofYBuilder setPageXMinWidth(Integer width) { + getObject().setPageXWidth(width); + getObject().setPageXWidthType(ComponentDimensionType.EXPAND); + return this; + } + + /** + * Sets the pageY component preferred width. + * + * @param width the pageY component preferred width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXofYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXofYBuilder setPageYWidth(Integer width) { + getObject().setPageYWidth(width); + return this; + } + + /** + * Sets the pageY component fixed width. + * + * @param width the pageY component fixed width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXofYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXofYBuilder setPageYFixedWidth(Integer width) { + getObject().setPageYWidth(width); + getObject().setPageYWidthType(ComponentDimensionType.FIXED); + return this; + } + + /** + * Sets the pageY component minimum width. + * + * @param width the pageY component minimum width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXofYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXofYBuilder setPageYMinWidth(Integer width) { + getObject().setPageYWidth(width); + getObject().setPageYWidthType(ComponentDimensionType.EXPAND); + return this; + } + + /** {@inheritDoc} */ + @Override + protected void configure() { + if (getObject().getFormatExpression() == null) { + setFormatExpression(new SystemMessageExpression("page_x_of_y")); + } + super.configure(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/PageXslashYBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/PageXslashYBuilder.java new file mode 100644 index 0000000..a8dca24 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/PageXslashYBuilder.java @@ -0,0 +1,131 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRPageXofY; +import software.xdev.dynamicreports.report.builder.expression.SystemMessageExpression; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

PageXslashYBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class PageXslashYBuilder extends AbstractFormatFieldBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for PageXslashYBuilder.

+ */ + protected PageXslashYBuilder() { + super(new DRPageXofY()); + } + + /** + * Sets the pageX component preferred width. + * + * @param width the pageX component preferred width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXslashYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXslashYBuilder setPageXWidth(Integer width) { + getObject().setPageXWidth(width); + return this; + } + + /** + * Sets the pageX component fixed width. + * + * @param width the pageX component fixed width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXslashYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXslashYBuilder setPageXFixedWidth(Integer width) { + getObject().setPageXWidth(width); + getObject().setPageXWidthType(ComponentDimensionType.FIXED); + return this; + } + + /** + * Sets the pageX component minimum width. + * + * @param width the pageX component minimum width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXslashYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXslashYBuilder setPageXMinWidth(Integer width) { + getObject().setPageXWidth(width); + getObject().setPageXWidthType(ComponentDimensionType.EXPAND); + return this; + } + + /** + * Sets the pageY component preferred width. + * + * @param width the pageY component preferred width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXslashYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXslashYBuilder setPageYWidth(Integer width) { + getObject().setPageYWidth(width); + return this; + } + + /** + * Sets the pageY component fixed width. + * + * @param width the pageY component fixed width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXslashYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXslashYBuilder setPageYFixedWidth(Integer width) { + getObject().setPageYWidth(width); + getObject().setPageYWidthType(ComponentDimensionType.FIXED); + return this; + } + + /** + * Sets the pageY component minimum width. + * + * @param width the pageY component minimum width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.PageXslashYBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public PageXslashYBuilder setPageYMinWidth(Integer width) { + getObject().setPageYWidth(width); + getObject().setPageYWidthType(ComponentDimensionType.EXPAND); + return this; + } + + /** {@inheritDoc} */ + @Override + protected void configure() { + if (getObject().getFormatExpression() == null) { + setFormatExpression(new SystemMessageExpression("page_x_slash_y")); + } + super.configure(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/RectangleBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/RectangleBuilder.java new file mode 100644 index 0000000..c3a2505 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/RectangleBuilder.java @@ -0,0 +1,65 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRRectangle; +import software.xdev.dynamicreports.report.builder.style.PenBuilder; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

RectangleBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class RectangleBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for RectangleBuilder.

+ */ + protected RectangleBuilder() { + super(new DRRectangle()); + } + + /** + *

setRadius.

+ * + * @param radius a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.RectangleBuilder} object. + */ + public RectangleBuilder setRadius(Integer radius) { + getObject().setRadius(radius); + return this; + } + + /** + *

setPen.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.RectangleBuilder} object. + */ + public RectangleBuilder setPen(PenBuilder pen) { + if (pen != null) { + getObject().setPen(pen.build()); + } else { + getObject().setPen(null); + } + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/SubreportBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/SubreportBuilder.java new file mode 100644 index 0000000..435f22b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/SubreportBuilder.java @@ -0,0 +1,164 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRSubreport; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JasperReport; + +import java.sql.Connection; +import java.util.Map; + +/** + *

SubreportBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class SubreportBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for SubreportBuilder.

+ */ + protected SubreportBuilder() { + super(new DRSubreport()); + } + + // report + + /** + *

setReport.

+ * + * @param reportBuilder a {@link software.xdev.dynamicreports.report.builder.ReportBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder setReport(ReportBuilder reportBuilder) { + getObject().setReportExpression(Expressions.value(reportBuilder)); + return this; + } + + /** + *

setReport.

+ * + * @param jasperReport a {@link net.sf.jasperreports.engine.JasperReport} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder setReport(JasperReport jasperReport) { + getObject().setReportExpression(Expressions.value(jasperReport)); + return this; + } + + /** + *

setReport.

+ * + * @param reportExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder setReport(DRIExpression reportExpression) { + getObject().setReportExpression(reportExpression); + return this; + } + + // parameters + + /** + *

setParameters.

+ * + * @param parameters a {@link java.util.Map} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder setParameters(Map parameters) { + getObject().setParametersExpression(Expressions.value(parameters)); + return this; + } + + /** + *

setParameters.

+ * + * @param parametersExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder setParameters(DRIExpression> parametersExpression) { + getObject().setParametersExpression(parametersExpression); + return this; + } + + // connection + + /** + *

setConnection.

+ * + * @param connection a {@link java.sql.Connection} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder setConnection(Connection connection) { + getObject().setConnectionExpression(Expressions.value(connection)); + return this; + } + + /** + *

setConnection.

+ * + * @param connectionExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder setConnection(DRIExpression connectionExpression) { + getObject().setConnectionExpression(connectionExpression); + return this; + } + + // datasource + + /** + *

setDataSource.

+ * + * @param dataSource a {@link net.sf.jasperreports.engine.JRDataSource} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder setDataSource(JRDataSource dataSource) { + getObject().setDataSourceExpression(Expressions.dataSource(dataSource)); + return this; + } + + /** + *

setDataSource.

+ * + * @param dataSourceExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder setDataSource(DRIExpression dataSourceExpression) { + getObject().setDataSourceExpression(dataSourceExpression); + return this; + } + + /** + *

setRunToBottom.

+ * + * @param runToBottom a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.SubreportBuilder} object. + */ + public SubreportBuilder setRunToBottom(Boolean runToBottom) { + getObject().setRunToBottom(runToBottom); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/TextFieldBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/TextFieldBuilder.java new file mode 100644 index 0000000..4a86a26 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/TextFieldBuilder.java @@ -0,0 +1,352 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import java.util.Date; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.VariableBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.constant.HorizontalAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; + +/** + *

TextFieldBuilder class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +@SuppressWarnings("deprecation") +public class TextFieldBuilder extends HyperLinkComponentBuilder, DRTextField> { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for TextFieldBuilder.

+ */ + protected TextFieldBuilder() { + super(new DRTextField()); + } + + /** + *

setText.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setText(final VariableBuilder variable) { + Validate.notNull(variable, "variable must not be null"); + getObject().setValueExpression(variable.getVariable()); + return this; + } + + /** + *

setText.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setText(final FieldBuilder field) { + Validate.notNull(field, "field must not be null"); + getObject().setValueExpression(field.getField()); + if (getObject().getDataType() == null) { + getObject().setDataType(field.getField().getDataType()); + } + return this; + } + + /** + *

setText.

+ * + * @param textExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setText(final DRIExpression textExpression) { + getObject().setValueExpression(textExpression); + if (textExpression instanceof DRIField && getObject().getDataType() == null) { + getObject().setDataType(((DRIField) textExpression).getDataType()); + } + return this; + } + + /** + *

setText.

+ * + * @param text a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + @SuppressWarnings("unchecked") + public TextFieldBuilder setText(final String text) { + getObject().setValueExpression((DRIExpression) Expressions.text(text)); + return this; + } + + /** + *

setText.

+ * + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + @SuppressWarnings("unchecked") + public TextFieldBuilder setText(final Number number) { + getObject().setValueExpression((DRIExpression) Expressions.number(number)); + return this; + } + + /** + *

setText.

+ * + * @param date a {@link java.util.Date} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + @SuppressWarnings("unchecked") + public TextFieldBuilder setText(final Date date) { + getObject().setValueExpression((DRIExpression) Expressions.date(date)); + return this; + } + + /** + *

setPattern.

+ * + * @param pattern a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setPattern(final String pattern) { + getObject().setPattern(pattern); + return this; + } + + /** + *

setPattern.

+ * + * @param patternExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setPattern(final DRIExpression patternExpression) { + getObject().setPatternExpression(patternExpression); + return this; + } + + /** + *

setHorizontalAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalAlignment} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + * @deprecated use setHorizontalTextAlignment instead + */ + @Deprecated + public TextFieldBuilder setHorizontalAlignment(final HorizontalAlignment horizontalAlignment) { + if (horizontalAlignment != null) { + getObject().setHorizontalTextAlignment(HorizontalTextAlignment.valueOf(horizontalAlignment.name())); + } else { + getObject().setHorizontalTextAlignment(null); + } + return this; + } + + /** + *

setHorizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setHorizontalTextAlignment(final HorizontalTextAlignment horizontalTextAlignment) { + getObject().setHorizontalTextAlignment(horizontalTextAlignment); + return this; + } + + /** + *

setValueFormatter.

+ * + * @param valueFormatter a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setValueFormatter(final DRIValueFormatter valueFormatter) { + getObject().setValueFormatter(valueFormatter); + return this; + } + + /** + *

setDataType.

+ * + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setDataType(final DRIDataType dataType) { + getObject().setDataType(dataType); + return this; + } + + /** + * This method is used to define the preferred width of a textField. The width is set to the columns multiplied by width of the character m for the font used + * + * @param columns the number of preferred columns >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + * @throws java.lang.IllegalArgumentException if columns is < 0 + */ + public TextFieldBuilder setColumns(final Integer columns) { + getObject().setColumns(columns); + return this; + } + + /** + * This method is used to define the fixed width of a textField. The width is set to the columns multiplied by width of the character m for the font used + * + * @param columns the number of fixed columns >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + * @throws java.lang.IllegalArgumentException if columns is < 0 + */ + public TextFieldBuilder setFixedColumns(final Integer columns) { + getObject().setColumns(columns); + getObject().setWidthType(ComponentDimensionType.FIXED); + return this; + } + + /** + * This method is used to define the minimum width of a textField. The width is set to the columns multiplied by width of the character m for the font used + * + * @param columns the number of minimum columns >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + * @throws java.lang.IllegalArgumentException if columns is < 0 + */ + public TextFieldBuilder setMinColumns(final Integer columns) { + getObject().setColumns(columns); + getObject().setWidthType(ComponentDimensionType.EXPAND); + return this; + } + + /** + * This method is used to define the preferred height of a textField. The height is set to the rows multiplied by height of the font + * + * @param rows the number of preferred rows >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public TextFieldBuilder setRows(final Integer rows) { + getObject().setRows(rows); + return this; + } + + /** + * This method is used to define the fixed height of a textField. The height is set to the rows multiplied by height of the font + * + * @param rows the number of fixed rows >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public TextFieldBuilder setFixedRows(final Integer rows) { + getObject().setRows(rows); + getObject().setHeightType(ComponentDimensionType.FIXED); + return this; + } + + /** + * This method is used to define the minimum height of a textField. The height is set to the rows multiplied by height of the font + * + * @param rows the number of minimum rows >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public TextFieldBuilder setMinRows(final Integer rows) { + getObject().setRows(rows); + getObject().setHeightType(ComponentDimensionType.EXPAND); + return this; + } + + /** + *

setEvaluationTime.

+ * + * @param evaluationTime a {@link software.xdev.dynamicreports.report.constant.Evaluation} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setEvaluationTime(final Evaluation evaluationTime) { + getObject().setEvaluationTime(evaluationTime); + return this; + } + + /** + *

setEvaluationGroup.

+ * + * @param evaluationGroup a {@link software.xdev.dynamicreports.report.builder.group.GroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setEvaluationGroup(final GroupBuilder evaluationGroup) { + Validate.notNull(evaluationGroup, "evaluationGroup must not be null"); + getObject().setEvaluationGroup(evaluationGroup.build()); + getObject().setEvaluationTime(Evaluation.GROUP); + return this; + } + + /** + *

setMarkup.

+ * + * @param markup a {@link software.xdev.dynamicreports.report.constant.Markup} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setMarkup(final Markup markup) { + getObject().setMarkup(markup); + return this; + } + + /** + *

setStretchWithOverflow.

+ * + * @param stretchWithOverflow a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + * @deprecated replaced by {@link #setTextAdjust(TextAdjust)} + */ + @Deprecated + public TextFieldBuilder setStretchWithOverflow(final Boolean stretchWithOverflow) { + getObject().setStretchWithOverflow(stretchWithOverflow); + return this; + } + + /** + *

setTextAdjust.

+ * + * @param textAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + * @return a T object. + */ + public TextFieldBuilder setTextAdjust(final TextAdjust textAdjust) { + getObject().setTextAdjust(textAdjust); + return this; + } + + /** + *

setPrintRepeatedValues.

+ * + * @param printRepeatedValues a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.TextFieldBuilder} object. + */ + public TextFieldBuilder setPrintRepeatedValues(final Boolean printRepeatedValues) { + getObject().setPrintRepeatedValues(printRepeatedValues); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/TotalPagesBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/TotalPagesBuilder.java new file mode 100644 index 0000000..5f3f8c5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/TotalPagesBuilder.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRTotalPages; +import software.xdev.dynamicreports.report.builder.expression.SystemMessageExpression; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

TotalPagesBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class TotalPagesBuilder extends AbstractFormatFieldBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for TotalPagesBuilder.

+ */ + protected TotalPagesBuilder() { + super(new DRTotalPages()); + } + + /** {@inheritDoc} */ + @Override + protected void configure() { + if (getObject().getFormatExpression() == null) { + setFormatExpression(new SystemMessageExpression("total_pages")); + } + super.configure(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/VerticalListBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/VerticalListBuilder.java new file mode 100644 index 0000000..85ae4ba --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/VerticalListBuilder.java @@ -0,0 +1,133 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRList; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.ListType; +import org.apache.commons.lang3.Validate; + +/** + *

VerticalListBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class VerticalListBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for VerticalListBuilder.

+ */ + protected VerticalListBuilder() { + super(new DRList(ListType.VERTICAL)); + } + + /** + *

add.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public VerticalListBuilder add(ComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for (ComponentBuilder component : components) { + getObject().addComponent(component.getComponent()); + } + return this; + } + + /** + *

add.

+ * + * @param gap a {@link java.lang.Integer} object. + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public VerticalListBuilder add(Integer gap, ComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + for (ComponentBuilder component : components) { + add(Components.vListCell(Components.filler().setHeight(gap)).heightFixed()); + add(component); + } + return this; + } + + /** + *

add.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public VerticalListBuilder add(VerticalListCellBuilder... cells) { + Validate.notNull(cells, "cells must not be null"); + Validate.noNullElements(cells, "cells must not contains null cell"); + for (VerticalListCellBuilder cell : cells) { + getObject().addCell(cell.build()); + } + return this; + } + + /** + *

add.

+ * + * @param gap a {@link java.lang.Integer} object. + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public VerticalListBuilder add(Integer gap, VerticalListCellBuilder... cells) { + Validate.notNull(cells, "cells must not be null"); + for (VerticalListCellBuilder cell : cells) { + add(Components.vListCell(Components.filler().setHeight(gap)).heightFixed(), cell); + } + return this; + } + + /** + *

setGap.

+ * + * @param gap a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public VerticalListBuilder setGap(Integer gap) { + getObject().setGap(gap); + return this; + } + + /** + *

setBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListBuilder} object. + */ + public VerticalListBuilder setBackgroundComponent(ComponentBuilder backgroundComponent) { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + getObject().setBackgroundComponent(backgroundComponent.build()); + return this; + } + + /** + *

getList.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.component.DRList} object. + */ + public DRList getList() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/VerticalListCellBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/VerticalListCellBuilder.java new file mode 100644 index 0000000..b8993d3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/VerticalListCellBuilder.java @@ -0,0 +1,126 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRListCell; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; + +/** + *

VerticalListCellBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class VerticalListCellBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for VerticalListCellBuilder.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + */ + protected VerticalListCellBuilder(ComponentBuilder component) { + super(new DRListCell(component.build())); + } + + // width + + /** + *

widthFixedOnLeft.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + */ + public VerticalListCellBuilder widthFixedOnLeft() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.LEFT); + return this; + } + + /** + *

widthFixedOnCenter.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + */ + public VerticalListCellBuilder widthFixedOnCenter() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.CENTER); + return this; + } + + /** + *

widthFixedOnRight.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + */ + public VerticalListCellBuilder widthFixedOnRight() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.RIGHT); + return this; + } + + /** + *

widthFloat.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + */ + public VerticalListCellBuilder widthFloat() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.FLOAT); + return this; + } + + /** + *

widthExpand.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + */ + public VerticalListCellBuilder widthExpand() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.EXPAND); + return this; + } + + // height + + /** + *

heightFixed.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + */ + public VerticalListCellBuilder heightFixed() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.TOP); + return this; + } + + /** + *

heightExpand.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.VerticalListCellBuilder} object. + */ + public VerticalListCellBuilder heightExpand() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.EXPAND); + return this; + } + + /** + *

getListCell.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.component.DRListCell} object. + */ + public DRListCell getListCell() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/XyListBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/XyListBuilder.java new file mode 100644 index 0000000..6a13e70 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/XyListBuilder.java @@ -0,0 +1,101 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRXyList; +import software.xdev.dynamicreports.report.constant.Constants; +import org.apache.commons.lang3.Validate; + +/** + *

XyListBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class XyListBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for XyListBuilder.

+ */ + protected XyListBuilder() { + super(new DRXyList()); + } + + /** + *

add.

+ * + * @param x a {@link java.lang.Integer} object. + * @param y a {@link java.lang.Integer} object. + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.XyListBuilder} object. + */ + public XyListBuilder add(Integer x, Integer y, ComponentBuilder component) { + Validate.notNull(x, "x must not be null"); + Validate.notNull(y, "y must not be null"); + Validate.notNull(component, "component must not be null"); + getObject().addComponent(x, y, component.getComponent()); + return this; + } + + /** + *

add.

+ * + * @param x a {@link java.lang.Integer} object. + * @param y a {@link java.lang.Integer} object. + * @param width a {@link java.lang.Integer} object. + * @param height a {@link java.lang.Integer} object. + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.XyListBuilder} object. + */ + public XyListBuilder add(Integer x, Integer y, Integer width, Integer height, ComponentBuilder component) { + Validate.notNull(x, "x must not be null"); + Validate.notNull(y, "y must not be null"); + Validate.notNull(component, "component must not be null"); + if (component instanceof DimensionComponentBuilder) { + ((DimensionComponentBuilder) component).setWidth(width); + ((DimensionComponentBuilder) component).setHeight(height); + } + getObject().addComponent(x, y, component.getComponent()); + return this; + } + + /** + *

add.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.component.XyListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.component.XyListBuilder} object. + */ + public XyListBuilder add(XyListCellBuilder... cells) { + Validate.notNull(cells, "cells must not be null"); + Validate.noNullElements(cells, "cells must not contains null cell"); + for (XyListCellBuilder cell : cells) { + getObject().addCell(cell.build()); + } + return this; + } + + /** + *

getXyList.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.component.DRXyList} object. + */ + public DRXyList getXyList() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/XyListCellBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/XyListCellBuilder.java new file mode 100644 index 0000000..66a2379 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/component/XyListCellBuilder.java @@ -0,0 +1,69 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.component; + +import software.xdev.dynamicreports.report.base.component.DRXyListCell; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

XyListCellBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class XyListCellBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for XyListCellBuilder.

+ * + * @param x a {@link java.lang.Integer} object. + * @param y a {@link java.lang.Integer} object. + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + */ + protected XyListCellBuilder(Integer x, Integer y, ComponentBuilder component) { + super(new DRXyListCell(x, y, component.build())); + } + + /** + *

Constructor for XyListCellBuilder.

+ * + * @param x a {@link java.lang.Integer} object. + * @param y a {@link java.lang.Integer} object. + * @param width a {@link java.lang.Integer} object. + * @param height a {@link java.lang.Integer} object. + * @param component a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + */ + protected XyListCellBuilder(Integer x, Integer y, Integer width, Integer height, ComponentBuilder component) { + super(new DRXyListCell(x, y, component.build())); + if (component instanceof DimensionComponentBuilder) { + ((DimensionComponentBuilder) component).setWidth(width); + ((DimensionComponentBuilder) component).setHeight(height); + } + } + + /** + *

getXyListCell.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.component.DRXyListCell} object. + */ + public DRXyListCell getXyListCell() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/AbstractBetweenValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/AbstractBetweenValueExpression.java new file mode 100644 index 0000000..b4199ce --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/AbstractBetweenValueExpression.java @@ -0,0 +1,81 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract AbstractBetweenValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractBetweenValueExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIValue value; + private Number min; + private Number max; + + /** + *

Constructor for AbstractBetweenValueExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param min a {@link java.lang.Number} object. + * @param max a {@link java.lang.Number} object. + */ + public AbstractBetweenValueExpression(DRIValue value, Number min, Number max) { + Validate.notNull(value, "value must not be null"); + Validate.notNull(min, "min must not be null"); + Validate.notNull(max, "min must not be null"); + Validate.isTrue(min.doubleValue() < max.doubleValue(), "min < max"); + this.value = value; + this.min = min; + this.max = max; + } + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + Number actualValue = reportParameters.getValue(value); + if (actualValue != null) { + return compare(actualValue, min, max); + } + return false; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return Boolean.class; + } + + /** + *

compare.

+ * + * @param actualValue a {@link java.lang.Number} object. + * @param min a {@link java.lang.Number} object. + * @param max a {@link java.lang.Number} object. + * @return a {@link java.lang.Boolean} object. + */ + protected abstract Boolean compare(Number actualValue, Number min, Number max); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/AbstractValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/AbstractValueExpression.java new file mode 100644 index 0000000..3dfc338 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/AbstractValueExpression.java @@ -0,0 +1,75 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract AbstractValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractValueExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIValue value; + private Number number; + + /** + *

Constructor for AbstractValueExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + */ + public AbstractValueExpression(DRIValue value, Number number) { + Validate.notNull(value, "value must not be null"); + Validate.notNull(number, "number must not be null"); + this.value = value; + this.number = number; + } + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + Number actualValue = reportParameters.getValue(value); + if (actualValue != null) { + return compare(actualValue, number); + } + return false; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return Boolean.class; + } + + /** + *

compare.

+ * + * @param actualValue a {@link java.lang.Number} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link java.lang.Boolean} object. + */ + protected abstract Boolean compare(Number actualValue, Number number); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/AbstractValuesExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/AbstractValuesExpression.java new file mode 100644 index 0000000..7da69d6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/AbstractValuesExpression.java @@ -0,0 +1,75 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract AbstractValuesExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractValuesExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIValue value; + private Number[] numbers; + + /** + *

Constructor for AbstractValuesExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param numbers a {@link java.lang.Number} object. + */ + public AbstractValuesExpression(DRIValue value, Number... numbers) { + Validate.notNull(value, "value must not be null"); + Validate.noNullElements(numbers, "numbers must not contains null number"); + this.value = value; + this.numbers = numbers; + } + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + Number actualValue = reportParameters.getValue(value); + if (actualValue != null) { + return compare(actualValue, numbers); + } + return false; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return Boolean.class; + } + + /** + *

compare.

+ * + * @param actualValue a {@link java.lang.Number} object. + * @param numbers an array of {@link java.lang.Number} objects. + * @return a {@link java.lang.Boolean} object. + */ + protected abstract Boolean compare(Number actualValue, Number[] numbers); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/BetweenValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/BetweenValueExpression.java new file mode 100644 index 0000000..7764252 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/BetweenValueExpression.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; + +/** + *

BetweenValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class BetweenValueExpression extends AbstractBetweenValueExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for BetweenValueExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param min a {@link java.lang.Number} object. + * @param max a {@link java.lang.Number} object. + */ + public BetweenValueExpression(DRIValue value, Number min, Number max) { + super(value, min, max); + } + + /** {@inheritDoc} */ + @Override + protected Boolean compare(Number actualValue, Number min, Number max) { + return actualValue.doubleValue() >= min.doubleValue() && actualValue.doubleValue() <= max.doubleValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/ConditionBuilders.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/ConditionBuilders.java new file mode 100644 index 0000000..56659b1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/ConditionBuilders.java @@ -0,0 +1,147 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.definition.DRIValue; + +/** + * A set of build in condition expressions + * + * @author Ricardo Mariaca + * + */ +public class ConditionBuilders { + + /** + *

equal.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param values a T object. + * @param values a T object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.EqualExpression} object. + */ + @SuppressWarnings("unchecked") + public EqualExpression equal(DRIValue value, T... values) { + return Conditions.equal(value, values); + } + + /** + *

equal.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.EqualValueExpression} object. + */ + public EqualValueExpression equal(DRIValue value, Number... number) { + return Conditions.equal(value, number); + } + + /** + *

unEqual.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param values a T object. + * @param values a T object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.UnEqualExpression} object. + */ + @SuppressWarnings("unchecked") + public UnEqualExpression unEqual(DRIValue value, T... values) { + return Conditions.unEqual(value, values); + } + + /** + *

unEqual.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.UnEqualValueExpression} object. + */ + public UnEqualValueExpression unEqual(DRIValue value, Number... number) { + return Conditions.unEqual(value, number); + } + + /** + *

smaller.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.SmallerValueExpression} object. + */ + public SmallerValueExpression smaller(DRIValue value, Number number) { + return Conditions.smaller(value, number); + } + + /** + *

smallerOrEquals.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.SmallerOrEqualsValueExpression} object. + */ + public SmallerOrEqualsValueExpression smallerOrEquals(DRIValue value, Number number) { + return Conditions.smallerOrEquals(value, number); + } + + /** + *

greater.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.GreaterValueExpression} object. + */ + public GreaterValueExpression greater(DRIValue value, Number number) { + return Conditions.greater(value, number); + } + + /** + *

greaterOrEquals.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.GreaterOrEqualsValueExpression} object. + */ + public GreaterOrEqualsValueExpression greaterOrEquals(DRIValue value, Number number) { + return Conditions.greaterOrEquals(value, number); + } + + /** + *

between.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param min a {@link java.lang.Number} object. + * @param max a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.BetweenValueExpression} object. + */ + public BetweenValueExpression between(DRIValue value, Number min, Number max) { + return Conditions.between(value, min, max); + } + + /** + *

notBetween.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param min a {@link java.lang.Number} object. + * @param max a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.NotBetweenValueExpression} object. + */ + public NotBetweenValueExpression notBetween(DRIValue value, Number min, Number max) { + return Conditions.notBetween(value, min, max); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/Conditions.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/Conditions.java new file mode 100644 index 0000000..a9acdf3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/Conditions.java @@ -0,0 +1,147 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.definition.DRIValue; + +/** + * A set of build in condition expressions + * + * @author Ricardo Mariaca + * + */ +public class Conditions { + + /** + *

equal.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param values a T object. + * @param values a T object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.EqualExpression} object. + */ + @SafeVarargs + public static EqualExpression equal(DRIValue value, T... values) { + return new EqualExpression(value, values); + } + + /** + *

equal.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.EqualValueExpression} object. + */ + public static EqualValueExpression equal(DRIValue value, Number... number) { + return new EqualValueExpression(value, number); + } + + /** + *

unEqual.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param values a T object. + * @param values a T object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.UnEqualExpression} object. + */ + @SafeVarargs + public static UnEqualExpression unEqual(DRIValue value, T... values) { + return new UnEqualExpression(value, values); + } + + /** + *

unEqual.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.UnEqualValueExpression} object. + */ + public static UnEqualValueExpression unEqual(DRIValue value, Number... number) { + return new UnEqualValueExpression(value, number); + } + + /** + *

smaller.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.SmallerValueExpression} object. + */ + public static SmallerValueExpression smaller(DRIValue value, Number number) { + return new SmallerValueExpression(value, number); + } + + /** + *

smallerOrEquals.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.SmallerOrEqualsValueExpression} object. + */ + public static SmallerOrEqualsValueExpression smallerOrEquals(DRIValue value, Number number) { + return new SmallerOrEqualsValueExpression(value, number); + } + + /** + *

greater.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.GreaterValueExpression} object. + */ + public static GreaterValueExpression greater(DRIValue value, Number number) { + return new GreaterValueExpression(value, number); + } + + /** + *

greaterOrEquals.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.GreaterOrEqualsValueExpression} object. + */ + public static GreaterOrEqualsValueExpression greaterOrEquals(DRIValue value, Number number) { + return new GreaterOrEqualsValueExpression(value, number); + } + + /** + *

between.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param min a {@link java.lang.Number} object. + * @param max a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.BetweenValueExpression} object. + */ + public static BetweenValueExpression between(DRIValue value, Number min, Number max) { + return new BetweenValueExpression(value, min, max); + } + + /** + *

notBetween.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param min a {@link java.lang.Number} object. + * @param max a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.condition.NotBetweenValueExpression} object. + */ + public static NotBetweenValueExpression notBetween(DRIValue value, Number min, Number max) { + return new NotBetweenValueExpression(value, min, max); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/EqualExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/EqualExpression.java new file mode 100644 index 0000000..ffd2b05 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/EqualExpression.java @@ -0,0 +1,70 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import org.apache.commons.lang3.Validate; + +/** + *

EqualExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class EqualExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIValue value; + private Object[] values; + + @SafeVarargs + /** + * Constructor for EqualExpression. + * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param values a T object. + * @param a T object. + */ + public EqualExpression(DRIValue value, T... values) { + Validate.notNull(value, "value must not be null"); + Validate.noNullElements(values, "values must not contains null value"); + this.value = value; + this.values = values; + } + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + Object actualValue = reportParameters.getValue(value); + for (Object value : values) { + if (value.equals(actualValue)) { + return true; + } + } + return false; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return Boolean.class; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/EqualValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/EqualValueExpression.java new file mode 100644 index 0000000..34c3406 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/EqualValueExpression.java @@ -0,0 +1,52 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; + +/** + *

EqualValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class EqualValueExpression extends AbstractValuesExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for EqualValueExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param numbers a {@link java.lang.Number} object. + */ + public EqualValueExpression(DRIValue value, Number... numbers) { + super(value, numbers); + } + + /** {@inheritDoc} */ + @Override + protected Boolean compare(Number actualValue, Number[] numbers) { + for (Number number : numbers) { + if (actualValue.doubleValue() == number.doubleValue()) { + return true; + } + } + return false; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/GreaterOrEqualsValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/GreaterOrEqualsValueExpression.java new file mode 100644 index 0000000..016a9bc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/GreaterOrEqualsValueExpression.java @@ -0,0 +1,47 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; + +/** + *

GreaterOrEqualsValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class GreaterOrEqualsValueExpression extends AbstractValueExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for GreaterOrEqualsValueExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + */ + public GreaterOrEqualsValueExpression(DRIValue value, Number number) { + super(value, number); + } + + /** {@inheritDoc} */ + @Override + protected Boolean compare(Number actualValue, Number number) { + return actualValue.doubleValue() >= number.doubleValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/GreaterValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/GreaterValueExpression.java new file mode 100644 index 0000000..dc62dd9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/GreaterValueExpression.java @@ -0,0 +1,47 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; + +/** + *

GreaterValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class GreaterValueExpression extends AbstractValueExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for GreaterValueExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + */ + public GreaterValueExpression(DRIValue value, Number number) { + super(value, number); + } + + /** {@inheritDoc} */ + @Override + protected Boolean compare(Number actualValue, Number number) { + return actualValue.doubleValue() > number.doubleValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/NotBetweenValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/NotBetweenValueExpression.java new file mode 100644 index 0000000..cdde217 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/NotBetweenValueExpression.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; + +/** + *

NotBetweenValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class NotBetweenValueExpression extends AbstractBetweenValueExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for NotBetweenValueExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param min a {@link java.lang.Number} object. + * @param max a {@link java.lang.Number} object. + */ + public NotBetweenValueExpression(DRIValue value, Number min, Number max) { + super(value, min, max); + } + + /** {@inheritDoc} */ + @Override + protected Boolean compare(Number actualValue, Number min, Number max) { + return actualValue.doubleValue() < min.doubleValue() || actualValue.doubleValue() > max.doubleValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/SmallerOrEqualsValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/SmallerOrEqualsValueExpression.java new file mode 100644 index 0000000..9715889 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/SmallerOrEqualsValueExpression.java @@ -0,0 +1,47 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; + +/** + *

SmallerOrEqualsValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class SmallerOrEqualsValueExpression extends AbstractValueExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for SmallerOrEqualsValueExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + */ + public SmallerOrEqualsValueExpression(DRIValue value, Number number) { + super(value, number); + } + + /** {@inheritDoc} */ + @Override + protected Boolean compare(Number actualValue, Number number) { + return actualValue.doubleValue() <= number.doubleValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/SmallerValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/SmallerValueExpression.java new file mode 100644 index 0000000..f2605d8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/SmallerValueExpression.java @@ -0,0 +1,47 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; + +/** + *

SmallerValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class SmallerValueExpression extends AbstractValueExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for SmallerValueExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param number a {@link java.lang.Number} object. + */ + public SmallerValueExpression(DRIValue value, Number number) { + super(value, number); + } + + /** {@inheritDoc} */ + @Override + protected Boolean compare(Number actualValue, Number number) { + return actualValue.doubleValue() < number.doubleValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/UnEqualExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/UnEqualExpression.java new file mode 100644 index 0000000..42cae79 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/UnEqualExpression.java @@ -0,0 +1,70 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import org.apache.commons.lang3.Validate; + +/** + *

UnEqualExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class UnEqualExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIValue value; + private Object[] values; + + @SafeVarargs + /** + *

Constructor for UnEqualExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param values a T object. + * @param a T object. + */ + public UnEqualExpression(DRIValue value, T... values) { + Validate.notNull(value, "value must not be null"); + Validate.noNullElements(values, "values must not contains null value"); + this.value = value; + this.values = values; + } + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + Object actualValue = reportParameters.getValue(value); + for (Object value : values) { + if (value.equals(actualValue)) { + return false; + } + } + return true; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return Boolean.class; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/UnEqualValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/UnEqualValueExpression.java new file mode 100644 index 0000000..37b06f4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/condition/UnEqualValueExpression.java @@ -0,0 +1,52 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.condition; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; + +/** + *

UnEqualValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class UnEqualValueExpression extends AbstractValuesExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for UnEqualValueExpression.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param numbers a {@link java.lang.Number} object. + */ + public UnEqualValueExpression(DRIValue value, Number... numbers) { + super(value, numbers); + } + + /** {@inheritDoc} */ + @Override + protected Boolean compare(Number actualValue, Number[] numbers) { + for (Number number : numbers) { + if (actualValue.doubleValue() == number.doubleValue()) { + return false; + } + } + return true; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/AbstractCrosstabGroupBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/AbstractCrosstabGroupBuilder.java new file mode 100644 index 0000000..8a509e1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/AbstractCrosstabGroupBuilder.java @@ -0,0 +1,423 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.crosstab; + +import java.util.Comparator; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.base.column.DRValueColumn; +import software.xdev.dynamicreports.report.base.crosstab.DRCrosstabGroup; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.HyperLinkBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.CrosstabTotalPosition; +import software.xdev.dynamicreports.report.constant.HorizontalAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.OrderType; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; + +/** + *

Abstract AbstractCrosstabGroupBuilder class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +@SuppressWarnings( {"unchecked", "deprecation"}) +public abstract class AbstractCrosstabGroupBuilder, U extends DRCrosstabGroup, V> extends AbstractBuilder implements DRIValue { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for AbstractCrosstabGroupBuilder.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param crosstabGroup a U object. + */ + protected AbstractCrosstabGroupBuilder(final ValueColumnBuilder column, final U crosstabGroup) { + super(crosstabGroup); + Validate.notNull(column, "column must not be null"); + final DRValueColumn col = column.getColumn(); + getObject().setExpression(col); + getObject().setDataType(col.getComponent().getDataType()); + getObject().setHeaderPattern(col.getComponent().getPattern()); + } + + /** + *

Constructor for AbstractCrosstabGroupBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param crosstabGroup a U object. + */ + protected AbstractCrosstabGroupBuilder(final FieldBuilder field, final U crosstabGroup) { + super(crosstabGroup); + Validate.notNull(field, "field must not be null"); + getObject().setExpression(field.getField()); + getObject().setDataType(field.getField().getDataType()); + } + + /** + *

Constructor for AbstractCrosstabGroupBuilder.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param crosstabGroup a U object. + */ + protected AbstractCrosstabGroupBuilder(final DRIExpression expression, final U crosstabGroup) { + super(crosstabGroup); + getObject().setExpression(expression); + if (expression instanceof DRIField) { + getObject().setDataType(((DRIField) expression).getDataType()); + } + } + + /** + *

setHeaderPattern.

+ * + * @param pattern a {@link java.lang.String} object. + * @return a T object. + */ + public T setHeaderPattern(final String pattern) { + getObject().setHeaderPattern(pattern); + return (T) this; + } + + /** + *

setHeaderHorizontalAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalAlignment} object. + * @return a T object. + * @deprecated use setHeaderHorizontalTextAlignment instead + */ + @Deprecated + public T setHeaderHorizontalAlignment(final HorizontalAlignment horizontalAlignment) { + if (horizontalAlignment != null) { + getObject().setHeaderHorizontalTextAlignment(HorizontalTextAlignment.valueOf(horizontalAlignment.name())); + } else { + getObject().setHeaderHorizontalTextAlignment(null); + } + return (T) this; + } + + /** + *

setHeaderHorizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + * @return a T object. + */ + public T setHeaderHorizontalTextAlignment(final HorizontalTextAlignment horizontalTextAlignment) { + getObject().setHeaderHorizontalTextAlignment(horizontalTextAlignment); + return (T) this; + } + + /** + *

setHeaderValueFormatter.

+ * + * @param valueFormatter a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + * @return a T object. + */ + public T setHeaderValueFormatter(final DRIValueFormatter valueFormatter) { + getObject().setHeaderValueFormatter(valueFormatter); + return (T) this; + } + + /** + *

setHeaderStretchWithOverflow.

+ * + * @param stretchWithOverflow a {@link java.lang.Boolean} object. + * @return a T object. + * @deprecated replaced by {@link #setHeaderTextAdjust(TextAdjust)} + */ + @Deprecated + public T setHeaderStretchWithOverflow(final Boolean stretchWithOverflow) { + getObject().setHeaderStretchWithOverflow(stretchWithOverflow); + return (T) this; + } + + /** + *

setHeaderTextAdjust.

+ * + * @param textAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + * @return a T object. + */ + public T setHeaderTextAdjust(final TextAdjust textAdjust) { + getObject().setHeaderTextAdjust(textAdjust); + return (T )this; + } + + /** + * Sets the crosstab group header hyperlink. + * + * @param hyperLink the group header hyperlink + * @return a crosstab group builder + */ + public T setHeaderHyperLink(final HyperLinkBuilder hyperLink) { + if (hyperLink != null) { + getObject().setHeaderHyperLink(hyperLink.getHyperLink()); + } else { + getObject().setHeaderHyperLink(null); + } + return (T) this; + } + + /** + *

setHeaderStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a T object. + */ + public T setHeaderStyle(final ReportStyleBuilder style) { + if (style != null) { + getObject().setHeaderStyle(style.getStyle()); + } else { + getObject().setHeaderStyle(null); + } + return (T) this; + } + + /** + * Adds a jasper property to the header group. + * + * @param propertyExpression the property expression + * @return a crosstab group builder + */ + public T addHeaderProperty(final DRIPropertyExpression propertyExpression) { + getObject().addHeaderPropertyExpression(propertyExpression); + return (T) this; + } + + /** + * Adds a jasper property to the header group. + * + * @param name the property name + * @param valueExpression the property value expression + * @return a crosstab group builder + */ + public T addHeaderProperty(final String name, final DRIExpression valueExpression) { + getObject().addHeaderPropertyExpression(Expressions.property(name, valueExpression)); + return (T) this; + } + + /** + * Adds a jasper property to the header group. + * + * @param name the property name + * @param value the property value + * @return a crosstab group builder + */ + public T addHeaderProperty(final String name, final String value) { + getObject().addHeaderPropertyExpression(Expressions.property(name, value)); + return (T) this; + } + + /** + *

setShowTotal.

+ * + * @param showTotal a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setShowTotal(final Boolean showTotal) { + getObject().setShowTotal(showTotal); + return (T) this; + } + + /** + *

setTotalPosition.

+ * + * @param totalPosition a {@link software.xdev.dynamicreports.report.constant.CrosstabTotalPosition} object. + * @return a T object. + */ + public T setTotalPosition(final CrosstabTotalPosition totalPosition) { + getObject().setTotalPosition(totalPosition); + return (T) this; + } + + /** + *

setTotalHeader.

+ * + * @param totalHeaderExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setTotalHeader(final DRIExpression totalHeaderExpression) { + getObject().setTotalHeaderExpression(totalHeaderExpression); + return (T) this; + } + + /** + *

setTotalHeader.

+ * + * @param totalHeader a {@link java.lang.String} object. + * @return a T object. + */ + public T setTotalHeader(final String totalHeader) { + getObject().setTotalHeaderExpression(Expressions.text(totalHeader)); + return (T) this; + } + + /** + *

setTotalHeaderStretchWithOverflow.

+ * + * @param stretchWithOverflow a {@link java.lang.Boolean} object. + * @return a T object. + * @deprecated replaced by {@link #setTotalHeaderTextAdjust(TextAdjust)} + */ + @Deprecated + public T setTotalHeaderStretchWithOverflow(final Boolean stretchWithOverflow) { + getObject().setTotalHeaderStretchWithOverflow(stretchWithOverflow); + return (T) this; + } + + /** + *

setTotalHeaderTextAdjust.

+ * + * @param textAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + * @return a T object. + */ + public T setTotalHeaderTextAdjust(final TextAdjust textAdjust) { + getObject().setTotalHeaderTextAdjust(textAdjust); + return (T )this; + } + + /** + *

setTotalHeaderStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a T object. + */ + public T setTotalHeaderStyle(final ReportStyleBuilder style) { + if (style != null) { + getObject().setTotalHeaderStyle(style.getStyle()); + } else { + getObject().setTotalHeaderStyle(null); + } + return (T) this; + } + + /** + * Adds a jasper property to the total header group. + * + * @param propertyExpression the property expression + * @return a crosstab group builder + */ + public T addTotalHeaderProperty(final DRIPropertyExpression propertyExpression) { + getObject().addTotalHeaderPropertyExpression(propertyExpression); + return (T) this; + } + + /** + * Adds a jasper property to the total header group. + * + * @param name the property name + * @param valueExpression the property value expression + * @return a crosstab group builder + */ + public T addTotalHeaderProperty(final String name, final DRIExpression valueExpression) { + getObject().addTotalHeaderPropertyExpression(Expressions.property(name, valueExpression)); + return (T) this; + } + + /** + * Adds a jasper property to the total header group. + * + * @param name the property name + * @param value the property value + * @return a crosstab group builder + */ + public T addTotalHeaderProperty(final String name, final String value) { + getObject().addTotalHeaderPropertyExpression(Expressions.property(name, value)); + return (T) this; + } + + /** + *

setDataType.

+ * + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + * @return a T object. + */ + public T setDataType(final DRIDataType dataType) { + getObject().setDataType(dataType); + return (T) this; + } + + /** + *

setOrderType.

+ * + * @param orderType a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + * @return a T object. + */ + public T setOrderType(final OrderType orderType) { + getObject().setOrderType(orderType); + return (T) this; + } + + /** + *

setOrderByExpression.

+ * + * @param orderByExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setOrderByExpression(final DRIExpression> orderByExpression) { + return orderBy(orderByExpression); + } + + /** + *

orderBy.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + * @return a T object. + */ + public T orderBy(final CrosstabMeasureBuilder> measure) { + return orderBy(Expressions.orderBy(measure)); + } + + /** + *

orderBy.

+ * + * @param orderByExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T orderBy(final DRIExpression> orderByExpression) { + getObject().setOrderByExpression(orderByExpression); + return (T) this; + } + + /** + *

setComparatorExpression.

+ * + * @param comparatorExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setComparatorExpression(final DRIExpression> comparatorExpression) { + getObject().setComparatorExpression(comparatorExpression); + return (T) this; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return getObject().getName(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabBuilder.java new file mode 100644 index 0000000..4ce53fd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabBuilder.java @@ -0,0 +1,471 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.crosstab; + +import software.xdev.dynamicreports.report.base.crosstab.DRCrosstab; +import software.xdev.dynamicreports.report.builder.DatasetBuilder; +import software.xdev.dynamicreports.report.builder.DynamicReports; +import software.xdev.dynamicreports.report.builder.component.ComponentBuilder; +import software.xdev.dynamicreports.report.builder.component.DimensionComponentBuilder; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.builder.style.SimpleStyleBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.RunDirection; +import net.sf.jasperreports.engine.JRDataSource; +import org.apache.commons.lang3.Validate; + +import java.sql.Connection; + +/** + *

CrosstabBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class CrosstabBuilder extends DimensionComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for CrosstabBuilder.

+ */ + protected CrosstabBuilder() { + super(new DRCrosstab()); + } + + /** + *

setRepeatColumnHeaders.

+ * + * @param repeatColumnHeaders a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setRepeatColumnHeaders(Boolean repeatColumnHeaders) { + getObject().setRepeatColumnHeaders(repeatColumnHeaders); + return this; + } + + /** + *

setRepeatRowHeaders.

+ * + * @param repeatRowHeaders a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setRepeatRowHeaders(Boolean repeatRowHeaders) { + getObject().setRepeatRowHeaders(repeatRowHeaders); + return this; + } + + /** + *

setColumnBreakOffset.

+ * + * @param columnBreakOffset a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setColumnBreakOffset(Integer columnBreakOffset) { + getObject().setColumnBreakOffset(columnBreakOffset); + return this; + } + + /** + *

setIgnoreWidth.

+ * + * @param ignoreWidth a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setIgnoreWidth(Boolean ignoreWidth) { + getObject().setIgnoreWidth(ignoreWidth); + return this; + } + + /** + *

setRunDirection.

+ * + * @param runDirection a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setRunDirection(RunDirection runDirection) { + getObject().setRunDirection(runDirection); + return this; + } + + /** + *

setCellWidth.

+ * + * @param cellWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setCellWidth(Integer cellWidth) { + getObject().setCellWidth(cellWidth); + return this; + } + + /** + *

setCellHeight.

+ * + * @param cellHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setCellHeight(Integer cellHeight) { + getObject().setCellHeight(cellHeight); + return this; + } + + /** + *

highlightOddRows.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder highlightOddRows() { + return setHighlightOddRows(true); + } + + /** + *

setHighlightOddRows.

+ * + * @param highlightOddRows a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setHighlightOddRows(Boolean highlightOddRows) { + getObject().setHighlightOddRows(highlightOddRows); + return this; + } + + /** + *

setOddRowStyle.

+ * + * @param oddRowStyle a {@link software.xdev.dynamicreports.report.builder.style.SimpleStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setOddRowStyle(SimpleStyleBuilder oddRowStyle) { + if (oddRowStyle != null) { + getObject().setOddRowStyle(oddRowStyle.build()); + } else { + getObject().setOddRowStyle(null); + } + return this; + } + + /** + *

setGroupStyle.

+ * + * @param groupStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setGroupStyle(ReportStyleBuilder groupStyle) { + if (groupStyle != null) { + getObject().setGroupStyle(groupStyle.build()); + } else { + getObject().setGroupStyle(null); + } + return this; + } + + /** + *

setGroupTotalStyle.

+ * + * @param groupTotalStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setGroupTotalStyle(ReportStyleBuilder groupTotalStyle) { + if (groupTotalStyle != null) { + getObject().setGroupTotalStyle(groupTotalStyle.build()); + } else { + getObject().setGroupTotalStyle(null); + } + return this; + } + + /** + *

setGrandTotalStyle.

+ * + * @param grandTotalStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setGrandTotalStyle(ReportStyleBuilder grandTotalStyle) { + if (grandTotalStyle != null) { + getObject().setGrandTotalStyle(grandTotalStyle.build()); + } else { + getObject().setGrandTotalStyle(null); + } + return this; + } + + /** + *

setCellStyle.

+ * + * @param cellStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setCellStyle(ReportStyleBuilder cellStyle) { + if (cellStyle != null) { + getObject().setCellStyle(cellStyle.build()); + } else { + getObject().setCellStyle(null); + } + return this; + } + + /** + *

setMeasureTitleStyle.

+ * + * @param measureTitleStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setMeasureTitleStyle(ReportStyleBuilder measureTitleStyle) { + if (measureTitleStyle != null) { + getObject().setMeasureTitleStyle(measureTitleStyle.build()); + } else { + getObject().setMeasureTitleStyle(null); + } + return this; + } + + /** + *

highlightEvenRows.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder highlightEvenRows() { + return setHighlightEvenRows(true); + } + + /** + *

setHighlightEvenRows.

+ * + * @param highlightEvenRows a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setHighlightEvenRows(Boolean highlightEvenRows) { + getObject().setHighlightEvenRows(highlightEvenRows); + return this; + } + + /** + *

setEvenRowStyle.

+ * + * @param evenRowStyle a {@link software.xdev.dynamicreports.report.builder.style.SimpleStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setEvenRowStyle(SimpleStyleBuilder evenRowStyle) { + if (evenRowStyle != null) { + getObject().setEvenRowStyle(evenRowStyle.build()); + } else { + getObject().setEvenRowStyle(null); + } + return this; + } + + /** + *

whenNoDataCell.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder whenNoDataCell(ComponentBuilder... components) { + return addWhenNoDataCell(components); + } + + /** + *

addWhenNoDataCell.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder addWhenNoDataCell(ComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for (ComponentBuilder component : components) { + getObject().getWhenNoDataCell().addComponent(component.build()); + } + return this; + } + + /** + *

headerCell.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder headerCell(ComponentBuilder... components) { + return addHeaderCell(components); + } + + /** + *

addHeaderCell.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder addHeaderCell(ComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for (ComponentBuilder component : components) { + getObject().getHeaderCell().addComponent(component.build()); + } + return this; + } + + /** + *

columnGroups.

+ * + * @param columnGroups a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder columnGroups(CrosstabColumnGroupBuilder... columnGroups) { + return addColumnGroup(columnGroups); + } + + /** + *

addColumnGroup.

+ * + * @param columnGroups a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder addColumnGroup(CrosstabColumnGroupBuilder... columnGroups) { + Validate.notNull(columnGroups, "columnGroups must not be null"); + Validate.noNullElements(columnGroups, "columnGroups must not contains null columnGroup"); + for (CrosstabColumnGroupBuilder columnGroup : columnGroups) { + getObject().addColumnGroup(columnGroup.build()); + } + return this; + } + + /** + *

rowGroups.

+ * + * @param rowGroups a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder rowGroups(CrosstabRowGroupBuilder... rowGroups) { + return addRowGroup(rowGroups); + } + + /** + *

addRowGroup.

+ * + * @param rowGroups a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder addRowGroup(CrosstabRowGroupBuilder... rowGroups) { + Validate.notNull(rowGroups, "rowGroups must not be null"); + Validate.noNullElements(rowGroups, "rowGroups must not contains null rowGroup"); + for (CrosstabRowGroupBuilder rowGroup : rowGroups) { + getObject().addRowGroup(rowGroup.build()); + } + return this; + } + + /** + *

variables.

+ * + * @param variables a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder variables(CrosstabVariableBuilder... variables) { + return addVariable(variables); + } + + /** + *

addVariable.

+ * + * @param variables a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder addVariable(CrosstabVariableBuilder... variables) { + Validate.notNull(variables, "variables must not be null"); + Validate.noNullElements(variables, "variables must not contains null measure"); + for (CrosstabVariableBuilder variable : variables) { + getObject().addVariable(variable.build()); + } + return this; + } + + /** + *

measures.

+ * + * @param measures a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder measures(CrosstabMeasureBuilder... measures) { + return addMeasure(measures); + } + + /** + *

addMeasure.

+ * + * @param measures a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder addMeasure(CrosstabMeasureBuilder... measures) { + Validate.notNull(measures, "measures must not be null"); + Validate.noNullElements(measures, "measures must not contains null measure"); + for (CrosstabMeasureBuilder measure : measures) { + getObject().addMeasure(measure.build()); + } + return this; + } + + // subdataset + + /** + *

setSubDataset.

+ * + * @param subDataset a {@link software.xdev.dynamicreports.report.builder.DatasetBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setSubDataset(DatasetBuilder subDataset) { + Validate.notNull(subDataset, "subDataset must not be null"); + getObject().getDataset().setSubDataset(subDataset.build()); + return this; + } + + /** + *

setDataSource.

+ * + * @param dataSource a {@link net.sf.jasperreports.engine.JRDataSource} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setDataSource(JRDataSource dataSource) { + DatasetBuilder dataset = DynamicReports.dataset(); + dataset.setDataSource(dataSource); + return setSubDataset(dataset); + } + + /** + *

setDataSource.

+ * + * @param sql a {@link java.lang.String} object. + * @param connection a {@link java.sql.Connection} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setDataSource(String sql, Connection connection) { + DatasetBuilder dataset = DynamicReports.dataset(); + dataset.setDataSource(sql, connection); + return setSubDataset(dataset); + } + + /** + *

setDataPreSorted.

+ * + * @param dataPreSorted a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder setDataPreSorted(Boolean dataPreSorted) { + getObject().getDataset().setDataPreSorted(dataPreSorted); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabBuilders.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabBuilders.java new file mode 100644 index 0000000..c7bce2a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabBuilders.java @@ -0,0 +1,313 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.crosstab; + +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + * A set of methods of creating and customizing crosstabs + * + * @author Ricardo Mariaca + * + */ +public class CrosstabBuilders { + + /** + *

crosstab.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public CrosstabBuilder crosstab() { + return Crosstabs.crosstab(); + } + + // column group + + /** + *

columnGroup.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + */ + public CrosstabColumnGroupBuilder columnGroup(ValueColumnBuilder column) { + return Crosstabs.columnGroup(column); + } + + /** + *

columnGroup.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + */ + public CrosstabColumnGroupBuilder columnGroup(FieldBuilder field) { + return Crosstabs.columnGroup(field); + } + + /** + *

columnGroup.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + */ + public CrosstabColumnGroupBuilder columnGroup(String fieldName, Class valueClass) { + return Crosstabs.columnGroup(fieldName, valueClass); + } + + /** + *

columnGroup.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + */ + public CrosstabColumnGroupBuilder columnGroup(DRIExpression expression) { + return Crosstabs.columnGroup(expression); + } + + // row group + + /** + *

rowGroup.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + */ + public CrosstabRowGroupBuilder rowGroup(ValueColumnBuilder column) { + return Crosstabs.rowGroup(column); + } + + /** + *

rowGroup.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + */ + public CrosstabRowGroupBuilder rowGroup(FieldBuilder field) { + return Crosstabs.rowGroup(field); + } + + /** + *

rowGroup.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + */ + public CrosstabRowGroupBuilder rowGroup(String fieldName, Class valueClass) { + return Crosstabs.rowGroup(fieldName, valueClass); + } + + /** + *

rowGroup.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + */ + public CrosstabRowGroupBuilder rowGroup(DRIExpression expression) { + return Crosstabs.rowGroup(expression); + } + + // variable + + /** + *

variable.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder} object. + */ + public CrosstabVariableBuilder variable(ValueColumnBuilder column, Calculation calculation) { + return Crosstabs.variable(column, calculation); + } + + /** + *

variable.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder} object. + */ + public CrosstabVariableBuilder variable(FieldBuilder field, Calculation calculation) { + return Crosstabs.variable(field, calculation); + } + + /** + *

variable.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder} object. + */ + public CrosstabVariableBuilder variable(String fieldName, Class valueClass, Calculation calculation) { + return Crosstabs.variable(fieldName, valueClass, calculation); + } + + /** + *

variable.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder} object. + */ + public CrosstabVariableBuilder variable(DRIExpression expression, Calculation calculation) { + return Crosstabs.variable(expression, calculation); + } + + // measure + + /** + *

measure.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder measure(ValueColumnBuilder column, Calculation calculation) { + return Crosstabs.measure(column, calculation); + } + + /** + *

measure.

+ * + * @param title a {@link java.lang.String} object. + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder measure(String title, ValueColumnBuilder column, Calculation calculation) { + return Crosstabs.measure(title, column, calculation); + } + + /** + *

measure.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder measure(FieldBuilder field, Calculation calculation) { + return Crosstabs.measure(field, calculation); + } + + /** + *

measure.

+ * + * @param title a {@link java.lang.String} object. + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder measure(String title, FieldBuilder field, Calculation calculation) { + return Crosstabs.measure(title, field, calculation); + } + + /** + *

measure.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder measure(String fieldName, Class valueClass, Calculation calculation) { + return Crosstabs.measure(fieldName, valueClass, calculation); + } + + /** + *

measure.

+ * + * @param title a {@link java.lang.String} object. + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder measure(String title, String fieldName, Class valueClass, Calculation calculation) { + return Crosstabs.measure(title, fieldName, valueClass, calculation); + } + + /** + *

measure.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder measure(DRIExpression expression, Calculation calculation) { + return Crosstabs.measure(expression, calculation); + } + + /** + *

measure.

+ * + * @param title a {@link java.lang.String} object. + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder measure(String title, DRIExpression expression, Calculation calculation) { + return Crosstabs.measure(title, expression, calculation); + } + + /** + *

measure.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder measure(DRIExpression expression) { + return Crosstabs.measure(expression); + } + + /** + *

measure.

+ * + * @param title a {@link java.lang.String} object. + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder measure(String title, DRIExpression expression) { + return Crosstabs.measure(title, expression); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabColumnGroupBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabColumnGroupBuilder.java new file mode 100644 index 0000000..e3217bb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabColumnGroupBuilder.java @@ -0,0 +1,83 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.crosstab; + +import software.xdev.dynamicreports.report.base.crosstab.DRCrosstabColumnGroup; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

CrosstabColumnGroupBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class CrosstabColumnGroupBuilder extends AbstractCrosstabGroupBuilder, DRCrosstabColumnGroup, T> { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for CrosstabColumnGroupBuilder.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + */ + protected CrosstabColumnGroupBuilder(ValueColumnBuilder column) { + super(column, new DRCrosstabColumnGroup()); + } + + /** + *

Constructor for CrosstabColumnGroupBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + protected CrosstabColumnGroupBuilder(FieldBuilder field) { + super(field, new DRCrosstabColumnGroup()); + } + + /** + *

Constructor for CrosstabColumnGroupBuilder.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected CrosstabColumnGroupBuilder(DRIExpression expression) { + super(expression, new DRCrosstabColumnGroup()); + } + + /** + *

setHeaderHeight.

+ * + * @param headerHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + */ + public CrosstabColumnGroupBuilder setHeaderHeight(Integer headerHeight) { + getObject().setHeaderHeight(headerHeight); + return this; + } + + /** + *

setTotalHeaderWidth.

+ * + * @param totalHeaderWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + */ + public CrosstabColumnGroupBuilder setTotalHeaderWidth(Integer totalHeaderWidth) { + getObject().setTotalHeaderWidth(totalHeaderWidth); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabMeasureBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabMeasureBuilder.java new file mode 100644 index 0000000..2fe51a7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabMeasureBuilder.java @@ -0,0 +1,373 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.crosstab; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.base.crosstab.DRCrosstabCellStyle; +import software.xdev.dynamicreports.report.base.crosstab.DRCrosstabMeasure; +import software.xdev.dynamicreports.report.base.crosstab.DRCrosstabVariable; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.HyperLinkBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.builder.datatype.DataTypes; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; +import software.xdev.dynamicreports.report.constant.HorizontalAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.DRICrosstabValue; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.component.DRITextField; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import software.xdev.dynamicreports.report.exception.DRReportException; + +/** + *

CrosstabMeasureBuilder class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +@SuppressWarnings("deprecation") +public class CrosstabMeasureBuilder extends AbstractBuilder, DRCrosstabMeasure> implements DRICrosstabValue { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for CrosstabMeasureBuilder.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected CrosstabMeasureBuilder(final ValueColumnBuilder column, final Calculation calculation) { + super(new DRCrosstabMeasure(Crosstabs.variable(column, calculation).build())); + if (calculation.equals(Calculation.COUNT) || calculation.equals(Calculation.DISTINCT_COUNT)) { + setDataType(DataTypes.longType()); + } else if (calculation.equals(Calculation.AVERAGE) || calculation.equals(Calculation.STANDARD_DEVIATION) || calculation.equals(Calculation.VARIANCE)) { + setDataType(DataTypes.doubleType()); + } else { + final DRITextField columnComponent = column.getColumn().getComponent(); + setDataType(columnComponent.getDataType()); + setPattern(columnComponent.getPattern()); + } + } + + /** + *

Constructor for CrosstabMeasureBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected CrosstabMeasureBuilder(final FieldBuilder field, final Calculation calculation) { + super(new DRCrosstabMeasure(Crosstabs.variable(field, calculation).build())); + if (calculation.equals(Calculation.COUNT) || calculation.equals(Calculation.DISTINCT_COUNT)) { + setDataType(DataTypes.longType()); + } else if (calculation.equals(Calculation.AVERAGE) || calculation.equals(Calculation.STANDARD_DEVIATION) || calculation.equals(Calculation.VARIANCE)) { + setDataType(DataTypes.doubleType()); + } else { + setDataType(field.getField().getDataType()); + } + } + + /** + *

Constructor for CrosstabMeasureBuilder.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected CrosstabMeasureBuilder(final DRIExpression expression, final Calculation calculation) { + super(new DRCrosstabMeasure(Crosstabs.variable(expression, calculation).build())); + if (calculation.equals(Calculation.COUNT) || calculation.equals(Calculation.DISTINCT_COUNT)) { + setDataType(DataTypes.longType()); + } else if (calculation.equals(Calculation.AVERAGE) || calculation.equals(Calculation.STANDARD_DEVIATION) || calculation.equals(Calculation.VARIANCE)) { + setDataType(DataTypes.doubleType()); + } else if (expression instanceof DRIField) { + setDataType(((DRIField) expression).getDataType()); + } + } + + /** + *

Constructor for CrosstabMeasureBuilder.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected CrosstabMeasureBuilder(final DRIExpression expression) { + super(new DRCrosstabMeasure(expression)); + } + + /** + *

setDataType.

+ * + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + @SuppressWarnings( {"unchecked", "rawtypes"}) + public CrosstabMeasureBuilder setDataType(final DRIDataType dataType) { + getObject().setDataType(dataType); + return this; + } + + /** + *

setPercentageType.

+ * + * @param percentageType a {@link software.xdev.dynamicreports.report.constant.CrosstabPercentageType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder setPercentageType(final CrosstabPercentageType percentageType) { + if (getObject().getExpression() instanceof DRCrosstabVariable) { + final DRCrosstabVariable variable = (DRCrosstabVariable) getObject().getExpression(); + if (percentageType != null && percentageType.equals(CrosstabPercentageType.GRAND_TOTAL) && !variable.getCalculation().equals(Calculation.COUNT) && + !variable.getCalculation().equals(Calculation.DISTINCT_COUNT)) { + setDataType(DataTypes.doubleType()); + } + variable.setPercentageType(percentageType); + } else { + throw new DRReportException("Percentage is not supported in this type of measure"); + } + return this; + } + + /** + *

setPattern.

+ * + * @param pattern a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder setPattern(final String pattern) { + getObject().setPattern(pattern); + return this; + } + + /** + *

setHorizontalAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalAlignment} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + * @deprecated use setHorizontalTextAlignment instead + */ + @Deprecated + public CrosstabMeasureBuilder setHorizontalAlignment(final HorizontalAlignment horizontalAlignment) { + if (horizontalAlignment != null) { + getObject().setHorizontalTextAlignment(HorizontalTextAlignment.valueOf(horizontalAlignment.name())); + } else { + getObject().setHorizontalTextAlignment(null); + } + return this; + } + + /** + *

setHorizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder setHorizontalTextAlignment(final HorizontalTextAlignment horizontalTextAlignment) { + getObject().setHorizontalTextAlignment(horizontalTextAlignment); + return this; + } + + /** + *

setValueFormatter.

+ * + * @param valueFormatter a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder setValueFormatter(final DRIValueFormatter valueFormatter) { + getObject().setValueFormatter(valueFormatter); + return this; + } + + /** + *

setStretchWithOverflow.

+ * + * @param stretchWithOverflow a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + * @deprecated replaced by {@link #setTextAdjust(TextAdjust)} + */ + @Deprecated + public CrosstabMeasureBuilder setStretchWithOverflow(final Boolean stretchWithOverflow) { + getObject().setStretchWithOverflow(stretchWithOverflow); + return this; + } + + /** + *

setTotalHeaderTextAdjust.

+ * + * @param textAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + * @return a T object. + */ + public CrosstabMeasureBuilder setTextAdjust(final TextAdjust textAdjust) { + getObject().setTextAdjust(textAdjust); + return this; + } + + /** + * Sets the crosstab measure hyperlink. + * + * @param hyperLink the measure hyperlink + * @return a crosstab measure builder + */ + public CrosstabMeasureBuilder setHyperLink(final HyperLinkBuilder hyperLink) { + if (hyperLink != null) { + getObject().setHyperLink(hyperLink.getHyperLink()); + } else { + getObject().setHyperLink(null); + } + return this; + } + + /** + * Adds a jasper property to the measure. + * + * @param propertyExpression the property expression + * @return a crosstab measure builder + */ + public CrosstabMeasureBuilder addProperty(final DRIPropertyExpression propertyExpression) { + getObject().addPropertyExpression(propertyExpression); + return this; + } + + /** + * Adds a jasper property to the measure. + * + * @param name the property name + * @param valueExpression the property value expression + * @return a crosstab measure builder + */ + public CrosstabMeasureBuilder addProperty(final String name, final DRIExpression valueExpression) { + getObject().addPropertyExpression(Expressions.property(name, valueExpression)); + return this; + } + + /** + * Adds a jasper property to the measure. + * + * @param name the property name + * @param value the property value + * @return a crosstab measure builder + */ + public CrosstabMeasureBuilder addProperty(final String name, final String value) { + getObject().addPropertyExpression(Expressions.property(name, value)); + return this; + } + + /** + *

setStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder setStyle(final ReportStyleBuilder style) { + Validate.notNull(style, "style must not be null"); + getObject().getStyles().add(new DRCrosstabCellStyle(style.getStyle())); + return this; + } + + /** + *

setStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @param rowGroup a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder setStyle(final ReportStyleBuilder style, final CrosstabRowGroupBuilder rowGroup) { + Validate.notNull(style, "style must not be null"); + Validate.notNull(rowGroup, "rowGroup must not be null"); + getObject().getStyles().add(new DRCrosstabCellStyle(style.getStyle(), rowGroup.build(), null)); + return this; + } + + /** + *

setStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @param columnGroup a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder setStyle(final ReportStyleBuilder style, final CrosstabColumnGroupBuilder columnGroup) { + Validate.notNull(style, "style must not be null"); + Validate.notNull(columnGroup, "columnGroup must not be null"); + getObject().getStyles().add(new DRCrosstabCellStyle(style.getStyle(), null, columnGroup.build())); + return this; + } + + /** + *

setStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @param rowGroup a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + * @param columnGroup a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder setStyle(final ReportStyleBuilder style, final CrosstabRowGroupBuilder rowGroup, final CrosstabColumnGroupBuilder columnGroup) { + Validate.notNull(style, "style must not be null"); + Validate.notNull(rowGroup, "rowGroup must not be null"); + Validate.notNull(columnGroup, "columnGroup must not be null"); + getObject().getStyles().add(new DRCrosstabCellStyle(style.getStyle(), rowGroup.build(), columnGroup.build())); + return this; + } + + /** + *

setTitle.

+ * + * @param titleExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder setTitle(final DRIExpression titleExpression) { + getObject().setTitleExpression(titleExpression); + return this; + } + + /** + *

setTitle.

+ * + * @param title a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder setTitle(final String title) { + getObject().setTitleExpression(Expressions.text(title)); + return this; + } + + /** + *

setTitleStyle.

+ * + * @param titleStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public CrosstabMeasureBuilder setTitleStyle(final ReportStyleBuilder titleStyle) { + if (titleStyle != null) { + getObject().setTitleStyle(titleStyle.getStyle()); + } else { + getObject().setTitleStyle(null); + } + return this; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return build().getExpression().getName(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabRowGroupBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabRowGroupBuilder.java new file mode 100644 index 0000000..2f3e130 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabRowGroupBuilder.java @@ -0,0 +1,83 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.crosstab; + +import software.xdev.dynamicreports.report.base.crosstab.DRCrosstabRowGroup; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

CrosstabRowGroupBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class CrosstabRowGroupBuilder extends AbstractCrosstabGroupBuilder, DRCrosstabRowGroup, T> { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for CrosstabRowGroupBuilder.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + */ + protected CrosstabRowGroupBuilder(ValueColumnBuilder column) { + super(column, new DRCrosstabRowGroup()); + } + + /** + *

Constructor for CrosstabRowGroupBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + protected CrosstabRowGroupBuilder(FieldBuilder field) { + super(field, new DRCrosstabRowGroup()); + } + + /** + *

Constructor for CrosstabRowGroupBuilder.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected CrosstabRowGroupBuilder(DRIExpression expression) { + super(expression, new DRCrosstabRowGroup()); + } + + /** + *

setHeaderWidth.

+ * + * @param headerWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + */ + public CrosstabRowGroupBuilder setHeaderWidth(Integer headerWidth) { + getObject().setHeaderWidth(headerWidth); + return this; + } + + /** + *

setTotalHeaderHeight.

+ * + * @param totalHeaderHeight a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + */ + public CrosstabRowGroupBuilder setTotalHeaderHeight(Integer totalHeaderHeight) { + getObject().setTotalHeaderHeight(totalHeaderHeight); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabVariableBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabVariableBuilder.java new file mode 100644 index 0000000..3a14da9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/CrosstabVariableBuilder.java @@ -0,0 +1,85 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.crosstab; + +import software.xdev.dynamicreports.report.base.crosstab.DRCrosstabVariable; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; +import software.xdev.dynamicreports.report.definition.DRICrosstabValue; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

CrosstabVariableBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class CrosstabVariableBuilder extends AbstractBuilder, DRCrosstabVariable> implements DRICrosstabValue { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for CrosstabVariableBuilder.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected CrosstabVariableBuilder(ValueColumnBuilder column, Calculation calculation) { + super(new DRCrosstabVariable(column.build(), calculation)); + } + + /** + *

Constructor for CrosstabVariableBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected CrosstabVariableBuilder(FieldBuilder field, Calculation calculation) { + super(new DRCrosstabVariable(field.getField(), calculation)); + } + + /** + *

Constructor for CrosstabVariableBuilder.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected CrosstabVariableBuilder(DRIExpression expression, Calculation calculation) { + super(new DRCrosstabVariable(expression, calculation)); + } + + /** + *

setPercentageType.

+ * + * @param percentageType a {@link software.xdev.dynamicreports.report.constant.CrosstabPercentageType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder} object. + */ + public CrosstabVariableBuilder setPercentageType(CrosstabPercentageType percentageType) { + getObject().setPercentageType(percentageType); + return this; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return getObject().getName(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/Crosstabs.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/Crosstabs.java new file mode 100644 index 0000000..0cb1918 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/crosstab/Crosstabs.java @@ -0,0 +1,323 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.crosstab; + +import software.xdev.dynamicreports.report.builder.DynamicReports; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + * A set of methods of creating and customizing crosstabs + * + * @author Ricardo Mariaca + * + */ +public class Crosstabs { + + /** + *

crosstab.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder} object. + */ + public static CrosstabBuilder crosstab() { + return new CrosstabBuilder(); + } + + // column group + + /** + *

columnGroup.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + */ + public static CrosstabColumnGroupBuilder columnGroup(ValueColumnBuilder column) { + return new CrosstabColumnGroupBuilder(column); + } + + /** + *

columnGroup.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + */ + public static CrosstabColumnGroupBuilder columnGroup(FieldBuilder field) { + return new CrosstabColumnGroupBuilder(field); + } + + /** + *

columnGroup.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + */ + public static CrosstabColumnGroupBuilder columnGroup(String fieldName, Class valueClass) { + return new CrosstabColumnGroupBuilder(DynamicReports.field(fieldName, valueClass)); + } + + /** + *

columnGroup.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + */ + public static CrosstabColumnGroupBuilder columnGroup(DRIExpression expression) { + return new CrosstabColumnGroupBuilder(expression); + } + + // row group + + /** + *

rowGroup.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + */ + public static CrosstabRowGroupBuilder rowGroup(ValueColumnBuilder column) { + return new CrosstabRowGroupBuilder(column); + } + + /** + *

rowGroup.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + */ + public static CrosstabRowGroupBuilder rowGroup(FieldBuilder field) { + return new CrosstabRowGroupBuilder(field); + } + + /** + *

rowGroup.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + */ + public static CrosstabRowGroupBuilder rowGroup(String fieldName, Class valueClass) { + return new CrosstabRowGroupBuilder(DynamicReports.field(fieldName, valueClass)); + } + + /** + *

rowGroup.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + */ + public static CrosstabRowGroupBuilder rowGroup(DRIExpression expression) { + return new CrosstabRowGroupBuilder(expression); + } + + // variable + + /** + *

variable.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder} object. + */ + public static CrosstabVariableBuilder variable(ValueColumnBuilder column, Calculation calculation) { + Validate.notNull(column, "column must not be null"); + return new CrosstabVariableBuilder(column, calculation); + } + + /** + *

variable.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder} object. + */ + public static CrosstabVariableBuilder variable(FieldBuilder field, Calculation calculation) { + Validate.notNull(field, "field must not be null"); + return new CrosstabVariableBuilder(field, calculation); + } + + /** + *

variable.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder} object. + */ + public static CrosstabVariableBuilder variable(String fieldName, Class valueClass, Calculation calculation) { + return new CrosstabVariableBuilder(DynamicReports.field(fieldName, valueClass), calculation); + } + + /** + *

variable.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder} object. + */ + public static CrosstabVariableBuilder variable(DRIExpression expression, Calculation calculation) { + return new CrosstabVariableBuilder(expression, calculation); + } + + // measure + + /** + *

measure.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public static CrosstabMeasureBuilder measure(ValueColumnBuilder column, Calculation calculation) { + Validate.notNull(column, "column must not be null"); + return new CrosstabMeasureBuilder(column, calculation); + } + + /** + *

measure.

+ * + * @param title a {@link java.lang.String} object. + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public static CrosstabMeasureBuilder measure(String title, ValueColumnBuilder column, Calculation calculation) { + CrosstabMeasureBuilder measure = measure(column, calculation); + return measure.setTitle(title); + } + + /** + *

measure.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public static CrosstabMeasureBuilder measure(FieldBuilder field, Calculation calculation) { + Validate.notNull(field, "field must not be null"); + return new CrosstabMeasureBuilder(field, calculation); + } + + /** + *

measure.

+ * + * @param title a {@link java.lang.String} object. + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public static CrosstabMeasureBuilder measure(String title, FieldBuilder field, Calculation calculation) { + return measure(field, calculation).setTitle(title); + } + + /** + *

measure.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public static CrosstabMeasureBuilder measure(String fieldName, Class valueClass, Calculation calculation) { + return new CrosstabMeasureBuilder(DynamicReports.field(fieldName, valueClass), calculation); + } + + /** + *

measure.

+ * + * @param title a {@link java.lang.String} object. + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public static CrosstabMeasureBuilder measure(String title, String fieldName, Class valueClass, Calculation calculation) { + CrosstabMeasureBuilder measure = measure(fieldName, valueClass, calculation); + return measure.setTitle(title); + } + + /** + *

measure.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public static CrosstabMeasureBuilder measure(DRIExpression expression, Calculation calculation) { + return new CrosstabMeasureBuilder(expression, calculation); + } + + /** + *

measure.

+ * + * @param title a {@link java.lang.String} object. + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public static CrosstabMeasureBuilder measure(String title, DRIExpression expression, Calculation calculation) { + CrosstabMeasureBuilder measure = measure(expression, calculation); + return measure.setTitle(title); + } + + /** + *

measure.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public static CrosstabMeasureBuilder measure(DRIExpression expression) { + return new CrosstabMeasureBuilder(expression); + } + + /** + *

measure.

+ * + * @param title a {@link java.lang.String} object. + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public static CrosstabMeasureBuilder measure(String title, DRIExpression expression) { + CrosstabMeasureBuilder measure = measure(expression); + return measure.setTitle(title); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/BigDecimalType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/BigDecimalType.java new file mode 100644 index 0000000..5a174e3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/BigDecimalType.java @@ -0,0 +1,52 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import java.math.BigDecimal; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

BigDecimalType class.

+ * + * @author Ricardo Mariaca + * + */ +public class BigDecimalType extends NumberType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getBigDecimalType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getBigDecimalType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + protected BigDecimal numberToValue(final Number number) { + return BigDecimal.valueOf(number.doubleValue()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/BigIntegerType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/BigIntegerType.java new file mode 100644 index 0000000..7effa6c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/BigIntegerType.java @@ -0,0 +1,52 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +import java.math.BigInteger; + +/** + *

BigIntegerType class.

+ * + * @author Ricardo Mariaca + * + */ +public class BigIntegerType extends NumberType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getBigIntegerType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getBigIntegerType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + protected BigInteger numberToValue(Number number) { + return BigInteger.valueOf(number.longValue()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/BooleanType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/BooleanType.java new file mode 100644 index 0000000..ecf7476 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/BooleanType.java @@ -0,0 +1,54 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import java.util.Locale; + +import software.xdev.dynamicreports.report.base.datatype.AbstractDataType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + *

BooleanType class.

+ * + * @author Ricardo Mariaca + * + */ +public class BooleanType extends AbstractDataType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getBooleanType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getBooleanType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + public Boolean stringToValue(final String value, final Locale locale) throws DRException { + return Boolean.parseBoolean(value); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/ByteType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/ByteType.java new file mode 100644 index 0000000..ea613ac --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/ByteType.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

ByteType class.

+ * + * @author Ricardo Mariaca + * + */ +public class ByteType extends NumberType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getByteType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getByteType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + protected Byte numberToValue(Number number) { + return number.byteValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/CharacterType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/CharacterType.java new file mode 100644 index 0000000..5c4114e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/CharacterType.java @@ -0,0 +1,58 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.base.datatype.AbstractDataType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; +import software.xdev.dynamicreports.report.exception.DRException; +import org.apache.commons.lang3.StringUtils; + +import java.util.Locale; + +/** + *

CharacterType class.

+ * + * @author Ricardo Mariaca + * + */ +public class CharacterType extends AbstractDataType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getCharacterType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getCharacterType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + public Character stringToValue(String value, Locale locale) throws DRException { + if (StringUtils.isNotEmpty(value)) { + return value.charAt(0); + } + return null; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DataTypeBuilders.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DataTypeBuilders.java new file mode 100644 index 0000000..9b8e334 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DataTypeBuilders.java @@ -0,0 +1,278 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.exception.DRException; + +/** + * A set of build in data types + * + * @author Ricardo Mariaca + * + */ +public class DataTypeBuilders { + + /** + *

detectType.

+ * + * @param dataType a {@link java.lang.Class} object. + * @param a U object. + * @return a T object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public > T detectType(Class dataType) throws DRException { + return DataTypes.detectType(dataType); + } + + /** + *

detectType.

+ * + * @param dataType a {@link java.lang.String} object. + * @return a T object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public > T detectType(String dataType) throws DRException { + return DataTypes.detectType(dataType); + } + + /** + *

bigDecimalType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.BigDecimalType} object. + */ + public BigDecimalType bigDecimalType() { + return DataTypes.bigDecimalType(); + } + + /** + *

bigIntegerType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.BigIntegerType} object. + */ + public BigIntegerType bigIntegerType() { + return DataTypes.bigIntegerType(); + } + + /** + *

booleanType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.BooleanType} object. + */ + public BooleanType booleanType() { + return DataTypes.booleanType(); + } + + /** + *

byteType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.ByteType} object. + */ + public ByteType byteType() { + return DataTypes.byteType(); + } + + /** + *

dateType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateType} object. + */ + public DateType dateType() { + return DataTypes.dateType(); + } + + /** + *

dateYearToFractionType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearToFractionType} object. + */ + public DateYearToFractionType dateYearToFractionType() { + return DataTypes.dateYearToFractionType(); + } + + /** + *

dateYearToHourType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearToHourType} object. + */ + public DateYearToHourType dateYearToHourType() { + return DataTypes.dateYearToHourType(); + } + + /** + *

dateYearToMinuteType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearToMinuteType} object. + */ + public DateYearToMinuteType dateYearToMinuteType() { + return DataTypes.dateYearToMinuteType(); + } + + /** + *

dateYearToMonthType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearToMonthType} object. + */ + public DateYearToMonthType dateYearToMonthType() { + return DataTypes.dateYearToMonthType(); + } + + /** + *

dateYearToSecondType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearToSecondType} object. + */ + public DateYearToSecondType dateYearToSecondType() { + return DataTypes.dateYearToSecondType(); + } + + /** + *

dateYearType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearType} object. + */ + public DateYearType dateYearType() { + return DataTypes.dateYearType(); + } + + /** + *

dateMonthType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateMonthType} object. + */ + public DateMonthType dateMonthType() { + return DataTypes.dateMonthType(); + } + + /** + *

dateDayType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateDayType} object. + */ + public DateDayType dateDayType() { + return DataTypes.dateDayType(); + } + + /** + *

doubleType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DoubleType} object. + */ + public DoubleType doubleType() { + return DataTypes.doubleType(); + } + + /** + *

floatType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.FloatType} object. + */ + public FloatType floatType() { + return DataTypes.floatType(); + } + + /** + *

characterType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.CharacterType} object. + */ + public CharacterType characterType() { + return DataTypes.characterType(); + } + + /** + *

integerType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.IntegerType} object. + */ + public IntegerType integerType() { + return DataTypes.integerType(); + } + + /** + *

longType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.LongType} object. + */ + public LongType longType() { + return DataTypes.longType(); + } + + /** + *

shortType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.ShortType} object. + */ + public ShortType shortType() { + return DataTypes.shortType(); + } + + /** + *

stringType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.StringType} object. + */ + public StringType stringType() { + return DataTypes.stringType(); + } + + /** + *

listType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.ListType} object. + */ + public ListType listType() { + return DataTypes.listType(); + } + + /** + *

timeHourToFractionType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.TimeHourToFractionType} object. + */ + public TimeHourToFractionType timeHourToFractionType() { + return DataTypes.timeHourToFractionType(); + } + + /** + *

timeHourToMinuteType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.TimeHourToMinuteType} object. + */ + public TimeHourToMinuteType timeHourToMinuteType() { + return DataTypes.timeHourToMinuteType(); + } + + /** + *

timeHourToSecondType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.TimeHourToSecondType} object. + */ + public TimeHourToSecondType timeHourToSecondType() { + return DataTypes.timeHourToSecondType(); + } + + /** + *

percentageType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.PercentageType} object. + */ + public PercentageType percentageType() { + return DataTypes.percentageType(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DataTypes.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DataTypes.java new file mode 100644 index 0000000..6fc1ea0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DataTypes.java @@ -0,0 +1,389 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.exception.DRException; +import org.apache.commons.lang3.Validate; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Date; +import java.util.List; + +/** + * A set of build in data types + * + * @author Ricardo Mariaca + * + */ +public class DataTypes { + private static final BigDecimalType bigDecimalType = new BigDecimalType(); + private static final BigIntegerType bigIntegerType = new BigIntegerType(); + private static final ByteType byteType = new ByteType(); + private static final DoubleType doubleType = new DoubleType(); + private static final FloatType floatType = new FloatType(); + private static final IntegerType integerType = new IntegerType(); + private static final LongType longType = new LongType(); + private static final ShortType shortType = new ShortType(); + private static final DateType dateType = new DateType(); + private static final DateYearToMonthType dateYearToMonthType = new DateYearToMonthType(); + private static final DateYearToHourType dateYearToHourType = new DateYearToHourType(); + private static final DateYearToMinuteType dateYearToMinuteType = new DateYearToMinuteType(); + private static final DateYearToSecondType dateYearToSecondType = new DateYearToSecondType(); + private static final DateYearToFractionType dateYearToFractionType = new DateYearToFractionType(); + private static final DateYearType dateYearType = new DateYearType(); + private static final DateMonthType dateMonthType = new DateMonthType(); + private static final DateDayType dateDayType = new DateDayType(); + private static final TimeHourToMinuteType timeHourToMinuteType = new TimeHourToMinuteType(); + private static final TimeHourToSecondType timeHourToSecondType = new TimeHourToSecondType(); + private static final TimeHourToFractionType timeHourToFractionType = new TimeHourToFractionType(); + private static final PercentageType percentageType = new PercentageType(); + private static final BooleanType booleanType = new BooleanType(); + private static final CharacterType characterType = new CharacterType(); + private static final StringType stringType = new StringType(); + private static final ListType listType = new ListType(); + + /** + *

detectType.

+ * + * @param dataType a {@link java.lang.Class} object. + * @param a U object. + * @return a T object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public static > T detectType(Class dataType) throws DRException { + return detectType(dataType.getName()); + } + + /** + *

detectType.

+ * + * @param dataType a {@link java.lang.String} object. + * @return a T object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + @SuppressWarnings("unchecked") + public static > T detectType(String dataType) throws DRException { + Validate.notNull(dataType, "dataType must not be null"); + + String dataTypeLC = dataType.toLowerCase().trim(); + if (dataTypeLC.equals("bigdecimal") || dataType.equals(BigDecimal.class.getName())) { + return (T) bigDecimalType; + } + if (dataTypeLC.equals("biginteger") || dataType.equals(BigInteger.class.getName())) { + return (T) bigIntegerType; + } + if (dataTypeLC.equals("byte") || dataType.equals(Byte.class.getName())) { + return (T) byteType; + } + if (dataTypeLC.equals("double") || dataType.equals(Double.class.getName())) { + return (T) doubleType; + } + if (dataTypeLC.equals("float") || dataType.equals(Float.class.getName())) { + return (T) floatType; + } + if (dataTypeLC.equals("integer") || dataType.equals(Integer.class.getName())) { + return (T) integerType; + } + if (dataTypeLC.equals("long") || dataType.equals(Long.class.getName())) { + return (T) longType; + } + if (dataTypeLC.equals("short") || dataType.equals(Short.class.getName())) { + return (T) shortType; + } + if (dataTypeLC.equals("date") || dataType.equals(Date.class.getName())) { + return (T) dateType; + } + if (dataTypeLC.equals("dateyeartomonth")) { + return (T) dateYearToMonthType; + } + if (dataTypeLC.equals("dateyeartohour")) { + return (T) dateYearToHourType; + } + if (dataTypeLC.equals("dateyeartominute")) { + return (T) dateYearToMinuteType; + } + if (dataTypeLC.equals("dateyeartosecond")) { + return (T) dateYearToSecondType; + } + if (dataTypeLC.equals("dateyeartofraction")) { + return (T) dateYearToFractionType; + } + if (dataTypeLC.equals("dateyear")) { + return (T) dateYearType; + } + if (dataTypeLC.equals("datemonth")) { + return (T) dateMonthType; + } + if (dataTypeLC.equals("dateday")) { + return (T) dateDayType; + } + if (dataTypeLC.equals("timehourtominute")) { + return (T) timeHourToMinuteType; + } + if (dataTypeLC.equals("timehourtosecond")) { + return (T) timeHourToSecondType; + } + if (dataTypeLC.equals("timehourtofraction")) { + return (T) timeHourToFractionType; + } + if (dataTypeLC.equals("percentage")) { + return (T) percentageType; + } + if (dataTypeLC.equals("boolean") || dataType.equals(Boolean.class.getName())) { + return (T) booleanType; + } + if (dataTypeLC.equals("character") || dataType.equals(Character.class.getName())) { + return (T) characterType; + } + if (dataTypeLC.equals("string") || dataTypeLC.equals("text") || dataType.equals(String.class.getName())) { + return (T) stringType; + } + if (dataTypeLC.equals("list") || dataType.equals(List.class.getName())) { + return (T) listType; + } + + throw new DRException("Data type \"" + dataType + "\" is not supported"); + } + + /** + *

bigDecimalType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.BigDecimalType} object. + */ + public static BigDecimalType bigDecimalType() { + return bigDecimalType; + } + + /** + *

bigIntegerType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.BigIntegerType} object. + */ + public static BigIntegerType bigIntegerType() { + return bigIntegerType; + } + + /** + *

booleanType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.BooleanType} object. + */ + public static BooleanType booleanType() { + return booleanType; + } + + /** + *

byteType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.ByteType} object. + */ + public static ByteType byteType() { + return byteType; + } + + /** + *

dateType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateType} object. + */ + public static DateType dateType() { + return dateType; + } + + /** + *

dateYearToFractionType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearToFractionType} object. + */ + public static DateYearToFractionType dateYearToFractionType() { + return dateYearToFractionType; + } + + /** + *

dateYearType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearType} object. + */ + public static DateYearType dateYearType() { + return dateYearType; + } + + /** + *

dateMonthType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateMonthType} object. + */ + public static DateMonthType dateMonthType() { + return dateMonthType; + } + + /** + *

dateDayType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateDayType} object. + */ + public static DateDayType dateDayType() { + return dateDayType; + } + + /** + *

dateYearToHourType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearToHourType} object. + */ + public static DateYearToHourType dateYearToHourType() { + return dateYearToHourType; + } + + /** + *

dateYearToMinuteType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearToMinuteType} object. + */ + public static DateYearToMinuteType dateYearToMinuteType() { + return dateYearToMinuteType; + } + + /** + *

dateYearToMonthType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearToMonthType} object. + */ + public static DateYearToMonthType dateYearToMonthType() { + return dateYearToMonthType; + } + + /** + *

dateYearToSecondType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DateYearToSecondType} object. + */ + public static DateYearToSecondType dateYearToSecondType() { + return dateYearToSecondType; + } + + /** + *

doubleType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.DoubleType} object. + */ + public static DoubleType doubleType() { + return doubleType; + } + + /** + *

floatType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.FloatType} object. + */ + public static FloatType floatType() { + return floatType; + } + + /** + *

characterType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.CharacterType} object. + */ + public static CharacterType characterType() { + return characterType; + } + + /** + *

integerType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.IntegerType} object. + */ + public static IntegerType integerType() { + return integerType; + } + + /** + *

longType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.LongType} object. + */ + public static LongType longType() { + return longType; + } + + /** + *

shortType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.ShortType} object. + */ + public static ShortType shortType() { + return shortType; + } + + /** + *

stringType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.StringType} object. + */ + public static StringType stringType() { + return stringType; + } + + /** + *

listType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.ListType} object. + */ + public static ListType listType() { + return listType; + } + + /** + *

timeHourToFractionType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.TimeHourToFractionType} object. + */ + public static TimeHourToFractionType timeHourToFractionType() { + return timeHourToFractionType; + } + + /** + *

timeHourToMinuteType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.TimeHourToMinuteType} object. + */ + public static TimeHourToMinuteType timeHourToMinuteType() { + return timeHourToMinuteType; + } + + /** + *

timeHourToSecondType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.TimeHourToSecondType} object. + */ + public static TimeHourToSecondType timeHourToSecondType() { + return timeHourToSecondType; + } + + /** + *

percentageType.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.datatype.PercentageType} object. + */ + public static PercentageType percentageType() { + return percentageType; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateDayType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateDayType.java new file mode 100644 index 0000000..495edf5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateDayType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

DateDayType class.

+ * + * @author Ricardo Mariaca + * + */ +public class DateDayType extends DateType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getDateDayType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getDateDayType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateMonthType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateMonthType.java new file mode 100644 index 0000000..f585cb1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateMonthType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

DateMonthType class.

+ * + * @author Ricardo Mariaca + * + */ +public class DateMonthType extends DateType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getDateMonthType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getDateMonthType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateType.java new file mode 100644 index 0000000..32988c5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateType.java @@ -0,0 +1,73 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.base.datatype.AbstractDataType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +/** + *

DateType class.

+ * + * @author Ricardo Mariaca + * + */ +public class DateType extends AbstractDataType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getDateType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getDateType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + public String valueToString(Date value, Locale locale) { + if (value != null) { + return new SimpleDateFormat(getPattern(), locale).format(value); + } + return null; + } + + /** {@inheritDoc} */ + @Override + public Date stringToValue(String value, Locale locale) throws DRException { + if (value != null) { + try { + return new SimpleDateFormat(getPattern(), locale).parse(value); + } catch (ParseException e) { + throw new DRException("Unable to convert string value to date", e); + } + } + return null; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToFractionType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToFractionType.java new file mode 100644 index 0000000..4efe114 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToFractionType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

DateYearToFractionType class.

+ * + * @author Ricardo Mariaca + * + */ +public class DateYearToFractionType extends DateType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getDateYearToFractionType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getDateYearToFractionType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToHourType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToHourType.java new file mode 100644 index 0000000..5cc1f5a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToHourType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

DateYearToHourType class.

+ * + * @author Ricardo Mariaca + * + */ +public class DateYearToHourType extends DateType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getDateYearToHourType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getDateYearToHourType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToMinuteType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToMinuteType.java new file mode 100644 index 0000000..e66c120 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToMinuteType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

DateYearToMinuteType class.

+ * + * @author Ricardo Mariaca + * + */ +public class DateYearToMinuteType extends DateType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getDateYearToMinuteType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getDateYearToMinuteType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToMonthType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToMonthType.java new file mode 100644 index 0000000..6406c60 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToMonthType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

DateYearToMonthType class.

+ * + * @author Ricardo Mariaca + * + */ +public class DateYearToMonthType extends DateType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getDateYearToMonthType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getDateYearToMonthType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToSecondType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToSecondType.java new file mode 100644 index 0000000..fed04fa --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearToSecondType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

DateYearToSecondType class.

+ * + * @author Ricardo Mariaca + * + */ +public class DateYearToSecondType extends DateType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getDateYearToSecondType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getDateYearToSecondType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearType.java new file mode 100644 index 0000000..66a733a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DateYearType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

DateYearType class.

+ * + * @author Ricardo Mariaca + * + */ +public class DateYearType extends DateType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getDateYearType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getDateYearType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DoubleType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DoubleType.java new file mode 100644 index 0000000..fc8f12d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/DoubleType.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

DoubleType class.

+ * + * @author Ricardo Mariaca + * + */ +public class DoubleType extends NumberType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getDoubleType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getDoubleType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + protected Double numberToValue(Number number) { + return number.doubleValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/FloatType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/FloatType.java new file mode 100644 index 0000000..a030845 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/FloatType.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

FloatType class.

+ * + * @author Ricardo Mariaca + * + */ +public class FloatType extends NumberType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getFloatType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getFloatType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + protected Float numberToValue(Number number) { + return number.floatValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/IntegerType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/IntegerType.java new file mode 100644 index 0000000..5c0db92 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/IntegerType.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

IntegerType class.

+ * + * @author Ricardo Mariaca + * + */ +public class IntegerType extends NumberType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getIntegerType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getIntegerType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + protected Integer numberToValue(Number number) { + return number.intValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/ListType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/ListType.java new file mode 100644 index 0000000..1ddf5ba --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/ListType.java @@ -0,0 +1,77 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.base.datatype.AbstractDataType; +import software.xdev.dynamicreports.report.base.expression.AbstractValueFormatter; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; + +import java.util.List; + +/** + *

ListType class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings("rawtypes") +public class ListType extends AbstractDataType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private static ListFormatter listFormatter = new ListFormatter(); + + /** {@inheritDoc} */ + @Override + public DRIValueFormatter getValueFormatter() { + return listFormatter; + } + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getStringType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getStringType().getHorizontalTextAlignment(); + } + + private static class ListFormatter extends AbstractValueFormatter { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + @Override + public String format(List values, ReportParameters reportParameters) { + StringBuilder result = new StringBuilder(); + for (Object value : values) { + if (result.length() > 0) { + result.append("\n"); + } + if (value != null) { + result.append(value.toString()); + } + } + return result.toString(); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/LongType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/LongType.java new file mode 100644 index 0000000..cbb1ff8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/LongType.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

LongType class.

+ * + * @author Ricardo Mariaca + * + */ +public class LongType extends NumberType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getLongType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getLongType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + protected Long numberToValue(Number number) { + return number.longValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/NumberType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/NumberType.java new file mode 100644 index 0000000..509468f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/NumberType.java @@ -0,0 +1,75 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.base.datatype.AbstractDataType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.ParseException; +import java.util.Locale; + +/** + *

Abstract NumberType class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class NumberType extends AbstractDataType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String valueToString(Number value, Locale locale) { + if (value != null) { + return new DecimalFormat(getPattern(), new DecimalFormatSymbols(locale)).format(value); + } + return null; + } + + /** {@inheritDoc} */ + @Override + public T stringToValue(String value, Locale locale) throws DRException { + if (value != null) { + try { + return numberToValue(new DecimalFormat(getPattern(), new DecimalFormatSymbols(locale)).parse(value)); + } catch (ParseException e) { + throw new DRException("Unable to convert string value to date", e); + } + } + return null; + } + + /** + *

numberToValue.

+ * + * @param number a {@link java.lang.Number} object. + * @return a T object. + */ + protected abstract T numberToValue(Number number); + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override + public Class getValueClass() { + return (Class) ReportUtils.getGenericClass(this, 0); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/PercentageType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/PercentageType.java new file mode 100644 index 0000000..2f46c10 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/PercentageType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

PercentageType class.

+ * + * @author Ricardo Mariaca + * + */ +public class PercentageType extends DoubleType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getPercentageType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getPercentageType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/ShortType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/ShortType.java new file mode 100644 index 0000000..df878c3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/ShortType.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

ShortType class.

+ * + * @author Ricardo Mariaca + * + */ +public class ShortType extends NumberType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getShortType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getShortType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + protected Short numberToValue(Number number) { + return number.shortValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/StringType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/StringType.java new file mode 100644 index 0000000..dd607a4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/StringType.java @@ -0,0 +1,54 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.base.datatype.AbstractDataType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.util.Locale; + +/** + *

StringType class.

+ * + * @author Ricardo Mariaca + * + */ +public class StringType extends AbstractDataType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getStringType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getStringType().getHorizontalTextAlignment(); + } + + /** {@inheritDoc} */ + @Override + public String stringToValue(String value, Locale locale) throws DRException { + return value; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/TimeHourToFractionType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/TimeHourToFractionType.java new file mode 100644 index 0000000..5e86e6c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/TimeHourToFractionType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

TimeHourToFractionType class.

+ * + * @author Ricardo Mariaca + * + */ +public class TimeHourToFractionType extends DateType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getTimeHourToFractionType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getTimeHourToFractionType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/TimeHourToMinuteType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/TimeHourToMinuteType.java new file mode 100644 index 0000000..a7656b8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/TimeHourToMinuteType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

TimeHourToMinuteType class.

+ * + * @author Ricardo Mariaca + * + */ +public class TimeHourToMinuteType extends DateType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getTimeHourToMinuteType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getTimeHourToMinuteType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/TimeHourToSecondType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/TimeHourToSecondType.java new file mode 100644 index 0000000..a4db885 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/datatype/TimeHourToSecondType.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.datatype; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.defaults.Defaults; + +/** + *

TimeHourToSecondType class.

+ * + * @author Ricardo Mariaca + * + */ +public class TimeHourToSecondType extends DateType { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public String getPattern() { + return Defaults.getDefaults().getTimeHourToSecondType().getPattern(); + } + + /** {@inheritDoc} */ + @Override + public HorizontalTextAlignment getHorizontalTextAlignment() { + return Defaults.getDefaults().getTimeHourToSecondType().getHorizontalTextAlignment(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/AbstractComplexExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/AbstractComplexExpression.java new file mode 100644 index 0000000..6626b1c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/AbstractComplexExpression.java @@ -0,0 +1,149 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.base.DRField; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.VariableBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIComplexExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +import java.util.ArrayList; +import java.util.List; + +/** + *

Abstract AbstractComplexExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractComplexExpression implements DRIComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private List> expressions; + + /** + *

Constructor for AbstractComplexExpression.

+ */ + protected AbstractComplexExpression() { + this.name = ReportUtils.generateUniqueName("complexExpression"); + this.expressions = new ArrayList>(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

addExpression.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + protected void addExpression(FieldBuilder field) { + Validate.notNull(field, "field must not be null"); + this.expressions.add(field.getField()); + } + + /** + *

addExpression.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + */ + protected void addExpression(String fieldName, Class valueClass) { + @SuppressWarnings( {"unchecked", "rawtypes"}) DRField field = new DRField(fieldName, valueClass); + this.expressions.add(field); + } + + /** + *

addExpression.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.TextColumnBuilder} object. + */ + protected void addExpression(TextColumnBuilder column) { + Validate.notNull(column, "column must not be null"); + this.expressions.add(column.build()); + } + + /** + *

addExpression.

+ * + * @param variable a {@link software.xdev.dynamicreports.report.builder.VariableBuilder} object. + */ + protected void addExpression(VariableBuilder variable) { + Validate.notNull(variable, "variable must not be null"); + this.expressions.add(variable.getVariable()); + } + + /** + *

addExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected void addExpression(DRIExpression expression) { + Validate.notNull(expression, "expression must not be null"); + this.expressions.add(expression); + } + + /** + *

addExpression.

+ * + * @param crosstabGroup a {@link software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder} object. + */ + protected void addExpression(AbstractCrosstabGroupBuilder crosstabGroup) { + Validate.notNull(crosstabGroup, "crosstabGroup must not be null"); + this.expressions.add(Expressions.crosstabValue(crosstabGroup)); + } + + /** + *

addExpression.

+ * + * @param crosstabMeasure a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + protected void addExpression(CrosstabMeasureBuilder crosstabMeasure) { + Validate.notNull(crosstabMeasure, "crosstabMeasure must not be null"); + this.expressions.add(Expressions.crosstabValue(crosstabMeasure)); + } + + /** {@inheritDoc} */ + @Override + public List> getExpressions() { + return expressions; + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("unchecked") + public Class getValueClass() { + return (Class) ReportUtils.getGenericClass(this, 0); + } + + /** {@inheritDoc} */ + @Override + public abstract T evaluate(List values, ReportParameters reportParameters); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/AbstractSubDatasourceExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/AbstractSubDatasourceExpression.java new file mode 100644 index 0000000..1b8586c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/AbstractSubDatasourceExpression.java @@ -0,0 +1,87 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import net.sf.jasperreports.engine.JRDataSource; +import org.apache.commons.lang3.Validate; + +import java.util.List; + +/** + *

Abstract AbstractSubDatasourceExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class AbstractSubDatasourceExpression extends AbstractComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for AbstractSubDatasourceExpression.

+ * + * @param fieldName a {@link java.lang.String} object. + */ + protected AbstractSubDatasourceExpression(String fieldName) { + Validate.notNull(fieldName, "fieldName must not be null"); + addExpression(fieldName, getSubDatasourceDataClass()); + } + + /** + *

Constructor for AbstractSubDatasourceExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected AbstractSubDatasourceExpression(DRIExpression expression) { + addExpression(expression); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override + public JRDataSource evaluate(List values, ReportParameters reportParameters) { + return createSubDatasource((T) values.get(0)); + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return JRDataSource.class; + } + + /** + *

getSubDatasourceDataClass.

+ * + * @return a {@link java.lang.Class} object. + */ + @SuppressWarnings("unchecked") + protected Class getSubDatasourceDataClass() { + return (Class) ReportUtils.getGenericClass(this, 0); + } + + /** + *

createSubDatasource.

+ * + * @param data a T object. + * @return a {@link net.sf.jasperreports.engine.JRDataSource} object. + */ + protected abstract JRDataSource createSubDatasource(T data); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/AddExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/AddExpression.java new file mode 100644 index 0000000..2e1fd0c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/AddExpression.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.math.BigDecimal; + +/** + *

AddExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class AddExpression extends CalculationExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + @SafeVarargs + /** + *

Constructor for AddExpression.

+ * + * @param expressions a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public AddExpression(DRIExpression... expressions) { + super(expressions); + } + + /** {@inheritDoc} */ + @Override + protected BigDecimal calculate(BigDecimal value1, BigDecimal value2) { + return value1.add(value2); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/BeanArraySubDatasourceExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/BeanArraySubDatasourceExpression.java new file mode 100644 index 0000000..c2ffe2f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/BeanArraySubDatasourceExpression.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.data.JRBeanArrayDataSource; + +/** + *

BeanArraySubDatasourceExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class BeanArraySubDatasourceExpression extends AbstractSubDatasourceExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for BeanArraySubDatasourceExpression.

+ * + * @param fieldName a {@link java.lang.String} object. + */ + public BeanArraySubDatasourceExpression(String fieldName) { + super(fieldName); + } + + /** + *

Constructor for BeanArraySubDatasourceExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public BeanArraySubDatasourceExpression(DRIExpression expression) { + super(expression); + } + + /** {@inheritDoc} */ + @Override + protected JRDataSource createSubDatasource(Object[] data) { + return new JRBeanArrayDataSource(data); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/BeanCollectionSubDatasourceExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/BeanCollectionSubDatasourceExpression.java new file mode 100644 index 0000000..5122763 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/BeanCollectionSubDatasourceExpression.java @@ -0,0 +1,59 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; + +import java.util.Collection; + +/** + *

BeanCollectionSubDatasourceExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class BeanCollectionSubDatasourceExpression extends AbstractSubDatasourceExpression> { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for BeanCollectionSubDatasourceExpression.

+ * + * @param fieldName a {@link java.lang.String} object. + */ + public BeanCollectionSubDatasourceExpression(String fieldName) { + super(fieldName); + } + + /** + *

Constructor for BeanCollectionSubDatasourceExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public BeanCollectionSubDatasourceExpression(DRIExpression> expression) { + super(expression); + } + + /** {@inheritDoc} */ + @Override + protected JRDataSource createSubDatasource(Collection data) { + return new JRBeanCollectionDataSource(data); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/CalculationExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/CalculationExpression.java new file mode 100644 index 0000000..d311834 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/CalculationExpression.java @@ -0,0 +1,91 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import java.math.BigDecimal; +import java.util.List; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + + +/** + * @author Ricardo Mariaca + */ +abstract class CalculationExpression extends AbstractComplexExpression +{ + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for CalculationExpression.

+ * + * @param expressions a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + @SafeVarargs + protected CalculationExpression(final DRIExpression... expressions) + { + Validate.notNull(expressions, "expressions must not be null"); + Validate.noNullElements(expressions, "expressions must not contains null expression"); + for(final DRIExpression expression : expressions) + { + this.addExpression(expression); + } + } + + /** + * {@inheritDoc} + */ + @Override + public BigDecimal evaluate(final List values, final ReportParameters reportParameters) + { + BigDecimal result = null; + for(final Object value : values) + { + final BigDecimal bigDecimalValue; + if(value instanceof final BigDecimal bd) + { + bigDecimalValue = bd; + } + else + { + bigDecimalValue = BigDecimal.valueOf(((Number)value).doubleValue()); + } + if(result == null) + { + result = bigDecimalValue; + } + else + { + result = this.calculate(result, bigDecimalValue); + } + } + return result; + } + + /** + *

calculate.

+ * + * @param value1 a {@link java.math.BigDecimal} object. + * @param value2 a {@link java.math.BigDecimal} object. + * @return a {@link java.math.BigDecimal} object. + */ + protected abstract BigDecimal calculate(BigDecimal value1, BigDecimal value2); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ColumnNumberExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ColumnNumberExpression.java new file mode 100644 index 0000000..e6ac6cd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ColumnNumberExpression.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

ColumnNumberExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class ColumnNumberExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public Integer evaluate(ReportParameters reportParameters) { + return reportParameters.getColumnNumber(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ColumnRowNumberExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ColumnRowNumberExpression.java new file mode 100644 index 0000000..d637fb2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ColumnRowNumberExpression.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

ColumnRowNumberExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class ColumnRowNumberExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public Integer evaluate(ReportParameters reportParameters) { + return reportParameters.getColumnRowNumber(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/CrosstabValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/CrosstabValueExpression.java new file mode 100644 index 0000000..943be06 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/CrosstabValueExpression.java @@ -0,0 +1,74 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSystemExpression; +import software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRICrosstabValue; + +/** + *

CrosstabValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public final class CrosstabValueExpression extends AbstractSystemExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for CrosstabValueExpression.

+ * + * @param group a {@link software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder} object. + */ + protected CrosstabValueExpression(AbstractCrosstabGroupBuilder group) { + super(group.getName()); + } + + /** + *

Constructor for CrosstabValueExpression.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.definition.DRICrosstabValue} object. + */ + protected CrosstabValueExpression(DRICrosstabValue measure) { + super(measure.getName()); + } + + /** + *

Constructor for CrosstabValueExpression.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.definition.DRICrosstabValue} object. + * @param group a {@link software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder} object. + */ + protected CrosstabValueExpression(DRICrosstabValue measure, AbstractCrosstabGroupBuilder group) { + super(measure.getName() + "_" + group.getName() + "_ALL"); + } + + /** + *

Constructor for CrosstabValueExpression.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.definition.DRICrosstabValue} object. + * @param rowGroup a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + * @param columnGroup a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + */ + protected CrosstabValueExpression(DRICrosstabValue measure, CrosstabRowGroupBuilder rowGroup, CrosstabColumnGroupBuilder columnGroup) { + super(measure.getName() + "_" + rowGroup.getName() + "_" + columnGroup.getName() + "_ALL"); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/DataSourceExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/DataSourceExpression.java new file mode 100644 index 0000000..02864f8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/DataSourceExpression.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRRewindableDataSource; + +/** + *

DataSourceExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class DataSourceExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private JRDataSource dataSource; + private boolean moveFirst = false; + + /** + *

Constructor for DataSourceExpression.

+ * + * @param dataSource a {@link net.sf.jasperreports.engine.JRDataSource} object. + */ + public DataSourceExpression(JRDataSource dataSource) { + this.dataSource = dataSource; + } + + /** {@inheritDoc} */ + @Override + public JRDataSource evaluate(ReportParameters reportParameters) { + if (moveFirst && dataSource != null && dataSource instanceof JRRewindableDataSource) { + try { + ((JRRewindableDataSource) dataSource).moveFirst(); + } catch (JRException e) { + } + } + moveFirst = true; + return dataSource; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return JRDataSource.class; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/DivideExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/DivideExpression.java new file mode 100644 index 0000000..a13f35f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/DivideExpression.java @@ -0,0 +1,53 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.math.BigDecimal; + +/** + *

DivideExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class DivideExpression extends CalculationExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private int scale; + + @SafeVarargs + /** + *

Constructor for DivideExpression.

+ * + * @param scale a int. + * @param expressions a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DivideExpression(int scale, DRIExpression... expressions) { + super(expressions); + this.scale = scale; + } + + /** {@inheritDoc} */ + @Override + protected BigDecimal calculate(BigDecimal value1, BigDecimal value2) { + return value1.divide(value2, scale, BigDecimal.ROUND_HALF_UP); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ExpressionBuilders.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ExpressionBuilders.java new file mode 100644 index 0000000..002f582 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ExpressionBuilders.java @@ -0,0 +1,494 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import java.awt.Image; +import java.io.InputStream; +import java.net.URL; +import java.util.Collection; +import java.util.Date; +import java.util.Map; + +import software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.definition.DRICrosstabValue; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRISimpleExpression; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * A set of build in expressions.
Expressions are used to define various calculations, conditions, text field content, specific report groups, etc. + * + * @author Ricardo Mariaca + * + */ +public class ExpressionBuilders { + + /** + *

printInFirstPage.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintInFirstPageExpression} object. + */ + public PrintInFirstPageExpression printInFirstPage() { + return Expressions.printInFirstPage(); + } + + /** + *

printNotInFirstPage.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintNotInFirstPageExpression} object. + */ + public PrintNotInFirstPageExpression printNotInFirstPage() { + return Expressions.printNotInFirstPage(); + } + + /** + *

printWhenGroupHasMoreThanOneRow.

+ * + * @param groupName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintWhenGroupHasMoreThanOneRowExpression} object. + */ + public PrintWhenGroupHasMoreThanOneRowExpression printWhenGroupHasMoreThanOneRow(final String groupName) { + return Expressions.printWhenGroupHasMoreThanOneRow(groupName); + } + + /** + *

printWhenGroupHasMoreThanOneRow.

+ * + * @param group a {@link software.xdev.dynamicreports.report.builder.group.GroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintWhenGroupHasMoreThanOneRowExpression} object. + */ + public PrintWhenGroupHasMoreThanOneRowExpression printWhenGroupHasMoreThanOneRow(final GroupBuilder group) { + return Expressions.printWhenGroupHasMoreThanOneRow(group); + } + + /** + *

reportRowNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ReportRowNumberExpression} object. + */ + public ReportRowNumberExpression reportRowNumber() { + return Expressions.reportRowNumber(); + } + + /** + *

pageRowNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PageRowNumberExpression} object. + */ + public PageRowNumberExpression pageRowNumber() { + return Expressions.pageRowNumber(); + } + + /** + *

columnRowNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ColumnRowNumberExpression} object. + */ + public ColumnRowNumberExpression columnRowNumber() { + return Expressions.columnRowNumber(); + } + + /** + *

pageNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PageNumberExpression} object. + */ + public PageNumberExpression pageNumber() { + return Expressions.pageNumber(); + } + + /** + *

columnNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ColumnNumberExpression} object. + */ + public ColumnNumberExpression columnNumber() { + return Expressions.columnNumber(); + } + + /** + *

groupRowNumber.

+ * + * @param groupName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.GroupRowNumberExpression} object. + */ + public GroupRowNumberExpression groupRowNumber(final String groupName) { + return Expressions.groupRowNumber(groupName); + } + + /** + *

groupRowNumber.

+ * + * @param group a {@link software.xdev.dynamicreports.report.builder.group.GroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.GroupRowNumberExpression} object. + */ + public GroupRowNumberExpression groupRowNumber(final GroupBuilder group) { + return Expressions.groupRowNumber(group); + } + + /** + *

date.

+ * + * @param date a {@link java.util.Date} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public ValueExpression date(final Date date) { + return Expressions.date(date); + } + + /** + *

number.

+ * + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public ValueExpression number(final Number number) { + return Expressions.number(number); + } + + /** + *

image.

+ * + * @param image a {@link java.awt.Image} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public ValueExpression image(final Image image) { + return Expressions.image(image); + } + + /** + *

inputStream.

+ * + * @param inputStream a {@link java.io.InputStream} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public ValueExpression inputStream(final InputStream inputStream) { + return Expressions.inputStream(inputStream); + } + + /** + *

url.

+ * + * @param url a {@link java.net.URL} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public ValueExpression url(final URL url) { + return Expressions.url(url); + } + + /** + *

value.

+ * + * @param value a T object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public ValueExpression value(final T value) { + return Expressions.value(value); + } + + /** + *

value.

+ * + * @param value a T object. + * @param valueClass a {@link java.lang.Class} object. + * @param valueClass a {@link java.lang.Class} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public ValueExpression value(final T value, final Class valueClass) { + return Expressions.value(value, valueClass); + } + + /** + *

text.

+ * + * @param text a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public ValueExpression text(final String text) { + return Expressions.text(text); + } + + /** + *

dataSource.

+ * + * @param dataSource a {@link net.sf.jasperreports.engine.JRDataSource} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.DataSourceExpression} object. + */ + public DataSourceExpression dataSource(final JRDataSource dataSource) { + return Expressions.dataSource(dataSource); + } + + /** + *

message.

+ * + * @param key a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MessageExpression} object. + */ + public MessageExpression message(final String key) { + return Expressions.message(key); + } + + /** + *

message.

+ * + * @param key a {@link java.lang.String} object. + * @param arguments an array of {@link java.lang.Object} objects. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MessageExpression} object. + */ + public MessageExpression message(final String key, final Object[] arguments) { + return Expressions.message(key, arguments); + } + + // jasper + + /** + * Creates a new jasper expression.
This expression allows declaring an expression in a Jasper native syntax. Knowledge of the jasper syntax is also required for proper use. + * + * @param expression the jasper expression + * @param valueClass the expression class + * @param a T object. + * @return the expression + */ + public JasperExpression jasperSyntax(final String expression, final Class valueClass) { + return Expressions.jasperSyntax(expression, valueClass); + } + + /** + * Creates a new jasper expression.
This expression allows declaring an expression in a Jasper native syntax. Knowledge of the jasper syntax is also required for proper use. + * + * @param expression the jasper expression + * @return the expression + */ + @SuppressWarnings("rawtypes") + public JasperExpression jasperSyntax(final String expression) { + return Expressions.jasperSyntax(expression); + } + + // property + + /** + *

property.

+ * + * @param name a {@link java.lang.String} object. + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRISimpleExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PropertyExpression} object. + */ + public PropertyExpression property(final String name, final DRISimpleExpression valueExpression) { + return Expressions.property(name, valueExpression); + } + + /** + *

property.

+ * + * @param name a {@link java.lang.String} object. + * @param value a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PropertyExpression} object. + */ + public PropertyExpression property(final String name, final String value) { + return Expressions.property(name, value); + } + + // parameter + + /** + *

parameter.

+ * + * @param name a {@link java.lang.String} object. + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRISimpleExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ParameterExpression} object. + */ + public ParameterExpression parameter(final String name, final DRISimpleExpression valueExpression) { + return Expressions.parameter(name, valueExpression); + } + + /** + *

parameter.

+ * + * @param name a {@link java.lang.String} object. + * @param value a {@link java.lang.Object} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ParameterExpression} object. + */ + public ParameterExpression parameter(final String name, final Object value) { + return Expressions.parameter(name, value); + } + + /** + *

printInOddRow.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintInOddRowExpression} object. + */ + public PrintInOddRowExpression printInOddRow() { + return Expressions.printInOddRow(); + } + + /** + *

printInEvenRow.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintInEvenRowExpression} object. + */ + public PrintInEvenRowExpression printInEvenRow() { + return Expressions.printInEvenRow(); + } + + // subdatasource + + /** + *

subDatasourceBeanCollection.

+ * + * @param fieldName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.BeanCollectionSubDatasourceExpression} object. + */ + public BeanCollectionSubDatasourceExpression subDatasourceBeanCollection(final String fieldName) { + return Expressions.subDatasourceBeanCollection(fieldName); + } + + /** + *

subDatasourceBeanCollection.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.BeanCollectionSubDatasourceExpression} object. + */ + public BeanCollectionSubDatasourceExpression subDatasourceBeanCollection(final DRIExpression> expression) { + return Expressions.subDatasourceBeanCollection(expression); + } + + /** + *

subDatasourceBeanArray.

+ * + * @param fieldName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.BeanArraySubDatasourceExpression} object. + */ + public BeanArraySubDatasourceExpression subDatasourceBeanArray(final String fieldName) { + return Expressions.subDatasourceBeanArray(fieldName); + } + + /** + *

subDatasourceBeanArray.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.BeanArraySubDatasourceExpression} object. + */ + public BeanArraySubDatasourceExpression subDatasourceBeanArray(final DRIExpression expression) { + return Expressions.subDatasourceBeanArray(expression); + } + + /** + *

subDatasourceMapCollection.

+ * + * @param fieldName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MapCollectionSubDatasourceExpression} object. + */ + public MapCollectionSubDatasourceExpression subDatasourceMapCollection(final String fieldName) { + return Expressions.subDatasourceMapCollection(fieldName); + } + + /** + *

subDatasourceMapCollection.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MapCollectionSubDatasourceExpression} object. + */ + public MapCollectionSubDatasourceExpression subDatasourceMapCollection(final DRIExpression>> expression) { + return Expressions.subDatasourceMapCollection(expression); + } + + /** + *

subDatasourceMapArray.

+ * + * @param fieldName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MapArraySubDatasourceExpression} object. + */ + public MapArraySubDatasourceExpression subDatasourceMapArray(final String fieldName) { + return Expressions.subDatasourceMapArray(fieldName); + } + + /** + *

subDatasourceMapArray.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MapArraySubDatasourceExpression} object. + */ + public MapArraySubDatasourceExpression subDatasourceMapArray(final DRIExpression expression) { + return Expressions.subDatasourceMapArray(expression); + } + + // crosstab + + /** + *

orderBy.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.OrderByExpression} object. + */ + public OrderByExpression orderBy(final CrosstabMeasureBuilder> measure) { + return Expressions.orderBy(measure); + } + + /** + *

crosstabValue.

+ * + * @param group a {@link software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.CrosstabValueExpression} object. + */ + public CrosstabValueExpression crosstabValue(final AbstractCrosstabGroupBuilder group) { + return Expressions.crosstabValue(group); + } + + /** + *

crosstabValue.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.definition.DRICrosstabValue} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.CrosstabValueExpression} object. + */ + public CrosstabValueExpression crosstabValue(final DRICrosstabValue measure) { + return Expressions.crosstabValue(measure); + } + + /** + *

crosstabValue.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.definition.DRICrosstabValue} object. + * @param group a {@link software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.CrosstabValueExpression} object. + */ + public CrosstabValueExpression crosstabValue(final DRICrosstabValue measure, final AbstractCrosstabGroupBuilder group) { + return Expressions.crosstabValue(measure, group); + } + + /** + *

crosstabValue.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.definition.DRICrosstabValue} object. + * @param rowGroup a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + * @param columnGroup a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.CrosstabValueExpression} object. + */ + public CrosstabValueExpression crosstabValue(final DRICrosstabValue measure, final CrosstabRowGroupBuilder rowGroup, final CrosstabColumnGroupBuilder columnGroup) { + return Expressions.crosstabValue(measure, rowGroup, columnGroup); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/Expressions.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/Expressions.java new file mode 100644 index 0000000..26a2562 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/Expressions.java @@ -0,0 +1,512 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import java.awt.Image; +import java.io.InputStream; +import java.net.URL; +import java.util.Collection; +import java.util.Date; +import java.util.Map; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.definition.DRICrosstabValue; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * A set of build in expressions.
Expressions are used to define various calculations, conditions, text field content, specific report groups, etc. + * + * @author Ricardo Mariaca + * + */ +public class Expressions { + private static final PrintInFirstPageExpression printInFirstPage = new PrintInFirstPageExpression(); + private static final PrintNotInFirstPageExpression printNotInFirstPage = new PrintNotInFirstPageExpression(); + private static final ReportRowNumberExpression reportRowNumber = new ReportRowNumberExpression(); + private static final PageRowNumberExpression pageRowNumber = new PageRowNumberExpression(); + private static final ColumnRowNumberExpression columnRowNumber = new ColumnRowNumberExpression(); + private static final PageNumberExpression pageNumber = new PageNumberExpression(); + private static final ColumnNumberExpression columnNumber = new ColumnNumberExpression(); + private static final PrintInOddRowExpression printInOddRow = new PrintInOddRowExpression(); + private static final PrintInEvenRowExpression printInEvenRow = new PrintInEvenRowExpression(); + + /** + *

printInFirstPage.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintInFirstPageExpression} object. + */ + public static PrintInFirstPageExpression printInFirstPage() { + return printInFirstPage; + } + + /** + *

printNotInFirstPage.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintNotInFirstPageExpression} object. + */ + public static PrintNotInFirstPageExpression printNotInFirstPage() { + return printNotInFirstPage; + } + + /** + *

printWhenGroupHasMoreThanOneRow.

+ * + * @param groupName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintWhenGroupHasMoreThanOneRowExpression} object. + */ + public static PrintWhenGroupHasMoreThanOneRowExpression printWhenGroupHasMoreThanOneRow(final String groupName) { + return new PrintWhenGroupHasMoreThanOneRowExpression(groupName); + } + + /** + *

printWhenGroupHasMoreThanOneRow.

+ * + * @param group a {@link software.xdev.dynamicreports.report.builder.group.GroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintWhenGroupHasMoreThanOneRowExpression} object. + */ + public static PrintWhenGroupHasMoreThanOneRowExpression printWhenGroupHasMoreThanOneRow(final GroupBuilder group) { + Validate.notNull(group, "group must not be null"); + return printWhenGroupHasMoreThanOneRow(group.getGroup().getName()); + } + + /** + *

reportRowNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ReportRowNumberExpression} object. + */ + public static ReportRowNumberExpression reportRowNumber() { + return reportRowNumber; + } + + /** + *

pageRowNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PageRowNumberExpression} object. + */ + public static PageRowNumberExpression pageRowNumber() { + return pageRowNumber; + } + + /** + *

columnRowNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ColumnRowNumberExpression} object. + */ + public static ColumnRowNumberExpression columnRowNumber() { + return columnRowNumber; + } + + /** + *

pageNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PageNumberExpression} object. + */ + public static PageNumberExpression pageNumber() { + return pageNumber; + } + + /** + *

columnNumber.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ColumnNumberExpression} object. + */ + public static ColumnNumberExpression columnNumber() { + return columnNumber; + } + + /** + *

groupRowNumber.

+ * + * @param groupName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.GroupRowNumberExpression} object. + */ + public static GroupRowNumberExpression groupRowNumber(final String groupName) { + return new GroupRowNumberExpression(groupName); + } + + /** + *

groupRowNumber.

+ * + * @param group a {@link software.xdev.dynamicreports.report.builder.group.GroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.GroupRowNumberExpression} object. + */ + public static GroupRowNumberExpression groupRowNumber(final GroupBuilder group) { + Validate.notNull(group, "group must not be null"); + return groupRowNumber(group.getGroup().getName()); + } + + /** + *

date.

+ * + * @param date a {@link java.util.Date} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public static ValueExpression date(final Date date) { + return value(date, Date.class); + } + + /** + *

number.

+ * + * @param number a {@link java.lang.Number} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public static ValueExpression number(final Number number) { + return value(number, Number.class); + } + + /** + *

image.

+ * + * @param image a {@link java.awt.Image} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public static ValueExpression image(final Image image) { + return value(image, Image.class); + } + + /** + *

inputStream.

+ * + * @param inputStream a {@link java.io.InputStream} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public static ValueExpression inputStream(final InputStream inputStream) { + return value(inputStream, InputStream.class); + } + + /** + *

url.

+ * + * @param url a {@link java.net.URL} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public static ValueExpression url(final URL url) { + return value(url, URL.class); + } + + /** + *

value.

+ * + * @param value a T object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public static ValueExpression value(final T value) { + return new ValueExpression<>(value); + } + + /** + *

value.

+ * + * @param value a T object. + * @param valueClass a {@link java.lang.Class} object. + * @param valueClass a {@link java.lang.Class} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public static ValueExpression value(final T value, final Class valueClass) { + return new ValueExpression<>(value, valueClass); + } + + /** + *

text.

+ * + * @param text a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ValueExpression} object. + */ + public static ValueExpression text(final String text) { + return value(text, String.class); + } + + /** + *

dataSource.

+ * + * @param dataSource a {@link net.sf.jasperreports.engine.JRDataSource} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.DataSourceExpression} object. + */ + public static DataSourceExpression dataSource(final JRDataSource dataSource) { + return new DataSourceExpression(dataSource); + } + + /** + *

message.

+ * + * @param key a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MessageExpression} object. + */ + public static MessageExpression message(final String key) { + if (key != null) { + return new MessageExpression(key); + } + return null; + } + + /** + *

message.

+ * + * @param key a {@link java.lang.String} object. + * @param arguments an array of {@link java.lang.Object} objects. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MessageExpression} object. + */ + public static MessageExpression message(final String key, final Object[] arguments) { + if (key != null) { + return new MessageExpression(key, arguments); + } + return null; + } + + // jasper + + /** + * Creates a new jasper expression.
This expression allows declaring an expression in a Jasper native syntax. Knowledge of the jasper syntax is also required for proper use. + * + * @param expression the jasper expression + * @param valueClass the expression class + * @param a T object. + * @return the expression + */ + public static JasperExpression jasperSyntax(final String expression, final Class valueClass) { + return new JasperExpression<>(expression, valueClass); + } + + /** + * Creates a new jasper expression.
This expression allows declaring an expression in a Jasper native syntax. Knowledge of the jasper syntax is also required for proper use. + * + * @param expression the jasper expression + * @return the expression + */ + @SuppressWarnings("rawtypes") + public static JasperExpression jasperSyntax(final String expression) { + return jasperSyntax(expression, Object.class); + } + + // property + + /** + *

property.

+ * + * @param name a {@link java.lang.String} object. + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PropertyExpression} object. + */ + public static PropertyExpression property(final String name, final DRIExpression valueExpression) { + return new PropertyExpression(name, valueExpression); + } + + /** + *

property.

+ * + * @param name a {@link java.lang.String} object. + * @param value a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PropertyExpression} object. + */ + public static PropertyExpression property(final String name, final String value) { + return new PropertyExpression(name, text(value)); + } + + // parameter + + /** + *

parameter.

+ * + * @param name a {@link java.lang.String} object. + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ParameterExpression} object. + */ + public static ParameterExpression parameter(final String name, final DRIExpression valueExpression) { + return new ParameterExpression(name, valueExpression); + } + + /** + *

parameter.

+ * + * @param name a {@link java.lang.String} object. + * @param value a {@link java.lang.Object} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.ParameterExpression} object. + */ + public static ParameterExpression parameter(final String name, final Object value) { + return new ParameterExpression(name, value(value)); + } + + /** + *

printInOddRow.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintInOddRowExpression} object. + */ + public static PrintInOddRowExpression printInOddRow() { + return printInOddRow; + } + + /** + *

printInEvenRow.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.expression.PrintInEvenRowExpression} object. + */ + public static PrintInEvenRowExpression printInEvenRow() { + return printInEvenRow; + } + + // subdatasource + + /** + *

subDatasourceBeanCollection.

+ * + * @param fieldName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.BeanCollectionSubDatasourceExpression} object. + */ + public static BeanCollectionSubDatasourceExpression subDatasourceBeanCollection(final String fieldName) { + return new BeanCollectionSubDatasourceExpression(fieldName); + } + + /** + *

subDatasourceBeanCollection.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.BeanCollectionSubDatasourceExpression} object. + */ + public static BeanCollectionSubDatasourceExpression subDatasourceBeanCollection(final DRIExpression> expression) { + return new BeanCollectionSubDatasourceExpression(expression); + } + + /** + *

subDatasourceBeanArray.

+ * + * @param fieldName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.BeanArraySubDatasourceExpression} object. + */ + public static BeanArraySubDatasourceExpression subDatasourceBeanArray(final String fieldName) { + return new BeanArraySubDatasourceExpression(fieldName); + } + + /** + *

subDatasourceBeanArray.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.BeanArraySubDatasourceExpression} object. + */ + public static BeanArraySubDatasourceExpression subDatasourceBeanArray(final DRIExpression expression) { + return new BeanArraySubDatasourceExpression(expression); + } + + /** + *

subDatasourceMapCollection.

+ * + * @param fieldName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MapCollectionSubDatasourceExpression} object. + */ + public static MapCollectionSubDatasourceExpression subDatasourceMapCollection(final String fieldName) { + return new MapCollectionSubDatasourceExpression(fieldName); + } + + /** + *

subDatasourceMapCollection.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MapCollectionSubDatasourceExpression} object. + */ + public static MapCollectionSubDatasourceExpression subDatasourceMapCollection(final DRIExpression>> expression) { + return new MapCollectionSubDatasourceExpression(expression); + } + + /** + *

subDatasourceMapArray.

+ * + * @param fieldName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MapArraySubDatasourceExpression} object. + */ + public static MapArraySubDatasourceExpression subDatasourceMapArray(final String fieldName) { + return new MapArraySubDatasourceExpression(fieldName); + } + + /** + *

subDatasourceMapArray.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.MapArraySubDatasourceExpression} object. + */ + public static MapArraySubDatasourceExpression subDatasourceMapArray(final DRIExpression expression) { + return new MapArraySubDatasourceExpression(expression); + } + + // crosstab + + /** + *

orderBy.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.OrderByExpression} object. + */ + public static OrderByExpression orderBy(final CrosstabMeasureBuilder> measure) { + return new OrderByExpression(measure); + } + + /** + *

crosstabValue.

+ * + * @param group a {@link software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.CrosstabValueExpression} object. + */ + public static CrosstabValueExpression crosstabValue(final AbstractCrosstabGroupBuilder group) { + return new CrosstabValueExpression<>(group); + } + + /** + *

crosstabValue.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.definition.DRICrosstabValue} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.CrosstabValueExpression} object. + */ + public static CrosstabValueExpression crosstabValue(final DRICrosstabValue measure) { + return new CrosstabValueExpression<>(measure); + } + + /** + *

crosstabValue.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.definition.DRICrosstabValue} object. + * @param group a {@link software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.CrosstabValueExpression} object. + */ + public static CrosstabValueExpression crosstabValue(final DRICrosstabValue measure, final AbstractCrosstabGroupBuilder group) { + return new CrosstabValueExpression<>(measure, group); + } + + /** + *

crosstabValue.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.definition.DRICrosstabValue} object. + * @param rowGroup a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder} object. + * @param columnGroup a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder} object. + * @param a T object. + * @return a {@link software.xdev.dynamicreports.report.builder.expression.CrosstabValueExpression} object. + */ + public static CrosstabValueExpression crosstabValue(final DRICrosstabValue measure, final CrosstabRowGroupBuilder rowGroup, final CrosstabColumnGroupBuilder columnGroup) { + return new CrosstabValueExpression<>(measure, rowGroup, columnGroup); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/GroupRowNumberExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/GroupRowNumberExpression.java new file mode 100644 index 0000000..344e022 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/GroupRowNumberExpression.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

GroupRowNumberExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class GroupRowNumberExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String groupName; + + /** + *

Constructor for GroupRowNumberExpression.

+ * + * @param groupName a {@link java.lang.String} object. + */ + public GroupRowNumberExpression(String groupName) { + this.groupName = groupName; + } + + /** {@inheritDoc} */ + @Override + public Integer evaluate(ReportParameters reportParameters) { + return reportParameters.getGroupCount(groupName); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/JasperExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/JasperExpression.java new file mode 100644 index 0000000..a7420e3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/JasperExpression.java @@ -0,0 +1,69 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.ReportUtils; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIJasperExpression; +import org.apache.commons.lang3.Validate; + +/** + *

JasperExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class JasperExpression implements DRIJasperExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private String expression; + private Class valueClass; + + /** + *

Constructor for JasperExpression.

+ * + * @param expression a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + */ + protected JasperExpression(String expression, Class valueClass) { + Validate.notNull(expression, "expression must not be null"); + Validate.notNull(valueClass, "valueClass must not be null"); + this.expression = expression; + this.valueClass = valueClass; + this.name = ReportUtils.generateUniqueName("jasperExpression"); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** {@inheritDoc} */ + @Override + public String getExpression() { + return expression; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return valueClass; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MapArraySubDatasourceExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MapArraySubDatasourceExpression.java new file mode 100644 index 0000000..db0cbc3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MapArraySubDatasourceExpression.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.data.JRMapArrayDataSource; + +/** + *

MapArraySubDatasourceExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class MapArraySubDatasourceExpression extends AbstractSubDatasourceExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for MapArraySubDatasourceExpression.

+ * + * @param fieldName a {@link java.lang.String} object. + */ + public MapArraySubDatasourceExpression(String fieldName) { + super(fieldName); + } + + /** + *

Constructor for MapArraySubDatasourceExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public MapArraySubDatasourceExpression(DRIExpression expression) { + super(expression); + } + + /** {@inheritDoc} */ + @Override + protected JRDataSource createSubDatasource(Object[] data) { + return new JRMapArrayDataSource(data); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MapCollectionSubDatasourceExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MapCollectionSubDatasourceExpression.java new file mode 100644 index 0000000..8e38f40 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MapCollectionSubDatasourceExpression.java @@ -0,0 +1,60 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.data.JRMapCollectionDataSource; + +import java.util.Collection; +import java.util.Map; + +/** + *

MapCollectionSubDatasourceExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class MapCollectionSubDatasourceExpression extends AbstractSubDatasourceExpression>> { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for MapCollectionSubDatasourceExpression.

+ * + * @param fieldName a {@link java.lang.String} object. + */ + public MapCollectionSubDatasourceExpression(String fieldName) { + super(fieldName); + } + + /** + *

Constructor for MapCollectionSubDatasourceExpression.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public MapCollectionSubDatasourceExpression(DRIExpression>> expression) { + super(expression); + } + + /** {@inheritDoc} */ + @Override + protected JRDataSource createSubDatasource(Collection> data) { + return new JRMapCollectionDataSource(data); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MessageExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MessageExpression.java new file mode 100644 index 0000000..b3e74e0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MessageExpression.java @@ -0,0 +1,61 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

MessageExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class MessageExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String key; + private Object[] arguments; + + /** + *

Constructor for MessageExpression.

+ * + * @param key a {@link java.lang.String} object. + */ + public MessageExpression(String key) { + this(key, null); + } + + /** + *

Constructor for MessageExpression.

+ * + * @param key a {@link java.lang.String} object. + * @param arguments an array of {@link java.lang.Object} objects. + */ + public MessageExpression(String key, Object[] arguments) { + this.key = key; + this.arguments = arguments; + } + + /** {@inheritDoc} */ + @Override + public String evaluate(ReportParameters reportParameters) { + return reportParameters.getMessage(key, arguments); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MultiplyExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MultiplyExpression.java new file mode 100644 index 0000000..f0159f9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/MultiplyExpression.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.math.BigDecimal; + +/** + *

MultiplyExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class MultiplyExpression extends CalculationExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + @SafeVarargs + /** + *

Constructor for MultiplyExpression.

+ * + * @param expressions a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public MultiplyExpression(DRIExpression... expressions) { + super(expressions); + } + + /** {@inheritDoc} */ + @Override + protected BigDecimal calculate(BigDecimal value1, BigDecimal value2) { + return value1.multiply(value2); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/OrderByExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/OrderByExpression.java new file mode 100644 index 0000000..94434be --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/OrderByExpression.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

OrderByExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class OrderByExpression extends AbstractSimpleExpression> { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private CrosstabMeasureBuilder> measure; + + /** + *

Constructor for OrderByExpression.

+ * + * @param measure a {@link software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder} object. + */ + public OrderByExpression(CrosstabMeasureBuilder> measure) { + this.measure = measure; + } + + /** {@inheritDoc} */ + @Override + public Comparable evaluate(ReportParameters reportParameters) { + return reportParameters.getValue(measure); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PageNumberExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PageNumberExpression.java new file mode 100644 index 0000000..2975a16 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PageNumberExpression.java @@ -0,0 +1,39 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSystemExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.SystemExpression; + +/** + *

PageNumberExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public final class PageNumberExpression extends AbstractSystemExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for PageNumberExpression.

+ */ + protected PageNumberExpression() { + super(SystemExpression.PAGE_NUMBER.name()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PageRowNumberExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PageRowNumberExpression.java new file mode 100644 index 0000000..7070410 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PageRowNumberExpression.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

PageRowNumberExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class PageRowNumberExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public Integer evaluate(ReportParameters reportParameters) { + return reportParameters.getPageRowNumber(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ParameterExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ParameterExpression.java new file mode 100644 index 0000000..dd6baf6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ParameterExpression.java @@ -0,0 +1,79 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIParameterExpression; +import org.apache.commons.lang3.Validate; + +/** + *

ParameterExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class ParameterExpression implements DRIParameterExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRIExpression valueExpression; + + /** + *

Constructor for ParameterExpression.

+ * + * @param name a {@link java.lang.String} object. + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public ParameterExpression(String name, DRIExpression valueExpression) { + Validate.notNull(name, "name must not be null"); + Validate.notNull(valueExpression, "valueExpression must not be null"); + this.name = name; + this.valueExpression = valueExpression; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

Setter for the field name.

+ * + * @param name a {@link java.lang.String} object. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getValueExpression() { + return valueExpression; + } + + /** + *

Setter for the field valueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setValueExpression(DRIExpression valueExpression) { + this.valueExpression = valueExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PercentageExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PercentageExpression.java new file mode 100644 index 0000000..0ba0a98 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PercentageExpression.java @@ -0,0 +1,51 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.util.List; + +/** + *

PercentageExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class PercentageExpression extends AbstractComplexExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for PercentageExpression.

+ * + * @param actualExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param totalExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public PercentageExpression(DRIExpression actualExpression, DRIExpression totalExpression) { + addExpression(actualExpression); + addExpression(totalExpression); + } + + /** {@inheritDoc} */ + @Override + public Double evaluate(List values, ReportParameters reportParameters) { + return ((Number) values.get(0)).doubleValue() / ((Number) values.get(1)).doubleValue(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintInEvenRowExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintInEvenRowExpression.java new file mode 100644 index 0000000..b572b3c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintInEvenRowExpression.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

PrintInEvenRowExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class PrintInEvenRowExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + return reportParameters.getReportRowNumber().doubleValue() % 2 != 0; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintInFirstPageExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintInFirstPageExpression.java new file mode 100644 index 0000000..378d282 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintInFirstPageExpression.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

PrintInFirstPageExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class PrintInFirstPageExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + return reportParameters.getPageNumber() == 1; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintInOddRowExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintInOddRowExpression.java new file mode 100644 index 0000000..578a925 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintInOddRowExpression.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

PrintInOddRowExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class PrintInOddRowExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + return reportParameters.getReportRowNumber().doubleValue() % 2 == 0; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintNotInFirstPageExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintNotInFirstPageExpression.java new file mode 100644 index 0000000..8e574dc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintNotInFirstPageExpression.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

PrintNotInFirstPageExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class PrintNotInFirstPageExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + return reportParameters.getPageNumber() > 1; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintWhenGroupHasMoreThanOneRowExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintWhenGroupHasMoreThanOneRowExpression.java new file mode 100644 index 0000000..68c00be --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PrintWhenGroupHasMoreThanOneRowExpression.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

PrintWhenGroupHasMoreThanOneRowExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class PrintWhenGroupHasMoreThanOneRowExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String groupName; + + /** + *

Constructor for PrintWhenGroupHasMoreThanOneRowExpression.

+ * + * @param groupName a {@link java.lang.String} object. + */ + public PrintWhenGroupHasMoreThanOneRowExpression(String groupName) { + this.groupName = groupName; + } + + /** {@inheritDoc} */ + @Override + public Boolean evaluate(ReportParameters reportParameters) { + return reportParameters.getGroupCount(groupName) > 1; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PropertyExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PropertyExpression.java new file mode 100644 index 0000000..033426d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/PropertyExpression.java @@ -0,0 +1,79 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import org.apache.commons.lang3.Validate; + +/** + *

PropertyExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class PropertyExpression implements DRIPropertyExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String name; + private DRIExpression valueExpression; + + /** + *

Constructor for PropertyExpression.

+ * + * @param name a {@link java.lang.String} object. + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public PropertyExpression(String name, DRIExpression valueExpression) { + Validate.notNull(name, "name must not be null"); + Validate.notNull(valueExpression, "valueExpression must not be null"); + this.name = name; + this.valueExpression = valueExpression; + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return name; + } + + /** + *

Setter for the field name.

+ * + * @param name a {@link java.lang.String} object. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override + public DRIExpression getValueExpression() { + return valueExpression; + } + + /** + *

Setter for the field valueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public void setValueExpression(DRIExpression valueExpression) { + this.valueExpression = valueExpression; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ReportRowNumberExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ReportRowNumberExpression.java new file mode 100644 index 0000000..e929e5f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ReportRowNumberExpression.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

ReportRowNumberExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class ReportRowNumberExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** {@inheritDoc} */ + @Override + public Integer evaluate(ReportParameters reportParameters) { + return reportParameters.getReportRowNumber(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/SubtractExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/SubtractExpression.java new file mode 100644 index 0000000..b877f74 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/SubtractExpression.java @@ -0,0 +1,49 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.math.BigDecimal; + +/** + *

SubtractExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class SubtractExpression extends CalculationExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + @SafeVarargs + /** + *

Constructor for SubtractExpression.

+ * + * @param expressions a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public SubtractExpression(DRIExpression... expressions) { + super(expressions); + } + + /** {@inheritDoc} */ + @Override + protected BigDecimal calculate(BigDecimal value1, BigDecimal value2) { + return value1.subtract(value2); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/SystemMessageExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/SystemMessageExpression.java new file mode 100644 index 0000000..2bf7ea4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/SystemMessageExpression.java @@ -0,0 +1,51 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +import java.util.ResourceBundle; + +/** + *

SystemMessageExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class SystemMessageExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String key; + + /** + *

Constructor for SystemMessageExpression.

+ * + * @param key a {@link java.lang.String} object. + */ + public SystemMessageExpression(String key) { + this.key = key; + } + + /** {@inheritDoc} */ + @Override + public String evaluate(ReportParameters reportParameters) { + return ResourceBundle.getBundle(Constants.RESOURCE_BUNDLE_NAME, reportParameters.getLocale()).getString(key); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ValueExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ValueExpression.java new file mode 100644 index 0000000..2c87785 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/expression/ValueExpression.java @@ -0,0 +1,73 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.expression; + +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import org.apache.commons.lang3.Validate; + +/** + *

ValueExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public class ValueExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private T value; + private Class valueClass; + + @SuppressWarnings("unchecked") + /** + *

Constructor for ValueExpression.

+ * + * @param value a T object. + */ + public ValueExpression(T value) { + Validate.notNull(value, "value must not be null"); + this.value = value; + this.valueClass = (Class) value.getClass(); + } + + /** + *

Constructor for ValueExpression.

+ * + * @param value a T object. + * @param valueClass a {@link java.lang.Class} object. + * @param valueClass a {@link java.lang.Class} object. + */ + public ValueExpression(T value, Class valueClass) { + Validate.notNull(valueClass, "valueClass must not be null"); + this.value = value; + this.valueClass = valueClass; + } + + /** {@inheritDoc} */ + @Override + public T evaluate(ReportParameters reportParameters) { + return value; + } + + /** {@inheritDoc} */ + @Override + public Class getValueClass() { + return valueClass; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/ColumnGridComponentBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/ColumnGridComponentBuilder.java new file mode 100644 index 0000000..5bbfd0a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/ColumnGridComponentBuilder.java @@ -0,0 +1,36 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.grid; + +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent; + +/** + *

ColumnGridComponentBuilder interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface ColumnGridComponentBuilder { + + /** + *

build.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent} object. + */ + public DRIColumnGridComponent build(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/ColumnTitleGroupBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/ColumnTitleGroupBuilder.java new file mode 100644 index 0000000..87f176e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/ColumnTitleGroupBuilder.java @@ -0,0 +1,325 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.grid; + +import org.apache.commons.lang3.Validate; + +import software.xdev.dynamicreports.report.base.grid.DRColumnTitleGroup; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; + +/** + *

ColumnTitleGroupBuilder class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class ColumnTitleGroupBuilder extends AbstractBuilder implements ColumnGridComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for ColumnTitleGroupBuilder.

+ */ + protected ColumnTitleGroupBuilder() { + super(new DRColumnTitleGroup()); + } + + /** + *

add.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + */ + public ColumnTitleGroupBuilder add(final ColumnGridComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for (final ColumnGridComponentBuilder component : components) { + getObject().addComponent(component.build()); + } + return this; + } + + /** + *

setTitle.

+ * + * @param titleExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + */ + public ColumnTitleGroupBuilder setTitle(final DRIExpression titleExpression) { + getObject().setTitleExpression(titleExpression); + return this; + } + + /** + *

setTitle.

+ * + * @param title a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + */ + public ColumnTitleGroupBuilder setTitle(final String title) { + getObject().setTitleExpression(Expressions.text(title)); + return this; + } + + /** + *

setTitleStyle.

+ * + * @param titleStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + */ + public ColumnTitleGroupBuilder setTitleStyle(final ReportStyleBuilder titleStyle) { + if (titleStyle != null) { + getObject().setTitleStyle(titleStyle.getStyle()); + } else { + getObject().setTitleStyle(null); + } + return this; + } + + /** + * This method is used to define the preferred width of a column title. The width is set to the columns multiplied by width of the font + * + * @param columns the number of preferred columns >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if columns is < 0 + */ + public ColumnTitleGroupBuilder setTitleColumns(final Integer columns) { + getObject().setTitleColumns(columns); + return this; + } + + /** + * This method is used to define the fixed width of a column title. The width is set to the columns multiplied by width of the font + * + * @param columns the number of fixed columns >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if columns is < 0 + */ + public ColumnTitleGroupBuilder setTitleFixedColumns(final Integer columns) { + getObject().setTitleColumns(columns); + getObject().setTitleWidthType(ComponentDimensionType.FIXED); + return this; + } + + /** + * This method is used to define the minimum width of a column title. The width is set to the columns multiplied by width of the font + * + * @param columns the number of minimum columns >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if columns is < 0 + */ + public ColumnTitleGroupBuilder setTitleMinColumns(final Integer columns) { + getObject().setTitleColumns(columns); + getObject().setTitleWidthType(ComponentDimensionType.EXPAND); + return this; + } + + /** + * Sets the preferred width of a column title. + * + * @param width the column title preferred width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ColumnTitleGroupBuilder setTitleWidth(final Integer width) { + getObject().setTitleWidth(width); + return this; + } + + /** + * Sets the fixed width of a column title. + * + * @param width the column title fixed width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ColumnTitleGroupBuilder setTitleFixedWidth(final Integer width) { + getObject().setTitleWidth(width); + getObject().setTitleWidthType(ComponentDimensionType.FIXED); + return this; + } + + /** + * Sets the minimum width of a column title. + * + * @param width the column title minimum width >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ColumnTitleGroupBuilder setTitleMinWidth(final Integer width) { + getObject().setTitleWidth(width); + getObject().setTitleWidthType(ComponentDimensionType.EXPAND); + return this; + } + + /** + * This method is used to define the preferred height of a column title. The height is set to the rows multiplied by height of the font + * + * @param rows the number of preferred rows >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public ColumnTitleGroupBuilder setTitleRows(final Integer rows) { + getObject().setTitleRows(rows); + return this; + } + + /** + * This method is used to define the fixed height of a column title. The height is set to the rows multiplied by height of the font + * + * @param rows the number of fixed rows >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public ColumnTitleGroupBuilder setTitleFixedRows(final Integer rows) { + getObject().setTitleRows(rows); + getObject().setTitleHeightType(ComponentDimensionType.FIXED); + return this; + } + + /** + * This method is used to define the minimum height of a column title. The height is set to the rows multiplied by height of the font + * + * @param rows the number of minimum rows >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if rows is < 0 + */ + public ColumnTitleGroupBuilder setTitleMinRows(final Integer rows) { + getObject().setTitleRows(rows); + getObject().setTitleHeightType(ComponentDimensionType.EXPAND); + return this; + } + + /** + * Sets the preferred height of a column title. + * + * @param height the column title preferred height >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ColumnTitleGroupBuilder setTitleHeight(final Integer height) { + getObject().setTitleHeight(height); + return this; + } + + /** + * Sets the fixed height of a column title. + * + * @param height the column title fixed height >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ColumnTitleGroupBuilder setTitleFixedHeight(final Integer height) { + getObject().setTitleHeight(height); + getObject().setTitleHeightType(ComponentDimensionType.FIXED); + return this; + } + + /** + * Sets the minimum height of a column title. + * + * @param height the column title minimum height >= 0 + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @throws java.lang.IllegalArgumentException if height is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public ColumnTitleGroupBuilder setTitleMinHeight(final Integer height) { + getObject().setTitleHeight(height); + getObject().setTitleHeightType(ComponentDimensionType.EXPAND); + return this; + } + + /** + *

setTitleStretchWithOverflow.

+ * + * @param stretchWithOverflow a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + * @deprecated replaced by {@link #setTitleTextAdjust(TextAdjust)} + */ + @Deprecated + public ColumnTitleGroupBuilder setTitleStretchWithOverflow(final Boolean stretchWithOverflow) { + getObject().setTitleStretchWithOverflow(stretchWithOverflow); + return this; + } + + /** + *

setTitleTextAdjust.

+ * + * @param textAdjust a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + * @return a T object. + */ + public ColumnTitleGroupBuilder setTitleTextAdjust(final TextAdjust textAdjust) { + getObject().setTitleTextAdjust(textAdjust); + return this; + } + + /** + * Adds a jasper property to the column title group. + * + * @param propertyExpression the property expression + * @return a column title group builder + */ + public ColumnTitleGroupBuilder addTitleProperty(final DRIPropertyExpression propertyExpression) { + getObject().addTitlePropertyExpression(propertyExpression); + return this; + } + + /** + * Adds a jasper property to the column title group. + * + * @param name the property name + * @param valueExpression the property value expression + * @return a column title group builder + */ + public ColumnTitleGroupBuilder addTitleProperty(final String name, final DRIExpression valueExpression) { + getObject().addTitlePropertyExpression(Expressions.property(name, valueExpression)); + return this; + } + + /** + * Adds a jasper property to the column title group. + * + * @param name the property name + * @param value the property value + * @return a column title group builder + */ + public ColumnTitleGroupBuilder addTitleProperty(final String name, final String value) { + getObject().addTitlePropertyExpression(Expressions.property(name, value)); + return this; + } + + /** + *

getColumnGridTitleGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.grid.DRColumnTitleGroup} object. + */ + public DRColumnTitleGroup getColumnGridTitleGroup() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/GridBuilders.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/GridBuilders.java new file mode 100644 index 0000000..93bcb9d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/GridBuilders.java @@ -0,0 +1,172 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.grid; + +/** + * A set of methods of customizing columns layout + * + * @author Ricardo Mariaca + * + */ +public class GridBuilders { + + // horizontal + + /** + *

horizontalColumnGridList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder horizontalColumnGridList() { + return Grids.horizontalColumnGridList(); + } + + /** + *

horizontalColumnGridList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder horizontalColumnGridList(ColumnGridComponentBuilder... components) { + return Grids.horizontalColumnGridList(components); + } + + /** + *

horizontalColumnGridList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder horizontalColumnGridList(HorizontalColumnGridListCellBuilder... cells) { + return Grids.horizontalColumnGridList(cells); + } + + /** + *

hColumnGridListCell.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + */ + public HorizontalColumnGridListCellBuilder hColumnGridListCell(ColumnGridComponentBuilder component) { + return Grids.hColumnGridListCell(component); + } + + // horizontal flow + + /** + *

horizontalFlowColumnGridList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder horizontalFlowColumnGridList() { + return Grids.horizontalFlowColumnGridList(); + } + + /** + *

horizontalFlowColumnGridList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder horizontalFlowColumnGridList(ColumnGridComponentBuilder... components) { + return Grids.horizontalFlowColumnGridList(components); + } + + /** + *

horizontalFlowColumnGridList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder horizontalFlowColumnGridList(HorizontalColumnGridListCellBuilder... cells) { + return Grids.horizontalFlowColumnGridList(cells); + } + + // vertical + + /** + *

verticalColumnGridList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListBuilder} object. + */ + public VerticalColumnGridListBuilder verticalColumnGridList() { + return Grids.verticalColumnGridList(); + } + + /** + *

verticalColumnGridList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListBuilder} object. + */ + public VerticalColumnGridListBuilder verticalColumnGridList(ColumnGridComponentBuilder... components) { + return Grids.verticalColumnGridList(components); + } + + /** + *

verticalColumnGridList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListBuilder} object. + */ + public VerticalColumnGridListBuilder verticalColumnGridList(VerticalColumnGridListCellBuilder... cells) { + return Grids.verticalColumnGridList(cells); + } + + /** + *

vColumnGridListCell.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + */ + public VerticalColumnGridListCellBuilder vColumnGridListCell(ColumnGridComponentBuilder component) { + return Grids.vColumnGridListCell(component); + } + + // title group + + /** + *

titleGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + */ + public ColumnTitleGroupBuilder titleGroup() { + return Grids.titleGroup(); + } + + /** + *

titleGroup.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + */ + public ColumnTitleGroupBuilder titleGroup(ColumnGridComponentBuilder... components) { + return Grids.titleGroup(components); + } + + /** + *

titleGroup.

+ * + * @param title a {@link java.lang.String} object. + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + */ + public ColumnTitleGroupBuilder titleGroup(String title, ColumnGridComponentBuilder... components) { + return Grids.titleGroup(title, components); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/Grids.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/Grids.java new file mode 100644 index 0000000..5f2ad88 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/Grids.java @@ -0,0 +1,176 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.grid; + +import org.apache.commons.lang3.Validate; + +/** + * A set of methods of customizing columns layout + * + * @author Ricardo Mariaca + * + */ +public class Grids { + + // horizontal + + /** + *

horizontalColumnGridList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public static HorizontalColumnGridListBuilder horizontalColumnGridList() { + return new HorizontalColumnGridListBuilder(); + } + + /** + *

horizontalColumnGridList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public static HorizontalColumnGridListBuilder horizontalColumnGridList(ColumnGridComponentBuilder... components) { + return new HorizontalColumnGridListBuilder().add(components); + } + + /** + *

horizontalColumnGridList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public static HorizontalColumnGridListBuilder horizontalColumnGridList(HorizontalColumnGridListCellBuilder... cells) { + return new HorizontalColumnGridListBuilder().add(cells); + } + + /** + *

hColumnGridListCell.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + */ + public static HorizontalColumnGridListCellBuilder hColumnGridListCell(ColumnGridComponentBuilder component) { + Validate.notNull(component, "component must not be null"); + return new HorizontalColumnGridListCellBuilder(component); + } + + // horizontal flow + + /** + *

horizontalFlowColumnGridList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public static HorizontalColumnGridListBuilder horizontalFlowColumnGridList() { + return new HorizontalFlowColumnGridListBuilder(); + } + + /** + *

horizontalFlowColumnGridList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public static HorizontalColumnGridListBuilder horizontalFlowColumnGridList(ColumnGridComponentBuilder... components) { + return new HorizontalFlowColumnGridListBuilder().add(components); + } + + /** + *

horizontalFlowColumnGridList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public static HorizontalColumnGridListBuilder horizontalFlowColumnGridList(HorizontalColumnGridListCellBuilder... cells) { + return new HorizontalFlowColumnGridListBuilder().add(cells); + } + + // vertical + + /** + *

verticalColumnGridList.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListBuilder} object. + */ + public static VerticalColumnGridListBuilder verticalColumnGridList() { + return new VerticalColumnGridListBuilder(); + } + + /** + *

verticalColumnGridList.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListBuilder} object. + */ + public static VerticalColumnGridListBuilder verticalColumnGridList(ColumnGridComponentBuilder... components) { + return new VerticalColumnGridListBuilder().add(components); + } + + /** + *

verticalColumnGridList.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListBuilder} object. + */ + public static VerticalColumnGridListBuilder verticalColumnGridList(VerticalColumnGridListCellBuilder... cells) { + return new VerticalColumnGridListBuilder().add(cells); + } + + /** + *

vColumnGridListCell.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + */ + public static VerticalColumnGridListCellBuilder vColumnGridListCell(ColumnGridComponentBuilder component) { + Validate.notNull(component, "component must not be null"); + return new VerticalColumnGridListCellBuilder(component); + } + + // title group + + /** + *

titleGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + */ + public static ColumnTitleGroupBuilder titleGroup() { + return new ColumnTitleGroupBuilder(); + } + + /** + *

titleGroup.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + */ + public static ColumnTitleGroupBuilder titleGroup(ColumnGridComponentBuilder... components) { + return new ColumnTitleGroupBuilder().add(components); + } + + /** + *

titleGroup.

+ * + * @param title a {@link java.lang.String} object. + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder} object. + */ + public static ColumnTitleGroupBuilder titleGroup(String title, ColumnGridComponentBuilder... components) { + return titleGroup(components).setTitle(title); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/HorizontalColumnGridListBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/HorizontalColumnGridListBuilder.java new file mode 100644 index 0000000..92bc04f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/HorizontalColumnGridListBuilder.java @@ -0,0 +1,136 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.grid; + +import software.xdev.dynamicreports.report.base.grid.DRColumnGridList; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.ListType; +import org.apache.commons.lang3.Validate; + +/** + *

HorizontalColumnGridListBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class HorizontalColumnGridListBuilder extends AbstractBuilder implements ColumnGridComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRColumnGridList row; + + /** + *

Constructor for HorizontalColumnGridListBuilder.

+ */ + protected HorizontalColumnGridListBuilder() { + super(new DRColumnGridList(ListType.VERTICAL)); + init(); + } + + /** + *

init.

+ */ + protected void init() { + newRow(); + } + + /** + *

add.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder add(ColumnGridComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for (ColumnGridComponentBuilder component : components) { + row.addComponent(component.build()); + } + return this; + } + + /** + *

add.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder add(HorizontalColumnGridListCellBuilder... cells) { + Validate.notNull(cells, "cells must not be null"); + Validate.noNullElements(cells, "cells must not contains null cell"); + for (HorizontalColumnGridListCellBuilder cell : cells) { + row.addCell(cell.build()); + } + return this; + } + + /** + *

newRow.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder newRow() { + return newRow(ListType.HORIZONTAL); + } + + /** + *

newFlowRow.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder newFlowRow() { + return newRow(ListType.HORIZONTAL_FLOW); + } + + private HorizontalColumnGridListBuilder newRow(ListType listType) { + row = new DRColumnGridList(listType); + getObject().addComponent(row); + return this; + } + + /** + *

setGap.

+ * + * @param gap a int. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder setGap(int gap) { + row.setGap(gap); + return this; + } + + /** + *

setVerticalGap.

+ * + * @param gap a int. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListBuilder} object. + */ + public HorizontalColumnGridListBuilder setVerticalGap(int gap) { + getObject().setGap(gap); + return this; + } + + /** + *

getColumnGridList.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.grid.DRColumnGridList} object. + */ + public DRColumnGridList getColumnGridList() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/HorizontalColumnGridListCellBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/HorizontalColumnGridListCellBuilder.java new file mode 100644 index 0000000..02eb125 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/HorizontalColumnGridListCellBuilder.java @@ -0,0 +1,126 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.grid; + +import software.xdev.dynamicreports.report.base.grid.DRColumnGridListCell; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; + +/** + *

HorizontalColumnGridListCellBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class HorizontalColumnGridListCellBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for HorizontalColumnGridListCellBuilder.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + */ + protected HorizontalColumnGridListCellBuilder(ColumnGridComponentBuilder component) { + super(new DRColumnGridListCell(component.build())); + } + + // width + + /** + *

widthFixed.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + */ + public HorizontalColumnGridListCellBuilder widthFixed() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.LEFT); + return this; + } + + /** + *

widthFloat.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + */ + public HorizontalColumnGridListCellBuilder widthFloat() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.FLOAT); + return this; + } + + /** + *

widthExpand.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + */ + public HorizontalColumnGridListCellBuilder widthExpand() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.EXPAND); + return this; + } + + // height + + /** + *

heightFixedOnTop.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + */ + public HorizontalColumnGridListCellBuilder heightFixedOnTop() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.TOP); + return this; + } + + /** + *

heightFixedOnMiddle.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + */ + public HorizontalColumnGridListCellBuilder heightFixedOnMiddle() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.MIDDLE); + return this; + } + + /** + *

heightFixedOnBottom.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + */ + public HorizontalColumnGridListCellBuilder heightFixedOnBottom() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.BOTTOM); + return this; + } + + /** + *

heightExpand.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.HorizontalColumnGridListCellBuilder} object. + */ + public HorizontalColumnGridListCellBuilder heightExpand() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.EXPAND); + return this; + } + + /** + *

getColumnGridListCell.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.grid.DRColumnGridListCell} object. + */ + public DRColumnGridListCell getColumnGridListCell() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/HorizontalFlowColumnGridListBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/HorizontalFlowColumnGridListBuilder.java new file mode 100644 index 0000000..88811e8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/HorizontalFlowColumnGridListBuilder.java @@ -0,0 +1,42 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.grid; + +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

HorizontalFlowColumnGridListBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class HorizontalFlowColumnGridListBuilder extends HorizontalColumnGridListBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for HorizontalFlowColumnGridListBuilder.

+ */ + protected HorizontalFlowColumnGridListBuilder() { + } + + /** {@inheritDoc} */ + @Override + protected void init() { + newFlowRow(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/VerticalColumnGridListBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/VerticalColumnGridListBuilder.java new file mode 100644 index 0000000..e32a5ae --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/VerticalColumnGridListBuilder.java @@ -0,0 +1,91 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.grid; + +import software.xdev.dynamicreports.report.base.grid.DRColumnGridList; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.ListType; +import org.apache.commons.lang3.Validate; + +/** + *

VerticalColumnGridListBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class VerticalColumnGridListBuilder extends AbstractBuilder implements ColumnGridComponentBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for VerticalColumnGridListBuilder.

+ */ + protected VerticalColumnGridListBuilder() { + super(new DRColumnGridList(ListType.VERTICAL)); + } + + /** + *

add.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListBuilder} object. + */ + public VerticalColumnGridListBuilder add(ColumnGridComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for (ColumnGridComponentBuilder component : components) { + getObject().addComponent(component.build()); + } + return this; + } + + /** + *

add.

+ * + * @param cells a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListBuilder} object. + */ + public VerticalColumnGridListBuilder add(VerticalColumnGridListCellBuilder... cells) { + Validate.notNull(cells, "cells must not be null"); + Validate.noNullElements(cells, "cells must not contains null cell"); + for (VerticalColumnGridListCellBuilder cell : cells) { + getObject().addCell(cell.build()); + } + return this; + } + + /** + *

setGap.

+ * + * @param gap a int. + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListBuilder} object. + */ + public VerticalColumnGridListBuilder setGap(int gap) { + getObject().setGap(gap); + return this; + } + + /** + *

getColumnGridList.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.grid.DRColumnGridList} object. + */ + public DRColumnGridList getColumnGridList() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/VerticalColumnGridListCellBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/VerticalColumnGridListCellBuilder.java new file mode 100644 index 0000000..45a6af5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/grid/VerticalColumnGridListCellBuilder.java @@ -0,0 +1,126 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.grid; + +import software.xdev.dynamicreports.report.base.grid.DRColumnGridListCell; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; + +/** + *

VerticalColumnGridListCellBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class VerticalColumnGridListCellBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for VerticalColumnGridListCellBuilder.

+ * + * @param component a {@link software.xdev.dynamicreports.report.builder.grid.ColumnGridComponentBuilder} object. + */ + protected VerticalColumnGridListCellBuilder(ColumnGridComponentBuilder component) { + super(new DRColumnGridListCell(component.build())); + } + + // width + + /** + *

widthFixedOnLeft.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + */ + public VerticalColumnGridListCellBuilder widthFixedOnLeft() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.LEFT); + return this; + } + + /** + *

widthFixedOnCenter.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + */ + public VerticalColumnGridListCellBuilder widthFixedOnCenter() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.CENTER); + return this; + } + + /** + *

widthFixedOnRight.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + */ + public VerticalColumnGridListCellBuilder widthFixedOnRight() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.RIGHT); + return this; + } + + /** + *

widthFloat.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + */ + public VerticalColumnGridListCellBuilder widthFloat() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.FLOAT); + return this; + } + + /** + *

widthExpand.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + */ + public VerticalColumnGridListCellBuilder widthExpand() { + getObject().setHorizontalAlignment(HorizontalCellComponentAlignment.EXPAND); + return this; + } + + // height + + /** + *

heightFixed.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + */ + public VerticalColumnGridListCellBuilder heightFixed() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.TOP); + return this; + } + + /** + *

heightExpand.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.grid.VerticalColumnGridListCellBuilder} object. + */ + public VerticalColumnGridListCellBuilder heightExpand() { + getObject().setVerticalAlignment(VerticalCellComponentAlignment.EXPAND); + return this; + } + + /** + *

getColumnGridListCell.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.grid.DRColumnGridListCell} object. + */ + public DRColumnGridListCell getColumnGridListCell() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/ColumnGroupBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/ColumnGroupBuilder.java new file mode 100644 index 0000000..8c1973d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/ColumnGroupBuilder.java @@ -0,0 +1,91 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.group; + +import software.xdev.dynamicreports.report.base.column.DRValueColumn; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import org.apache.commons.lang3.Validate; + +/** + *

ColumnGroupBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class ColumnGroupBuilder extends GroupBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRValueColumn column; + + /** + *

Constructor for ColumnGroupBuilder.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + */ + protected ColumnGroupBuilder(ValueColumnBuilder column) { + Validate.notNull(column, "column must not be null"); + this.column = column.build(); + init(); + } + + /** + *

Constructor for ColumnGroupBuilder.

+ * + * @param name a {@link java.lang.String} object. + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + */ + protected ColumnGroupBuilder(String name, ValueColumnBuilder column) { + super(name); + Validate.notNull(column, "column must not be null"); + this.column = column.build(); + init(); + } + + @SuppressWarnings("unchecked") + private void init() { + @SuppressWarnings("rawtypes") DRIDataType dataType = column.getComponent().getDataType(); + getObject().getValueField().setDataType(dataType); + getObject().getValueField().setStyle(column.getComponent().getStyle()); + getObject().getValueField().setPattern(column.getComponent().getPattern()); + getObject().getValueField().setPatternExpression(column.getComponent().getPatternExpression()); + getObject().getValueField().setHorizontalTextAlignment(column.getComponent().getHorizontalTextAlignment()); + getObject().setTitleExpression(column.getTitleExpression()); + getObject().setTitleStyle(column.getTitleStyle()); + getObject().setTitleWidth(column.getComponent().getWidth()); + } + + /** + *

setHideColumn.

+ * + * @param hideColumn a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder} object. + */ + public ColumnGroupBuilder setHideColumn(Boolean hideColumn) { + getObject().setHideColumn(hideColumn); + return this; + } + + /** {@inheritDoc} */ + @Override + protected void configure() { + setValueExpression(column); + super.configure(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/CustomGroupBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/CustomGroupBuilder.java new file mode 100644 index 0000000..3d350c5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/CustomGroupBuilder.java @@ -0,0 +1,101 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.group; + +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + *

CustomGroupBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class CustomGroupBuilder extends GroupBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for CustomGroupBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + protected CustomGroupBuilder(FieldBuilder field) { + Validate.notNull(field, "field must not be null"); + setValueExpression(field.build()); + } + + /** + *

Constructor for CustomGroupBuilder.

+ * + * @param name a {@link java.lang.String} object. + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + */ + protected CustomGroupBuilder(String name, FieldBuilder field) { + super(name); + Validate.notNull(field, "field must not be null"); + setValueExpression(field.build()); + } + + /** + *

Constructor for CustomGroupBuilder.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected CustomGroupBuilder(DRIExpression valueExpression) { + setValueExpression(valueExpression); + } + + /** + *

Constructor for CustomGroupBuilder.

+ * + * @param name a {@link java.lang.String} object. + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected CustomGroupBuilder(String name, DRIExpression valueExpression) { + super(name); + setValueExpression(valueExpression); + } + + /** + *

setTitle.

+ * + * @param titleExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public CustomGroupBuilder setTitle(DRIExpression titleExpression) { + getObject().setTitleExpression(titleExpression); + getObject().setHeaderLayout(GroupHeaderLayout.TITLE_AND_VALUE); + return this; + } + + /** + *

setTitle.

+ * + * @param title a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public CustomGroupBuilder setTitle(String title) { + getObject().setTitleExpression(Expressions.text(title)); + getObject().setHeaderLayout(GroupHeaderLayout.TITLE_AND_VALUE); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/GroupBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/GroupBuilder.java new file mode 100644 index 0000000..a64d8d1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/GroupBuilder.java @@ -0,0 +1,533 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.group; + +import software.xdev.dynamicreports.report.base.DRGroup; +import software.xdev.dynamicreports.report.base.component.DRTextField; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.builder.component.ComponentBuilder; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.constant.HorizontalAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract GroupBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings( {"unchecked", "rawtypes", "deprecation"}) +public abstract class GroupBuilder> extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression valueExpression; + + /** + *

Constructor for GroupBuilder.

+ */ + protected GroupBuilder() { + super(new DRGroup(new DRTextField())); + } + + /** + *

Constructor for GroupBuilder.

+ * + * @param name a {@link java.lang.String} object. + */ + protected GroupBuilder(String name) { + super(new DRGroup(name, new DRTextField())); + } + + /** + *

Setter for the field valueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected void setValueExpression(DRIExpression valueExpression) { + this.valueExpression = valueExpression; + } + + /** + *

setHeaderLayout.

+ * + * @param headerLayout a {@link software.xdev.dynamicreports.report.constant.GroupHeaderLayout} object. + * @return a T object. + */ + public T setHeaderLayout(GroupHeaderLayout headerLayout) { + getObject().setHeaderLayout(headerLayout); + return (T) this; + } + + /** + *

showColumnHeaderAndFooter.

+ * + * @return a T object. + */ + public T showColumnHeaderAndFooter() { + return setShowColumnHeaderAndFooter(true); + } + + /** + *

setShowColumnHeaderAndFooter.

+ * + * @param showColumnHeaderAndFooter a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setShowColumnHeaderAndFooter(Boolean showColumnHeaderAndFooter) { + getObject().setShowColumnHeaderAndFooter(showColumnHeaderAndFooter); + return (T) this; + } + + /** + *

setAddToTableOfContents.

+ * + * @param addToTableOfContents a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setAddToTableOfContents(Boolean addToTableOfContents) { + getObject().setAddToTableOfContents(addToTableOfContents); + return (T) this; + } + + /** + *

setPrintSubtotalsWhenExpression.

+ * + * @param printSubtotalsWhenExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setPrintSubtotalsWhenExpression(DRIExpression printSubtotalsWhenExpression) { + getObject().setPrintSubtotalsWhenExpression(printSubtotalsWhenExpression); + return (T) this; + } + + /** + *

setPadding.

+ * + * @param padding a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setPadding(Integer padding) { + getObject().setPadding(padding); + return (T) this; + } + + /** + *

startInNewPage.

+ * + * @return a T object. + */ + public T startInNewPage() { + return setStartInNewPage(true); + } + + /** + *

setStartInNewPage.

+ * + * @param startInNewPage a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setStartInNewPage(Boolean startInNewPage) { + getObject().setStartInNewPage(startInNewPage); + return (T) this; + } + + /** + *

startInNewColumn.

+ * + * @return a T object. + */ + public T startInNewColumn() { + return setStartInNewColumn(true); + } + + /** + *

setStartInNewColumn.

+ * + * @param startInNewColumn a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setStartInNewColumn(Boolean startInNewColumn) { + getObject().setStartInNewColumn(startInNewColumn); + return (T) this; + } + + /** + *

reprintHeaderOnEachPage.

+ * + * @return a T object. + */ + public T reprintHeaderOnEachPage() { + return setReprintHeaderOnEachPage(true); + } + + /** + *

setReprintHeaderOnEachPage.

+ * + * @param reprintHeaderOnEachPage a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setReprintHeaderOnEachPage(Boolean reprintHeaderOnEachPage) { + getObject().setReprintHeaderOnEachPage(reprintHeaderOnEachPage); + return (T) this; + } + + /** + *

resetPageNumber.

+ * + * @return a T object. + */ + public T resetPageNumber() { + return setResetPageNumber(true); + } + + /** + *

setResetPageNumber.

+ * + * @param resetPageNumber a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setResetPageNumber(Boolean resetPageNumber) { + getObject().setResetPageNumber(resetPageNumber); + return (T) this; + } + + /** + *

setMinHeightToStartNewPage.

+ * + * @param minHeightToStartNewPage a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setMinHeightToStartNewPage(Integer minHeightToStartNewPage) { + getObject().setMinHeightToStartNewPage(minHeightToStartNewPage); + return (T) this; + } + + /** + *

setFooterPosition.

+ * + * @param footerPosition a {@link software.xdev.dynamicreports.report.constant.GroupFooterPosition} object. + * @return a T object. + */ + public T setFooterPosition(GroupFooterPosition footerPosition) { + getObject().setFooterPosition(footerPosition); + return (T) this; + } + + /** + *

keepTogether.

+ * + * @return a T object. + */ + public T keepTogether() { + return setKeepTogether(true); + } + + /** + *

setKeepTogether.

+ * + * @param keepTogether a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setKeepTogether(Boolean keepTogether) { + getObject().setKeepTogether(keepTogether); + return (T) this; + } + + /** + *

headerWithSubtotal.

+ * + * @return a T object. + */ + public T headerWithSubtotal() { + return setHeaderWithSubtotal(true); + } + + /** + *

setHeaderWithSubtotal.

+ * + * @param headerWithSubtotal a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setHeaderWithSubtotal(Boolean headerWithSubtotal) { + getObject().setHeaderWithSubtotal(headerWithSubtotal); + return (T) this; + } + + /** + *

groupByDataType.

+ * + * @return a T object. + */ + public T groupByDataType() { + return setGroupByDataType(true); + } + + /** + *

setGroupByDataType.

+ * + * @param groupByDataType a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setGroupByDataType(Boolean groupByDataType) { + getObject().setGroupByDataType(groupByDataType); + return (T) this; + } + + /** + *

setStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a T object. + */ + public T setStyle(ReportStyleBuilder style) { + if (style != null) { + getObject().getValueField().setStyle(style.getStyle()); + } else { + getObject().getValueField().setStyle(null); + } + return (T) this; + } + + /** + *

setHorizontalAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalAlignment} object. + * @return a T object. + * @deprecated use setHorizontalTextAlignment instead + */ + @Deprecated + public T setHorizontalAlignment(HorizontalAlignment horizontalAlignment) { + if (horizontalAlignment != null) { + getObject().getValueField().setHorizontalTextAlignment(HorizontalTextAlignment.valueOf(horizontalAlignment.name())); + } else { + getObject().getValueField().setHorizontalTextAlignment(null); + } + return (T) this; + } + + /** + *

setHorizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + * @return a T object. + */ + public T setHorizontalTextAlignment(HorizontalTextAlignment horizontalTextAlignment) { + getObject().getValueField().setHorizontalTextAlignment(horizontalTextAlignment); + return (T) this; + } + + /** + *

setTitleStyle.

+ * + * @param titleStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a T object. + */ + public T setTitleStyle(ReportStyleBuilder titleStyle) { + if (titleStyle != null) { + getObject().setTitleStyle(titleStyle.getStyle()); + } else { + getObject().setTitleStyle(null); + } + return (T) this; + } + + /** + *

setTitleWidth.

+ * + * @param titleWidth a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setTitleWidth(Integer titleWidth) { + getObject().setTitleWidth(titleWidth); + return (T) this; + } + + // header + + /** + *

setHeaderSplitType.

+ * + * @param splitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a T object. + */ + public T setHeaderSplitType(SplitType splitType) { + getObject().getHeaderBand().setSplitType(splitType); + return (T) this; + } + + /** + *

setHeaderPrintWhenExpression.

+ * + * @param printWhenExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setHeaderPrintWhenExpression(DRIExpression printWhenExpression) { + getObject().getHeaderBand().setPrintWhenExpression(printWhenExpression); + return (T) this; + } + + /** + *

setHeaderStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a T object. + */ + public T setHeaderStyle(ReportStyleBuilder style) { + if (style != null) { + getObject().getHeaderBand().getList().setStyle(style.build()); + } else { + getObject().getHeaderBand().getList().setStyle(null); + } + return (T) this; + } + + /** + *

setHeaderBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a T object. + */ + public T setHeaderBackgroundComponent(ComponentBuilder backgroundComponent) { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + getObject().getHeaderBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T) this; + } + + /** + *

addHeaderComponent.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a T object. + */ + public T addHeaderComponent(ComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for (ComponentBuilder component : components) { + getObject().getHeaderBand().addComponent(component.build()); + } + return (T) this; + } + + /** + *

header.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a T object. + */ + public T header(ComponentBuilder... components) { + return addHeaderComponent(components); + } + + // footer + + /** + *

setFooterSplitType.

+ * + * @param splitType a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + * @return a T object. + */ + public T setFooterSplitType(SplitType splitType) { + getObject().getFooterBand().setSplitType(splitType); + return (T) this; + } + + /** + *

setFooterPrintWhenExpression.

+ * + * @param printWhenExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setFooterPrintWhenExpression(DRIExpression printWhenExpression) { + getObject().getFooterBand().setPrintWhenExpression(printWhenExpression); + return (T) this; + } + + /** + *

setFooterStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a T object. + */ + public T setFooterStyle(ReportStyleBuilder style) { + if (style != null) { + getObject().getFooterBand().getList().setStyle(style.build()); + } else { + getObject().getFooterBand().getList().setStyle(null); + } + return (T) this; + } + + /** + *

setFooterBackgroundComponent.

+ * + * @param backgroundComponent a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a T object. + */ + public T setFooterBackgroundComponent(ComponentBuilder backgroundComponent) { + Validate.notNull(backgroundComponent, "backgroundComponent must not be null"); + getObject().getFooterBand().getList().setBackgroundComponent(backgroundComponent.build()); + return (T) this; + } + + /** + *

addFooterComponent.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a T object. + */ + public T addFooterComponent(ComponentBuilder... components) { + Validate.notNull(components, "components must not be null"); + Validate.noNullElements(components, "components must not contains null component"); + for (ComponentBuilder component : components) { + getObject().getFooterBand().addComponent(component.build()); + } + return (T) this; + } + + /** + *

footer.

+ * + * @param components a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + * @return a T object. + */ + public T footer(ComponentBuilder... components) { + return addFooterComponent(components); + } + + /** {@inheritDoc} */ + @Override + protected void configure() { + super.configure(); + getObject().getValueField().setValueExpression(valueExpression); + } + + /** + *

getGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRGroup} object. + */ + public DRGroup getGroup() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/GroupBuilders.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/GroupBuilders.java new file mode 100644 index 0000000..9a14f75 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/GroupBuilders.java @@ -0,0 +1,121 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.group; + +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + * A set of methods of creating report groups + * + * @author Ricardo Mariaca + * + */ +public class GroupBuilders { + + // column + + /** + *

group.

+ * + * @param groupColumn a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder} object. + */ + public ColumnGroupBuilder group(ValueColumnBuilder groupColumn) { + return Groups.group(groupColumn); + } + + /** + *

group.

+ * + * @param name a {@link java.lang.String} object. + * @param groupColumn a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder} object. + */ + public ColumnGroupBuilder group(String name, ValueColumnBuilder groupColumn) { + return Groups.group(name, groupColumn); + } + + // custom + + /** + *

group.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public CustomGroupBuilder group(String fieldName, Class valueClass) { + return Groups.group(fieldName, valueClass); + } + + /** + *

group.

+ * + * @param name a {@link java.lang.String} object. + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public CustomGroupBuilder group(String name, String fieldName, Class valueClass) { + return Groups.group(name, fieldName, valueClass); + } + + /** + *

group.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public CustomGroupBuilder group(FieldBuilder field) { + return Groups.group(field); + } + + /** + *

group.

+ * + * @param name a {@link java.lang.String} object. + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public CustomGroupBuilder group(String name, FieldBuilder field) { + return Groups.group(name, field); + } + + /** + *

group.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public CustomGroupBuilder group(DRIExpression expression) { + return Groups.group(expression); + } + + /** + *

group.

+ * + * @param name a {@link java.lang.String} object. + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public CustomGroupBuilder group(String name, DRIExpression expression) { + return Groups.group(name, expression); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/Groups.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/Groups.java new file mode 100644 index 0000000..ac5d73c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/group/Groups.java @@ -0,0 +1,122 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.group; + +import software.xdev.dynamicreports.report.builder.DynamicReports; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + * A set of methods of creating report groups + * + * @author Ricardo Mariaca + * + */ +public class Groups { + + // column + + /** + *

group.

+ * + * @param groupColumn a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder} object. + */ + public static ColumnGroupBuilder group(ValueColumnBuilder groupColumn) { + return new ColumnGroupBuilder(groupColumn); + } + + /** + *

group.

+ * + * @param name a {@link java.lang.String} object. + * @param groupColumn a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder} object. + */ + public static ColumnGroupBuilder group(String name, ValueColumnBuilder groupColumn) { + return new ColumnGroupBuilder(name, groupColumn); + } + + // custom + + /** + *

group.

+ * + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public static CustomGroupBuilder group(String fieldName, Class valueClass) { + return group(DynamicReports.field(fieldName, valueClass)); + } + + /** + *

group.

+ * + * @param name a {@link java.lang.String} object. + * @param fieldName a {@link java.lang.String} object. + * @param valueClass a {@link java.lang.Class} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public static CustomGroupBuilder group(String name, String fieldName, Class valueClass) { + return group(name, DynamicReports.field(fieldName, valueClass)); + } + + /** + *

group.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public static CustomGroupBuilder group(FieldBuilder field) { + return new CustomGroupBuilder(field); + } + + /** + *

group.

+ * + * @param name a {@link java.lang.String} object. + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public static CustomGroupBuilder group(String name, FieldBuilder field) { + return new CustomGroupBuilder(name, field); + } + + /** + *

group.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public static CustomGroupBuilder group(DRIExpression expression) { + return new CustomGroupBuilder(expression); + } + + /** + *

group.

+ * + * @param name a {@link java.lang.String} object. + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder} object. + */ + public static CustomGroupBuilder group(String name, DRIExpression expression) { + return new CustomGroupBuilder(name, expression); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/BaseStyleBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/BaseStyleBuilder.java new file mode 100644 index 0000000..58c133f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/BaseStyleBuilder.java @@ -0,0 +1,706 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.base.style.DRBaseStyle; +import software.xdev.dynamicreports.report.base.style.DRTabStop; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.constant.LineSpacing; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.Rotation; +import software.xdev.dynamicreports.report.constant.TabStopAlignment; +import software.xdev.dynamicreports.report.constant.VerticalAlignment; +import software.xdev.dynamicreports.report.constant.VerticalImageAlignment; +import software.xdev.dynamicreports.report.constant.VerticalTextAlignment; +import org.apache.commons.lang3.Validate; + +import java.awt.Color; + +/** + *

Abstract BaseStyleBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings( {"unchecked", "deprecation"}) +public abstract class BaseStyleBuilder, U extends DRBaseStyle> extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for BaseStyleBuilder.

+ * + * @param baseStyle a U object. + */ + protected BaseStyleBuilder(U baseStyle) { + super(baseStyle); + } + + /** + *

setBackgroundColor.

+ * + * @param backgroundColor a {@link java.awt.Color} object. + * @return a T object. + */ + public T setBackgroundColor(Color backgroundColor) { + getObject().setBackgroundColor(backgroundColor); + return (T) this; + } + + /** + *

setBorder.

+ * + * @param border a {@link software.xdev.dynamicreports.report.builder.style.BorderBuilder} object. + * @return a T object. + */ + public T setBorder(BorderBuilder border) { + if (border != null) { + getObject().setBorder(border.build()); + } else { + getObject().setBorder(null); + } + return (T) this; + } + + /** + *

setBorder.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a T object. + */ + public T setBorder(PenBuilder pen) { + return setBorder(pen != null ? Styles.border(pen) : null); + } + + /** + *

setTopBorder.

+ * + * @param topPen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a T object. + */ + public T setTopBorder(PenBuilder topPen) { + if (topPen != null) { + getObject().getBorder().setTopPen(topPen.build()); + } else { + getObject().getBorder().setTopPen(null); + } + return (T) this; + } + + /** + *

setLeftBorder.

+ * + * @param leftPen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a T object. + */ + public T setLeftBorder(PenBuilder leftPen) { + if (leftPen != null) { + getObject().getBorder().setLeftPen(leftPen.build()); + } else { + getObject().getBorder().setLeftPen(null); + } + return (T) this; + } + + /** + *

setBottomBorder.

+ * + * @param bottomPen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a T object. + */ + public T setBottomBorder(PenBuilder bottomPen) { + if (bottomPen != null) { + getObject().getBorder().setBottomPen(bottomPen.build()); + } else { + getObject().getBorder().setBottomPen(null); + } + return (T) this; + } + + /** + *

setRightBorder.

+ * + * @param rightPen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a T object. + */ + public T setRightBorder(PenBuilder rightPen) { + if (rightPen != null) { + getObject().getBorder().setRightPen(rightPen.build()); + } else { + getObject().getBorder().setRightPen(null); + } + return (T) this; + } + + /** + *

setFont.

+ * + * @param font a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + * @return a T object. + */ + public T setFont(FontBuilder font) { + if (font != null) { + getObject().setFont(font.build()); + } else { + getObject().setFont(null); + } + return (T) this; + } + + /** + *

bold.

+ * + * @return a T object. + */ + public T bold() { + return setBold(true); + } + + /** + *

setBold.

+ * + * @param bold a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setBold(Boolean bold) { + getObject().getFont().setBold(bold); + return (T) this; + } + + /** + *

setFontName.

+ * + * @param fontName a {@link java.lang.String} object. + * @return a T object. + */ + public T setFontName(String fontName) { + getObject().getFont().setFontName(fontName); + return (T) this; + } + + /** + *

setFontSize.

+ * + * @param fontSize a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setFontSize(Integer fontSize) { + getObject().getFont().setFontSize(fontSize); + return (T) this; + } + + /** + *

italic.

+ * + * @return a T object. + */ + public T italic() { + return setItalic(true); + } + + /** + *

setItalic.

+ * + * @param italic a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setItalic(Boolean italic) { + getObject().getFont().setItalic(italic); + return (T) this; + } + + /** + *

boldItalic.

+ * + * @return a T object. + */ + public T boldItalic() { + setBold(true); + return setItalic(true); + } + + @Deprecated + /** + * You should configure the fonts.xml file + * + * @param pdfEmbedded a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setPdfEmbedded(Boolean pdfEmbedded) { + getObject().getFont().setPdfEmbedded(pdfEmbedded); + return (T) this; + } + + @Deprecated + /** + * You should configure the fonts.xml file + * + * @param pdfEncoding a {@link java.lang.String} object. + * @return a T object. + */ + public T setPdfEncoding(String pdfEncoding) { + getObject().getFont().setPdfEncoding(pdfEncoding); + return (T) this; + } + + @Deprecated + /** + * You should configure the fonts.xml file + * + * @param pdfFontName a {@link java.lang.String} object. + * @return a T object. + */ + public T setPdfFontName(String pdfFontName) { + getObject().getFont().setPdfFontName(pdfFontName); + return (T) this; + } + + /** + *

strikeThrough.

+ * + * @return a T object. + */ + public T strikeThrough() { + return setStrikeThrough(true); + } + + /** + *

setStrikeThrough.

+ * + * @param strikeThrough a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setStrikeThrough(Boolean strikeThrough) { + getObject().getFont().setStrikeThrough(strikeThrough); + return (T) this; + } + + /** + *

underline.

+ * + * @return a T object. + */ + public T underline() { + return setUnderline(true); + } + + /** + *

setUnderline.

+ * + * @param underline a {@link java.lang.Boolean} object. + * @return a T object. + */ + public T setUnderline(Boolean underline) { + getObject().getFont().setUnderline(underline); + return (T) this; + } + + /** + *

setForegroundColor.

+ * + * @param foregroudColor a {@link java.awt.Color} object. + * @return a T object. + */ + public T setForegroundColor(Color foregroudColor) { + getObject().setForegroundColor(foregroudColor); + return (T) this; + } + + /** + *

setHorizontalAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalAlignment} object. + * @return a T object. + * @deprecated use setHorizontalTextAlignment instead + */ + @Deprecated + public T setHorizontalAlignment(HorizontalAlignment horizontalAlignment) { + if (horizontalAlignment != null) { + getObject().setHorizontalTextAlignment(HorizontalTextAlignment.valueOf(horizontalAlignment.name())); + } else { + getObject().setHorizontalTextAlignment(null); + } + return (T) this; + } + + /** + *

setHorizontalTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + * @return a T object. + */ + public T setHorizontalTextAlignment(HorizontalTextAlignment horizontalTextAlignment) { + getObject().setHorizontalTextAlignment(horizontalTextAlignment); + return (T) this; + } + + /** + *

setHorizontalImageAlignment.

+ * + * @param horizontalImageAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + * @return a T object. + */ + public T setHorizontalImageAlignment(HorizontalImageAlignment horizontalImageAlignment) { + getObject().setHorizontalImageAlignment(horizontalImageAlignment); + return (T) this; + } + + /** + *

setImageScale.

+ * + * @param imageScale a {@link software.xdev.dynamicreports.report.constant.ImageScale} object. + * @return a T object. + */ + public T setImageScale(ImageScale imageScale) { + getObject().setImageScale(imageScale); + return (T) this; + } + + /** + *

setPadding.

+ * + * @param padding a {@link software.xdev.dynamicreports.report.builder.style.PaddingBuilder} object. + * @return a T object. + */ + public T setPadding(PaddingBuilder padding) { + if (padding != null) { + getObject().setPadding(padding.build()); + } else { + getObject().setPadding(null); + } + return (T) this; + } + + /** + *

setPadding.

+ * + * @param padding a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setPadding(Integer padding) { + return setPadding(Styles.padding(padding)); + } + + /** + *

setTopPadding.

+ * + * @param top a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setTopPadding(Integer top) { + getObject().getPadding().setTop(top); + return (T) this; + } + + /** + *

setLeftPadding.

+ * + * @param left a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setLeftPadding(Integer left) { + getObject().getPadding().setLeft(left); + return (T) this; + } + + /** + *

setBottomPadding.

+ * + * @param bottom a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setBottomPadding(Integer bottom) { + getObject().getPadding().setBottom(bottom); + return (T) this; + } + + /** + *

setRightPadding.

+ * + * @param right a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setRightPadding(Integer right) { + getObject().getPadding().setRight(right); + return (T) this; + } + + /** + *

setPattern.

+ * + * @param pattern a {@link java.lang.String} object. + * @return a T object. + */ + public T setPattern(String pattern) { + getObject().setPattern(pattern); + return (T) this; + } + + /** + *

setRadius.

+ * + * @param radius a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setRadius(Integer radius) { + getObject().setRadius(radius); + return (T) this; + } + + /** + *

setRotation.

+ * + * @param rotation a {@link software.xdev.dynamicreports.report.constant.Rotation} object. + * @return a T object. + */ + public T setRotation(Rotation rotation) { + getObject().setRotation(rotation); + return (T) this; + } + + /** + *

setAlignment.

+ * + * @param horizontalAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalAlignment} object. + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalAlignment} object. + * @return a T object. + * @deprecated use setTextAlignment instead + */ + @Deprecated + public T setAlignment(HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) { + if (horizontalAlignment != null) { + getObject().setHorizontalTextAlignment(HorizontalTextAlignment.valueOf(horizontalAlignment.name())); + } else { + getObject().setHorizontalTextAlignment(null); + } + if (verticalAlignment != null) { + getObject().setVerticalTextAlignment(VerticalTextAlignment.valueOf(verticalAlignment.name())); + } else { + getObject().setVerticalTextAlignment(null); + } + return (T) this; + } + + /** + *

setTextAlignment.

+ * + * @param horizontalTextAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + * @param verticalTextAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalTextAlignment} object. + * @return a T object. + */ + public T setTextAlignment(HorizontalTextAlignment horizontalTextAlignment, VerticalTextAlignment verticalTextAlignment) { + getObject().setHorizontalTextAlignment(horizontalTextAlignment); + getObject().setVerticalTextAlignment(verticalTextAlignment); + return (T) this; + } + + /** + *

setImageAlignment.

+ * + * @param horizontalImageAlignment a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + * @param verticalImageAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalImageAlignment} object. + * @return a T object. + */ + public T setImageAlignment(HorizontalImageAlignment horizontalImageAlignment, VerticalImageAlignment verticalImageAlignment) { + getObject().setHorizontalImageAlignment(horizontalImageAlignment); + getObject().setVerticalImageAlignment(verticalImageAlignment); + return (T) this; + } + + /** + *

setVerticalAlignment.

+ * + * @param verticalAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalAlignment} object. + * @return a T object. + * @deprecated use setVerticalTextAlignment instead + */ + @Deprecated + public T setVerticalAlignment(VerticalAlignment verticalAlignment) { + if (verticalAlignment != null) { + getObject().setVerticalTextAlignment(VerticalTextAlignment.valueOf(verticalAlignment.name())); + } else { + getObject().setVerticalTextAlignment(null); + } + return (T) this; + } + + /** + *

setVerticalTextAlignment.

+ * + * @param verticalTextAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalTextAlignment} object. + * @return a T object. + */ + public T setVerticalTextAlignment(VerticalTextAlignment verticalTextAlignment) { + getObject().setVerticalTextAlignment(verticalTextAlignment); + return (T) this; + } + + /** + *

setVerticalImageAlignment.

+ * + * @param verticalImageAlignment a {@link software.xdev.dynamicreports.report.constant.VerticalImageAlignment} object. + * @return a T object. + */ + public T setVerticalImageAlignment(VerticalImageAlignment verticalImageAlignment) { + getObject().setVerticalImageAlignment(verticalImageAlignment); + return (T) this; + } + + /** + *

setMarkup.

+ * + * @param markup a {@link software.xdev.dynamicreports.report.constant.Markup} object. + * @return a T object. + */ + public T setMarkup(Markup markup) { + getObject().setMarkup(markup); + return (T) this; + } + + /** + *

setLineSpacing.

+ * + * @param lineSpacing a {@link software.xdev.dynamicreports.report.constant.LineSpacing} object. + * @return a T object. + */ + public T setLineSpacing(LineSpacing lineSpacing) { + getObject().getParagraph().setLineSpacing(lineSpacing); + return (T) this; + } + + /** + *

setLineSpacingSize.

+ * + * @param lineSpacingSize a {@link java.lang.Float} object. + * @return a T object. + */ + public T setLineSpacingSize(Float lineSpacingSize) { + getObject().getParagraph().setLineSpacingSize(lineSpacingSize); + return (T) this; + } + + /** + *

setFirstLineIndent.

+ * + * @param firstLineIndent a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setFirstLineIndent(Integer firstLineIndent) { + getObject().getParagraph().setFirstLineIndent(firstLineIndent); + return (T) this; + } + + /** + *

setLeftIndent.

+ * + * @param leftIndent a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setLeftIndent(Integer leftIndent) { + getObject().getParagraph().setLeftIndent(leftIndent); + return (T) this; + } + + /** + *

setRightIndent.

+ * + * @param rightIndent a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setRightIndent(Integer rightIndent) { + getObject().getParagraph().setRightIndent(rightIndent); + return (T) this; + } + + /** + *

setSpacingBefore.

+ * + * @param spacingBefore a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setSpacingBefore(Integer spacingBefore) { + getObject().getParagraph().setSpacingBefore(spacingBefore); + return (T) this; + } + + /** + *

setSpacingAfter.

+ * + * @param spacingAfter a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setSpacingAfter(Integer spacingAfter) { + getObject().getParagraph().setSpacingAfter(spacingAfter); + return (T) this; + } + + /** + *

setTabStopWidth.

+ * + * @param tabStopWidth a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setTabStopWidth(Integer tabStopWidth) { + getObject().getParagraph().setTabStopWidth(tabStopWidth); + return (T) this; + } + + /** + *

addTabStop.

+ * + * @param position a int. + * @param alignment a {@link software.xdev.dynamicreports.report.constant.TabStopAlignment} object. + * @return a T object. + */ + public T addTabStop(int position, TabStopAlignment alignment) { + Validate.notNull(alignment, "alignment must not be null"); + DRTabStop tabStop = new DRTabStop(); + tabStop.setPosition(position); + tabStop.setAlignment(alignment); + getObject().getParagraph().getTabStops().add(tabStop); + return (T) this; + } + + /** + *

setLinePen.

+ * + * @param linePen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a T object. + */ + public T setLinePen(PenBuilder linePen) { + if (linePen != null) { + getObject().setLinePen(linePen.build()); + } else { + getObject().setLinePen(null); + } + return (T) this; + } + + /** + *

getStyle.

+ * + * @return a U object. + */ + public U getStyle() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/BorderBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/BorderBuilder.java new file mode 100644 index 0000000..e7f4221 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/BorderBuilder.java @@ -0,0 +1,117 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.base.style.DRBorder; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

BorderBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class BorderBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for BorderBuilder.

+ */ + protected BorderBuilder() { + super(new DRBorder()); + } + + /** + *

Constructor for BorderBuilder.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + protected BorderBuilder(PenBuilder pen) { + super(new DRBorder(pen.build())); + } + + /** + *

setTopPen.

+ * + * @param topPen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.BorderBuilder} object. + */ + public BorderBuilder setTopPen(PenBuilder topPen) { + if (topPen != null) { + getObject().setTopPen(topPen.build()); + } else { + getObject().setTopPen(null); + } + return this; + } + + /** + *

setLeftPen.

+ * + * @param leftPen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.BorderBuilder} object. + */ + public BorderBuilder setLeftPen(PenBuilder leftPen) { + if (leftPen != null) { + getObject().setLeftPen(leftPen.build()); + } else { + getObject().setLeftPen(null); + } + return this; + } + + /** + *

setBottomPen.

+ * + * @param bottomPen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.BorderBuilder} object. + */ + public BorderBuilder setBottomPen(PenBuilder bottomPen) { + if (bottomPen != null) { + getObject().setBottomPen(bottomPen.build()); + } else { + getObject().setBottomPen(null); + } + return this; + } + + /** + *

setRightPen.

+ * + * @param rightPen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.BorderBuilder} object. + */ + public BorderBuilder setRightPen(PenBuilder rightPen) { + if (rightPen != null) { + getObject().setRightPen(rightPen.build()); + } else { + getObject().setRightPen(null); + } + return this; + } + + /** + *

getBorder.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRBorder} object. + */ + public DRBorder getBorder() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/ConditionalStyleBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/ConditionalStyleBuilder.java new file mode 100644 index 0000000..20148a8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/ConditionalStyleBuilder.java @@ -0,0 +1,41 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.base.style.DRConditionalStyle; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

ConditionalStyleBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class ConditionalStyleBuilder extends BaseStyleBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for ConditionalStyleBuilder.

+ * + * @param conditionExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected ConditionalStyleBuilder(DRIExpression conditionExpression) { + super(new DRConditionalStyle(conditionExpression)); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/FontBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/FontBuilder.java new file mode 100644 index 0000000..f1dfaee --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/FontBuilder.java @@ -0,0 +1,208 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.base.style.DRFont; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

FontBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class FontBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for FontBuilder.

+ */ + protected FontBuilder() { + super(new DRFont()); + } + + /** + *

Constructor for FontBuilder.

+ * + * @param fontName a {@link java.lang.String} object. + * @param bold a {@link java.lang.Boolean} object. + * @param italic a {@link java.lang.Boolean} object. + * @param fontSize a {@link java.lang.Integer} object. + */ + protected FontBuilder(String fontName, Boolean bold, Boolean italic, Integer fontSize) { + super(new DRFont(fontName, bold, italic, fontSize)); + } + + /** + *

setFontName.

+ * + * @param fontName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder setFontName(String fontName) { + getObject().setFontName(fontName); + return this; + } + + /** + *

setFontSize.

+ * + * @param fontSize a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder setFontSize(Integer fontSize) { + getObject().setFontSize(fontSize); + return this; + } + + /** + *

bold.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder bold() { + return setBold(true); + } + + /** + *

setBold.

+ * + * @param bold a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder setBold(Boolean bold) { + getObject().setBold(bold); + return this; + } + + /** + *

italic.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder italic() { + return setItalic(true); + } + + /** + *

setItalic.

+ * + * @param italic a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder setItalic(Boolean italic) { + getObject().setItalic(italic); + return this; + } + + /** + *

boldItalic.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder boldItalic() { + setBold(true); + return setItalic(true); + } + + @Deprecated + /** + * You should configure the fonts.xml file + * + * @param pdfEmbedded a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder setPdfEmbedded(Boolean pdfEmbedded) { + getObject().setPdfEmbedded(pdfEmbedded); + return this; + } + + @Deprecated + /** + * You should configure the fonts.xml file + * + * @param pdfEncoding a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder setPdfEncoding(String pdfEncoding) { + getObject().setPdfEncoding(pdfEncoding); + return this; + } + + @Deprecated + /** + * You should configure the fonts.xml file + * + * @param pdfFontName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder setPdfFontName(String pdfFontName) { + getObject().setPdfFontName(pdfFontName); + return this; + } + + /** + *

strikeThrough.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder strikeThrough() { + return setStrikeThrough(true); + } + + /** + *

setStrikeThrough.

+ * + * @param strikeThrough a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder setStrikeThrough(Boolean strikeThrough) { + getObject().setStrikeThrough(strikeThrough); + return this; + } + + /** + *

underline.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder underline() { + return setUnderline(true); + } + + /** + *

setUnderline.

+ * + * @param underline a {@link java.lang.Boolean} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder setUnderline(Boolean underline) { + getObject().setUnderline(underline); + return this; + } + + /** + *

getFont.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRFont} object. + */ + public DRFont getFont() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/PaddingBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/PaddingBuilder.java new file mode 100644 index 0000000..9a1d368 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/PaddingBuilder.java @@ -0,0 +1,101 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.base.style.DRPadding; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

PaddingBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class PaddingBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for PaddingBuilder.

+ */ + protected PaddingBuilder() { + super(new DRPadding()); + } + + /** + *

Constructor for PaddingBuilder.

+ * + * @param padding a int. + */ + protected PaddingBuilder(int padding) { + super(new DRPadding(padding)); + } + + /** + *

setTop.

+ * + * @param top a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.PaddingBuilder} object. + */ + public PaddingBuilder setTop(Integer top) { + getObject().setTop(top); + return this; + } + + /** + *

setLeft.

+ * + * @param left a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.PaddingBuilder} object. + */ + public PaddingBuilder setLeft(Integer left) { + getObject().setLeft(left); + return this; + } + + /** + *

setBottom.

+ * + * @param bottom a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.PaddingBuilder} object. + */ + public PaddingBuilder setBottom(Integer bottom) { + getObject().setBottom(bottom); + return this; + } + + /** + *

setRight.

+ * + * @param right a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.PaddingBuilder} object. + */ + public PaddingBuilder setRight(Integer right) { + getObject().setRight(right); + return this; + } + + /** + *

getPadding.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRPadding} object. + */ + public DRPadding getPadding() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/PenBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/PenBuilder.java new file mode 100644 index 0000000..c8ce342 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/PenBuilder.java @@ -0,0 +1,94 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.base.style.DRPen; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.LineStyle; + +import java.awt.Color; + +/** + *

PenBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class PenBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for PenBuilder.

+ */ + protected PenBuilder() { + super(new DRPen()); + } + + /** + *

Constructor for PenBuilder.

+ * + * @param lineWidth a {@link java.lang.Float} object. + * @param lineStyle a {@link software.xdev.dynamicreports.report.constant.LineStyle} object. + */ + protected PenBuilder(Float lineWidth, LineStyle lineStyle) { + super(new DRPen(lineWidth, lineStyle)); + } + + /** + *

setLineWidth.

+ * + * @param lineWidth a {@link java.lang.Float} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public PenBuilder setLineWidth(Float lineWidth) { + getObject().setLineWidth(lineWidth); + return this; + } + + /** + *

setLineStyle.

+ * + * @param lineStyle a {@link software.xdev.dynamicreports.report.constant.LineStyle} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public PenBuilder setLineStyle(LineStyle lineStyle) { + getObject().setLineStyle(lineStyle); + return this; + } + + /** + *

setLineColor.

+ * + * @param lineColor a {@link java.awt.Color} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public PenBuilder setLineColor(Color lineColor) { + getObject().setLineColor(lineColor); + return this; + } + + /** + *

getPen.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRPen} object. + */ + public DRPen getPen() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/ReportStyleBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/ReportStyleBuilder.java new file mode 100644 index 0000000..ff99204 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/ReportStyleBuilder.java @@ -0,0 +1,45 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +import java.io.Serializable; + +/** + *

ReportStyleBuilder interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface ReportStyleBuilder extends Serializable { + + /** + *

getStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getStyle(); + + /** + *

build.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle build(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/SimpleStyleBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/SimpleStyleBuilder.java new file mode 100644 index 0000000..051b101 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/SimpleStyleBuilder.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.base.style.DRSimpleStyle; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

SimpleStyleBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class SimpleStyleBuilder extends BaseStyleBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for SimpleStyleBuilder.

+ */ + protected SimpleStyleBuilder() { + super(new DRSimpleStyle()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/StyleBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/StyleBuilder.java new file mode 100644 index 0000000..2480e67 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/StyleBuilder.java @@ -0,0 +1,99 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.base.style.DRStyle; +import software.xdev.dynamicreports.report.constant.Constants; +import org.apache.commons.lang3.Validate; + +/** + *

StyleBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class StyleBuilder extends BaseStyleBuilder implements ReportStyleBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for StyleBuilder.

+ */ + protected StyleBuilder() { + this(new DRStyle()); + } + + /** + *

Constructor for StyleBuilder.

+ * + * @param style a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + protected StyleBuilder(DRStyle style) { + super(style); + } + + /** + *

conditionalStyles.

+ * + * @param conditionalStyles a {@link software.xdev.dynamicreports.report.builder.style.ConditionalStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public StyleBuilder conditionalStyles(ConditionalStyleBuilder... conditionalStyles) { + return addConditionalStyle(conditionalStyles); + } + + /** + *

addConditionalStyle.

+ * + * @param conditionalStyles a {@link software.xdev.dynamicreports.report.builder.style.ConditionalStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public StyleBuilder addConditionalStyle(ConditionalStyleBuilder... conditionalStyles) { + Validate.notNull(conditionalStyles, "conditionalStyles must not be null"); + Validate.noNullElements(conditionalStyles, "conditionalStyles must not contains null conditionalStyle"); + for (ConditionalStyleBuilder conditionalStyle : conditionalStyles) { + getObject().addConditionalStyle(conditionalStyle.build()); + } + return this; + } + + /** + *

setName.

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public StyleBuilder setName(String name) { + getObject().setName(name); + return this; + } + + /** + *

setParentStyle.

+ * + * @param parentStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public StyleBuilder setParentStyle(ReportStyleBuilder parentStyle) { + if (parentStyle != null) { + getObject().setParentStyle(parentStyle.build()); + } else { + getObject().setParentStyle(null); + } + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/StyleBuilders.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/StyleBuilders.java new file mode 100644 index 0000000..380f9d7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/StyleBuilders.java @@ -0,0 +1,361 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.constant.LineStyle; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.io.File; +import java.io.InputStream; +import java.net.URL; + +/** + * A set of methods of creating and customizing styles + * + * @author Ricardo Mariaca + * + */ +public class StyleBuilders { + + // font + + /** + *

font.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder font() { + return Styles.font(); + } + + /** + *

font.

+ * + * @param fontName a {@link java.lang.String} object. + * @param bold a boolean. + * @param italic a boolean. + * @param fontSize a int. + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder font(String fontName, boolean bold, boolean italic, int fontSize) { + return Styles.font(fontName, bold, italic, fontSize); + } + + /** + *

fontArial.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder fontArial() { + return Styles.fontArial(); + } + + /** + *

fontArialBold.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder fontArialBold() { + return Styles.fontArialBold(); + } + + /** + *

fontTimesNewRoman.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder fontTimesNewRoman() { + return Styles.fontTimesNewRoman(); + } + + /** + *

fontTimesNewRomanBold.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder fontTimesNewRomanBold() { + return Styles.fontTimesNewRomanBold(); + } + + /** + *

fontCourierNew.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder fontCourierNew() { + return Styles.fontCourierNew(); + } + + /** + *

fontCourierNewBold.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public FontBuilder fontCourierNewBold() { + return Styles.fontCourierNewBold(); + } + + // pen + + /** + *

pen.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public PenBuilder pen() { + return Styles.pen(); + } + + /** + *

pen.

+ * + * @param lineWidth a {@link java.lang.Float} object. + * @param lineStyle a {@link software.xdev.dynamicreports.report.constant.LineStyle} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public PenBuilder pen(Float lineWidth, LineStyle lineStyle) { + return Styles.pen(lineWidth, lineStyle); + } + + /** + *

penThin.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public PenBuilder penThin() { + return Styles.penThin(); + } + + /** + *

pen1Point.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public PenBuilder pen1Point() { + return Styles.pen1Point(); + } + + /** + *

pen2Point.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public PenBuilder pen2Point() { + return Styles.pen2Point(); + } + + /** + *

penDotted.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public PenBuilder penDotted() { + return Styles.penDotted(); + } + + /** + *

penDashed.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public PenBuilder penDashed() { + return Styles.penDashed(); + } + + /** + *

penDouble.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public PenBuilder penDouble() { + return Styles.penDouble(); + } + + // border + + /** + *

border.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.BorderBuilder} object. + */ + public BorderBuilder border() { + return Styles.border(); + } + + /** + *

border.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.BorderBuilder} object. + */ + public BorderBuilder border(PenBuilder pen) { + return Styles.border(pen); + } + + // padding + + /** + *

padding.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PaddingBuilder} object. + */ + public PaddingBuilder padding() { + return Styles.padding(); + } + + /** + *

padding.

+ * + * @param padding a int. + * @return a {@link software.xdev.dynamicreports.report.builder.style.PaddingBuilder} object. + */ + public PaddingBuilder padding(int padding) { + return Styles.padding(padding); + } + + // style + + /** + *

style.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public StyleBuilder style() { + return Styles.style(); + } + + /** + *

style.

+ * + * @param parentStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public StyleBuilder style(ReportStyleBuilder parentStyle) { + return Styles.style(parentStyle); + } + + /** + *

style.

+ * + * @param font a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public StyleBuilder style(FontBuilder font) { + return Styles.style(font); + } + + /** + *

style.

+ * + * @param borderPen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public StyleBuilder style(PenBuilder borderPen) { + return Styles.style(borderPen); + } + + /** + *

style.

+ * + * @param padding a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public StyleBuilder style(Integer padding) { + return Styles.style(padding); + } + + /** + *

simpleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.SimpleStyleBuilder} object. + */ + public SimpleStyleBuilder simpleStyle() { + return Styles.simpleStyle(); + } + + /** + *

templateStyle.

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStyleBuilder} object. + */ + public TemplateStyleBuilder templateStyle(String name) { + return Styles.templateStyle(name); + } + + /** + *

conditionalStyle.

+ * + * @param conditionExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.ConditionalStyleBuilder} object. + */ + public ConditionalStyleBuilder conditionalStyle(DRIExpression conditionExpression) { + return Styles.conditionalStyle(conditionExpression); + } + + /** + *

templateStyles.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public TemplateStylesBuilder templateStyles() { + return Styles.templateStyles(); + } + + /** + *

loadStyles.

+ * + * @param inputStream a {@link java.io.InputStream} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public TemplateStylesBuilder loadStyles(InputStream inputStream) { + return Styles.loadStyles(inputStream); + } + + /** + *

loadStyles.

+ * + * @param file a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public TemplateStylesBuilder loadStyles(File file) { + return Styles.loadStyles(file); + } + + /** + *

loadStyles.

+ * + * @param fileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public TemplateStylesBuilder loadStyles(String fileName) throws DRException { + return Styles.loadStyles(fileName); + } + + /** + *

loadStyles.

+ * + * @param url a {@link java.net.URL} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public TemplateStylesBuilder loadStyles(URL url) { + return Styles.loadStyles(url); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/Styles.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/Styles.java new file mode 100644 index 0000000..dc2564e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/Styles.java @@ -0,0 +1,364 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.constant.FontName; +import software.xdev.dynamicreports.report.constant.LineStyle; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.exception.DRException; +import org.apache.commons.lang3.Validate; + +import java.io.File; +import java.io.InputStream; +import java.net.URL; + +/** + * A set of methods of creating and customizing styles + * + * @author Ricardo Mariaca + * + */ +public class Styles { + + // font + + /** + *

font.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public static FontBuilder font() { + return new FontBuilder(); + } + + /** + *

font.

+ * + * @param fontName a {@link java.lang.String} object. + * @param bold a boolean. + * @param italic a boolean. + * @param fontSize a int. + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public static FontBuilder font(String fontName, boolean bold, boolean italic, int fontSize) { + return new FontBuilder(fontName, bold, italic, fontSize); + } + + /** + *

fontArial.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public static FontBuilder fontArial() { + return new FontBuilder(FontName.ARIAL, false, false, 10); + } + + /** + *

fontArialBold.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public static FontBuilder fontArialBold() { + return new FontBuilder(FontName.ARIAL, true, false, 10); + } + + /** + *

fontTimesNewRoman.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public static FontBuilder fontTimesNewRoman() { + return new FontBuilder(FontName.TIMES_NEW_ROMAN, false, false, 10); + } + + /** + *

fontTimesNewRomanBold.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public static FontBuilder fontTimesNewRomanBold() { + return new FontBuilder(FontName.TIMES_NEW_ROMAN, true, false, 10); + } + + /** + *

fontCourierNew.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public static FontBuilder fontCourierNew() { + return new FontBuilder(FontName.COURIER_NEW, false, false, 10); + } + + /** + *

fontCourierNewBold.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + */ + public static FontBuilder fontCourierNewBold() { + return new FontBuilder(FontName.COURIER_NEW, true, false, 10); + } + + // pen + + /** + *

pen.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public static PenBuilder pen() { + return new PenBuilder(); + } + + /** + *

pen.

+ * + * @param lineWidth a {@link java.lang.Float} object. + * @param lineStyle a {@link software.xdev.dynamicreports.report.constant.LineStyle} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public static PenBuilder pen(Float lineWidth, LineStyle lineStyle) { + return new PenBuilder(lineWidth, lineStyle); + } + + /** + *

penThin.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public static PenBuilder penThin() { + return new PenBuilder(0.5f, LineStyle.SOLID); + } + + /** + *

pen1Point.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public static PenBuilder pen1Point() { + return new PenBuilder(1f, LineStyle.SOLID); + } + + /** + *

pen2Point.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public static PenBuilder pen2Point() { + return new PenBuilder(2f, LineStyle.SOLID); + } + + /** + *

penDotted.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public static PenBuilder penDotted() { + return new PenBuilder(1f, LineStyle.DOTTED); + } + + /** + *

penDashed.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public static PenBuilder penDashed() { + return new PenBuilder(1f, LineStyle.DASHED); + } + + /** + *

penDouble.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + */ + public static PenBuilder penDouble() { + return new PenBuilder(1f, LineStyle.DOUBLE); + } + + // border + + /** + *

border.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.BorderBuilder} object. + */ + public static BorderBuilder border() { + return new BorderBuilder(); + } + + /** + *

border.

+ * + * @param pen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.BorderBuilder} object. + */ + public static BorderBuilder border(PenBuilder pen) { + Validate.notNull(pen, "pen must not be null"); + return new BorderBuilder(pen); + } + + // padding + + /** + *

padding.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.PaddingBuilder} object. + */ + public static PaddingBuilder padding() { + return new PaddingBuilder(); + } + + /** + *

padding.

+ * + * @param padding a int. + * @return a {@link software.xdev.dynamicreports.report.builder.style.PaddingBuilder} object. + */ + public static PaddingBuilder padding(int padding) { + return new PaddingBuilder(padding); + } + + // style + + /** + *

style.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public static StyleBuilder style() { + return new StyleBuilder(); + } + + /** + *

style.

+ * + * @param parentStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public static StyleBuilder style(ReportStyleBuilder parentStyle) { + return new StyleBuilder().setParentStyle(parentStyle); + } + + /** + *

style.

+ * + * @param font a {@link software.xdev.dynamicreports.report.builder.style.FontBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public static StyleBuilder style(FontBuilder font) { + return new StyleBuilder().setFont(font); + } + + /** + *

style.

+ * + * @param borderPen a {@link software.xdev.dynamicreports.report.builder.style.PenBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public static StyleBuilder style(PenBuilder borderPen) { + return new StyleBuilder().setBorder(borderPen); + } + + /** + *

style.

+ * + * @param padding a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public static StyleBuilder style(Integer padding) { + return new StyleBuilder().setPadding(padding); + } + + /** + *

simpleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.SimpleStyleBuilder} object. + */ + public static SimpleStyleBuilder simpleStyle() { + return new SimpleStyleBuilder(); + } + + /** + *

templateStyle.

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStyleBuilder} object. + */ + public static TemplateStyleBuilder templateStyle(String name) { + return new TemplateStyleBuilder(name); + } + + /** + *

conditionalStyle.

+ * + * @param conditionExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.ConditionalStyleBuilder} object. + */ + public static ConditionalStyleBuilder conditionalStyle(DRIExpression conditionExpression) { + return new ConditionalStyleBuilder(conditionExpression); + } + + /** + *

templateStyles.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public static TemplateStylesBuilder templateStyles() { + return new TemplateStylesBuilder(); + } + + /** + *

loadStyles.

+ * + * @param inputStream a {@link java.io.InputStream} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public static TemplateStylesBuilder loadStyles(InputStream inputStream) { + return new TemplateStylesBuilder().loadStyles(inputStream); + } + + /** + *

loadStyles.

+ * + * @param file a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public static TemplateStylesBuilder loadStyles(File file) { + return new TemplateStylesBuilder().loadStyles(file); + } + + /** + *

loadStyles.

+ * + * @param fileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public static TemplateStylesBuilder loadStyles(String fileName) throws DRException { + return new TemplateStylesBuilder().loadStyles(fileName); + } + + /** + *

loadStyles.

+ * + * @param url a {@link java.net.URL} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public static TemplateStylesBuilder loadStyles(URL url) { + return new TemplateStylesBuilder().loadStyles(url); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/TemplateStyleBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/TemplateStyleBuilder.java new file mode 100644 index 0000000..8ea8799 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/TemplateStyleBuilder.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.report.base.style.DRTemplateStyle; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

TemplateStyleBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class TemplateStyleBuilder extends AbstractBuilder implements ReportStyleBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for TemplateStyleBuilder.

+ * + * @param name a {@link java.lang.String} object. + */ + protected TemplateStyleBuilder(String name) { + super(new DRTemplateStyle(name)); + } + + /** {@inheritDoc} */ + @Override + public DRTemplateStyle getStyle() { + return build(); + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/TemplateStylesBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/TemplateStylesBuilder.java new file mode 100644 index 0000000..909da42 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/style/TemplateStylesBuilder.java @@ -0,0 +1,146 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.style; + +import software.xdev.dynamicreports.jasper.base.JasperTemplateStyleLoader; +import software.xdev.dynamicreports.report.base.style.DRStyle; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.exception.DRException; +import org.apache.commons.lang3.Validate; + +import java.io.File; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/** + *

TemplateStylesBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class TemplateStylesBuilder extends AbstractBuilder> { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for TemplateStylesBuilder.

+ */ + protected TemplateStylesBuilder() { + super(new ArrayList()); + } + + /** + *

loadStyles.

+ * + * @param inputStream a {@link java.io.InputStream} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public TemplateStylesBuilder loadStyles(InputStream inputStream) { + return addStyles(JasperTemplateStyleLoader.loadStyles(inputStream)); + } + + /** + *

loadStyles.

+ * + * @param file a {@link java.io.File} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public TemplateStylesBuilder loadStyles(File file) { + return addStyles(JasperTemplateStyleLoader.loadStyles(file)); + } + + /** + *

loadStyles.

+ * + * @param fileName a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public TemplateStylesBuilder loadStyles(String fileName) throws DRException { + return addStyles(JasperTemplateStyleLoader.loadStyles(fileName)); + } + + /** + *

loadStyles.

+ * + * @param url a {@link java.net.URL} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public TemplateStylesBuilder loadStyles(URL url) { + return addStyles(JasperTemplateStyleLoader.loadStyles(url)); + } + + private TemplateStylesBuilder addStyles(DRStyle[] styles) { + for (DRStyle style : styles) { + this.getObject().add(new StyleBuilder(style)); + } + return this; + } + + /** + *

styles.

+ * + * @param styles a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public TemplateStylesBuilder styles(StyleBuilder... styles) { + return addStyle(styles); + } + + /** + *

addStyle.

+ * + * @param styles a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.TemplateStylesBuilder} object. + */ + public TemplateStylesBuilder addStyle(StyleBuilder... styles) { + Validate.notNull(styles, "styles must not be null"); + Validate.noNullElements(styles, "styles must not contains null style"); + for (StyleBuilder templateStyle : styles) { + getObject().add(templateStyle); + } + return this; + } + + /** + *

getStyle.

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.style.StyleBuilder} object. + */ + public StyleBuilder getStyle(String name) { + Validate.notNull(name, "name must not be null"); + for (StyleBuilder style : getStyles()) { + if (name.equals(style.getStyle().getName())) { + return style; + } + } + return null; + } + + /** + *

getStyles.

+ * + * @return a {@link java.util.List} object. + */ + public List getStyles() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/AggregationSubtotalBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/AggregationSubtotalBuilder.java new file mode 100644 index 0000000..f892f78 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/AggregationSubtotalBuilder.java @@ -0,0 +1,140 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.subtotal; + +import software.xdev.dynamicreports.report.base.DRVariable; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.builder.datatype.DataTypes; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.constant.SubtotalPosition; +import software.xdev.dynamicreports.report.definition.DRIField; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.column.DRIValueColumn; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.exception.DRReportException; + +/** + *

AggregationSubtotalBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class AggregationSubtotalBuilder extends SubtotalBuilder, T> implements DRIValue { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression expression; + private Calculation calculation; + + // column + + /** + *

Constructor for AggregationSubtotalBuilder.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected AggregationSubtotalBuilder(ValueColumnBuilder column, Calculation calculation) { + this(column.getColumn(), column, calculation); + } + + // field + + /** + *

Constructor for AggregationSubtotalBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param showInColumn a {@link software.xdev.dynamicreports.report.builder.column.ColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected AggregationSubtotalBuilder(FieldBuilder field, ColumnBuilder showInColumn, Calculation calculation) { + this(field.build(), showInColumn, calculation); + } + + // expression + + /** + *

Constructor for AggregationSubtotalBuilder.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param showInColumn a {@link software.xdev.dynamicreports.report.builder.column.ColumnBuilder} object. + * @param calculation a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + protected AggregationSubtotalBuilder(DRIExpression expression, ColumnBuilder showInColumn, Calculation calculation) { + super(showInColumn); + this.expression = expression; + this.calculation = calculation; + if (calculation.equals(Calculation.COUNT) || calculation.equals(Calculation.DISTINCT_COUNT)) { + setDataType(DataTypes.longType()); + } else if (calculation.equals(Calculation.AVERAGE) || calculation.equals(Calculation.STANDARD_DEVIATION) || calculation.equals(Calculation.VARIANCE)) { + setDataType(DataTypes.doubleType()); + } else if (expression instanceof DRIValueColumn) { + setDataType(((DRIValueColumn) expression).getComponent().getDataType()); + setPattern(((DRIValueColumn) expression).getComponent().getPattern()); + } else if (expression instanceof DRIField) { + setDataType(((DRIField) expression).getDataType()); + } + } + + private static Evaluation subtotalPositionToEvaluation(SubtotalPosition position) { + switch (position) { + case PAGE_HEADER: + case PAGE_FOOTER: + return Evaluation.PAGE; + case COLUMN_HEADER: + case COLUMN_FOOTER: + return Evaluation.COLUMN; + case GROUP_HEADER: + case GROUP_FOOTER: + return Evaluation.GROUP; + case FIRST_GROUP_HEADER: + case FIRST_GROUP_FOOTER: + return Evaluation.FIRST_GROUP; + case LAST_GROUP_HEADER: + case LAST_GROUP_FOOTER: + return Evaluation.LAST_GROUP; + case TITLE: + case LAST_PAGE_FOOTER: + case SUMMARY: + return Evaluation.REPORT; + default: + throw new DRReportException("Subtotal position " + position.name() + " not supported"); + } + } + + /** {@inheritDoc} */ + @Override + protected void configure() { + DRVariable subtotalVariable = new DRVariable(expression, calculation); + Evaluation resetType = subtotalPositionToEvaluation(getObject().getPosition()); + subtotalVariable.setResetType(resetType); + subtotalVariable.setResetGroup(getObject().getGroup()); + setValueExpression(subtotalVariable); + + super.configure(); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return getSubtotal().getName(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/BaseSubtotalBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/BaseSubtotalBuilder.java new file mode 100644 index 0000000..de53f26 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/BaseSubtotalBuilder.java @@ -0,0 +1,397 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.subtotal; + +import software.xdev.dynamicreports.report.base.DRSubtotal; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.builder.HyperLinkBuilder; +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.Position; +import software.xdev.dynamicreports.report.constant.SubtotalPosition; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import org.apache.commons.lang3.Validate; + +/** + *

Abstract BaseSubtotalBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +@SuppressWarnings("unchecked") +public abstract class BaseSubtotalBuilder, U> extends AbstractBuilder> { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression valueExpression; + + /** + *

Constructor for BaseSubtotalBuilder.

+ * + * @param showInColumn a {@link software.xdev.dynamicreports.report.builder.column.ColumnBuilder} object. + */ + protected BaseSubtotalBuilder(ColumnBuilder showInColumn) { + super(new DRSubtotal(showInColumn.build())); + } + + /** + *

Setter for the field valueExpression.

+ * + * @param valueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + protected void setValueExpression(DRIExpression valueExpression) { + this.valueExpression = valueExpression; + } + + /** + *

setShowInColumn.

+ * + * @param showInColumn a {@link software.xdev.dynamicreports.report.builder.column.ColumnBuilder} object. + * @return a T object. + */ + public T setShowInColumn(ColumnBuilder showInColumn) { + Validate.notNull(showInColumn, "showInColumn must not be null"); + getObject().setShowInColumn(showInColumn.build()); + return (T) this; + } + + /** + *

setLabel.

+ * + * @param labelExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setLabel(DRIExpression labelExpression) { + getObject().setLabelExpression(labelExpression); + return (T) this; + } + + /** + *

setLabel.

+ * + * @param label a {@link java.lang.String} object. + * @return a T object. + */ + public T setLabel(String label) { + getObject().setLabelExpression(Expressions.text(label)); + return (T) this; + } + + /** + *

setLabelStyle.

+ * + * @param labelStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a T object. + */ + public T setLabelStyle(ReportStyleBuilder labelStyle) { + if (labelStyle != null) { + getObject().setLabelStyle(labelStyle.getStyle()); + } else { + getObject().setLabelStyle(null); + } + return (T) this; + } + + /** + *

setLabelPosition.

+ * + * @param labelPosition a {@link software.xdev.dynamicreports.report.constant.Position} object. + * @return a T object. + */ + public T setLabelPosition(Position labelPosition) { + getObject().setLabelPosition(labelPosition); + return (T) this; + } + + /** + * Sets the label component preferred width. + * + * @param width the label component preferred width >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setLabelWidth(Integer width) { + getObject().setLabelWidth(width); + return (T) this; + } + + /** + * Sets the label component fixed width. + * + * @param width the label component fixed width >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setLabelFixedWidth(Integer width) { + getObject().setLabelWidth(width); + getObject().setLabelWidthType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + * Sets the label component minimum width. + * + * @param width the label component minimum width >= 0 + * @return a T object. + * @throws java.lang.IllegalArgumentException if width is < 0 + * @see software.xdev.dynamicreports.report.builder.Units + */ + public T setLabelMinWidth(Integer width) { + getObject().setLabelWidth(width); + getObject().setLabelWidthType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + *

setPattern.

+ * + * @param pattern a {@link java.lang.String} object. + * @return a T object. + */ + public T setPattern(String pattern) { + getObject().getValueField().setPattern(pattern); + return (T) this; + } + + /** + *

setPattern.

+ * + * @param patternExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setPattern(DRIExpression patternExpression) { + getObject().getValueField().setPatternExpression(patternExpression); + return (T) this; + } + + /** + *

setValueFormatter.

+ * + * @param valueFormatter a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + * @return a T object. + */ + public T setValueFormatter(DRIValueFormatter valueFormatter) { + getObject().getValueField().setValueFormatter(valueFormatter); + return (T) this; + } + + /** + *

setDataType.

+ * + * @param dataType a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + * @return a T object. + */ + @SuppressWarnings("rawtypes") + public T setDataType(DRIDataType dataType) { + getObject().getValueField().setDataType(dataType); + return (T) this; + } + + /** + *

setAnchorName.

+ * + * @param anchorName a {@link java.lang.String} object. + * @return a T object. + */ + public T setAnchorName(String anchorName) { + getObject().getValueField().setAnchorNameExpression(Expressions.text(anchorName)); + return (T) this; + } + + /** + *

setAnchorName.

+ * + * @param anchorNameExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setAnchorName(DRIExpression anchorNameExpression) { + getObject().getValueField().setAnchorNameExpression(anchorNameExpression); + return (T) this; + } + + /** + *

setBookmarkLevel.

+ * + * @param bookmarkLevel a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setBookmarkLevel(Integer bookmarkLevel) { + getObject().getValueField().setBookmarkLevel(bookmarkLevel); + return (T) this; + } + + /** + *

setHyperLink.

+ * + * @param hyperLink a {@link software.xdev.dynamicreports.report.builder.HyperLinkBuilder} object. + * @return a T object. + */ + public T setHyperLink(HyperLinkBuilder hyperLink) { + if (hyperLink != null) { + getObject().getValueField().setHyperLink(hyperLink.getHyperLink()); + } else { + getObject().getValueField().setHyperLink(null); + } + return (T) this; + } + + /** + *

setRows.

+ * + * @param rows a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setRows(Integer rows) { + getObject().getValueField().setRows(rows); + return (T) this; + } + + /** + *

setFixedRows.

+ * + * @param rows a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setFixedRows(Integer rows) { + getObject().getValueField().setRows(rows); + getObject().getValueField().setHeightType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + *

setMinRows.

+ * + * @param rows a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setMinRows(Integer rows) { + getObject().getValueField().setRows(rows); + getObject().getValueField().setHeightType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + *

setHeight.

+ * + * @param height a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setHeight(Integer height) { + getObject().getValueField().setHeight(height); + return (T) this; + } + + /** + *

setFixedHeight.

+ * + * @param height a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setFixedHeight(Integer height) { + getObject().getValueField().setHeight(height); + getObject().getValueField().setHeightType(ComponentDimensionType.FIXED); + return (T) this; + } + + /** + *

setMinHeight.

+ * + * @param height a {@link java.lang.Integer} object. + * @return a T object. + */ + public T setMinHeight(Integer height) { + getObject().getValueField().setHeight(height); + getObject().getValueField().setHeightType(ComponentDimensionType.EXPAND); + return (T) this; + } + + /** + *

setStyle.

+ * + * @param style a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a T object. + */ + public T setStyle(ReportStyleBuilder style) { + if (style != null) { + getObject().getValueField().setStyle(style.getStyle()); + } else { + getObject().getValueField().setStyle(null); + } + return (T) this; + } + + /** + *

setPrintWhenExpression.

+ * + * @param printWhenExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a T object. + */ + public T setPrintWhenExpression(DRIExpression printWhenExpression) { + getObject().getValueField().setPrintWhenExpression(printWhenExpression); + return (T) this; + } + + /** + *

setGroup.

+ * + * @param group a {@link software.xdev.dynamicreports.report.builder.group.GroupBuilder} object. + * @return a T object. + */ + public T setGroup(GroupBuilder group) { + if (group != null) { + getObject().setGroup(group.getGroup()); + } else { + getObject().setGroup(null); + } + return (T) this; + } + + /** + *

setPosition.

+ * + * @param position a {@link software.xdev.dynamicreports.report.constant.SubtotalPosition} object. + * @return a T object. + */ + public T setPosition(SubtotalPosition position) { + getObject().setPosition(position); + return (T) this; + } + + /** {@inheritDoc} */ + @Override + protected void configure() { + super.configure(); + getObject().getValueField().setValueExpression(valueExpression); + } + + /** + *

getSubtotal.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRSubtotal} object. + */ + public DRSubtotal getSubtotal() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/CustomSubtotalBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/CustomSubtotalBuilder.java new file mode 100644 index 0000000..7593a3c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/CustomSubtotalBuilder.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.subtotal; + +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

CustomSubtotalBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class CustomSubtotalBuilder extends SubtotalBuilder, T> implements DRIValue { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for CustomSubtotalBuilder.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param showInColumn a {@link software.xdev.dynamicreports.report.builder.column.ColumnBuilder} object. + */ + protected CustomSubtotalBuilder(DRIExpression expression, ColumnBuilder showInColumn) { + super(showInColumn); + setValueExpression(expression); + } + + /** {@inheritDoc} */ + @Override + public String getName() { + return getSubtotal().getName(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/PercentageSubtotalBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/PercentageSubtotalBuilder.java new file mode 100644 index 0000000..9efa80b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/PercentageSubtotalBuilder.java @@ -0,0 +1,150 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.subtotal; + +import software.xdev.dynamicreports.report.base.DRGroup; +import software.xdev.dynamicreports.report.base.DRVariable; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.builder.datatype.DataTypes; +import software.xdev.dynamicreports.report.builder.expression.PercentageExpression; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.constant.PercentageTotalType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.exception.DRReportException; + +/** + *

PercentageSubtotalBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class PercentageSubtotalBuilder extends BaseSubtotalBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private DRIExpression expression; + private PercentageTotalType totalType; + private DRGroup totalGroup; + + // column + + /** + *

Constructor for PercentageSubtotalBuilder.

+ * + * @param column a {@link software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder} object. + */ + protected PercentageSubtotalBuilder(ValueColumnBuilder column) { + this(column.build(), column); + } + + // field + + /** + *

Constructor for PercentageSubtotalBuilder.

+ * + * @param field a {@link software.xdev.dynamicreports.report.builder.FieldBuilder} object. + * @param showInColumn a {@link software.xdev.dynamicreports.report.builder.column.ColumnBuilder} object. + */ + protected PercentageSubtotalBuilder(FieldBuilder field, ColumnBuilder showInColumn) { + this(field.getField(), showInColumn); + } + + // expression + + /** + *

Constructor for PercentageSubtotalBuilder.

+ * + * @param expression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @param showInColumn a {@link software.xdev.dynamicreports.report.builder.column.ColumnBuilder} object. + */ + protected PercentageSubtotalBuilder(DRIExpression expression, ColumnBuilder showInColumn) { + super(showInColumn); + this.expression = expression; + } + + /** + *

Setter for the field totalType.

+ * + * @param totalType a {@link software.xdev.dynamicreports.report.constant.PercentageTotalType} object. + * @return a {@link software.xdev.dynamicreports.report.builder.subtotal.PercentageSubtotalBuilder} object. + */ + public PercentageSubtotalBuilder setTotalType(PercentageTotalType totalType) { + this.totalType = totalType; + return this; + } + + /** + *

Setter for the field totalGroup.

+ * + * @param totalGroup a {@link software.xdev.dynamicreports.report.builder.group.GroupBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.subtotal.PercentageSubtotalBuilder} object. + */ + public PercentageSubtotalBuilder setTotalGroup(GroupBuilder totalGroup) { + if (totalGroup != null) { + this.totalGroup = totalGroup.getGroup(); + setTotalType(PercentageTotalType.GROUP); + } else { + this.totalGroup = null; + } + return this; + } + + /** {@inheritDoc} */ + @Override + protected void configure() { + if (getObject().getValueField().getDataType() == null) { + getObject().getValueField().setDataType(DataTypes.percentageType()); + } + + DRVariable actualExpression = new DRVariable(expression, Calculation.SUM); + actualExpression.setResetType(Evaluation.GROUP); + actualExpression.setResetGroup(getObject().getGroup()); + + DRVariable totalExpression = new DRVariable(expression, Calculation.SUM); + if (totalType != null) { + switch (totalType) { + case REPORT: + totalExpression.setResetType(Evaluation.REPORT); + break; + case GROUP: + totalExpression.setResetType(Evaluation.GROUP); + break; + case FIRST_GROUP: + totalExpression.setResetType(Evaluation.FIRST_GROUP); + break; + case LAST_GROUP: + totalExpression.setResetType(Evaluation.LAST_GROUP); + break; + default: + throw new DRReportException("Percentage total type " + totalType.name() + " not supported."); + } + } else { + totalExpression.setResetType(Evaluation.BEFORE_GROUP); + totalGroup = getObject().getGroup(); + } + totalExpression.setResetGroup(totalGroup); + + setValueExpression(new PercentageExpression(actualExpression, totalExpression)); + + super.configure(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/SubtotalBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/SubtotalBuilder.java new file mode 100644 index 0000000..d327c8e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/SubtotalBuilder.java @@ -0,0 +1,40 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.subtotal; + +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

Abstract SubtotalBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public abstract class SubtotalBuilder, U> extends BaseSubtotalBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for SubtotalBuilder.

+ * + * @param showInColumn a {@link software.xdev.dynamicreports.report.builder.column.ColumnBuilder} object. + */ + protected SubtotalBuilder(ColumnBuilder showInColumn) { + super(showInColumn); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/SubtotalBuilders.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/SubtotalBuilders.java new file mode 100644 index 0000000..5b09969 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/SubtotalBuilders.java @@ -0,0 +1,230 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.subtotal; + +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + * A set of methods of creating column subtotals + * + * @author Ricardo Mariaca + * + */ +public class SubtotalBuilders { + + // calculation + public AggregationSubtotalBuilder aggregate(ValueColumnBuilder subtotalColumn, Calculation calculation) { + return Subtotals.aggregate(subtotalColumn, calculation); + } + + public AggregationSubtotalBuilder aggregate(String fieldName, Class valueClass, ColumnBuilder showInColumn, Calculation calculation) { + return Subtotals.aggregate(fieldName, valueClass, showInColumn, calculation); + } + + public AggregationSubtotalBuilder aggregate(FieldBuilder field, ColumnBuilder showInColumn, Calculation calculation) { + return Subtotals.aggregate(field, showInColumn, calculation); + } + + public AggregationSubtotalBuilder aggregate(DRIExpression expression, ColumnBuilder showInColumn, Calculation calculation) { + return Subtotals.aggregate(expression, showInColumn, calculation); + } + + // sum + public AggregationSubtotalBuilder sum(ValueColumnBuilder subtotalColumn) { + return Subtotals.sum(subtotalColumn); + } + + public AggregationSubtotalBuilder sum(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return Subtotals.sum(fieldName, valueClass, showInColumn); + } + + public AggregationSubtotalBuilder sum(FieldBuilder field, ColumnBuilder showInColumn) { + return Subtotals.sum(field, showInColumn); + } + + public AggregationSubtotalBuilder sum(DRIExpression expression, ColumnBuilder showInColumn) { + return Subtotals.sum(expression, showInColumn); + } + + // average + public AggregationSubtotalBuilder avg(ValueColumnBuilder subtotalColumn) { + return Subtotals.avg(subtotalColumn); + } + + public AggregationSubtotalBuilder avg(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return Subtotals.avg(fieldName, valueClass, showInColumn); + } + + public AggregationSubtotalBuilder avg(FieldBuilder field, ColumnBuilder showInColumn) { + return Subtotals.avg(field, showInColumn); + } + + public AggregationSubtotalBuilder avg(DRIExpression expression, ColumnBuilder showInColumn) { + return Subtotals.avg(expression, showInColumn); + } + + // count + public AggregationSubtotalBuilder count(ValueColumnBuilder subtotalColumn) { + return Subtotals.count(subtotalColumn); + } + + public AggregationSubtotalBuilder count(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return Subtotals.count(fieldName, valueClass, showInColumn); + } + + public AggregationSubtotalBuilder count(FieldBuilder field, ColumnBuilder showInColumn) { + return Subtotals.count(field, showInColumn); + } + + public AggregationSubtotalBuilder count(DRIExpression expression, ColumnBuilder showInColumn) { + return Subtotals.count(expression, showInColumn); + } + + // distinct count + public AggregationSubtotalBuilder distinctCount(ValueColumnBuilder subtotalColumn) { + return Subtotals.distinctCount(subtotalColumn); + } + + public AggregationSubtotalBuilder distinctCount(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return Subtotals.distinctCount(fieldName, valueClass, showInColumn); + } + + public AggregationSubtotalBuilder distinctCount(FieldBuilder field, ColumnBuilder showInColumn) { + return Subtotals.distinctCount(field, showInColumn); + } + + public AggregationSubtotalBuilder distinctCount(DRIExpression expression, ColumnBuilder showInColumn) { + return Subtotals.distinctCount(expression, showInColumn); + } + + // first + public AggregationSubtotalBuilder first(ValueColumnBuilder subtotalColumn) { + return Subtotals.first(subtotalColumn); + } + + public AggregationSubtotalBuilder first(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return Subtotals.first(fieldName, valueClass, showInColumn); + } + + public AggregationSubtotalBuilder first(FieldBuilder field, ColumnBuilder showInColumn) { + return Subtotals.first(field, showInColumn); + } + + public AggregationSubtotalBuilder first(DRIExpression expression, ColumnBuilder showInColumn) { + return Subtotals.first(expression, showInColumn); + } + + // highest + public AggregationSubtotalBuilder max(ValueColumnBuilder subtotalColumn) { + return Subtotals.max(subtotalColumn); + } + + public AggregationSubtotalBuilder max(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return Subtotals.max(fieldName, valueClass, showInColumn); + } + + public AggregationSubtotalBuilder max(FieldBuilder field, ColumnBuilder showInColumn) { + return Subtotals.max(field, showInColumn); + } + + public AggregationSubtotalBuilder max(DRIExpression expression, ColumnBuilder showInColumn) { + return Subtotals.max(expression, showInColumn); + } + + // lowest + public AggregationSubtotalBuilder min(ValueColumnBuilder subtotalColumn) { + return Subtotals.min(subtotalColumn); + } + + public AggregationSubtotalBuilder min(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return Subtotals.min(fieldName, valueClass, showInColumn); + } + + public AggregationSubtotalBuilder min(FieldBuilder field, ColumnBuilder showInColumn) { + return Subtotals.min(field, showInColumn); + } + + public AggregationSubtotalBuilder min(DRIExpression expression, ColumnBuilder showInColumn) { + return Subtotals.min(expression, showInColumn); + } + + // standard deviation + public AggregationSubtotalBuilder stdDev(ValueColumnBuilder subtotalColumn) { + return Subtotals.stdDev(subtotalColumn); + } + + public AggregationSubtotalBuilder stdDev(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return Subtotals.stdDev(fieldName, valueClass, showInColumn); + } + + public AggregationSubtotalBuilder stdDev(FieldBuilder field, ColumnBuilder showInColumn) { + return Subtotals.stdDev(field, showInColumn); + } + + public AggregationSubtotalBuilder stdDev(DRIExpression expression, ColumnBuilder showInColumn) { + return Subtotals.stdDev(expression, showInColumn); + } + + // variance + public AggregationSubtotalBuilder var(ValueColumnBuilder subtotalColumn) { + return Subtotals.var(subtotalColumn); + } + + public AggregationSubtotalBuilder var(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return Subtotals.var(fieldName, valueClass, showInColumn); + } + + public AggregationSubtotalBuilder var(FieldBuilder field, ColumnBuilder showInColumn) { + return Subtotals.var(field, showInColumn); + } + + public AggregationSubtotalBuilder var(DRIExpression expression, ColumnBuilder showInColumn) { + return Subtotals.var(expression, showInColumn); + } + + // custom + public CustomSubtotalBuilder customValue(DRIExpression expression, ColumnBuilder showInColumn) { + return Subtotals.customValue(expression, showInColumn); + } + + // percentage + public PercentageSubtotalBuilder percentage(ValueColumnBuilder subtotalColumn) { + return Subtotals.percentage(subtotalColumn); + } + + public PercentageSubtotalBuilder percentage(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return Subtotals.percentage(fieldName, valueClass, showInColumn); + } + + public PercentageSubtotalBuilder percentage(FieldBuilder field, ColumnBuilder showInColumn) { + return Subtotals.percentage(field, showInColumn); + } + + /*public PercentageSubtotalBuilder percentage(DRISimpleExpression expression, ColumnBuilder showInColumn) { + return Subtotals.percentage(expression, showInColumn); + }*/ + + // text + public AggregationSubtotalBuilder text(String text, ColumnBuilder showInColumn) { + return Subtotals.text(text, showInColumn); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/Subtotals.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/Subtotals.java new file mode 100644 index 0000000..75f1961 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/subtotal/Subtotals.java @@ -0,0 +1,239 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.subtotal; + +import software.xdev.dynamicreports.report.builder.DynamicReports; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.ValueColumnBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import org.apache.commons.lang3.Validate; + +/** + * A set of methods of creating column subtotals + * + * @author Ricardo Mariaca + */ +public class Subtotals { + + // calculation + public static AggregationSubtotalBuilder aggregate(ValueColumnBuilder subtotalColumn, Calculation calculation) { + Validate.notNull(subtotalColumn, "subtotalColumn must not be null"); + return new AggregationSubtotalBuilder(subtotalColumn, calculation); + } + + public static AggregationSubtotalBuilder aggregate(String fieldName, Class valueClass, ColumnBuilder showInColumn, Calculation calculation) { + return aggregate(DynamicReports.field(fieldName, valueClass), showInColumn, calculation); + } + + public static AggregationSubtotalBuilder aggregate(FieldBuilder field, ColumnBuilder showInColumn, Calculation calculation) { + Validate.notNull(showInColumn, "showInColumn must not be null"); + return new AggregationSubtotalBuilder(field, showInColumn, calculation); + } + + public static AggregationSubtotalBuilder aggregate(DRIExpression expression, ColumnBuilder showInColumn, Calculation calculation) { + Validate.notNull(showInColumn, "showInColumn must not be null"); + return new AggregationSubtotalBuilder(expression, showInColumn, calculation); + } + + // sum + public static AggregationSubtotalBuilder sum(ValueColumnBuilder subtotalColumn) { + return aggregate(subtotalColumn, Calculation.SUM); + } + + public static AggregationSubtotalBuilder sum(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return aggregate(fieldName, valueClass, showInColumn, Calculation.SUM); + } + + public static AggregationSubtotalBuilder sum(FieldBuilder field, ColumnBuilder showInColumn) { + return aggregate(field, showInColumn, Calculation.SUM); + } + + public static AggregationSubtotalBuilder sum(DRIExpression expression, ColumnBuilder showInColumn) { + return aggregate(expression, showInColumn, Calculation.SUM); + } + + // average + public static AggregationSubtotalBuilder avg(ValueColumnBuilder subtotalColumn) { + return aggregate(subtotalColumn, Calculation.AVERAGE); + } + + public static AggregationSubtotalBuilder avg(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return aggregate(fieldName, valueClass, showInColumn, Calculation.AVERAGE); + } + + public static AggregationSubtotalBuilder avg(FieldBuilder field, ColumnBuilder showInColumn) { + return aggregate(field, showInColumn, Calculation.AVERAGE); + } + + public static AggregationSubtotalBuilder avg(DRIExpression expression, ColumnBuilder showInColumn) { + return aggregate(expression, showInColumn, Calculation.AVERAGE); + } + + // count + public static AggregationSubtotalBuilder count(ValueColumnBuilder subtotalColumn) { + return aggregate(subtotalColumn, Calculation.COUNT); + } + + public static AggregationSubtotalBuilder count(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return aggregate(fieldName, valueClass, showInColumn, Calculation.COUNT); + } + + public static AggregationSubtotalBuilder count(FieldBuilder field, ColumnBuilder showInColumn) { + return aggregate(field, showInColumn, Calculation.COUNT); + } + + public static AggregationSubtotalBuilder count(DRIExpression expression, ColumnBuilder showInColumn) { + return aggregate(expression, showInColumn, Calculation.COUNT); + } + + // distinct count + public static AggregationSubtotalBuilder distinctCount(ValueColumnBuilder subtotalColumn) { + return aggregate(subtotalColumn, Calculation.DISTINCT_COUNT); + } + + public static AggregationSubtotalBuilder distinctCount(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return aggregate(fieldName, valueClass, showInColumn, Calculation.DISTINCT_COUNT); + } + + public static AggregationSubtotalBuilder distinctCount(FieldBuilder field, ColumnBuilder showInColumn) { + return aggregate(field, showInColumn, Calculation.DISTINCT_COUNT); + } + + public static AggregationSubtotalBuilder distinctCount(DRIExpression expression, ColumnBuilder showInColumn) { + return aggregate(expression, showInColumn, Calculation.DISTINCT_COUNT); + } + + // first + public static AggregationSubtotalBuilder first(ValueColumnBuilder subtotalColumn) { + return aggregate(subtotalColumn, Calculation.FIRST); + } + + public static AggregationSubtotalBuilder first(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return aggregate(fieldName, valueClass, showInColumn, Calculation.FIRST); + } + + public static AggregationSubtotalBuilder first(FieldBuilder field, ColumnBuilder showInColumn) { + return aggregate(field, showInColumn, Calculation.FIRST); + } + + public static AggregationSubtotalBuilder first(DRIExpression expression, ColumnBuilder showInColumn) { + return aggregate(expression, showInColumn, Calculation.FIRST); + } + + // highest + public static AggregationSubtotalBuilder max(ValueColumnBuilder subtotalColumn) { + return aggregate(subtotalColumn, Calculation.HIGHEST); + } + + public static AggregationSubtotalBuilder max(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return aggregate(fieldName, valueClass, showInColumn, Calculation.HIGHEST); + } + + public static AggregationSubtotalBuilder max(FieldBuilder field, ColumnBuilder showInColumn) { + return aggregate(field, showInColumn, Calculation.HIGHEST); + } + + public static AggregationSubtotalBuilder max(DRIExpression expression, ColumnBuilder showInColumn) { + return aggregate(expression, showInColumn, Calculation.HIGHEST); + } + + // lowest + public static AggregationSubtotalBuilder min(ValueColumnBuilder subtotalColumn) { + return aggregate(subtotalColumn, Calculation.LOWEST); + } + + public static AggregationSubtotalBuilder min(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return aggregate(fieldName, valueClass, showInColumn, Calculation.LOWEST); + } + + public static AggregationSubtotalBuilder min(FieldBuilder field, ColumnBuilder showInColumn) { + return aggregate(field, showInColumn, Calculation.LOWEST); + } + + public static AggregationSubtotalBuilder min(DRIExpression expression, ColumnBuilder showInColumn) { + return aggregate(expression, showInColumn, Calculation.LOWEST); + } + + // standard deviation + public static AggregationSubtotalBuilder stdDev(ValueColumnBuilder subtotalColumn) { + return aggregate(subtotalColumn, Calculation.STANDARD_DEVIATION); + } + + public static AggregationSubtotalBuilder stdDev(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return aggregate(fieldName, valueClass, showInColumn, Calculation.STANDARD_DEVIATION); + } + + public static AggregationSubtotalBuilder stdDev(FieldBuilder field, ColumnBuilder showInColumn) { + return aggregate(field, showInColumn, Calculation.STANDARD_DEVIATION); + } + + public static AggregationSubtotalBuilder stdDev(DRIExpression expression, ColumnBuilder showInColumn) { + return aggregate(expression, showInColumn, Calculation.STANDARD_DEVIATION); + } + + // variance + public static AggregationSubtotalBuilder var(ValueColumnBuilder subtotalColumn) { + return aggregate(subtotalColumn, Calculation.VARIANCE); + } + + public static AggregationSubtotalBuilder var(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return aggregate(fieldName, valueClass, showInColumn, Calculation.VARIANCE); + } + + public static AggregationSubtotalBuilder var(FieldBuilder field, ColumnBuilder showInColumn) { + return aggregate(field, showInColumn, Calculation.VARIANCE); + } + + public static AggregationSubtotalBuilder var(DRIExpression expression, ColumnBuilder showInColumn) { + return aggregate(expression, showInColumn, Calculation.VARIANCE); + } + + // custom + public static CustomSubtotalBuilder customValue(DRIExpression expression, ColumnBuilder showInColumn) { + Validate.notNull(showInColumn, "showInColumn must not be null"); + return new CustomSubtotalBuilder(expression, showInColumn); + } + + // percentage + public static PercentageSubtotalBuilder percentage(ValueColumnBuilder subtotalColumn) { + Validate.notNull(subtotalColumn, "subtotalColumn must not be null"); + return new PercentageSubtotalBuilder(subtotalColumn); + } + + public static PercentageSubtotalBuilder percentage(String fieldName, Class valueClass, ColumnBuilder showInColumn) { + return percentage(DynamicReports.field(fieldName, valueClass), showInColumn); + } + + public static PercentageSubtotalBuilder percentage(FieldBuilder field, ColumnBuilder showInColumn) { + Validate.notNull(showInColumn, "showInColumn must not be null"); + return new PercentageSubtotalBuilder(field, showInColumn); + } + + /*public static PercentageSubtotalBuilder percentage(DRISimpleExpression expression, ColumnBuilder showInColumn) { + Validate.notNull(showInColumn, "showInColumn must not be null"); + return new PercentageSubtotalBuilder(expression, showInColumn); + }*/ + + // text + public static AggregationSubtotalBuilder text(String text, ColumnBuilder showInColumn) { + return aggregate(Expressions.text(text), showInColumn, Calculation.NOTHING); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/tableofcontents/TableOfContentsCustomizer.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/tableofcontents/TableOfContentsCustomizer.java new file mode 100644 index 0000000..a7691a9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/tableofcontents/TableOfContentsCustomizer.java @@ -0,0 +1,316 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.tableofcontents; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.hyperLink; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import software.xdev.dynamicreports.jasper.base.tableofcontents.JasperTocHeading; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.HyperLinkBuilder; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.builder.component.ComponentBuilder; +import software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder; +import software.xdev.dynamicreports.report.builder.component.TextFieldBuilder; +import software.xdev.dynamicreports.report.builder.component.VerticalListBuilder; +import software.xdev.dynamicreports.report.builder.expression.SystemMessageExpression; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.HyperLinkType; +import software.xdev.dynamicreports.report.constant.TableOfContentsPosition; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + *

TableOfContentsCustomizer class.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public class TableOfContentsCustomizer implements DRITableOfContentsCustomizer { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + * Constant dots="" + */ + protected static String dots; + + static { + final StringBuilder dots = new StringBuilder(200); + for (int i = 0; i < dots.capacity(); i++) { + dots.append("."); + } + TableOfContentsCustomizer.dots = dots.toString(); + } + + protected ReportBuilder report; + protected List headingList; + protected int headings; + protected int levels; + protected FieldBuilder levelField; + protected FieldBuilder textField; + protected FieldBuilder referenceField; + protected FieldBuilder pageIndexField; + protected HyperLinkBuilder referenceHyperLink; + protected int pageIndexDigits; + protected ReportStyleBuilder titleStyle; + protected ReportStyleBuilder headingStyle; + protected Map headingStyles; + protected Integer textFixedWidth; + protected Integer dotsFixedWidth; + protected Integer pageIndexFixedWidth; + protected TableOfContentsPosition position; + + /** + *

Constructor for TableOfContentsCustomizer.

+ */ + public TableOfContentsCustomizer() { + headingStyles = new HashMap<>(); + } + + /** + *

init.

+ */ + protected void init() { + levelField = field("level", type.integerType()); + textField = field("text", type.stringType()); + referenceField = field("reference", type.stringType()); + pageIndexField = field("pageIndex", type.integerType()); + + referenceHyperLink = hyperLink(); + referenceHyperLink.setAnchor(new ReferenceExpression()); + referenceHyperLink.setType(HyperLinkType.LOCAL_ANCHOR); + + pageIndexDigits = String.valueOf(headings).length(); + + if (titleStyle == null) { + titleStyle = stl.style().bold().setFontSize(16).setHorizontalTextAlignment(HorizontalTextAlignment.CENTER); + } + } + + /** {@inheritDoc} */ + @Override + public void setReport(final ReportBuilder report) { + this.report = report; + } + + /** {@inheritDoc} */ + @Override + public void setHeadingList(final List headingList) { + this.headingList = headingList; + } + + /** {@inheritDoc} */ + @Override + public void setHeadings(final int headings) { + this.headings = headings; + } + + /** {@inheritDoc} */ + @Override + public void setLevels(final int levels) { + this.levels = levels; + } + + /** {@inheritDoc} */ + @Override + public void customize() { + init(); + + report.title(title(), cmp.filler().setFixedHeight(20)).fields(levelField, textField, referenceField, pageIndexField).detail(detailComponent()); + } + + /** + *

title.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + */ + protected ComponentBuilder title() { + return cmp.text(new SystemMessageExpression("table_of_contents")).setStyle(titleStyle); + } + + /** + *

detailComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + */ + protected ComponentBuilder detailComponent() { + final VerticalListBuilder detailComponent = cmp.verticalList(); + for (int i = 0; i < levels; i++) { + final ComponentBuilder headingComponent = headingComponent(i); + headingComponent.setPrintWhenExpression(new PrintHeadingExpression(i)); + headingComponent.removeLineWhenBlank(); + detailComponent.add(headingComponent); + } + return detailComponent; + } + + /** + *

headingComponent.

+ * + * @param level a int. + * @return a {@link software.xdev.dynamicreports.report.builder.component.ComponentBuilder} object. + */ + protected ComponentBuilder headingComponent(final int level) { + final HorizontalListBuilder headingComponent = cmp.horizontalList(); + + if (level > 0) { + headingComponent.add(cmp.filler().setFixedWidth(level * 10)); + } + + final TextFieldBuilder textComponent = cmp.text(textField).setHyperLink(referenceHyperLink); + if (textFixedWidth != null) { + textComponent.setFixedWidth(textFixedWidth); + } + headingComponent.add(textComponent); + + if (level > 0) { + headingComponent.add(cmp.filler().setFixedWidth(level * 10)); + } + + final TextFieldBuilder dotsComponent = cmp.text(dots.toString()).setTextAdjust(TextAdjust.CUT_TEXT).setHyperLink(referenceHyperLink); + if (dotsFixedWidth != null) { + dotsComponent.setFixedWidth(dotsFixedWidth); + } + headingComponent.add(dotsComponent); + + final TextFieldBuilder pageIndexComponent = cmp.text(pageIndexField).setHyperLink(referenceHyperLink); + if (pageIndexFixedWidth != null) { + pageIndexComponent.setFixedWidth(pageIndexFixedWidth); + } else { + pageIndexComponent.setFixedColumns(pageIndexDigits); + } + headingComponent.add(pageIndexComponent); + + ReportStyleBuilder headingStyle = headingStyles.get(level); + if (headingStyle == null) { + headingStyle = this.headingStyle; + } + if (headingStyle != null) { + textComponent.setStyle(headingStyle); + dotsComponent.setStyle(headingStyle); + pageIndexComponent.setStyle(headingStyle); + } + + return headingComponent; + } + + /** + *

Setter for the field titleStyle.

+ * + * @param titleStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + */ + public void setTitleStyle(final ReportStyleBuilder titleStyle) { + this.titleStyle = titleStyle; + } + + /** + *

Setter for the field headingStyle.

+ * + * @param headingStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + */ + public void setHeadingStyle(final ReportStyleBuilder headingStyle) { + this.headingStyle = headingStyle; + } + + /** + *

Setter for the field headingStyle.

+ * + * @param level a int. + * @param headingStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + */ + public void setHeadingStyle(final int level, final ReportStyleBuilder headingStyle) { + this.headingStyles.put(level, headingStyle); + } + + /** + *

Setter for the field textFixedWidth.

+ * + * @param textFixedWidth a {@link java.lang.Integer} object. + */ + public void setTextFixedWidth(final Integer textFixedWidth) { + this.textFixedWidth = textFixedWidth; + } + + /** + *

Setter for the field dotsFixedWidth.

+ * + * @param dotsFixedWidth a {@link java.lang.Integer} object. + */ + public void setDotsFixedWidth(final Integer dotsFixedWidth) { + this.dotsFixedWidth = dotsFixedWidth; + } + + /** + *

Setter for the field pageIndexFixedWidth.

+ * + * @param pageIndexFixedWidth a {@link java.lang.Integer} object. + */ + public void setPageIndexFixedWidth(final Integer pageIndexFixedWidth) { + this.pageIndexFixedWidth = pageIndexFixedWidth; + } + + /** {@inheritDoc} */ + @Override + public TableOfContentsPosition getPosition() { + return position; + } + + /** + *

Setter for the field position.

+ * + * @param position a {@link software.xdev.dynamicreports.report.constant.TableOfContentsPosition} object. + */ + public void setPosition(final TableOfContentsPosition position) { + this.position = position; + } + + protected class ReferenceExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + @Override + public String evaluate(final ReportParameters reportParameters) { + return reportParameters.getValue(referenceField); + } + } + + protected class PrintHeadingExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private final int level; + + public PrintHeadingExpression(final int level) { + this.level = level; + } + + @Override + public Boolean evaluate(final ReportParameters reportParameters) { + return reportParameters.getValue(levelField) == level; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/tableofcontents/TableOfContentsCustomizerBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/tableofcontents/TableOfContentsCustomizerBuilder.java new file mode 100644 index 0000000..1d1ee25 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/tableofcontents/TableOfContentsCustomizerBuilder.java @@ -0,0 +1,127 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.tableofcontents; + +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.constant.TableOfContentsPosition; + +/** + *

TableOfContentsCustomizerBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class TableOfContentsCustomizerBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for TableOfContentsCustomizerBuilder.

+ */ + public TableOfContentsCustomizerBuilder() { + super(new TableOfContentsCustomizer()); + } + + /** + *

getTableOfContents.

+ * + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizer} object. + */ + public TableOfContentsCustomizer getTableOfContents() { + return build(); + } + + /** + *

setTitleStyle.

+ * + * @param titleStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder} object. + */ + public TableOfContentsCustomizerBuilder setTitleStyle(ReportStyleBuilder titleStyle) { + this.getObject().setTitleStyle(titleStyle); + return this; + } + + /** + *

setHeadingStyle.

+ * + * @param headingStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder} object. + */ + public TableOfContentsCustomizerBuilder setHeadingStyle(ReportStyleBuilder headingStyle) { + this.getObject().setHeadingStyle(headingStyle); + return this; + } + + /** + *

setHeadingStyle.

+ * + * @param level a int. + * @param headingStyle a {@link software.xdev.dynamicreports.report.builder.style.ReportStyleBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder} object. + */ + public TableOfContentsCustomizerBuilder setHeadingStyle(int level, ReportStyleBuilder headingStyle) { + this.getObject().setHeadingStyle(level, headingStyle); + return this; + } + + /** + *

setTextFixedWidth.

+ * + * @param textFixedWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder} object. + */ + public TableOfContentsCustomizerBuilder setTextFixedWidth(Integer textFixedWidth) { + this.getObject().setTextFixedWidth(textFixedWidth); + return this; + } + + /** + *

setDotsFixedWidth.

+ * + * @param dotsFixedWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder} object. + */ + public TableOfContentsCustomizerBuilder setDotsFixedWidth(Integer dotsFixedWidth) { + this.getObject().setDotsFixedWidth(dotsFixedWidth); + return this; + } + + /** + *

setPageIndexFixedWidth.

+ * + * @param pageIndexFixedWidth a {@link java.lang.Integer} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder} object. + */ + public TableOfContentsCustomizerBuilder setPageIndexFixedWidth(Integer pageIndexFixedWidth) { + this.getObject().setPageIndexFixedWidth(pageIndexFixedWidth); + return this; + } + + /** + *

setPosition.

+ * + * @param position a {@link software.xdev.dynamicreports.report.constant.TableOfContentsPosition} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizerBuilder} object. + */ + public TableOfContentsCustomizerBuilder setPosition(TableOfContentsPosition position) { + this.getObject().setPosition(position); + return this; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/tableofcontents/TableOfContentsHeadingBuilder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/tableofcontents/TableOfContentsHeadingBuilder.java new file mode 100644 index 0000000..2ae6d51 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/builder/tableofcontents/TableOfContentsHeadingBuilder.java @@ -0,0 +1,109 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.builder.tableofcontents; + +import software.xdev.dynamicreports.report.base.DRTableOfContentsHeading; +import software.xdev.dynamicreports.report.builder.AbstractBuilder; +import software.xdev.dynamicreports.report.builder.expression.Expressions; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

TableOfContentsHeadingBuilder class.

+ * + * @author Ricardo Mariaca + * + */ +public class TableOfContentsHeadingBuilder extends AbstractBuilder { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for TableOfContentsHeadingBuilder.

+ */ + public TableOfContentsHeadingBuilder() { + super(new DRTableOfContentsHeading()); + } + + /** + *

setParentHeading.

+ * + * @param parentHeading a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsHeadingBuilder} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsHeadingBuilder} object. + */ + public TableOfContentsHeadingBuilder setParentHeading(TableOfContentsHeadingBuilder parentHeading) { + if (parentHeading != null) { + getObject().setParentHeading(parentHeading.build()); + } else { + getObject().setParentHeading(null); + } + return this; + } + + /** + *

setLabel.

+ * + * @param label a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsHeadingBuilder} object. + */ + public TableOfContentsHeadingBuilder setLabel(String label) { + this.getObject().setLabelExpression(Expressions.text(label)); + return this; + } + + /** + *

setLabel.

+ * + * @param labelExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsHeadingBuilder} object. + */ + public TableOfContentsHeadingBuilder setLabel(DRIExpression labelExpression) { + this.getObject().setLabelExpression(labelExpression); + return this; + } + + /** + *

setCustomValue.

+ * + * @param customValue a {@link java.lang.Object} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsHeadingBuilder} object. + */ + public TableOfContentsHeadingBuilder setCustomValue(Object customValue) { + this.getObject().setCustomValueExpression(Expressions.value(customValue)); + return this; + } + + /** + *

setCustomValue.

+ * + * @param customValueExpression a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + * @return a {@link software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsHeadingBuilder} object. + */ + public TableOfContentsHeadingBuilder setCustomValue(DRIExpression customValueExpression) { + this.getObject().setCustomValueExpression(customValueExpression); + return this; + } + + /** + *

getTableOfContentsHeading.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRTableOfContentsHeading} object. + */ + public DRTableOfContentsHeading getTableOfContentsHeading() { + return build(); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/CustomComponentTransform.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/CustomComponentTransform.java new file mode 100644 index 0000000..47ade89 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/CustomComponentTransform.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.component; + +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.constant.ResetType; +import software.xdev.dynamicreports.design.definition.component.DRIDesignComponent; +import software.xdev.dynamicreports.design.transformation.DesignTransformAccessor; +import software.xdev.dynamicreports.jasper.transformation.JasperTransformAccessor; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.JRComponentElement; + +/** + *

CustomComponentTransform interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface CustomComponentTransform { + + /** + *

isTransform.

+ * + * @param component a {@link java.lang.Object} object. + * @return a boolean. + */ + public boolean isTransform(Object component); + + /** + *

designComponent.

+ * + * @param accessor a {@link software.xdev.dynamicreports.design.transformation.DesignTransformAccessor} object. + * @param component a T object. + * @param resetType a {@link software.xdev.dynamicreports.design.constant.ResetType} object. + * @param resetGroup a {@link software.xdev.dynamicreports.design.base.DRDesignGroup} object. + * @return a U object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public U designComponent(DesignTransformAccessor accessor, T component, ResetType resetType, DRDesignGroup resetGroup) throws DRException; + + /** + *

jasperComponent.

+ * + * @param accessor a {@link software.xdev.dynamicreports.jasper.transformation.JasperTransformAccessor} object. + * @param component a U object. + * @return a {@link net.sf.jasperreports.engine.JRComponentElement} object. + */ + public JRComponentElement jasperComponent(JasperTransformAccessor accessor, U component); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/CustomComponents.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/CustomComponents.java new file mode 100644 index 0000000..82f948a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/CustomComponents.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.component; + +import net.sf.jasperreports.extensions.ExtensionsEnvironment; + +import java.util.List; + +/** + *

CustomComponents class.

+ * + * @author Ricardo Mariaca + * + */ +public class CustomComponents { + + /** + *

getComponentTransform.

+ * + * @param component a {@link java.lang.Object} object. + * @return a {@link software.xdev.dynamicreports.report.component.CustomComponentTransform} object. + */ + @SuppressWarnings("rawtypes") + public static CustomComponentTransform getComponentTransform(Object component) { + List transforms = ExtensionsEnvironment.getExtensionsRegistry().getExtensions(CustomComponentTransform.class); + for (CustomComponentTransform transform : transforms) { + if (transform.isTransform(component)) { + return transform; + } + } + return null; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/DRICustomComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/DRICustomComponent.java new file mode 100644 index 0000000..e9ecd32 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/DRICustomComponent.java @@ -0,0 +1,30 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.component; + +import software.xdev.dynamicreports.report.definition.component.DRIDimensionComponent; + +/** + *

DRICustomComponent interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRICustomComponent extends DRIDimensionComponent { + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/DRIDesignCustomComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/DRIDesignCustomComponent.java new file mode 100644 index 0000000..000c0c9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/component/DRIDesignCustomComponent.java @@ -0,0 +1,30 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.component; + +import software.xdev.dynamicreports.design.definition.component.DRIDesignComponent; + +/** + *

DRIDesignCustomComponent interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDesignCustomComponent extends DRIDesignComponent { + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/AxisPosition.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/AxisPosition.java new file mode 100644 index 0000000..59d3789 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/AxisPosition.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

AxisPosition class.

+ * + * @author Ricardo Mariaca + * + */ +public enum AxisPosition { + LEFT_OR_TOP, RIGHT_OR_BOTTOM +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/BooleanComponentType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/BooleanComponentType.java new file mode 100644 index 0000000..f2b5182 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/BooleanComponentType.java @@ -0,0 +1,35 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

BooleanComponentType class.

+ * + * @author Ricardo Mariaca + */ +public enum BooleanComponentType +{ + /** + * Shows a text value (true/false) + */ + TEXT_TRUE_FALSE, + /** + * Shows a text value (yes/no) + */ + TEXT_YES_NO +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/BreakType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/BreakType.java new file mode 100644 index 0000000..fc5e4e0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/BreakType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

BreakType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum BreakType { + PAGE, COLUMN +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Calculation.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Calculation.java new file mode 100644 index 0000000..09e7b31 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Calculation.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

Calculation class.

+ * + * @author Ricardo Mariaca + * + */ +public enum Calculation { + NOTHING, COUNT, SUM, AVERAGE, LOWEST, HIGHEST, STANDARD_DEVIATION, VARIANCE, FIRST, DISTINCT_COUNT +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ComponentDimensionType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ComponentDimensionType.java new file mode 100644 index 0000000..450f9d6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ComponentDimensionType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

ComponentDimensionType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum ComponentDimensionType { + FIXED, FLOAT, EXPAND +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ComponentPositionType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ComponentPositionType.java new file mode 100644 index 0000000..3296109 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ComponentPositionType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

ComponentPositionType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum ComponentPositionType { + FLOAT, FIX_RELATIVE_TO_TOP, FIX_RELATIVE_TO_BOTTOM; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Constants.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Constants.java new file mode 100644 index 0000000..cd1063d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Constants.java @@ -0,0 +1,36 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

Constants interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface Constants { + /** + * Value used as serialVersionUID for the current version. + */ + public static final long SERIAL_VERSION_UID = 10000; + + /** + * Constant RESOURCE_BUNDLE_NAME="dynamicreports-messages" + */ + public static final String RESOURCE_BUNDLE_NAME = "dynamicreports-messages"; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/CrosstabPercentageType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/CrosstabPercentageType.java new file mode 100644 index 0000000..1b4be9a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/CrosstabPercentageType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

CrosstabPercentageType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum CrosstabPercentageType { + NONE, GRAND_TOTAL +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/CrosstabTotalPosition.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/CrosstabTotalPosition.java new file mode 100644 index 0000000..8534cac --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/CrosstabTotalPosition.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

CrosstabTotalPosition class.

+ * + * @author Ricardo Mariaca + * + */ +public enum CrosstabTotalPosition { + START, END +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Evaluation.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Evaluation.java new file mode 100644 index 0000000..710ef63 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Evaluation.java @@ -0,0 +1,54 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

Evaluation class.

+ * + * @author Ricardo Mariaca + * + */ +public enum Evaluation { + NONE, + + /** + * A constant specifying that an expression should be evaluated at the end of the filling process. + */ + REPORT, + + /** + * A constant specifying that an expression should be evaluated after each page is filled. + */ + PAGE, + + /** + * A constant specifying that an expression should be evaluated after each column is filled. + */ + COLUMN, + + /** + * A constant specifying that an expression should be evaluated after each group break. + */ + GROUP, + + FIRST_GROUP, + + BEFORE_GROUP, + + LAST_GROUP +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/FontName.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/FontName.java new file mode 100644 index 0000000..5e0c107 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/FontName.java @@ -0,0 +1,39 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

FontName class.

+ * + * @author Ricardo Mariaca + * + */ +public class FontName { + /** + * Constant ARIAL="Arial" + */ + public static final String ARIAL = "Arial"; + /** + * Constant TIMES_NEW_ROMAN="Times New Roman" + */ + public static final String TIMES_NEW_ROMAN = "Times New Roman"; + /** + * Constant COURIER_NEW="Courier New" + */ + public static final String COURIER_NEW = "Courier New"; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/GroupFooterPosition.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/GroupFooterPosition.java new file mode 100644 index 0000000..e49743e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/GroupFooterPosition.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

GroupFooterPosition class.

+ * + * @author Ricardo Mariaca + * + */ +public enum GroupFooterPosition { + NORMAL, STACK_AT_BOTTOM, FORCE_AT_BOTTOM, COLLATE_AT_BOTTOM +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/GroupHeaderLayout.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/GroupHeaderLayout.java new file mode 100644 index 0000000..97b8dc3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/GroupHeaderLayout.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

GroupHeaderLayout class.

+ * + * @author Ricardo Mariaca + * + */ +public enum GroupHeaderLayout { + EMPTY, VALUE, TITLE_AND_VALUE +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalAlignment.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalAlignment.java new file mode 100644 index 0000000..4b333d8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalAlignment.java @@ -0,0 +1,30 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

HorizontalAlignment class.

+ * + * @author Ricardo Mariaca + * + * @deprecated use HorizontalTextAligment for texts or HorizontalImageAligment for images instead + */ +@Deprecated +public enum HorizontalAlignment { + LEFT, CENTER, RIGHT, JUSTIFIED +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalCellComponentAlignment.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalCellComponentAlignment.java new file mode 100644 index 0000000..db499b5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalCellComponentAlignment.java @@ -0,0 +1,86 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

HorizontalCellComponentAlignment class.

+ * + * @author Ricardo Mariaca + * + */ +public enum HorizontalCellComponentAlignment { + /** + *
+     *
+     *  -------------
+     * | -           |
+     * ||C|          |
+     * | -           |
+     *  -------------
+     * 
+ */ + LEFT, + + /** + *
+     *
+     *  -------------
+     * |      -      |
+     * |     |C|     |
+     * |      -      |
+     *  -------------
+     * 
+ */ + CENTER, + + /** + *
+     *
+     *  -------------
+     * |           - |
+     * |          |C||
+     * |           - |
+     *  -------------
+     * 
+ */ + RIGHT, + + /** + *
+     *
+     *  -------------
+     * | ----------- |
+     * ||     C     ||
+     * | ----------- |
+     *  -------------
+     * 
+ */ + FLOAT, + + /** + *
+     *
+     *  -------------
+     * | ----------- |
+     * ||     C     ||
+     * | ----------- |
+     *  -------------
+     * 
+ */ + EXPAND +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalImageAlignment.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalImageAlignment.java new file mode 100644 index 0000000..8a3ef49 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalImageAlignment.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

HorizontalImageAlignment class.

+ * + * @author Ricardo Mariaca + * + */ +public enum HorizontalImageAlignment { + LEFT, CENTER, RIGHT +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalTextAlignment.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalTextAlignment.java new file mode 100644 index 0000000..41c25eb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HorizontalTextAlignment.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

HorizontalTextAlignment class.

+ * + * @author Ricardo Mariaca + * + */ +public enum HorizontalTextAlignment { + LEFT, CENTER, RIGHT, JUSTIFIED +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HyperLinkTarget.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HyperLinkTarget.java new file mode 100644 index 0000000..87410fb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HyperLinkTarget.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

HyperLinkTarget class.

+ * + * @author Ricardo Mariaca + * + */ +public enum HyperLinkTarget { + NONE, SELF, BLANK, PARENT, TOP +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HyperLinkType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HyperLinkType.java new file mode 100644 index 0000000..79502ec --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/HyperLinkType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

HyperLinkType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum HyperLinkType { + NONE, REFERENCE, LOCAL_ANCHOR, LOCAL_PAGE, REMOTE_ANCHOR, REMOTE_PAGE +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ImageAnchorType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ImageAnchorType.java new file mode 100644 index 0000000..5906a9b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ImageAnchorType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

ImageAnchorType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum ImageAnchorType { + MOVE_SIZE, MOVE_NO_SIZE, NO_MOVE_NO_SIZE +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ImageScale.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ImageScale.java new file mode 100644 index 0000000..99fe078 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ImageScale.java @@ -0,0 +1,55 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

ImageScale class.

+ * + * @author Ricardo Mariaca + * + */ +public enum ImageScale { + + /** + * Use CLIP instead + */ + @Deprecated NO_RESIZE, /** + * Use FILL_FRAME instead + */ + @Deprecated FILL, /** + * Use RETAIN_SHAPE instead + */ + @Deprecated FILL_PROPORTIONALLY, /** + * A constant value specifying that if the actual image is larger than the image element size, it will be cut off so that it keeps its original resolution, and only the region that fits the + * specified size will be displayed. + */ + CLIP, /** + * A constant value specifying that if the dimensions of the actual image do not fit those specified for the image element that displays it, the image can be forced to obey them and stretch itself + * so that it fits in the designated output area. + */ + FILL_FRAME, /** + * A constant value specifying that if the actual image does not fit into the image element, it can be adapted to those dimensions without needing to change its original proportions. + */ + RETAIN_SHAPE, /** + * A scale image type that instructs the engine to stretch the image height to fit the actual height of the image. + */ + REAL_HEIGHT, /** + * A scale image type that stretches the images height in the same way as {@link #REAL_HEIGHT}, and in addition it changes the image width to the actual with of the image. + */ + REAL_SIZE +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Language.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Language.java new file mode 100644 index 0000000..82febed --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Language.java @@ -0,0 +1,39 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

Language class.

+ * + * @author Ricardo Mariaca + * + */ +public class Language { + /** + * Constant JAVA="java" + */ + public static final String JAVA = "java"; + /** + * Constant GROOVY="groovy" + */ + public static final String GROOVY = "groovy"; + /** + * Constant JAVA_SCRIPT="javascript" + */ + public static final String JAVA_SCRIPT = "javascript"; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/LineDirection.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/LineDirection.java new file mode 100644 index 0000000..fef826a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/LineDirection.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

LineDirection class.

+ * + * @author Ricardo Mariaca + * + */ +public enum LineDirection { + TOP_DOWN, BOTTOM_UP +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/LineSpacing.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/LineSpacing.java new file mode 100644 index 0000000..aaa2cf7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/LineSpacing.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

LineSpacing class.

+ * + * @author Ricardo Mariaca + * + */ +public enum LineSpacing { + SINGLE, ONE_AND_HALF, DOUBLE, AT_LEAST, FIXED, PROPORTIONAL +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/LineStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/LineStyle.java new file mode 100644 index 0000000..cc7be46 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/LineStyle.java @@ -0,0 +1,40 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

LineStyle class.

+ * + * @author Ricardo Mariaca + * + */ +public enum LineStyle { + /** + * Constant useful for specifying solid line style. + */ + SOLID, /** + * Constant useful for specifying dashed line style. + */ + DASHED, /** + * Constant useful for specifying dotted line style. + */ + DOTTED, /** + * Constant useful for specifying double line style. + */ + DOUBLE +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ListType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ListType.java new file mode 100644 index 0000000..d015572 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ListType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

ListType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum ListType { + HORIZONTAL, HORIZONTAL_FLOW, VERTICAL +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Markup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Markup.java new file mode 100644 index 0000000..962b991 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Markup.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

Markup class.

+ * + * @author Ricardo Mariaca + * + */ +public enum Markup { + NONE, STYLED, RTF, HTML +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/MeterShape.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/MeterShape.java new file mode 100644 index 0000000..ea03093 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/MeterShape.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

MeterShape class.

+ * + * @author Ricardo Mariaca + * + */ +public enum MeterShape { + CHORD, CIRCLE, PIE, DIAL +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/OrderType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/OrderType.java new file mode 100644 index 0000000..48f29c5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/OrderType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

OrderType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum OrderType { + ASCENDING, DESCENDING +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Orientation.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Orientation.java new file mode 100644 index 0000000..574c737 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Orientation.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

Orientation class.

+ * + * @author Ricardo Mariaca + * + */ +public enum Orientation { + HORIZONTAL, VERTICAL +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PageOrientation.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PageOrientation.java new file mode 100644 index 0000000..ed04c5e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PageOrientation.java @@ -0,0 +1,36 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

PageOrientation class.

+ * + * @author Ricardo Mariaca + * + */ +public enum PageOrientation { + /** + * Portrait page orientation. + */ + PORTRAIT, + + /** + * Landscape page orientation. + */ + LANDSCAPE +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PageType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PageType.java new file mode 100644 index 0000000..75f36ee --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PageType.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

PageType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum PageType { + LETTER(612, 792), NOTE(540, 720), LEGAL(612, 1008), A0(2380, 3368), A1(1684, 2380), A2(1190, 1684), A3(842, 1190), A4(595, 842), A5(421, 595), A6(297, 421), A7(210, 297), A8(148, 210), + A9(105, 148), A10(74, 105), B0(2836, 4008), B1(2004, 2836), B2(1418, 2004), B3(1002, 1418), B4(709, 1002), B5(501, 709), B6(353, 497), B7(252, 353), B8(173, 252), B9(122, 173), B10(86, 122), + C0(2599, 3679), C1(1836, 2599), C2(1296, 1836), C3(922, 1296), C4(648, 922), C5(461, 648), C6(324, 461), C7(230, 324), C8(158, 230), C9(115, 158), C10(79, 115), ARCH_E(2592, 3456), + ARCH_D(1728, 2592), ARCH_C(1296, 1728), ARCH_B(864, 1296), ARCH_A(648, 864), FLSA(612, 936), FLSE(612, 936), HALFLETTER(396, 612), _11X17(792, 1224), LEDGER(1224, 792); + + private int width; + private int height; + + private PageType(int width, int height) { + this.width = width; + this.height = height; + } + + /** + *

Getter for the field width.

+ * + * @return a int. + */ + public int getWidth() { + return width; + } + + /** + *

Getter for the field height.

+ * + * @return a int. + */ + public int getHeight() { + return height; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PdfEncoding.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PdfEncoding.java new file mode 100644 index 0000000..1a16ce4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PdfEncoding.java @@ -0,0 +1,111 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

PdfEncoding class.

+ * + * @author Ricardo Mariaca + * + */ +public class PdfEncoding { + /** + * Constant CP1250_Central_European="CP1250" + */ + public static final String CP1250_Central_European = "CP1250"; + /** + * Constant CP1251_Cyrillic="CP1251" + */ + public static final String CP1251_Cyrillic = "CP1251"; + /** + * Constant CP1252_Western_European_ANSI="CP1252" + */ + public static final String CP1252_Western_European_ANSI = "CP1252"; + /** + * Constant CP1253_Greek="CP1253" + */ + public static final String CP1253_Greek = "CP1253"; + /** + * Constant CP1254_Turkish="CP1254" + */ + public static final String CP1254_Turkish = "CP1254"; + /** + * Constant CP1255_Hebrew="CP1255" + */ + public static final String CP1255_Hebrew = "CP1255"; + /** + * Constant CP1256_Arabic="CP1256" + */ + public static final String CP1256_Arabic = "CP1256"; + /** + * Constant CP1257_Baltic="CP1257" + */ + public static final String CP1257_Baltic = "CP1257"; + /** + * Constant CP1258_Vietnamese="CP1258" + */ + public static final String CP1258_Vietnamese = "CP1258"; + /** + * Constant UniGB_UCS2_H_Chinese_Simplified="UniGB-UCS2-H" + */ + public static final String UniGB_UCS2_H_Chinese_Simplified = "UniGB-UCS2-H"; + /** + * Constant UniGB_UCS2_V_Chinese_Simplified="UniGB-UCS2-V" + */ + public static final String UniGB_UCS2_V_Chinese_Simplified = "UniGB-UCS2-V"; + /** + * Constant UniCNS_UCS2_H_Chinese_traditional="UniCNS-UCS2-H" + */ + public static final String UniCNS_UCS2_H_Chinese_traditional = "UniCNS-UCS2-H"; + /** + * Constant UniCNS_UCS2_V_Chinese_traditional="UniCNS-UCS2-V" + */ + public static final String UniCNS_UCS2_V_Chinese_traditional = "UniCNS-UCS2-V"; + /** + * Constant UniJIS_UCS2_H_Japanese="UniJIS-UCS2-H" + */ + public static final String UniJIS_UCS2_H_Japanese = "UniJIS-UCS2-H"; + /** + * Constant UniJIS_UCS2_V_Japanese="UniJIS-UCS2-V" + */ + public static final String UniJIS_UCS2_V_Japanese = "UniJIS-UCS2-V"; + /** + * Constant UniJIS_UCS2_HW_H_Japanese="UniJIS-UCS2-HW-H" + */ + public static final String UniJIS_UCS2_HW_H_Japanese = "UniJIS-UCS2-HW-H"; + /** + * Constant UniJIS_UCS2_HW_V_Japanese="UniJIS-UCS2-HW-V" + */ + public static final String UniJIS_UCS2_HW_V_Japanese = "UniJIS-UCS2-HW-V"; + /** + * Constant UniKS_UCS2_H_Korean="UniKS-UCS2-H" + */ + public static final String UniKS_UCS2_H_Korean = "UniKS-UCS2-H"; + /** + * Constant UniKS_UCS2_V_Korean="UniKS-UCS2-V" + */ + public static final String UniKS_UCS2_V_Korean = "UniKS-UCS2-V"; + /** + * Constant Identity_H_Unicode_with_horizontal_writing="Identity-H" + */ + public static final String Identity_H_Unicode_with_horizontal_writing = "Identity-H"; + /** + * Constant Identity_V_Unicode_with_horizontal_writing="Identity-V" + */ + public static final String Identity_V_Unicode_with_horizontal_writing = "Identity-V"; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PdfPrintScaling.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PdfPrintScaling.java new file mode 100644 index 0000000..66c5feb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PdfPrintScaling.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

PdfPrintScaling class.

+ * + * @author Ricardo Mariaca + * + */ +public enum PdfPrintScaling { + NONE, DEFAULT +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PdfaConformance.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PdfaConformance.java new file mode 100644 index 0000000..1782769 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PdfaConformance.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

PdfaConformance class.

+ * + * @author Ricardo Mariaca + * + */ +public enum PdfaConformance { + NONE, PDFA_1A, PDFA_1B +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PercentageTotalType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PercentageTotalType.java new file mode 100644 index 0000000..dff90b2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/PercentageTotalType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

PercentageTotalType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum PercentageTotalType { + REPORT, GROUP, FIRST_GROUP, LAST_GROUP +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Position.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Position.java new file mode 100644 index 0000000..11a7562 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Position.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

Position class.

+ * + * @author Ricardo Mariaca + * + */ +public enum Position { + TOP, BOTTOM, LEFT, RIGHT +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/QrCodeErrorCorrectionLevel.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/QrCodeErrorCorrectionLevel.java new file mode 100644 index 0000000..1f9a6c6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/QrCodeErrorCorrectionLevel.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

QrCodeErrorCorrectionLevel class.

+ * + * @author Ricardo Mariaca + * + */ +public enum QrCodeErrorCorrectionLevel { + L, M, Q, H; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/QueryLanguage.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/QueryLanguage.java new file mode 100644 index 0000000..e090ed1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/QueryLanguage.java @@ -0,0 +1,51 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

QueryLanguage class.

+ * + * @author Ricardo Mariaca + * + */ +public class QueryLanguage { + /** + * Constant SQL="sql" + */ + public static final String SQL = "sql"; + /** + * Constant HQL="hql" + */ + public static final String HQL = "hql"; + /** + * Constant XPATH="xPath" + */ + public static final String XPATH = "xPath"; + /** + * Constant MDX="mdx" + */ + public static final String MDX = "mdx"; + /** + * Constant EJBQL="ejbql" + */ + public static final String EJBQL = "ejbql"; + /** + * Constant CSV="csv" + */ + public static final String CSV = "csv"; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/RectangleAnchor.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/RectangleAnchor.java new file mode 100644 index 0000000..0f951ff --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/RectangleAnchor.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

RectangleAnchor class.

+ * + * @author Ricardo Mariaca + * + */ +public enum RectangleAnchor { + CENTER, TOP, TOP_LEFT, TOP_RIGHT, BOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT, LEFT, RIGHT +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Rotation.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Rotation.java new file mode 100644 index 0000000..29cf7a0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/Rotation.java @@ -0,0 +1,40 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

Rotation class.

+ * + * @author Ricardo Mariaca + * + */ +public enum Rotation { + /** + * Constant useful for displaying the text without rotating it + */ + NONE, /** + * Constant useful for rotating the text 90 degrees counter clockwise. + */ + LEFT, /** + * Constant useful for rotating the text 90 degrees clockwise. + */ + RIGHT, /** + * Constant useful for rotating the text 180 degrees. + */ + UPSIDE_DOWN +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/RunDirection.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/RunDirection.java new file mode 100644 index 0000000..a3d6595 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/RunDirection.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

RunDirection class.

+ * + * @author Ricardo Mariaca + * + */ +public enum RunDirection { + LEFT_TO_RIGHT, RIGHT_TO_LEFT +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ScaleType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ScaleType.java new file mode 100644 index 0000000..2ba710f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ScaleType.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

ScaleType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum ScaleType { + ON_BOTH_AXES, ON_DOMAIN_AXIS, ON_RANGE_AXIS +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SpiderRotation.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SpiderRotation.java new file mode 100644 index 0000000..df31b96 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SpiderRotation.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

SpiderRotation class.

+ * + * @author Ricardo Mariaca + * + */ +public enum SpiderRotation { + CLOCKWISE, ANTICLOCKWISE; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SplitType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SplitType.java new file mode 100644 index 0000000..0752760 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SplitType.java @@ -0,0 +1,37 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

SplitType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum SplitType { + /** + * A band can be split + */ + IMMEDIATE, /** + * Prevents a band from splitting. + */ + PREVENT, /** + * A band can be split, but never within its declared height. + */ + STRETCH +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/StretchType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/StretchType.java new file mode 100644 index 0000000..23d87ed --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/StretchType.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

StretchType class.

+ * + * @author Ricardo Mariaca + */ +public enum StretchType +{ + NO_STRETCH, + /** + * @deprecated use ELEMENT_GROUP_HEIGHT instead + */ + @Deprecated + RELATIVE_TO_TALLEST_OBJECT, + /** + * @deprecated use CONTAINER_HEIGHT instead + */ + @Deprecated + RELATIVE_TO_BAND_HEIGHT, ELEMENT_GROUP_HEIGHT, ELEMENT_GROUP_BOTTOM, CONTAINER_HEIGHT, CONTAINER_BOTTOM +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SubtotalPosition.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SubtotalPosition.java new file mode 100644 index 0000000..d8f37dc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SubtotalPosition.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

SubtotalPosition class.

+ * + * @author Ricardo Mariaca + * + */ +public enum SubtotalPosition { + TITLE, PAGE_HEADER, PAGE_FOOTER, COLUMN_HEADER, COLUMN_FOOTER, GROUP_HEADER, GROUP_FOOTER, FIRST_GROUP_HEADER, FIRST_GROUP_FOOTER, LAST_GROUP_HEADER, LAST_GROUP_FOOTER, LAST_PAGE_FOOTER, SUMMARY +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SystemExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SystemExpression.java new file mode 100644 index 0000000..81477fc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/SystemExpression.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

SystemExpression class.

+ * + * @author Ricardo Mariaca + * + */ +public enum SystemExpression { + PAGE_NUMBER +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TabStopAlignment.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TabStopAlignment.java new file mode 100644 index 0000000..25fc50e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TabStopAlignment.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

TabStopAlignment class.

+ * + * @author Ricardo Mariaca + * + */ +public enum TabStopAlignment { + LEFT, CENTER, RIGHT +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TableOfContentsPosition.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TableOfContentsPosition.java new file mode 100644 index 0000000..6710e18 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TableOfContentsPosition.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

TableOfContentsPosition class.

+ * + * @author Ricardo Mariaca + * + */ +public enum TableOfContentsPosition { + TOP, BOTTOM +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TableOrder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TableOrder.java new file mode 100644 index 0000000..e1ef169 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TableOrder.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

TableOrder class.

+ * + * @author Ricardo Mariaca + * + */ +public enum TableOrder { + BY_ROW, BY_COLUMN; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TextAdjust.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TextAdjust.java new file mode 100644 index 0000000..1afb66d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TextAdjust.java @@ -0,0 +1,27 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + * + * @author Jan Moxter + * + */ +public enum TextAdjust { + CUT_TEXT, STRETCH_HEIGHT, SCALE_FONT +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TimePeriod.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TimePeriod.java new file mode 100644 index 0000000..f5b92d1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/TimePeriod.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

TimePeriod class.

+ * + * @author Ricardo Mariaca + * + */ +public enum TimePeriod { + YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ValueLocation.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ValueLocation.java new file mode 100644 index 0000000..2d0d592 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/ValueLocation.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

ValueLocation class.

+ * + * @author Ricardo Mariaca + * + */ +public enum ValueLocation { + NONE, LEFT, RIGHT, BULB +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalAlignment.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalAlignment.java new file mode 100644 index 0000000..c9d19d7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalAlignment.java @@ -0,0 +1,30 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

VerticalAlignment class.

+ * + * @author Ricardo Mariaca + * + * @deprecated use VerticalTextAligment for texts or VerticalImageAligment for images instead + */ +@Deprecated +public enum VerticalAlignment { + TOP, MIDDLE, BOTTOM, JUSTIFIED +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalCellComponentAlignment.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalCellComponentAlignment.java new file mode 100644 index 0000000..f526068 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalCellComponentAlignment.java @@ -0,0 +1,82 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

VerticalCellComponentAlignment class.

+ * + * @author Ricardo Mariaca + * + */ +public enum VerticalCellComponentAlignment { + /** + *
+     *
+     *  ---
+     * | - |
+     * ||C||
+     * | - |
+     * |   |
+     * |   |
+     *  ---
+     * 
+ */ + TOP, + + /** + *
+     *
+     *  ---
+     * |   |
+     * | - |
+     * ||C||
+     * | - |
+     * |   |
+     *  ---
+     * 
+ */ + MIDDLE, + + /** + *
+     *
+     *  ---
+     * |   |
+     * |   |
+     * | - |
+     * ||C||
+     * | - |
+     *  ---
+     * 
+ */ + BOTTOM, + + /** + *
+     *
+     *  ---
+     * | - |
+     * || ||
+     * ||C||
+     * || ||
+     * | - |
+     *  ---
+     * 
+ */ + EXPAND +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalImageAlignment.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalImageAlignment.java new file mode 100644 index 0000000..3068ddf --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalImageAlignment.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

VerticalImageAlignment class.

+ * + * @author Ricardo Mariaca + * + */ +public enum VerticalImageAlignment { + TOP, MIDDLE, BOTTOM +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalTextAlignment.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalTextAlignment.java new file mode 100644 index 0000000..a434276 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/VerticalTextAlignment.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

VerticalTextAlignment class.

+ * + * @author Ricardo Mariaca + * + */ +public enum VerticalTextAlignment { + TOP, MIDDLE, BOTTOM, JUSTIFIED +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/WhenNoDataType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/WhenNoDataType.java new file mode 100644 index 0000000..bd5e8c2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/WhenNoDataType.java @@ -0,0 +1,40 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

WhenNoDataType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum WhenNoDataType { + /** + * Specifies that in case of empty datasources, there will be an empty report. + */ + NO_PAGES, /** + * Specifies that in case of empty datasources, there will be a report with just one blank page. + */ + BLANK_PAGE, /** + * Specifies that in case of empty datasources, all sections except detail will displayed. + */ + ALL_SECTIONS_NO_DETAIL, /** + * Specifies that in case of empty datasources, the NoData section will be displayed. + */ + NO_DATA_SECTION +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/WhenResourceMissingType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/WhenResourceMissingType.java new file mode 100644 index 0000000..b941019 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/constant/WhenResourceMissingType.java @@ -0,0 +1,46 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.constant; + +/** + *

WhenResourceMissingType class.

+ * + * @author Ricardo Mariaca + * + */ +public enum WhenResourceMissingType { + /** + * Return NULL when a resource is missing. + */ + NULL, + + /** + * Return empty string when a resource is missing. + */ + EMPTY, + + /** + * Return the key when a resource is missing. + */ + KEY, + + /** + * Throw an exception when a resource is missing. + */ + ERROR; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/datasource/DRDataSource.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/datasource/DRDataSource.java new file mode 100644 index 0000000..b83feca --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/datasource/DRDataSource.java @@ -0,0 +1,93 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.datasource; + +import software.xdev.dynamicreports.report.constant.Constants; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRField; +import net.sf.jasperreports.engine.JRRewindableDataSource; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + *

DRDataSource class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRDataSource implements JRRewindableDataSource, Serializable { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + private String[] columns; + private List> values; + private Iterator> iterator; + private Map currentRecord; + + /** + *

Constructor for DRDataSource.

+ * + * @param columns a {@link java.lang.String} object. + */ + public DRDataSource(String... columns) { + this.columns = columns; + this.values = new ArrayList>(); + } + + /** + *

add.

+ * + * @param values a {@link java.lang.Object} object. + */ + public void add(Object... values) { + Map row = new HashMap(); + for (int i = 0; i < values.length; i++) { + row.put(columns[i], values[i]); + } + this.values.add(row); + } + + /** {@inheritDoc} */ + @Override + public Object getFieldValue(JRField field) throws JRException { + return currentRecord.get(field.getName()); + } + + /** {@inheritDoc} */ + @Override + public boolean next() throws JRException { + if (iterator == null) { + this.iterator = values.iterator(); + } + boolean hasNext = iterator.hasNext(); + if (hasNext) { + currentRecord = iterator.next(); + } + return hasNext; + } + + /** {@inheritDoc} */ + @Override + public void moveFirst() throws JRException { + iterator = null; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/defaults/Default.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/defaults/Default.java new file mode 100644 index 0000000..820d7e2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/defaults/Default.java @@ -0,0 +1,2051 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.defaults; + +import java.awt.Color; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Date; +import java.util.Locale; + +import software.xdev.dynamicreports.report.base.DRMargin; +import software.xdev.dynamicreports.report.base.datatype.DRDataType; +import software.xdev.dynamicreports.report.base.style.DRFont; +import software.xdev.dynamicreports.report.base.style.DRPadding; +import software.xdev.dynamicreports.report.base.style.DRSimpleStyle; +import software.xdev.dynamicreports.report.base.style.DRStyle; +import software.xdev.dynamicreports.report.builder.tableofcontents.TableOfContentsCustomizer; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; +import software.xdev.dynamicreports.report.constant.CrosstabTotalPosition; +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.constant.Language; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.constant.Position; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.constant.TableOfContentsPosition; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.component.DRITextField; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; + + +/** + *

Default class.

+ * + * @author Ricardo Mariaca, Jan Moxter + */ +public class Default +{ + protected String reportName; + protected Locale locale; + protected boolean showColumnTitle; + protected boolean showColumnValues; + protected boolean ignorePagination; + protected WhenNoDataType whenNoDataType; + protected WhenResourceMissingType whenResourceMissingType; + protected boolean titleOnANewPage; + protected boolean summaryOnANewPage; + protected boolean summaryWithPageHeaderAndFooter; + protected boolean floatColumnFooter; + protected Orientation printOrder; + protected RunDirection columnDirection; + protected String language; + protected boolean useFieldNameAsDescription; + // style + protected boolean highlightDetailOddRows; + protected DRSimpleStyle detailOddRowStyle; + protected boolean highlightDetailEvenRows; + protected DRSimpleStyle detailEvenRowStyle; + protected DRStyle textStyle; + protected DRStyle columnTitleStyle; + protected DRStyle columnStyle; + protected DRStyle groupTitleStyle; + protected DRStyle groupStyle; + protected DRStyle subtotalStyle; + protected DRStyle imageStyle; + // page + protected int pageWidth; + protected int pageHeight; + protected PageOrientation pageOrientation; + protected DRMargin pageMargin; + protected DRMargin subreportPageMargin; + protected int pageColumnsPerPage; + protected int pageColumnSpace; + protected boolean ignorePageWidth; + // column + protected boolean columnPrintRepeatedDetailValues; + protected int columnWidth; + // component + protected boolean removeLineWhenBlank; + protected boolean printInFirstWholeBand; + protected boolean printWhenDetailOverflows; + // group + protected GroupHeaderLayout groupHeaderLayout; + protected boolean groupHideColumn; + protected boolean groupShowColumnHeaderAndFooter; + protected int groupPadding; + protected boolean groupStartInNewPage; + protected boolean groupStartInNewColumn; + protected boolean groupReprintHeaderOnEachPage; + protected boolean groupResetPageNumber; + protected Integer groupMinHeightToStartNewPage; + protected GroupFooterPosition groupFooterPosition; + protected boolean groupKeepTogether; + protected boolean groupHeaderWithSubtotal; + protected boolean groupByDataType; + // subtotal + protected Position subtotalLabelPosition; + // table of contents + protected boolean tableOfContents; + protected DRITableOfContentsCustomizer tableOfContentsCustomizer; + protected boolean addGroupToTableOfContents; + protected TableOfContentsPosition tableOfContentsPosition; + // text field + protected int textFieldWidth; + protected boolean textFieldPrintRepeatedValues; + protected boolean textFieldStretchWithOverflow; + // image + protected int imageWidth; + protected int imageHeight; + // filler + protected int fillerWidth; + protected int fillerHeight; + // line + protected int lineWidth; + protected int lineHeight; + // ellipse + protected int ellipseWidth; + protected int ellipseHeight; + // rectangle + protected Integer rectangleRadius; + protected int rectangleWidth; + protected int rectangleHeight; + // map + protected int mapWidth; + protected int mapHeight; + // custom component + protected int customComponentWidth; + protected int customComponentHeight; + // break + protected int breakWidth; + protected int breakHeight; + // generic element + protected int genericElementWidth; + protected int genericElementHeight; + // list + protected Integer listWidth; + protected Integer listHeight; + protected int listgap; + protected HorizontalCellComponentAlignment horizontalCellComponentAlignment; + protected VerticalCellComponentAlignment verticalCellComponentAlignment; + // multi page list + protected int multiPageListWidth; + protected int multiPageListHeight; + // subreport + protected int subreportWidth; + protected int subreportHeight; + // crosstab + protected int crosstabWidth; + protected int crosstabHeight; + protected CrosstabTotalPosition crosstabColumnGroupTotalPosition; + protected CrosstabTotalPosition crosstabRowGroupTotalPosition; + protected boolean crosstabColumnGroupShowTotal; + protected boolean crosstabRowGroupShowTotal; + protected int crosstabColumnGroupTotalHeaderMaxWidth; + protected int crosstabRowGroupHeaderMaxWidth; + protected int crosstabCellMaxWidth; + protected boolean crosstabHighlightOddRows; + protected DRSimpleStyle crosstabOddRowStyle; + protected boolean crosstabHighlightEvenRows; + protected DRSimpleStyle crosstabEvenRowStyle; + protected DRStyle crosstabGroupStyle; + protected DRStyle crosstabGroupTotalStyle; + protected DRStyle crosstabGrandTotalStyle; + protected DRStyle crosstabCellStyle; + protected DRStyle crosstabMeasureTitleStyle; + protected CrosstabPercentageType crosstabPercentageType; + // boolean + protected BooleanComponentType booleanComponentType; + protected boolean booleanEmptyWhenNullValue; + protected int booleanImageWidth; + protected int booleanImageHeight; + protected DRStyle booleanColumnStyle; + protected HorizontalImageAlignment booleanHorizontalImageAlignment; + // split + protected SplitType defaultSplitType; + protected SplitType titleSplitType; + protected SplitType pageHeaderSplitType; + protected SplitType pageFooterSplitType; + protected SplitType columnHeaderSplitType; + protected SplitType columnFooterSplitType; + protected SplitType groupHeaderSplitType; + protected SplitType groupFooterSplitType; + protected SplitType detailHeaderSplitType; + protected SplitType detailSplitType; + protected SplitType detailFooterSplitType; + protected SplitType lastPageFooterSplitType; + protected SplitType summarySplitType; + protected SplitType noDataSplitType; + protected SplitType backgroundSplitType; + // band style + protected DRIStyle bandStyle; + // band background component + protected DRIComponent bandBackgroundComponent; + // font + protected DRFont font; + // datatype + protected DRDataType bigDecimalType; + protected DRDataType bigIntegerType; + protected DRDataType byteType; + protected DRDataType doubleType; + protected DRDataType floatType; + protected DRDataType integerType; + protected DRDataType longType; + protected DRDataType shortType; + protected DRDataType dateType; + protected DRDataType dateYearToMonthType; + protected DRDataType dateYearToHourType; + protected DRDataType dateYearToMinuteType; + protected DRDataType dateYearToSecondType; + protected DRDataType dateYearToFractionType; + protected DRDataType dateYearType; + protected DRDataType dateMonthType; + protected DRDataType dateDayType; + protected DRDataType timeHourToMinuteType; + protected DRDataType timeHourToSecondType; + protected DRDataType timeHourToFractionType; + protected DRDataType percentageType; + protected DRDataType booleanType; + protected DRDataType characterType; + protected DRDataType stringType; + protected HorizontalTextAlignment pageXofYHorizontalTextAlignment; + // system fonts + protected boolean loadSystemFonts; + + /** + *

Constructor for Default.

+ */ + public Default() + { + this.init(); + } + + protected void init() + { + this.reportName = "Report"; + this.locale = Locale.getDefault(); + this.showColumnTitle = true; + this.showColumnValues = true; + this.ignorePagination = false; + this.whenNoDataType = WhenNoDataType.NO_PAGES; + this.whenResourceMissingType = WhenResourceMissingType.NULL; + this.titleOnANewPage = false; + this.summaryOnANewPage = false; + this.summaryWithPageHeaderAndFooter = false; + this.floatColumnFooter = false; + this.printOrder = Orientation.VERTICAL; + this.columnDirection = RunDirection.LEFT_TO_RIGHT; + this.language = Language.JAVA; + this.useFieldNameAsDescription = true; + + this.highlightDetailOddRows = false; + this.detailOddRowStyle = new DRSimpleStyle(); + this.detailOddRowStyle.setBackgroundColor(new Color(200, 200, 200)); + this.highlightDetailEvenRows = false; + this.detailEvenRowStyle = new DRSimpleStyle(); + this.detailEvenRowStyle.setBackgroundColor(new Color(240, 240, 240)); + + this.textStyle = new DRStyle(); + this.textStyle.setForegroundColor(Color.BLACK); + this.textStyle.setPadding(new DRPadding(2)); + + this.columnTitleStyle = null; + this.columnStyle = null; + this.groupTitleStyle = null; + this.groupStyle = null; + this.subtotalStyle = null; + this.imageStyle = new DRStyle(); + this.imageStyle.setImageScale(ImageScale.RETAIN_SHAPE); + + this.pageWidth = PageType.A4.getWidth(); + this.pageHeight = PageType.A4.getHeight(); + this.pageOrientation = PageOrientation.PORTRAIT; + this.pageMargin = new DRMargin(10); + this.subreportPageMargin = new DRMargin(0); + this.pageColumnsPerPage = 1; + this.pageColumnSpace = 0; + this.ignorePageWidth = false; + + this.columnPrintRepeatedDetailValues = true; + this.columnWidth = 100; + + this.removeLineWhenBlank = false; + this.printInFirstWholeBand = false; + this.printWhenDetailOverflows = false; + + this.groupHeaderLayout = GroupHeaderLayout.VALUE; + this.groupHideColumn = true; + this.groupShowColumnHeaderAndFooter = false; + this.groupPadding = 10; + this.groupStartInNewPage = false; + this.groupStartInNewColumn = false; + this.groupReprintHeaderOnEachPage = false; + this.groupResetPageNumber = false; + this.groupMinHeightToStartNewPage = null; + this.groupFooterPosition = GroupFooterPosition.NORMAL; + this.groupKeepTogether = false; + this.groupHeaderWithSubtotal = false; + this.groupByDataType = false; + + this.subtotalLabelPosition = Position.TOP; + + this.tableOfContents = false; + this.tableOfContentsCustomizer = new TableOfContentsCustomizer(); + this.addGroupToTableOfContents = true; + this.tableOfContentsPosition = TableOfContentsPosition.TOP; + + this.textFieldWidth = 100; + this.textFieldPrintRepeatedValues = true; + this.textFieldStretchWithOverflow = true; + + this.imageWidth = 100; + this.imageHeight = 100; + + this.fillerWidth = 0; + this.fillerHeight = 0; + + this.lineWidth = 1; + this.lineHeight = 1; + + this.ellipseWidth = 100; + this.ellipseHeight = 100; + + this.rectangleRadius = null; + this.rectangleWidth = 100; + this.rectangleHeight = 100; + + this.mapWidth = 200; + this.mapHeight = 200; + + this.customComponentWidth = 200; + this.customComponentHeight = 200; + + this.breakWidth = 1; + this.breakHeight = 1; + + this.genericElementWidth = 100; + this.genericElementHeight = 100; + + this.listWidth = null; + this.listHeight = null; + this.listgap = 0; + this.horizontalCellComponentAlignment = HorizontalCellComponentAlignment.FLOAT; + this.verticalCellComponentAlignment = VerticalCellComponentAlignment.EXPAND; + + this.multiPageListWidth = 200; + this.multiPageListHeight = 0; + + this.subreportWidth = 200; + this.subreportHeight = 0; + + this.crosstabWidth = 200; + this.crosstabHeight = 0; + this.crosstabColumnGroupTotalPosition = CrosstabTotalPosition.END; + this.crosstabRowGroupTotalPosition = CrosstabTotalPosition.END; + this.crosstabColumnGroupShowTotal = true; + this.crosstabRowGroupShowTotal = true; + this.crosstabColumnGroupTotalHeaderMaxWidth = 150; + this.crosstabRowGroupHeaderMaxWidth = 150; + this.crosstabCellMaxWidth = 150; + this.crosstabHighlightOddRows = false; + this.crosstabOddRowStyle = new DRSimpleStyle(); + this.crosstabOddRowStyle.setBackgroundColor(new Color(200, 200, 200)); + this.crosstabHighlightEvenRows = false; + this.crosstabEvenRowStyle = new DRSimpleStyle(); + this.crosstabEvenRowStyle.setBackgroundColor(new Color(240, 240, 240)); + this.crosstabGroupStyle = null; + this.crosstabGroupTotalStyle = null; + this.crosstabGrandTotalStyle = null; + this.crosstabCellStyle = null; + this.crosstabMeasureTitleStyle = null; + this.crosstabPercentageType = CrosstabPercentageType.NONE; + + this.booleanComponentType = BooleanComponentType.TEXT_TRUE_FALSE; + this.booleanEmptyWhenNullValue = false; + this.booleanImageWidth = 14; + this.booleanImageHeight = 14; + this.booleanColumnStyle = null; + this.booleanHorizontalImageAlignment = HorizontalImageAlignment.CENTER; + + this.pageXofYHorizontalTextAlignment = HorizontalTextAlignment.CENTER; + + this.defaultSplitType = null; + this.titleSplitType = null; + this.pageHeaderSplitType = null; + this.pageFooterSplitType = null; + this.columnHeaderSplitType = null; + this.columnFooterSplitType = null; + this.groupHeaderSplitType = null; + this.groupFooterSplitType = null; + this.detailHeaderSplitType = null; + this.detailSplitType = null; + this.detailFooterSplitType = null; + this.lastPageFooterSplitType = null; + this.summarySplitType = null; + this.noDataSplitType = null; + this.backgroundSplitType = null; + + this.bandStyle = null; + + this.bandBackgroundComponent = null; + + this.font = new DRFont("SansSerif", 10); + + this.bigDecimalType = new DRDataType<>("#,##0.00#", HorizontalTextAlignment.RIGHT); + this.bigIntegerType = new DRDataType<>("#,##0", HorizontalTextAlignment.RIGHT); + this.byteType = new DRDataType<>("#,##0", HorizontalTextAlignment.RIGHT); + this.doubleType = new DRDataType<>("#,##0.#", HorizontalTextAlignment.RIGHT); + this.floatType = new DRDataType<>("#,##0.#", HorizontalTextAlignment.RIGHT); + this.integerType = new DRDataType<>("#,##0", HorizontalTextAlignment.RIGHT); + this.longType = new DRDataType<>("#,##0", HorizontalTextAlignment.RIGHT); + this.shortType = new DRDataType<>("#,##0", HorizontalTextAlignment.RIGHT); + this.dateType = new DRDataType<>("MM/dd/yyyy", HorizontalTextAlignment.RIGHT); + this.dateYearToMonthType = new DRDataType<>("MM/yyyy", HorizontalTextAlignment.RIGHT); + this.dateYearToHourType = new DRDataType<>("MM/dd/yyyy h a", HorizontalTextAlignment.RIGHT); + this.dateYearToMinuteType = new DRDataType<>("MM/dd/yyyy h:mm a", HorizontalTextAlignment.RIGHT); + this.dateYearToSecondType = new DRDataType<>("MM/dd/yyyy h:mm:ss a", HorizontalTextAlignment.RIGHT); + this.dateYearToFractionType = new DRDataType<>("MM/dd/yyyy h:mm:ss,SSS a", HorizontalTextAlignment.RIGHT); + this.dateYearType = new DRDataType<>("yyyy", HorizontalTextAlignment.RIGHT); + this.dateMonthType = new DRDataType<>("MMMM", HorizontalTextAlignment.RIGHT); + this.dateDayType = new DRDataType<>("dd", HorizontalTextAlignment.RIGHT); + this.timeHourToMinuteType = new DRDataType<>("h:mm a", HorizontalTextAlignment.RIGHT); + this.timeHourToSecondType = new DRDataType<>("h:mm:ss a", HorizontalTextAlignment.RIGHT); + this.timeHourToFractionType = new DRDataType<>("h:mm:ss,SSS a", HorizontalTextAlignment.RIGHT); + this.percentageType = new DRDataType<>("#,##0.00%", HorizontalTextAlignment.RIGHT); + this.booleanType = new DRDataType<>(null, HorizontalTextAlignment.CENTER); + this.characterType = new DRDataType<>(null, HorizontalTextAlignment.LEFT); + this.stringType = new DRDataType<>(null, HorizontalTextAlignment.LEFT); + + this.loadSystemFonts = true; + } + + /** + *

Getter for the field reportName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getReportName() + { + return this.reportName; + } + + /** + *

Getter for the field locale.

+ * + * @return a {@link java.util.Locale} object. + */ + public Locale getLocale() + { + return this.locale; + } + + /** + *

isShowColumnTitle.

+ * + * @return a boolean. + */ + public boolean isShowColumnTitle() + { + return this.showColumnTitle; + } + + /** + *

isShowColumnValues.

+ * + * @return a boolean. + */ + public boolean isShowColumnValues() + { + return this.showColumnValues; + } + + /** + *

isIgnorePagination.

+ * + * @return a boolean. + */ + public boolean isIgnorePagination() + { + return this.ignorePagination; + } + + /** + *

Getter for the field whenNoDataType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenNoDataType} object. + */ + public WhenNoDataType getWhenNoDataType() + { + return this.whenNoDataType; + } + + /** + *

Getter for the field whenResourceMissingType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + */ + public WhenResourceMissingType getWhenResourceMissingType() + { + return this.whenResourceMissingType; + } + + /** + *

isTitleOnANewPage.

+ * + * @return a boolean. + */ + public boolean isTitleOnANewPage() + { + return this.titleOnANewPage; + } + + /** + *

isSummaryOnANewPage.

+ * + * @return a boolean. + */ + public boolean isSummaryOnANewPage() + { + return this.summaryOnANewPage; + } + + /** + *

isSummaryWithPageHeaderAndFooter.

+ * + * @return a boolean. + */ + public boolean isSummaryWithPageHeaderAndFooter() + { + return this.summaryWithPageHeaderAndFooter; + } + + /** + *

isFloatColumnFooter.

+ * + * @return a boolean. + */ + public boolean isFloatColumnFooter() + { + return this.floatColumnFooter; + } + + /** + *

Getter for the field printOrder.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Orientation} object. + */ + public Orientation getPrintOrder() + { + return this.printOrder; + } + + /** + *

Getter for the field columnDirection.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public RunDirection getColumnDirection() + { + return this.columnDirection; + } + + /** + *

Getter for the field language.

+ * + * @return a {@link java.lang.String} object. + */ + public String getLanguage() + { + return this.language; + } + + /** + *

isUseFieldNameAsDescription.

+ * + * @return a boolean. + */ + public boolean isUseFieldNameAsDescription() + { + return this.useFieldNameAsDescription; + } + + /** + *

isHighlightDetailOddRows.

+ * + * @return a boolean. + */ + public boolean isHighlightDetailOddRows() + { + return this.highlightDetailOddRows; + } + + /** + *

Getter for the field detailOddRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public DRSimpleStyle getDetailOddRowStyle() + { + return this.detailOddRowStyle; + } + + /** + *

isHighlightDetailEvenRows.

+ * + * @return a boolean. + */ + public boolean isHighlightDetailEvenRows() + { + return this.highlightDetailEvenRows; + } + + /** + *

Getter for the field detailEvenRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public DRSimpleStyle getDetailEvenRowStyle() + { + return this.detailEvenRowStyle; + } + + /** + *

Getter for the field textStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getTextStyle() + { + return this.textStyle; + } + + /** + *

Getter for the field columnTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getColumnTitleStyle() + { + return this.columnTitleStyle; + } + + /** + *

Getter for the field columnStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getColumnStyle() + { + return this.columnStyle; + } + + /** + *

Getter for the field groupTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getGroupTitleStyle() + { + return this.groupTitleStyle; + } + + /** + *

Getter for the field groupStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getGroupStyle() + { + return this.groupStyle; + } + + /** + *

Getter for the field subtotalStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getSubtotalStyle() + { + return this.subtotalStyle; + } + + /** + *

Getter for the field imageStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getImageStyle() + { + return this.imageStyle; + } + + /** + *

Getter for the field pageWidth.

+ * + * @return a int. + */ + public int getPageWidth() + { + return this.pageWidth; + } + + /** + *

Getter for the field pageHeight.

+ * + * @return a int. + */ + public int getPageHeight() + { + return this.pageHeight; + } + + /** + *

Getter for the field pageOrientation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + */ + public PageOrientation getPageOrientation() + { + return this.pageOrientation; + } + + /** + *

Getter for the field pageMargin.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRMargin} object. + */ + public DRMargin getPageMargin() + { + return this.pageMargin; + } + + /** + *

Getter for the field subreportPageMargin.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.DRMargin} object. + */ + public DRMargin getSubreportPageMargin() + { + return this.subreportPageMargin; + } + + /** + *

Getter for the field pageColumnsPerPage.

+ * + * @return a int. + */ + public int getPageColumnsPerPage() + { + return this.pageColumnsPerPage; + } + + /** + *

Getter for the field pageColumnSpace.

+ * + * @return a int. + */ + public int getPageColumnSpace() + { + return this.pageColumnSpace; + } + + /** + *

isIgnorePageWidth.

+ * + * @return a boolean. + */ + public boolean isIgnorePageWidth() + { + return this.ignorePageWidth; + } + + /** + *

isColumnPrintRepeatedDetailValues.

+ * + * @return a boolean. + */ + public boolean isColumnPrintRepeatedDetailValues() + { + return this.columnPrintRepeatedDetailValues; + } + + /** + *

Getter for the field columnWidth.

+ * + * @return a int. + */ + public int getColumnWidth() + { + return this.columnWidth; + } + + /** + *

isRemoveLineWhenBlank.

+ * + * @return a boolean. + */ + public boolean isRemoveLineWhenBlank() + { + return this.removeLineWhenBlank; + } + + /** + *

isPrintInFirstWholeBand.

+ * + * @return a boolean. + */ + public boolean isPrintInFirstWholeBand() + { + return this.printInFirstWholeBand; + } + + /** + *

isPrintWhenDetailOverflows.

+ * + * @return a boolean. + */ + public boolean isPrintWhenDetailOverflows() + { + return this.printWhenDetailOverflows; + } + + /** + *

Getter for the field groupHeaderLayout.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.GroupHeaderLayout} object. + */ + public GroupHeaderLayout getGroupHeaderLayout() + { + return this.groupHeaderLayout; + } + + /** + *

isGroupHideColumn.

+ * + * @return a boolean. + */ + public boolean isGroupHideColumn() + { + return this.groupHideColumn; + } + + /** + *

isGroupShowColumnHeaderAndFooter.

+ * + * @return a boolean. + */ + public boolean isGroupShowColumnHeaderAndFooter() + { + return this.groupShowColumnHeaderAndFooter; + } + + /** + *

Getter for the field groupPadding.

+ * + * @return a int. + */ + public int getGroupPadding() + { + return this.groupPadding; + } + + /** + *

isGroupStartInNewPage.

+ * + * @return a boolean. + */ + public boolean isGroupStartInNewPage() + { + return this.groupStartInNewPage; + } + + /** + *

isGroupStartInNewColumn.

+ * + * @return a boolean. + */ + public boolean isGroupStartInNewColumn() + { + return this.groupStartInNewColumn; + } + + /** + *

isGroupReprintHeaderOnEachPage.

+ * + * @return a boolean. + */ + public boolean isGroupReprintHeaderOnEachPage() + { + return this.groupReprintHeaderOnEachPage; + } + + /** + *

isGroupResetPageNumber.

+ * + * @return a boolean. + */ + public boolean isGroupResetPageNumber() + { + return this.groupResetPageNumber; + } + + /** + *

Getter for the field groupMinHeightToStartNewPage.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getGroupMinHeightToStartNewPage() + { + return this.groupMinHeightToStartNewPage; + } + + /** + *

Getter for the field groupFooterPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.GroupFooterPosition} object. + */ + public GroupFooterPosition getGroupFooterPosition() + { + return this.groupFooterPosition; + } + + /** + *

isGroupKeepTogether.

+ * + * @return a boolean. + */ + public boolean isGroupKeepTogether() + { + return this.groupKeepTogether; + } + + /** + *

isGroupHeaderWithSubtotal.

+ * + * @return a boolean. + */ + public boolean isGroupHeaderWithSubtotal() + { + return this.groupHeaderWithSubtotal; + } + + /** + *

isGroupByDataType.

+ * + * @return a boolean. + */ + public boolean isGroupByDataType() + { + return this.groupByDataType; + } + + /** + *

Getter for the field subtotalLabelPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Position} object. + */ + public Position getSubtotalLabelPosition() + { + return this.subtotalLabelPosition; + } + + /** + *

isTableOfContents.

+ * + * @return a boolean. + */ + public boolean isTableOfContents() + { + return this.tableOfContents; + } + + /** + *

Getter for the field tableOfContentsCustomizer.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer} object. + */ + public DRITableOfContentsCustomizer getTableOfContentsCustomizer() + { + return this.tableOfContentsCustomizer; + } + + /** + *

isAddGroupToTableOfContents.

+ * + * @return a boolean. + */ + public boolean isAddGroupToTableOfContents() + { + return this.addGroupToTableOfContents; + } + + /** + *

Getter for the field tableOfContentsPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.TableOfContentsPosition} object. + */ + public TableOfContentsPosition getTableOfContentsPosition() + { + return this.tableOfContentsPosition; + } + + /** + *

Getter for the field textFieldWidth.

+ * + * @return a int. + */ + public int getTextFieldWidth() + { + return this.textFieldWidth; + } + + /** + *

isTextFieldPrintRepeatedValues.

+ * + * @return a boolean. + */ + public boolean isTextFieldPrintRepeatedValues() + { + return this.textFieldPrintRepeatedValues; + } + + /** + *

isTextFieldStretchWithOverflow.

+ * + * @return a boolean. + * @deprecated replaced by {@link #getTextFieldTextAdjust(DRITextField)} + */ + @Deprecated + public boolean isTextFieldStretchWithOverflow() + { + return this.textFieldStretchWithOverflow; + } + + /** + *

getTextFieldTextAdjust.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + public TextAdjust getTextFieldTextAdjust() + { + return null; + } + + /** + *

Getter for the field imageWidth.

+ * + * @return a int. + */ + public int getImageWidth() + { + return this.imageWidth; + } + + /** + *

Getter for the field imageHeight.

+ * + * @return a int. + */ + public int getImageHeight() + { + return this.imageHeight; + } + + /** + *

Getter for the field fillerWidth.

+ * + * @return a int. + */ + public int getFillerWidth() + { + return this.fillerWidth; + } + + /** + *

Getter for the field fillerHeight.

+ * + * @return a int. + */ + public int getFillerHeight() + { + return this.fillerHeight; + } + + /** + *

Getter for the field lineWidth.

+ * + * @return a int. + */ + public int getLineWidth() + { + return this.lineWidth; + } + + /** + *

Getter for the field lineHeight.

+ * + * @return a int. + */ + public int getLineHeight() + { + return this.lineHeight; + } + + /** + *

Getter for the field ellipseWidth.

+ * + * @return a int. + */ + public int getEllipseWidth() + { + return this.ellipseWidth; + } + + /** + *

Getter for the field ellipseHeight.

+ * + * @return a int. + */ + public int getEllipseHeight() + { + return this.ellipseHeight; + } + + /** + *

Getter for the field rectangleRadius.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getRectangleRadius() + { + return this.rectangleRadius; + } + + /** + *

Getter for the field rectangleWidth.

+ * + * @return a int. + */ + public int getRectangleWidth() + { + return this.rectangleWidth; + } + + /** + *

Getter for the field rectangleHeight.

+ * + * @return a int. + */ + public int getRectangleHeight() + { + return this.rectangleHeight; + } + + /** + *

Getter for the field mapWidth.

+ * + * @return a int. + */ + public int getMapWidth() + { + return this.mapWidth; + } + + /** + *

Getter for the field mapHeight.

+ * + * @return a int. + */ + public int getMapHeight() + { + return this.mapHeight; + } + + /** + *

Getter for the field customComponentWidth.

+ * + * @return a int. + */ + public int getCustomComponentWidth() + { + return this.customComponentWidth; + } + + /** + *

Getter for the field customComponentHeight.

+ * + * @return a int. + */ + public int getCustomComponentHeight() + { + return this.customComponentHeight; + } + + /** + *

Getter for the field breakWidth.

+ * + * @return a int. + */ + public int getBreakWidth() + { + return this.breakWidth; + } + + /** + *

Getter for the field breakHeight.

+ * + * @return a int. + */ + public int getBreakHeight() + { + return this.breakHeight; + } + + /** + *

Getter for the field genericElementWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getGenericElementWidth() + { + return this.genericElementWidth; + } + + /** + *

Getter for the field genericElementHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getGenericElementHeight() + { + return this.genericElementHeight; + } + + /** + *

Getter for the field listWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getListWidth() + { + return this.listWidth; + } + + /** + *

Getter for the field listHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getListHeight() + { + return this.listHeight; + } + + /** + *

Getter for the field listgap.

+ * + * @return a int. + */ + public int getListgap() + { + return this.listgap; + } + + /** + *

Getter for the field horizontalCellComponentAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + */ + public HorizontalCellComponentAlignment getHorizontalCellComponentAlignment() + { + return this.horizontalCellComponentAlignment; + } + + /** + *

Getter for the field verticalCellComponentAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + */ + public VerticalCellComponentAlignment getVerticalCellComponentAlignment() + { + return this.verticalCellComponentAlignment; + } + + /** + *

Getter for the field multiPageListWidth.

+ * + * @return a int. + */ + public int getMultiPageListWidth() + { + return this.multiPageListWidth; + } + + /** + *

Getter for the field multiPageListHeight.

+ * + * @return a int. + */ + public int getMultiPageListHeight() + { + return this.multiPageListHeight; + } + + /** + *

Getter for the field subreportWidth.

+ * + * @return a int. + */ + public int getSubreportWidth() + { + return this.subreportWidth; + } + + /** + *

Getter for the field subreportHeight.

+ * + * @return a int. + */ + public int getSubreportHeight() + { + return this.subreportHeight; + } + + /** + *

Getter for the field crosstabWidth.

+ * + * @return a int. + */ + public int getCrosstabWidth() + { + return this.crosstabWidth; + } + + /** + *

Getter for the field crosstabHeight.

+ * + * @return a int. + */ + public int getCrosstabHeight() + { + return this.crosstabHeight; + } + + /** + *

Getter for the field crosstabColumnGroupTotalPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.CrosstabTotalPosition} object. + */ + public CrosstabTotalPosition getCrosstabColumnGroupTotalPosition() + { + return this.crosstabColumnGroupTotalPosition; + } + + /** + *

Getter for the field crosstabRowGroupTotalPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.CrosstabTotalPosition} object. + */ + public CrosstabTotalPosition getCrosstabRowGroupTotalPosition() + { + return this.crosstabRowGroupTotalPosition; + } + + /** + *

isCrosstabColumnGroupShowTotal.

+ * + * @return a boolean. + */ + public boolean isCrosstabColumnGroupShowTotal() + { + return this.crosstabColumnGroupShowTotal; + } + + /** + *

isCrosstabRowGroupShowTotal.

+ * + * @return a boolean. + */ + public boolean isCrosstabRowGroupShowTotal() + { + return this.crosstabRowGroupShowTotal; + } + + /** + *

Getter for the field crosstabColumnGroupTotalHeaderMaxWidth.

+ * + * @return a int. + */ + public int getCrosstabColumnGroupTotalHeaderMaxWidth() + { + return this.crosstabColumnGroupTotalHeaderMaxWidth; + } + + /** + *

Getter for the field crosstabRowGroupHeaderMaxWidth.

+ * + * @return a int. + */ + public int getCrosstabRowGroupHeaderMaxWidth() + { + return this.crosstabRowGroupHeaderMaxWidth; + } + + /** + *

Getter for the field crosstabCellMaxWidth.

+ * + * @return a int. + */ + public int getCrosstabCellMaxWidth() + { + return this.crosstabCellMaxWidth; + } + + /** + *

Getter for the field crosstabOddRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public DRSimpleStyle getCrosstabOddRowStyle() + { + return this.crosstabOddRowStyle; + } + + /** + *

Getter for the field crosstabEvenRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRSimpleStyle} object. + */ + public DRSimpleStyle getCrosstabEvenRowStyle() + { + return this.crosstabEvenRowStyle; + } + + /** + *

isCrosstabHighlightOddRows.

+ * + * @return a boolean. + */ + public boolean isCrosstabHighlightOddRows() + { + return this.crosstabHighlightOddRows; + } + + /** + *

isCrosstabHighlightEvenRows.

+ * + * @return a boolean. + */ + public boolean isCrosstabHighlightEvenRows() + { + return this.crosstabHighlightEvenRows; + } + + /** + *

Getter for the field crosstabGroupStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getCrosstabGroupStyle() + { + return this.crosstabGroupStyle; + } + + /** + *

Getter for the field crosstabGroupTotalStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getCrosstabGroupTotalStyle() + { + return this.crosstabGroupTotalStyle; + } + + /** + *

Getter for the field crosstabGrandTotalStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getCrosstabGrandTotalStyle() + { + return this.crosstabGrandTotalStyle; + } + + /** + *

Getter for the field crosstabCellStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getCrosstabCellStyle() + { + return this.crosstabCellStyle; + } + + /** + *

Getter for the field crosstabMeasureTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRStyle} object. + */ + public DRStyle getCrosstabMeasureTitleStyle() + { + return this.crosstabMeasureTitleStyle; + } + + /** + *

Getter for the field crosstabPercentageType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.CrosstabPercentageType} object. + */ + public CrosstabPercentageType getCrosstabPercentageType() + { + return this.crosstabPercentageType; + } + + /** + *

Getter for the field booleanComponentType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.BooleanComponentType} object. + */ + public BooleanComponentType getBooleanComponentType() + { + return this.booleanComponentType; + } + + /** + *

isBooleanEmptyWhenNullValue.

+ * + * @return a boolean. + */ + public boolean isBooleanEmptyWhenNullValue() + { + return this.booleanEmptyWhenNullValue; + } + + /** + *

Getter for the field booleanImageWidth.

+ * + * @return a int. + */ + public int getBooleanImageWidth() + { + return this.booleanImageWidth; + } + + /** + *

Getter for the field booleanImageHeight.

+ * + * @return a int. + */ + public int getBooleanImageHeight() + { + return this.booleanImageHeight; + } + + /** + *

Getter for the field booleanColumnStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIStyle} object. + */ + public DRIStyle getBooleanColumnStyle() + { + return this.booleanColumnStyle; + } + + /** + *

Getter for the field booleanHorizontalImageAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public HorizontalImageAlignment getBooleanHorizontalImageAlignment() + { + return this.booleanHorizontalImageAlignment; + } + + /** + *

Getter for the field defaultSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getDefaultSplitType() + { + return this.defaultSplitType; + } + + /** + *

Getter for the field titleSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getTitleSplitType() + { + return this.titleSplitType; + } + + /** + *

Getter for the field pageHeaderSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getPageHeaderSplitType() + { + return this.pageHeaderSplitType; + } + + /** + *

Getter for the field pageFooterSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getPageFooterSplitType() + { + return this.pageFooterSplitType; + } + + /** + *

Getter for the field columnHeaderSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getColumnHeaderSplitType() + { + return this.columnHeaderSplitType; + } + + /** + *

Getter for the field columnFooterSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getColumnFooterSplitType() + { + return this.columnFooterSplitType; + } + + /** + *

Getter for the field groupHeaderSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getGroupHeaderSplitType() + { + return this.groupHeaderSplitType; + } + + /** + *

Getter for the field groupFooterSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getGroupFooterSplitType() + { + return this.groupFooterSplitType; + } + + /** + *

Getter for the field detailHeaderSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getDetailHeaderSplitType() + { + return this.detailHeaderSplitType; + } + + /** + *

Getter for the field detailSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getDetailSplitType() + { + return this.detailSplitType; + } + + /** + *

Getter for the field detailFooterSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getDetailFooterSplitType() + { + return this.detailFooterSplitType; + } + + /** + *

Getter for the field lastPageFooterSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getLastPageFooterSplitType() + { + return this.lastPageFooterSplitType; + } + + /** + *

Getter for the field summarySplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getSummarySplitType() + { + return this.summarySplitType; + } + + /** + *

Getter for the field noDataSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getNoDataSplitType() + { + return this.noDataSplitType; + } + + /** + *

Getter for the field backgroundSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getBackgroundSplitType() + { + return this.backgroundSplitType; + } + + /** + *

Getter for the field bandStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIStyle} object. + */ + public DRIStyle getBandStyle() + { + return this.bandStyle; + } + + /** + *

Getter for the field bandBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getBandBackgroundComponent() + { + return this.bandBackgroundComponent; + } + + /** + *

Getter for the field font.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.style.DRFont} object. + */ + public DRFont getFont() + { + return this.font; + } + + /** + *

Getter for the field bigDecimalType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getBigDecimalType() + { + return this.bigDecimalType; + } + + /** + *

Getter for the field bigIntegerType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getBigIntegerType() + { + return this.bigIntegerType; + } + + /** + *

Getter for the field byteType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getByteType() + { + return this.byteType; + } + + /** + *

Getter for the field doubleType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getDoubleType() + { + return this.doubleType; + } + + /** + *

Getter for the field floatType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getFloatType() + { + return this.floatType; + } + + /** + *

Getter for the field integerType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getIntegerType() + { + return this.integerType; + } + + /** + *

Getter for the field longType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getLongType() + { + return this.longType; + } + + /** + *

Getter for the field shortType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getShortType() + { + return this.shortType; + } + + /** + *

Getter for the field dateType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getDateType() + { + return this.dateType; + } + + /** + *

Getter for the field dateYearToMonthType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getDateYearToMonthType() + { + return this.dateYearToMonthType; + } + + /** + *

Getter for the field dateYearToHourType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getDateYearToHourType() + { + return this.dateYearToHourType; + } + + /** + *

Getter for the field dateYearToMinuteType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getDateYearToMinuteType() + { + return this.dateYearToMinuteType; + } + + /** + *

Getter for the field dateYearToSecondType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getDateYearToSecondType() + { + return this.dateYearToSecondType; + } + + /** + *

Getter for the field dateYearToFractionType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getDateYearToFractionType() + { + return this.dateYearToFractionType; + } + + /** + *

Getter for the field dateYearType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getDateYearType() + { + return this.dateYearType; + } + + /** + *

Getter for the field dateMonthType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getDateMonthType() + { + return this.dateMonthType; + } + + /** + *

Getter for the field dateDayType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getDateDayType() + { + return this.dateDayType; + } + + /** + *

Getter for the field timeHourToMinuteType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getTimeHourToMinuteType() + { + return this.timeHourToMinuteType; + } + + /** + *

Getter for the field timeHourToSecondType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getTimeHourToSecondType() + { + return this.timeHourToSecondType; + } + + /** + *

Getter for the field timeHourToFractionType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getTimeHourToFractionType() + { + return this.timeHourToFractionType; + } + + /** + *

Getter for the field percentageType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getPercentageType() + { + return this.percentageType; + } + + /** + *

Getter for the field booleanType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getBooleanType() + { + return this.booleanType; + } + + /** + *

Getter for the field characterType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getCharacterType() + { + return this.characterType; + } + + /** + *

Getter for the field stringType.

+ * + * @return a {@link software.xdev.dynamicreports.report.base.datatype.DRDataType} object. + */ + public DRDataType getStringType() + { + return this.stringType; + } + + /** + *

Getter for the field pageXofYHorizontalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public HorizontalTextAlignment getPageXofYHorizontalTextAlignment() + { + return this.pageXofYHorizontalTextAlignment; + } + + /** + *

isLoadSystemFonts.

+ * + * @return a boolean. + */ + public boolean isLoadSystemFonts() + { + return this.loadSystemFonts; + } + + /** + *

Setter for the field loadSystemFonts.

+ * + * @param loadSystemFonts a boolean. + */ + protected void setLoadSystemFonts(final boolean loadSystemFonts) + { + this.loadSystemFonts = loadSystemFonts; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/defaults/Defaults.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/defaults/Defaults.java new file mode 100644 index 0000000..d2e1f87 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/defaults/Defaults.java @@ -0,0 +1,42 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.defaults; + +import java.util.ServiceLoader; + + +public final class Defaults +{ + private static Default instance = ServiceLoader.load(Default.class) + .findFirst() + .orElseGet(Default::new); + + private Defaults() + { + } + + public static Default getDefaults() + { + return instance; + } + + public static void setDefault(final Default d) + { + instance = d; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIBand.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIBand.java new file mode 100644 index 0000000..fa95f8c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIBand.java @@ -0,0 +1,54 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.definition.component.DRIList; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.io.Serializable; + +/** + *

DRIBand interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIBand extends Serializable { + + /** + *

getSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getSplitType(); + + /** + *

getList.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIList} object. + */ + public DRIList getList(); + + /** + *

getPrintWhenExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getPrintWhenExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRICrosstabValue.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRICrosstabValue.java new file mode 100644 index 0000000..30dc7e7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRICrosstabValue.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +/** + *

DRICrosstabValue interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRICrosstabValue extends DRIValue { + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRICustomValues.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRICustomValues.java new file mode 100644 index 0000000..dd0beed --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRICustomValues.java @@ -0,0 +1,75 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.jasper.base.tableofcontents.JasperTocHeading; + +import java.io.Serializable; +import java.util.Map; + +/** + *

DRICustomValues interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRICustomValues extends Serializable { + /** + * Constant NAME="CUSTOM_VALUES" + */ + public static final String NAME = "CUSTOM_VALUES"; + + /** + *

setSystemValue.

+ * + * @param name a {@link java.lang.String} object. + * @param value a {@link java.lang.Object} object. + */ + public void setSystemValue(String name, Object value); + + /** + *

addTocHeading.

+ * + * @param level a int. + * @param id a {@link java.lang.String} object. + * @param text a {@link java.lang.String} object. + * @param customValue a {@link java.lang.Object} object. + */ + public void addTocHeading(int level, String id, String text, Object customValue); + + /** + *

getTocHeadings.

+ * + * @return a {@link java.util.Map} object. + */ + public Map getTocHeadings(); + + /** + *

setTocHeadings.

+ * + * @param tocHeadings a {@link java.util.Map} object. + */ + public void setTocHeadings(Map tocHeadings); + + /** + *

setSubreportWidth.

+ * + * @param subreportWidth a {@link java.lang.Integer} object. + */ + public void setSubreportWidth(Integer subreportWidth); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIDataset.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIDataset.java new file mode 100644 index 0000000..84539bc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIDataset.java @@ -0,0 +1,82 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.io.Serializable; +import java.sql.Connection; +import java.util.List; + +/** + *

DRIDataset interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDataset extends Serializable { + + /** + *

getFields.

+ * + * @return a {@link java.util.List} object. + */ + public List> getFields(); + + /** + *

getVariables.

+ * + * @return a {@link java.util.List} object. + */ + public List> getVariables(); + + /** + *

getSorts.

+ * + * @return a {@link java.util.List} object. + */ + public List getSorts(); + + /** + *

getQuery.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIQuery} object. + */ + public DRIQuery getQuery(); + + /** + *

getConnectionExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getConnectionExpression(); + + /** + *

getDataSourceExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getDataSourceExpression(); + + /** + *

getFilterExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getFilterExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIField.java new file mode 100644 index 0000000..069f052 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIField.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRIField interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIField extends DRIExpression, DRIValue { + + /** + *

getDataType.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + */ + public DRIDataType getDataType(); + + /** + *

getDescription.

+ * + * @return a {@link java.lang.String} object. + */ + public String getDescription(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIGroup.java new file mode 100644 index 0000000..7537916 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIGroup.java @@ -0,0 +1,189 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.definition.component.DRITextField; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +import java.io.Serializable; + +/** + *

DRIGroup interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIGroup extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getValueField.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRITextField} object. + */ + public DRITextField getValueField(); + + /** + *

getTitleExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getTitleExpression(); + + /** + *

getTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getTitleStyle(); + + /** + *

getTitleWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getTitleWidth(); + + /** + *

getHeaderLayout.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.GroupHeaderLayout} object. + */ + public GroupHeaderLayout getHeaderLayout(); + + /** + *

getHideColumn.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getHideColumn(); + + /** + *

getGroupByDataType.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getGroupByDataType(); + + /** + *

getShowColumnHeaderAndFooter.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getShowColumnHeaderAndFooter(); + + /** + *

getAddToTableOfContents.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getAddToTableOfContents(); + + /** + *

getPrintSubtotalsWhenExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getPrintSubtotalsWhenExpression(); + + /** + *

getPadding.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPadding(); + + /** + *

getStartInNewPage.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getStartInNewPage(); + + /** + *

getStartInNewColumn.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getStartInNewColumn(); + + /** + *

getReprintHeaderOnEachPage.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getReprintHeaderOnEachPage(); + + /** + *

getResetPageNumber.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getResetPageNumber(); + + /** + *

getMinHeightToStartNewPage.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getMinHeightToStartNewPage(); + + /** + *

getFooterPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.GroupFooterPosition} object. + */ + public GroupFooterPosition getFooterPosition(); + + /** + *

getKeepTogether.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getKeepTogether(); + + /** + *

getHeaderWithSubtotal.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getHeaderWithSubtotal(); + + /** + *

getHeaderBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getHeaderBand(); + + /** + *

getFooterBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getFooterBand(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIHyperLink.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIHyperLink.java new file mode 100644 index 0000000..d9495d0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIHyperLink.java @@ -0,0 +1,73 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.io.Serializable; + +/** + *

DRIHyperLink interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIHyperLink extends Serializable { + + /** + *

getAnchorExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getAnchorExpression(); + + /** + *

getPageExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getPageExpression(); + + /** + *

getReferenceExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getReferenceExpression(); + + /** + *

getTooltipExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getTooltipExpression(); + + /** + *

getType.

+ * + * @return a {@link java.lang.String} object. + */ + public String getType(); + + /** + *

getTarget.

+ * + * @return a {@link java.lang.String} object. + */ + public String getTarget(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIMargin.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIMargin.java new file mode 100644 index 0000000..a57faa5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIMargin.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import java.io.Serializable; + +/** + *

DRIMargin interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIMargin extends Serializable { + + /** + *

getTop.

+ * + * @return a int. + */ + public int getTop(); + + /** + *

getLeft.

+ * + * @return a int. + */ + public int getLeft(); + + /** + *

getBottom.

+ * + * @return a int. + */ + public int getBottom(); + + /** + *

getRight.

+ * + * @return a int. + */ + public int getRight(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIPage.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIPage.java new file mode 100644 index 0000000..257d5ee --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIPage.java @@ -0,0 +1,80 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.report.constant.PageOrientation; + +import java.io.Serializable; + +/** + *

DRIPage interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIPage extends Serializable { + + /** + *

getWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getWidth(); + + /** + *

getHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getHeight(); + + /** + *

getOrientation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + */ + public PageOrientation getOrientation(); + + /** + *

getMargin.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIMargin} object. + */ + public DRIMargin getMargin(); + + /** + *

getColumnsPerPage.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getColumnsPerPage(); + + /** + *

getColumnSpace.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getColumnSpace(); + + /** + *

getIgnorePageWidth.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnorePageWidth(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIParameter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIParameter.java new file mode 100644 index 0000000..85c8a67 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIParameter.java @@ -0,0 +1,47 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import java.io.Serializable; + +/** + *

DRIParameter interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIParameter extends DRIValue, Serializable { + + /** {@inheritDoc} */ + @Override + public String getName(); + + /** + *

getValueClass.

+ * + * @return a {@link java.lang.Class} object. + */ + public Class getValueClass(); + + /** + *

getValue.

+ * + * @return a T object. + */ + public T getValue(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIQuery.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIQuery.java new file mode 100644 index 0000000..2eeccd6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIQuery.java @@ -0,0 +1,43 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import java.io.Serializable; + +/** + *

DRIQuery interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIQuery extends Serializable { + + /** + *

getText.

+ * + * @return a {@link java.lang.String} object. + */ + public String getText(); + + /** + *

getLanguage.

+ * + * @return a {@link java.lang.String} object. + */ + public String getLanguage(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIReport.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIReport.java new file mode 100644 index 0000000..c6a8c32 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIReport.java @@ -0,0 +1,474 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import java.io.Serializable; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; + +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.column.DRIColumn; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGrid; +import software.xdev.dynamicreports.report.definition.style.DRIConditionalStyle; +import software.xdev.dynamicreports.report.definition.style.DRIFont; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.definition.style.DRISimpleStyle; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; + +/** + *

DRIReport interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIReport extends Serializable { + + /** + *

getTemplate.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIReportTemplate} object. + */ + public DRIReportTemplate getTemplate(); + + /** + *

getTemplateStyles.

+ * + * @return a {@link java.util.List} object. + */ + public List getTemplateStyles(); + + /** + *

getTemplateDesign.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRITemplateDesign} object. + */ + public DRITemplateDesign getTemplateDesign(); + + /** + *

getReportName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getReportName(); + + /** + *

getLocale.

+ * + * @return a {@link java.util.Locale} object. + */ + public Locale getLocale(); + + /** + *

getResourceBundle.

+ * + * @return a {@link java.util.ResourceBundle} object. + */ + public ResourceBundle getResourceBundle(); + + /** + *

getResourceBundleName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getResourceBundleName(); + + /** + *

getShowColumnTitle.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getShowColumnTitle(); + + /** + *

getShowColumnValues.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getShowColumnValues(); + + /** + *

getColumns.

+ * + * @return a {@link java.util.List} object. + */ + public List> getColumns(); + + /** + *

getGroups.

+ * + * @return a {@link java.util.List} object. + */ + public List getGroups(); + + /** + *

getFields.

+ * + * @return a {@link java.util.List} object. + */ + public List> getFields(); + + /** + *

getVariables.

+ * + * @return a {@link java.util.List} object. + */ + public List> getVariables(); + + /** + *

getSorts.

+ * + * @return a {@link java.util.List} object. + */ + public List getSorts(); + + /** + *

getSubtotals.

+ * + * @return a {@link java.util.List} object. + */ + public List> getSubtotals(); + + /** + *

getParameters.

+ * + * @return a {@link java.util.List} object. + */ + public List> getParameters(); + + /** + *

getParameterValues.

+ * + * @return a {@link java.util.Map} object. + */ + public Map getParameterValues(); + + /** + *

getScriptlets.

+ * + * @return a {@link java.util.List} object. + */ + public List getScriptlets(); + + /** + *

getProperties.

+ * + * @return a {@link java.util.Properties} object. + */ + public Properties getProperties(); + + /** + *

getQuery.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIQuery} object. + */ + public DRIQuery getQuery(); + + /** + *

getPage.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIPage} object. + */ + public DRIPage getPage(); + + /** + *

getIgnorePagination.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnorePagination(); + + /** + *

getWhenNoDataType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenNoDataType} object. + */ + public WhenNoDataType getWhenNoDataType(); + + /** + *

getWhenResourceMissingType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + */ + public WhenResourceMissingType getWhenResourceMissingType(); + + /** + *

getTitleOnANewPage.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getTitleOnANewPage(); + + /** + *

getSummaryOnANewPage.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getSummaryOnANewPage(); + + /** + *

getSummaryWithPageHeaderAndFooter.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getSummaryWithPageHeaderAndFooter(); + + /** + *

getFloatColumnFooter.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getFloatColumnFooter(); + + /** + *

getPrintOrder.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Orientation} object. + */ + public Orientation getPrintOrder(); + + /** + *

getColumnDirection.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public RunDirection getColumnDirection(); + + /** + *

getLanguage.

+ * + * @return a {@link java.lang.String} object. + */ + public String getLanguage(); + + /** + *

getUseFieldNameAsDescription.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getUseFieldNameAsDescription(); + + /** + *

getDefaultFont.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIFont} object. + */ + public DRIFont getDefaultFont(); + + /** + *

getTextStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getTextStyle(); + + /** + *

getColumnTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getColumnTitleStyle(); + + /** + *

getColumnStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getColumnStyle(); + + /** + *

getGroupTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getGroupTitleStyle(); + + /** + *

getGroupStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getGroupStyle(); + + /** + *

getSubtotalStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getSubtotalStyle(); + + /** + *

getImageStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getImageStyle(); + + /** + *

getHighlightDetailOddRows.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getHighlightDetailOddRows(); + + /** + *

getDetailOddRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + public DRISimpleStyle getDetailOddRowStyle(); + + /** + *

getHighlightDetailEvenRows.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getHighlightDetailEvenRows(); + + /** + *

getDetailEvenRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + public DRISimpleStyle getDetailEvenRowStyle(); + + /** + *

getDetailRowHighlighters.

+ * + * @return a {@link java.util.List} object. + */ + public List getDetailRowHighlighters(); + + /** + *

getColumnGrid.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.grid.DRIColumnGrid} object. + */ + public DRIColumnGrid getColumnGrid(); + + /** + *

getTableOfContents.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getTableOfContents(); + + /** + *

getTableOfContentsCustomizer.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer} object. + */ + public DRITableOfContentsCustomizer getTableOfContentsCustomizer(); + + /** + *

getFilterExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getFilterExpression(); + + /** + *

getTitleBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getTitleBand(); + + /** + *

getPageHeaderBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getPageHeaderBand(); + + /** + *

getPageFooterBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getPageFooterBand(); + + /** + *

getColumnHeaderBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getColumnHeaderBand(); + + /** + *

getColumnFooterBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getColumnFooterBand(); + + /** + *

getDetailBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getDetailBand(); + + /** + *

getDetailHeaderBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getDetailHeaderBand(); + + /** + *

getDetailFooterBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getDetailFooterBand(); + + /** + *

getLastPageFooterBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getLastPageFooterBand(); + + /** + *

getSummaryBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getSummaryBand(); + + /** + *

getNoDataBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getNoDataBand(); + + /** + *

getBackgroundBand.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIBand} object. + */ + public DRIBand getBackgroundBand(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIReportTemplate.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIReportTemplate.java new file mode 100644 index 0000000..e867229 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIReportTemplate.java @@ -0,0 +1,867 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import java.io.Serializable; +import java.util.List; +import java.util.Locale; + +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.Position; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.style.DRIFont; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.definition.style.DRISimpleStyle; +import software.xdev.dynamicreports.report.definition.style.DRIStyle; + +/** + *

DRIReportTemplate interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIReportTemplate extends Serializable { + + /** + *

getTemplateStyles.

+ * + * @return a {@link java.util.List} object. + */ + public List getTemplateStyles(); + + /** + *

getLocale.

+ * + * @return a {@link java.util.Locale} object. + */ + public Locale getLocale(); + + /** + *

getShowColumnTitle.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getShowColumnTitle(); + + /** + *

getShowColumnValues.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getShowColumnValues(); + + /** + *

getIgnorePagination.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnorePagination(); + + /** + *

getWhenNoDataType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenNoDataType} object. + */ + public WhenNoDataType getWhenNoDataType(); + + /** + *

getWhenResourceMissingType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + */ + public WhenResourceMissingType getWhenResourceMissingType(); + + /** + *

getTitleOnANewPage.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getTitleOnANewPage(); + + /** + *

getSummaryOnANewPage.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getSummaryOnANewPage(); + + /** + *

getSummaryWithPageHeaderAndFooter.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getSummaryWithPageHeaderAndFooter(); + + /** + *

getFloatColumnFooter.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getFloatColumnFooter(); + + /** + *

getPrintOrder.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Orientation} object. + */ + public Orientation getPrintOrder(); + + /** + *

getColumnDirection.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public RunDirection getColumnDirection(); + + /** + *

getLanguage.

+ * + * @return a {@link java.lang.String} object. + */ + public String getLanguage(); + + /** + *

getUseFieldNameAsDescription.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getUseFieldNameAsDescription(); + + /** + *

getHighlightDetailOddRows.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getHighlightDetailOddRows(); + + /** + *

getDetailOddRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + public DRISimpleStyle getDetailOddRowStyle(); + + /** + *

getHighlightDetailEvenRows.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getHighlightDetailEvenRows(); + + /** + *

getDetailEvenRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + public DRISimpleStyle getDetailEvenRowStyle(); + + /** + *

getDefaultFont.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIFont} object. + */ + public DRIFont getDefaultFont(); + + /** + *

getTextStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getTextStyle(); + + /** + *

getColumnTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getColumnTitleStyle(); + + /** + *

getColumnStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getColumnStyle(); + + /** + *

getGroupTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getGroupTitleStyle(); + + /** + *

getGroupStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getGroupStyle(); + + /** + *

getSubtotalStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getSubtotalStyle(); + + /** + *

getImageStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getImageStyle(); + + /** + *

getPageWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageWidth(); + + /** + *

getPageHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageHeight(); + + /** + *

getPageOrientation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + */ + public PageOrientation getPageOrientation(); + + /** + *

getPageMargin.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIMargin} object. + */ + public DRIMargin getPageMargin(); + + /** + *

getPageColumnsPerPage.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageColumnsPerPage(); + + /** + *

getPageColumnSpace.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageColumnSpace(); + + /** + *

getIgnorePageWidth.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnorePageWidth(); + + /** + *

getColumnPrintRepeatedDetailValues.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getColumnPrintRepeatedDetailValues(); + + /** + *

getColumnWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getColumnWidth(); + + /** + *

getGroupHeaderLayout.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.GroupHeaderLayout} object. + */ + public GroupHeaderLayout getGroupHeaderLayout(); + + /** + *

getGroupHideColumn.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getGroupHideColumn(); + + /** + *

getGroupShowColumnHeaderAndFooter.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getGroupShowColumnHeaderAndFooter(); + + /** + *

getGroupPadding.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getGroupPadding(); + + /** + *

getGroupStartInNewPage.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getGroupStartInNewPage(); + + /** + *

getGroupStartInNewColumn.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getGroupStartInNewColumn(); + + /** + *

getGroupReprintHeaderOnEachPage.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getGroupReprintHeaderOnEachPage(); + + /** + *

getGroupResetPageNumber.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getGroupResetPageNumber(); + + /** + *

getGroupFooterPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.GroupFooterPosition} object. + */ + public GroupFooterPosition getGroupFooterPosition(); + + /** + *

getGroupKeepTogether.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getGroupKeepTogether(); + + /** + *

getGroupHeaderWithSubtotal.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getGroupHeaderWithSubtotal(); + + /** + *

getSubtotalLabelPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Position} object. + */ + public Position getSubtotalLabelPosition(); + + /** + *

getTableOfContents.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getTableOfContents(); + + /** + *

getTableOfContentsCustomizer.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRITableOfContentsCustomizer} object. + */ + public DRITableOfContentsCustomizer getTableOfContentsCustomizer(); + + /** + *

getTextFieldWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getTextFieldWidth(); + + /** + *

getImageHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getImageHeight(); + + /** + *

getImageWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getImageWidth(); + + /** + *

getListgap.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getListgap(); + + /** + *

getMultiPageListHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getMultiPageListHeight(); + + /** + *

getMultiPageListWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getMultiPageListWidth(); + + /** + *

getSubreportHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getSubreportHeight(); + + /** + *

getSubreportWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getSubreportWidth(); + + /** + *

getCrosstabHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getCrosstabHeight(); + + /** + *

getCrosstabWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getCrosstabWidth(); + + /** + *

getCrosstabHighlightOddRows.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getCrosstabHighlightOddRows(); + + /** + *

getCrosstabOddRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + public DRISimpleStyle getCrosstabOddRowStyle(); + + /** + *

getCrosstabHighlightEvenRows.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getCrosstabHighlightEvenRows(); + + /** + *

getCrosstabEvenRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + public DRISimpleStyle getCrosstabEvenRowStyle(); + + /** + *

getCrosstabGroupStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getCrosstabGroupStyle(); + + /** + *

getCrosstabGroupTotalStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getCrosstabGroupTotalStyle(); + + /** + *

getCrosstabGrandTotalStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getCrosstabGrandTotalStyle(); + + /** + *

getCrosstabCellStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getCrosstabCellStyle(); + + /** + *

getCrosstabMeasureTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getCrosstabMeasureTitleStyle(); + + /** + *

getBooleanComponentType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.BooleanComponentType} object. + */ + public BooleanComponentType getBooleanComponentType(); + + /** + *

getBooleanEmptyWhenNullValue.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getBooleanEmptyWhenNullValue(); + + /** + *

getBooleanImageWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getBooleanImageWidth(); + + /** + *

getBooleanImageHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getBooleanImageHeight(); + + /** + *

getBooleanColumnStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getBooleanColumnStyle(); + + /** + *

getDefaultSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getDefaultSplitType(); + + /** + *

getTitleSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getTitleSplitType(); + + /** + *

getPageHeaderSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getPageHeaderSplitType(); + + /** + *

getPageFooterSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getPageFooterSplitType(); + + /** + *

getColumnHeaderSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getColumnHeaderSplitType(); + + /** + *

getColumnFooterSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getColumnFooterSplitType(); + + /** + *

getGroupHeaderSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getGroupHeaderSplitType(); + + /** + *

getGroupFooterSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getGroupFooterSplitType(); + + /** + *

getDetailHeaderSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getDetailHeaderSplitType(); + + /** + *

getDetailSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getDetailSplitType(); + + /** + *

getDetailFooterSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getDetailFooterSplitType(); + + /** + *

getLastPageFooterSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getLastPageFooterSplitType(); + + /** + *

getSummarySplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getSummarySplitType(); + + /** + *

getNoDataSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getNoDataSplitType(); + + /** + *

getBackgroundSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getBackgroundSplitType(); + + /** + *

getTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getTitleStyle(); + + /** + *

getPageHeaderStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getPageHeaderStyle(); + + /** + *

getPageFooterStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getPageFooterStyle(); + + /** + *

getColumnHeaderStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getColumnHeaderStyle(); + + /** + *

getColumnFooterStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getColumnFooterStyle(); + + /** + *

getGroupHeaderStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getGroupHeaderStyle(); + + /** + *

getGroupFooterStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getGroupFooterStyle(); + + /** + *

getDetailHeaderStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getDetailHeaderStyle(); + + /** + *

getDetailStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getDetailStyle(); + + /** + *

getDetailFooterStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getDetailFooterStyle(); + + /** + *

getLastPageFooterStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getLastPageFooterStyle(); + + /** + *

getSummaryStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getSummaryStyle(); + + /** + *

getNoDataStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getNoDataStyle(); + + /** + *

getBackgroundStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getBackgroundStyle(); + + /** + *

getTitleBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getTitleBackgroundComponent(); + + /** + *

getPageHeaderBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getPageHeaderBackgroundComponent(); + + /** + *

getPageFooterBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getPageFooterBackgroundComponent(); + + /** + *

getColumnHeaderBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getColumnHeaderBackgroundComponent(); + + /** + *

getColumnFooterBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getColumnFooterBackgroundComponent(); + + /** + *

getGroupHeaderBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getGroupHeaderBackgroundComponent(); + + /** + *

getGroupFooterBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getGroupFooterBackgroundComponent(); + + /** + *

getDetailHeaderBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getDetailHeaderBackgroundComponent(); + + /** + *

getDetailBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getDetailBackgroundComponent(); + + /** + *

getDetailFooterBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getDetailFooterBackgroundComponent(); + + /** + *

getLastPageFooterBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getLastPageFooterBackgroundComponent(); + + /** + *

getSummaryBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getSummaryBackgroundComponent(); + + /** + *

getNoDataBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getNoDataBackgroundComponent(); + + /** + *

getBackgroundBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getBackgroundBackgroundComponent(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIScriptlet.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIScriptlet.java new file mode 100644 index 0000000..8685549 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIScriptlet.java @@ -0,0 +1,106 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +/** + *

DRIScriptlet interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIScriptlet { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + * Called before the report is initialized. + * + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public void beforeReportInit(ReportParameters reportParameters); + + /** + * Called after the report is initialized. + * + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public void afterReportInit(ReportParameters reportParameters); + + /** + * Called before each page is initialized. + * + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public void beforePageInit(ReportParameters reportParameters); + + /** + * Called after each page is initialized. + * + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public void afterPageInit(ReportParameters reportParameters); + + /** + * Called before each column is initialized. + * + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public void beforeColumnInit(ReportParameters reportParameters); + + /** + * Called after each column is initialized. + * + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public void afterColumnInit(ReportParameters reportParameters); + + /** + * Called before a group is initialized. + * + * @param groupName the group name + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public void beforeGroupInit(String groupName, ReportParameters reportParameters); + + /** + * Called after a group is initialized. + * + * @param groupName the group name + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public void afterGroupInit(String groupName, ReportParameters reportParameters); + + /** + * Called before evaluating each detail. + * + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public void beforeDetailEval(ReportParameters reportParameters); + + /** + * Called after evaluating each detail. + * + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public void afterDetailEval(ReportParameters reportParameters); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRISort.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRISort.java new file mode 100644 index 0000000..dda410a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRISort.java @@ -0,0 +1,46 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.report.constant.OrderType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.io.Serializable; + +/** + *

DRISort interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRISort extends Serializable { + + /** + *

getExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getExpression(); + + /** + *

getOrderType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + */ + public OrderType getOrderType(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRISubtotal.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRISubtotal.java new file mode 100644 index 0000000..d0f463f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRISubtotal.java @@ -0,0 +1,98 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.Position; +import software.xdev.dynamicreports.report.constant.SubtotalPosition; +import software.xdev.dynamicreports.report.definition.column.DRIColumn; +import software.xdev.dynamicreports.report.definition.component.DRITextField; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +/** + *

DRISubtotal interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRISubtotal extends DRIExpression, DRIValue { + + /** + *

getShowInColumn.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.column.DRIColumn} object. + */ + public DRIColumn getShowInColumn(); + + /** + *

getValueField.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRITextField} object. + */ + public DRITextField getValueField(); + + /** + *

getLabelExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getLabelExpression(); + + /** + *

getLabelStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getLabelStyle(); + + /** + *

getLabelPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Position} object. + */ + public Position getLabelPosition(); + + /** + *

getLabelWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getLabelWidth(); + + /** + *

getLabelWidthType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public ComponentDimensionType getLabelWidthType(); + + /** + *

getPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SubtotalPosition} object. + */ + public SubtotalPosition getPosition(); + + /** + *

getGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + */ + public DRIGroup getGroup(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRITableOfContentsCustomizer.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRITableOfContentsCustomizer.java new file mode 100644 index 0000000..f9e842b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRITableOfContentsCustomizer.java @@ -0,0 +1,74 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.jasper.base.tableofcontents.JasperTocHeading; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.constant.TableOfContentsPosition; + +import java.io.Serializable; +import java.util.List; + +/** + *

DRITableOfContentsCustomizer interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRITableOfContentsCustomizer extends Serializable { + + /** + *

setReport.

+ * + * @param report a {@link software.xdev.dynamicreports.report.builder.ReportBuilder} object. + */ + public void setReport(ReportBuilder report); + + /** + *

setHeadingList.

+ * + * @param headingList a {@link java.util.List} object. + */ + public void setHeadingList(List headingList); + + /** + *

setHeadings.

+ * + * @param headings a int. + */ + public void setHeadings(int headings); + + /** + *

setLevels.

+ * + * @param levels a int. + */ + public void setLevels(int levels); + + /** + *

customize.

+ */ + public void customize(); + + /** + *

getPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.TableOfContentsPosition} object. + */ + public TableOfContentsPosition getPosition(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRITableOfContentsHeading.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRITableOfContentsHeading.java new file mode 100644 index 0000000..0d04e1e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRITableOfContentsHeading.java @@ -0,0 +1,53 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.io.Serializable; + +/** + *

DRITableOfContentsHeading interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRITableOfContentsHeading extends Serializable { + + /** + *

getParentHeading.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRITableOfContentsHeading} object. + */ + public DRITableOfContentsHeading getParentHeading(); + + /** + *

getLabelExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getLabelExpression(); + + /** + *

getCustomValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getCustomValueExpression(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRITemplateDesign.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRITemplateDesign.java new file mode 100644 index 0000000..1caf347 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRITemplateDesign.java @@ -0,0 +1,233 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.io.Serializable; +import java.util.List; + +/** + *

DRITemplateDesign interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRITemplateDesign extends Serializable { + + /** + *

getReportName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getReportName(); + + /** + *

getFields.

+ * + * @return a {@link java.util.List} object. + */ + public List> getFields(); + + /** + *

isDefinedParameter.

+ * + * @param name a {@link java.lang.String} object. + * @return a boolean. + */ + public boolean isDefinedParameter(String name); + + /** + *

getResourceBundleName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getResourceBundleName(); + + /** + *

getIgnorePagination.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnorePagination(); + + /** + *

getWhenNoDataType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenNoDataType} object. + */ + public WhenNoDataType getWhenNoDataType(); + + /** + *

getWhenResourceMissingType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.WhenResourceMissingType} object. + */ + public WhenResourceMissingType getWhenResourceMissingType(); + + /** + *

getTitleOnANewPage.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getTitleOnANewPage(); + + /** + *

getSummaryOnANewPage.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getSummaryOnANewPage(); + + /** + *

getSummaryWithPageHeaderAndFooter.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getSummaryWithPageHeaderAndFooter(); + + /** + *

getFloatColumnFooter.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getFloatColumnFooter(); + + /** + *

getPageWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageWidth(); + + /** + *

getPageHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageHeight(); + + /** + *

getPageOrientation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.PageOrientation} object. + */ + public PageOrientation getPageOrientation(); + + /** + *

getPageMargin.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIMargin} object. + */ + public DRIMargin getPageMargin(); + + /** + *

getPageColumnsPerPage.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageColumnsPerPage(); + + /** + *

getPageColumnSpace.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageColumnSpace(); + + /** + *

getPageColumnWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageColumnWidth(); + + /** + *

getTitleComponentsCount.

+ * + * @return a int. + */ + public int getTitleComponentsCount(); + + /** + *

getPageHeaderComponentsCount.

+ * + * @return a int. + */ + public int getPageHeaderComponentsCount(); + + /** + *

getPageFooterComponentsCount.

+ * + * @return a int. + */ + public int getPageFooterComponentsCount(); + + /** + *

getColumnHeaderComponentsCount.

+ * + * @return a int. + */ + public int getColumnHeaderComponentsCount(); + + /** + *

getColumnFooterComponentsCount.

+ * + * @return a int. + */ + public int getColumnFooterComponentsCount(); + + /** + *

getLastPageFooterComponentsCount.

+ * + * @return a int. + */ + public int getLastPageFooterComponentsCount(); + + /** + *

getSummaryComponentsCount.

+ * + * @return a int. + */ + public int getSummaryComponentsCount(); + + /** + *

getNoDataComponentsCount.

+ * + * @return a int. + */ + public int getNoDataComponentsCount(); + + /** + *

getBackgroundComponentsCount.

+ * + * @return a int. + */ + public int getBackgroundComponentsCount(); + + /** + *

getDesign.

+ * + * @return a T object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public T getDesign() throws DRException; +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIValue.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIValue.java new file mode 100644 index 0000000..db9fe50 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIValue.java @@ -0,0 +1,34 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +/** + *

DRIValue interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIValue { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIVariable.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIVariable.java new file mode 100644 index 0000000..95a1a5c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/DRIVariable.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRIVariable interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIVariable extends DRIExpression, DRIValue { + + /** + *

getCalculation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + public Calculation getCalculation(); + + /** + *

getResetType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Evaluation} object. + */ + public Evaluation getResetType(); + + /** + *

getResetGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + */ + public DRIGroup getResetGroup(); + + /** + *

getValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getValueExpression(); + + /** + *

getInitialValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getInitialValueExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/ReportParameters.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/ReportParameters.java new file mode 100644 index 0000000..9bd7fa2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/ReportParameters.java @@ -0,0 +1,182 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition; + +import java.sql.Connection; +import java.util.Locale; + +/** + *

ReportParameters interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface ReportParameters { + /** + * Constant CROSSTAB_ROW_COUNTER="CROSSTAB_ROW_NUMBER" + */ + public static final String CROSSTAB_ROW_COUNTER = "CROSSTAB_ROW_NUMBER"; + + /** + *

getValue.

+ * + * @param name a {@link java.lang.String} object. + * @param a T object. + * @return a T object. + */ + public T getValue(String name); + + /** + *

getValue.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param a T object. + * @return a T object. + */ + public T getValue(DRIValue value); + + /** + *

getFieldValue.

+ * + * @param name a {@link java.lang.String} object. + * @param a T object. + * @return a T object. + */ + public T getFieldValue(String name); + + /** + *

getVariableValue.

+ * + * @param name a {@link java.lang.String} object. + * @param a T object. + * @return a T object. + */ + public T getVariableValue(String name); + + /** + *

getParameterValue.

+ * + * @param name a {@link java.lang.String} object. + * @param a T object. + * @return a T object. + */ + public T getParameterValue(String name); + + /** + *

getPageNumber.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageNumber(); + + /** + *

getColumnNumber.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getColumnNumber(); + + /** + *

getReportRowNumber.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getReportRowNumber(); + + /** + *

getPageRowNumber.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageRowNumber(); + + /** + *

getColumnRowNumber.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getColumnRowNumber(); + + /** + *

getCrosstabRowNumber.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getCrosstabRowNumber(); + + /** + *

getGroupCount.

+ * + * @param groupName a {@link java.lang.String} object. + * @return a {@link java.lang.Integer} object. + */ + public Integer getGroupCount(String groupName); + + /** + *

getConnection.

+ * + * @return a {@link java.sql.Connection} object. + */ + public Connection getConnection(); + + /** + *

getLocale.

+ * + * @return a {@link java.util.Locale} object. + */ + public Locale getLocale(); + + /** + *

getScriptlet.

+ * + * @param name a {@link java.lang.String} object. + * @return a {@link software.xdev.dynamicreports.report.definition.DRIScriptlet} object. + */ + public DRIScriptlet getScriptlet(String name); + + /** + *

getMessage.

+ * + * @param key a {@link java.lang.String} object. + * @return a {@link java.lang.String} object. + */ + public String getMessage(String key); + + /** + *

getMessage.

+ * + * @param key a {@link java.lang.String} object. + * @param arguments an array of {@link java.lang.Object} objects. + * @return a {@link java.lang.String} object. + */ + public String getMessage(String key, Object[] arguments); + + /** + *

getMasterParameters.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + */ + public ReportParameters getMasterParameters(); + + /** + *

getSubreportWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getSubreportWidth(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/column/DRIBooleanColumn.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/column/DRIBooleanColumn.java new file mode 100644 index 0000000..15918bb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/column/DRIBooleanColumn.java @@ -0,0 +1,32 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.column; + +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.component.DRIBooleanField; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRIBooleanColumn interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIBooleanColumn extends DRIExpression, DRIColumn, DRIValue { + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/column/DRIColumn.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/column/DRIColumn.java new file mode 100644 index 0000000..20ee2b3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/column/DRIColumn.java @@ -0,0 +1,109 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.column; + +import java.util.List; + +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.component.DRIComponent; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +/** + *

DRIColumn interface.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public interface DRIColumn extends DRIColumnGridComponent { + + /** + *

getComponent.

+ * + * @return a T object. + */ + T getComponent(); + + /** + *

getTitleExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + DRIExpression getTitleExpression(); + + /** + *

getTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + DRIReportStyle getTitleStyle(); + + /** + *

getTitleHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + Integer getTitleHeight(); + + /** + *

getTitleHeightType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + ComponentDimensionType getTitleHeightType(); + + /** + *

getTitleRows.

+ * + * @return a {@link java.lang.Integer} object. + */ + Integer getTitleRows(); + + /** + *

getTitleStretchWithOverflow.

+ * + * @return a {@link java.lang.Boolean} object. + * @deprecated replaced by {@link #getTitleTextAdjust()} + */ + @Deprecated + Boolean getTitleStretchWithOverflow(); + + /** + *

getTitlePropertyExpressions.

+ * + * @return a {@link java.util.List} object. + */ + List getTitlePropertyExpressions(); + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + String getName(); + + /** + *

getTitleTextAdjust.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + TextAdjust getTitleTextAdjust(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/column/DRIValueColumn.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/column/DRIValueColumn.java new file mode 100644 index 0000000..3178ac7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/column/DRIValueColumn.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.column; + +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.component.DRITextField; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRIValueColumn interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIValueColumn extends DRIExpression, DRIColumn>, DRIValue { + + /** + *

getPrintRepeatedDetailValues.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getPrintRepeatedDetailValues(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIBooleanField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIBooleanField.java new file mode 100644 index 0000000..4517627 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIBooleanField.java @@ -0,0 +1,81 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRIBooleanField interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIBooleanField extends DRIHyperLinkComponent { + + /** + *

getValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getValueExpression(); + + /** + *

getComponentType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.BooleanComponentType} object. + */ + public BooleanComponentType getComponentType(); + + /** + *

getEmptyWhenNullValue.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getEmptyWhenNullValue(); + + /** + *

getImageWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getImageWidth(); + + /** + *

getImageHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getImageHeight(); + + /** + *

getHorizontalImageAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public HorizontalImageAlignment getHorizontalImageAlignment(); + + /** + *

getHorizontalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public HorizontalTextAlignment getHorizontalTextAlignment(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIBreak.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIBreak.java new file mode 100644 index 0000000..037081a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIBreak.java @@ -0,0 +1,37 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.constant.BreakType; + +/** + *

DRIBreak interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIBreak extends DRIComponent { + + /** + *

getType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.BreakType} object. + */ + public BreakType getType(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIComponent.java new file mode 100644 index 0000000..0fa0a40 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIComponent.java @@ -0,0 +1,70 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.definition.DRITableOfContentsHeading; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +import java.io.Serializable; +import java.util.List; + +/** + *

DRIComponent interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIComponent extends Serializable { + + /** + *

getStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getStyle(); + + /** + *

getPrintWhenExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getPrintWhenExpression(); + + /** + *

getRemoveLineWhenBlank.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getRemoveLineWhenBlank(); + + /** + *

getPropertyExpressions.

+ * + * @return a {@link java.util.List} object. + */ + public List getPropertyExpressions(); + + /** + *

getTableOfContentsHeading.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRITableOfContentsHeading} object. + */ + public DRITableOfContentsHeading getTableOfContentsHeading(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRICurrentDate.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRICurrentDate.java new file mode 100644 index 0000000..458cc7d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRICurrentDate.java @@ -0,0 +1,34 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +/** + *

DRICurrentDate interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRICurrentDate extends DRIFormatField { + + /** + *

getPattern.

+ * + * @return a {@link java.lang.String} object. + */ + public String getPattern(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIDimensionComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIDimensionComponent.java new file mode 100644 index 0000000..7d163e4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIDimensionComponent.java @@ -0,0 +1,95 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.ComponentPositionType; +import software.xdev.dynamicreports.report.constant.StretchType; +import software.xdev.dynamicreports.report.definition.DRIGroup; + +/** + *

DRIDimensionComponent interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDimensionComponent extends DRIComponent { + + /** + *

getWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getWidth(); + + /** + *

getHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getHeight(); + + /** + *

getWidthType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public ComponentDimensionType getWidthType(); + + /** + *

getHeightType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public ComponentDimensionType getHeightType(); + + /** + *

getPositionType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ComponentPositionType} object. + */ + public ComponentPositionType getPositionType(); + + /** + *

getStretchType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.StretchType} object. + */ + public StretchType getStretchType(); + + /** + *

getPrintInFirstWholeBand.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getPrintInFirstWholeBand(); + + /** + *

getPrintWhenDetailOverflows.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getPrintWhenDetailOverflows(); + + /** + *

getPrintWhenGroupChanges.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + */ + public DRIGroup getPrintWhenGroupChanges(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIEllipse.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIEllipse.java new file mode 100644 index 0000000..b71bc93 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIEllipse.java @@ -0,0 +1,37 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.definition.style.DRIPen; + +/** + *

DRIEllipse interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIEllipse extends DRIDimensionComponent { + + /** + *

getPen.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIPen} object. + */ + public DRIPen getPen(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIFiller.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIFiller.java new file mode 100644 index 0000000..37fed08 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIFiller.java @@ -0,0 +1,27 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +/** + *

DRIFiller interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIFiller extends DRIDimensionComponent { +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIFormatField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIFormatField.java new file mode 100644 index 0000000..5e1c3ff --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIFormatField.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRIFormatField interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIFormatField extends DRIHyperLinkComponent { + + /** + *

getFormatExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getFormatExpression(); + + /** + *

getHorizontalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public HorizontalTextAlignment getHorizontalTextAlignment(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIGenericElement.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIGenericElement.java new file mode 100644 index 0000000..052cded --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIGenericElement.java @@ -0,0 +1,53 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.definition.expression.DRIParameterExpression; + +import java.util.List; + +/** + *

DRIGenericElement interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIGenericElement extends DRIDimensionComponent { + + /** + *

getGenericElementNamespace.

+ * + * @return a {@link java.lang.String} object. + */ + public String getGenericElementNamespace(); + + /** + *

getGenericElementName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getGenericElementName(); + + /** + *

getParameterExpressions.

+ * + * @return a {@link java.util.List} object. + */ + public List getParameterExpressions(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIHyperLinkComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIHyperLinkComponent.java new file mode 100644 index 0000000..2f4c0d1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIHyperLinkComponent.java @@ -0,0 +1,51 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.definition.DRIHyperLink; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRIHyperLinkComponent interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIHyperLinkComponent extends DRIDimensionComponent { + + /** + *

getAnchorNameExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getAnchorNameExpression(); + + /** + *

getBookmarkLevel.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getBookmarkLevel(); + + /** + *

getHyperLink.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIHyperLink} object. + */ + public DRIHyperLink getHyperLink(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIImage.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIImage.java new file mode 100644 index 0000000..cf4adc1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIImage.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRIImage interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIImage extends DRIHyperLinkComponent { + + /** + *

getImageExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getImageExpression(); + + /** + *

getImageScale.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ImageScale} object. + */ + public ImageScale getImageScale(); + + /** + *

getUsingCache.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getUsingCache(); + + /** + *

getLazy.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getLazy(); + + /** + *

getHorizontalImageAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public HorizontalImageAlignment getHorizontalImageAlignment(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRILine.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRILine.java new file mode 100644 index 0000000..c7b8eba --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRILine.java @@ -0,0 +1,45 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.constant.LineDirection; +import software.xdev.dynamicreports.report.definition.style.DRIPen; + +/** + *

DRILine interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRILine extends DRIDimensionComponent { + + /** + *

getDirection.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.LineDirection} object. + */ + public LineDirection getDirection(); + + /** + *

getPen.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIPen} object. + */ + public DRIPen getPen(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIList.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIList.java new file mode 100644 index 0000000..d953d56 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIList.java @@ -0,0 +1,59 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.constant.ListType; + +import java.util.List; + +/** + *

DRIList interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIList extends DRIDimensionComponent { + + /** + *

getListCells.

+ * + * @return a {@link java.util.List} object. + */ + public List getListCells(); + + /** + *

getType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ListType} object. + */ + public ListType getType(); + + /** + *

getGap.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getGap(); + + /** + *

getBackgroundComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getBackgroundComponent(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIListCell.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIListCell.java new file mode 100644 index 0000000..1affe43 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIListCell.java @@ -0,0 +1,53 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; + +import java.io.Serializable; + +/** + *

DRIListCell interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIListCell extends Serializable { + + /** + *

getHorizontalAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + */ + public HorizontalCellComponentAlignment getHorizontalAlignment(); + + /** + *

getVerticalAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + */ + public VerticalCellComponentAlignment getVerticalAlignment(); + + /** + *

getComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getComponent(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIMap.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIMap.java new file mode 100644 index 0000000..37ac4e3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIMap.java @@ -0,0 +1,51 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRIMap interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIMap extends DRIDimensionComponent { + + /** + *

getLatitudeExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getLatitudeExpression(); + + /** + *

getLongitudeExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getLongitudeExpression(); + + /** + *

getZoomExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getZoomExpression(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIMultiPageList.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIMultiPageList.java new file mode 100644 index 0000000..ee8d526 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIMultiPageList.java @@ -0,0 +1,46 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.constant.SplitType; + +import java.util.List; + +/** + *

DRIMultiPageList interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIMultiPageList extends DRIDimensionComponent { + + /** + *

getComponents.

+ * + * @return a {@link java.util.List} object. + */ + public List getComponents(); + + /** + *

getSplitType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.SplitType} object. + */ + public SplitType getSplitType(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIPageNumber.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIPageNumber.java new file mode 100644 index 0000000..da7d2ea --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIPageNumber.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +/** + *

DRIPageNumber interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIPageNumber extends DRIFormatField { + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIPageXofY.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIPageXofY.java new file mode 100644 index 0000000..a8740cb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIPageXofY.java @@ -0,0 +1,58 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; + +/** + *

DRIPageXofY interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIPageXofY extends DRIFormatField { + + /** + *

getPageXWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageXWidth(); + + /** + *

getPageXWidthType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public ComponentDimensionType getPageXWidthType(); + + /** + *

getPageYWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getPageYWidth(); + + /** + *

getPageYWidthType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + public ComponentDimensionType getPageYWidthType(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIRectangle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIRectangle.java new file mode 100644 index 0000000..47242aa --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIRectangle.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.definition.style.DRIPen; + +/** + *

DRIRectangle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIRectangle extends DRIDimensionComponent { + + /** + *

getRadius.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getRadius(); + + /** + *

getPen.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIPen} object. + */ + public DRIPen getPen(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRISubreport.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRISubreport.java new file mode 100644 index 0000000..a388cd2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRISubreport.java @@ -0,0 +1,67 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +import java.sql.Connection; +import java.util.Map; + +/** + *

DRISubreport interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRISubreport extends DRIDimensionComponent { + + /** + *

getReportExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getReportExpression(); + + /** + *

getParametersExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression> getParametersExpression(); + + /** + *

getConnectionExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getConnectionExpression(); + + /** + *

getDataSourceExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getDataSourceExpression(); + + /** + *

getRunToBottom.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getRunToBottom(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRITextField.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRITextField.java new file mode 100644 index 0000000..8bb365b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRITextField.java @@ -0,0 +1,136 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.DRIGroup; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; + +/** + *

DRITextField interface.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public interface DRITextField extends DRIHyperLinkComponent { + + /** + *

getValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + DRIExpression getValueExpression(); + + /** + *

getPattern.

+ * + * @return a {@link java.lang.String} object. + */ + String getPattern(); + + /** + *

getPatternExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + DRIExpression getPatternExpression(); + + /** + *

getHorizontalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + HorizontalTextAlignment getHorizontalTextAlignment(); + + /** + *

getValueFormatter.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + */ + DRIValueFormatter getValueFormatter(); + + /** + *

getDataType.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + */ + DRIDataType getDataType(); + + /** + *

getColumns.

+ * + * @return a {@link java.lang.Integer} object. + */ + Integer getColumns(); + + /** + *

getRows.

+ * + * @return a {@link java.lang.Integer} object. + */ + Integer getRows(); + + /** + *

getEvaluationTime.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Evaluation} object. + */ + Evaluation getEvaluationTime(); + + /** + *

getEvaluationGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIGroup} object. + */ + DRIGroup getEvaluationGroup(); + + /** + *

getMarkup.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Markup} object. + */ + Markup getMarkup(); + + /** + *

getStretchWithOverflow.

+ * + * @return a {@link java.lang.Boolean} object. + * @deprecated replaced {@link #getTextAdjust()} + */ + @Deprecated + Boolean getStretchWithOverflow(); + + /** + *

getPrintRepeatedValues.

+ * + * @return a {@link java.lang.Boolean} object. + */ + Boolean getPrintRepeatedValues(); + + /** + *

getTextAdjust.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + TextAdjust getTextAdjust(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRITotalPages.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRITotalPages.java new file mode 100644 index 0000000..74052bd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRITotalPages.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +/** + *

DRITotalPages interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRITotalPages extends DRIFormatField { + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIXyList.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIXyList.java new file mode 100644 index 0000000..33636db --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIXyList.java @@ -0,0 +1,37 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import java.util.List; + +/** + *

DRIXyList interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIXyList extends DRIDimensionComponent { + + /** + *

getXyListCells.

+ * + * @return a {@link java.util.List} object. + */ + public List getXyListCells(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIXyListCell.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIXyListCell.java new file mode 100644 index 0000000..ec5ae9c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/component/DRIXyListCell.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.component; + +import java.io.Serializable; + +/** + *

DRIXyListCell interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIXyListCell extends Serializable { + + /** + *

getX.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getX(); + + /** + *

getY.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getY(); + + /** + *

getComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIComponent} object. + */ + public DRIComponent getComponent(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstab.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstab.java new file mode 100644 index 0000000..d3dce26 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstab.java @@ -0,0 +1,195 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.crosstab; + +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.definition.component.DRIDimensionComponent; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; +import software.xdev.dynamicreports.report.definition.style.DRISimpleStyle; + +import java.util.List; + +/** + *

DRICrosstab interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRICrosstab extends DRIDimensionComponent { + + /** + *

getDataset.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabDataset} object. + */ + public DRICrosstabDataset getDataset(); + + /** + *

isRepeatColumnHeaders.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean isRepeatColumnHeaders(); + + /** + *

isRepeatRowHeaders.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean isRepeatRowHeaders(); + + /** + *

getColumnBreakOffset.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getColumnBreakOffset(); + + /** + *

getIgnoreWidth.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getIgnoreWidth(); + + /** + *

getRunDirection.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.RunDirection} object. + */ + public RunDirection getRunDirection(); + + /** + *

getCellWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getCellWidth(); + + /** + *

getCellHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getCellHeight(); + + /** + *

getHighlightOddRows.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getHighlightOddRows(); + + /** + *

getOddRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + public DRISimpleStyle getOddRowStyle(); + + /** + *

getHighlightEvenRows.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getHighlightEvenRows(); + + /** + *

getEvenRowStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRISimpleStyle} object. + */ + public DRISimpleStyle getEvenRowStyle(); + + /** + *

getGroupStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getGroupStyle(); + + /** + *

getGroupTotalStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getGroupTotalStyle(); + + /** + *

getGrandTotalStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getGrandTotalStyle(); + + /** + *

getCellStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getCellStyle(); + + /** + *

getMeasureTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getMeasureTitleStyle(); + + /** + *

getWhenNoDataCell.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabCellContent} object. + */ + public DRICrosstabCellContent getWhenNoDataCell(); + + /** + *

getHeaderCell.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabCellContent} object. + */ + public DRICrosstabCellContent getHeaderCell(); + + /** + *

getColumnGroups.

+ * + * @return a {@link java.util.List} object. + */ + public List> getColumnGroups(); + + /** + *

getRowGroups.

+ * + * @return a {@link java.util.List} object. + */ + public List> getRowGroups(); + + /** + *

getVariables.

+ * + * @return a {@link java.util.List} object. + */ + public List> getVariables(); + + /** + *

getMeasures.

+ * + * @return a {@link java.util.List} object. + */ + public List> getMeasures(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabCellContent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabCellContent.java new file mode 100644 index 0000000..9c9f7b9 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabCellContent.java @@ -0,0 +1,46 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.crosstab; + +import software.xdev.dynamicreports.report.definition.component.DRIList; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +import java.io.Serializable; + +/** + *

DRICrosstabCellContent interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRICrosstabCellContent extends Serializable { + + /** + *

getList.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.component.DRIList} object. + */ + public DRIList getList(); + + /** + *

getStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getStyle(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabCellStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabCellStyle.java new file mode 100644 index 0000000..3a465bb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabCellStyle.java @@ -0,0 +1,52 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.crosstab; + +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +import java.io.Serializable; + +/** + *

DRICrosstabCellStyle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRICrosstabCellStyle extends Serializable { + + /** + *

getRowGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabRowGroup} object. + */ + public DRICrosstabRowGroup getRowGroup(); + + /** + *

getColumnGroup.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.crosstab.DRICrosstabColumnGroup} object. + */ + public DRICrosstabColumnGroup getColumnGroup(); + + /** + *

getStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getStyle(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabColumnGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabColumnGroup.java new file mode 100644 index 0000000..de74bd6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabColumnGroup.java @@ -0,0 +1,41 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.crosstab; + +/** + *

DRICrosstabColumnGroup interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRICrosstabColumnGroup extends DRICrosstabGroup { + + /** + *

getHeaderHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getHeaderHeight(); + + /** + *

getTotalHeaderWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getTotalHeaderWidth(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabDataset.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabDataset.java new file mode 100644 index 0000000..2b7f3e3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabDataset.java @@ -0,0 +1,45 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.crosstab; + +import software.xdev.dynamicreports.report.definition.DRIDataset; + +import java.io.Serializable; + +/** + *

DRICrosstabDataset interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRICrosstabDataset extends Serializable { + + /** + *

getSubDataset.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIDataset} object. + */ + public DRIDataset getSubDataset(); + + /** + *

getDataPreSorted.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getDataPreSorted(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabGroup.java new file mode 100644 index 0000000..6c53873 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabGroup.java @@ -0,0 +1,188 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.crosstab; + +import java.util.Comparator; +import java.util.List; + +import software.xdev.dynamicreports.report.constant.CrosstabTotalPosition; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.OrderType; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.DRIHyperLink; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.expression.DRISystemExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +/** + *

DRICrosstabGroup interface.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public interface DRICrosstabGroup extends DRISystemExpression { + + /** {@inheritDoc} */ + @Override String getName(); + + /** + *

getHeaderPattern.

+ * + * @return a {@link java.lang.String} object. + */ + String getHeaderPattern(); + + /** + *

getHeaderHorizontalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + HorizontalTextAlignment getHeaderHorizontalTextAlignment(); + + /** + *

getHeaderValueFormatter.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + */ + DRIValueFormatter getHeaderValueFormatter(); + + /** + *

getHeaderStretchWithOverflow.

+ * + * @return a {@link java.lang.Boolean} object. + * @deprecated replaced by {@link #getHeaderTextAdjust()} + */ + @Deprecated + Boolean getHeaderStretchWithOverflow(); + + /** + *

getHeaderTextAdjust.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + TextAdjust getHeaderTextAdjust(); + + /** + *

getHeaderHyperLink.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIHyperLink} object. + */ + DRIHyperLink getHeaderHyperLink(); + + /** + *

getHeaderStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + DRIReportStyle getHeaderStyle(); + + /** + *

getHeaderPropertyExpressions.

+ * + * @return a {@link java.util.List} object. + */ + List getHeaderPropertyExpressions(); + + /** + *

getShowTotal.

+ * + * @return a {@link java.lang.Boolean} object. + */ + Boolean getShowTotal(); + + /** + *

getTotalPosition.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.CrosstabTotalPosition} object. + */ + CrosstabTotalPosition getTotalPosition(); + + /** + *

getTotalHeaderExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + DRIExpression getTotalHeaderExpression(); + + /** + *

getTotalHeaderStretchWithOverflow.

+ * + * @return a {@link java.lang.Boolean} object. + * @deprecated replaced by {@link #getTotalHeaderTextAdjust()} + */ + @Deprecated Boolean getTotalHeaderStretchWithOverflow(); + + /** + *

getTotalHeaderTextAdjust.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + TextAdjust getTotalHeaderTextAdjust(); + + /** + *

getTotalHeaderStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + DRIReportStyle getTotalHeaderStyle(); + + /** + *

getTotalHeaderPropertyExpressions.

+ * + * @return a {@link java.util.List} object. + */ + List getTotalHeaderPropertyExpressions(); + + /** + *

getExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + DRIExpression getExpression(); + + /** + *

getDataType.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + */ + DRIDataType getDataType(); + + /** + *

getOrderByExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + DRIExpression> getOrderByExpression(); + + /** + *

getOrderType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.OrderType} object. + */ + OrderType getOrderType(); + + /** + *

getComparatorExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + DRIExpression> getComparatorExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabMeasure.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabMeasure.java new file mode 100644 index 0000000..ac6a829 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabMeasure.java @@ -0,0 +1,131 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.crosstab; + +import java.io.Serializable; +import java.util.List; + +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.DRIHyperLink; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +/** + *

DRICrosstabMeasure interface.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public interface DRICrosstabMeasure extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + String getName(); + + /** + *

getDataType.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.datatype.DRIDataType} object. + */ + DRIDataType getDataType(); + + /** + *

getExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + DRIExpression getExpression(); + + /** + *

getPattern.

+ * + * @return a {@link java.lang.String} object. + */ + String getPattern(); + + /** + *

getHorizontalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + HorizontalTextAlignment getHorizontalTextAlignment(); + + /** + *

getValueFormatter.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + */ + DRIValueFormatter getValueFormatter(); + + /** + *

getStretchWithOverflow.

+ * + * @return a {@link java.lang.Boolean} object. + * @deprecated replaced by {@link #getTextAdjust()} + */ + @Deprecated Boolean getStretchWithOverflow(); + + /** + *

getTextAdjust.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + TextAdjust getTextAdjust(); + + /** + *

getHyperLink.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.DRIHyperLink} object. + */ + DRIHyperLink getHyperLink(); + + /** + *

getPropertyExpressions.

+ * + * @return a {@link java.util.List} object. + */ + List getPropertyExpressions(); + + /** + *

getStyles.

+ * + * @return a {@link java.util.List} object. + */ + List getStyles(); + + /** + *

getTitleExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + DRIExpression getTitleExpression(); + + /** + *

getTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + DRIReportStyle getTitleStyle(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabRowGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabRowGroup.java new file mode 100644 index 0000000..c1773ba --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabRowGroup.java @@ -0,0 +1,41 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.crosstab; + +/** + *

DRICrosstabRowGroup interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRICrosstabRowGroup extends DRICrosstabGroup { + + /** + *

getHeaderWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getHeaderWidth(); + + /** + *

getTotalHeaderHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getTotalHeaderHeight(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabVariable.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabVariable.java new file mode 100644 index 0000000..0f9ba40 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/crosstab/DRICrosstabVariable.java @@ -0,0 +1,58 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.crosstab; + +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRISystemExpression; + +/** + *

DRICrosstabVariable interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRICrosstabVariable extends DRISystemExpression, DRIValue { + + /** {@inheritDoc} */ + @Override + public Class getValueClass(); + + /** + *

getValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getValueExpression(); + + /** + *

getCalculation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Calculation} object. + */ + public Calculation getCalculation(); + + /** + *

getPercentageType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.CrosstabPercentageType} object. + */ + public CrosstabPercentageType getPercentageType(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/datatype/DRIDataType.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/datatype/DRIDataType.java new file mode 100644 index 0000000..a87378c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/datatype/DRIDataType.java @@ -0,0 +1,121 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.datatype; + +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import software.xdev.dynamicreports.report.exception.DRException; + +import java.io.Serializable; +import java.util.Locale; + +/** + *

DRIDataType interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIDataType extends Serializable { + + /** + *

getPattern.

+ * + * @return a {@link java.lang.String} object. + */ + public String getPattern(); + + /** + *

getValueFormatter.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter} object. + */ + public DRIValueFormatter getValueFormatter(); + + /** + *

getHorizontalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public HorizontalTextAlignment getHorizontalTextAlignment(); + + /** + *

valueToString.

+ * + * @param value a U object. + * @param locale a {@link java.util.Locale} object. + * @return a {@link java.lang.String} object. + */ + public String valueToString(U value, Locale locale); + + /** + *

valueToString.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + * @return a {@link java.lang.String} object. + */ + public String valueToString(DRIValue value, ReportParameters reportParameters); + + /** + *

valueToString.

+ * + * @param name a {@link java.lang.String} object. + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + * @return a {@link java.lang.String} object. + */ + public String valueToString(String name, ReportParameters reportParameters); + + /** + *

stringToValue.

+ * + * @param value a {@link java.lang.String} object. + * @param locale a {@link java.util.Locale} object. + * @return a T object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public T stringToValue(String value, Locale locale) throws DRException; + + /** + *

stringToValue.

+ * + * @param value a {@link software.xdev.dynamicreports.report.definition.DRIValue} object. + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + * @return a T object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public T stringToValue(DRIValue value, ReportParameters reportParameters) throws DRException; + + /** + *

stringToValue.

+ * + * @param name a {@link java.lang.String} object. + * @param reportParameters a {@link software.xdev.dynamicreports.report.definition.ReportParameters} object. + * @return a T object. + * @throws software.xdev.dynamicreports.report.exception.DRException if any. + */ + public T stringToValue(String name, ReportParameters reportParameters) throws DRException; + + /** + *

getValueClass.

+ * + * @return a {@link java.lang.Class} object. + */ + public Class getValueClass(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIComplexExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIComplexExpression.java new file mode 100644 index 0000000..ab7e3cf --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIComplexExpression.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.expression; + +import software.xdev.dynamicreports.report.definition.ReportParameters; + +import java.util.List; + +/** + * A complex implementation of an expression.
The difference between a simple and complex expression is that a complex expression allows registering additional fields or variables that are not + * defined in the report and are needed for calculating the value. + * + * @author Ricardo Mariaca + * + */ +public interface DRIComplexExpression extends DRIExpression { + + /** + *

getExpressions.

+ * + * @return a {@link java.util.List} object. + */ + public List> getExpressions(); + + /** + * Evaluates the expression. + * + * @param values the values of the registered expressions + * @param reportParameters access to report fields, variables, parameters, expressions, and other report values + * @return the result of the expression evaluation + */ + public T evaluate(List values, ReportParameters reportParameters); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIExpression.java new file mode 100644 index 0000000..f7fac71 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIExpression.java @@ -0,0 +1,44 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.expression; + +import java.io.Serializable; + +/** + * Expressions are used to define various calculations, conditions, text field content, specific report groups, etc. Every expression can access the declared report fields, variables and other + * expressions and get their values to calculate the expression value. + * + * @author Ricardo Mariaca + * + */ +public interface DRIExpression extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getValueClass.

+ * + * @return a {@link java.lang.Class} object. + */ + public Class getValueClass(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIJasperExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIJasperExpression.java new file mode 100644 index 0000000..943b4b4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIJasperExpression.java @@ -0,0 +1,34 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.expression; + +/** + * This expression allows declaring an expression in a Jasper native syntax. Knowledge of the jasper syntax is also required for proper use. + * + * @author Ricardo Mariaca + * + */ +public interface DRIJasperExpression extends DRIExpression { + + /** + * Gets the jasper expression. + * + * @return the jasper expression + */ + public String getExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIParameterExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIParameterExpression.java new file mode 100644 index 0000000..b92f43a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIParameterExpression.java @@ -0,0 +1,43 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.expression; + +import java.io.Serializable; + +/** + *

DRIParameterExpression interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIParameterExpression extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getValueExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIPropertyExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIPropertyExpression.java new file mode 100644 index 0000000..a020933 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIPropertyExpression.java @@ -0,0 +1,43 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.expression; + +import java.io.Serializable; + +/** + *

DRIPropertyExpression interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIPropertyExpression extends Serializable { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getValueExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getValueExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRISimpleExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRISimpleExpression.java new file mode 100644 index 0000000..9c14299 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRISimpleExpression.java @@ -0,0 +1,38 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.expression; + +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.ReportParameters; + +/** + * The basic and the simplest implementation of an expression. + * + * @author Ricardo Mariaca + * + */ +public interface DRISimpleExpression extends DRIValue, DRIExpression { + + /** + * Evaluates the expression. + * + * @param reportParameters access to report fields, variables, parameters, expressions, and other report values + * @return the result of the expression evaluation + */ + public T evaluate(ReportParameters reportParameters); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRISystemExpression.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRISystemExpression.java new file mode 100644 index 0000000..9b51e19 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRISystemExpression.java @@ -0,0 +1,27 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.expression; + +/** + *

DRISystemExpression interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRISystemExpression extends DRIExpression { +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIValueFormatter.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIValueFormatter.java new file mode 100644 index 0000000..ee75e22 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/expression/DRIValueFormatter.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.expression; + +import software.xdev.dynamicreports.report.definition.ReportParameters; + +import java.io.Serializable; + +/** + * The purpose of this expression is to format a value only.
For instance, when it is necessary to display a currency next to the value or just show a value in another format.
It can be + * applied in any report column, group, subtotal, or text field component. + * + * @author Ricardo Mariaca + * + */ +public interface DRIValueFormatter extends Serializable { + + /** + * Evaluates the format expression. + * + * @param value the value to be formatted + * @param reportParameters access to report fields, variables, parameters, expressions, and other report values + * @return the formatted value + */ + public T format(U value, ReportParameters reportParameters); + + /** + *

getValueClass.

+ * + * @return a {@link java.lang.Class} object. + */ + public Class getValueClass(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGrid.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGrid.java new file mode 100644 index 0000000..c86db89 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGrid.java @@ -0,0 +1,36 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.grid; + +import java.io.Serializable; + +/** + *

DRIColumnGrid interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIColumnGrid extends Serializable { + + /** + *

getList.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.grid.DRIColumnGridList} object. + */ + public DRIColumnGridList getList(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGridComponent.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGridComponent.java new file mode 100644 index 0000000..eb12d70 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGridComponent.java @@ -0,0 +1,30 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.grid; + +import java.io.Serializable; + +/** + *

DRIColumnGridComponent interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIColumnGridComponent extends Serializable { + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGridList.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGridList.java new file mode 100644 index 0000000..5dba50c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGridList.java @@ -0,0 +1,52 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.grid; + +import software.xdev.dynamicreports.report.constant.ListType; + +import java.util.List; + +/** + *

DRIColumnGridList interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIColumnGridList extends DRIColumnGridComponent { + + /** + *

getListCells.

+ * + * @return a {@link java.util.List} object. + */ + public List getListCells(); + + /** + *

getType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ListType} object. + */ + public ListType getType(); + + /** + *

getGap.

+ * + * @return a int. + */ + public int getGap(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGridListCell.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGridListCell.java new file mode 100644 index 0000000..5009041 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnGridListCell.java @@ -0,0 +1,53 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.grid; + +import software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment; +import software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment; + +import java.io.Serializable; + +/** + *

DRIColumnGridListCell interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIColumnGridListCell extends Serializable { + + /** + *

getHorizontalAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalCellComponentAlignment} object. + */ + public HorizontalCellComponentAlignment getHorizontalAlignment(); + + /** + *

getVerticalAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.VerticalCellComponentAlignment} object. + */ + public VerticalCellComponentAlignment getVerticalAlignment(); + + /** + *

getComponent.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.grid.DRIColumnGridComponent} object. + */ + public DRIColumnGridComponent getComponent(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnTitleGroup.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnTitleGroup.java new file mode 100644 index 0000000..f839c7c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/grid/DRIColumnTitleGroup.java @@ -0,0 +1,121 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.grid; + +import java.util.List; + +import software.xdev.dynamicreports.report.constant.ComponentDimensionType; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; +import software.xdev.dynamicreports.report.definition.expression.DRIPropertyExpression; +import software.xdev.dynamicreports.report.definition.style.DRIReportStyle; + +/** + *

DRIColumnTitleGroup interface.

+ * + * @author Ricardo Mariaca, Jan Moxter + * + */ +public interface DRIColumnTitleGroup extends DRIColumnGridComponent { + + /** + *

getList.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.grid.DRIColumnGridList} object. + */ + DRIColumnGridList getList(); + + /** + *

getTitleExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + DRIExpression getTitleExpression(); + + /** + *

getTitleStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + DRIReportStyle getTitleStyle(); + + /** + *

getTitleWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + Integer getTitleWidth(); + + /** + *

getTitleWidthType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + ComponentDimensionType getTitleWidthType(); + + /** + *

getTitleColumns.

+ * + * @return a {@link java.lang.Integer} object. + */ + Integer getTitleColumns(); + + /** + *

getTitleHeight.

+ * + * @return a {@link java.lang.Integer} object. + */ + Integer getTitleHeight(); + + /** + *

getTitleHeightType.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ComponentDimensionType} object. + */ + ComponentDimensionType getTitleHeightType(); + + /** + *

getTitleRows.

+ * + * @return a {@link java.lang.Integer} object. + */ + Integer getTitleRows(); + + /** + *

getTitleStretchWithOverflow.

+ * + * @return a {@link java.lang.Boolean} object. + * @deprecated replaced by {@link #getTitleTextAdjust()} + */ + @Deprecated + Boolean getTitleStretchWithOverflow(); + + /** + *

getTitleTextAdjust.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.TextAdjust} object. + */ + TextAdjust getTitleTextAdjust(); + + /** + *

getTitlePropertyExpressions.

+ * + * @return a {@link java.util.List} object. + */ + List getTitlePropertyExpressions(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIBaseStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIBaseStyle.java new file mode 100644 index 0000000..9d1d41e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIBaseStyle.java @@ -0,0 +1,151 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.constant.Rotation; +import software.xdev.dynamicreports.report.constant.VerticalImageAlignment; +import software.xdev.dynamicreports.report.constant.VerticalTextAlignment; + +import java.awt.Color; +import java.io.Serializable; + +/** + *

DRIBaseStyle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIBaseStyle extends Serializable { + + /** + *

getForegroundColor.

+ * + * @return a {@link java.awt.Color} object. + */ + public Color getForegroundColor(); + + /** + *

getBackgroundColor.

+ * + * @return a {@link java.awt.Color} object. + */ + public Color getBackgroundColor(); + + /** + *

getRadius.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getRadius(); + + /** + *

getImageScale.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.ImageScale} object. + */ + public ImageScale getImageScale(); + + /** + *

getHorizontalImageAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalImageAlignment} object. + */ + public HorizontalImageAlignment getHorizontalImageAlignment(); + + /** + *

getVerticalImageAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.VerticalImageAlignment} object. + */ + public VerticalImageAlignment getVerticalImageAlignment(); + + /** + *

getHorizontalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.HorizontalTextAlignment} object. + */ + public HorizontalTextAlignment getHorizontalTextAlignment(); + + /** + *

getVerticalTextAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.VerticalTextAlignment} object. + */ + public VerticalTextAlignment getVerticalTextAlignment(); + + /** + *

getBorder.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIBorder} object. + */ + public DRIBorder getBorder(); + + /** + *

getPadding.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIPadding} object. + */ + public DRIPadding getPadding(); + + /** + *

getFont.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIFont} object. + */ + public DRIFont getFont(); + + /** + *

getRotation.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Rotation} object. + */ + public Rotation getRotation(); + + /** + *

getPattern.

+ * + * @return a {@link java.lang.String} object. + */ + public String getPattern(); + + /** + *

getMarkup.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.Markup} object. + */ + public Markup getMarkup(); + + /** + *

getParagraph.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIParagraph} object. + */ + public DRIParagraph getParagraph(); + + /** + *

getLinePen.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIPen} object. + */ + public DRIPen getLinePen(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIBorder.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIBorder.java new file mode 100644 index 0000000..8f1a5ca --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIBorder.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +import java.io.Serializable; + +/** + *

DRIBorder interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIBorder extends Serializable { + + /** + *

getTopPen.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIPen} object. + */ + public DRIPen getTopPen(); + + /** + *

getLeftPen.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIPen} object. + */ + public DRIPen getLeftPen(); + + /** + *

getBottomPen.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIPen} object. + */ + public DRIPen getBottomPen(); + + /** + *

getRightPen.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIPen} object. + */ + public DRIPen getRightPen(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIConditionalStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIConditionalStyle.java new file mode 100644 index 0000000..4c20934 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIConditionalStyle.java @@ -0,0 +1,36 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +import software.xdev.dynamicreports.report.definition.expression.DRIExpression; + +/** + *

DRIConditionalStyle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIConditionalStyle extends DRIBaseStyle { + + /** + *

getConditionExpression.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.expression.DRIExpression} object. + */ + public DRIExpression getConditionExpression(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIFont.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIFont.java new file mode 100644 index 0000000..8a7ad86 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIFont.java @@ -0,0 +1,92 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +import java.io.Serializable; + +/** + *

DRIFont interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIFont extends Serializable { + + /** + *

getFontName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getFontName(); + + /** + *

getBold.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getBold(); + + /** + *

getItalic.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getItalic(); + + /** + *

getUnderline.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getUnderline(); + + /** + *

getStrikeThrough.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getStrikeThrough(); + + /** + *

getFontSize.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getFontSize(); + + /** + *

getPdfFontName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getPdfFontName(); + + /** + *

getPdfEncoding.

+ * + * @return a {@link java.lang.String} object. + */ + public String getPdfEncoding(); + + /** + *

getPdfEmbedded.

+ * + * @return a {@link java.lang.Boolean} object. + */ + public Boolean getPdfEmbedded(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIPadding.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIPadding.java new file mode 100644 index 0000000..f754ebe --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIPadding.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +import java.io.Serializable; + +/** + *

DRIPadding interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIPadding extends Serializable { + + /** + *

getTop.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getTop(); + + /** + *

getLeft.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getLeft(); + + /** + *

getBottom.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getBottom(); + + /** + *

getRight.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getRight(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIParagraph.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIParagraph.java new file mode 100644 index 0000000..5a9423d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIParagraph.java @@ -0,0 +1,95 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +import software.xdev.dynamicreports.report.constant.LineSpacing; + +import java.io.Serializable; +import java.util.List; + +/** + *

DRIParagraph interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIParagraph extends Serializable { + + /** + *

getLineSpacing.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.LineSpacing} object. + */ + public LineSpacing getLineSpacing(); + + /** + *

getLineSpacingSize.

+ * + * @return a {@link java.lang.Float} object. + */ + public Float getLineSpacingSize(); + + /** + *

getFirstLineIndent.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getFirstLineIndent(); + + /** + *

getLeftIndent.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getLeftIndent(); + + /** + *

getRightIndent.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getRightIndent(); + + /** + *

getSpacingBefore.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getSpacingBefore(); + + /** + *

getSpacingAfter.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getSpacingAfter(); + + /** + *

getTabStopWidth.

+ * + * @return a {@link java.lang.Integer} object. + */ + public Integer getTabStopWidth(); + + /** + *

getTabStops.

+ * + * @return a {@link java.util.List} object. + */ + public List getTabStops(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIPen.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIPen.java new file mode 100644 index 0000000..0abc9bf --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIPen.java @@ -0,0 +1,53 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +import software.xdev.dynamicreports.report.constant.LineStyle; + +import java.awt.Color; +import java.io.Serializable; + +/** + *

DRIPen interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIPen extends Serializable { + + /** + *

getLineWidth.

+ * + * @return a {@link java.lang.Float} object. + */ + public Float getLineWidth(); + + /** + *

getLineStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.LineStyle} object. + */ + public LineStyle getLineStyle(); + + /** + *

getLineColor.

+ * + * @return a {@link java.awt.Color} object. + */ + public Color getLineColor(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIReportStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIReportStyle.java new file mode 100644 index 0000000..e1bc3e7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIReportStyle.java @@ -0,0 +1,30 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +import java.io.Serializable; + +/** + *

DRIReportStyle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIReportStyle extends Serializable { + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRISimpleStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRISimpleStyle.java new file mode 100644 index 0000000..d49ce8a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRISimpleStyle.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +/** + *

DRISimpleStyle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRISimpleStyle extends DRIBaseStyle { + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIStyle.java new file mode 100644 index 0000000..f07bbbc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRIStyle.java @@ -0,0 +1,50 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +import java.util.List; + +/** + *

DRIStyle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRIStyle extends DRIBaseStyle, DRIReportStyle { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + + /** + *

getParentStyle.

+ * + * @return a {@link software.xdev.dynamicreports.report.definition.style.DRIReportStyle} object. + */ + public DRIReportStyle getParentStyle(); + + /** + *

getConditionalStyles.

+ * + * @return a {@link java.util.List} object. + */ + public List getConditionalStyles(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRITabStop.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRITabStop.java new file mode 100644 index 0000000..66bbdbd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRITabStop.java @@ -0,0 +1,45 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +import software.xdev.dynamicreports.report.constant.TabStopAlignment; + +import java.io.Serializable; + +/** + *

DRITabStop interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRITabStop extends Serializable { + + /** + *

getPosition.

+ * + * @return a int. + */ + public int getPosition(); + + /** + *

getAlignment.

+ * + * @return a {@link software.xdev.dynamicreports.report.constant.TabStopAlignment} object. + */ + public TabStopAlignment getAlignment(); +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRITemplateStyle.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRITemplateStyle.java new file mode 100644 index 0000000..6222604 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/definition/style/DRITemplateStyle.java @@ -0,0 +1,35 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.definition.style; + +/** + *

DRITemplateStyle interface.

+ * + * @author Ricardo Mariaca + * + */ +public interface DRITemplateStyle extends DRIReportStyle { + + /** + *

getName.

+ * + * @return a {@link java.lang.String} object. + */ + public String getName(); + +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/exception/DRException.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/exception/DRException.java new file mode 100644 index 0000000..f4c6d73 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/exception/DRException.java @@ -0,0 +1,58 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.exception; + +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRException class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRException extends Exception { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for DRException.

+ * + * @param message a {@link java.lang.String} object. + */ + public DRException(String message) { + super(message); + } + + /** + *

Constructor for DRException.

+ * + * @param cause a {@link java.lang.Throwable} object. + */ + public DRException(Throwable cause) { + super(cause); + } + + /** + *

Constructor for DRException.

+ * + * @param message a {@link java.lang.String} object. + * @param cause a {@link java.lang.Throwable} object. + */ + public DRException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/exception/DRReportException.java b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/exception/DRReportException.java new file mode 100644 index 0000000..7264df7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/java/software/xdev/dynamicreports/report/exception/DRReportException.java @@ -0,0 +1,58 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.report.exception; + +import software.xdev.dynamicreports.report.constant.Constants; + +/** + *

DRReportException class.

+ * + * @author Ricardo Mariaca + * + */ +public class DRReportException extends RuntimeException { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + /** + *

Constructor for DRReportException.

+ * + * @param message a {@link java.lang.String} object. + */ + public DRReportException(String message) { + super(message); + } + + /** + *

Constructor for DRReportException.

+ * + * @param cause a {@link java.lang.Throwable} object. + */ + public DRReportException(Throwable cause) { + super(cause); + } + + /** + *

Constructor for DRReportException.

+ * + * @param message a {@link java.lang.String} object. + * @param cause a {@link java.lang.Throwable} object. + */ + public DRReportException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/dynamicreports-messages.properties b/dynamicreports-core-for-grid-exporter/src/main/resources/dynamicreports-messages.properties new file mode 100644 index 0000000..325400e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/dynamicreports-messages.properties @@ -0,0 +1,11 @@ +page_x_of_y={0} of {1} +page_x_slash_y={0}/{1} +total_pages={0} +page_number={0} +current_date={0} +total=Total +true=True +false=False +yes=Yes +no=No +table_of_contents=Table of contents \ No newline at end of file diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/fonts.xml b/dynamicreports-core-for-grid-exporter/src/main/resources/fonts.xml new file mode 100644 index 0000000..e48e79a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/fonts.xml @@ -0,0 +1,23 @@ + + + + + + + Arial, Helvetica, sans-serif + + + + + + 'Times New Roman', Times, serif + + + + + + 'Courier New', Courier, monospace + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/jasperreports_extension.properties b/dynamicreports-core-for-grid-exporter/src/main/resources/jasperreports_extension.properties new file mode 100644 index 0000000..f869f8c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/jasperreports_extension.properties @@ -0,0 +1,2 @@ +net.sf.jasperreports.extension.registry.factory.system.font.families=software.xdev.dynamicreports.jasper.base.JasperSystemFontExtensionsRegistryFactory +net.sf.jasperreports.extension.system.font.families.drfonts=fonts.xml diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/defaults/schema/dynamicreports.xjb b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/defaults/schema/dynamicreports.xjb new file mode 100644 index 0000000..9d87d0f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/defaults/schema/dynamicreports.xjb @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/defaults/schema/dynamicreports.xsd b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/defaults/schema/dynamicreports.xsd new file mode 100644 index 0000000..a89bc60 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/defaults/schema/dynamicreports.xsd @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/ball_green.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/ball_green.svg new file mode 100644 index 0000000..6f9f13b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/ball_green.svg @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + icon + button + submit + add + ok + green + yes + positive + good + confirm + + + + + Lumen Design Studio + + + + + Lumen Design Studio + + + + round submit icon + green round submit icon + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/ball_red.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/ball_red.svg new file mode 100644 index 0000000..d689377 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/ball_red.svg @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + round error warning button + + + Lumen Design Studio + + + + + Lumen Design Studio + + + error warning icon + + + error + icon + button + red + stop + no + warning + negative + delete + cancel + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean1_false.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean1_false.svg new file mode 100644 index 0000000..9f3f8ea --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean1_false.svg @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean1_true.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean1_true.svg new file mode 100644 index 0000000..ece0533 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean1_true.svg @@ -0,0 +1,209 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean2_false.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean2_false.svg new file mode 100644 index 0000000..f2632bc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean2_false.svg @@ -0,0 +1,161 @@ + + + + + + + + Delete icon + Red round glosy Delete icon + + + delete + no + no access + denied + red + round + glosy + button + icon + + + + + Open Clip Art Library + + + + + Jakub Jankiewicz + + + + + Jakub Jankiewicz + + + + image/svg+xml + + + pl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean2_true.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean2_true.svg new file mode 100644 index 0000000..df85d69 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean2_true.svg @@ -0,0 +1,80 @@ + + + + + + + + OK icon + Green round glosy OK icon + + + ok + check + icon + green + round + glosy + button + + + + + Open Clip Art Library + + + + + Jakub Jankiewicz + + + + + Jakub Jankiewicz + + + + image/svg+xml + + + pl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean3_false.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean3_false.svg new file mode 100644 index 0000000..2d6730b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean3_false.svg @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean3_true.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean3_true.svg new file mode 100644 index 0000000..c39e423 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean3_true.svg @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean4_false.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean4_false.svg new file mode 100644 index 0000000..0bdee01 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/boolean4_false.svg @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Add + 2005-10-30 + + + Jean-Victor Balin + + + jean.victor.balin@gmail.com + + + + icon + add + plus + + + fr-FR + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/checkbox1_true.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/checkbox1_true.svg new file mode 100644 index 0000000..03f6339 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/checkbox1_true.svg @@ -0,0 +1,65 @@ + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/checkbox2_true.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/checkbox2_true.svg new file mode 100644 index 0000000..e6781e7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/checkbox2_true.svg @@ -0,0 +1,66 @@ + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/checkbox_false.svg b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/checkbox_false.svg new file mode 100644 index 0000000..4d2e4fd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/main/resources/software/xdev/dynamicreports/report/images/checkbox_false.svg @@ -0,0 +1,61 @@ + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/TestDefault.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/TestDefault.java new file mode 100644 index 0000000..99ed16a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/TestDefault.java @@ -0,0 +1,29 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports; + +import software.xdev.dynamicreports.report.defaults.Default; + + +public class TestDefault extends Default +{ + public TestDefault() + { + this.getFont().setFontName("Arimo"); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/jasper/base/JasperCustomValuesTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/jasper/base/JasperCustomValuesTest.java new file mode 100644 index 0000000..74f9b48 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/jasper/base/JasperCustomValuesTest.java @@ -0,0 +1,67 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.jasper.base; + +import static software.xdev.dynamicreports.jasper.base.JasperScriptletManager.USE_THREAD_SAFE_SCRIPLET_MANAGER_PROPERTY_KEY; + +import java.util.Properties; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Unit tests for {@link JasperCustomValues}. + */ +public class JasperCustomValuesTest { + + private JasperScriptlet scriptlet = new JasperScriptlet(); + + @Test + public void shouldUseDefaultScriptletManager() { + JasperCustomValues cut = createClassUnderTest(false); + Assertions.assertTrue(cut.getScriptletManager() instanceof DefaultJasperScriptletManager); + } + + @Test + public void shouldUseThreadSafeScriptleManagerIfPropertySet() { + JasperCustomValues cut = createClassUnderTest(true); + Assertions.assertTrue(cut.getScriptletManager() instanceof ThreadSafeJasperScriptletManager); + } + + @Test + public void shouldSetScriptletWithDefaultManager() { + JasperCustomValues cut = createClassUnderTest(false); + cut.setJasperScriptlet(scriptlet); + Assertions.assertEquals(scriptlet, cut.getJasperScriptlet()); + } + + @Test + public void shouldSetScriptletWithThreadSafeManager() { + JasperCustomValues cut = createClassUnderTest(true); + cut.setJasperScriptlet(scriptlet); + Assertions.assertEquals(scriptlet, cut.getJasperScriptlet()); + } + + private JasperCustomValues createClassUnderTest(boolean useThreadSafeManager) { + Properties properties = new Properties(); + if (useThreadSafeManager) { + properties.setProperty(USE_THREAD_SAFE_SCRIPLET_MANAGER_PROPERTY_KEY, "true"); + } + return new JasperCustomValues(properties); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/report/ReportUtilsTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/report/ReportUtilsTest.java new file mode 100644 index 0000000..15c710f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/report/ReportUtilsTest.java @@ -0,0 +1,81 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package software.xdev.dynamicreports.report; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.stream.IntStream; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +/** + * Unit tests for {@link ReportUtils}. + */ +public class ReportUtilsTest { + + private static final String BASE_NAME = "any name"; + private static final int NUMBER_OF_THREADS = 20; + private static final int NUMBER_OF_NAMES = 1000; + + @BeforeEach + public void setUp() { + ReportUtils.setCounter(1); + } + + @Test + public void shouldGenerateUniqueNamesConcurrently() throws Exception { + final ExecutorService executor = Executors.newFixedThreadPool(NUMBER_OF_THREADS); + try { + final List> futureNames = this.submitTasks(executor); + this.assertUniqueNames(futureNames); + } finally { + executor.shutdown(); + } + } + + @Test + public void shouldResetCounter() { + ReportUtils.setCounter(Integer.MAX_VALUE); + final String name = ReportUtils.generateUniqueName(BASE_NAME); + Assertions.assertTrue(name.endsWith("0_")); + } + + private List> submitTasks(final ExecutorService executor) { + final Callable task = () -> ReportUtils.generateUniqueName(BASE_NAME); + final List> futureNames = new ArrayList<>(); + IntStream.range(0, NUMBER_OF_NAMES).forEach(i -> futureNames.add(executor.submit(task))); + return futureNames; + } + + private void assertUniqueNames(final List> futureNames) throws Exception { + final Set generatedNames = new HashSet<>(); + for (final Future futureName : futureNames) { + generatedNames.add(futureName.get()); + } + Assertions.assertEquals(NUMBER_OF_NAMES, generatedNames.size()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/report/builder/style/StyleBuildersTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/report/builder/style/StyleBuildersTest.java new file mode 100644 index 0000000..0e47206 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/report/builder/style/StyleBuildersTest.java @@ -0,0 +1,107 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package software.xdev.dynamicreports.report.builder.style; + +import static software.xdev.dynamicreports.report.constant.FontName.ARIAL; +import static software.xdev.dynamicreports.report.constant.FontName.COURIER_NEW; +import static software.xdev.dynamicreports.report.constant.FontName.TIMES_NEW_ROMAN; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Integration tests for {@link StyleBuilders}. + */ +public class StyleBuildersTest { + + private StyleBuilders cut = new StyleBuilders(); + + @Test + public void shouldCreateFontBuilderWithArial() { + FontBuilder fontBuilder = cut.fontArial(); + Assertions.assertEquals(ARIAL, fontBuilder.getFont().getFontName()); + Assertions.assertFalse(fontBuilder.getFont().getBold()); + Assertions.assertFalse(fontBuilder.getFont().getItalic()); + } + + @Test + public void shouldCreateFontBuilderWithArialBold() { + FontBuilder fontBuilder = cut.fontArialBold(); + Assertions.assertEquals(ARIAL, fontBuilder.getFont().getFontName()); + Assertions.assertTrue(fontBuilder.getFont().getBold()); + Assertions.assertFalse(fontBuilder.getFont().getItalic()); + } + + @Test + public void shouldCreateFontBuilderWithArialBoldItalic() { + FontBuilder fontBuilder = cut.fontArialBold().italic(); + Assertions.assertEquals(ARIAL, fontBuilder.getFont().getFontName()); + Assertions.assertTrue(fontBuilder.getFont().getBold()); + Assertions.assertTrue(fontBuilder.getFont().getItalic()); + } + + @Test + public void shouldCreateFontBuilderWithTimesNewRoman() { + FontBuilder fontBuilder = cut.fontTimesNewRoman(); + Assertions.assertEquals(TIMES_NEW_ROMAN, fontBuilder.getFont().getFontName()); + Assertions.assertFalse(fontBuilder.getFont().getBold()); + Assertions.assertFalse(fontBuilder.getFont().getItalic()); + } + + @Test + public void shouldCreateFontBuilderWithTimesNewRomanBold() { + FontBuilder fontBuilder = cut.fontTimesNewRomanBold(); + Assertions.assertEquals(TIMES_NEW_ROMAN, fontBuilder.getFont().getFontName()); + Assertions.assertTrue(fontBuilder.getFont().getBold()); + Assertions.assertFalse(fontBuilder.getFont().getItalic()); + } + + @Test + public void shouldCreateFontBuilderWithTimesNewRomanBoldItalic() { + FontBuilder fontBuilder = cut.fontTimesNewRomanBold().italic(); + Assertions.assertEquals(TIMES_NEW_ROMAN, fontBuilder.getFont().getFontName()); + Assertions.assertTrue(fontBuilder.getFont().getBold()); + Assertions.assertTrue(fontBuilder.getFont().getItalic()); + } + + @Test + public void shouldCreateFontBuilderWithCourierNew() { + FontBuilder fontBuilder = cut.fontCourierNew(); + Assertions.assertEquals(COURIER_NEW, fontBuilder.getFont().getFontName()); + Assertions.assertFalse(fontBuilder.getFont().getBold()); + Assertions.assertFalse(fontBuilder.getFont().getItalic()); + } + + @Test + public void shouldCreateFontBuilderWithCourierNewBold() { + FontBuilder fontBuilder = cut.fontCourierNewBold(); + Assertions.assertEquals(COURIER_NEW, fontBuilder.getFont().getFontName()); + Assertions.assertTrue(fontBuilder.getFont().getBold()); + Assertions.assertFalse(fontBuilder.getFont().getItalic()); + } + + @Test + public void shouldCreateFontBuilderWithCourierNewBoldItalic() { + FontBuilder fontBuilder = cut.fontCourierNewBold().italic(); + Assertions.assertEquals(COURIER_NEW, fontBuilder.getFont().getFontName()); + Assertions.assertTrue(fontBuilder.getFont().getBold()); + Assertions.assertTrue(fontBuilder.getFont().getItalic()); + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/base/ConditionsTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/base/ConditionsTest.java new file mode 100644 index 0000000..d12030c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/base/ConditionsTest.java @@ -0,0 +1,248 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.base; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cnd; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; + +import java.sql.Connection; +import java.util.Locale; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.definition.DRIScriptlet; +import software.xdev.dynamicreports.report.definition.DRIValue; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRISimpleExpression; + + +/** + * @author Ricardo Mariaca + */ +class ConditionsTest +{ + + @Test + void test() + { + // equal + final FieldBuilder value = field("name", Integer.class); + // conditionTrue("equal", cnd.equal(value, 5, 10, 20)); + // conditionFalse("equal", cnd.equal(value, 5, 20)); + + // unequal + // conditionFalse("unequal", cnd.unEqual(value, 5, 10, 20)); + // conditionTrue("unequal", cnd.unEqual(value, 5, 20)); + + // smaller + this.conditionFalse("smaller", cnd.smaller(value, 5)); + this.conditionFalse("smaller", cnd.smaller(value, 10)); + this.conditionTrue("smaller", cnd.smaller(value, 15)); + + // smallerOrEquals + this.conditionFalse("smallerOrEquals", cnd.smallerOrEquals(value, 5)); + this.conditionTrue("smallerOrEquals", cnd.smallerOrEquals(value, 10)); + this.conditionTrue("smallerOrEquals", cnd.smallerOrEquals(value, 15)); + + // greater + this.conditionTrue("greater", cnd.greater(value, 5)); + this.conditionFalse("greater", cnd.greater(value, 10)); + this.conditionFalse("greater", cnd.greater(value, 15)); + + // greaterOrEquals + this.conditionTrue("greaterOrEquals", cnd.greaterOrEquals(value, 5)); + this.conditionTrue("greaterOrEquals", cnd.greaterOrEquals(value, 10)); + this.conditionFalse("greaterOrEquals", cnd.greaterOrEquals(value, 15)); + + // between + this.conditionTrue("between", cnd.between(value, 5, 15)); + this.conditionTrue("between", cnd.between(value, 5, 10)); + this.conditionTrue("between", cnd.between(value, 10, 20)); + this.conditionFalse("between", cnd.between(value, 5, 9)); + this.conditionFalse("between", cnd.between(value, 11, 20)); + + // notBetween + this.conditionFalse("notBetween", cnd.notBetween(value, 5, 15)); + this.conditionFalse("notBetween", cnd.notBetween(value, 5, 10)); + this.conditionFalse("notBetween", cnd.notBetween(value, 10, 20)); + this.conditionTrue("notBetween", cnd.notBetween(value, 5, 9)); + this.conditionTrue("notBetween", cnd.notBetween(value, 11, 20)); + + // equal object + final FieldBuilder value2 = field("name", Object.class); + this.conditionTrue("equal", cnd.equal(value2, Type.A, Type.C, Type.F), Type.C); + this.conditionFalse("equal", cnd.equal(value2, Type.B, Type.C), Type.E); + + // unequal object + this.conditionFalse("unequal", cnd.unEqual(value2, Type.A, Type.C, Type.F), Type.C); + this.conditionTrue("unequal", cnd.unEqual(value2, Type.B, Type.C), Type.E); + } + + private void conditionTrue(final String name, final DRISimpleExpression condition) + { + Assertions.assertTrue(condition.evaluate(new TestReportParameters(10)), name + " condition"); + } + + private void conditionFalse(final String name, final DRISimpleExpression condition) + { + Assertions.assertFalse(condition.evaluate(new TestReportParameters(10)), name + " condition"); + } + + private void conditionTrue(final String name, final DRISimpleExpression condition, final Object actualValue) + { + Assertions.assertTrue(condition.evaluate(new TestReportParameters(actualValue)), name + " condition"); + } + + private void conditionFalse(final String name, final DRISimpleExpression condition, final Object actualValue) + { + Assertions.assertFalse(condition.evaluate(new TestReportParameters(actualValue)), name + " condition"); + } + + private enum Type + { + A, B, C, D, E, F + } + + + private static class TestReportParameters implements ReportParameters + { + private final Object value; + + public TestReportParameters(final Object value) + { + this.value = value; + } + + @Override + public Integer getColumnNumber() + { + return null; + } + + @Override + public Integer getColumnRowNumber() + { + return null; + } + + @Override + public Connection getConnection() + { + return null; + } + + @Override + public Integer getGroupCount(final String groupName) + { + return null; + } + + @Override + public Locale getLocale() + { + return null; + } + + @Override + public String getMessage(final String key) + { + return null; + } + + @Override + public String getMessage(final String key, final Object[] arguments) + { + return null; + } + + @Override + public Integer getPageNumber() + { + return null; + } + + @Override + public Integer getPageRowNumber() + { + return null; + } + + @Override + public Integer getReportRowNumber() + { + return null; + } + + @Override + public Integer getCrosstabRowNumber() + { + return null; + } + + @Override + public DRIScriptlet getScriptlet(final String name) + { + return null; + } + + @Override + public T getValue(final String name) + { + return null; + } + + @Override + @SuppressWarnings("unchecked") + public T getValue(final DRIValue value) + { + return (T)this.value; + } + + @Override + public ReportParameters getMasterParameters() + { + return null; + } + + @Override + public Integer getSubreportWidth() + { + return null; + } + + @Override + public T getFieldValue(final String name) + { + return null; + } + + @Override + public T getVariableValue(final String name) + { + return null; + } + + @Override + public T getParameterValue(final String name) + { + return null; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/base/DataTypeTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/base/DataTypeTest.java new file mode 100644 index 0000000..b25a0eb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/base/DataTypeTest.java @@ -0,0 +1,161 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.base; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.report.builder.datatype.BigDecimalType; +import software.xdev.dynamicreports.report.builder.datatype.StringType; +import software.xdev.dynamicreports.report.definition.datatype.DRIDataType; +import software.xdev.dynamicreports.report.exception.DRException; + + +/** + * @author Ricardo Mariaca + */ +class DataTypeTest +{ + @Test + void detectTypeTest() + { + try + { + this.detectTypeTest(type.bigDecimalType(), BigDecimal.class); + this.detectTypeTest(type.bigIntegerType(), BigInteger.class); + this.detectTypeTest(type.byteType(), Byte.class); + this.detectTypeTest(type.doubleType(), Double.class); + this.detectTypeTest(type.floatType(), Float.class); + this.detectTypeTest(type.integerType(), Integer.class); + this.detectTypeTest(type.longType(), Long.class); + this.detectTypeTest(type.shortType(), Short.class); + this.detectTypeTest(type.dateType(), Date.class); + this.detectTypeTest(type.dateYearToMonthType(), "DateYearToMonth"); + this.detectTypeTest(type.dateYearToHourType(), "DateYearToHour"); + this.detectTypeTest(type.dateYearToMinuteType(), "DateYearToMinute"); + this.detectTypeTest(type.dateYearToSecondType(), "DateYearToSecond"); + this.detectTypeTest(type.dateYearToFractionType(), "DateYearToFraction"); + this.detectTypeTest(type.dateYearType(), "DateYear"); + this.detectTypeTest(type.dateMonthType(), "DateMonth"); + this.detectTypeTest(type.dateDayType(), "DateDay"); + this.detectTypeTest(type.timeHourToMinuteType(), "TimeHourToMinute"); + this.detectTypeTest(type.timeHourToSecondType(), "TimeHourToSecond"); + this.detectTypeTest(type.timeHourToFractionType(), "TimeHourToFraction"); + this.detectTypeTest(type.percentageType(), "Percentage"); + this.detectTypeTest(type.booleanType(), Boolean.class); + this.detectTypeTest(type.characterType(), Character.class); + this.detectTypeTest(type.stringType(), String.class); + this.detectTypeTest(type.stringType(), "Text"); + this.detectTypeTest(type.listType(), List.class); + + @SuppressWarnings("unused") + final BigDecimalType bigDecimalType = type.detectType(BigDecimal.class); + @SuppressWarnings("unused") + final StringType stringType = type.detectType(String.class); + } + catch(final DRException e) + { + Assertions.fail(e.getMessage()); + } + } + + public void detectTypeTest(final DRIDataType dataType, final Class valueClass) throws DRException + { + this.detectTypeTest(dataType, valueClass.getSimpleName()); + Assertions.assertEquals(dataType.getClass(), type.detectType(valueClass.getName()).getClass()); + Assertions.assertEquals(dataType.getClass(), type.detectType(valueClass).getClass()); + } + + public void detectTypeTest(final DRIDataType dataType, final String... dataTypes) throws DRException + { + for(final String stringDataType : dataTypes) + { + Assertions.assertEquals(dataType.getClass(), type.detectType(stringDataType).getClass()); + Assertions.assertEquals(dataType.getClass(), type.detectType(stringDataType.toLowerCase()).getClass()); + Assertions.assertEquals(dataType.getClass(), type.detectType(stringDataType.toUpperCase()).getClass()); + } + } + + @Test + void valueConversionTest() + { + this.valueConversionTest("BigDecimal", type.bigDecimalType(), 1000, "1,000.00"); + this.valueConversionTest("BigInteger", type.bigIntegerType(), 1000, "1,000"); + this.valueConversionTest("Byte", type.byteType(), 100, "100"); + this.valueConversionTest("Double", type.doubleType(), 1000.1, "1,000.1"); + this.valueConversionTest("Float", type.floatType(), 1000.1, "1,000.1"); + this.valueConversionTest("Integer", type.integerType(), 1000, "1,000"); + this.valueConversionTest("Long", type.longType(), 1000, "1,000"); + this.valueConversionTest("Short", type.shortType(), 1000, "1,000"); + + final Calendar c = Calendar.getInstance(); + c.set(2010, 0, 2, 15, 5, 20); + c.set(Calendar.MILLISECOND, 100); + final Date date = c.getTime(); + this.valueConversionTest("Date", type.dateType(), date, "01/02/2010"); + this.valueConversionTest("DateYearToMonth", type.dateYearToMonthType(), date, "01/2010"); + this.valueConversionTest("DateYearToHour", type.dateYearToHourType(), date, "01/02/2010 3 PM"); + this.valueConversionTest("DateYearToMinute", type.dateYearToMinuteType(), date, "01/02/2010 3:05 PM"); + this.valueConversionTest("DateYearToSecond", type.dateYearToSecondType(), date, "01/02/2010 3:05:20 PM"); + this.valueConversionTest("DateYearToFraction", type.dateYearToFractionType(), date, "01/02/2010 3:05:20,100 PM"); + this.valueConversionTest("DateYear", type.dateYearType(), date, "2010"); + this.valueConversionTest("DateMonth", type.dateMonthType(), date, "January"); + this.valueConversionTest("DateDay", type.dateDayType(), date, "02"); + this.valueConversionTest("TimeHourToMinute", type.timeHourToMinuteType(), date, "3:05 PM"); + this.valueConversionTest("TimeHourToSecond", type.timeHourToSecondType(), date, "3:05:20 PM"); + this.valueConversionTest("TimeHourToFraction", type.timeHourToFractionType(), date, "3:05:20,100 PM"); + + this.valueConversionTest("Percentage", type.percentageType(), 0.89156, "89.16%"); + this.valueConversionTest("Boolean", type.booleanType(), true, "true"); + this.valueConversionTest("Character", type.characterType(), 'a', "a"); + this.valueConversionTest("String", type.stringType(), "text", "text"); + } + + private void valueConversionTest( + final String name, + final DRIDataType dataType, + final U value, + final String stringValue) + { + Assertions.assertEquals(stringValue, dataType.valueToString(value, Locale.ENGLISH)); + + try + { + final String stringResult = dataType.valueToString(value, Locale.ENGLISH); + final U stringToValue = dataType.stringToValue(stringValue, Locale.ENGLISH); + Assertions.assertTrue( + stringToValue.getClass().equals(dataType.getValueClass())); + Assertions.assertEquals( + stringResult, + dataType.valueToString(stringToValue, Locale.ENGLISH)); + } + catch(final DRException e) + { + Assertions.fail(e.getMessage()); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/bugs/Bug_2997586_Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/bugs/Bug_2997586_Test.java new file mode 100644 index 0000000..6842b4c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/bugs/Bug_2997586_Test.java @@ -0,0 +1,55 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.bugs; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.report.builder.component.TextFieldBuilder; + + +/** + * @author Ricardo Mariaca + *

+ * The height in setDimension(Integer width, Integer height) of the DimensionComponentBuilder class is set with the + * width. + */ +class Bug_2997586_Test +{ + + @Test + void test() + { + final Integer width = 150; + final Integer height = 200; + + TextFieldBuilder textField = cmp.text("").setDimension(width, height); + Assertions.assertEquals(width, textField.getComponent().getWidth()); + Assertions.assertEquals(height, textField.getComponent().getHeight()); + + textField = cmp.text("").setFixedDimension(width, height); + Assertions.assertEquals(width, textField.getComponent().getWidth()); + Assertions.assertEquals(height, textField.getComponent().getHeight()); + + textField = cmp.text("").setMinDimension(width, height); + Assertions.assertEquals(width, textField.getComponent().getWidth()); + Assertions.assertEquals(height, textField.getComponent().getHeight()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/AbstractBandTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/AbstractBandTest.java new file mode 100644 index 0000000..178a465 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/AbstractBandTest.java @@ -0,0 +1,128 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.design.base.DRDesignBand; +import software.xdev.dynamicreports.design.base.DRDesignReport; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.exception.DRException; + + +/** + * @author Ricardo Mariaca + */ +public abstract class AbstractBandTest +{ + + @Test + public void test() + { + final ReportBuilder rb = new DesignReportBuilder(); + this.configureReport(rb); + try + { + final DRDesignReport report = new DRDesignReport(rb.getReport()); + this.titleBandTest(report.getTitleBand()); + this.pageHeaderBandTest(report.getPageHeaderBand()); + this.pageFooterBandTest(report.getPageFooterBand()); + this.columnHeaderBandTest(report.getColumnHeaderBand()); + this.columnFooterBandTest(report.getColumnFooterBand()); + for(final DRDesignBand designBand : report.getDetailBands()) + { + this.detailBandTest(designBand); + } + this.lastPageFooterBandTest(report.getLastPageFooterBand()); + this.summaryBandTest(report.getSummaryBand()); + this.noDataBandTest(report.getNoDataBand()); + this.backgroundBandTest(report.getBackgroundBand()); + } + catch(final DRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } + + protected void titleBandTest(final DRDesignBand band) + { + Assertions.assertNull(band); + } + + protected void pageHeaderBandTest(final DRDesignBand band) + { + Assertions.assertNull(band); + } + + protected void pageFooterBandTest(final DRDesignBand band) + { + Assertions.assertNull(band); + } + + protected void columnHeaderBandTest(final DRDesignBand band) + { + Assertions.assertNull(band); + } + + protected void columnFooterBandTest(final DRDesignBand band) + { + Assertions.assertNull(band); + } + + protected void detailBandTest(final DRDesignBand band) + { + Assertions.assertNull(band); + } + + protected void lastPageFooterBandTest(final DRDesignBand band) + { + Assertions.assertNull(band); + } + + protected void summaryBandTest(final DRDesignBand band) + { + Assertions.assertNull(band); + } + + protected void noDataBandTest(final DRDesignBand band) + { + Assertions.assertNull(band); + } + + protected void backgroundBandTest(final DRDesignBand band) + { + Assertions.assertNull(band); + } + + protected void componentPositionTest(final DRDesignComponent component, final int x, final int y, final int width, final int height) + { + Assertions.assertNotNull(component.getWidth()); + Assertions.assertEquals(Integer.valueOf(width), component.getWidth()); + Assertions.assertNotNull(component.getHeight()); + Assertions.assertEquals(Integer.valueOf(height), component.getHeight()); + Assertions.assertNotNull(component.getX()); + Assertions.assertEquals(Integer.valueOf(x), component.getX()); + Assertions.assertNotNull(component.getY()); + Assertions.assertEquals(Integer.valueOf(y), component.getY()); + } + + public abstract void configureReport(ReportBuilder rb); +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/DesignReportBuilder.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/DesignReportBuilder.java new file mode 100644 index 0000000..80e8423 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/DesignReportBuilder.java @@ -0,0 +1,36 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design; + +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.definition.DRITemplateDesign; + +/** + * @author Ricardo Mariaca + */ +public class DesignReportBuilder extends ReportBuilder { + private static final long serialVersionUID = 1L; + + public DesignReportBuilder() { + getObject().setTemplateDesign(new DesignTestTemplateDesign()); + } + + public DesignReportBuilder(DRITemplateDesign templateDesign) { + getObject().setTemplateDesign(templateDesign); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/DesignTestTemplateDesign.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/DesignTestTemplateDesign.java new file mode 100644 index 0000000..733d0f5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/DesignTestTemplateDesign.java @@ -0,0 +1,28 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design; + +import software.xdev.dynamicreports.report.base.AbstractTemplateDesign; + +/** + * @author Ricardo Mariaca + */ +public class DesignTestTemplateDesign extends AbstractTemplateDesign { + private static final long serialVersionUID = 1L; + +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/ColumnPosition1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/ColumnPosition1Test.java new file mode 100644 index 0000000..d853940 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/ColumnPosition1Test.java @@ -0,0 +1,67 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design.position; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.design.base.DRDesignBand; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.test.design.AbstractBandTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class ColumnPosition1Test extends AbstractBandTest { + + @Override + public void configureReport(ReportBuilder rb) { + rb.columns(col.column("Column1", "field1", Integer.class), col.column("Column2", "field2", Integer.class)); + } + + @Override + protected void columnHeaderBandTest(DRDesignBand band) { + testBand(band); + } + + @Override + protected void detailBandTest(DRDesignBand band) { + testBand(band); + } + + protected void testBand(DRDesignBand band) { + DRDesignComponent component = band.getBandComponent(); + Assertions.assertTrue(component instanceof DRDesignList); + DRDesignList list = (DRDesignList) component; + Assertions.assertEquals(ListType.HORIZONTAL, list.getType()); + Assertions.assertEquals(2, list.getComponents().size()); + componentPositionTest(list, 0, 0, 575, 16); + Assertions.assertTrue(list.getComponents().get(0) instanceof DRDesignTextField); + Assertions.assertTrue(list.getComponents().get(1) instanceof DRDesignTextField); + + // column1 + componentPositionTest(list.getComponents().get(0), 0, 0, 287, 16); + + // column2 + componentPositionTest(list.getComponents().get(1), 287, 0, 288, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/ColumnPosition2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/ColumnPosition2Test.java new file mode 100644 index 0000000..0bd4c05 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/ColumnPosition2Test.java @@ -0,0 +1,93 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design.position; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.design.base.DRDesignBand; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.ListType; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grid; + +/** + * @author Ricardo Mariaca + */ +public class ColumnPosition2Test extends ColumnPosition1Test { + + @Override + public void configureReport(ReportBuilder rb) { + TextColumnBuilder column1, column2, column3, column4, column5; + + rb.columns(column1 = col.column("Column1", "field1", Integer.class), column2 = col.column("Column2", "field2", Integer.class), column3 = col.column("Column3", "field3", Integer.class), + column4 = col.column("Column4", "field4", Integer.class).setWidth(50), column5 = col.column("Column5", "field5", Integer.class)) + .columnGrid(column1, grid.horizontalColumnGridList().add(column2, column3).newRow().add(column4, column5)); + } + + @Override + protected void testBand(DRDesignBand band) { + DRDesignComponent component = band.getBandComponent(); + Assertions.assertTrue(component instanceof DRDesignList); + DRDesignList list1 = (DRDesignList) component; + Assertions.assertEquals(ListType.HORIZONTAL, list1.getType()); + Assertions.assertEquals(2, list1.getComponents().size()); + componentPositionTest(list1, 0, 0, 575, 32); + Assertions.assertTrue(list1.getComponents().get(0) instanceof DRDesignTextField); + Assertions.assertTrue(list1.getComponents().get(1) instanceof DRDesignList); + + DRDesignList list2 = (DRDesignList) list1.getComponents().get(1); + Assertions.assertEquals(ListType.VERTICAL, list2.getType()); + Assertions.assertEquals(2, list2.getComponents().size()); + componentPositionTest(list2, 191, 0, 384, 32); + Assertions.assertTrue(list2.getComponents().get(0) instanceof DRDesignList); + Assertions.assertTrue(list2.getComponents().get(1) instanceof DRDesignList); + + DRDesignList list3 = (DRDesignList) list2.getComponents().get(0); + Assertions.assertEquals(ListType.HORIZONTAL, list3.getType()); + Assertions.assertEquals(2, list3.getComponents().size()); + componentPositionTest(list3, 191, 0, 384, 16); + Assertions.assertTrue(list3.getComponents().get(0) instanceof DRDesignTextField); + Assertions.assertTrue(list3.getComponents().get(1) instanceof DRDesignTextField); + + DRDesignList list4 = (DRDesignList) list2.getComponents().get(1); + Assertions.assertEquals(ListType.HORIZONTAL, list4.getType()); + Assertions.assertEquals(2, list4.getComponents().size()); + componentPositionTest(list4, 191, 16, 384, 16); + Assertions.assertTrue(list4.getComponents().get(0) instanceof DRDesignTextField); + Assertions.assertTrue(list4.getComponents().get(1) instanceof DRDesignTextField); + + // column1 + componentPositionTest(list1.getComponents().get(0), 0, 0, 191, 32); + + // column2 + componentPositionTest(list3.getComponents().get(0), 0, 0, 192, 16); + + // column3 + componentPositionTest(list3.getComponents().get(1), 192, 0, 192, 16); + + // column4 + componentPositionTest(list4.getComponents().get(0), 0, 0, 128, 16); + + // column5 + componentPositionTest(list4.getComponents().get(1), 128, 0, 256, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/HorizontalListPositionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/HorizontalListPositionTest.java new file mode 100644 index 0000000..38ff1bc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/HorizontalListPositionTest.java @@ -0,0 +1,68 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design.position; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.design.base.DRDesignBand; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.test.design.AbstractBandTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class HorizontalListPositionTest extends AbstractBandTest { + + @Override + public void configureReport(ReportBuilder rb) { + rb.setPageFormat(PageType.A2) + .title(cmp.horizontalList(cmp.hListCell(cmp.text("").setHeight(23)), cmp.hListCell(cmp.text("")), cmp.hListCell(cmp.text("")).widthFixed(), + cmp.hListCell(cmp.text("")).widthFixed().heightFixedOnTop(), cmp.hListCell(cmp.text("")).heightFixedOnTop(), + cmp.hListCell(cmp.text("")).widthFixed().heightFixedOnMiddle(), cmp.hListCell(cmp.text("")).heightFixedOnMiddle(), + cmp.hListCell(cmp.text("")).widthFixed().heightFixedOnBottom(), cmp.hListCell(cmp.text("")).heightFixedOnBottom())); + } + + @Override + protected void titleBandTest(DRDesignBand band) { + DRDesignComponent component = band.getBandComponent(); + Assertions.assertTrue(component instanceof DRDesignList); + DRDesignList list = (DRDesignList) component; + Assertions.assertEquals(ListType.HORIZONTAL, list.getType()); + Assertions.assertEquals(9, list.getComponents().size()); + componentPositionTest(list, 0, 0, 1170, 23); + for (int i = 0; i < 9; i++) { + Assertions.assertTrue(list.getComponents().get(i) instanceof DRDesignTextField); + } + + componentPositionTest(list.getComponents().get(0), 0, 0, 154, 23); + componentPositionTest(list.getComponents().get(1), 154, 0, 154, 23); + componentPositionTest(list.getComponents().get(2), 308, 0, 100, 23); + componentPositionTest(list.getComponents().get(3), 408, 0, 100, 16); + componentPositionTest(list.getComponents().get(4), 508, 0, 154, 16); + componentPositionTest(list.getComponents().get(5), 662, 3, 100, 16); + componentPositionTest(list.getComponents().get(6), 762, 3, 154, 16); + componentPositionTest(list.getComponents().get(7), 916, 7, 100, 16); + componentPositionTest(list.getComponents().get(8), 1016, 7, 154, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/SubtotalPositionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/SubtotalPositionTest.java new file mode 100644 index 0000000..ecb668b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/SubtotalPositionTest.java @@ -0,0 +1,123 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design.position; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.design.base.DRDesignBand; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.test.design.AbstractBandTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class SubtotalPositionTest extends AbstractBandTest { + + @Override + public void configureReport(ReportBuilder rb) { + TextColumnBuilder column3; + + rb.setShowColumnTitle(false) + .columns(col.column("Column1", "field1", Integer.class), col.column("Column2", "field2", Integer.class), column3 = col.column("Column3", "field3", Integer.class)) + .subtotalsAtTitle(sbt.sum(column3)) + .subtotalsAtPageHeader(sbt.sum(column3)) + .subtotalsAtPageFooter(sbt.sum(column3)) + .subtotalsAtColumnHeader(sbt.sum(column3)) + .subtotalsAtColumnFooter(sbt.sum(column3)) + .subtotalsAtLastPageFooter(sbt.sum(column3)) + .subtotalsAtSummary(sbt.sum(column3), sbt.aggregate(column3, Calculation.AVERAGE)); + } + + @Override + protected void titleBandTest(DRDesignBand band) { + testBand(band); + } + + @Override + protected void pageHeaderBandTest(DRDesignBand band) { + testBand(band); + } + + @Override + protected void pageFooterBandTest(DRDesignBand band) { + testBand(band); + } + + @Override + protected void columnHeaderBandTest(DRDesignBand band) { + testBand(band); + } + + @Override + protected void columnFooterBandTest(DRDesignBand band) { + testBand(band); + } + + @Override + protected void detailBandTest(DRDesignBand band) { + Assertions.assertNotNull(band); + } + + @Override + protected void lastPageFooterBandTest(DRDesignBand band) { + testBand(band); + } + + @Override + protected void summaryBandTest(DRDesignBand band) { + DRDesignComponent component = band.getBandComponent(); + Assertions.assertTrue(component instanceof DRDesignList); + DRDesignList list = (DRDesignList) component; + Assertions.assertEquals(ListType.HORIZONTAL, list.getType()); + Assertions.assertEquals(1, list.getComponents().size()); + componentPositionTest(list, 0, 0, 575, 32); + Assertions.assertTrue(list.getComponents().get(0) instanceof DRDesignList); + + list = (DRDesignList) list.getComponents().get(0); + Assertions.assertEquals(ListType.VERTICAL, list.getType()); + Assertions.assertEquals(2, list.getComponents().size()); + componentPositionTest(list, 383, 0, 192, 32); + Assertions.assertTrue(list.getComponents().get(0) instanceof DRDesignTextField); + Assertions.assertTrue(list.getComponents().get(1) instanceof DRDesignTextField); + + // column3 + componentPositionTest(list.getComponents().get(0), 383, 0, 192, 16); + componentPositionTest(list.getComponents().get(1), 383, 16, 192, 16); + } + + protected void testBand(DRDesignBand band) { + DRDesignComponent component = band.getBandComponent(); + Assertions.assertTrue(component instanceof DRDesignList); + DRDesignList list = (DRDesignList) component; + Assertions.assertEquals(ListType.HORIZONTAL, list.getType()); + Assertions.assertEquals(1, list.getComponents().size()); + componentPositionTest(list, 0, 0, 575, 16); + Assertions.assertTrue(list.getComponents().get(0) instanceof DRDesignTextField); + + // column3 + componentPositionTest(list.getComponents().get(0), 383, 0, 192, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/VerticalListPositionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/VerticalListPositionTest.java new file mode 100644 index 0000000..8e78a5d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/position/VerticalListPositionTest.java @@ -0,0 +1,71 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design.position; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.design.base.DRDesignBand; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.test.design.AbstractBandTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class VerticalListPositionTest extends AbstractBandTest { + + @Override + public void configureReport(ReportBuilder rb) { + rb.title(cmp.horizontalList(cmp.verticalList(cmp.vListCell(cmp.text("")), cmp.vListCell(cmp.text("")).heightFixed(), cmp.vListCell(cmp.text("")).widthFixedOnLeft().heightFixed(), + cmp.vListCell(cmp.text("")).widthFixedOnLeft(), cmp.vListCell(cmp.text("")).widthFixedOnCenter().heightFixed(), + cmp.vListCell(cmp.text("")).widthFixedOnCenter(), cmp.vListCell(cmp.text("")).widthFixedOnRight().heightFixed(), + cmp.vListCell(cmp.text("")).widthFixedOnRight()), cmp.filler().setHeight(200))); + } + + @Override + protected void titleBandTest(DRDesignBand band) { + DRDesignComponent component = band.getBandComponent(); + Assertions.assertTrue(component instanceof DRDesignList); + DRDesignList list = (DRDesignList) component; + Assertions.assertEquals(ListType.HORIZONTAL, list.getType()); + Assertions.assertEquals(1, list.getComponents().size()); + componentPositionTest(list, 0, 0, 575, 200); + Assertions.assertTrue(list.getComponents().get(0) instanceof DRDesignList); + + list = (DRDesignList) list.getComponents().get(0); + Assertions.assertEquals(ListType.VERTICAL, list.getType()); + Assertions.assertEquals(8, list.getComponents().size()); + componentPositionTest(list, 0, 0, 575, 200); + for (int i = 0; i < 8; i++) { + Assertions.assertTrue(list.getComponents().get(i) instanceof DRDesignTextField); + } + + componentPositionTest(list.getComponents().get(0), 0, 0, 575, 34); + componentPositionTest(list.getComponents().get(1), 0, 34, 575, 16); + componentPositionTest(list.getComponents().get(2), 0, 50, 100, 16); + componentPositionTest(list.getComponents().get(3), 0, 66, 100, 34); + componentPositionTest(list.getComponents().get(4), 237, 100, 100, 16); + componentPositionTest(list.getComponents().get(5), 237, 116, 100, 34); + componentPositionTest(list.getComponents().get(6), 475, 150, 100, 16); + componentPositionTest(list.getComponents().get(7), 475, 166, 100, 34); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/BandBackgroundTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/BandBackgroundTest.java new file mode 100644 index 0000000..342c12c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/BandBackgroundTest.java @@ -0,0 +1,171 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.template; + +import java.util.ArrayList; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.base.DRDesignReport; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignRectangle; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.builder.ReportTemplateBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.exception.DRException; +import software.xdev.dynamicreports.test.design.DesignReportBuilder; + + +/** + * @author Ricardo Mariaca + */ +class BandBackgroundTest +{ + + @Test + void styleTest() + { + final ReportBuilder rb = new DesignReportBuilder(); + final TextColumnBuilder column1; + final TextColumnBuilder column2; + final ColumnGroupBuilder group1; + + final ReportTemplateBuilder template = template().setTitleBackgroundComponent(cmp.roundRectangle(1)) + .setPageHeaderBackgroundComponent(cmp.roundRectangle(2)) + .setPageFooterBackgroundComponent(cmp.roundRectangle(3)) + .setColumnHeaderBackgroundComponent(cmp.roundRectangle(4)) + .setColumnFooterBackgroundComponent(cmp.roundRectangle(5)) + .setGroupHeaderBackgroundComponent(cmp.roundRectangle(6)) + .setGroupFooterBackgroundComponent(cmp.roundRectangle(7)) + .setDetailHeaderBackgroundComponent(cmp.roundRectangle(8)) + .setDetailBackgroundComponent(cmp.roundRectangle(9)) + .setDetailFooterBackgroundComponent(cmp.roundRectangle(10)) + .setLastPageFooterBackgroundComponent(cmp.roundRectangle(11)) + .setSummaryBackgroundComponent(cmp.roundRectangle(12)) + .setBackgroundBackgroundComponent(cmp.roundRectangle(13)); + + rb.setTemplate(template) + .setPageColumnsPerPage(2) + .columns( + column1 = col.column("Column1", "field1", String.class), + column2 = col.column("Column2", "field2", Integer.class)) + .groupBy(group1 = grp.group(column1).setHeaderLayout(GroupHeaderLayout.TITLE_AND_VALUE)) + .subtotalsAtGroupHeader(group1, sbt.sum(column2)) + .subtotalsAtGroupFooter(group1, sbt.sum(column2)) + .title(cmp.verticalGap(10)) + .pageHeader(cmp.verticalGap(10)) + .pageFooter(cmp.verticalGap(10)) + .columnHeader(cmp.verticalGap(10)) + .columnFooter(cmp.verticalGap(10)) + .groupHeader(group1, cmp.verticalGap(10)) + .groupFooter(group1, cmp.verticalGap(10)) + .detailHeader(cmp.verticalGap(10)) + .detail(cmp.verticalGap(10)) + .detailFooter(cmp.verticalGap(10)) + .lastPageFooter(cmp.verticalGap(10)) + .summary(cmp.verticalGap(10)) + .background(cmp.verticalGap(10)); + + this.testBackgroundComponents(rb, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13); + + rb.setTitleBackgroundComponent(cmp.roundRectangle(14)) + .setPageHeaderBackgroundComponent(cmp.roundRectangle(15)) + .setPageFooterBackgroundComponent(cmp.roundRectangle(16)) + .setColumnHeaderBackgroundComponent(cmp.roundRectangle(17)) + .setColumnFooterBackgroundComponent(cmp.roundRectangle(18)) + .setGroupHeaderBackgroundComponent(group1, cmp.roundRectangle(19)) + .setGroupFooterBackgroundComponent(group1, cmp.roundRectangle(20)) + .setDetailHeaderBackgroundComponent(cmp.roundRectangle(21)) + .setDetailBackgroundComponent(cmp.roundRectangle(22)) + .setDetailFooterBackgroundComponent(cmp.roundRectangle(23)) + .setLastPageFooterBackgroundComponent(cmp.roundRectangle(24)) + .setSummaryBackgroundComponent(cmp.roundRectangle(25)) + .setBackgroundBackgroundComponent(cmp.roundRectangle(26)); + + this.testBackgroundComponents(rb, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26); + } + + private void testBackgroundComponents(final ReportBuilder rb, final Integer... radius) + { + try + { + final DRDesignReport report = new DRDesignReport(rb.getReport()); + + DRDesignRectangle rectangle = + (DRDesignRectangle)((DRDesignList)report.getTitleBand().getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[0], rectangle.getRadius()); + rectangle = (DRDesignRectangle)((DRDesignList)report.getPageHeaderBand() + .getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[1], rectangle.getRadius()); + rectangle = (DRDesignRectangle)((DRDesignList)report.getPageFooterBand() + .getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[2], rectangle.getRadius()); + rectangle = (DRDesignRectangle)((DRDesignList)report.getColumnHeaderBand() + .getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[3], rectangle.getRadius()); + rectangle = (DRDesignRectangle)((DRDesignList)report.getColumnFooterBand() + .getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[4], rectangle.getRadius()); + final DRDesignGroup group = new ArrayList<>(report.getGroups()).get(0); + rectangle = (DRDesignRectangle)((DRDesignList)group.getHeaderBands() + .get(0) + .getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[5], rectangle.getRadius()); + rectangle = (DRDesignRectangle)((DRDesignList)group.getFooterBands() + .get(0) + .getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[6], rectangle.getRadius()); + rectangle = (DRDesignRectangle)((DRDesignList)report.getDetailBands() + .get(0) + .getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[7], rectangle.getRadius()); + rectangle = (DRDesignRectangle)((DRDesignList)report.getDetailBands() + .get(1) + .getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[8], rectangle.getRadius()); + rectangle = (DRDesignRectangle)((DRDesignList)report.getDetailBands() + .get(2) + .getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[9], rectangle.getRadius()); + rectangle = (DRDesignRectangle)((DRDesignList)report.getLastPageFooterBand() + .getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[10], rectangle.getRadius()); + rectangle = + (DRDesignRectangle)((DRDesignList)report.getSummaryBand().getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[11], rectangle.getRadius()); + rectangle = (DRDesignRectangle)((DRDesignList)report.getBackgroundBand() + .getBandComponent()).getBackgroundComponent(); + Assertions.assertEquals(radius[12], rectangle.getRadius()); + } + catch(final DRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/ExceptionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/ExceptionTest.java new file mode 100644 index 0000000..7a110fa --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/ExceptionTest.java @@ -0,0 +1,114 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design.report; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.design.base.DRDesignReport; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.exception.DRException; +import software.xdev.dynamicreports.test.design.DesignReportBuilder; +import org.junit.jupiter.api.Test; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.variable; + +/** + * @author Ricardo Mariaca + */ +public class ExceptionTest { + + @Test + public void testComponentFixedWidth() { + ReportBuilder rb1 = new DesignReportBuilder(); + rb1.title(cmp.text("").setFixedWidth(600)); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("component fixed width exception"); + } catch (DRException e) { + } + + ReportBuilder rb2 = new DesignReportBuilder(); + rb2.title(cmp.horizontalList(cmp.text("").setFixedWidth(600))); + try { + new DRDesignReport(rb2.getReport()); + Assertions.fail("component fixed width exception"); + } catch (DRException e) { + } + + ReportBuilder rb3 = new DesignReportBuilder(); + rb3.title(cmp.horizontalFlowList(cmp.text("").setFixedWidth(600))); + try { + new DRDesignReport(rb3.getReport()); + Assertions.fail("component fixed width exception"); + } catch (DRException e) { + } + } + + @Test + public void testComponentMinimumWidth() { + ReportBuilder rb1 = new DesignReportBuilder(); + rb1.title(cmp.text("").setMinWidth(600)); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("component minimum width exception"); + } catch (DRException e) { + } + + ReportBuilder rb2 = new DesignReportBuilder(); + rb2.title(cmp.horizontalList(cmp.text("").setMinWidth(600))); + try { + new DRDesignReport(rb2.getReport()); + Assertions.fail("component fixed width exception"); + } catch (DRException e) { + } + + ReportBuilder rb3 = new DesignReportBuilder(); + rb3.title(cmp.horizontalFlowList(cmp.text("").setMinWidth(600))); + try { + new DRDesignReport(rb3.getReport()); + Assertions.fail("component fixed width exception"); + } catch (DRException e) { + } + } + + @Test + public void testVariable() { + TextColumnBuilder column = col.column("fieldName", Object.class); + ColumnGroupBuilder group = grp.group(column); + ReportBuilder rb1 = + new DesignReportBuilder().columns(column).groupBy(group).variables(variable("fieldName", Object.class, Calculation.SUM).setResetGroup(group).setResetType(Evaluation.REPORT)); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("variable exception"); + } catch (DRException e) { + } + + ReportBuilder rb2 = new DesignReportBuilder().columns(column).groupBy(group).variables(variable("fieldName", Object.class, Calculation.SUM).setResetType(Evaluation.GROUP)); + try { + new DRDesignReport(rb2.getReport()); + Assertions.fail("variable exception"); + } catch (DRException e) { + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/ReportTemplateTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/ReportTemplateTest.java new file mode 100644 index 0000000..039663e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/ReportTemplateTest.java @@ -0,0 +1,357 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.margin; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; +import static software.xdev.dynamicreports.report.builder.DynamicReports.template; + +import java.awt.Color; +import java.util.ArrayList; +import java.util.Locale; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.design.base.DRDesignGroup; +import software.xdev.dynamicreports.design.base.DRDesignReport; +import software.xdev.dynamicreports.design.base.component.DRDesignComponent; +import software.xdev.dynamicreports.design.base.component.DRDesignImage; +import software.xdev.dynamicreports.design.base.component.DRDesignList; +import software.xdev.dynamicreports.design.base.component.DRDesignTextField; +import software.xdev.dynamicreports.design.base.crosstab.DRDesignCrosstab; +import software.xdev.dynamicreports.design.definition.component.DRIDesignList; +import software.xdev.dynamicreports.design.definition.style.DRIDesignStyle; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.constant.Language; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.exception.DRException; +import software.xdev.dynamicreports.test.design.DesignReportBuilder; + + +class ReportTemplateTest +{ + + private void configureReport(final ReportBuilder rb) + { + final TextColumnBuilder column1; + + rb.columns(column1 = col.column("Column1", "field1", Integer.class), col.booleanColumn("Column2", "field2")) + .groupBy(grp.group(column1).header(cmp.horizontalList(cmp.hListCell(cmp.text("")).widthFixed()))) + .title(cmp.horizontalList( + cmp.hListCell(cmp.image("")).widthFixed().heightFixedOnTop(), + cmp.hListCell(ctab.crosstab() + .rowGroups(ctab.rowGroup("f1", String.class)) + .columnGroups( + ctab.columnGroup("f2", String.class), + ctab.columnGroup("f3", String.class)) + .measures(ctab.measure("f4", "f4", Integer.class, Calculation.SUM))) + .widthFixed() + .heightFixedOnTop())) + .setTemplate(template().setLocale(Locale.ENGLISH) + .setShowColumnTitle(false) + .setIgnorePagination(true) + .setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL) + .setWhenResourceMissingType(WhenResourceMissingType.KEY) + .setTitleOnANewPage(true) + .setSummaryOnANewPage(true) + .setSummaryWithPageHeaderAndFooter(true) + .setFloatColumnFooter(true) + .setPrintOrder(Orientation.HORIZONTAL) + .setColumnDirection(RunDirection.RIGHT_TO_LEFT) + .setLanguage(Language.GROOVY) + + .setHighlightDetailOddRows(true) + .setDetailOddRowStyle(stl.simpleStyle().setBackgroundColor(Color.BLUE)) + .setHighlightDetailEvenRows(true) + .setDetailEvenRowStyle(stl.simpleStyle().setBackgroundColor(Color.CYAN)) + .setDefaultFont(stl.font().setFontSize(12)) + .setTextStyle(stl.style().bold()) + + .setPageFormat(PageType.A3, PageOrientation.LANDSCAPE) + .setPageMargin(margin(3)) + .setPageColumnsPerPage(3) + .setPageColumnSpace(20) + + .setColumnPrintRepeatedDetailValues(false) + .setColumnWidth(250) + + .setGroupHeaderLayout(GroupHeaderLayout.TITLE_AND_VALUE) + .setGroupHideColumn(false) + .setGroupShowColumnHeaderAndFooter(true) + .setGroupPadding(20) + .setGroupStartInNewPage(true) + .setGroupStartInNewColumn(true) + .setGroupReprintHeaderOnEachPage(true) + .setGroupHeaderWithSubtotal(true) + + .setTextFieldWidth(150) + + .setImageWidth(110) + .setImageHeight(120) + + .setListgap(10) + + .setCrosstabWidth(90) + .setCrosstabHeight(101) + .setCrosstabHighlightOddRows(true) + .setCrosstabOddRowStyle(stl.simpleStyle().setBackgroundColor(Color.ORANGE)) + .setCrosstabHighlightEvenRows(true) + .setCrosstabEvenRowStyle(stl.simpleStyle().setBackgroundColor(Color.MAGENTA)) + .setCrosstabGroupStyle(stl.style().setBackgroundColor(Color.RED)) + .setCrosstabGroupTotalStyle(stl.style().setBackgroundColor(Color.ORANGE)) + .setCrosstabGrandTotalStyle(stl.style().setBackgroundColor(Color.BLUE)) + .setCrosstabCellStyle(stl.style().setBackgroundColor(Color.CYAN)) + .setCrosstabMeasureTitleStyle(stl.style().setBackgroundColor(Color.YELLOW)) + + .setBooleanColumnStyle(stl.style(stl.pen1Point())) + + .setDetailSplitType(SplitType.IMMEDIATE)); + } + + @Test + void test() + { + @SuppressWarnings("rawtypes") + final ReportBuilder rb = new DesignReportBuilder(); + this.configureReport(rb); + try + { + final DRDesignReport report = new DRDesignReport(rb.getReport()); + Assertions.assertEquals(Locale.ENGLISH, report.getLocale()); + Assertions.assertNull(report.getColumnHeaderBand()); + Assertions.assertTrue(report.isIgnorePagination()); + Assertions.assertEquals( + WhenNoDataType.ALL_SECTIONS_NO_DETAIL, + report.getWhenNoDataType()); + Assertions.assertEquals( + WhenResourceMissingType.KEY, + report.getWhenResourceMissingType()); + Assertions.assertTrue(report.isTitleOnANewPage()); + Assertions.assertTrue(report.isSummaryOnANewPage()); + Assertions.assertTrue(report.isSummaryWithPageHeaderAndFooter()); + Assertions.assertTrue(report.isFloatColumnFooter()); + Assertions.assertEquals(Orientation.HORIZONTAL, report.getPrintOrder()); + Assertions.assertEquals(RunDirection.RIGHT_TO_LEFT, report.getColumnDirection()); + Assertions.assertEquals(Language.GROOVY, report.getLanguage()); + + final DRDesignTextField columnTextField1 = + (DRDesignTextField)((DRDesignList)report.getDetailBands().get(0).getBandComponent()).getComponents() + .get(0); + DRIDesignStyle style = columnTextField1.getStyle(); + Assertions.assertEquals( + Color.BLUE, + style.getConditionalStyles().get(0).getBackgroundColor()); + Assertions.assertEquals( + Color.CYAN, + style.getConditionalStyles().get(1).getBackgroundColor()); + Assertions.assertEquals( + 12, + style.getParentStyle().getFont().getFontSize()); + Assertions.assertTrue(style.getParentStyle().getFont().getBold()); + + Assertions.assertEquals(1190, report.getPage().getWidth()); + Assertions.assertEquals(842, report.getPage().getHeight()); + Assertions.assertEquals(PageOrientation.LANDSCAPE, report.getPage().getOrientation()); + Assertions.assertEquals(3, report.getPage().getMargin().getLeft()); + Assertions.assertEquals(3, report.getPage().getColumnsPerPage()); + Assertions.assertEquals(20, report.getPage().getColumnSpace()); + + Assertions.assertFalse(columnTextField1.isPrintRepeatedValues()); + Assertions.assertEquals(180, columnTextField1.getWidth()); + + final DRDesignTextField columnTextField2 = + (DRDesignTextField)((DRDesignList)report.getDetailBands().get(0).getBandComponent()).getComponents() + .get(1); + style = columnTextField2.getStyle(); + Assertions.assertEquals( + Color.BLUE, + style.getConditionalStyles().get(0).getBackgroundColor()); + Assertions.assertEquals( + Color.CYAN, + style.getConditionalStyles().get(1).getBackgroundColor()); + Assertions.assertEquals( + Float.valueOf(1), + style.getParentStyle().getBorder().getTopPen().getLineWidth()); + Assertions.assertEquals(181, columnTextField2.getWidth()); + + final DRDesignGroup group = (DRDesignGroup)report.getGroups().toArray()[0]; + final DRDesignComponent textField = group.getHeaderBands().get(1).getBandComponent(); + Assertions.assertEquals( + 2, + ((DRDesignList)group.getHeaderBands().get(0).getBandComponent()).getComponents().size()); + Assertions.assertEquals("groupHeader.textField1", textField.getUniqueName()); + Assertions.assertEquals(20, columnTextField1.getX()); + Assertions.assertTrue(group.isStartInNewPage()); + Assertions.assertTrue(group.isStartInNewColumn()); + Assertions.assertTrue(group.isReprintHeaderOnEachPage()); + Assertions.assertTrue(group.isHeaderWithSubtotal()); + + Assertions.assertEquals(150, textField.getWidth()); + + final DRDesignList titleList = (DRDesignList)report.getTitleBand().getBandComponent(); + Assertions.assertEquals(10, titleList.getGap()); + + final DRDesignComponent image = titleList.getComponents().get(0); + Assertions.assertEquals(110, image.getWidth()); + Assertions.assertEquals(120, image.getHeight()); + + final DRDesignCrosstab crosstab = (DRDesignCrosstab)titleList.getComponents().get(1); + Assertions.assertEquals(Integer.valueOf(90), crosstab.getWidth()); + Assertions.assertEquals(Integer.valueOf(101), crosstab.getHeight()); + style = crosstab.getCells().get(0).getContent().getComponent().getStyle(); + Assertions.assertEquals( + new Color(63, 241, 191), + style.getConditionalStyles().get(0).getBackgroundColor()); + Assertions.assertEquals( + new Color(63, 191, 255), + style.getConditionalStyles().get(1).getBackgroundColor()); + Assertions.assertEquals(Color.CYAN, style.getParentStyle().getBackgroundColor()); + style = crosstab.getColumnGroups().get(0).getHeader().getComponent().getStyle(); + Assertions.assertEquals(Color.RED, style.getBackgroundColor()); + style = ((DRIDesignList)crosstab.getColumnGroups().get(0).getTotalHeader().getComponent()).getComponents() + .get(0) + .getStyle(); + Assertions.assertEquals(Color.BLUE, style.getBackgroundColor()); + style = ((DRIDesignList)crosstab.getColumnGroups().get(1).getHeader().getComponent()).getComponents() + .get(0) + .getStyle(); + Assertions.assertEquals(Color.RED, style.getBackgroundColor()); + style = ((DRIDesignList)crosstab.getColumnGroups().get(1).getTotalHeader().getComponent()).getComponents() + .get(0) + .getStyle(); + Assertions.assertEquals(Color.ORANGE, style.getBackgroundColor()); + style = ((DRIDesignList)crosstab.getRowGroups().get(0).getHeader().getComponent()).getComponents() + .get(0) + .getStyle(); + Assertions.assertEquals(Color.RED, style.getBackgroundColor()); + style = crosstab.getRowGroups().get(0).getTotalHeader().getComponent().getStyle(); + Assertions.assertEquals(Color.BLUE, style.getBackgroundColor()); + + style = crosstab.getColumnGroups().get(0).getHeader().getStyle(); + Assertions.assertEquals(Color.RED, style.getBackgroundColor()); + style = crosstab.getColumnGroups().get(0).getTotalHeader().getStyle(); + Assertions.assertEquals(Color.BLUE, style.getBackgroundColor()); + style = crosstab.getColumnGroups().get(1).getHeader().getStyle(); + Assertions.assertEquals(Color.RED, style.getBackgroundColor()); + style = crosstab.getColumnGroups().get(1).getTotalHeader().getStyle(); + Assertions.assertEquals(Color.ORANGE, style.getBackgroundColor()); + style = crosstab.getRowGroups().get(0).getHeader().getStyle(); + Assertions.assertEquals(Color.RED, style.getBackgroundColor()); + style = crosstab.getRowGroups().get(0).getTotalHeader().getStyle(); + Assertions.assertEquals(Color.BLUE, style.getBackgroundColor()); + + style = ((DRIDesignList)crosstab.getColumnGroups().get(0).getTotalHeader().getComponent()).getComponents() + .get(1) + .getStyle(); + Assertions.assertEquals(Color.YELLOW, style.getBackgroundColor()); + style = ((DRIDesignList)crosstab.getColumnGroups().get(1).getHeader().getComponent()).getComponents() + .get(1) + .getStyle(); + Assertions.assertEquals(Color.YELLOW, style.getBackgroundColor()); + style = ((DRIDesignList)crosstab.getColumnGroups().get(1).getTotalHeader().getComponent()).getComponents() + .get(1) + .getStyle(); + Assertions.assertEquals(Color.YELLOW, style.getBackgroundColor()); + + Assertions.assertEquals( + SplitType.IMMEDIATE, + report.getDetailBands().get(0).getSplitType()); + } + catch(final DRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } + + @Test + void styleTest() + { + final ReportBuilder rb = new DesignReportBuilder(); + final TextColumnBuilder column1; + + rb.columns(column1 = col.column("Column1", "field1", Integer.class)) + .groupBy(grp.group(column1).setHeaderLayout(GroupHeaderLayout.TITLE_AND_VALUE).setHideColumn(false)) + .subtotalsAtSummary(sbt.sum(column1)) + .title(cmp.image(""), cmp.image("")) + .setTemplate(template().setColumnStyle(stl.style().setFontSize(1)) + .setColumnTitleStyle(stl.style().setFontSize(2)) + .setGroupStyle(stl.style().setFontSize(3)) + .setGroupTitleStyle(stl.style().setFontSize(4)) + .setSubtotalStyle(stl.style().setFontSize(5)) + .setImageStyle(stl.style().setBorder(stl.pen1Point()))); + try + { + final DRDesignReport report = new DRDesignReport(rb.getReport()); + + DRDesignTextField textField = + (DRDesignTextField)((DRDesignList)report.getDetailBands().get(0).getBandComponent()).getComponents() + .get(0); + Assertions.assertEquals(Integer.valueOf(1), textField.getStyle().getFont().getFontSize()); + + textField = + (DRDesignTextField)((DRDesignList)report.getColumnHeaderBand().getBandComponent()).getComponents() + .get(1); + Assertions.assertEquals( + Integer.valueOf(2), + textField.getStyle().getFont().getFontSize()); + + final DRDesignList groupHeaderComponent = + (DRDesignList)new ArrayList<>(report.getGroups()).get(0).getHeaderBands().get(0).getBandComponent(); + textField = (DRDesignTextField)groupHeaderComponent.getComponents().get(1); + Assertions.assertEquals(Integer.valueOf(3), textField.getStyle().getFont().getFontSize()); + + textField = (DRDesignTextField)groupHeaderComponent.getComponents().get(0); + Assertions.assertEquals( + 4, + textField.getStyle().getFont().getFontSize()); + + textField = + (DRDesignTextField)((DRDesignList)report.getSummaryBand().getBandComponent()).getComponents().get(0); + Assertions.assertEquals( + 5, + textField.getStyle().getFont().getFontSize()); + + final DRDesignImage image = + (DRDesignImage)((DRDesignList)report.getTitleBand().getBandComponent()).getComponents().get(0); + Assertions.assertEquals( + Float.valueOf(1), + image.getStyle().getBorder().getTopPen().getLineWidth()); + } + catch(final DRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/TemplateDesignTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/TemplateDesignTest.java new file mode 100644 index 0000000..bf5d44a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/design/report/TemplateDesignTest.java @@ -0,0 +1,290 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.design.report; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.design.base.DRDesignReport; +import software.xdev.dynamicreports.report.base.AbstractTemplateDesign; +import software.xdev.dynamicreports.report.base.DRMargin; +import software.xdev.dynamicreports.report.builder.MarginBuilder; +import software.xdev.dynamicreports.report.builder.ReportBuilder; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.definition.DRIMargin; +import software.xdev.dynamicreports.report.exception.DRException; +import software.xdev.dynamicreports.test.design.DesignReportBuilder; +import org.junit.jupiter.api.Test; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.margin; + +/** + * @author Ricardo Mariaca + */ +public class TemplateDesignTest { + + @Test + public void testComponentFixedWidth() { + ReportBuilder rb1 = new DesignReportBuilder(new TestTemplateDesign()); + try { + new DRDesignReport(rb1.getReport()); + } catch (DRException e) { + Assertions.fail("template design failed"); + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.setPageFormat(100, 100, PageOrientation.LANDSCAPE); + try { + new DRDesignReport(rb1.getReport()); + } catch (DRException e) { + Assertions.fail("template design failed - page width"); + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.setPageFormat(50, 200, PageOrientation.LANDSCAPE); + try { + new DRDesignReport(rb1.getReport()); + } catch (DRException e) { + Assertions.fail("template design failed - page height"); + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.setPageFormat(200, 100, PageOrientation.PORTRAIT); + try { + new DRDesignReport(rb1.getReport()); + } catch (DRException e) { + Assertions.fail("template design failed - page orientation"); + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + MarginBuilder margin = margin(); + margin.setLeft(10).setRight(6).setTop(7).setBottom(8); + rb1.setPageMargin(margin); + try { + new DRDesignReport(rb1.getReport()); + } catch (DRException e) { + Assertions.fail("template design failed - page left margin"); + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + margin = margin(); + margin.setLeft(5).setRight(10).setTop(7).setBottom(8); + rb1.setPageMargin(margin); + try { + new DRDesignReport(rb1.getReport()); + } catch (DRException e) { + Assertions.fail("template design failed - page right margin"); + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + margin = margin(); + margin.setLeft(5).setRight(6).setTop(10).setBottom(8); + rb1.setPageMargin(margin); + try { + new DRDesignReport(rb1.getReport()); + } catch (DRException e) { + Assertions.fail("template design failed - page top margin"); + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + margin = margin(); + margin.setLeft(5).setRight(6).setTop(7).setBottom(10); + rb1.setPageMargin(margin); + try { + new DRDesignReport(rb1.getReport()); + } catch (DRException e) { + Assertions.fail("template design failed - page bottom margin"); + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.setPageColumnsPerPage(5); + try { + new DRDesignReport(rb1.getReport()); + } catch (DRException e) { + Assertions.fail("template design failed - page columnsPerPage margin"); + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.setPageColumnSpace(5); + try { + new DRDesignReport(rb1.getReport()); + } catch (DRException e) { + Assertions.fail("template design failed - page columnSpace margin"); + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.title(cmp.text("")); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("template design failed - title band"); + } catch (DRException e) { + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.pageHeader(cmp.text("")); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("template design failed - page header band"); + } catch (DRException e) { + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.pageFooter(cmp.text("")); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("template design failed - page footer band"); + } catch (DRException e) { + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.columnHeader(cmp.text("")); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("template design failed - column header band"); + } catch (DRException e) { + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.columnFooter(cmp.text("")); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("template design failed - column footer band"); + } catch (DRException e) { + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.pageFooter(cmp.text("")); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("template design failed - page footer band"); + } catch (DRException e) { + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.summary(cmp.text("")); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("template design failed - summary band"); + } catch (DRException e) { + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.noData(cmp.text("")); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("template design failed - no data band"); + } catch (DRException e) { + } + + rb1 = new DesignReportBuilder(new TestTemplateDesign()); + rb1.background(cmp.text("")); + try { + new DRDesignReport(rb1.getReport()); + Assertions.fail("template design failed - background band"); + } catch (DRException e) { + } + } + + public class TestTemplateDesign extends AbstractTemplateDesign { + private static final long serialVersionUID = 1L; + + @Override + public Integer getPageWidth() { + return 200; + } + + @Override + public Integer getPageHeight() { + return 100; + } + + @Override + public PageOrientation getPageOrientation() { + return PageOrientation.LANDSCAPE; + } + + @Override + public DRIMargin getPageMargin() { + DRMargin margin = new DRMargin(); + margin.setLeft(5); + margin.setRight(6); + margin.setTop(7); + margin.setBottom(8); + return margin; + } + + @Override + public Integer getPageColumnsPerPage() { + return 2; + } + + @Override + public Integer getPageColumnSpace() { + return 20; + } + + @Override + public Integer getPageColumnWidth() { + return 100; + } + + @Override + public int getTitleComponentsCount() { + return 1; + } + + @Override + public int getPageHeaderComponentsCount() { + return 1; + } + + @Override + public int getPageFooterComponentsCount() { + return 1; + } + + @Override + public int getColumnHeaderComponentsCount() { + return 1; + } + + @Override + public int getColumnFooterComponentsCount() { + return 1; + } + + @Override + public int getLastPageFooterComponentsCount() { + return 1; + } + + @Override + public int getSummaryComponentsCount() { + return 1; + } + + @Override + public int getNoDataComponentsCount() { + return 1; + } + + @Override + public int getBackgroundComponentsCount() { + return 1; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperCrosstabPositionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperCrosstabPositionTest.java new file mode 100644 index 0000000..0962c9e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperCrosstabPositionTest.java @@ -0,0 +1,73 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper; + +import software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; + +/** + * @author Ricardo Mariaca + */ +public abstract class AbstractJasperCrosstabPositionTest extends AbstractJasperPositionTest { + private String crosstabBand; + + public void setCrosstabBand(String crosstabBand) { + this.crosstabBand = crosstabBand; + } + + protected void crosstabWhenNoDataElementPositionTest(String name, int index, int x, int y, int width, int height) { + elementPositionTest(getPrefix(1) + "whennodatacell." + name, index, x, y, width, height); + } + + protected void crosstabHeaderElementPositionTest(String name, int index, int x, int y, int width, int height) { + elementPositionTest(getPrefix(1) + "headercell." + name, index, x, y, width, height); + } + + // group header + protected void crosstabGroupHeaderPositionTest(AbstractCrosstabGroupBuilder group, int index, int x, int y, int width, int height) { + elementPositionTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupHeaderName(group), index, x, y, width, height); + } + + // group total header + protected void crosstabGroupTotalHeaderPositionTest(AbstractCrosstabGroupBuilder group, int index, int x, int y, int width, int height) { + elementPositionTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTotalHeaderName(group), index, x, y, width, height); + } + + // group title header + protected void crosstabGroupTitleHeaderPositionTest(AbstractCrosstabGroupBuilder group, CrosstabMeasureBuilder measure, int index, int x, int y, int width, int height) { + elementPositionTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTitleHeaderName(group, measure), index, x, y, width, height); + } + + // group title total header + protected void crosstabGroupTitleTotalHeaderPositionTest(AbstractCrosstabGroupBuilder group, CrosstabMeasureBuilder measure, int index, int x, int y, int width, int height) { + elementPositionTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTitleTotalHeaderName(group, measure), index, x, y, width, height); + } + + // cell + protected void crosstabCellPositionTest(CrosstabMeasureBuilder measure, CrosstabRowGroupBuilder rowGroup, CrosstabColumnGroupBuilder columnGroup, int index, int x, int y, int width, + int height) { + elementPositionTest(getPrefix(1) + JasperTestUtils.getCrosstabCellName(measure, rowGroup, columnGroup), index, x, y, width, height); + } + + private String getPrefix(int index) { + return crosstabBand + ".crosstab" + index + "."; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperCrosstabStyleTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperCrosstabStyleTest.java new file mode 100644 index 0000000..18ac313 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperCrosstabStyleTest.java @@ -0,0 +1,135 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper; + +import software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import net.sf.jasperreports.engine.type.HorizontalTextAlignEnum; +import net.sf.jasperreports.engine.type.LineStyleEnum; + +import java.awt.Color; + +/** + * @author Ricardo Mariaca + */ +public abstract class AbstractJasperCrosstabStyleTest extends AbstractJasperStyleTest { + private String crosstabBand; + + public void setCrosstabBand(String crosstabBand) { + this.crosstabBand = crosstabBand; + } + + // header + protected void crosstabHeaderElementStyleTest(String name, int index, Color foreColor, Color backColor, String fontName, Float fontSize, Boolean bold, Boolean italic) { + styleTest(getPrefix(1) + "headercell." + name, index, foreColor, backColor, fontName, fontSize, bold, italic); + } + + protected void crosstabHeaderElementBorderTest(String name, int index, Color topColor, LineStyleEnum topLineStyle, float top, Color bottomColor, LineStyleEnum bottomLineStyle, float bottom, + Color leftColor, LineStyleEnum leftLineStyle, float left, Color rightColor, LineStyleEnum rightLineStyle, float right) { + borderTest(getPrefix(1) + "headercell." + name, index, topColor, topLineStyle, top, bottomColor, bottomLineStyle, bottom, leftColor, leftLineStyle, left, rightColor, rightLineStyle, right); + } + + protected void crosstabHeaderElementPaddingTest(String name, int index, Integer top, Integer bottom, Integer left, Integer right) { + paddingTest(getPrefix(1) + "headercell." + name, index, top, bottom, left, right); + } + + protected void crosstabHeaderElementHorizontalAlignmentTest(String name, int index, HorizontalTextAlignEnum horizontalAlignment) { + horizontalAlignmentTest(getPrefix(1) + "headercell." + name, index, horizontalAlignment); + } + + // group header + protected void crosstabGroupHeaderStyleTest(AbstractCrosstabGroupBuilder group, int index, Color foreColor, Color backColor, String fontName, Float fontSize, Boolean bold, + Boolean italic) { + styleTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupHeaderName(group), index, foreColor, backColor, fontName, fontSize, bold, italic); + } + + protected void crosstabGroupHeaderBorderTest(AbstractCrosstabGroupBuilder group, int index, Color topColor, LineStyleEnum topLineStyle, float top, Color bottomColor, + LineStyleEnum bottomLineStyle, float bottom, Color leftColor, LineStyleEnum leftLineStyle, float left, Color rightColor, LineStyleEnum rightLineStyle, + float right) { + borderTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupHeaderName(group), index, topColor, topLineStyle, top, bottomColor, bottomLineStyle, bottom, leftColor, leftLineStyle, left, + rightColor, rightLineStyle, right); + } + + protected void crosstabGroupHeaderPaddingTest(AbstractCrosstabGroupBuilder group, int index, Integer top, Integer bottom, Integer left, Integer right) { + paddingTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupHeaderName(group), index, top, bottom, left, right); + } + + protected void crosstabGroupHeaderHorizontalAlignmentTest(AbstractCrosstabGroupBuilder group, int index, HorizontalTextAlignEnum horizontalAlignment) { + horizontalAlignmentTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupHeaderName(group), index, horizontalAlignment); + } + + protected void crosstabGroupTitleHeaderStyleTest(AbstractCrosstabGroupBuilder group, CrosstabMeasureBuilder measure, int index, Color foreColor, Color backColor, String fontName, + Float fontSize, Boolean bold, Boolean italic) { + styleTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTitleHeaderName(group, measure), index, foreColor, backColor, fontName, fontSize, bold, italic); + } + + // group total header + protected void crosstabGroupTotalHeaderStyleTest(AbstractCrosstabGroupBuilder group, int index, Color foreColor, Color backColor, String fontName, Float fontSize, Boolean bold, + Boolean italic) { + styleTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTotalHeaderName(group), index, foreColor, backColor, fontName, fontSize, bold, italic); + } + + protected void crosstabGroupTotalHeaderBorderTest(AbstractCrosstabGroupBuilder group, int index, Color topColor, LineStyleEnum topLineStyle, float top, Color bottomColor, + LineStyleEnum bottomLineStyle, float bottom, Color leftColor, LineStyleEnum leftLineStyle, float left, Color rightColor, + LineStyleEnum rightLineStyle, float right) { + borderTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTotalHeaderName(group), index, topColor, topLineStyle, top, bottomColor, bottomLineStyle, bottom, leftColor, leftLineStyle, left, + rightColor, rightLineStyle, right); + } + + protected void crosstabGroupTotalHeaderPaddingTest(AbstractCrosstabGroupBuilder group, int index, Integer top, Integer bottom, Integer left, Integer right) { + paddingTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTotalHeaderName(group), index, top, bottom, left, right); + } + + protected void crosstabGroupTotalHeaderHorizontalAlignmentTest(AbstractCrosstabGroupBuilder group, int index, HorizontalTextAlignEnum horizontalAlignment) { + horizontalAlignmentTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTotalHeaderName(group), index, horizontalAlignment); + } + + protected void crosstabGroupTitleTotalHeaderStyleTest(AbstractCrosstabGroupBuilder group, CrosstabMeasureBuilder measure, int index, Color foreColor, Color backColor, String fontName, + Float fontSize, Boolean bold, Boolean italic) { + styleTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTitleTotalHeaderName(group, measure), index, foreColor, backColor, fontName, fontSize, bold, italic); + } + + // cell + protected void crosstabCellStyleTest(CrosstabMeasureBuilder measure, CrosstabRowGroupBuilder rowGroup, CrosstabColumnGroupBuilder columnGroup, int index, Color foreColor, Color backColor, + String fontName, Float fontSize, Boolean bold, Boolean italic) { + styleTest(getPrefix(1) + JasperTestUtils.getCrosstabCellName(measure, rowGroup, columnGroup), index, foreColor, backColor, fontName, fontSize, bold, italic); + } + + protected void crosstabCellBorderTest(CrosstabMeasureBuilder measure, CrosstabRowGroupBuilder rowGroup, CrosstabColumnGroupBuilder columnGroup, int index, Color topColor, + LineStyleEnum topLineStyle, float top, Color bottomColor, LineStyleEnum bottomLineStyle, float bottom, Color leftColor, LineStyleEnum leftLineStyle, + float left, Color rightColor, LineStyleEnum rightLineStyle, float right) { + borderTest(getPrefix(1) + JasperTestUtils.getCrosstabCellName(measure, rowGroup, columnGroup), index, topColor, topLineStyle, top, bottomColor, bottomLineStyle, bottom, leftColor, + leftLineStyle, left, rightColor, rightLineStyle, right); + } + + protected void crosstabCellPaddingTest(CrosstabMeasureBuilder measure, CrosstabRowGroupBuilder rowGroup, CrosstabColumnGroupBuilder columnGroup, int index, Integer top, Integer bottom, + Integer left, Integer right) { + paddingTest(getPrefix(1) + JasperTestUtils.getCrosstabCellName(measure, rowGroup, columnGroup), index, top, bottom, left, right); + } + + protected void crosstabCellHorizontalAlignmentTest(CrosstabMeasureBuilder measure, CrosstabRowGroupBuilder rowGroup, CrosstabColumnGroupBuilder columnGroup, int index, + HorizontalTextAlignEnum horizontalAlignment) { + horizontalAlignmentTest(getPrefix(1) + JasperTestUtils.getCrosstabCellName(measure, rowGroup, columnGroup), index, horizontalAlignment); + } + + private String getPrefix(int index) { + return crosstabBand + ".crosstab" + index + "."; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperCrosstabValueTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperCrosstabValueTest.java new file mode 100644 index 0000000..5fed3d1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperCrosstabValueTest.java @@ -0,0 +1,104 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper; + +import software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; + +/** + * @author Ricardo Mariaca + */ +public abstract class AbstractJasperCrosstabValueTest extends AbstractJasperValueTest { + private String crosstabBand; + + public void setCrosstabBand(String crosstabBand) { + this.crosstabBand = crosstabBand; + } + + protected void crosstabHeaderElementCountTest(String name, int expectedNumberOfElements) { + elementCountTest(getPrefix(1) + "headercell." + name, expectedNumberOfElements); + } + + protected void crosstabHeaderElementValueTest(String name, String... values) { + elementValueTest(getPrefix(1) + "headercell." + name, values); + } + + // group header + protected void crosstabGroupHeaderCountTest(AbstractCrosstabGroupBuilder group, int expectedNumberOfElements) { + elementCountTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupHeaderName(group), expectedNumberOfElements); + } + + protected void crosstabGroupHeaderValueTest(AbstractCrosstabGroupBuilder group, String... values) { + elementValueTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupHeaderName(group), values); + } + + protected void crosstabGroupHeaderFullValueTest(AbstractCrosstabGroupBuilder group, String... values) { + elementFullValueTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupHeaderName(group), values); + } + + // group total header + protected void crosstabGroupTotalHeaderCountTest(AbstractCrosstabGroupBuilder group, int expectedNumberOfElements) { + elementCountTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTotalHeaderName(group), expectedNumberOfElements); + } + + protected void crosstabGroupTotalHeaderValueTest(AbstractCrosstabGroupBuilder group, String... values) { + elementValueTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTotalHeaderName(group), values); + } + + protected void crosstabGroupTotalHeaderFullValueTest(AbstractCrosstabGroupBuilder group, String... values) { + elementFullValueTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTotalHeaderName(group), values); + } + + // group title header + protected void crosstabGroupTitleHeaderCountTest(AbstractCrosstabGroupBuilder group, CrosstabMeasureBuilder measure, int expectedNumberOfElements) { + elementCountTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTitleHeaderName(group, measure), expectedNumberOfElements); + } + + protected void crosstabGroupTitleHeaderValueTest(AbstractCrosstabGroupBuilder group, CrosstabMeasureBuilder measure, String... values) { + elementValueTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTitleHeaderName(group, measure), values); + } + + // group title total header + protected void crosstabGroupTitleTotalHeaderCountTest(AbstractCrosstabGroupBuilder group, CrosstabMeasureBuilder measure, int expectedNumberOfElements) { + elementCountTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTitleTotalHeaderName(group, measure), expectedNumberOfElements); + } + + protected void crosstabGroupTitleTotalHeaderValueTest(AbstractCrosstabGroupBuilder group, CrosstabMeasureBuilder measure, String... values) { + elementValueTest(getPrefix(1) + JasperTestUtils.getCrosstabGroupTitleTotalHeaderName(group, measure), values); + } + + // cell + protected void crosstabCellCountTest(CrosstabMeasureBuilder measure, CrosstabRowGroupBuilder rowGroup, CrosstabColumnGroupBuilder columnGroup, int expectedNumberOfElements) { + elementCountTest(getPrefix(1) + JasperTestUtils.getCrosstabCellName(measure, rowGroup, columnGroup), expectedNumberOfElements); + } + + protected void crosstabCellValueTest(CrosstabMeasureBuilder measure, CrosstabRowGroupBuilder rowGroup, CrosstabColumnGroupBuilder columnGroup, String... values) { + elementValueTest(getPrefix(1) + JasperTestUtils.getCrosstabCellName(measure, rowGroup, columnGroup), values); + } + + protected void crosstabCellFullValueTest(CrosstabMeasureBuilder measure, CrosstabRowGroupBuilder rowGroup, CrosstabColumnGroupBuilder columnGroup, String... values) { + elementFullValueTest(getPrefix(1) + JasperTestUtils.getCrosstabCellName(measure, rowGroup, columnGroup), values); + } + + protected String getPrefix(int index) { + return crosstabBand + ".crosstab" + index + "."; + } + +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperPositionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperPositionTest.java new file mode 100644 index 0000000..a71f563 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperPositionTest.java @@ -0,0 +1,150 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.SubtotalBuilder; +import net.sf.jasperreports.engine.JRPrintElement; + + +/** + * @author Ricardo Mariaca + */ +public abstract class AbstractJasperPositionTest extends AbstractJasperTest +{ + + protected void elementPositionTest( + final String name, + final int index, + final int x, + final int y, + final int width, + final int height) + { + final JRPrintElement element = this.getElementAt(name, index); + Assertions.assertEquals(width, element.getWidth()); + Assertions.assertEquals(height, element.getHeight()); + Assertions.assertEquals(x, element.getX()); + Assertions.assertEquals(y, element.getY()); + } + + // column detail + protected void columnDetailPositionTest( + final ColumnBuilder column, + final int index, + final int x, + final int y, + final int width, + final int height) + { + this.elementPositionTest(JasperTestUtils.getColumnDetailName(column), index, x, y, width, height); + } + + // column title + protected void columnTitlePositionTest( + final ColumnBuilder column, + final int index, + final int x, + final int y, + final int width, + final int height) + { + this.elementPositionTest(JasperTestUtils.getColumnTitleName(column), index, x, y, width, height); + } + + // subtotal label + protected void subtotalLabelPositionTest( + final SubtotalBuilder subtotal, + final int index, + final int x, + final int y, + final int width, + final int height) + { + this.elementPositionTest(JasperTestUtils.getSubtotalLabelName(subtotal, 1), index, x, y, width, height); + } + + protected void subtotalLabelIndexPositionTest( + final SubtotalBuilder subtotal, + final int subtotalIndex, + final int index, + final int x, + final int y, + final int width, + final int height) + { + this.elementPositionTest( + JasperTestUtils.getSubtotalLabelName(subtotal, subtotalIndex), + index, + x, + y, + width, + height); + } + + // subtotal + protected void subtotalPositionTest( + final SubtotalBuilder subtotal, + final int index, + final int x, + final int y, + final int width, + final int height) + { + this.elementPositionTest(JasperTestUtils.getSubtotalName(subtotal, 1), index, x, y, width, height); + } + + protected void subtotalIndexPositionTest( + final SubtotalBuilder subtotal, + final int subtotalIndex, + final int index, + final int x, + final int y, + final int width, + final int height) + { + this.elementPositionTest(JasperTestUtils.getSubtotalName(subtotal, subtotalIndex), index, x, y, width, height); + } + + // group header title + protected void groupHeaderTitlePositionTest( + final GroupBuilder group, + final int index, + final int x, + final int y, + final int width, + final int height) + { + this.elementPositionTest(JasperTestUtils.getHeaderTitleGroupName(group), index, x, y, width, height); + } + + // group header + protected void groupHeaderPositionTest( + final GroupBuilder group, + final int index, + final int x, + final int y, + final int width, + final int height) + { + this.elementPositionTest(JasperTestUtils.getHeaderGroupName(group), index, x, y, width, height); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperStyleTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperStyleTest.java new file mode 100644 index 0000000..a964caf --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperStyleTest.java @@ -0,0 +1,329 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper; + +import java.awt.Color; + +import org.junit.jupiter.api.Assertions; + +import net.sf.jasperreports.engine.JRImageAlignment; +import net.sf.jasperreports.engine.JRStyle; +import net.sf.jasperreports.engine.JRTextAlignment; +import net.sf.jasperreports.engine.base.JRBoxPen; +import net.sf.jasperreports.engine.type.HorizontalImageAlignEnum; +import net.sf.jasperreports.engine.type.HorizontalTextAlignEnum; +import net.sf.jasperreports.engine.type.LineStyleEnum; +import net.sf.jasperreports.engine.type.VerticalImageAlignEnum; +import net.sf.jasperreports.engine.type.VerticalTextAlignEnum; +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.SubtotalBuilder; + + +/** + * Base class for jasper style tests. + */ +public abstract class AbstractJasperStyleTest extends AbstractJasperTest +{ + + protected static final String TEST_FONT_NAME = "Arimo"; + + protected void styleTest( + final String name, final int index, final Color foreColor, final Color backColor, + final String fontName, final Float fontSize, final Boolean bold, final Boolean italic) + { + final JRStyle style = this.getElementAt(name, index).getStyle(); + this.styleTest(style, foreColor, backColor, fontName, fontSize, bold, italic); + } + + protected void styleTest( + final JRStyle style, final Color foreColor, final Color backColor, final String fontName, + final Float fontSize, final Boolean bold, final Boolean italic) + { + Assertions.assertNotNull(style); + Assertions.assertEquals(foreColor, style.getForecolor()); + Assertions.assertEquals(backColor, style.getBackcolor()); + Assertions.assertEquals(fontName, style.getFontName()); + Assertions.assertEquals(fontSize, style.getFontsize()); + Assertions.assertEquals(bold, style.isBold()); + Assertions.assertEquals(italic, style.isItalic()); + } + + protected void borderTest( + final String name, final int index, final Color topColor, final LineStyleEnum topLineStyle, + final float top, final Color bottomColor, final LineStyleEnum bottomLineStyle, final float bottom, final Color leftColor, + final LineStyleEnum leftLineStyle, final float left, final Color rightColor, final LineStyleEnum rightLineStyle, + final float right) + { + final JRStyle style = this.getElementAt(name, index).getStyle(); + + JRBoxPen pen = style.getLineBox().getTopPen(); + Assertions.assertEquals(top, pen.getLineWidth().floatValue(), 0); + Assertions.assertEquals(topColor, pen.getLineColor()); + Assertions.assertEquals(topLineStyle, pen.getLineStyleValue()); + + pen = style.getLineBox().getBottomPen(); + Assertions.assertEquals(bottom, pen.getLineWidth().floatValue(), 0); + Assertions.assertEquals(bottomColor, pen.getLineColor()); + Assertions.assertEquals(bottomLineStyle, pen.getLineStyleValue()); + + pen = style.getLineBox().getLeftPen(); + Assertions.assertEquals(left, pen.getLineWidth().floatValue(), 0); + Assertions.assertEquals(leftColor, pen.getLineColor()); + Assertions.assertEquals(leftLineStyle, pen.getLineStyleValue()); + + pen = style.getLineBox().getRightPen(); + Assertions.assertEquals(right, pen.getLineWidth().floatValue(), 0); + Assertions.assertEquals(rightColor, pen.getLineColor()); + Assertions.assertEquals(rightLineStyle, pen.getLineStyleValue()); + } + + protected void paddingTest( + final String name, final int index, final Integer top, final Integer bottom, final Integer left, + final Integer right) + { + final JRStyle style = this.getElementAt(name, index).getStyle(); + Assertions.assertEquals(top, style.getLineBox().getTopPadding()); + Assertions.assertEquals(bottom, style.getLineBox().getBottomPadding()); + Assertions.assertEquals(left, style.getLineBox().getLeftPadding()); + Assertions.assertEquals(right, style.getLineBox().getRightPadding()); + } + + protected void horizontalAlignmentTest( + final String name, final int index, + final HorizontalImageAlignEnum horizontalAlignment) + { + final JRImageAlignment element = (JRImageAlignment)this.getElementAt(name, index); + if(horizontalAlignment == null) + { + Assertions.assertEquals( + HorizontalImageAlignEnum.LEFT, + element.getHorizontalImageAlign()); + } + Assertions.assertEquals( + horizontalAlignment, + element.getHorizontalImageAlign()); + } + + protected void horizontalAlignmentTest( + final String name, final int index, + final HorizontalTextAlignEnum horizontalAlignment) + { + final JRTextAlignment element = (JRTextAlignment)this.getElementAt(name, index); + if(horizontalAlignment == null) + { + Assertions.assertEquals( + HorizontalTextAlignEnum.LEFT, + element.getHorizontalTextAlign()); + } + Assertions.assertEquals( + horizontalAlignment, + element.getHorizontalTextAlign()); + } + + protected void verticalAlignmentTest( + final String name, final int index, + final VerticalImageAlignEnum verticalAlignment) + { + final JRImageAlignment element = (JRImageAlignment)this.getElementAt(name, index); + if(verticalAlignment == null) + { + Assertions.assertEquals( + VerticalImageAlignEnum.TOP, + element.getVerticalImageAlign()); + } + Assertions.assertEquals(verticalAlignment, element.getVerticalImageAlign()); + } + + protected void verticalAlignmentTest( + final String name, final int index, + final VerticalTextAlignEnum verticalAlignment) + { + final JRTextAlignment element = (JRTextAlignment)this.getElementAt(name, index); + if(verticalAlignment == null) + { + Assertions.assertEquals( + VerticalTextAlignEnum.TOP, + element.getVerticalTextAlign()); + } + Assertions.assertEquals(verticalAlignment, element.getVerticalTextAlign()); + } + + // column detail + protected void columnDetailStyleTest( + final ColumnBuilder column, final int index, final Color foreColor, + final Color backColor, final String fontName, final Float fontSize, final Boolean bold, final Boolean italic) + { + this.styleTest(JasperTestUtils.getColumnDetailName(column), index, foreColor, backColor, fontName, + fontSize, bold, italic); + } + + protected void columnDetailPaddingTest( + final ColumnBuilder column, final int index, final Integer top, + final Integer bottom, final Integer left, final Integer right) + { + this.paddingTest(JasperTestUtils.getColumnDetailName(column), index, top, bottom, left, right); + } + + protected void columnDetailAlignmentTest( + final ColumnBuilder column, final int index, + final HorizontalImageAlignEnum horizontalAlignment) + { + this.horizontalAlignmentTest(JasperTestUtils.getColumnDetailName(column), index, + horizontalAlignment); + } + + protected void columnDetailAlignmentTest( + final ColumnBuilder column, final int index, + final VerticalImageAlignEnum verticalAlignment) + { + this.verticalAlignmentTest(JasperTestUtils.getColumnDetailName(column), index, verticalAlignment); + } + + protected void columnDetailAlignmentTest( + final ColumnBuilder column, final int index, + final HorizontalTextAlignEnum horizontalAlignment) + { + this.horizontalAlignmentTest(JasperTestUtils.getColumnDetailName(column), index, + horizontalAlignment); + } + + protected void columnDetailAlignmentTest( + final ColumnBuilder column, final int index, + final VerticalTextAlignEnum verticalAlignment) + { + this.verticalAlignmentTest(JasperTestUtils.getColumnDetailName(column), index, verticalAlignment); + } + + protected void columnDetailBorderTest( + final ColumnBuilder column, final int index, final Color topColor, + final LineStyleEnum topLineStyle, final float top, final Color bottomColor, final LineStyleEnum bottomLineStyle, + final float bottom, final Color leftColor, final LineStyleEnum leftLineStyle, final float left, final Color rightColor, + final LineStyleEnum rightLineStyle, final float right) + { + this.borderTest(JasperTestUtils.getColumnDetailName(column), index, topColor, topLineStyle, top, + bottomColor, bottomLineStyle, bottom, leftColor, leftLineStyle, left, rightColor, + rightLineStyle, right); + } + + // column title + protected void columnTitleBorderTest( + final ColumnBuilder column, final int index, final Color topColor, + final LineStyleEnum topLineStyle, final float top, final Color bottomColor, final LineStyleEnum bottomLineStyle, + final float bottom, final Color leftColor, final LineStyleEnum leftLineStyle, final float left, final Color rightColor, + final LineStyleEnum rightLineStyle, final float right) + { + this.borderTest(JasperTestUtils.getColumnTitleName(column), index, topColor, topLineStyle, top, + bottomColor, bottomLineStyle, bottom, leftColor, leftLineStyle, left, rightColor, + rightLineStyle, right); + } + + protected void columnTitlePaddingTest( + final ColumnBuilder column, final int index, final Integer top, + final Integer bottom, final Integer left, final Integer right) + { + this.paddingTest(JasperTestUtils.getColumnTitleName(column), index, top, bottom, left, right); + } + + protected void columnTitleStyleTest( + final ColumnBuilder column, final int index, final Color foreColor, + final Color backColor, final String fontName, final Float fontSize, final Boolean bold, final Boolean italic) + { + this.styleTest(JasperTestUtils.getColumnTitleName(column), index, foreColor, backColor, fontName, + fontSize, bold, italic); + } + + protected void columnTitleAlignmentTest( + final ColumnBuilder column, final int index, + final HorizontalTextAlignEnum horizontalAlignment) + { + this.horizontalAlignmentTest(JasperTestUtils.getColumnTitleName(column), index, horizontalAlignment); + } + + // subtotal label + protected void subtotalLabelBorderTest( + final SubtotalBuilder subtotal, final int index, final Color topColor, + final LineStyleEnum topLineStyle, final float top, final Color bottomColor, final LineStyleEnum bottomLineStyle, + final float bottom, final Color leftColor, final LineStyleEnum leftLineStyle, final float left, final Color rightColor, + final LineStyleEnum rightLineStyle, final float right) + { + this.borderTest(JasperTestUtils.getSubtotalLabelName(subtotal, 1), index, topColor, topLineStyle, + top, bottomColor, bottomLineStyle, bottom, leftColor, leftLineStyle, left, rightColor, + rightLineStyle, right); + } + + protected void subtotalLabelStyleTest( + final SubtotalBuilder subtotal, final int index, final Color foreColor, + final Color backColor, final String fontName, final Float fontSize, final Boolean bold, final Boolean italic) + { + this.styleTest(JasperTestUtils.getSubtotalLabelName(subtotal, 1), index, foreColor, backColor, + fontName, fontSize, bold, italic); + } + + // subtotal + protected void subtotalBorderTest( + final SubtotalBuilder subtotal, final int index, final Color topColor, + final LineStyleEnum topLineStyle, final float top, final Color bottomColor, final LineStyleEnum bottomLineStyle, + final float bottom, final Color leftColor, final LineStyleEnum leftLineStyle, final float left, final Color rightColor, + final LineStyleEnum rightLineStyle, final float right) + { + this.borderTest(JasperTestUtils.getSubtotalName(subtotal, 1), index, topColor, topLineStyle, top, + bottomColor, bottomLineStyle, bottom, leftColor, leftLineStyle, left, rightColor, + rightLineStyle, right); + } + + protected void subtotalPaddingTest( + final SubtotalBuilder subtotal, final int index, final Integer top, + final Integer bottom, final Integer left, final Integer right) + { + this.paddingTest(JasperTestUtils.getSubtotalName(subtotal, 1), index, top, bottom, left, right); + } + + protected void subtotalStyleTest( + final SubtotalBuilder subtotal, final int index, final Color foreColor, + final Color backColor, final String fontName, final Float fontSize, final Boolean bold, final Boolean italic) + { + this.styleTest(JasperTestUtils.getSubtotalName(subtotal, 1), index, foreColor, backColor, fontName, + fontSize, bold, italic); + } + + // group header title + protected void groupHeaderTitleStyleTest( + final GroupBuilder group, final int index, final Color foreColor, + final Color backColor, final String fontName, final Float fontSize, final Boolean bold, final Boolean italic) + { + this.styleTest(JasperTestUtils.getHeaderTitleGroupName(group), index, foreColor, backColor, fontName, + fontSize, bold, italic); + } + + // group header + protected void groupHeaderStyleTest( + final GroupBuilder group, final int index, final Color foreColor, + final Color backColor, final String fontName, final Float fontSize, final Boolean bold, final Boolean italic) + { + this.styleTest(JasperTestUtils.getHeaderGroupName(group), index, foreColor, backColor, fontName, + fontSize, bold, italic); + } + + protected void groupHeaderAlignmentTest( + final GroupBuilder group, final int index, + final HorizontalTextAlignEnum horizontalAlignment) + { + this.horizontalAlignmentTest(JasperTestUtils.getHeaderGroupName(group), index, horizontalAlignment); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperTest.java new file mode 100644 index 0000000..c664e75 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperTest.java @@ -0,0 +1,253 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.DynamicReports; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRPrintElement; +import net.sf.jasperreports.engine.JRPrintFrame; +import net.sf.jasperreports.engine.JRPrintPage; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.JasperReport; +import net.sf.jasperreports.engine.util.JRLoader; +import net.sf.jasperreports.engine.util.JRSaver; + + +/** + * @author Ricardo Mariaca + */ +public abstract class AbstractJasperTest +{ + private JasperReportBuilder reportBuilder; + private JasperReport jasperReport; + private JasperPrint jasperPrint; + + @BeforeEach + public void init() + { + try + { + this.reportBuilder = DynamicReports.report(); + this.configureReport(this.reportBuilder); + if(this.serializableTest()) + { + this.reportBuilder = this.serializableReportTest(this.reportBuilder); + this.serializableParametersTest(this.reportBuilder.getJasperParameters()); + } + final JRDataSource dataSource = this.createDataSource(); + if(dataSource != null) + { + this.reportBuilder.setDataSource(dataSource); + } + this.build(); + if(this.serializableJrPrintTest()) + { + this.jasperPrint = this.serializableTest(this.jasperPrint); + } + } + catch(final Exception e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } + + protected void build() throws DRException + { + this.jasperReport = this.reportBuilder.toJasperReport(); + this.jasperPrint = this.reportBuilder.toJasperPrint(); + } + + @Test + public void test() + { + } + + protected boolean serializableTest() + { + return true; + } + + protected boolean serializableJrPrintTest() + { + return true; + } + + private JasperReportBuilder serializableReportTest(final JasperReportBuilder report) + throws IOException, ClassNotFoundException + { + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(report); + oos.flush(); + oos.close(); + + final InputStream stream = new ByteArrayInputStream(bos.toByteArray()); + final ObjectInputStream ois = new ObjectInputStream(stream); + return (JasperReportBuilder)ois.readObject(); + } + + @SuppressWarnings("unchecked") + private Map serializableParametersTest(final Map parameters) + throws IOException, ClassNotFoundException + { + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(parameters); + oos.flush(); + oos.close(); + + final InputStream stream = new ByteArrayInputStream(bos.toByteArray()); + final ObjectInputStream ois = new ObjectInputStream(stream); + return (Map)ois.readObject(); + } + + private JasperPrint serializableTest(final JasperPrint jasperPrint) throws IOException, JRException + { + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); + JRSaver.saveObject(jasperPrint, bos); + bos.flush(); + bos.close(); + + final InputStream stream = new ByteArrayInputStream(bos.toByteArray()); + return (JasperPrint)JRLoader.loadObject(stream); + } + + public JasperReportBuilder getReportBuilder() + { + return this.reportBuilder; + } + + public JasperReport getJasperReport() + { + return this.jasperReport; + } + + public JasperPrint getJasperPrint() + { + return this.jasperPrint; + } + + protected void numberOfPagesTest(final int expectedNumberOfPages) + { + Assertions.assertEquals(expectedNumberOfPages, this.getNumberOfPages()); + } + + private int getNumberOfPages() + { + return this.jasperPrint.getPages().size(); + } + + protected JRPrintElement getElementAt(final String key, final int index) + { + final List elements = this.findElement(key); + if(elements.size() - 1 < index) + { + Assertions.fail("Element " + key + " at index " + index + " not found"); + return null; + } + return elements.get(index); + } + + protected List findElement(final String key) + { + final List elements = new ArrayList<>(); + for( + final Iterator iterator = this.jasperPrint.getPages().iterator(); iterator.hasNext(); ) + { + final JRPrintPage page = (JRPrintPage)iterator.next(); + for( + final Iterator iterator2 = page.getElements().iterator(); iterator2.hasNext(); ) + { + final JRPrintElement element = (JRPrintElement)iterator2.next(); + this.findElement(key, elements, element); + } + } + return elements; + } + + protected void findElement(final String key, final List elements, final JRPrintElement element) + { + if(key.equals(element.getKey())) + { + elements.add(element); + } + if(element instanceof JRPrintFrame) + { + for( + final Iterator iterator = ((JRPrintFrame)element).getElements().iterator(); iterator.hasNext(); ) + { + final JRPrintElement element2 = (JRPrintElement)iterator.next(); + this.findElement(key, elements, element2); + } + } + } + + protected void containsElement(final String key, final int pageIndex) + { + final List elements = new ArrayList<>(); + final JRPrintPage page = this.getJasperPrint().getPages().get(pageIndex); + for( + final Iterator iterator = page.getElements().iterator(); iterator.hasNext(); ) + { + final JRPrintElement element = (JRPrintElement)iterator.next(); + this.findElement(key, elements, element); + } + if(elements.isEmpty()) + { + Assertions.fail("Element " + key + " at page index " + pageIndex + " not found"); + } + } + + protected Date toDate(final int year, final int month, final int day) + { + final Calendar c = Calendar.getInstance(); + c.clear(); + c.set(Calendar.YEAR, year); + c.set(Calendar.MONTH, month - 1); + c.set(Calendar.DAY_OF_MONTH, day); + return c.getTime(); + } + + protected JRDataSource createDataSource() + { + return null; + } + + protected abstract void configureReport(JasperReportBuilder rb) throws DRException; +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperValueTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperValueTest.java new file mode 100644 index 0000000..30fcef4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/AbstractJasperValueTest.java @@ -0,0 +1,252 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper; + +import java.util.List; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.BaseSubtotalBuilder; +import net.sf.jasperreports.engine.DefaultJasperReportsContext; +import net.sf.jasperreports.engine.JRPrintElement; +import net.sf.jasperreports.engine.JRPrintText; +import net.sf.jasperreports.engine.util.JRStyledTextUtil; + + +/** + * @author Ricardo Mariaca + */ +public abstract class AbstractJasperValueTest extends AbstractJasperTest +{ + + protected void elementCountTest(final String name, final int expectedNumberOfElements) + { + Assertions.assertEquals(expectedNumberOfElements, this.findElement(name).size()); + } + + protected void elementValueTest(final String name, final int index, final String value) + { + Assertions.assertEquals(value, this.getElementValue(name, index)); + } + + protected void elementFullValueTest(final String name, final int index, final String value) + { + Assertions.assertEquals(value, this.getElementFullValue(name, index)); + } + + protected void elementValueTest(final String name, final String... values) + { + final List elements = this.findElement(name); + Assertions.assertTrue(values.length <= elements.size()); + for(int i = 0; i < values.length; i++) + { + final JRPrintText textElement = (JRPrintText)elements.get(i); + final String value = + JRStyledTextUtil.getInstance(DefaultJasperReportsContext.getInstance()).getTruncatedText(textElement); + Assertions.assertEquals(values[i], value); + } + } + + protected void elementFullValueTest(final String name, final String... values) + { + final List elements = this.findElement(name); + Assertions.assertTrue(values.length <= elements.size()); + for(int i = 0; i < values.length; i++) + { + final String value = ((JRPrintText)elements.get(i)).getFullText(); + Assertions.assertEquals(values[i], value); + } + } + + private String getElementValue(final String key, final int index) + { + final JRPrintText textElement = (JRPrintText)this.getElementAt(key, index); + final String value = + JRStyledTextUtil.getInstance(DefaultJasperReportsContext.getInstance()).getTruncatedText(textElement); + return value; + } + + private String getElementFullValue(final String key, final int index) + { + return ((JRPrintText)this.getElementAt(key, index)).getFullText(); + } + + // column detail + protected void columnDetailCountTest(final ColumnBuilder column, final int expectedNumberOfElements) + { + this.elementCountTest(JasperTestUtils.getColumnDetailName(column), expectedNumberOfElements); + } + + protected void columnDetailValueTest(final ColumnBuilder column, final int index, final String value) + { + this.elementValueTest(JasperTestUtils.getColumnDetailName(column), index, value); + } + + protected void columnDetailFullValueTest(final ColumnBuilder column, final int index, final String value) + { + this.elementFullValueTest(JasperTestUtils.getColumnDetailName(column), index, value); + } + + protected void columnDetailValueTest(final ColumnBuilder column, final String... values) + { + this.elementValueTest(JasperTestUtils.getColumnDetailName(column), values); + } + + protected void columnDetailAtPageIndexTest(final ColumnBuilder column, final int pageIndex) + { + this.containsElement(JasperTestUtils.getColumnDetailName(column), pageIndex); + } + + // column title + protected void columnTitleCountTest(final ColumnBuilder column, final int expectedNumberOfElements) + { + this.elementCountTest(JasperTestUtils.getColumnTitleName(column), expectedNumberOfElements); + } + + protected void columnTitleValueTest(final ColumnBuilder column, final int index, final String value) + { + this.elementValueTest(JasperTestUtils.getColumnTitleName(column), index, value); + } + + protected void columnTitleFullValueTest(final ColumnBuilder column, final int index, final String value) + { + this.elementFullValueTest(JasperTestUtils.getColumnTitleName(column), index, value); + } + + protected void columnTitleValueTest(final ColumnBuilder column, final String... values) + { + this.elementValueTest(JasperTestUtils.getColumnTitleName(column), values); + } + + // subtotal label + protected void subtotalLabelCountTest(final BaseSubtotalBuilder subtotal, final int expectedNumberOfElements) + { + this.elementCountTest(JasperTestUtils.getSubtotalLabelName(subtotal, 1), expectedNumberOfElements); + } + + protected void subtotalLabelValueTest(final BaseSubtotalBuilder subtotal, final int index, + final String value) + { + this.elementValueTest(JasperTestUtils.getSubtotalLabelName(subtotal, 1), index, value); + } + + protected void subtotalLabelValueTest(final BaseSubtotalBuilder subtotal, final String... values) + { + this.elementValueTest(JasperTestUtils.getSubtotalLabelName(subtotal, 1), values); + } + + protected void subtotalLabelIndexCountTest( + final BaseSubtotalBuilder subtotal, + final int subtotalIndex, + final int expectedNumberOfElements) + { + this.elementCountTest(JasperTestUtils.getSubtotalLabelName(subtotal, subtotalIndex), expectedNumberOfElements); + } + + protected void subtotalLabelIndexValueTest( + final BaseSubtotalBuilder subtotal, + final int subtotalIndex, + final int index, + final String value) + { + this.elementValueTest(JasperTestUtils.getSubtotalLabelName(subtotal, subtotalIndex), index, value); + } + + protected void subtotalLabelIndexValueTest( + final BaseSubtotalBuilder subtotal, + final int subtotalIndex, + final String... values) + { + this.elementValueTest(JasperTestUtils.getSubtotalLabelName(subtotal, subtotalIndex), values); + } + + // subtotal + protected void subtotalCountTest(final BaseSubtotalBuilder subtotal, final int expectedNumberOfElements) + { + this.elementCountTest(JasperTestUtils.getSubtotalName(subtotal, 1), expectedNumberOfElements); + } + + protected void subtotalValueTest(final BaseSubtotalBuilder subtotal, final int index, final String value) + { + this.elementValueTest(JasperTestUtils.getSubtotalName(subtotal, 1), index, value); + } + + protected void subtotalValueTest(final BaseSubtotalBuilder subtotal, final String... values) + { + this.elementValueTest(JasperTestUtils.getSubtotalName(subtotal, 1), values); + } + + protected void subtotalIndexCountTest( + final BaseSubtotalBuilder subtotal, + final int subtotalIndex, + final int expectedNumberOfElements) + { + this.elementCountTest(JasperTestUtils.getSubtotalName(subtotal, subtotalIndex), expectedNumberOfElements); + } + + protected void subtotalIndexValueTest( + final BaseSubtotalBuilder subtotal, + final int subtotalIndex, + final int index, + final String value) + { + this.elementValueTest(JasperTestUtils.getSubtotalName(subtotal, subtotalIndex), index, value); + } + + protected void subtotalIndexValueTest( + final BaseSubtotalBuilder subtotal, + final int subtotalIndex, + final String... values) + { + this.elementValueTest(JasperTestUtils.getSubtotalName(subtotal, subtotalIndex), values); + } + + // group header title + protected void groupHeaderTitleCountTest(final GroupBuilder group, final int expectedNumberOfElements) + { + this.elementCountTest(JasperTestUtils.getHeaderTitleGroupName(group), expectedNumberOfElements); + } + + protected void groupHeaderTitleValueTest(final GroupBuilder group, final int index, final String value) + { + this.elementValueTest(JasperTestUtils.getHeaderTitleGroupName(group), index, value); + } + + protected void groupHeaderTitleValueTest(final GroupBuilder group, final String... values) + { + this.elementValueTest(JasperTestUtils.getHeaderTitleGroupName(group), values); + } + + // group header + protected void groupHeaderCountTest(final GroupBuilder group, final int expectedNumberOfElements) + { + this.elementCountTest(JasperTestUtils.getHeaderGroupName(group), expectedNumberOfElements); + } + + protected void groupHeaderValueTest(final GroupBuilder group, final int index, final String value) + { + this.elementValueTest(JasperTestUtils.getHeaderGroupName(group), index, value); + } + + protected void groupHeaderValueTest(final GroupBuilder group, final String... values) + { + this.elementValueTest(JasperTestUtils.getHeaderGroupName(group), values); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/JasperTestUtils.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/JasperTestUtils.java new file mode 100644 index 0000000..1276029 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/JasperTestUtils.java @@ -0,0 +1,137 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.report.base.DRSubtotal; +import software.xdev.dynamicreports.report.builder.column.ColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.group.GroupBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.BaseSubtotalBuilder; + +/** + * @author Ricardo Mariaca + */ +public class JasperTestUtils { + + // column detail + public static String getColumnDetailName(ColumnBuilder column) { + return "detail.column_" + column.build().getName() + "1"; + } + + // column title + public static String getColumnTitleName(ColumnBuilder column) { + return "columnHeader.column_" + column.build().getName() + ".title1"; + } + + // subtotal + private static String getSubtotalName(BaseSubtotalBuilder subtotal) { + String band = null; + DRSubtotal subtl = subtotal.getSubtotal(); + switch (subtl.getPosition()) { + case TITLE: + band = "title"; + break; + case PAGE_HEADER: + band = "pageHeader"; + break; + case PAGE_FOOTER: + band = "pageFooter"; + break; + case COLUMN_HEADER: + band = "columnHeader"; + break; + case COLUMN_FOOTER: + band = "columnFooter"; + break; + case GROUP_HEADER: + case FIRST_GROUP_HEADER: + case LAST_GROUP_HEADER: + band = "subtotalGroupHeader"; + break; + case GROUP_FOOTER: + case FIRST_GROUP_FOOTER: + case LAST_GROUP_FOOTER: + band = "subtotalGroupFooter"; + break; + case LAST_PAGE_FOOTER: + band = "lastPageFooter"; + break; + case SUMMARY: + band = "summary"; + break; + default: + Assertions.fail("Subtotal position " + subtl.getPosition().name() + " not found"); + return null; + } + return band + ".column_" + subtl.getShowInColumn().getName() + ".subtotal"; + } + + public static String getSubtotalLabelName(BaseSubtotalBuilder subtotal, int subtotalIndex) { + return getSubtotalName(subtotal) + ".label" + subtotalIndex; + } + + public static String getSubtotalName(BaseSubtotalBuilder subtotal, int subtotalIndex) { + return getSubtotalName(subtotal) + subtotalIndex; + } + + // group header title + public static String getHeaderTitleGroupName(GroupBuilder group) { + return "groupHeaderTitleAndValue.group_" + group.getGroup().getName() + ".title1"; + } + + // group header + public static String getHeaderGroupName(GroupBuilder group) { + return "groupHeaderTitleAndValue.group_" + group.getGroup().getName() + "1"; + } + + // crosstab group header + public static String getCrosstabGroupHeaderName(AbstractCrosstabGroupBuilder group) { + return "group_" + group.build().getName() + ".header1"; + } + + // crosstab group total header + public static String getCrosstabGroupTotalHeaderName(AbstractCrosstabGroupBuilder group) { + return "group_" + group.build().getName() + ".totalheader1"; + } + + // crosstab group title header + public static String getCrosstabGroupTitleHeaderName(AbstractCrosstabGroupBuilder group, CrosstabMeasureBuilder measure) { + return "group_" + group.build().getName() + ".titleheader." + measure.build().getName() + "1"; + } + + // crosstab group title total header + public static String getCrosstabGroupTitleTotalHeaderName(AbstractCrosstabGroupBuilder group, CrosstabMeasureBuilder measure) { + return "group_" + group.build().getName() + ".titletotalheader." + measure.build().getName() + "1"; + } + + // crosstab cell + public static String getCrosstabCellName(CrosstabMeasureBuilder measure, CrosstabRowGroupBuilder rowGroup, CrosstabColumnGroupBuilder columnGroup) { + String name = "cell_measure[" + measure.build().getName() + "]"; + if (rowGroup != null) { + name += "_rowgroup[" + rowGroup.build().getName() + "]"; + } + if (columnGroup != null) { + name += "_columngroup[" + columnGroup.build().getName() + "]"; + } + return name + "1"; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumn1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumn1Test.java new file mode 100644 index 0000000..488eb1f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumn1Test.java @@ -0,0 +1,81 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +import java.io.Serializable; +import java.util.Locale; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRPrintImage; + + +/** + * @author Ricardo Mariaca + */ +public class BooleanColumn1Test extends AbstractJasperValueTest implements Serializable +{ + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.setLocale(Locale.ENGLISH) + .columns(col.booleanColumn("field1").setComponentType(BooleanComponentType.TEXT_TRUE_FALSE), + col.booleanColumn("field1").setComponentType(BooleanComponentType.TEXT_YES_NO), + col.booleanColumn("field1") + .setComponentType(BooleanComponentType.TEXT_TRUE_FALSE) + .setEmptyWhenNullValue(true)); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + this.elementCountTest("detail.column_field11", 3); + this.elementValueTest("detail.column_field11", "True", "False", "False"); + + this.elementCountTest("detail.column_field12", 3); + this.elementValueTest("detail.column_field12", "Yes", "No", "No"); + + this.elementCountTest("detail.column_field13", 3); + this.elementValueTest("detail.column_field13", "True", "False", ""); + + Assertions.assertNull((((JRPrintImage)this.getElementAt("detail.column_field111", 2)).getRenderer())); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add(true); + dataSource.add(false); + dataSource.add(); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumn2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumn2Test.java new file mode 100644 index 0000000..a15a7bc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumn2Test.java @@ -0,0 +1,80 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.template; + +import java.io.Serializable; +import java.util.Locale; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRPrintImage; + + +/** + * @author Ricardo Mariaca + */ +public class BooleanColumn2Test extends AbstractJasperValueTest implements Serializable +{ + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.setLocale(Locale.ENGLISH) + .setTemplate(template().setBooleanEmptyWhenNullValue(true)) + .columns( + col.booleanColumn("field1").setComponentType(BooleanComponentType.TEXT_TRUE_FALSE), + col.booleanColumn("field1") + .setComponentType(BooleanComponentType.TEXT_TRUE_FALSE) + .setEmptyWhenNullValue(false)); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + this.elementCountTest("detail.column_field11", 3); + this.elementValueTest("detail.column_field11", "True", "False", ""); + + this.elementCountTest("detail.column_field12", 3); + this.elementValueTest("detail.column_field12", "True", "False", "False"); + + Assertions.assertNull((((JRPrintImage)this.getElementAt("detail.column_field13", 2)).getRenderer())); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add(true); + dataSource.add(false); + dataSource.add(); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition1Test.java new file mode 100644 index 0000000..a022be6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition1Test.java @@ -0,0 +1,65 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + + +/** + * @author Ricardo Mariaca + */ +public class BooleanColumnPosition1Test extends AbstractJasperPositionTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.columns(col.booleanColumn("field1").setComponentType(BooleanComponentType.TEXT_TRUE_FALSE), + col.booleanColumn("field1") + .setStyle(stl.style().setPadding(0)), col.column("field2", String.class).setFixedWidth(20)); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + this.elementPositionTest("detail.column_field11", 0, 0, 0, 277, 38); + this.elementPositionTest("detail.column_field12", 0, 277, 0, 278, 38); + + this.elementPositionTest("detail.column_field11", 1, 0, 0, 277, 16); + this.elementPositionTest("detail.column_field12", 1, 277, 0, 278, 16); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1", "field2"); + dataSource.add(true, "11111"); + dataSource.add(false, ""); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition2Test.java new file mode 100644 index 0000000..372b5cf --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition2Test.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + + +/** + * @author Ricardo Mariaca + */ +public class BooleanColumnPosition2Test extends AbstractJasperPositionTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.columns(col.booleanColumn("field1").setComponentType(BooleanComponentType.TEXT_TRUE_FALSE), + col.booleanColumn("field1"), + col.column("field2", String.class).setFixedWidth(20).setRows(3)); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + this.elementPositionTest("detail.column_field11", 0, 0, 0, 277, 49); + this.elementPositionTest("detail.column_field12", 0, 277, 0, 278, 49); + + this.elementPositionTest("detail.column_field11", 1, 0, 0, 277, 39); + this.elementPositionTest("detail.column_field12", 1, 277, 0, 278, 39); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1", "field2"); + dataSource.add(true, "1111111"); + dataSource.add(false, ""); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition3Test.java new file mode 100644 index 0000000..e63f981 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition3Test.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.BooleanComponentType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + + +/** + * @author Ricardo Mariaca + */ +public class BooleanColumnPosition3Test extends AbstractJasperPositionTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.columns( + col.booleanColumn("C1", "field1").setComponentType(BooleanComponentType.TEXT_TRUE_FALSE).setFixedWidth(100), + col.booleanColumn("C2", "field1").setFixedWidth(110).setFixedHeight(40)); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + this.elementPositionTest("columnHeader.list1", 0, 10, 10, 210, 16); + this.elementPositionTest("columnHeader.column_field1.title1", 0, 0, 0, 100, 16); + this.elementPositionTest("columnHeader.column_field1.title2", 0, 100, 0, 110, 16); + + this.elementPositionTest("detail.list1", 0, 10, 26, 210, 40); + this.elementPositionTest("detail.column_field11", 0, 0, 0, 100, 40); + this.elementPositionTest("detail.column_field12", 0, 100, 0, 110, 40); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add(true); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition4Test.java new file mode 100644 index 0000000..f073709 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition4Test.java @@ -0,0 +1,67 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + + +/** + * @author Ricardo Mariaca + */ +public class BooleanColumnPosition4Test extends AbstractJasperPositionTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.setColumnStyle(stl.style().setPadding(2)) + .columns( + col.booleanColumn("1", "field1"), + col.booleanColumn("1", "field1")); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + this.elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 16); + this.elementPositionTest("columnHeader.column_field1.title1", 0, 0, 0, 287, 16); + this.elementPositionTest("columnHeader.column_field1.title2", 0, 287, 0, 288, 16); + + this.elementPositionTest("detail.list1", 0, 10, 26, 575, 18); + this.elementPositionTest("detail.column_field11", 0, 0, 0, 287, 18); + this.elementPositionTest("detail.column_field12", 0, 287, 0, 288, 18); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add(true); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition5Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition5Test.java new file mode 100644 index 0000000..206e5b1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/BooleanColumnPosition5Test.java @@ -0,0 +1,68 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + + +/** + * @author Ricardo Mariaca + */ +public class BooleanColumnPosition5Test extends AbstractJasperPositionTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.setColumnStyle(stl.style().setPadding(2)) + .highlightDetailEvenRows() + .columns( + col.booleanColumn("1", "field1"), + col.booleanColumn("1", "field1")); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + this.elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 16); + this.elementPositionTest("columnHeader.column_field1.title1", 0, 0, 0, 287, 16); + this.elementPositionTest("columnHeader.column_field1.title2", 0, 287, 0, 288, 16); + + this.elementPositionTest("detail.list1", 0, 10, 26, 575, 18); + this.elementPositionTest("detail.column_field11", 0, 0, 0, 287, 18); + this.elementPositionTest("detail.column_field12", 0, 287, 0, 288, 18); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add(true); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column1Test.java new file mode 100644 index 0000000..e1b9066 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column1Test.java @@ -0,0 +1,137 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.base.expression.AbstractValueFormatter; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; + +/** + * @author Ricardo Mariaca + */ +public class Column1Test extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private TextColumnBuilder column5; + private TextColumnBuilder column6; + private TextColumnBuilder column7; + + private Date date = new Date(); + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setLocale(Locale.ENGLISH) + .addField("field1", Integer.class) + .columns(column2 = col.column("Column2\nColumn2", "field2", String.class), column3 = col.column("Column3", "field3", Date.class).setPattern("dd.MM.yyyy"), + column4 = col.column("Column4", "field4", Double.class).setPattern("#,###.00"), + column5 = col.column("Column5", "field5", BigDecimal.class).setValueFormatter(new ColumnValueFormatter()), + column6 = col.column("Column6", "field6", Double.class).setPattern(new PatternExpression()), column7 = col.column("Column7", field("field7", Date.class).build())); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(3); + // column2 + columnDetailCountTest(column2, 110); + columnDetailValueTest(column2, 50, "test"); + columnTitleCountTest(column2, 3); + columnTitleValueTest(column2, "Column2\nColumn2", "Column2\nColumn2", "Column2\nColumn2"); + // column3 + columnDetailCountTest(column3, 110); + columnDetailValueTest(column3, 50, new SimpleDateFormat("dd.MM.yyyy").format(date)); + columnTitleCountTest(column3, 3); + columnTitleValueTest(column3, "Column3", "Column3", "Column3"); + // column4 + columnDetailCountTest(column4, 110); + columnDetailValueTest(column4, 50, "1.00"); + columnTitleCountTest(column4, 3); + columnTitleValueTest(column4, "Column4", "Column4", "Column4"); + // column5 + columnDetailCountTest(column5, 110); + columnDetailValueTest(column5, 50, "value = 10"); + columnTitleCountTest(column5, 3); + columnTitleValueTest(column5, "Column5", "Column5", "Column5"); + // column6 + columnDetailCountTest(column6, 110); + columnDetailValueTest(column6, 0, "1.00"); + columnDetailValueTest(column6, 1, "1.000"); + columnDetailValueTest(column6, 2, "1.0000"); + columnDetailValueTest(column6, 3, "1.0"); + columnDetailValueTest(column6, 50, "1.0"); + columnTitleCountTest(column6, 3); + columnTitleValueTest(column6, "Column6", "Column6", "Column6"); + // column7 + columnDetailCountTest(column7, 110); + columnDetailValueTest(column7, 50, new SimpleDateFormat("MM/dd/yyyy").format(date)); + columnTitleCountTest(column7, 3); + columnTitleValueTest(column7, "Column7", "Column7", "Column7"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5", "field6", "field7"); + for (int i = 0; i < 110; i++) { + dataSource.add(1, "test", date, 1d, new BigDecimal(10), 1d, date); + } + return dataSource; + } + + private class ColumnValueFormatter extends AbstractValueFormatter { + private static final long serialVersionUID = 1L; + + @Override + public String format(BigDecimal value, ReportParameters reportParameters) { + return "value = " + value; + } + } + + private class PatternExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public String evaluate(ReportParameters reportParameters) { + String pattern = "#,###.0"; + Integer reportRowNumber = reportParameters.getReportRowNumber(); + if (reportRowNumber < 4) { + for (int i = 0; i < reportRowNumber; i++) { + pattern += "0"; + } + } + return pattern; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column2Test.java new file mode 100644 index 0000000..c2adbff --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column2Test.java @@ -0,0 +1,99 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.util.ArrayList; +import java.util.List; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; + +/** + * @author Ricardo Mariaca + */ +public class Column2Test extends AbstractJasperValueTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setPageColumnsPerPage(2) + .fields(field("field1", Integer.class)) + .columns(column1 = col.reportRowNumberColumn("Column1").setWidth(50), column2 = col.pageRowNumberColumn("Column2").setWidth(50), column3 = col.columnRowNumberColumn("Column3").setWidth(50)); + } + + @Override + public void test() { + super.test(); + + List rows = new ArrayList(); + for (int i = 0; i < 110; i++) { + rows.add(String.valueOf(i + 1)); + } + List pageRows = new ArrayList(); + for (int i = 0; i < 100; i++) { + pageRows.add(String.valueOf(i + 1)); + } + for (int i = 0; i < 10; i++) { + pageRows.add(String.valueOf(i + 1)); + } + List columnRows = new ArrayList(); + for (int i = 0; i < 50; i++) { + columnRows.add(String.valueOf(i + 1)); + } + for (int i = 0; i < 50; i++) { + columnRows.add(String.valueOf(i + 1)); + } + for (int i = 0; i < 10; i++) { + columnRows.add(String.valueOf(i + 1)); + } + + numberOfPagesTest(2); + // column1 + columnDetailCountTest(column1, 110); + columnDetailValueTest(column1, rows.toArray(new String[] {})); + columnTitleCountTest(column1, 3); + columnTitleValueTest(column1, "Column1", "Column1", "Column1"); + // column2 + columnDetailCountTest(column2, 110); + columnDetailValueTest(column2, pageRows.toArray(new String[] {})); + columnTitleCountTest(column2, 3); + columnTitleValueTest(column2, "Column2", "Column2", "Column2"); + // column3 + columnDetailCountTest(column3, 110); + columnDetailValueTest(column3, columnRows.toArray(new String[] {})); + columnTitleCountTest(column3, 3); + columnTitleValueTest(column3, "Column3", "Column3", "Column3"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 110; i++) { + dataSource.add(i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column3Test.java new file mode 100644 index 0000000..f4d2601 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column3Test.java @@ -0,0 +1,126 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractValueFormatter; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.datatype.DoubleType; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.definition.expression.DRIValueFormatter; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class Column3Test extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private TextColumnBuilder column5; + private TextColumnBuilder column6; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setLocale(Locale.ENGLISH) + .columnGrid(ListType.HORIZONTAL_FLOW) + .columns(column1 = col.column("Column1", "field1", type.stringType()), column2 = col.column("Column2", "field2", type.dateType()), + column3 = col.column("Column3", "field3", type.dateYearToMinuteType()), column4 = col.column("Column4", "field4", type.doubleType()), + column5 = col.column("Column5", "field5", type.bigDecimalType()), column6 = col.column("Column6", "field6", new CustomType())); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + // column2 + columnDetailCountTest(column1, 10); + columnDetailValueTest(column1, 1, "test"); + columnTitleCountTest(column1, 1); + columnTitleValueTest(column1, "Column1"); + // column2 + columnDetailCountTest(column2, 10); + columnDetailValueTest(column2, 1, new SimpleDateFormat(type.dateType().getPattern()).format(new Date())); + columnTitleCountTest(column2, 1); + columnTitleValueTest(column2, "Column2"); + // column3 + columnDetailCountTest(column3, 10); + columnDetailValueTest(column3, 1, new SimpleDateFormat(type.dateYearToMinuteType().getPattern()).format(new Date())); + columnTitleCountTest(column3, 1); + columnTitleValueTest(column3, "Column3"); + // column4 + columnDetailCountTest(column4, 10); + columnDetailValueTest(column4, 1, "1,000.1"); + columnTitleCountTest(column4, 1); + columnTitleValueTest(column4, "Column4"); + // column5 + columnDetailCountTest(column5, 10); + columnDetailValueTest(column5, 1, "10.00"); + columnTitleCountTest(column5, 1); + columnTitleValueTest(column5, "Column5"); + // column6 + columnDetailCountTest(column6, 10); + columnDetailValueTest(column6, 1, "value = 1.0"); + columnTitleCountTest(column6, 1); + columnTitleValueTest(column6, "Column6"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5", "field6"); + for (int i = 0; i < 10; i++) { + dataSource.add("test", new Date(), new Date(), 1000.1d, new BigDecimal(10), 1d); + } + return dataSource; + } + + private class CustomType extends DoubleType { + private static final long serialVersionUID = 1L; + + @Override + public DRIValueFormatter getValueFormatter() { + return new ColumnValueFormatter(); + } + + } + + private class ColumnValueFormatter extends AbstractValueFormatter { + private static final long serialVersionUID = 1L; + + @Override + public String format(Double value, ReportParameters reportParameters) { + return "value = " + value; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column4Test.java new file mode 100644 index 0000000..83fb58c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/Column4Test.java @@ -0,0 +1,74 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class Column4Test extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columns(column1 = col.column("Column1", "field1", type.stringType()).setPrintRepeatedDetailValues(false).setPrintInFirstWholeBand(true), + column2 = col.column("Column2", "field2", type.integerType())); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(2); + // column1 + columnDetailCountTest(column1, 3); + columnDetailValueTest(column1, "test1", "test2", "test2"); + columnTitleCountTest(column1, 2); + columnTitleValueTest(column1, "Column1", "Column1"); + // column2 + columnDetailCountTest(column2, 60); + columnDetailValueTest(column2, 0, "0"); + columnTitleCountTest(column2, 2); + columnTitleValueTest(column2, "Column2", "Column2"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 0; i < 30; i++) { + dataSource.add("test1", i); + } + for (int i = 0; i < 30; i++) { + dataSource.add("test2", i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnGridTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnGridTest.java new file mode 100644 index 0000000..30b6be5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnGridTest.java @@ -0,0 +1,80 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class ColumnGridTest extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private AggregationSubtotalBuilder subtotal1; + private AggregationSubtotalBuilder subtotal2; + private AggregationSubtotalBuilder subtotal3; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columnGrid(ListType.VERTICAL) + .columns(column1 = col.column("Column1", "field1", Integer.class), column2 = col.column("Column2", "field2", Integer.class), column3 = col.column("Column3", "field3", Integer.class)) + .subtotalsAtSummary(subtotal1 = sbt.sum(column1), subtotal2 = sbt.sum(column2), subtotal3 = sbt.sum(column3)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnTitlePositionTest(column1, 0, 10, 10, 575, 16); + columnDetailPositionTest(column1, 0, 10, 58, 575, 16); + columnDetailPositionTest(column1, 1, 10, 106, 575, 16); + // column2 + columnTitlePositionTest(column2, 0, 10, 26, 575, 16); + columnDetailPositionTest(column2, 0, 10, 74, 575, 16); + columnDetailPositionTest(column2, 1, 10, 122, 575, 16); + // column3 + columnTitlePositionTest(column3, 0, 10, 42, 575, 16); + columnDetailPositionTest(column3, 0, 10, 90, 575, 16); + columnDetailPositionTest(column3, 1, 10, 138, 575, 16); + // subtotal + subtotalPositionTest(subtotal1, 0, 10, 154, 575, 16); + subtotalPositionTest(subtotal2, 0, 10, 170, 575, 16); + subtotalPositionTest(subtotal3, 0, 10, 186, 575, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add(1, 2, 3); + dataSource.add(1, 2, 3); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnPosition1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnPosition1Test.java new file mode 100644 index 0000000..ca6346c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnPosition1Test.java @@ -0,0 +1,79 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class ColumnPosition1Test extends AbstractJasperPositionTest { + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private TextColumnBuilder column5; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.addField("field1", type.integerType()) + .columns(column2 = col.column("Very long Column2 title", "field2", String.class).setFixedWidth(70), column3 = col.column("Column3", "field3", Integer.class), + column4 = col.column("Column4", "field4", Integer.class), column5 = col.column("Column5", "field5", Integer.class)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 26); + elementPositionTest("detail.list1", 0, 10, 36, 575, 16); + elementPositionTest("detail.list1", 1, 10, 52, 575, 26); + + // column2 + columnTitlePositionTest(column2, 0, 0, 0, 70, 26); + columnDetailPositionTest(column2, 0, 0, 0, 70, 16); + columnDetailPositionTest(column2, 1, 0, 0, 70, 26); + // column3 + columnTitlePositionTest(column3, 0, 70, 0, 168, 26); + columnDetailPositionTest(column3, 0, 70, 0, 168, 16); + columnDetailPositionTest(column3, 1, 70, 0, 168, 26); + // column4 + columnTitlePositionTest(column4, 0, 238, 0, 168, 26); + columnDetailPositionTest(column4, 0, 238, 0, 168, 16); + columnDetailPositionTest(column4, 1, 238, 0, 168, 26); + // column5 + columnTitlePositionTest(column5, 0, 406, 0, 169, 26); + columnDetailPositionTest(column5, 0, 406, 0, 169, 16); + columnDetailPositionTest(column5, 1, 406, 0, 169, 26); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5"); + dataSource.add(1, "2", 3, 4, 5); + dataSource.add(1, "very very very long value 2", 3, 4, 5); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnPosition2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnPosition2Test.java new file mode 100644 index 0000000..276e70b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnPosition2Test.java @@ -0,0 +1,95 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grid; + +/** + * @author Ricardo Mariaca + */ +public class ColumnPosition2Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private TextColumnBuilder column5; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columns(column1 = col.column("Column1", "field1", Integer.class), column2 = col.column("Very very very very very very long Column2 title", "field2", String.class), + column3 = col.column("Column3", "field3", Integer.class), column4 = col.column("Column4", "field4", Integer.class).setWidth(50), + column5 = col.column("Column5", "field5", Integer.class)).columnGrid(column1, grid.horizontalColumnGridList().add(column2, column3).newRow().add(column4, column5)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 42); + // elementPositionTest("columnHeader.list2", 0, 191, 0, 384, 42); + elementPositionTest("columnHeader.list3", 0, 191, 0, 384, 26); + elementPositionTest("columnHeader.list4", 0, 191, 26, 384, 16); + + elementPositionTest("detail.list1", 0, 10, 52, 575, 32); + // elementPositionTest("detail.list2", 0, 191, 0, 384, 32); + elementPositionTest("detail.list3", 0, 191, 0, 384, 16); + elementPositionTest("detail.list4", 0, 191, 16, 384, 16); + + elementPositionTest("detail.list1", 1, 10, 84, 575, 42); + // elementPositionTest("detail.list2", 1, 191, 0, 384, 42); + elementPositionTest("detail.list3", 1, 191, 0, 384, 26); + elementPositionTest("detail.list4", 1, 191, 26, 384, 16); + + // column1 + columnTitlePositionTest(column1, 0, 0, 0, 191, 42); + columnDetailPositionTest(column1, 0, 0, 0, 191, 32); + columnDetailPositionTest(column1, 1, 0, 0, 191, 42); + // column2 + columnTitlePositionTest(column2, 0, 0, 0, 192, 26); + columnDetailPositionTest(column2, 0, 0, 0, 192, 16); + columnDetailPositionTest(column2, 1, 0, 0, 192, 26); + // column3 + columnTitlePositionTest(column3, 0, 192, 0, 192, 26); + columnDetailPositionTest(column3, 0, 192, 0, 192, 16); + columnDetailPositionTest(column3, 1, 192, 0, 192, 26); + // column4 + columnTitlePositionTest(column4, 0, 0, 0, 128, 16); + columnDetailPositionTest(column4, 0, 0, 0, 128, 16); + columnDetailPositionTest(column4, 1, 0, 0, 128, 16); + // column5 + columnTitlePositionTest(column5, 0, 128, 0, 256, 16); + columnDetailPositionTest(column5, 0, 128, 0, 256, 16); + columnDetailPositionTest(column5, 1, 128, 0, 256, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5"); + dataSource.add(1, "2", 3, 4, 5); + dataSource.add(1, "very very very very very very very long value 2", 3, 4, 5); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroup1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroup1Test.java new file mode 100644 index 0000000..a3d1da3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroup1Test.java @@ -0,0 +1,76 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grid; + +/** + * @author Ricardo Mariaca + */ +public class ColumnTitleGroup1Test extends AbstractJasperValueTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + + @Override + protected void configureReport(JasperReportBuilder rb) { + column1 = col.column("Column1", "field1", String.class); + column2 = col.column("Column2", "field2", String.class); + column3 = col.column("Column3", "field3", String.class); + column4 = col.column("Column4", "field4", String.class); + + rb.columnGrid(column1, grid.titleGroup("Group1", column2, grid.titleGroup("Group2", column3, column4))).columns(column1, column2, column3, column4); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementValueTest("columnHeader.columngroup.title1", 0, "Group1"); + elementValueTest("columnHeader.columngroup.title2", 0, "Group2"); + // column1 + columnTitleValueTest(column1, 0, "Column1"); + columnDetailValueTest(column1, 0, "text"); + // column2 + columnTitleValueTest(column2, 0, "Column2"); + columnDetailValueTest(column2, 0, "text"); + // column3 + columnTitleValueTest(column3, 0, "Column3"); + columnDetailValueTest(column3, 0, "text"); + // column4 + columnTitleValueTest(column4, 0, "Column4"); + columnDetailValueTest(column4, 0, "text"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add("text", "text", "text", "text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroup2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroup2Test.java new file mode 100644 index 0000000..54bfb1f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroup2Test.java @@ -0,0 +1,74 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.jasper.constant.JasperProperty; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grid; + +/** + * @author Ricardo Mariaca + */ +public class ColumnTitleGroup2Test extends AbstractJasperValueTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + + @Override + protected void configureReport(JasperReportBuilder rb) { + column1 = col.column("Column1", "field1", String.class); + column2 = col.column("Column2", "field2", String.class).setFixedWidth(25); + column3 = col.column("Column3", "field3", String.class).setFixedWidth(25); + + ColumnTitleGroupBuilder titleGroup = grid.titleGroup("test test test", column2, column3).setTitleStretchWithOverflow(false).addTitleProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true"); + rb.columnGrid(column1, titleGroup).columns(column1, column2, column3); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementValueTest("columnHeader.columngroup.title1", 0, "test test "); + elementFullValueTest("columnHeader.columngroup.title1", 0, "test test test"); + // column1 + columnTitleValueTest(column1, 0, "Column1"); + columnDetailValueTest(column1, 0, "text"); + // column2 + columnTitleValueTest(column2, 0, "Column2"); + columnDetailValueTest(column2, 0, "text"); + // column3 + columnTitleValueTest(column3, 0, "Column3"); + columnDetailValueTest(column3, 0, "text"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("text", "text", "text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroup3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroup3Test.java new file mode 100644 index 0000000..a8d6667 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroup3Test.java @@ -0,0 +1,77 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grid; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.jasper.constant.JasperProperty; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * @author Ricardo Mariaca, Jan Moxter + */ +public class ColumnTitleGroup3Test extends AbstractJasperValueTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + + @Override + protected void configureReport(final JasperReportBuilder rb) { + column1 = col.column("Column1", "field1", String.class); + column2 = col.column("Column2", "field2", String.class).setFixedWidth(25); + column3 = col.column("Column3", "field3", String.class).setFixedWidth(25); + + final ColumnTitleGroupBuilder titleGroup = grid.titleGroup("test test test", column2, column3) + .setTitleTextAdjust(TextAdjust.CUT_TEXT) + .addTitleProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true"); + rb.columnGrid(column1, titleGroup).columns(column1, column2, column3); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementValueTest("columnHeader.columngroup.title1", 0, "test test "); + elementFullValueTest("columnHeader.columngroup.title1", 0, "test test test"); + // column1 + columnTitleValueTest(column1, 0, "Column1"); + columnDetailValueTest(column1, 0, "text"); + // column2 + columnTitleValueTest(column2, 0, "Column2"); + columnDetailValueTest(column2, 0, "text"); + // column3 + columnTitleValueTest(column3, 0, "Column3"); + columnDetailValueTest(column3, 0, "text"); + } + + @Override + protected JRDataSource createDataSource() { + final DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("text", "text", "text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition1Test.java new file mode 100644 index 0000000..03ec980 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition1Test.java @@ -0,0 +1,86 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grid; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class ColumnTitleGroupPosition1Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + column1 = col.column("Column1", "field1", String.class); + column2 = col.column("Column2", "field2", String.class); + column3 = col.column("Column3", "field3", Integer.class); + column4 = col.column("Column4", "field4", String.class); + + rb.columnGrid(column1, grid.titleGroup("Group1", column2, grid.titleGroup("group2", column3, column4))) + .columns(column1, column2, column3, column4) + .subtotalsAtSummary(subtotal1 = sbt.sum(column3)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 48); + elementPositionTest("columnHeader.list3", 0, 143, 16, 432, 32); + elementPositionTest("columnHeader.list5", 0, 144, 16, 288, 16); + elementPositionTest("columnHeader.columngroup.title1", 0, 143, 0, 432, 16); + elementPositionTest("columnHeader.columngroup.title2", 0, 144, 0, 288, 16); + // column1 + columnTitlePositionTest(column1, 0, 0, 0, 143, 48); + columnDetailPositionTest(column1, 0, 0, 0, 143, 26); + // column2 + columnTitlePositionTest(column2, 0, 0, 0, 144, 32); + columnDetailPositionTest(column2, 0, 143, 0, 144, 26); + // column3 + columnTitlePositionTest(column3, 0, 0, 0, 144, 16); + columnDetailPositionTest(column3, 0, 287, 0, 144, 26); + // column4 + columnTitlePositionTest(column4, 0, 144, 0, 144, 16); + columnDetailPositionTest(column4, 0, 431, 0, 144, 26); + // subtotal + subtotalPositionTest(subtotal1, 0, 287, 0, 144, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add("text", "text text text text text text text text", 1, "text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition2Test.java new file mode 100644 index 0000000..9477483 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition2Test.java @@ -0,0 +1,77 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grid; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class ColumnTitleGroupPosition2Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + column1 = col.column("Column1", "field1", String.class); + column2 = col.column("Column2", "field2", Integer.class); + column3 = col.column("Column3", "field3", String.class).setFixedWidth(50); + + rb.columnGrid(column1, grid.titleGroup("Group1", column2, column3)).columns(column1, column2, column3).subtotalsAtSummary(subtotal1 = sbt.sum(column2)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 32); + elementPositionTest("columnHeader.list3", 0, 230, 16, 345, 16); + elementPositionTest("columnHeader.columngroup.title1", 0, 230, 0, 345, 16); + // column1 + columnTitlePositionTest(column1, 0, 0, 0, 230, 32); + columnDetailPositionTest(column1, 0, 0, 0, 230, 16); + // column2 + columnTitlePositionTest(column2, 0, 0, 0, 295, 16); + columnDetailPositionTest(column2, 0, 230, 0, 295, 16); + // column3 + columnTitlePositionTest(column3, 0, 295, 0, 50, 16); + columnDetailPositionTest(column3, 0, 525, 0, 50, 16); + // subtotal + subtotalPositionTest(subtotal1, 0, 230, 0, 295, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("text", 1, "text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition3Test.java new file mode 100644 index 0000000..1f66e71 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition3Test.java @@ -0,0 +1,77 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grid; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class ColumnTitleGroupPosition3Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + column1 = col.column("Col1", "field1", String.class); + column2 = col.column("Col2", "field2", Integer.class).setFixedWidth(40); + column3 = col.column("Col3", "field3", String.class).setFixedWidth(40); + + rb.columnGrid(column1, grid.titleGroup("Group1", column2, column3)).columns(column1, column2, column3).subtotalsAtSummary(subtotal1 = sbt.sum(column2)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 32); + elementPositionTest("columnHeader.list3", 0, 495, 16, 80, 16); + elementPositionTest("columnHeader.columngroup.title1", 0, 495, 0, 80, 16); + // column1 + columnTitlePositionTest(column1, 0, 0, 0, 495, 32); + columnDetailPositionTest(column1, 0, 0, 0, 495, 16); + // column2 + columnTitlePositionTest(column2, 0, 0, 0, 40, 16); + columnDetailPositionTest(column2, 0, 495, 0, 40, 16); + // column3 + columnTitlePositionTest(column3, 0, 40, 0, 40, 16); + columnDetailPositionTest(column3, 0, 535, 0, 40, 16); + // subtotal + subtotalPositionTest(subtotal1, 0, 495, 0, 40, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("text", 1, "text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition4Test.java new file mode 100644 index 0000000..134b830 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition4Test.java @@ -0,0 +1,91 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grid; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class ColumnTitleGroupPosition4Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private TextColumnBuilder column5; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + column1 = col.column("Col1", "field1", String.class); + column2 = col.column("Col2", "field2", Integer.class); + column3 = col.column("Col3", "field3", String.class); + column4 = col.column("Col4", "field4", String.class); + column5 = col.column("Col5", "field5", String.class); + + rb.columnGrid(column1, grid.titleGroup("Group1", column2, column3).setTitleFixedWidth(400), grid.titleGroup("Group2", column4, column5).setTitleFixedWidth(80)) + .columns(column1, column2, column3, column4, column5) + .subtotalsAtSummary(subtotal1 = sbt.sum(column2)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 32); + elementPositionTest("columnHeader.list3", 0, 95, 16, 400, 16); + elementPositionTest("columnHeader.list5", 0, 495, 16, 80, 16); + elementPositionTest("columnHeader.columngroup.title1", 0, 95, 0, 400, 16); + elementPositionTest("columnHeader.columngroup.title2", 0, 495, 0, 80, 16); + // column1 + columnTitlePositionTest(column1, 0, 0, 0, 95, 32); + columnDetailPositionTest(column1, 0, 0, 0, 95, 16); + // column2 + columnTitlePositionTest(column2, 0, 0, 0, 200, 16); + columnDetailPositionTest(column2, 0, 95, 0, 200, 16); + // column3 + columnTitlePositionTest(column3, 0, 200, 0, 200, 16); + columnDetailPositionTest(column3, 0, 295, 0, 200, 16); + // column4 + columnTitlePositionTest(column4, 0, 0, 0, 40, 16); + columnDetailPositionTest(column4, 0, 495, 0, 40, 16); + // column5 + columnTitlePositionTest(column5, 0, 40, 0, 40, 16); + columnDetailPositionTest(column5, 0, 535, 0, 40, 16); + // subtotal + subtotalPositionTest(subtotal1, 0, 95, 0, 200, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5"); + dataSource.add("text", 1, "text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition5Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition5Test.java new file mode 100644 index 0000000..ef7b89e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition5Test.java @@ -0,0 +1,88 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grid; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class ColumnTitleGroupPosition5Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + column1 = col.column("Col1", "field1", String.class); + column2 = col.column("Col2", "field2", Integer.class); + column3 = col.column("Col3", "field3", String.class).setFixedWidth(50); + column4 = col.column("Col4", "field4", String.class); + + ColumnTitleGroupBuilder titleGroup2 = grid.titleGroup("Group 2", column3, column4).setTitleFixedWidth(150); + ColumnTitleGroupBuilder titleGroup1 = grid.titleGroup("Group 1", column2, titleGroup2).setTitleFixedWidth(300); + + rb.columnGrid(column1, titleGroup1).columns(column1, column2, column3, column4).subtotalsAtSummary(subtotal1 = sbt.sum(column2)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 48); + elementPositionTest("columnHeader.list3", 0, 275, 16, 300, 32); + elementPositionTest("columnHeader.list5", 0, 150, 16, 150, 16); + elementPositionTest("columnHeader.columngroup.title1", 0, 275, 0, 300, 16); + elementPositionTest("columnHeader.columngroup.title2", 0, 150, 0, 150, 16); + // column1 + columnTitlePositionTest(column1, 0, 0, 0, 275, 48); + columnDetailPositionTest(column1, 0, 0, 0, 275, 16); + // column2 + columnTitlePositionTest(column2, 0, 0, 0, 150, 32); + columnDetailPositionTest(column2, 0, 275, 0, 150, 16); + // column3 + columnTitlePositionTest(column3, 0, 0, 0, 50, 16); + columnDetailPositionTest(column3, 0, 425, 0, 50, 16); + // column4 + columnTitlePositionTest(column4, 0, 50, 0, 100, 16); + columnDetailPositionTest(column4, 0, 475, 0, 100, 16); + // subtotal + subtotalPositionTest(subtotal1, 0, 275, 0, 150, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add("text", 1, "text", "text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition6Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition6Test.java new file mode 100644 index 0000000..acdd88e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ColumnTitleGroupPosition6Test.java @@ -0,0 +1,73 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grid; + +/** + * @author Ricardo Mariaca + */ +public class ColumnTitleGroupPosition6Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + + @Override + protected void configureReport(JasperReportBuilder rb) { + column1 = col.column("field1", String.class); + column2 = col.column("field2", Integer.class); + column3 = col.column("field3", String.class).setFixedWidth(50); + column4 = col.column("field4", String.class); + + rb.columnGrid(column1, grid.titleGroup("Group 1", column2), grid.titleGroup("Group 2", column3, column4)).columns(column1, column2, column3, column4); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 16); + elementPositionTest("columnHeader.columngroup.title1", 0, 164, 0, 164, 16); + elementPositionTest("columnHeader.columngroup.title2", 0, 328, 0, 247, 16); + // column1 + columnDetailPositionTest(column1, 0, 0, 0, 164, 16); + // column2 + columnDetailPositionTest(column2, 0, 164, 0, 164, 16); + // column3 + columnDetailPositionTest(column3, 0, 328, 0, 50, 16); + // column4 + columnDetailPositionTest(column4, 0, 378, 0, 197, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add("text", 1, "text", "text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ComponentColumnPositionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ComponentColumnPositionTest.java new file mode 100644 index 0000000..e183dea --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ComponentColumnPositionTest.java @@ -0,0 +1,97 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.ComponentColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.CustomSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.exp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class ComponentColumnPositionTest extends AbstractJasperPositionTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private ComponentColumnBuilder column3; + private CustomSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columns(column1 = col.column("Column1", "field1", type.stringType()), col.componentColumn(cmp.filler().setFixedWidth(5)), col.componentColumn(cmp.filler()).setFixedWidth(5), + column3 = col.componentColumn("Column3", cmp.verticalList(cmp.horizontalList(cmp.text("aa"), cmp.text("cc")), cmp.text("aa")))) + .subtotalsAtSummary(subtotal1 = sbt.customValue(exp.text("subtotal"), column3)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 16); + elementPositionTest("detail.list1", 0, 10, 26, 575, 32); + elementPositionTest("detail.list1", 1, 10, 58, 575, 32); + + // column1 + columnTitlePositionTest(column1, 0, 0, 0, 188, 16); + columnDetailPositionTest(column1, 0, 0, 0, 188, 32); + columnDetailPositionTest(column1, 1, 0, 0, 188, 32); + + // column3 + columnTitlePositionTest(column3, 0, 198, 0, 377, 16); + // columnDetailPositionTest(column3, 0, 198, 0, 377, 32); + // columnDetailPositionTest(column3, 1, 198, 0, 377, 32); + + elementPositionTest("detail.list2", 0, 198, 0, 377, 16); + elementPositionTest("detail.list2", 1, 198, 0, 377, 16); + + elementPositionTest("detail.textField1", 0, 0, 0, 188, 16); + elementPositionTest("detail.textField1", 1, 0, 0, 188, 16); + + elementPositionTest("detail.textField2", 0, 188, 0, 189, 16); + elementPositionTest("detail.textField2", 1, 188, 0, 189, 16); + + elementPositionTest("detail.textField3", 0, 198, 16, 377, 16); + elementPositionTest("detail.textField3", 1, 198, 16, 377, 16); + + // summary + elementPositionTest("summary.list1", 0, 10, 90, 575, 16); + subtotalPositionTest(subtotal1, 0, 198, 0, 377, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 2; i++) { + dataSource.add("test"); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/EmptyColumnTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/EmptyColumnTest.java new file mode 100644 index 0000000..e3167ae --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/EmptyColumnTest.java @@ -0,0 +1,101 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class EmptyColumnTest extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private TextColumnBuilder column5; + private TextColumnBuilder column6; + private TextColumnBuilder column7; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columns(column1 = col.column("Column1", "field1", String.class), column2 = col.emptyColumn(), column3 = col.column("Column3", "field3", String.class), + column4 = col.emptyColumn(false, true), column5 = col.emptyColumn(true, false), column6 = col.emptyColumn(true, true), column7 = col.column("Column7", "field7", String.class)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnDetailCountTest(column1, 1); + columnDetailValueTest(column1, "test1"); + columnTitleCountTest(column1, 1); + columnTitleValueTest(column1, "Column1"); + + // column2 + columnDetailCountTest(column2, 0); + columnTitleCountTest(column2, 0); + + // column3 + columnDetailCountTest(column3, 1); + columnDetailValueTest(column3, "test3"); + columnTitleCountTest(column3, 1); + columnTitleValueTest(column3, "Column3"); + + // column4 + columnDetailCountTest(column4, 1); + columnDetailValueTest(column4, ""); + columnTitleCountTest(column4, 0); + + // column5 + columnDetailCountTest(column5, 0); + columnTitleCountTest(column5, 1); + columnTitleValueTest(column5, ""); + + // column6 + columnDetailCountTest(column6, 1); + columnDetailValueTest(column6, ""); + columnTitleCountTest(column6, 1); + columnTitleValueTest(column6, ""); + + // column7 + columnDetailCountTest(column7, 1); + columnDetailValueTest(column7, "test7"); + columnTitleCountTest(column7, 1); + columnTitleValueTest(column7, "Column7"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5", "field6", "field7"); + dataSource.add("test1", "test2", "test3", "test4", "test5", "test6", "test7"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ExpressionColumnTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ExpressionColumnTest.java new file mode 100644 index 0000000..3135a3e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/ExpressionColumnTest.java @@ -0,0 +1,137 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.base.expression.AbstractValueFormatter; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; + +/** + * @author Ricardo Mariaca + */ +public class ExpressionColumnTest extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private FieldBuilder field1; + private TextColumnBuilder column2; + private TextColumnBuilder expression1; + private TextColumnBuilder calcExpression1; + private TextColumnBuilder calcExpression2; + private TextColumnBuilder calcExpression3; + private TextColumnBuilder calcExpression4; + private TextColumnBuilder calcExpression5; + private TextColumnBuilder calcExpression6; + private TextColumnBuilder calcExpression7; + private TextColumnBuilder calcExpression8; + private TextColumnBuilder expression2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setLocale(Locale.ENGLISH) + .fields(field1 = field("field1", Double.class)) + .columns(column2 = col.column("Column2", "field2", Double.class).setValueFormatter(new ColumnValueFormatter()), expression1 = col.column("Expression", new ValueExpression1()), + calcExpression1 = expression1.multiply(column2), calcExpression2 = calcExpression1.multiply(5), calcExpression3 = calcExpression2.subtract(calcExpression1), + calcExpression4 = calcExpression3.subtract(5), calcExpression5 = calcExpression4.add(calcExpression1), calcExpression6 = calcExpression5.add(5), + calcExpression7 = calcExpression6.divide(2, expression1), calcExpression8 = calcExpression7.divide(2, 3), expression2 = col.column("Expression", new ValueExpression2())); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + // column2 + columnDetailCountTest(column2, 3); + columnDetailValueTest(column2, "value = 4.0", "value = 5.0", "value = 6.0"); + // expression + columnDetailCountTest(expression1, 3); + columnDetailValueTest(expression1, "5.0", "7.0", "9.0"); + columnDetailCountTest(expression2, 3); + columnDetailValueTest(expression2, "11.67", "15.33", "19.0"); + // calcExpression + columnDetailCountTest(calcExpression1, 3); + columnDetailValueTest(calcExpression1, "20.00", "35.00", "54.00"); + columnDetailCountTest(calcExpression2, 3); + columnDetailValueTest(calcExpression2, "100.00", "175.00", "270.00"); + columnDetailCountTest(calcExpression3, 3); + columnDetailValueTest(calcExpression3, "80.00", "140.00", "216.00"); + columnDetailCountTest(calcExpression4, 3); + columnDetailValueTest(calcExpression4, "75.00", "135.00", "211.00"); + columnDetailCountTest(calcExpression5, 3); + columnDetailValueTest(calcExpression5, "95.00", "170.00", "265.00"); + columnDetailCountTest(calcExpression6, 3); + columnDetailValueTest(calcExpression6, "100.00", "175.00", "270.00"); + columnDetailCountTest(calcExpression7, 3); + columnDetailValueTest(calcExpression7, "20.00", "25.00", "30.00"); + columnDetailCountTest(calcExpression8, 3); + columnDetailValueTest(calcExpression8, "6.67", "8.33", "10.00"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + dataSource.add(1d, 4d); + dataSource.add(2d, 5d); + dataSource.add(3d, 6d); + return dataSource; + } + + private class ValueExpression1 extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Double evaluate(ReportParameters reportParameters) { + double f1 = reportParameters.getValue(field1); + double f2 = reportParameters.getValue(column2); + return f1 + f2; + } + } + + private class ValueExpression2 extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Double evaluate(ReportParameters reportParameters) { + double f1 = reportParameters.getValue(expression1); + double f2 = reportParameters.getValue(calcExpression8).doubleValue(); + return f1 + f2; + } + } + + private class ColumnValueFormatter extends AbstractValueFormatter { + private static final long serialVersionUID = 1L; + + @Override + public String format(Double value, ReportParameters reportParameters) { + return "value = " + value; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/PercentageColumnTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/PercentageColumnTest.java new file mode 100644 index 0000000..4c951df --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/column/PercentageColumnTest.java @@ -0,0 +1,90 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.column; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractValueFormatter; +import software.xdev.dynamicreports.report.builder.column.PercentageColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; + +/** + * @author Ricardo Mariaca + */ +public class PercentageColumnTest extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private PercentageColumnBuilder percentage1; + private PercentageColumnBuilder percentage2; + private PercentageColumnBuilder percentage3; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column2; + + rb.setLocale(Locale.ENGLISH) + .fields(field("field1", Integer.class)) + .columns(column2 = col.column("field2", Integer.class), percentage1 = col.percentageColumn("field1", Integer.class), percentage2 = col.percentageColumn(column2), + percentage3 = col.percentageColumn("field3", Integer.class).setValueFormatter(new ColumnValueFormatter())); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + // percentage1 + columnDetailCountTest(percentage1, 3); + columnDetailValueTest(percentage1, "16.67%", "33.33%", "50.00%"); + // percentage2 + columnDetailCountTest(percentage2, 3); + columnDetailValueTest(percentage2, "26.67%", "33.33%", "40.00%"); + // percentage3 + columnDetailCountTest(percentage3, 3); + columnDetailValueTest(percentage3, "value = 29.17%", "value = 33.33%", "value = 37.50%"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add(1, 4, 7); + dataSource.add(2, 5, 8); + dataSource.add(3, 6, 9); + return dataSource; + } + + private class ColumnValueFormatter extends AbstractValueFormatter { + private static final long serialVersionUID = 1L; + + @Override + public String format(Double value, ReportParameters reportParameters) { + return "value = " + new DecimalFormat("#,##0.00%", new DecimalFormatSymbols(Locale.ENGLISH)).format(value); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/BreakTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/BreakTest.java new file mode 100644 index 0000000..c810782 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/BreakTest.java @@ -0,0 +1,82 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.constant.Constants; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JREmptyDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class BreakTest extends AbstractJasperPositionTest implements Serializable { + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setPageColumnsPerPage(2) + .columns(col.componentColumn("Column1", + cmp.verticalList(cmp.text("value"), cmp.pageBreak().setPrintWhenExpression(new Expression1()), cmp.columnBreak().setPrintWhenExpression(new Expression2())))) + .title(cmp.text("text1"), cmp.pageBreak(), cmp.text("text1")); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(3); + + elementPositionTest("title.textField1", 0, 10, 10, 575, 16); + elementPositionTest("title.textField2", 0, 10, 10, 575, 16); + elementPositionTest("detail.textField1", 0, 10, 42, 287, 16); + elementPositionTest("detail.textField1", 1, 10, 26, 287, 16); + elementPositionTest("detail.textField1", 2, 297, 26, 287, 16); + } + + @Override + protected JRDataSource createDataSource() { + return new JREmptyDataSource(3); + } + + public class Expression1 extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + @Override + public Boolean evaluate(ReportParameters reportParameters) { + return reportParameters.getReportRowNumber() == 1; + } + } + + public class Expression2 extends AbstractSimpleExpression { + private static final long serialVersionUID = Constants.SERIAL_VERSION_UID; + + @Override + public Boolean evaluate(ReportParameters reportParameters) { + return reportParameters.getReportRowNumber() == 2; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Component1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Component1Test.java new file mode 100644 index 0000000..5c4c32c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Component1Test.java @@ -0,0 +1,97 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class Component1Test extends AbstractJasperValueTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setLocale(Locale.ENGLISH) + .columns(col.column("Column1", "field1", Integer.class)) + .pageFooter(cmp.pageXofY(), cmp.pageXslashY(), cmp.currentDate().setPattern("dd.MM.yyyy"), cmp.totalPages(), cmp.pageNumber(), cmp.totalPages().setFormatExpression("total pages {0}"), + cmp.pageNumber().setFormatExpression("page number {0}"), cmp.currentDate().setFormatExpression("current date {0}"), + cmp.currentDate().setFormatExpression("current date {0}").setPattern("dd.MM.yyyy")); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(3); + elementCountTest("pageFooter.textField1", 3); + elementValueTest("pageFooter.textField1", "1", "2", "3"); + + elementCountTest("pageFooter.textField2", 3); + elementValueTest("pageFooter.textField2", " of 3", " of 3", " of 3"); + + elementCountTest("pageFooter.textField3", 3); + elementValueTest("pageFooter.textField3", "1", "2", "3"); + + elementCountTest("pageFooter.textField4", 3); + elementValueTest("pageFooter.textField4", "/3", "/3", "/3"); + + elementCountTest("pageFooter.textField5", 3); + String date = new SimpleDateFormat("dd.MM.yyyy").format(new Date()); + elementValueTest("pageFooter.textField5", date, date, date); + + elementCountTest("pageFooter.textField6", 3); + elementValueTest("pageFooter.textField6", "3", "3", "3"); + + elementCountTest("pageFooter.textField7", 3); + elementValueTest("pageFooter.textField7", "1", "2", "3"); + + elementCountTest("pageFooter.textField8", 3); + elementValueTest("pageFooter.textField8", "total pages 3", "total pages 3", "total pages 3"); + + elementCountTest("pageFooter.textField9", 3); + elementValueTest("pageFooter.textField9", "page number 1", "page number 2", "page number 3"); + + elementCountTest("pageFooter.textField10", 3); + date = type.dateType().valueToString(new Date(), Locale.ENGLISH); + elementValueTest("pageFooter.textField10", "current date " + date, "current date " + date, "current date " + date); + + elementCountTest("pageFooter.textField11", 3); + date = new SimpleDateFormat("dd.MM.yyyy").format(new Date()); + elementValueTest("pageFooter.textField11", "current date " + date, "current date " + date, "current date " + date); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 100; i++) { + dataSource.add(i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Component2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Component2Test.java new file mode 100644 index 0000000..6ad9f1c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Component2Test.java @@ -0,0 +1,99 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.LineDirection; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRPrintLine; +import net.sf.jasperreports.engine.JRPrintRectangle; +import net.sf.jasperreports.engine.type.LineDirectionEnum; + + +/** + * @author Ricardo Mariaca + */ +public class Component2Test extends AbstractJasperPositionTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.title(cmp.horizontalList(cmp.line(), cmp.filler().setFixedWidth(10), cmp.line()), + cmp.horizontalList( + cmp.line().setFixedDimension(1, 50), + cmp.line().setDirection(LineDirection.TOP_DOWN), + cmp.line().setDirection(LineDirection.BOTTOM_UP)), + cmp.ellipse(), + cmp.rectangle(), + cmp.roundRectangle(), + cmp.roundRectangle(20), + cmp.verticalGap(30), + cmp.horizontalList(cmp.text(""), cmp.horizontalGap(10), cmp.text("")), + cmp.centerHorizontal(cmp.text("").setFixedWidth(50)), + cmp.centerHorizontal(cmp.text("").setFixedWidth(50)).setFixedWidth(250), + cmp.horizontalList(cmp.centerVertical(cmp.text("").setFixedRows(1)), cmp.text("").setFixedRows(3)), + cmp.centerVertical(cmp.text("").setFixedRows(1)).setFixedHeight(50)); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + this.elementPositionTest("title.line1", 0, 0, 0, 282, 1); + this.elementPositionTest("title.line2", 0, 292, 0, 283, 1); + this.elementPositionTest("title.line3", 0, 0, 0, 1, 50); + this.elementPositionTest("title.line4", 0, 1, 0, 287, 50); + this.elementPositionTest("title.line5", 0, 288, 0, 287, 50); + + JRPrintLine line = (JRPrintLine)this.getElementAt("title.line4", 0); + Assertions.assertEquals(LineDirectionEnum.TOP_DOWN, line.getDirectionValue()); + line = (JRPrintLine)this.getElementAt("title.line5", 0); + Assertions.assertEquals(LineDirectionEnum.BOTTOM_UP, line.getDirectionValue()); + + this.elementPositionTest("title.ellipse1", 0, 10, 61, 575, 100); + this.elementPositionTest("title.rectangle1", 0, 10, 161, 575, 100); + this.elementPositionTest("title.rectangle2", 0, 10, 261, 575, 100); + this.elementPositionTest("title.rectangle3", 0, 10, 361, 575, 100); + + JRPrintRectangle rectangle = (JRPrintRectangle)this.getElementAt("title.rectangle1", 0); + Assertions.assertEquals(0, rectangle.getRadius()); + rectangle = (JRPrintRectangle)this.getElementAt("title.rectangle2", 0); + Assertions.assertEquals(10, rectangle.getRadius()); + rectangle = (JRPrintRectangle)this.getElementAt("title.rectangle3", 0); + Assertions.assertEquals(20, rectangle.getRadius()); + + this.elementPositionTest("title.list4", 0, 10, 491, 575, 16); + this.elementPositionTest("title.textField1", 0, 0, 0, 282, 16); + this.elementPositionTest("title.textField2", 0, 292, 0, 283, 16); + + this.elementPositionTest("title.textField3", 0, 262, 0, 50, 16); + this.elementPositionTest("title.textField4", 0, 100, 0, 50, 16); + + this.elementPositionTest("title.textField5", 0, 0, 11, 287, 16); + this.elementPositionTest("title.textField6", 0, 287, 0, 288, 39); + this.elementPositionTest("title.textField7", 0, 10, 595, 575, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Component3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Component3Test.java new file mode 100644 index 0000000..967b90e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Component3Test.java @@ -0,0 +1,86 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.exp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.component.TextFieldBuilder; +import software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder; +import software.xdev.dynamicreports.report.constant.ComponentPositionType; +import software.xdev.dynamicreports.report.constant.StretchType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRElement; +import net.sf.jasperreports.engine.JREmptyDataSource; +import net.sf.jasperreports.engine.type.PositionTypeEnum; +import net.sf.jasperreports.engine.type.StretchTypeEnum; + + +/** + * @author Ricardo Mariaca + */ +public class Component3Test extends AbstractJasperTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + final CustomGroupBuilder group = grp.group("group1", exp.text("")); + + final TextFieldBuilder textField = cmp.text("") + .setPositionType(ComponentPositionType.FIX_RELATIVE_TO_TOP) + .setStretchType(StretchType.NO_STRETCH) + .setPrintInFirstWholeBand(true) + .setPrintWhenDetailOverflows(true) + .setPrintWhenGroupChanges(group); + rb.title(textField) + .columns(col.column("column1", type.stringType()).setPrintWhenDetailOverflows(true)) + .groupBy(group); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + JRElement textField = this.getJasperReport().getTitle().getElementByKey("title.textField1"); + Assertions.assertEquals(PositionTypeEnum.FIX_RELATIVE_TO_TOP, textField.getPositionTypeValue()); + Assertions.assertEquals(StretchTypeEnum.NO_STRETCH, textField.getStretchTypeValue()); + Assertions.assertTrue(textField.isPrintInFirstWholeBand()); + Assertions.assertTrue(textField.isPrintWhenDetailOverflows()); + Assertions.assertEquals("group1", textField.getPrintWhenGroupChanges().getName()); + + textField = this.getJasperReport().getDetailSection().getBands()[0].getElementByKey("detail.column_column11"); + Assertions.assertTrue(textField.isPrintWhenDetailOverflows()); + } + + @Override + protected JRDataSource createDataSource() + { + return new JREmptyDataSource(1); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ComponentStyleTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ComponentStyleTest.java new file mode 100644 index 0000000..037ab01 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ComponentStyleTest.java @@ -0,0 +1,76 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRPen; +import net.sf.jasperreports.engine.JRPrintEllipse; +import net.sf.jasperreports.engine.JRPrintLine; +import net.sf.jasperreports.engine.JRPrintRectangle; +import net.sf.jasperreports.engine.type.LineStyleEnum; + +import java.awt.Color; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class ComponentStyleTest extends AbstractJasperStyleTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + StyleBuilder style = stl.style().setLinePen(stl.penDotted()); + rb.title(cmp.line().setStyle(style), cmp.filler().setFixedHeight(10), cmp.line().setPen(stl.pen2Point()), cmp.ellipse().setStyle(style), cmp.ellipse().setPen(stl.pen2Point()), + cmp.rectangle().setStyle(style), cmp.rectangle().setPen(stl.pen2Point())); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + JRPrintLine line = (JRPrintLine) getElementAt("title.line1", 0); + penTest(line.getStyle().getLinePen(), 1f, null, LineStyleEnum.DOTTED); + + line = (JRPrintLine) getElementAt("title.line2", 0); + penTest(line.getLinePen(), 2f, Color.BLACK, LineStyleEnum.SOLID); + + JRPrintEllipse ellipse = (JRPrintEllipse) getElementAt("title.ellipse1", 0); + penTest(ellipse.getStyle().getLinePen(), 1f, null, LineStyleEnum.DOTTED); + ellipse = (JRPrintEllipse) getElementAt("title.ellipse2", 0); + penTest(ellipse.getLinePen(), 2f, Color.BLACK, LineStyleEnum.SOLID); + + JRPrintRectangle rectangle = (JRPrintRectangle) getElementAt("title.rectangle1", 0); + penTest(rectangle.getStyle().getLinePen(), 1f, null, LineStyleEnum.DOTTED); + rectangle = (JRPrintRectangle) getElementAt("title.rectangle2", 0); + penTest(rectangle.getLinePen(), 2f, Color.BLACK, LineStyleEnum.SOLID); + + } + + private void penTest(JRPen pen, Float width, Color color, LineStyleEnum style) { + Assertions.assertEquals(width, pen.getLineWidth()); + Assertions.assertEquals(color, pen.getLineColor()); + Assertions.assertEquals(style, pen.getLineStyleValue()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Image1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Image1Test.java new file mode 100644 index 0000000..2dd725a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Image1Test.java @@ -0,0 +1,105 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.Serializable; +import java.util.Arrays; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.ImageScale; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperTest; +import net.sf.jasperreports.engine.DefaultJasperReportsContext; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRPrintImage; +import net.sf.jasperreports.engine.type.ImageTypeEnum; +import net.sf.jasperreports.engine.type.ScaleImageEnum; +import net.sf.jasperreports.engine.util.JRImageLoader; +import net.sf.jasperreports.renderers.SimpleDataRenderer; + + +/** + * @author Ricardo Mariaca + */ +public class Image1Test extends AbstractJasperTest +{ + private Image image; + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL) + .setImageStyle(stl.style().setImageScale(ImageScale.CLIP)) + .title(cmp.image(this.image = new TestImage()), cmp.image(Image1Test.class.getResource("noimage"))); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + try + { + final byte[] imageData = JRImageLoader.getInstance(DefaultJasperReportsContext.getInstance()) + .loadBytesFromAwtImage(this.image, ImageTypeEnum.JPEG); + final JRPrintImage jrImage = (JRPrintImage)this.getElementAt("title.image1", 0); + Assertions.assertTrue(Arrays.equals( + imageData, + ((SimpleDataRenderer)jrImage.getRenderer()).getData(DefaultJasperReportsContext.getInstance()))); + Assertions.assertEquals(ScaleImageEnum.CLIP, jrImage.getScaleImageValue()); + } + catch(final JRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } + + @Override + protected boolean serializableTest() + { + return false; + } + + private class TestImage extends BufferedImage implements Serializable + { + private static final long serialVersionUID = 1L; + + public TestImage() + { + super(100, 100, BufferedImage.TYPE_INT_RGB); + final Graphics2D g2d = this.createGraphics(); + g2d.setColor(Color.BLUE); + g2d.setComposite(AlphaComposite.Src); + g2d.fill(new Rectangle2D.Float(5, 5, 90, 90)); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Image2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Image2Test.java new file mode 100644 index 0000000..0789a22 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/Image2Test.java @@ -0,0 +1,89 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +import java.util.Arrays; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.component.ImageBuilder; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.test.jasper.AbstractJasperTest; +import net.sf.jasperreports.engine.DefaultJasperReportsContext; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JREmptyDataSource; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRPrintImage; +import net.sf.jasperreports.engine.type.HorizontalImageAlignEnum; +import net.sf.jasperreports.renderers.SimpleDataRenderer; + + +/** + * @author Ricardo Mariaca + */ +class Image2Test extends AbstractJasperTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + final ImageBuilder image = cmp.image(Image2Test.class.getResourceAsStream("dynamicreports.png")) + .setHorizontalImageAlignment(HorizontalImageAlignment.CENTER); + rb.pageHeader(image).detail(cmp.filler().setFixedHeight(20)); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(2); + + try + { + JRPrintImage jrImage = (JRPrintImage)this.getElementAt("pageHeader.image1", 0); + final byte[] imageData1 = + ((SimpleDataRenderer)jrImage.getRenderer()).getData(DefaultJasperReportsContext.getInstance()); + jrImage = (JRPrintImage)this.getElementAt("pageHeader.image1", 1); + final byte[] imageData2 = + ((SimpleDataRenderer)jrImage.getRenderer()).getData(DefaultJasperReportsContext.getInstance()); + Assertions.assertTrue(Arrays.equals(imageData1, imageData2)); + Assertions.assertEquals(HorizontalImageAlignEnum.CENTER, jrImage.getHorizontalImageAlign()); + } + catch(final JRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } + + @Override + protected boolean serializableTest() + { + return false; + } + + @Override + protected JRDataSource createDataSource() + { + return new JREmptyDataSource(50); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/List1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/List1Test.java new file mode 100644 index 0000000..5113feb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/List1Test.java @@ -0,0 +1,195 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class List1Test extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + StyleBuilder style = stl.style().setPadding(10); + + rb.setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL) + .setTextStyle(stl.style().setPadding(1)) + .title(cmp.horizontalList() + .setBaseStyle(style) + .setBaseGap(2) + .setGap(5) + .add(cmp.verticalList() + .setStyle(style) + .add(cmp.vListCell(cmp.text("").setWidth(50)).heightFixed()) + .add(10, cmp.vListCell(cmp.text("").setWidth(50)).heightFixed(), cmp.vListCell(cmp.text("").setWidth(50)).heightFixed()) + .add(cmp.vListCell(cmp.text("").setWidth(50)).heightFixed()) + .add(cmp.filler()) + .add(cmp.vListCell(cmp.text("").setWidth(50)).heightFixed())) + .add(cmp.hListCell(cmp.verticalList() + .setStyle(stl.style().setPadding(stl.padding().setLeft(2).setRight(4).setTop(6).setBottom(8))) + .setGap(5) + .add(cmp.vListCell(cmp.text("").setWidth(10)).widthFixedOnCenter().heightFixed()) + .add(cmp.text(""), cmp.horizontalList().setStyle(style).add(cmp.text(""), cmp.text("")).add(5, cmp.text("").setWidth(50)), cmp.text("")) + .add(cmp.vListCell(cmp.horizontalList(cmp.text(""), cmp.text("")).setStyle(style)).widthFixedOnCenter().heightFixed())).widthFixed().heightFixedOnMiddle()) + .add(cmp.verticalList() + .setStyle(style) + .add(cmp.text("")) + .add(cmp.vListCell(cmp.text("").setHeight(30).setWidth(50)), cmp.vListCell(cmp.text("").setWidth(50)).heightFixed(), + cmp.vListCell(cmp.text("").setWidth(50)).widthFixedOnLeft().heightFixed(), cmp.vListCell(cmp.text("").setWidth(50)).widthFixedOnLeft(), + cmp.vListCell(cmp.text("").setWidth(50)).widthFixedOnCenter().heightFixed(), cmp.vListCell(cmp.text("").setWidth(50)).widthFixedOnCenter(), + cmp.vListCell(cmp.text("").setWidth(50)).widthFixedOnRight().heightFixed(), cmp.vListCell(cmp.text("").setWidth(50)).widthFixedOnRight())) + .add(cmp.text("").setWidth(20).setHeight(200)) + + .newRow(10) + .add(cmp.text("")) + + .newRow() + .add(cmp.hListCell(cmp.text("")).widthFixed().heightFixedOnMiddle()) + .add(cmp.filler()) + .add(cmp.filler()) + .add(cmp.hListCell(cmp.text("")).widthFixed().heightFixedOnMiddle()) + + .newRow() + .add(cmp.text("").setWidth(50).setHeight(50)) + .add(cmp.text("").setWidth(50)) + .add(cmp.hListCell(cmp.text("").setWidth(50)).widthFixed()) + .add(cmp.hListCell(cmp.text("").setWidth(50)).widthFixed().heightFixedOnTop()) + .add(cmp.hListCell(cmp.text("").setWidth(50)).heightFixedOnTop()) + .add(cmp.hListCell(cmp.verticalList(cmp.text("").setWidth(50), cmp.text("").setWidth(50)).setStyle(style)).widthFixed().heightFixedOnMiddle()) + .add(cmp.hListCell(cmp.text("").setWidth(50)).heightFixedOnMiddle()) + .add(cmp.hListCell(cmp.text("").setWidth(50)).widthFixed().heightFixedOnBottom()) + .add(cmp.hListCell(cmp.text("").setWidth(50)).heightFixedOnBottom()) + + .newFlowRow() + .setGap(5) + .setStyle(style) + .add(cmp.text(""), cmp.text(""), cmp.text(""), cmp.text(""), cmp.text(""), cmp.text("").setWidth(500), cmp.text(""), cmp.text("")) + .newRow() + .add(cmp.text(""), cmp.text(""), cmp.text("")) + .add(cmp.hListCell(cmp.text("")).widthFixed()) + .add(cmp.hListCell(cmp.text("")).widthExpand()) + .add(cmp.text(""), cmp.text(""), cmp.text("")) + .newRow() + .add(cmp.text("")) + .add(cmp.verticalList().add(cmp.vListCell(cmp.text("")).widthFixedOnCenter(), cmp.vListCell(cmp.text("")).widthFixedOnCenter())) + .add(cmp.text(""))); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + elementPositionTest("title.list1", 0, 10, 10, 575, 426); + + elementPositionTest("title.list2", 0, 0, 0, 555, 200); + elementPositionTest("title.list3", 0, 0, 0, 86, 200); + elementPositionTest("title.textField1", 0, 0, 0, 66, 14); + elementPositionTest("title.textField2", 0, 0, 24, 66, 14); + elementPositionTest("title.textField3", 0, 0, 48, 66, 14); + elementPositionTest("title.textField4", 0, 0, 62, 66, 14); + elementPositionTest("title.textField5", 0, 0, 166, 66, 14); + + elementPositionTest("title.list4", 0, 91, 28, 281, 144); + elementPositionTest("title.textField6", 0, 132, 0, 10, 14); + elementPositionTest("title.textField7", 0, 0, 19, 275, 14); + + elementPositionTest("title.list5", 0, 0, 38, 275, 34); + elementPositionTest("title.textField8", 0, 0, 0, 100, 14); + elementPositionTest("title.textField9", 0, 100, 0, 100, 14); + elementPositionTest("title.textField10", 0, 205, 0, 50, 14); + + elementPositionTest("title.textField11", 0, 0, 77, 275, 14); + + elementPositionTest("title.list6", 0, 27, 96, 220, 34); + elementPositionTest("title.textField12", 0, 0, 0, 100, 14); + elementPositionTest("title.textField13", 0, 100, 0, 100, 14); + + elementPositionTest("title.list7", 0, 377, 0, 148, 200); + elementPositionTest("title.textField14", 0, 0, 0, 128, 20); + elementPositionTest("title.textField15", 0, 0, 20, 128, 43); + elementPositionTest("title.textField16", 0, 0, 63, 128, 14); + elementPositionTest("title.textField17", 0, 0, 77, 50, 14); + elementPositionTest("title.textField18", 0, 0, 91, 50, 20); + elementPositionTest("title.textField19", 0, 39, 111, 50, 14); + elementPositionTest("title.textField20", 0, 39, 125, 50, 20); + elementPositionTest("title.textField21", 0, 78, 145, 50, 14); + elementPositionTest("title.textField22", 0, 78, 159, 50, 21); + + elementPositionTest("title.textField23", 0, 530, 0, 25, 200); + elementPositionTest("title.textField24", 0, 0, 214, 555, 14); + + elementPositionTest("title.list8", 0, 0, 230, 555, 14); + elementPositionTest("title.textField25", 0, 0, 0, 100, 14); + elementPositionTest("title.textField26", 0, 455, 0, 100, 14); + + elementPositionTest("title.list9", 0, 0, 246, 555, 50); + elementPositionTest("title.textField27", 0, 0, 0, 67, 50); + elementPositionTest("title.textField28", 0, 67, 0, 67, 50); + elementPositionTest("title.textField29", 0, 134, 0, 50, 50); + elementPositionTest("title.textField30", 0, 184, 0, 50, 14); + elementPositionTest("title.textField31", 0, 234, 0, 67, 14); + + elementPositionTest("title.list10", 0, 301, 1, 70, 48); + elementPositionTest("title.textField32", 0, 0, 0, 50, 14); + elementPositionTest("title.textField33", 0, 0, 14, 50, 14); + + elementPositionTest("title.textField34", 0, 371, 18, 67, 14); + elementPositionTest("title.textField35", 0, 438, 36, 50, 14); + elementPositionTest("title.textField36", 0, 488, 36, 67, 14); + + elementPositionTest("title.list11", 0, 0, 298, 555, 62); + // elementPositionTest("title.list12", 0, 0, 0, 535, 42); + elementPositionTest("title.list13", 0, 0, 0, 535, 14); + elementPositionTest("title.textField37", 0, 0, 0, 103, 14); + elementPositionTest("title.textField38", 0, 108, 0, 103, 14); + elementPositionTest("title.textField39", 0, 216, 0, 103, 14); + elementPositionTest("title.textField40", 0, 324, 0, 103, 14); + elementPositionTest("title.textField41", 0, 432, 0, 103, 14); + + elementPositionTest("title.textField42", 0, 0, 14, 535, 14); + + elementPositionTest("title.list14", 0, 0, 28, 535, 14); + elementPositionTest("title.textField43", 0, 0, 0, 265, 14); + elementPositionTest("title.textField44", 0, 270, 0, 265, 14); + + elementPositionTest("title.list15", 0, 0, 362, 555, 14); + elementPositionTest("title.textField45", 0, 0, 0, 59, 14); + elementPositionTest("title.textField46", 0, 59, 0, 59, 14); + elementPositionTest("title.textField47", 0, 118, 0, 59, 14); + elementPositionTest("title.textField48", 0, 177, 0, 100, 14); + elementPositionTest("title.textField49", 0, 277, 0, 100, 14); + elementPositionTest("title.textField50", 0, 377, 0, 59, 14); + elementPositionTest("title.textField51", 0, 436, 0, 59, 14); + elementPositionTest("title.textField52", 0, 495, 0, 60, 14); + + elementPositionTest("title.list16", 0, 0, 378, 555, 28); + elementPositionTest("title.textField53", 0, 0, 0, 227, 28); + // elementPositionTest("title.list17", 0, 227, 0, 100, 28); + elementPositionTest("title.textField54", 0, 227, 0, 100, 14); + elementPositionTest("title.textField55", 0, 227, 14, 100, 14); + elementPositionTest("title.textField56", 0, 327, 0, 228, 28); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/List2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/List2Test.java new file mode 100644 index 0000000..0c10d98 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/List2Test.java @@ -0,0 +1,75 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.component.VerticalListBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class List2Test extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + VerticalListBuilder list1 = cmp.verticalList(); + list1.add(cmp.text("")); + + VerticalListBuilder list2 = cmp.verticalList(); + list2.add(cmp.text("")); + list2.add(cmp.filler().setFixedWidth(500)); + + VerticalListBuilder list3 = cmp.verticalList(); + list3.add(cmp.text("")); + + VerticalListBuilder list4 = cmp.verticalList(); + list4.add(cmp.text("")); + list4.add(cmp.filler().setFixedWidth(50)); + + VerticalListBuilder list5 = cmp.verticalList(); + list5.add(cmp.text("")); + + VerticalListBuilder list6 = cmp.verticalList(); + list6.add(cmp.text("")); + list6.add(cmp.filler().setFixedWidth(200)); + list6.add(cmp.text("")); + list6.add(cmp.filler().setFixedWidth(500)); + + rb.title(cmp.horizontalList(list1, list2), cmp.horizontalList(list3, list4), cmp.horizontalList(list5, list6)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("title.textField1", 0, 0, 0, 75, 16); + elementPositionTest("title.textField2", 0, 75, 0, 500, 16); + + elementPositionTest("title.textField3", 0, 0, 0, 287, 16); + elementPositionTest("title.textField4", 0, 287, 0, 288, 16); + + elementPositionTest("title.textField5", 0, 0, 0, 75, 32); + elementPositionTest("title.textField6", 0, 75, 0, 500, 16); + elementPositionTest("title.textField7", 0, 75, 16, 500, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/List3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/List3Test.java new file mode 100644 index 0000000..81eb35b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/List3Test.java @@ -0,0 +1,128 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.component.HorizontalListBuilder; +import software.xdev.dynamicreports.report.builder.component.VerticalListBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class List3Test extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + VerticalListBuilder list1 = cmp.verticalList(); + list1.add(cmp.text("")); + list1.add(cmp.text("")); + list1.setFixedWidth(50); + + HorizontalListBuilder list2 = cmp.horizontalList(); + list2.add(cmp.text("")); + list2.add(cmp.text("")); + list2.setFixedWidth(150); + + VerticalListBuilder list3 = cmp.verticalList(); + list3.add(cmp.text("")); + list3.add(cmp.text("")); + list3.setFixedWidth(200); + + HorizontalListBuilder list4 = cmp.horizontalList(); + list4.add(cmp.text("")); + list4.add(cmp.text("")); + list4.setFixedWidth(500); + + VerticalListBuilder list5 = cmp.verticalList(); + list5.add(cmp.text("")); + list5.add(cmp.text("")); + list5.setFixedHeight(50); + + HorizontalListBuilder list6 = cmp.horizontalList(); + list6.add(cmp.text("")); + list6.add(cmp.text("")); + list6.setFixedHeight(40); + + HorizontalListBuilder list7 = cmp.horizontalList(); + list7.add(cmp.text("").setFixedWidth(30)); + list7.add(cmp.text("")); + list7.setFixedWidth(150); + + VerticalListBuilder list8 = cmp.verticalList(); + list8.add(cmp.text("").setFixedHeight(20)); + list8.add(cmp.text("")); + list8.setFixedHeight(50); + + VerticalListBuilder list9 = cmp.verticalList(); + list9.add(cmp.text("")); + list9.add(cmp.text("")); + list9.setFixedDimension(250, 40); + + HorizontalListBuilder list10 = cmp.horizontalList(); + list10.add(cmp.text("")); + list10.add(cmp.text("")); + list10.setFixedDimension(250, 40); + + rb.title(list1, list2, list3, list4, list5, list6, list7, list8, list9, list10); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("title.textField1", 0, 10, 10, 50, 16); + elementPositionTest("title.textField2", 0, 10, 26, 50, 16); + + elementPositionTest("title.list3", 0, 10, 42, 150, 16); + elementPositionTest("title.textField3", 0, 0, 0, 75, 16); + elementPositionTest("title.textField4", 0, 75, 0, 75, 16); + + elementPositionTest("title.textField5", 0, 10, 58, 200, 16); + elementPositionTest("title.textField6", 0, 10, 74, 200, 16); + + elementPositionTest("title.list5", 0, 10, 90, 500, 16); + elementPositionTest("title.textField7", 0, 0, 0, 250, 16); + elementPositionTest("title.textField8", 0, 250, 0, 250, 16); + + elementPositionTest("title.textField9", 0, 10, 106, 575, 25); + elementPositionTest("title.textField10", 0, 10, 131, 575, 25); + + elementPositionTest("title.list7", 0, 10, 156, 575, 40); + elementPositionTest("title.textField11", 0, 0, 0, 287, 40); + elementPositionTest("title.textField12", 0, 287, 0, 288, 40); + + elementPositionTest("title.list8", 0, 10, 196, 150, 16); + elementPositionTest("title.textField13", 0, 0, 0, 30, 16); + elementPositionTest("title.textField14", 0, 30, 0, 120, 16); + + elementPositionTest("title.textField15", 0, 10, 212, 575, 20); + elementPositionTest("title.textField16", 0, 10, 232, 575, 30); + + elementPositionTest("title.textField17", 0, 10, 262, 250, 20); + elementPositionTest("title.textField18", 0, 10, 282, 250, 20); + + elementPositionTest("title.list11", 0, 10, 302, 250, 40); + elementPositionTest("title.textField19", 0, 0, 0, 125, 40); + elementPositionTest("title.textField20", 0, 125, 0, 125, 40); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListBackgroundComponentTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListBackgroundComponentTest.java new file mode 100644 index 0000000..b510710 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListBackgroundComponentTest.java @@ -0,0 +1,102 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; +import static software.xdev.dynamicreports.report.builder.DynamicReports.template; + +import java.util.List; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.ReportTemplateBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.component.RectangleBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRPrintElement; + + +/** + * @author Ricardo Mariaca + */ +class ListBackgroundComponentTest extends AbstractJasperPositionTest +{ + private TextColumnBuilder column; + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + final RectangleBuilder background = cmp.rectangle(); + final ReportTemplateBuilder template = template().setDetailBackgroundComponent(background); + + rb.setTemplate(template) + .setTitleBackgroundComponent(background) + .setSummaryBackgroundComponent(background) + .title(cmp.text("title").setFixedHeight(300)) + .columns(this.column = col.column("field1", String.class)) + .summary(cmp.text("text\ntext"), + cmp.horizontalList(cmp.text("text"), + cmp.horizontalList(cmp.text("text"), cmp.text("text")).setBackgroundComponent(background), + cmp.text("text")), + cmp.verticalList(cmp.text("text"), cmp.text("text")) + .setStyle(stl.style(5)) + .setBackgroundComponent(background)); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + this.elementPositionTest("title.list1", 0, 10, 10, 575, 300); + this.elementPositionTest("title.list1.background", 0, 0, 0, 575, 300); + + this.columnDetailPositionTest(this.column, 0, 0, 0, 575, 16); + this.elementPositionTest("detail.list1", 0, 10, 310, 575, 16); + this.elementPositionTest("detail.list1.background", 0, 0, 0, 575, 16); + this.columnDetailPositionTest(this.column, 1, 0, 0, 575, 16); + this.elementPositionTest("detail.list1", 1, 10, 326, 575, 16); + this.elementPositionTest("detail.list1.background", 1, 0, 0, 575, 16); + + this.elementPositionTest("summary.list1", 0, 10, 342, 575, 84); + this.elementPositionTest("summary.list1.background", 0, 0, 0, 575, 84); + this.elementPositionTest("summary.list2", 0, 0, 26, 575, 16); + final List elements = this.findElement("summary.list2.background"); + Assertions.assertTrue(elements.isEmpty()); + this.elementPositionTest("summary.list3", 0, 143, 0, 288, 16); + this.elementPositionTest("summary.list3.background", 0, 0, 0, 288, 16); + this.elementPositionTest("summary.list4", 0, 0, 42, 575, 42); + this.elementPositionTest("summary.list4.background", 0, 0, 0, 565, 32); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add("value1"); + dataSource.add("value2"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListComponentGroupTypeTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListComponentGroupTypeTest.java new file mode 100644 index 0000000..8392f8a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListComponentGroupTypeTest.java @@ -0,0 +1,57 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class ListComponentGroupTypeTest extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setPageFormat(PageType.A8) + .setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL) + .title(cmp.text("title").setFixedHeight(130)) + .summary(cmp.text("text1"), cmp.text("text2"), cmp.horizontalList(cmp.verticalList(cmp.text("text3"), cmp.text("text4")), cmp.text("text5")), cmp.text("text6")) + .setSummarySplitType(SplitType.IMMEDIATE); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(2); + + elementPositionTest("summary.list2", 0, 10, 10, 128, 32); + + elementPositionTest("summary.textField1", 0, 10, 140, 128, 16); + elementPositionTest("summary.textField2", 0, 10, 156, 128, 16); + elementPositionTest("summary.textField3", 0, 0, 0, 64, 16); + elementPositionTest("summary.textField4", 0, 0, 16, 64, 16); + elementPositionTest("summary.textField5", 0, 64, 0, 64, 32); + elementPositionTest("summary.textField6", 0, 10, 42, 128, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListFixedComponents1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListFixedComponents1Test.java new file mode 100644 index 0000000..6e85101 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListFixedComponents1Test.java @@ -0,0 +1,46 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class ListFixedComponents1Test extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.title(cmp.horizontalList(cmp.text("").setFixedWidth(50), cmp.text("").setFixedWidth(100))); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("title.list1", 0, 10, 10, 150, 16); + + elementPositionTest("title.textField1", 0, 0, 0, 50, 16); + elementPositionTest("title.textField2", 0, 50, 0, 100, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListFixedComponents2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListFixedComponents2Test.java new file mode 100644 index 0000000..552cad2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListFixedComponents2Test.java @@ -0,0 +1,46 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class ListFixedComponents2Test extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.title(cmp.horizontalList(cmp.text("")).setFixedWidth(300).setBaseStyle(stl.style().setPadding(5))); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("title.list1", 0, 10, 10, 300, 26); + + elementPositionTest("title.textField1", 0, 0, 0, 290, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListGapTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListGapTest.java new file mode 100644 index 0000000..6f2b144 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/ListGapTest.java @@ -0,0 +1,48 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class ListGapTest extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setPageFormat(PageType.A5).setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL).title(cmp.horizontalList(cmp.text("a"), cmp.text("a")).setGap(250)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("title.list1", 0, 10, 10, 401, 16); + + elementPositionTest("title.textField1", 0, 0, 0, 75, 16); + elementPositionTest("title.textField2", 0, 325, 0, 76, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList1Test.java new file mode 100644 index 0000000..b7d48b1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList1Test.java @@ -0,0 +1,67 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.component.MultiPageListBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class MultiPageList1Test extends AbstractJasperValueTest { + private TextColumnBuilder column1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + MultiPageListBuilder multiPageList = cmp.multiPageList(); + for (int i = 0; i < 150; i++) { + multiPageList.add(cmp.text("text" + i)); + } + rb.title(multiPageList).columns(column1 = col.column("Column1", "field1", Integer.class)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(3); + + for (int i = 0; i < 150; i++) { + elementValueTest("title.textField1", i, "text" + i); + } + + columnTitleValueTest(column1, "Column1"); + columnDetailValueTest(column1, "0", "1"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 2; i++) { + dataSource.add(i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList2Test.java new file mode 100644 index 0000000..a386b9f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList2Test.java @@ -0,0 +1,78 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.component.MultiPageListBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class MultiPageList2Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + MultiPageListBuilder multiPageList1 = cmp.multiPageList(); + for (int i = 0; i < 3; i++) { + MultiPageListBuilder multiPageList2 = cmp.multiPageList(); + multiPageList1.add(multiPageList2); + for (int j = 0; j < 50; j++) { + multiPageList2.add(cmp.text("text")); + } + } + rb.title(multiPageList1).columns(column1 = col.column("Column1", "field1", Integer.class)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(3); + + for (int i = 0; i < 51; i++) { + elementPositionTest("title.textField1", i, 10, 10 + i * 16, 575, 16); + } + for (int i = 0; i < 51; i++) { + elementPositionTest("title.textField1", 51 + i, 10, 10 + i * 16, 575, 16); + } + for (int i = 0; i < 48; i++) { + elementPositionTest("title.textField1", 102 + i, 10, 10 + i * 16, 575, 16); + } + + columnTitlePositionTest(column1, 0, 10, 778, 575, 16); + columnDetailPositionTest(column1, 0, 10, 794, 575, 16); + columnDetailPositionTest(column1, 1, 10, 810, 575, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 2; i++) { + dataSource.add(i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList3Test.java new file mode 100644 index 0000000..741114a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList3Test.java @@ -0,0 +1,79 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.component.MultiPageListBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class MultiPageList3Test extends AbstractJasperValueTest { + private TextColumnBuilder column1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + column1 = col.column("Column1", "field1", type.integerType()); + + MultiPageListBuilder multiPageList = cmp.multiPageList(); + multiPageList.add(cmp.subreport(createSubreport(80))); + multiPageList.newPage(); + multiPageList.add(cmp.subreport(createSubreport(80))); + multiPageList.newPage(); + multiPageList.add(cmp.subreport(createSubreport(10))); + multiPageList.newPage(); + multiPageList.add(cmp.subreport(createSubreport(10))); + rb.title(multiPageList); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(4); + + columnDetailAtPageIndexTest(column1, 0); + columnDetailAtPageIndexTest(column1, 1); + columnDetailAtPageIndexTest(column1, 2); + columnDetailAtPageIndexTest(column1, 3); + } + + private JasperReportBuilder createSubreport(int numberOfRecords) { + JasperReportBuilder report = report(); + report.title(cmp.verticalGap(6)).setPageColumnsPerPage(2).columns(column1).setDataSource(createSubreportDataSource(numberOfRecords)); + + return report; + } + + protected JRDataSource createSubreportDataSource(int numberOfRecords) { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < numberOfRecords; i++) { + dataSource.add(i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList4Test.java new file mode 100644 index 0000000..f184ecd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/MultiPageList4Test.java @@ -0,0 +1,100 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.component.MultiPageListBuilder; +import software.xdev.dynamicreports.report.constant.SplitType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRPrintElement; +import net.sf.jasperreports.engine.JRPrintText; + + +/** + * @author Ricardo Mariaca + */ +public class MultiPageList4Test extends AbstractJasperValueTest +{ + private TextColumnBuilder column1; + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + this.column1 = col.column("Column1", "field1", type.stringType()); + + final MultiPageListBuilder multiPageList = cmp.multiPageList(); + multiPageList.setSplitType(SplitType.PREVENT); + multiPageList.add(cmp.subreport(this.createSubreport())); + multiPageList.add(cmp.verticalGap(730)); + multiPageList.add(cmp.subreport(this.createSubreport())); + rb.title(multiPageList); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(2); + + int count = 0; + for(final JRPrintElement element : this.getJasperPrint().getPages().get(0).getElements()) + { + if(element instanceof JRPrintText) + { + count++; + } + } + Assertions.assertEquals(3, count); + count = 0; + for(final JRPrintElement element : this.getJasperPrint().getPages().get(1).getElements()) + { + if(element instanceof JRPrintText) + { + count++; + } + } + Assertions.assertEquals(3, count); + } + + private JasperReportBuilder createSubreport() + { + final JasperReportBuilder report = report(); + report.columns(this.column1).setDataSource(this.createSubreportDataSource()); + + return report; + } + + protected JRDataSource createSubreportDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add("text"); + dataSource.add("text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber1Test.java new file mode 100644 index 0000000..a1c4c0a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber1Test.java @@ -0,0 +1,59 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class PageNumber1Test extends AbstractJasperValueTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL).pageFooter(cmp.pageNumber(), cmp.totalPages(), cmp.pageXslashY(), cmp.pageXofY()); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + elementCountTest("pageFooter.textField1", 1); + elementValueTest("pageFooter.textField1", "1"); + + elementCountTest("pageFooter.textField2", 1); + elementValueTest("pageFooter.textField2", "1"); + + elementCountTest("pageFooter.textField3", 1); + elementValueTest("pageFooter.textField3", "1"); + + elementCountTest("pageFooter.textField4", 1); + elementValueTest("pageFooter.textField4", "/1"); + + elementCountTest("pageFooter.textField5", 1); + elementValueTest("pageFooter.textField5", "1"); + + elementCountTest("pageFooter.textField6", 1); + elementValueTest("pageFooter.textField6", " of 1"); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber2Test.java new file mode 100644 index 0000000..d6f479b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber2Test.java @@ -0,0 +1,74 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class PageNumber2Test extends AbstractJasperValueTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columns(col.column("Column1", "field1", Integer.class)) + .summaryOnANewPage() + .summaryWithPageHeaderAndFooter() + .summary(cmp.text("summary")) + .pageFooter(cmp.pageNumber(), cmp.totalPages(), cmp.pageXslashY(), cmp.pageXofY()); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(2); + elementCountTest("pageFooter.textField1", 2); + elementValueTest("pageFooter.textField1", "1", "2"); + + elementCountTest("pageFooter.textField2", 2); + elementValueTest("pageFooter.textField2", "2", "2"); + + elementCountTest("pageFooter.textField3", 2); + elementValueTest("pageFooter.textField3", "1", "2"); + + elementCountTest("pageFooter.textField4", 2); + elementValueTest("pageFooter.textField4", "/2", "/2"); + + elementCountTest("pageFooter.textField5", 2); + elementValueTest("pageFooter.textField5", "1", "2"); + + elementCountTest("pageFooter.textField6", 2); + elementValueTest("pageFooter.textField6", " of 2", " of 2"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 10; i++) { + dataSource.add(i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber3Test.java new file mode 100644 index 0000000..c3d2896 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber3Test.java @@ -0,0 +1,138 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.component.SubreportBuilder; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JREmptyDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class PageNumber3Test extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(JasperReportBuilder rb) { + SubreportBuilder subreport = cmp.subreport(titleSubreport()).setDataSource(new SubreportDataSourceExpression()); + + rb.detail(subreport) + .pageFooter(cmp.pageNumber(), cmp.totalPages(), cmp.pageXslashY(), cmp.pageXofY(), cmp.pageXofY().setFormatExpression("Page {0} of {1}"), + cmp.pageXofY().setHorizontalTextAlignment(HorizontalTextAlignment.LEFT), cmp.pageXofY().setHorizontalTextAlignment(HorizontalTextAlignment.RIGHT), + cmp.pageXofY().setHorizontalTextAlignment(HorizontalTextAlignment.JUSTIFIED), cmp.pageXofY().setHorizontalTextAlignment(HorizontalTextAlignment.CENTER)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(3); + elementCountTest("pageFooter.textField1", 3); + elementValueTest("pageFooter.textField1", "1", "2", "3"); + + elementCountTest("pageFooter.textField2", 3); + elementValueTest("pageFooter.textField2", "3", "3", "3"); + + elementCountTest("pageFooter.textField3", 3); + elementValueTest("pageFooter.textField3", "1", "2", "3"); + + elementCountTest("pageFooter.textField4", 3); + elementValueTest("pageFooter.textField4", "/3", "/3", "/3"); + + elementCountTest("pageFooter.textField5", 3); + elementValueTest("pageFooter.textField5", "1", "2", "3"); + + elementCountTest("pageFooter.textField6", 3); + elementValueTest("pageFooter.textField6", " of 3", " of 3", " of 3"); + + elementCountTest("pageFooter.textField7", 3); + elementValueTest("pageFooter.textField7", "Page 1", "Page 2", "Page 3"); + + elementCountTest("pageFooter.textField8", 3); + elementValueTest("pageFooter.textField8", " of 3", " of 3", " of 3"); + + elementCountTest("pageFooter.textField9", 3); + elementValueTest("pageFooter.textField9", "1", "2", "3"); + + elementCountTest("pageFooter.textField10", 3); + elementValueTest("pageFooter.textField10", " of 3", " of 3", " of 3"); + + elementCountTest("pageFooter.textField11", 3); + elementValueTest("pageFooter.textField11", "1", "2", "3"); + + elementCountTest("pageFooter.textField12", 3); + elementValueTest("pageFooter.textField12", " of 3", " of 3", " of 3"); + + elementCountTest("pageFooter.textField13", 3); + elementValueTest("pageFooter.textField13", "1", "2", "3"); + + elementCountTest("pageFooter.textField14", 3); + elementValueTest("pageFooter.textField14", " of 3", " of 3", " of 3"); + + elementCountTest("pageFooter.textField15", 3); + elementValueTest("pageFooter.textField15", "1", "2", "3"); + + elementCountTest("pageFooter.textField16", 3); + elementValueTest("pageFooter.textField16", " of 3", " of 3", " of 3"); + } + + private JasperReportBuilder titleSubreport() { + JasperReportBuilder report = report(); + report.columns(col.column("Column1", "field1", type.integerType())).setDataSource(titleSubreportDataSource()); + return report; + } + + private JRDataSource titleSubreportDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 50; i++) { + dataSource.add(i); + } + return dataSource; + } + + @Override + protected JRDataSource createDataSource() { + return new JREmptyDataSource(2); + } + + private class SubreportDataSourceExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public JRDataSource evaluate(ReportParameters reportParameters) { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 50; i++) { + dataSource.add(i); + } + return dataSource; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber4Test.java new file mode 100644 index 0000000..0e5575d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber4Test.java @@ -0,0 +1,76 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; + +/** + * @author Ricardo Mariaca + */ +public class PageNumber4Test extends AbstractJasperValueTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setLocale(Locale.ENGLISH) + .columns(col.column("Column1", "field1", Integer.class)) + .groupBy(grp.group("field2", String.class)) + .pageFooter(cmp.pageXofY(), cmp.pageXslashY(), cmp.totalPages(), cmp.pageNumber()); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(3); + elementCountTest("pageFooter.textField1", 3); + elementValueTest("pageFooter.textField1", "1", "2", "3"); + + elementCountTest("pageFooter.textField2", 3); + elementValueTest("pageFooter.textField2", " of 3", " of 3", " of 3"); + + elementCountTest("pageFooter.textField3", 3); + elementValueTest("pageFooter.textField3", "1", "2", "3"); + + elementCountTest("pageFooter.textField4", 3); + elementValueTest("pageFooter.textField4", "/3", "/3", "/3"); + + elementCountTest("pageFooter.textField5", 3); + elementValueTest("pageFooter.textField5", "3", "3", "3"); + + elementCountTest("pageFooter.textField6", 3); + elementValueTest("pageFooter.textField6", "1", "2", "3"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 0; i < 100; i++) { + dataSource.add(i, "text" + (i < 50 ? "1" : "2")); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber5Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber5Test.java new file mode 100644 index 0000000..8028999 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber5Test.java @@ -0,0 +1,76 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; + +/** + * @author Ricardo Mariaca + */ +public class PageNumber5Test extends AbstractJasperValueTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setLocale(Locale.ENGLISH) + .columns(col.column("Column1", "field1", Integer.class)) + .groupBy(grp.group("field2", String.class).setResetPageNumber(true)) + .pageFooter(cmp.pageXofY(), cmp.pageXslashY(), cmp.totalPages(), cmp.pageNumber()); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(3); + elementCountTest("pageFooter.textField1", 3); + elementValueTest("pageFooter.textField1", "1", "2", "1"); + + elementCountTest("pageFooter.textField2", 3); + elementValueTest("pageFooter.textField2", " of 2", " of 2", " of 1"); + + elementCountTest("pageFooter.textField3", 3); + elementValueTest("pageFooter.textField3", "1", "2", "1"); + + elementCountTest("pageFooter.textField4", 3); + elementValueTest("pageFooter.textField4", "/2", "/2", "/1"); + + elementCountTest("pageFooter.textField5", 3); + elementValueTest("pageFooter.textField5", "2", "2", "1"); + + elementCountTest("pageFooter.textField6", 3); + elementValueTest("pageFooter.textField6", "1", "2", "1"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 0; i < 90; i++) { + dataSource.add(i, "text" + (i < 50 ? "1" : "2")); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber6Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber6Test.java new file mode 100644 index 0000000..5d126ee --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumber6Test.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.report.exception.DRException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; + +/** + * @author Ricardo Mariaca + */ +public class PageNumber6Test { + + @Test + public void test() { + try { + report().summary(cmp.pageXofY().setFormatExpression("{1} {0}")).toJasperPrint(); + Assertions.fail("Wrong page number"); + } catch (DRException e) { + } + + try { + report().summary(cmp.pageXofY().setFormatExpression("{1} {1}")).toJasperPrint(); + Assertions.fail("Wrong page number"); + } catch (DRException e) { + } + + try { + report().summary(cmp.pageXofY().setFormatExpression("{0} {0}")).toJasperPrint(); + Assertions.fail("Wrong page number"); + } catch (DRException e) { + } + + try { + report().summary(cmp.pageXofY().setFormatExpression("{0}")).toJasperPrint(); + Assertions.fail("Wrong page number"); + } catch (DRException e) { + } + + try { + report().summary(cmp.pageXofY().setFormatExpression("{1}")).toJasperPrint(); + Assertions.fail("Wrong page number"); + } catch (DRException e) { + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumberPositionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumberPositionTest.java new file mode 100644 index 0000000..eda3996 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/PageNumberPositionTest.java @@ -0,0 +1,95 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.component.PageXofYBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class PageNumberPositionTest extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + StyleBuilder style = stl.style().setHorizontalTextAlignment(HorizontalTextAlignment.LEFT); + PageXofYBuilder pageXofYLeft = cmp.pageXofY().setStyle(stl.style(style)); + PageXofYBuilder pageXofYRight = cmp.pageXofY().setStyle(stl.style(style).setHorizontalTextAlignment(HorizontalTextAlignment.RIGHT)); + + rb.setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL) + .pageFooter(cmp.pageXofY(), cmp.pageXofY().setHorizontalTextAlignment(HorizontalTextAlignment.LEFT), cmp.pageXofY().setHorizontalTextAlignment(HorizontalTextAlignment.RIGHT), + cmp.pageXofY().setHorizontalTextAlignment(HorizontalTextAlignment.JUSTIFIED), cmp.pageXofY().setHorizontalTextAlignment(HorizontalTextAlignment.CENTER), + cmp.horizontalList(pageXofYLeft, pageXofYRight, pageXofYLeft, pageXofYRight), cmp.pageXofY().setPageXFixedWidth(20), cmp.pageXofY().setPageYFixedWidth(25), + cmp.pageXslashY().setPageXFixedWidth(30), cmp.pageXslashY().setPageYFixedWidth(35), cmp.pageXofY().setPageXFixedWidth(18).setPageYFixedWidth(22)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + elementPositionTest("pageFooter.textField1", 0, 0, 0, 287, 16); + elementPositionTest("pageFooter.textField2", 0, 287, 0, 288, 16); + + elementPositionTest("pageFooter.textField3", 0, 0, 0, 40, 16); + elementPositionTest("pageFooter.textField4", 0, 40, 0, 535, 16); + + elementPositionTest("pageFooter.textField5", 0, 0, 0, 517, 16); + elementPositionTest("pageFooter.textField6", 0, 517, 0, 58, 16); + + elementPositionTest("pageFooter.textField7", 0, 0, 0, 287, 16); + elementPositionTest("pageFooter.textField8", 0, 287, 0, 288, 16); + + elementPositionTest("pageFooter.textField9", 0, 0, 0, 287, 16); + elementPositionTest("pageFooter.textField10", 0, 287, 0, 288, 16); + + elementPositionTest("pageFooter.textField11", 0, 0, 0, 36, 12); + elementPositionTest("pageFooter.textField12", 0, 36, 0, 107, 12); + + elementPositionTest("pageFooter.textField13", 0, 0, 0, 90, 12); + elementPositionTest("pageFooter.textField14", 0, 90, 0, 54, 12); + + elementPositionTest("pageFooter.textField15", 0, 0, 0, 36, 12); + elementPositionTest("pageFooter.textField16", 0, 36, 0, 108, 12); + + elementPositionTest("pageFooter.textField17", 0, 0, 0, 90, 12); + elementPositionTest("pageFooter.textField18", 0, 90, 0, 54, 12); + + elementPositionTest("pageFooter.textField19", 0, 0, 0, 20, 16); + elementPositionTest("pageFooter.textField20", 0, 20, 0, 555, 16); + + elementPositionTest("pageFooter.textField21", 0, 0, 0, 550, 16); + elementPositionTest("pageFooter.textField22", 0, 550, 0, 25, 16); + + elementPositionTest("pageFooter.textField23", 0, 0, 0, 30, 16); + elementPositionTest("pageFooter.textField24", 0, 30, 0, 545, 16); + + elementPositionTest("pageFooter.textField25", 0, 0, 0, 540, 16); + elementPositionTest("pageFooter.textField26", 0, 540, 0, 35, 16); + + elementPositionTest("pageFooter.textField27", 0, 0, 0, 18, 16); + elementPositionTest("pageFooter.textField28", 0, 18, 0, 22, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField1Test.java new file mode 100644 index 0000000..5f3dd63 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField1Test.java @@ -0,0 +1,76 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class TextField1Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columns(column1 = col.column("Column1", "field1", Integer.class), column2 = col.column("Column2", "field2", Integer.class).setColumns(20), + column3 = col.column("Column3", "field3", Integer.class).setRows(2)) + .subtotalsAtSummary(subtotal1 = sbt.sum(column2)) + .title(cmp.horizontalList(cmp.hListCell(cmp.text("").setColumns(10).setRows(5)).widthFixed())); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("title.textField1", 0, 10, 10, 94, 62); + + columnTitlePositionTest(column1, 0, 0, 0, 149, 16); + columnDetailPositionTest(column1, 0, 0, 0, 149, 27); + + columnTitlePositionTest(column2, 0, 149, 0, 276, 16); + columnDetailPositionTest(column2, 0, 149, 0, 276, 27); + + columnTitlePositionTest(column3, 0, 425, 0, 150, 16); + columnDetailPositionTest(column3, 0, 425, 0, 150, 27); + + subtotalPositionTest(subtotal1, 0, 149, 0, 276, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + for (int i = 0; i < 10; i++) { + dataSource.add(i, i, i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField2Test.java new file mode 100644 index 0000000..a68ca04 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField2Test.java @@ -0,0 +1,60 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class TextField2Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columns(column1 = col.column("test test", "field1", String.class).setFixedWidth(25).setStretchWithOverflow(false).setTitleStretchWithOverflow(false)) + .title(cmp.text("test test").setFixedWidth(25).setStretchWithOverflow(false), cmp.text("test test").setFixedWidth(25)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("title.textField1", 0, 10, 10, 25, 16); + elementPositionTest("title.textField2", 0, 10, 26, 25, 26); + + columnTitlePositionTest(column1, 0, 10, 52, 25, 16); + columnDetailPositionTest(column1, 0, 10, 68, 25, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add("test test"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField3Test.java new file mode 100644 index 0000000..efb700d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField3Test.java @@ -0,0 +1,73 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.jasper.constant.JasperProperty; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class TextField3Test extends AbstractJasperValueTest { + private TextColumnBuilder column1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columns(column1 = col.column("test test", "field1", String.class) + .setFixedWidth(25) + .setStretchWithOverflow(false) + .addProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true") + .setTitleStretchWithOverflow(false) + .addTitleProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true")) + .title(cmp.text("test test").setFixedWidth(25).setStretchWithOverflow(false).addProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true"), cmp.text("test test").setFixedWidth(25), + cmp.text("test test").setFixedWidth(25).setStretchWithOverflow(false)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementValueTest("title.textField1", 0, "test "); + elementFullValueTest("title.textField1", 0, "test test"); + elementValueTest("title.textField2", 0, "test test"); + elementValueTest("title.textField3", 0, "test "); + elementFullValueTest("title.textField3", 0, "test "); + + columnTitleValueTest(column1, 0, "test "); + columnTitleFullValueTest(column1, 0, "test test"); + + columnDetailValueTest(column1, 0, "test "); + columnDetailFullValueTest(column1, 0, "test test"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add("test test"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField4Test.java new file mode 100644 index 0000000..d3380fa --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField4Test.java @@ -0,0 +1,77 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.VariableBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.Evaluation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; +import static software.xdev.dynamicreports.report.builder.DynamicReports.variable; + +/** + * @author Ricardo Mariaca + */ +public class TextField4Test extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", type.integerType()); + VariableBuilder variable1 = variable("variable1", column1, Calculation.SUM); + + rb.columns(column1).variables(variable1).title(cmp.text(new TextExpression()).setEvaluationTime(Evaluation.REPORT)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementValueTest("title.textField1", 0, "sum = 14"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add(5); + dataSource.add(9); + return dataSource; + } + + private class TextExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public String evaluate(ReportParameters reportParameters) { + return "sum = " + reportParameters.getValue("variable1"); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField5Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField5Test.java new file mode 100644 index 0000000..4b5fc38 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField5Test.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class TextField5Test extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.detail(cmp.horizontalList(cmp.text(field("field1", type.stringType())).setPrintRepeatedValues(false).setPrintInFirstWholeBand(true), cmp.text(field("field2", type.integerType())))); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(2); + // textField1 + elementCountTest("detail.textField1", 3); + elementValueTest("detail.textField1", "test1", "test2", "test2"); + // textField2 + elementCountTest("detail.textField2", 60); + elementValueTest("detail.textField2", 0, "0"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 0; i < 30; i++) { + dataSource.add("test1", i); + } + for (int i = 0; i < 30; i++) { + dataSource.add("test2", i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField6Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField6Test.java new file mode 100644 index 0000000..03ae521 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField6Test.java @@ -0,0 +1,65 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * @author Jan Moxter + */ +public class TextField6Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + + @Override + protected void configureReport(final JasperReportBuilder rb) { + rb.columns(column1 = col.column("test test", "field1", String.class) + .setFixedWidth(25) + .setTextAdjust(TextAdjust.CUT_TEXT) + .setTitleTextAdjust(TextAdjust.CUT_TEXT)) + .title(cmp.text("test test").setFixedWidth(25) + .setTextAdjust(TextAdjust.CUT_TEXT), cmp.text("test test").setFixedWidth(25)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("title.textField1", 0, 10, 10, 25, 16); + elementPositionTest("title.textField2", 0, 10, 26, 25, 26); + + columnTitlePositionTest(column1, 0, 10, 52, 25, 16); + columnDetailPositionTest(column1, 0, 10, 68, 25, 16); + } + + @Override + protected JRDataSource createDataSource() { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add("test test"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField7Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField7Test.java new file mode 100644 index 0000000..939a062 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/TextField7Test.java @@ -0,0 +1,80 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.jasper.constant.JasperProperty; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * @author Jan Moxter + */ +public class TextField7Test extends AbstractJasperValueTest { + private TextColumnBuilder column1; + + @Override + protected void configureReport(final JasperReportBuilder rb) { + rb.columns(column1 = col.column("test test", "field1", String.class) + .setFixedWidth(25) + .setTextAdjust(TextAdjust.CUT_TEXT) + .addProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true") + .setTitleTextAdjust(TextAdjust.CUT_TEXT) + .addTitleProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true")) + .title(cmp.text("test test") + .setFixedWidth(25) + .setTextAdjust(TextAdjust.CUT_TEXT) + .addProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true"), cmp.text("test test") + .setFixedWidth(25), + cmp.text("test test") + .setFixedWidth(25) + .setTextAdjust(TextAdjust.CUT_TEXT)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementValueTest("title.textField1", 0, "test "); + elementFullValueTest("title.textField1", 0, "test test"); + elementValueTest("title.textField2", 0, "test test"); + elementValueTest("title.textField3", 0, "test "); + elementFullValueTest("title.textField3", 0, "test "); + + columnTitleValueTest(column1, 0, "test "); + columnTitleFullValueTest(column1, 0, "test test"); + + columnDetailValueTest(column1, 0, "test "); + columnDetailFullValueTest(column1, 0, "test test"); + } + + @Override + protected JRDataSource createDataSource() { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add("test test"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/VerticalListTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/VerticalListTest.java new file mode 100644 index 0000000..2f29e68 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/VerticalListTest.java @@ -0,0 +1,58 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class VerticalListTest extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setPageFormat(PageType.A8) + .setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL) + .title(cmp.text("text"), cmp.text("text text text text text text text"), + cmp.horizontalList(cmp.verticalList(cmp.text("text"), cmp.text("text text text text text text"), cmp.text("text")), cmp.text("text")), cmp.text("text")); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // elementPositionTest("title.list1", 0, 10, 10, 128, 116); + elementPositionTest("title.list2", 0, 10, 52, 128, 58); + // elementPositionTest("title.list3", 0, 0, 0, 64, 58); + + elementPositionTest("title.textField1", 0, 10, 10, 128, 16); + elementPositionTest("title.textField2", 0, 10, 26, 128, 26); + elementPositionTest("title.textField3", 0, 0, 0, 64, 16); + elementPositionTest("title.textField4", 0, 0, 16, 64, 26); + elementPositionTest("title.textField5", 0, 0, 42, 64, 16); + elementPositionTest("title.textField6", 0, 64, 0, 64, 58); + elementPositionTest("title.textField7", 0, 10, 110, 128, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/XyListTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/XyListTest.java new file mode 100644 index 0000000..58d0fd3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/component/XyListTest.java @@ -0,0 +1,88 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.component; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.component.XyListBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class XyListTest extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + StyleBuilder style = stl.style(stl.pen1Point()); + + XyListBuilder list1 = cmp.xyList(); + list1.add(10, 10, cmp.text("")); + list1.add(50, 15, cmp.text("")); + + XyListBuilder list2 = cmp.xyList().setStyle(style); + list2.add(10, 10, cmp.text("")); + list2.add(50, 15, cmp.text("")); + list2.add(200, 5, cmp.horizontalList(cmp.text(""), cmp.text("")).setWidth(100)); + list2.add(350, 5, cmp.verticalList(cmp.text(""), cmp.text("")).setWidth(150)); + + XyListBuilder list3 = cmp.xyList(); + list3.add(10, 10, cmp.horizontalList(cmp.text("").setWidth(50), cmp.text("")).newRow().add(cmp.text(""))); + list3.add(200, 10, cmp.xyList().add(5, 5, cmp.horizontalList(cmp.text(""), cmp.text("")))); + + XyListBuilder list4 = cmp.xyList().setStyle(style).setFixedWidth(250); + list4.add(100, 10, cmp.xyList().setStyle(style).add(5, 5, cmp.verticalList(cmp.text(""), cmp.text("")))); + + rb.title(list1, list2, list3, list4); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("title.textField1", 0, 20, 20, 100, 16); + elementPositionTest("title.textField2", 0, 60, 25, 100, 16); + + elementPositionTest("title.list3", 0, 10, 41, 575, 37); + elementPositionTest("title.textField3", 0, 10, 10, 100, 16); + elementPositionTest("title.textField4", 0, 50, 15, 100, 16); + elementPositionTest("title.list4", 0, 200, 5, 100, 16); + elementPositionTest("title.textField5", 0, 0, 0, 50, 16); + elementPositionTest("title.textField6", 0, 50, 0, 50, 16); + elementPositionTest("title.textField7", 0, 350, 5, 150, 16); + elementPositionTest("title.textField8", 0, 350, 21, 150, 16); + + elementPositionTest("title.list8", 0, 20, 88, 150, 16); + elementPositionTest("title.textField9", 0, 0, 0, 50, 16); + elementPositionTest("title.textField10", 0, 50, 0, 100, 16); + elementPositionTest("title.textField11", 0, 20, 104, 150, 16); + elementPositionTest("title.list9", 0, 215, 93, 200, 16); + elementPositionTest("title.textField12", 0, 0, 0, 100, 16); + elementPositionTest("title.textField13", 0, 100, 0, 100, 16); + + elementPositionTest("title.list10", 0, 10, 120, 250, 47); + elementPositionTest("title.list11", 0, 100, 10, 105, 37); + elementPositionTest("title.textField14", 0, 5, 5, 100, 16); + elementPositionTest("title.textField15", 0, 5, 21, 100, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab1Test.java new file mode 100644 index 0000000..f21133f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab1Test.java @@ -0,0 +1,191 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class Crosstab1Test extends AbstractJasperCrosstabValueTest { + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + private CrosstabMeasureBuilder measure3; + private CrosstabMeasureBuilder measure4; + private CrosstabMeasureBuilder measure5; + private CrosstabMeasureBuilder measure6; + private CrosstabMeasureBuilder measure7; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + TextColumnBuilder column3 = col.column("Column3", "field3", Integer.class); + TextColumnBuilder column4 = col.column("Column4", "field4", Double.class); + TextColumnBuilder column5 = col.column("Column5", "field5", String.class); + + measure1 = ctab.measure(column3, Calculation.SUM); + measure2 = ctab.measure(column3, Calculation.SUM); + measure2.setPercentageType(CrosstabPercentageType.GRAND_TOTAL); + measure3 = ctab.measure(column4, Calculation.SUM); + measure4 = ctab.measure(column4, Calculation.SUM); + measure4.setPercentageType(CrosstabPercentageType.GRAND_TOTAL); + measure5 = ctab.measure(column5, Calculation.COUNT); + measure6 = ctab.measure(column5, Calculation.COUNT); + measure6.setPercentageType(CrosstabPercentageType.GRAND_TOTAL); + measure7 = ctab.measure(column4, Calculation.AVERAGE); + + CrosstabBuilder crosstab = ctab.crosstab() + .headerCell(cmp.text("Header")) + .rowGroups(rowGroup = ctab.rowGroup(column1).setTotalHeader("Total for rowgroup")) + .columnGroups(columnGroup = ctab.columnGroup(column2)) + .measures(measure1, measure2, measure3, measure4, measure5, measure6, measure7); + + rb.setLocale(Locale.ENGLISH).columns(column1, column2, column3, column4, column5).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + crosstabHeaderElementCountTest("textField1", 1); + crosstabHeaderElementValueTest("textField1", "Header"); + + // column group + crosstabGroupHeaderCountTest(columnGroup, 2); + crosstabGroupHeaderValueTest(columnGroup, "c", "d"); + crosstabGroupTotalHeaderCountTest(columnGroup, 1); + crosstabGroupTotalHeaderValueTest(columnGroup, "Total"); + + // row group + crosstabGroupHeaderCountTest(rowGroup, 3); + crosstabGroupHeaderValueTest(rowGroup, "a", "b", "c"); + crosstabGroupTotalHeaderCountTest(rowGroup, 1); + crosstabGroupTotalHeaderValueTest(rowGroup, "Total for rowgroup"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 6); + crosstabCellValueTest(measure1, null, null, "358", "768", "1,193", "1,602", "1,193", "1,602"); + crosstabCellCountTest(measure1, null, columnGroup, 3); + crosstabCellValueTest(measure1, null, columnGroup, "1,126", "2,795", "2,795"); + crosstabCellCountTest(measure1, rowGroup, null, 2); + crosstabCellValueTest(measure1, rowGroup, null, "2,744", "3,972"); + crosstabCellCountTest(measure1, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure1, rowGroup, columnGroup, "6,716"); + + // measure2 + crosstabCellCountTest(measure2, null, null, 6); + crosstabCellValueTest(measure2, null, null, "5.3", "11.4", "17.8", "23.9", "17.8", "23.9"); + crosstabCellCountTest(measure2, null, columnGroup, 3); + crosstabCellValueTest(measure2, null, columnGroup, "16.8", "41.6", "41.6"); + crosstabCellCountTest(measure2, rowGroup, null, 2); + crosstabCellValueTest(measure2, rowGroup, null, "40.9", "59.1"); + crosstabCellCountTest(measure2, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure2, rowGroup, columnGroup, "100"); + + // measure3 + crosstabCellCountTest(measure3, null, null, 6); + crosstabCellValueTest(measure3, null, null, "5", "9", "13", "17", "13", "17"); + crosstabCellCountTest(measure3, null, columnGroup, 3); + crosstabCellValueTest(measure3, null, columnGroup, "14", "30", "30"); + crosstabCellCountTest(measure3, rowGroup, null, 2); + crosstabCellValueTest(measure3, rowGroup, null, "31", "43"); + crosstabCellCountTest(measure3, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure3, rowGroup, columnGroup, "74"); + + // measure4 + crosstabCellCountTest(measure4, null, null, 6); + crosstabCellValueTest(measure4, null, null, "6.8", "12.2", "17.6", "23", "17.6", "23"); + crosstabCellCountTest(measure4, null, columnGroup, 3); + crosstabCellValueTest(measure4, null, columnGroup, "18.9", "40.5", "40.5"); + crosstabCellCountTest(measure4, rowGroup, null, 2); + crosstabCellValueTest(measure4, rowGroup, null, "41.9", "58.1"); + crosstabCellCountTest(measure4, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure4, rowGroup, columnGroup, "100"); + + // measure5 + crosstabCellCountTest(measure5, null, null, 6); + crosstabCellValueTest(measure5, null, null, "2", "2", "2", "2", "2", "2"); + crosstabCellCountTest(measure5, null, columnGroup, 3); + crosstabCellValueTest(measure5, null, columnGroup, "4", "4", "4"); + crosstabCellCountTest(measure5, rowGroup, null, 2); + crosstabCellValueTest(measure5, rowGroup, null, "6", "6"); + crosstabCellCountTest(measure5, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure5, rowGroup, columnGroup, "12"); + + // measure6 + crosstabCellCountTest(measure6, null, null, 6); + crosstabCellValueTest(measure6, null, null, "16", "16", "16", "16", "16", "16"); + crosstabCellCountTest(measure6, null, columnGroup, 3); + crosstabCellValueTest(measure6, null, columnGroup, "33", "33", "33"); + crosstabCellCountTest(measure6, rowGroup, null, 2); + crosstabCellValueTest(measure6, rowGroup, null, "50", "50"); + crosstabCellCountTest(measure6, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure6, rowGroup, columnGroup, "100"); + + // measure7 + crosstabCellCountTest(measure7, null, null, 6); + crosstabCellValueTest(measure7, null, null, "2.5", "4.5", "6.5", "8.5", "6.5", "8.5"); + crosstabCellCountTest(measure7, null, columnGroup, 3); + crosstabCellValueTest(measure7, null, columnGroup, "3.5", "7.5", "7.5"); + crosstabCellCountTest(measure7, rowGroup, null, 2); + crosstabCellValueTest(measure7, rowGroup, null, "5.2", "7.2"); + crosstabCellCountTest(measure7, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure7, rowGroup, columnGroup, "6.2"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5"); + dataSource.add("a", "c", 106, 2d, "1"); + dataSource.add("a", "c", 252, 3d, "1"); + dataSource.add("a", "d", 312, 4d, "1"); + dataSource.add("a", "d", 456, 5d, "4"); + dataSource.add("b", "c", 515, 6d, "5"); + dataSource.add("b", "c", 678, 7d, "6"); + dataSource.add("b", "d", 779, 8d, "7"); + dataSource.add("b", "d", 823, 9d, "8"); + dataSource.add("c", "c", 515, 6d, "5"); + dataSource.add("c", "c", 678, 7d, "6"); + dataSource.add("c", "d", 779, 8d, "7"); + dataSource.add("c", "d", 823, 9d, "8"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab2Test.java new file mode 100644 index 0000000..f31bee3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab2Test.java @@ -0,0 +1,153 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class Crosstab2Test extends AbstractJasperCrosstabValueTest { + private CrosstabRowGroupBuilder rowGroup1; + private CrosstabRowGroupBuilder rowGroup2; + private CrosstabColumnGroupBuilder columnGroup1; + private CrosstabColumnGroupBuilder columnGroup2; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + TextColumnBuilder column3 = col.column("Column3", "field3", String.class); + TextColumnBuilder column4 = col.column("Column4", "field4", String.class); + TextColumnBuilder column5 = col.column("Column5", "field5", Integer.class); + + measure1 = ctab.measure("measure1", column5, Calculation.SUM); + measure2 = ctab.measure("measure2", column5, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab() + .headerCell(cmp.text("Header")) + .setCellWidth(20) + .rowGroups(rowGroup1 = ctab.rowGroup(column1), rowGroup2 = ctab.rowGroup(column2)) + .columnGroups(columnGroup1 = ctab.columnGroup(column3), columnGroup2 = ctab.columnGroup(column4)) + .measures(measure1, measure2); + + rb.setLocale(Locale.ENGLISH).setPageFormat(PageType.A3, PageOrientation.LANDSCAPE).columns(column1, column2, column3, column4, column5).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + crosstabHeaderElementCountTest("textField1", 1); + crosstabHeaderElementValueTest("textField1", "Header"); + + // column group + crosstabGroupHeaderCountTest(columnGroup1, 2); + crosstabGroupHeaderValueTest(columnGroup1, "g", "h"); + crosstabGroupTotalHeaderCountTest(columnGroup1, 1); + crosstabGroupTotalHeaderValueTest(columnGroup1, "Total"); + crosstabGroupHeaderCountTest(columnGroup2, 4); + crosstabGroupHeaderValueTest(columnGroup2, "i", "j", "k", "l"); + crosstabGroupTotalHeaderCountTest(columnGroup2, 2); + crosstabGroupTotalHeaderValueTest(columnGroup2, "Total", "Total"); + + // column group title + crosstabGroupTitleHeaderCountTest(columnGroup1, measure1, 0); + crosstabGroupTitleTotalHeaderCountTest(columnGroup1, measure1, 1); + crosstabGroupTitleTotalHeaderValueTest(columnGroup1, measure1, "measure1"); + crosstabGroupTitleHeaderCountTest(columnGroup2, measure1, 4); + crosstabGroupTitleHeaderValueTest(columnGroup2, measure1, "measure1", "measure1", "measure1", "measure1"); + crosstabGroupTitleTotalHeaderCountTest(columnGroup2, measure1, 2); + crosstabGroupTitleTotalHeaderValueTest(columnGroup2, measure1, "measure1", "measure1"); + + crosstabGroupTitleHeaderCountTest(columnGroup1, measure2, 0); + crosstabGroupTitleTotalHeaderCountTest(columnGroup1, measure2, 1); + crosstabGroupTitleTotalHeaderValueTest(columnGroup1, measure2, "measure2"); + crosstabGroupTitleHeaderCountTest(columnGroup2, measure2, 4); + crosstabGroupTitleHeaderValueTest(columnGroup2, measure2, "measure2", "measure2", "measure2", "measure2"); + crosstabGroupTitleTotalHeaderCountTest(columnGroup2, measure2, 2); + crosstabGroupTitleTotalHeaderValueTest(columnGroup2, measure2, "measure2", "measure2"); + + // row group + crosstabGroupHeaderCountTest(rowGroup1, 2); + crosstabGroupHeaderValueTest(rowGroup1, "a", "b"); + crosstabGroupTotalHeaderCountTest(rowGroup1, 1); + crosstabGroupTotalHeaderValueTest(rowGroup1, "Total"); + crosstabGroupHeaderCountTest(rowGroup2, 4); + crosstabGroupHeaderValueTest(rowGroup2, "c", "d", "e", "f"); + crosstabGroupTotalHeaderCountTest(rowGroup2, 2); + crosstabGroupTotalHeaderValueTest(rowGroup2, "Total", "Total"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 16); + crosstabCellValueTest(measure1, null, null, "1", "2", "0", "0", "3", "4", "0", "0", "0", "0", "5", "6", "0", "0", "7", "8"); + crosstabCellCountTest(measure1, null, columnGroup1, 4); + crosstabCellValueTest(measure1, null, columnGroup1, "3", "7", "11", "15"); + crosstabCellCountTest(measure1, null, columnGroup2, 8); + crosstabCellValueTest(measure1, null, columnGroup2, "3", "0", "7", "0", "0", "11", "0", "15"); + crosstabCellCountTest(measure1, rowGroup1, null, 4); + crosstabCellValueTest(measure1, rowGroup1, null, "4", "6", "12", "14"); + crosstabCellCountTest(measure1, rowGroup2, null, 8); + crosstabCellValueTest(measure1, rowGroup2, null, "4", "6", "0", "0", "0", "0", "12", "14"); + crosstabCellCountTest(measure1, rowGroup1, columnGroup1, 1); + crosstabCellValueTest(measure1, rowGroup1, columnGroup1, "36"); + crosstabCellCountTest(measure1, rowGroup2, columnGroup2, 4); + crosstabCellValueTest(measure1, rowGroup2, columnGroup2, "10", "0", "0", "26"); + crosstabCellCountTest(measure1, rowGroup1, columnGroup2, 2); + crosstabCellValueTest(measure1, rowGroup1, columnGroup2, "10", "26"); + crosstabCellCountTest(measure1, rowGroup2, columnGroup1, 2); + crosstabCellValueTest(measure1, rowGroup2, columnGroup1, "10", "26"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5"); + dataSource.add("a", "c", "g", "i", 1); + dataSource.add("a", "c", "g", "j", 2); + dataSource.add("a", "d", "g", "i", 3); + dataSource.add("a", "d", "g", "j", 4); + dataSource.add("b", "e", "h", "k", 5); + dataSource.add("b", "e", "h", "l", 6); + dataSource.add("b", "f", "h", "k", 7); + dataSource.add("b", "f", "h", "l", 8); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab3Test.java new file mode 100644 index 0000000..eb8a113 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab3Test.java @@ -0,0 +1,122 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractValueFormatter; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class Crosstab3Test extends AbstractJasperCrosstabValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + measure1.setValueFormatter(new ValueFormatter1()); + + CrosstabBuilder crosstab = ctab.crosstab() + .rowGroups(rowGroup = ctab.rowGroup("field1", String.class).setHeaderValueFormatter(new ValueFormatter2())) + .columnGroups(columnGroup = ctab.columnGroup("field2", String.class).setHeaderValueFormatter(new ValueFormatter2())) + .measures(measure1); + + rb.setLocale(Locale.ENGLISH).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group + crosstabGroupHeaderCountTest(columnGroup, 2); + crosstabGroupHeaderValueTest(columnGroup, "value = c", "value = d"); + crosstabGroupTotalHeaderCountTest(columnGroup, 1); + crosstabGroupTotalHeaderValueTest(columnGroup, "Total"); + + // row group + crosstabGroupHeaderCountTest(rowGroup, 2); + crosstabGroupHeaderValueTest(rowGroup, "value = a", "value = b"); + crosstabGroupTotalHeaderCountTest(rowGroup, 1); + crosstabGroupTotalHeaderValueTest(rowGroup, "Total"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 4); + crosstabCellValueTest(measure1, null, null, "value = 3", "value = 7", "value = 11", "value = 15"); + crosstabCellCountTest(measure1, null, columnGroup, 2); + crosstabCellValueTest(measure1, null, columnGroup, "value = 10", "value = 26"); + crosstabCellCountTest(measure1, rowGroup, null, 2); + crosstabCellValueTest(measure1, rowGroup, null, "value = 14", "value = 22"); + crosstabCellCountTest(measure1, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure1, rowGroup, columnGroup, "value = 36"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("a", "c", 2); + dataSource.add("a", "d", 3); + dataSource.add("a", "d", 4); + dataSource.add("b", "c", 5); + dataSource.add("b", "c", 6); + dataSource.add("b", "d", 7); + dataSource.add("b", "d", 8); + return dataSource; + } + + private class ValueFormatter1 extends AbstractValueFormatter { + private static final long serialVersionUID = 1L; + + @Override + public String format(Integer value, ReportParameters reportParameters) { + return "value = " + value; + } + } + + private class ValueFormatter2 extends AbstractValueFormatter { + private static final long serialVersionUID = 1L; + + @Override + public String format(String value, ReportParameters reportParameters) { + return "value = " + value; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab4Test.java new file mode 100644 index 0000000..14a247a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab4Test.java @@ -0,0 +1,108 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import software.xdev.dynamicreports.test.jasper.JasperTestUtils; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class Crosstab4Test extends AbstractJasperCrosstabValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + CrosstabBuilder crosstab = ctab.crosstab() + .setDataPreSorted(true) + .rowGroups(rowGroup = ctab.rowGroup("field1", String.class)) + .columnGroups(columnGroup = ctab.columnGroup("field2", String.class)) + .measures(measure1 = ctab.measure("field3", Integer.class, Calculation.SUM)); + + rb.setLocale(Locale.ENGLISH).summary(crosstab, crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group + crosstabGroupHeaderCountTest(columnGroup, 2); + crosstabGroupHeaderValueTest(columnGroup, "d", "c"); + crosstabGroupTotalHeaderCountTest(columnGroup, 1); + crosstabGroupTotalHeaderValueTest(columnGroup, "Total"); + + // row group + crosstabGroupHeaderCountTest(rowGroup, 3); + crosstabGroupHeaderValueTest(rowGroup, "c", "a", "b"); + crosstabGroupTotalHeaderCountTest(rowGroup, 1); + crosstabGroupTotalHeaderValueTest(rowGroup, "Total"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 6); + crosstabCellValueTest(measure1, null, null, "1", "1", "1", "1", "1", "1"); + crosstabCellCountTest(measure1, null, columnGroup, 3); + crosstabCellValueTest(measure1, null, columnGroup, "2", "2", "2"); + crosstabCellCountTest(measure1, rowGroup, null, 2); + crosstabCellValueTest(measure1, rowGroup, null, "3", "3"); + crosstabCellCountTest(measure1, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure1, rowGroup, columnGroup, "6"); + + // column group + elementCountTest(getPrefix(2) + JasperTestUtils.getCrosstabGroupHeaderName(columnGroup), 2); + elementCountTest(getPrefix(2) + JasperTestUtils.getCrosstabGroupTotalHeaderName(columnGroup), 1); + + // row group + elementCountTest(getPrefix(2) + JasperTestUtils.getCrosstabGroupHeaderName(rowGroup), 3); + elementCountTest(getPrefix(2) + JasperTestUtils.getCrosstabGroupTotalHeaderName(rowGroup), 1); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("c", "d", 1); + dataSource.add("c", "c", 1); + dataSource.add("a", "d", 1); + dataSource.add("a", "c", 1); + dataSource.add("b", "d", 1); + dataSource.add("b", "c", 1); + + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab5Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab5Test.java new file mode 100644 index 0000000..ed036dd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab5Test.java @@ -0,0 +1,207 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.exp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; +import java.util.Locale; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder; +import software.xdev.dynamicreports.report.builder.expression.AbstractComplexExpression; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.CrosstabPercentageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * @author Ricardo Mariaca + */ +public class Crosstab5Test extends AbstractJasperCrosstabValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabVariableBuilder variable1; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + private CrosstabMeasureBuilder measure3; + private CrosstabMeasureBuilder measure4; + private CrosstabMeasureBuilder measure5; + + @Override + protected void configureReport(final JasperReportBuilder rb) { + this.rowGroup = ctab.rowGroup("field1", String.class); + this.columnGroup = ctab.columnGroup("field2", String.class); + + final FieldBuilder field = field("field3", Integer.class); + this.variable1 = ctab.variable(field, Calculation.SUM); + this.measure1 = ctab.measure(field, Calculation.SUM); + this.measure2 = ctab.measure(field, Calculation.SUM); + this.measure2.setPercentageType(CrosstabPercentageType.GRAND_TOTAL); + this.measure3 = ctab.measure(new PercentageExpression1()); + this.measure3.setDataType(type.doubleType()); + final String expression = "$V{" + this.measure1.getName() + "}.doubleValue()/$V{" + this.measure1.getName() + "_" + this.rowGroup.getName() + "_" + this.columnGroup.getName() + "_ALL}.doubleValue() * 100"; + this.measure4 = ctab.measure(exp.jasperSyntax(expression, Double.class)); + this.measure4.setDataType(type.doubleType()); + this.measure5 = ctab.measure(new PercentageExpression2()); + this.measure5.setDataType(type.doubleType()); + + final CrosstabBuilder crosstab = ctab.crosstab().rowGroups(this.rowGroup).columnGroups(this.columnGroup).variables( + this.variable1).measures(this.measure1, this.measure2, this.measure3, this.measure4, this.measure5); + + rb.setLocale(Locale.ENGLISH).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + this.numberOfPagesTest(1); + + this.setCrosstabBand("summary"); + + // column group + this.crosstabGroupHeaderCountTest(this.columnGroup, 2); + this.crosstabGroupHeaderValueTest(this.columnGroup, "c", "d"); + this.crosstabGroupTotalHeaderCountTest(this.columnGroup, 1); + this.crosstabGroupTotalHeaderValueTest(this.columnGroup, "Total"); + + // row group + this.crosstabGroupHeaderCountTest(this.rowGroup, 2); + this.crosstabGroupHeaderValueTest(this.rowGroup, "a", "b"); + this.crosstabGroupTotalHeaderCountTest(this.rowGroup, 1); + this.crosstabGroupTotalHeaderValueTest(this.rowGroup, "Total"); + + // measure1 + this.crosstabCellCountTest(this.measure1, null, null, 4); + this.crosstabCellValueTest(this.measure1, null, null, "3", "7", "11", "15"); + this.crosstabCellCountTest(this.measure1, null, this.columnGroup, 2); + this.crosstabCellValueTest(this.measure1, null, this.columnGroup, "10", "26"); + this.crosstabCellCountTest(this.measure1, this.rowGroup, null, 2); + this.crosstabCellValueTest(this.measure1, this.rowGroup, null, "14", "22"); + this.crosstabCellCountTest(this.measure1, this.rowGroup, this.columnGroup, 1); + this.crosstabCellValueTest(this.measure1, this.rowGroup, this.columnGroup, "36"); + + // measure2 + this.crosstabCellCountTest(this.measure2, null, null, 4); + this.crosstabCellValueTest(this.measure2, null, null, "8.3", "19.4", "30.6", "41.7"); + this.crosstabCellCountTest(this.measure2, null, this.columnGroup, 2); + this.crosstabCellValueTest(this.measure2, null, this.columnGroup, "27.8", "72.2"); + this.crosstabCellCountTest(this.measure2, this.rowGroup, null, 2); + this.crosstabCellValueTest(this.measure2, this.rowGroup, null, "38.9", "61.1"); + this.crosstabCellCountTest(this.measure2, this.rowGroup, this.columnGroup, 1); + this.crosstabCellValueTest(this.measure2, this.rowGroup, this.columnGroup, "100"); + + // measure3 + this.crosstabCellCountTest(this.measure3, null, null, 4); + this.crosstabCellValueTest(this.measure3, null, null, "8.3", "19.4", "30.6", "41.7"); + this.crosstabCellCountTest(this.measure3, null, this.columnGroup, 2); + this.crosstabCellValueTest(this.measure3, null, this.columnGroup, "27.8", "72.2"); + this.crosstabCellCountTest(this.measure3, this.rowGroup, null, 2); + this.crosstabCellValueTest(this.measure3, this.rowGroup, null, "38.9", "61.1"); + this.crosstabCellCountTest(this.measure3, this.rowGroup, this.columnGroup, 1); + this.crosstabCellValueTest(this.measure3, this.rowGroup, this.columnGroup, "100"); + + // measure4 + this.crosstabCellCountTest(this.measure4, null, null, 4); + this.crosstabCellValueTest(this.measure4, null, null, "8.3", "19.4", "30.6", "41.7"); + this.crosstabCellCountTest(this.measure4, null, this.columnGroup, 2); + this.crosstabCellValueTest(this.measure4, null, this.columnGroup, "27.8", "72.2"); + this.crosstabCellCountTest(this.measure4, this.rowGroup, null, 2); + this.crosstabCellValueTest(this.measure4, this.rowGroup, null, "38.9", "61.1"); + this.crosstabCellCountTest(this.measure4, this.rowGroup, this.columnGroup, 1); + this.crosstabCellValueTest(this.measure4, this.rowGroup, this.columnGroup, "100"); + + // measure5 + this.crosstabCellCountTest(this.measure5, null, null, 4); + this.crosstabCellValueTest(this.measure5, null, null, "21.4", "31.8", "78.6", "68.2"); + this.crosstabCellCountTest(this.measure5, null, this.columnGroup, 2); + this.crosstabCellValueTest(this.measure5, null, this.columnGroup, "27.8", "72.2"); + this.crosstabCellCountTest(this.measure5, this.rowGroup, null, 2); + this.crosstabCellValueTest(this.measure5, this.rowGroup, null, "100", "100"); + this.crosstabCellCountTest(this.measure5, this.rowGroup, this.columnGroup, 1); + this.crosstabCellValueTest(this.measure5, this.rowGroup, this.columnGroup, "100"); + } + + @Override + protected JRDataSource createDataSource() { + final DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("a", "c", 2); + dataSource.add("a", "d", 3); + dataSource.add("a", "d", 4); + dataSource.add("b", "c", 5); + dataSource.add("b", "c", 6); + dataSource.add("b", "d", 7); + dataSource.add("b", "d", 8); + return dataSource; + } + + private class PercentageExpression1 extends AbstractComplexExpression { + private static final long serialVersionUID = 1L; + + private PercentageExpression1() { + this.addExpression(exp.crosstabValue(Crosstab5Test.this.measure1)); + this.addExpression(exp.crosstabValue(Crosstab5Test.this.measure1, Crosstab5Test.this.rowGroup, + Crosstab5Test.this.columnGroup)); + } + + @Override + public BigDecimal evaluate(final List values, final ReportParameters reportParameters) { + final Integer value1 = (Integer) values.get(0); + final Integer value2 = (Integer) values.get(1); + return new BigDecimal(value1).divide(new BigDecimal(value2), 3, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)); + } + } + + private class PercentageExpression2 extends AbstractComplexExpression { + private static final long serialVersionUID = 1L; + + private PercentageExpression2() { + this.addExpression(exp.crosstabValue(Crosstab5Test.this.variable1)); + this.addExpression(exp.crosstabValue(Crosstab5Test.this.measure1, Crosstab5Test.this.rowGroup)); + this.addExpression(exp.jasperSyntax("$V{" + Crosstab5Test.this.measure1.getName() + "_" + Crosstab5Test.this.rowGroup.getName() + "_ALL}", Integer.class)); + } + + @Override + public BigDecimal evaluate(final List values, final ReportParameters reportParameters) { + final Integer value1 = (Integer) values.get(0); + final Integer value2 = (Integer) values.get(1); + final Integer measure1Value = reportParameters.getValue(Crosstab5Test.this.measure1); + Assertions.assertEquals(value1, measure1Value); + Assertions.assertEquals(value2, values.get(2)); + return new BigDecimal(value1).divide(new BigDecimal(value2), 3, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab6Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab6Test.java new file mode 100644 index 0000000..bab3890 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab6Test.java @@ -0,0 +1,117 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.jasper.constant.JasperProperty; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class Crosstab6Test extends AbstractJasperCrosstabValueTest { + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + measure1.addProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true"); + measure1.setStretchWithOverflow(false); + + CrosstabBuilder crosstab = ctab.crosstab() + .setCellWidth(18) + .rowGroups(rowGroup = ctab.rowGroup("field1", String.class) + .addHeaderProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true") + .addTotalHeaderProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true") + .setHeaderStretchWithOverflow(false) + .setTotalHeaderStretchWithOverflow(false) + .setHeaderWidth(18)) + .columnGroups(columnGroup = ctab.columnGroup("field2", String.class) + .addHeaderProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true") + .addTotalHeaderProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true") + .setHeaderStretchWithOverflow(false) + .setTotalHeaderStretchWithOverflow(false)) + .measures(measure1); + + rb.summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group + crosstabGroupHeaderCountTest(columnGroup, 2); + crosstabGroupHeaderValueTest(columnGroup, "c ", "d "); + crosstabGroupHeaderFullValueTest(columnGroup, "c test test", "d test test"); + crosstabGroupTotalHeaderCountTest(columnGroup, 1); + crosstabGroupTotalHeaderValueTest(columnGroup, "To"); + crosstabGroupTotalHeaderFullValueTest(columnGroup, "Total"); + + // row group + crosstabGroupHeaderCountTest(rowGroup, 2); + crosstabGroupHeaderValueTest(rowGroup, "a ", "b "); + crosstabGroupHeaderFullValueTest(rowGroup, "a test test", "b test test"); + crosstabGroupTotalHeaderCountTest(rowGroup, 1); + crosstabGroupTotalHeaderValueTest(rowGroup, "To"); + crosstabGroupTotalHeaderFullValueTest(rowGroup, "Total"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 4); + crosstabCellValueTest(measure1, null, null, "30", "70", "11", "15"); + crosstabCellFullValueTest(measure1, null, null, "30", "70", "110", "150"); + crosstabCellCountTest(measure1, null, columnGroup, 2); + crosstabCellValueTest(measure1, null, columnGroup, "10", "26"); + crosstabCellFullValueTest(measure1, null, columnGroup, "100", "260"); + crosstabCellCountTest(measure1, rowGroup, null, 2); + crosstabCellValueTest(measure1, rowGroup, null, "14", "22"); + crosstabCellFullValueTest(measure1, rowGroup, null, "140", "220"); + crosstabCellCountTest(measure1, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure1, rowGroup, columnGroup, "36"); + crosstabCellFullValueTest(measure1, rowGroup, columnGroup, "360"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a test test", "c test test", 10); + dataSource.add("a test test", "c test test", 20); + dataSource.add("a test test", "d test test", 30); + dataSource.add("a test test", "d test test", 40); + dataSource.add("b test test", "c test test", 50); + dataSource.add("b test test", "c test test", 60); + dataSource.add("b test test", "d test test", 70); + dataSource.add("b test test", "d test test", 80); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab7Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab7Test.java new file mode 100644 index 0000000..3acbb9d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/Crosstab7Test.java @@ -0,0 +1,118 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.jasper.constant.JasperProperty; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.TextAdjust; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * @author Jan Moxter + */ +public class Crosstab7Test extends AbstractJasperCrosstabValueTest { + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(final JasperReportBuilder rb) { + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + measure1.addProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true"); + measure1.setTextAdjust(TextAdjust.CUT_TEXT); + + final CrosstabBuilder crosstab = ctab.crosstab() + .setCellWidth(18) + .rowGroups(rowGroup = ctab.rowGroup("field1", String.class) + .addHeaderProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true") + .addTotalHeaderProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true") + .setHeaderTextAdjust(TextAdjust.CUT_TEXT) + .setTotalHeaderTextAdjust(TextAdjust.CUT_TEXT) + .setHeaderWidth(18)) + .columnGroups(columnGroup = ctab.columnGroup("field2", String.class) + .addHeaderProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true") + .addTotalHeaderProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, "true") + .setHeaderTextAdjust(TextAdjust.CUT_TEXT) + .setTotalHeaderTextAdjust(TextAdjust.CUT_TEXT)) + .measures(measure1); + + rb.summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group + crosstabGroupHeaderCountTest(columnGroup, 2); + crosstabGroupHeaderValueTest(columnGroup, "c ", "d "); + crosstabGroupHeaderFullValueTest(columnGroup, "c test test", "d test test"); + crosstabGroupTotalHeaderCountTest(columnGroup, 1); + crosstabGroupTotalHeaderValueTest(columnGroup, "To"); + crosstabGroupTotalHeaderFullValueTest(columnGroup, "Total"); + + // row group + crosstabGroupHeaderCountTest(rowGroup, 2); + crosstabGroupHeaderValueTest(rowGroup, "a ", "b "); + crosstabGroupHeaderFullValueTest(rowGroup, "a test test", "b test test"); + crosstabGroupTotalHeaderCountTest(rowGroup, 1); + crosstabGroupTotalHeaderValueTest(rowGroup, "To"); + crosstabGroupTotalHeaderFullValueTest(rowGroup, "Total"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 4); + crosstabCellValueTest(measure1, null, null, "30", "70", "11", "15"); + crosstabCellFullValueTest(measure1, null, null, "30", "70", "110", "150"); + crosstabCellCountTest(measure1, null, columnGroup, 2); + crosstabCellValueTest(measure1, null, columnGroup, "10", "26"); + crosstabCellFullValueTest(measure1, null, columnGroup, "100", "260"); + crosstabCellCountTest(measure1, rowGroup, null, 2); + crosstabCellValueTest(measure1, rowGroup, null, "14", "22"); + crosstabCellFullValueTest(measure1, rowGroup, null, "140", "220"); + crosstabCellCountTest(measure1, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure1, rowGroup, columnGroup, "36"); + crosstabCellFullValueTest(measure1, rowGroup, columnGroup, "360"); + } + + @Override + protected JRDataSource createDataSource() { + final DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a test test", "c test test", 10); + dataSource.add("a test test", "c test test", 20); + dataSource.add("a test test", "d test test", 30); + dataSource.add("a test test", "d test test", 40); + dataSource.add("b test test", "c test test", 50); + dataSource.add("b test test", "c test test", 60); + dataSource.add("b test test", "d test test", 70); + dataSource.add("b test test", "d test test", 80); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition10Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition10Test.java new file mode 100644 index 0000000..8153f97 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition10Test.java @@ -0,0 +1,86 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabPosition10Test extends AbstractJasperCrosstabPositionTest { + private CrosstabRowGroupBuilder rowGroup1; + private CrosstabColumnGroupBuilder columnGroup1; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + TextColumnBuilder column3 = col.column("Column3", "field3", Integer.class); + + rowGroup1 = ctab.rowGroup(column1).setShowTotal(false); + measure1 = ctab.measure(column3, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab().rowGroups(rowGroup1).columnGroups(columnGroup1 = ctab.columnGroup(column2)).measures(measure1); + + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group 1 + crosstabGroupHeaderPositionTest(columnGroup1, 0, 0, 0, 100, 26); + crosstabGroupHeaderPositionTest(columnGroup1, 1, 0, 0, 100, 26); + crosstabGroupTotalHeaderPositionTest(columnGroup1, 0, 0, 0, 100, 26); + + // row group 1 + crosstabGroupHeaderPositionTest(rowGroup1, 0, 0, 0, 100, 16); + + // measures + crosstabCellPositionTest(measure1, null, null, 0, 0, 0, 100, 16); + crosstabCellPositionTest(measure1, null, null, 1, 0, 0, 100, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("text", "a", 1); + dataSource.add("text", "a\nb", 1); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition1Test.java new file mode 100644 index 0000000..8f22e2c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition1Test.java @@ -0,0 +1,121 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabPosition1Test extends AbstractJasperCrosstabPositionTest { + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + TextColumnBuilder column3 = col.column("Column3", "field3", Integer.class); + TextColumnBuilder column4 = col.column("Column4", "field4", Double.class); + + measure1 = ctab.measure(column3, Calculation.SUM); + measure2 = ctab.measure(column4, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab() + .headerCell(cmp.text("Header")) + .setCellWidth(200) + .rowGroups(rowGroup = ctab.rowGroup(column1).setHeaderWidth(50)) + .columnGroups(columnGroup = ctab.columnGroup(column2).setTotalHeaderWidth(210)) + .measures(measure1, measure2); + + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).columns(column1, column2, column3, column4).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + crosstabHeaderElementPositionTest("textField1", 0, 0, 0, 50, 16); + + // column group + crosstabGroupHeaderPositionTest(columnGroup, 0, 0, 0, 200, 16); + crosstabGroupHeaderPositionTest(columnGroup, 1, 0, 0, 200, 16); + crosstabGroupTotalHeaderPositionTest(columnGroup, 0, 0, 0, 210, 16); + + // row group + crosstabGroupHeaderPositionTest(rowGroup, 0, 0, 0, 50, 16); + crosstabGroupHeaderPositionTest(rowGroup, 1, 0, 0, 50, 16); + crosstabGroupHeaderPositionTest(rowGroup, 2, 0, 0, 50, 16); + crosstabGroupTotalHeaderPositionTest(rowGroup, 0, 0, 0, 50, 16); + + // measures + for (int i = 0; i < 6; i++) { + crosstabCellPositionTest(measure1, null, null, i, 0, 0, 100, 16); + crosstabCellPositionTest(measure2, null, null, i, 100, 0, 100, 16); + } + for (int i = 0; i < 3; i++) { + crosstabCellPositionTest(measure1, null, columnGroup, i, 0, 0, 105, 16); + crosstabCellPositionTest(measure2, null, columnGroup, i, 105, 0, 105, 16); + } + for (int i = 0; i < 2; i++) { + crosstabCellPositionTest(measure1, rowGroup, null, i, 0, 0, 100, 16); + crosstabCellPositionTest(measure2, rowGroup, null, i, 100, 0, 100, 16); + } + crosstabCellPositionTest(measure1, rowGroup, columnGroup, 0, 0, 0, 105, 16); + crosstabCellPositionTest(measure2, rowGroup, columnGroup, 0, 105, 0, 105, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add("a", "c", 106, 2d); + dataSource.add("a", "c", 252, 3d); + dataSource.add("a", "d", 312, 4d); + dataSource.add("a", "d", 456, 5d); + dataSource.add("b", "c", 515, 6d); + dataSource.add("b", "c", 678, 7d); + dataSource.add("b", "d", 779, 8d); + dataSource.add("b", "d", 823, 9d); + dataSource.add("c", "c", 515, 6d); + dataSource.add("c", "c", 678, 7d); + dataSource.add("c", "d", 779, 8d); + dataSource.add("c", "d", 823, 9d); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition2Test.java new file mode 100644 index 0000000..429037b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition2Test.java @@ -0,0 +1,117 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabPosition2Test extends AbstractJasperCrosstabPositionTest { + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + TextColumnBuilder column3 = col.column("Column3", "field3", Integer.class); + TextColumnBuilder column4 = col.column("Column4", "field4", Double.class); + + measure1 = ctab.measure(column3, Calculation.SUM); + measure2 = ctab.measure(column4, Calculation.SUM); + + CrosstabBuilder crosstab = + ctab.crosstab().headerCell(cmp.text("Header")).rowGroups(rowGroup = ctab.rowGroup(column1)).columnGroups(columnGroup = ctab.columnGroup(column2)).measures(measure1, measure2); + + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).columns(column1, column2, column3, column4).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + crosstabHeaderElementPositionTest("textField1", 0, 0, 0, 100, 16); + + // column group + crosstabGroupHeaderPositionTest(columnGroup, 0, 0, 0, 150, 16); + crosstabGroupHeaderPositionTest(columnGroup, 1, 0, 0, 150, 16); + crosstabGroupTotalHeaderPositionTest(columnGroup, 0, 0, 0, 150, 16); + + // row group + crosstabGroupHeaderPositionTest(rowGroup, 0, 0, 0, 100, 16); + crosstabGroupHeaderPositionTest(rowGroup, 1, 0, 0, 100, 16); + crosstabGroupHeaderPositionTest(rowGroup, 2, 0, 0, 100, 16); + crosstabGroupTotalHeaderPositionTest(rowGroup, 0, 0, 0, 100, 16); + + // measures + for (int i = 0; i < 6; i++) { + crosstabCellPositionTest(measure1, null, null, i, 0, 0, 75, 16); + crosstabCellPositionTest(measure2, null, null, i, 75, 0, 75, 16); + } + for (int i = 0; i < 3; i++) { + crosstabCellPositionTest(measure1, null, columnGroup, i, 0, 0, 75, 16); + crosstabCellPositionTest(measure2, null, columnGroup, i, 75, 0, 75, 16); + } + for (int i = 0; i < 2; i++) { + crosstabCellPositionTest(measure1, rowGroup, null, i, 0, 0, 75, 16); + crosstabCellPositionTest(measure2, rowGroup, null, i, 75, 0, 75, 16); + } + crosstabCellPositionTest(measure1, rowGroup, columnGroup, 0, 0, 0, 75, 16); + crosstabCellPositionTest(measure2, rowGroup, columnGroup, 0, 75, 0, 75, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add("a", "c", 106, 2d); + dataSource.add("a", "c", 252, 3d); + dataSource.add("a", "d", 312, 4d); + dataSource.add("a", "d", 456, 5d); + dataSource.add("b", "c", 515, 6d); + dataSource.add("b", "c", 678, 7d); + dataSource.add("b", "d", 779, 8d); + dataSource.add("b", "d", 823, 9d); + dataSource.add("c", "c", 515, 6d); + dataSource.add("c", "c", 678, 7d); + dataSource.add("c", "d", 779, 8d); + dataSource.add("c", "d", 823, 9d); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition3Test.java new file mode 100644 index 0000000..5568b06 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition3Test.java @@ -0,0 +1,122 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabPosition3Test extends AbstractJasperCrosstabPositionTest { + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + TextColumnBuilder column3 = col.column("Column3", "field3", Integer.class); + TextColumnBuilder column4 = col.column("Column4", "field4", Double.class); + + measure1 = ctab.measure(column3, Calculation.SUM); + measure2 = ctab.measure(column4, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab() + .headerCell(cmp.text("Header"), cmp.text("Header2")) + .setCellHeight(20) + .rowGroups(rowGroup = ctab.rowGroup(column1).setTotalHeaderHeight(30)) + .columnGroups(columnGroup = ctab.columnGroup(column2).setHeaderHeight(40)) + .measures(measure1, measure2); + + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).columns(column1, column2, column3, column4).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + crosstabHeaderElementPositionTest("textField1", 0, 0, 0, 100, 20); + crosstabHeaderElementPositionTest("textField2", 0, 0, 20, 100, 20); + + // column group + crosstabGroupHeaderPositionTest(columnGroup, 0, 0, 0, 150, 40); + crosstabGroupHeaderPositionTest(columnGroup, 1, 0, 0, 150, 40); + crosstabGroupTotalHeaderPositionTest(columnGroup, 0, 0, 0, 150, 40); + + // row group + crosstabGroupHeaderPositionTest(rowGroup, 0, 0, 0, 100, 20); + crosstabGroupHeaderPositionTest(rowGroup, 1, 0, 0, 100, 20); + crosstabGroupHeaderPositionTest(rowGroup, 2, 0, 0, 100, 20); + crosstabGroupTotalHeaderPositionTest(rowGroup, 0, 0, 0, 100, 30); + + // measures + for (int i = 0; i < 6; i++) { + crosstabCellPositionTest(measure1, null, null, i, 0, 0, 75, 20); + crosstabCellPositionTest(measure2, null, null, i, 75, 0, 75, 20); + } + for (int i = 0; i < 3; i++) { + crosstabCellPositionTest(measure1, null, columnGroup, i, 0, 0, 75, 20); + crosstabCellPositionTest(measure2, null, columnGroup, i, 75, 0, 75, 20); + } + for (int i = 0; i < 2; i++) { + crosstabCellPositionTest(measure1, rowGroup, null, i, 0, 0, 75, 30); + crosstabCellPositionTest(measure2, rowGroup, null, i, 75, 0, 75, 30); + } + crosstabCellPositionTest(measure1, rowGroup, columnGroup, 0, 0, 0, 75, 30); + crosstabCellPositionTest(measure2, rowGroup, columnGroup, 0, 75, 0, 75, 30); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add("a", "c", 106, 2d); + dataSource.add("a", "c", 252, 3d); + dataSource.add("a", "d", 312, 4d); + dataSource.add("a", "d", 456, 5d); + dataSource.add("b", "c", 515, 6d); + dataSource.add("b", "c", 678, 7d); + dataSource.add("b", "d", 779, 8d); + dataSource.add("b", "d", 823, 9d); + dataSource.add("c", "c", 515, 6d); + dataSource.add("c", "c", 678, 7d); + dataSource.add("c", "d", 779, 8d); + dataSource.add("c", "d", 823, 9d); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition4Test.java new file mode 100644 index 0000000..66d7b3d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition4Test.java @@ -0,0 +1,114 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabPosition4Test extends AbstractJasperCrosstabPositionTest { + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + TextColumnBuilder column3 = col.column("Column3", "field3", Integer.class); + TextColumnBuilder column4 = col.column("Column4", "field4", Double.class); + + measure1 = ctab.measure(column3, Calculation.SUM); + measure2 = ctab.measure(column4, Calculation.SUM); + + CrosstabBuilder crosstab = + ctab.crosstab().setCellWidth(80).setCellHeight(30).rowGroups(rowGroup = ctab.rowGroup(column1)).columnGroups(columnGroup = ctab.columnGroup(column2)).measures(measure1, measure2); + + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).columns(column1, column2, column3, column4).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group + crosstabGroupHeaderPositionTest(columnGroup, 0, 0, 0, 80, 16); + crosstabGroupHeaderPositionTest(columnGroup, 1, 0, 0, 80, 16); + crosstabGroupTotalHeaderPositionTest(columnGroup, 0, 0, 0, 80, 16); + + // row group + crosstabGroupHeaderPositionTest(rowGroup, 0, 0, 0, 100, 30); + crosstabGroupHeaderPositionTest(rowGroup, 1, 0, 0, 100, 30); + crosstabGroupHeaderPositionTest(rowGroup, 2, 0, 0, 100, 30); + crosstabGroupTotalHeaderPositionTest(rowGroup, 0, 0, 0, 100, 30); + + // measures + for (int i = 0; i < 6; i++) { + crosstabCellPositionTest(measure1, null, null, i, 0, 0, 40, 30); + crosstabCellPositionTest(measure2, null, null, i, 40, 0, 40, 30); + } + for (int i = 0; i < 3; i++) { + crosstabCellPositionTest(measure1, null, columnGroup, i, 0, 0, 40, 30); + crosstabCellPositionTest(measure2, null, columnGroup, i, 40, 0, 40, 30); + } + for (int i = 0; i < 2; i++) { + crosstabCellPositionTest(measure1, rowGroup, null, i, 0, 0, 40, 30); + crosstabCellPositionTest(measure2, rowGroup, null, i, 40, 0, 40, 30); + } + crosstabCellPositionTest(measure1, rowGroup, columnGroup, 0, 0, 0, 40, 30); + crosstabCellPositionTest(measure2, rowGroup, columnGroup, 0, 40, 0, 40, 30); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add("a", "c", 106, 2d); + dataSource.add("a", "c", 252, 3d); + dataSource.add("a", "d", 312, 4d); + dataSource.add("a", "d", 456, 5d); + dataSource.add("b", "c", 515, 6d); + dataSource.add("b", "c", 678, 7d); + dataSource.add("b", "d", 779, 8d); + dataSource.add("b", "d", 823, 9d); + dataSource.add("c", "c", 515, 6d); + dataSource.add("c", "c", 678, 7d); + dataSource.add("c", "d", 779, 8d); + dataSource.add("c", "d", 823, 9d); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition5Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition5Test.java new file mode 100644 index 0000000..8f4ce9a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition5Test.java @@ -0,0 +1,127 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabPosition5Test extends AbstractJasperCrosstabPositionTest { + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup1; + private CrosstabColumnGroupBuilder columnGroup2; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field1", String.class); + TextColumnBuilder column3 = col.column("Column3", "field2", String.class); + TextColumnBuilder column4 = col.column("Column4", "field3", Integer.class); + TextColumnBuilder column5 = col.column("Column5", "field4", Double.class); + + measure1 = ctab.measure("measure1", column4, Calculation.SUM); + measure2 = ctab.measure("measure2", column5, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab() + .headerCell(cmp.text("Header")) + .setCellWidth(100) + .rowGroups(rowGroup = ctab.rowGroup(column1).setHeaderWidth(50)) + .columnGroups(columnGroup1 = ctab.columnGroup(column2), columnGroup2 = ctab.columnGroup(column3)) + .measures(measure1, measure2); + + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + crosstabHeaderElementPositionTest("textField1", 0, 0, 0, 50, 48); + + // column group 1 + crosstabGroupHeaderPositionTest(columnGroup1, 0, 0, 0, 300, 16); + crosstabGroupTotalHeaderPositionTest(columnGroup1, 0, 0, 0, 100, 24); + + crosstabGroupTitleTotalHeaderPositionTest(columnGroup1, measure1, 0, 0, 0, 50, 24); + crosstabGroupTitleTotalHeaderPositionTest(columnGroup1, measure2, 0, 50, 0, 50, 24); + + // column group 2 + crosstabGroupHeaderPositionTest(columnGroup2, 0, 0, 0, 100, 16); + crosstabGroupHeaderPositionTest(columnGroup2, 1, 0, 0, 100, 16); + crosstabGroupTotalHeaderPositionTest(columnGroup2, 0, 0, 0, 100, 16); + + crosstabGroupTitleHeaderPositionTest(columnGroup2, measure1, 0, 0, 0, 50, 16); + crosstabGroupTitleHeaderPositionTest(columnGroup2, measure2, 0, 50, 0, 50, 16); + crosstabGroupTitleHeaderPositionTest(columnGroup2, measure1, 1, 0, 0, 50, 16); + crosstabGroupTitleHeaderPositionTest(columnGroup2, measure2, 1, 50, 0, 50, 16); + crosstabGroupTitleTotalHeaderPositionTest(columnGroup2, measure1, 0, 0, 0, 50, 16); + crosstabGroupTitleTotalHeaderPositionTest(columnGroup2, measure2, 0, 50, 0, 50, 16); + + // row group + crosstabGroupHeaderPositionTest(rowGroup, 0, 0, 0, 50, 16); + crosstabGroupTotalHeaderPositionTest(rowGroup, 0, 0, 0, 50, 16); + + // measures + for (int i = 0; i < 2; i++) { + crosstabCellPositionTest(measure1, null, null, i, 0, 0, 50, 16); + crosstabCellPositionTest(measure2, null, null, i, 50, 0, 50, 16); + } + crosstabCellPositionTest(measure1, null, columnGroup1, 0, 0, 0, 50, 16); + crosstabCellPositionTest(measure2, null, columnGroup1, 0, 50, 0, 50, 16); + crosstabCellPositionTest(measure1, null, columnGroup2, 0, 0, 0, 50, 16); + crosstabCellPositionTest(measure2, null, columnGroup2, 0, 50, 0, 50, 16); + crosstabCellPositionTest(measure1, rowGroup, null, 0, 0, 0, 50, 16); + crosstabCellPositionTest(measure2, rowGroup, null, 0, 50, 0, 50, 16); + crosstabCellPositionTest(measure1, rowGroup, columnGroup1, 0, 0, 0, 50, 16); + crosstabCellPositionTest(measure2, rowGroup, columnGroup1, 0, 50, 0, 50, 16); + crosstabCellPositionTest(measure1, rowGroup, columnGroup2, 0, 0, 0, 50, 16); + crosstabCellPositionTest(measure2, rowGroup, columnGroup2, 0, 50, 0, 50, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add("a", "c", 1, 2d); + dataSource.add("a", "c", 2, 3d); + dataSource.add("a", "d", 3, 4d); + dataSource.add("a", "d", 4, 5d); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition6Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition6Test.java new file mode 100644 index 0000000..6a862b1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition6Test.java @@ -0,0 +1,96 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabPosition6Test extends AbstractJasperCrosstabPositionTest { + private CrosstabRowGroupBuilder rowGroup1; + private CrosstabRowGroupBuilder rowGroup2; + private CrosstabColumnGroupBuilder columnGroup1; + private CrosstabColumnGroupBuilder columnGroup2; + private CrosstabMeasureBuilder measure; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field1", String.class); + TextColumnBuilder column3 = col.column("Column3", "field2", String.class); + TextColumnBuilder column4 = col.column("Column4", "field2", String.class); + TextColumnBuilder column5 = col.column("Column5", "field3", Integer.class); + + measure = ctab.measure("measure", column5, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab() + .rowGroups(rowGroup1 = ctab.rowGroup(column1), rowGroup2 = ctab.rowGroup(column2).setShowTotal(false)) + .columnGroups(columnGroup1 = ctab.columnGroup(column3), columnGroup2 = ctab.columnGroup(column4).setShowTotal(false)) + .measures(measure); + + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group 1 + crosstabGroupHeaderPositionTest(columnGroup1, 0, 0, 0, 100, 16); + crosstabGroupTotalHeaderPositionTest(columnGroup1, 0, 0, 0, 100, 24); + + // column group 2 + crosstabGroupHeaderPositionTest(columnGroup2, 0, 0, 0, 100, 16); + + // row group 1 + crosstabGroupHeaderPositionTest(rowGroup1, 0, 0, 0, 100, 16); + crosstabGroupTotalHeaderPositionTest(rowGroup1, 0, 0, 0, 200, 16); + + // row group 2 + crosstabGroupHeaderPositionTest(rowGroup2, 0, 0, 0, 100, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("a", "c", 2); + dataSource.add("a", "d", 3); + dataSource.add("a", "d", 4); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition7Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition7Test.java new file mode 100644 index 0000000..eda90fb --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition7Test.java @@ -0,0 +1,98 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabPosition7Test extends AbstractJasperCrosstabPositionTest { + private CrosstabRowGroupBuilder rowGroup1; + private CrosstabRowGroupBuilder rowGroup2; + private CrosstabColumnGroupBuilder columnGroup1; + private CrosstabColumnGroupBuilder columnGroup2; + private CrosstabMeasureBuilder measure; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field1", String.class); + TextColumnBuilder column3 = col.column("Column3", "field2", String.class); + TextColumnBuilder column4 = col.column("Column4", "field2", String.class); + TextColumnBuilder column5 = col.column("Column5", "field3", Integer.class); + + measure = ctab.measure("measure", column5, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab() + .rowGroups(rowGroup1 = ctab.rowGroup(column1), rowGroup2 = ctab.rowGroup(column2).setShowTotal(false)) + .columnGroups(columnGroup1 = ctab.columnGroup(column3), columnGroup2 = ctab.columnGroup(column4).setShowTotal(false)) + .measures(measure) + .setCellWidth(50) + .setCellHeight(20); + + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group 1 + crosstabGroupHeaderPositionTest(columnGroup1, 0, 0, 0, 50, 16); + crosstabGroupTotalHeaderPositionTest(columnGroup1, 0, 0, 0, 50, 24); + + // column group 2 + crosstabGroupHeaderPositionTest(columnGroup2, 0, 0, 0, 50, 16); + + // row group 1 + crosstabGroupHeaderPositionTest(rowGroup1, 0, 0, 0, 100, 20); + crosstabGroupTotalHeaderPositionTest(rowGroup1, 0, 0, 0, 200, 20); + + // row group 2 + crosstabGroupHeaderPositionTest(rowGroup2, 0, 0, 0, 100, 20); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("a", "c", 2); + dataSource.add("a", "d", 3); + dataSource.add("a", "d", 4); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition8Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition8Test.java new file mode 100644 index 0000000..73bbc2c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition8Test.java @@ -0,0 +1,94 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabPosition8Test extends AbstractJasperCrosstabPositionTest { + private CrosstabRowGroupBuilder rowGroup1; + private CrosstabColumnGroupBuilder columnGroup1; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + TextColumnBuilder column3 = col.column("Column3", "field3", Integer.class); + + rowGroup1 = ctab.rowGroup(column1).setHeaderWidth(22); + measure1 = ctab.measure("measure1", column3, Calculation.SUM); + measure2 = ctab.measure("measure2", column3, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab().setCellWidth(100).rowGroups(rowGroup1).columnGroups(columnGroup1 = ctab.columnGroup(column2)).measures(measure1, measure2); + + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group 1 + crosstabGroupHeaderPositionTest(columnGroup1, 0, 0, 0, 100, 16); + crosstabGroupTotalHeaderPositionTest(columnGroup1, 0, 0, 0, 100, 16); + + // row group 1 + crosstabGroupHeaderPositionTest(rowGroup1, 0, 0, 0, 22, 26); + crosstabGroupTotalHeaderPositionTest(rowGroup1, 0, 0, 0, 22, 26); + + // measures + crosstabCellPositionTest(measure1, null, null, 0, 0, 0, 50, 26); + crosstabCellPositionTest(measure1, rowGroup1, null, 0, 0, 0, 50, 26); + crosstabCellPositionTest(measure1, null, columnGroup1, 0, 0, 0, 50, 26); + crosstabCellPositionTest(measure1, rowGroup1, columnGroup1, 0, 0, 0, 50, 26); + + crosstabCellPositionTest(measure2, null, null, 0, 50, 0, 50, 26); + crosstabCellPositionTest(measure2, rowGroup1, null, 0, 50, 0, 50, 26); + crosstabCellPositionTest(measure2, null, columnGroup1, 0, 50, 0, 50, 26); + crosstabCellPositionTest(measure2, rowGroup1, columnGroup1, 0, 50, 0, 50, 26); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("text text", "a", 1); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition9Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition9Test.java new file mode 100644 index 0000000..1ef0839 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabPosition9Test.java @@ -0,0 +1,85 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabPosition9Test extends AbstractJasperCrosstabPositionTest { + private CrosstabRowGroupBuilder rowGroup1; + private CrosstabRowGroupBuilder rowGroup2; + private CrosstabColumnGroupBuilder columnGroup1; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + TextColumnBuilder column3 = col.column("Column3", "field3", Integer.class); + + rowGroup1 = ctab.rowGroup(column1).setShowTotal(false); + rowGroup2 = ctab.rowGroup(column1).setShowTotal(false).setHeaderWidth(25); + measure1 = ctab.measure("measure1", column3, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab().rowGroups(rowGroup1, rowGroup2).columnGroups(columnGroup1 = ctab.columnGroup(column2)).measures(measure1); + + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group 1 + crosstabGroupHeaderPositionTest(columnGroup1, 0, 0, 0, 100, 16); + + // row group 1 + crosstabGroupHeaderPositionTest(rowGroup1, 0, 0, 0, 100, 26); + crosstabGroupHeaderPositionTest(rowGroup2, 0, 0, 0, 25, 26); + + // measures + crosstabCellPositionTest(measure1, null, null, 0, 0, 0, 100, 26); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("text text", "a", 1); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle1Test.java new file mode 100644 index 0000000..ab8c231 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle1Test.java @@ -0,0 +1,130 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.awt.Color; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabStyleTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.type.HorizontalTextAlignEnum; + +/** + * Crosstab style tests. + * + * @author Ricardo Mariaca + */ +public class CrosstabStyle1Test extends AbstractJasperCrosstabStyleTest { + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + FieldBuilder field1 = field("field1", String.class); + FieldBuilder field2 = field("field2", String.class); + + StyleBuilder titleStyle1 = stl.style().setFontSize(12).bold(); + StyleBuilder titleStyle2 = stl.style(titleStyle1).setBackgroundColor(Color.LIGHT_GRAY); + StyleBuilder titleStyle3 = stl.style(titleStyle2).setBorder(stl.pen1Point()) + .setHorizontalTextAlignment(HorizontalTextAlignment.CENTER); + StyleBuilder cellStyle = stl.style().bold(); + final StyleBuilder rowGroupCellStyle = stl.style(cellStyle).setBackgroundColor(Color.BLUE); + final StyleBuilder columnGroupCellStyle = stl.style(cellStyle).setBackgroundColor(Color.ORANGE); + final StyleBuilder rowColumnGroupCellStyle = stl.style(cellStyle).setBackgroundColor(Color.RED); + + rowGroup = ctab.rowGroup(field1).setHeaderStyle(titleStyle2).setTotalHeaderStyle(titleStyle3); + columnGroup = + ctab.columnGroup(field2).setHeaderStyle(titleStyle2).setTotalHeaderStyle(titleStyle3); + + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + measure1.setStyle(cellStyle); + measure1.setStyle(rowGroupCellStyle, rowGroup); + measure1.setStyle(columnGroupCellStyle, columnGroup); + measure1.setStyle(rowColumnGroupCellStyle, rowGroup, columnGroup); + + CrosstabBuilder crosstab = ctab.crosstab().headerCell(cmp.text("Header").setStyle(titleStyle1)) + .rowGroups(rowGroup).columnGroups(columnGroup).measures(measure1); + + rb.summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + crosstabHeaderElementStyleTest("textField1", 0, null, null, TEST_FONT_NAME, 12f, true, null); + + crosstabGroupHeaderStyleTest(rowGroup, 0, null, Color.LIGHT_GRAY, TEST_FONT_NAME, 12f, true, + null); + crosstabGroupTotalHeaderStyleTest(rowGroup, 0, null, Color.LIGHT_GRAY, TEST_FONT_NAME, 12f, + true, null); + crosstabGroupTotalHeaderHorizontalAlignmentTest(rowGroup, 0, HorizontalTextAlignEnum.CENTER); + + crosstabGroupHeaderStyleTest(columnGroup, 0, null, Color.LIGHT_GRAY, TEST_FONT_NAME, 12f, true, + null); + crosstabGroupTotalHeaderStyleTest(columnGroup, 0, null, Color.LIGHT_GRAY, TEST_FONT_NAME, 12f, + true, null); + crosstabGroupTotalHeaderHorizontalAlignmentTest(columnGroup, 0, HorizontalTextAlignEnum.CENTER); + + for (int i = 0; i < 4; i++) { + crosstabCellStyleTest(measure1, null, null, i, null, null, TEST_FONT_NAME, 10f, true, null); + } + for (int i = 0; i < 2; i++) { + crosstabCellStyleTest(measure1, rowGroup, null, i, null, Color.BLUE, TEST_FONT_NAME, 10f, + true, null); + crosstabCellStyleTest(measure1, null, columnGroup, i, null, Color.ORANGE, TEST_FONT_NAME, 10f, + true, null); + } + crosstabCellStyleTest(measure1, rowGroup, columnGroup, 0, null, Color.RED, TEST_FONT_NAME, 10f, + true, null); + + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("a", "c", 2); + dataSource.add("a", "d", 3); + dataSource.add("a", "d", 4); + dataSource.add("b", "c", 5); + dataSource.add("b", "c", 6); + dataSource.add("b", "d", 7); + dataSource.add("b", "d", 8); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle2Test.java new file mode 100644 index 0000000..21f8aae --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle2Test.java @@ -0,0 +1,133 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.awt.Color; +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * Crosstab style tests. + * + * @author Ricardo Mariaca + */ +public class CrosstabStyle2Test extends AbstractJasperCrosstabStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + FieldBuilder field1 = field("field1", String.class); + FieldBuilder field2 = field("field2", String.class); + + final StyleBuilder cellStyle = + stl.style().conditionalStyles(stl.conditionalStyle(new ConditionExpression(10, 15, 14, 36)) + .setBackgroundColor(Color.ORANGE)); + + rowGroup = ctab.rowGroup(field1); + columnGroup = ctab.columnGroup(field2); + + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + measure1.setStyle(cellStyle); + + CrosstabBuilder crosstab = + ctab.crosstab().rowGroups(rowGroup).columnGroups(columnGroup).measures(measure1); + + rb.summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + crosstabCellStyleTest(measure1, null, null, 0, null, null, TEST_FONT_NAME, 10f, null, null); + crosstabCellStyleTest(measure1, null, null, 1, null, null, TEST_FONT_NAME, 10f, null, null); + crosstabCellStyleTest(measure1, null, null, 2, null, null, TEST_FONT_NAME, 10f, null, null); + crosstabCellStyleTest(measure1, null, null, 3, null, Color.ORANGE, TEST_FONT_NAME, 10f, null, + null); + + crosstabCellStyleTest(measure1, rowGroup, null, 0, null, Color.ORANGE, TEST_FONT_NAME, 10f, + null, null); + crosstabCellStyleTest(measure1, rowGroup, null, 1, null, null, TEST_FONT_NAME, 10f, null, null); + + crosstabCellStyleTest(measure1, null, columnGroup, 0, null, Color.ORANGE, TEST_FONT_NAME, 10f, + null, null); + crosstabCellStyleTest(measure1, null, columnGroup, 1, null, null, TEST_FONT_NAME, 10f, null, + null); + + crosstabCellStyleTest(measure1, rowGroup, columnGroup, 0, null, Color.ORANGE, TEST_FONT_NAME, + 10f, null, null); + + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("a", "c", 2); + dataSource.add("a", "d", 3); + dataSource.add("a", "d", 4); + dataSource.add("b", "c", 5); + dataSource.add("b", "c", 6); + dataSource.add("b", "d", 7); + dataSource.add("b", "d", 8); + return dataSource; + } + + private class ConditionExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + private List values; + + private ConditionExpression(Integer... values) { + this.values = Arrays.asList(values); + } + + @Override + public Boolean evaluate(ReportParameters reportParameters) { + Integer value = reportParameters.getValue(measure1); + return values.contains(value); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle3Test.java new file mode 100644 index 0000000..8ebdd26 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle3Test.java @@ -0,0 +1,92 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; + +import java.awt.Color; +import java.io.Serializable; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * Crosstab style tests. + * + * @author Ricardo Mariaca + */ +public class CrosstabStyle3Test extends AbstractJasperCrosstabStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + FieldBuilder field1 = field("field1", String.class); + FieldBuilder field2 = field("field2", String.class); + + rowGroup = ctab.rowGroup(field1).setShowTotal(false); + columnGroup = ctab.columnGroup(field2).setShowTotal(false); + + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab().highlightEvenRows().highlightOddRows() + .rowGroups(rowGroup).columnGroups(columnGroup).measures(measure1); + + rb.summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + Color color1 = new Color(240, 240, 240); + Color color2 = new Color(200, 200, 200); + + crosstabCellStyleTest(measure1, null, null, 0, Color.BLACK, color2, TEST_FONT_NAME, 10f, null, + null); + crosstabCellStyleTest(measure1, null, null, 1, Color.BLACK, color1, TEST_FONT_NAME, 10f, null, + null); + crosstabCellStyleTest(measure1, null, null, 2, Color.BLACK, color2, TEST_FONT_NAME, 10f, null, + null); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("b", "c", 1); + dataSource.add("c", "c", 1); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle4Test.java new file mode 100644 index 0000000..cfccca7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle4Test.java @@ -0,0 +1,174 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.awt.Color; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * Crosstab style tests. + * + * @author Ricardo Mariaca + */ +public class CrosstabStyle4Test extends AbstractJasperCrosstabStyleTest { + private CrosstabRowGroupBuilder rowGroup1; + private CrosstabRowGroupBuilder rowGroup2; + private CrosstabColumnGroupBuilder columnGroup1; + private CrosstabColumnGroupBuilder columnGroup2; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + final FieldBuilder field1 = field("field1", String.class); + final FieldBuilder field2 = field("field2", String.class); + final FieldBuilder field3 = field("field3", String.class); + final FieldBuilder field4 = field("field4", String.class); + + rowGroup1 = ctab.rowGroup(field1); + rowGroup2 = ctab.rowGroup(field2); + columnGroup1 = ctab.columnGroup(field3); + columnGroup2 = ctab.columnGroup(field4); + + measure1 = ctab.measure("field5", Integer.class, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab().highlightEvenRows().setCellWidth(50) + .setEvenRowStyle(stl.simpleStyle().setBackgroundColor(Color.LIGHT_GRAY).bold()) + .setGroupStyle(stl.style(1).setBackgroundColor(Color.BLUE).bold()) + .setGroupTotalStyle(stl.style(1).setBackgroundColor(Color.RED)) + .setGrandTotalStyle(stl.style(1).setBackgroundColor(Color.MAGENTA).bold()) + .setCellStyle(stl.style().setBackgroundColor(Color.YELLOW).italic()) + .rowGroups(rowGroup1, rowGroup2).columnGroups(columnGroup1, columnGroup2) + .measures(measure1); + + rb.summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + final Color color1 = new Color(239, 239, 48); + final Color color2 = new Color(239, 48, 239); + final Color color3 = new Color(239, 48, 48); + + crosstabGroupHeaderStyleTest(rowGroup1, 0, null, Color.BLUE, TEST_FONT_NAME, 10f, true, null); + crosstabGroupTotalHeaderStyleTest(rowGroup1, 0, null, Color.MAGENTA, TEST_FONT_NAME, 10f, true, + null); + + crosstabGroupHeaderStyleTest(rowGroup2, 0, null, Color.BLUE, TEST_FONT_NAME, 10f, true, null); + crosstabGroupTotalHeaderStyleTest(rowGroup2, 0, null, Color.RED, TEST_FONT_NAME, 10f, null, + null); + + crosstabGroupHeaderStyleTest(columnGroup1, 0, null, Color.BLUE, TEST_FONT_NAME, 10f, true, + null); + crosstabGroupTotalHeaderStyleTest(columnGroup1, 0, null, Color.MAGENTA, TEST_FONT_NAME, 10f, + true, null); + + crosstabGroupHeaderStyleTest(columnGroup2, 0, null, Color.BLUE, TEST_FONT_NAME, 10f, true, + null); + crosstabGroupTotalHeaderStyleTest(columnGroup2, 0, null, Color.RED, TEST_FONT_NAME, 10f, null, + null); + + crosstabCellStyleTest(measure1, null, null, 0, null, Color.YELLOW, TEST_FONT_NAME, 10f, null, + true); + crosstabCellStyleTest(measure1, null, null, 1, null, Color.YELLOW, TEST_FONT_NAME, 10f, null, + true); + crosstabCellStyleTest(measure1, null, null, 2, null, color1, TEST_FONT_NAME, 10f, true, true); + crosstabCellStyleTest(measure1, null, null, 3, null, color1, TEST_FONT_NAME, 10f, true, true); + crosstabCellStyleTest(measure1, null, null, 4, null, Color.YELLOW, TEST_FONT_NAME, 10f, null, + true); + crosstabCellStyleTest(measure1, null, null, 5, null, Color.YELLOW, TEST_FONT_NAME, 10f, null, + true); + crosstabCellStyleTest(measure1, null, null, 6, null, color1, TEST_FONT_NAME, 10f, true, true); + crosstabCellStyleTest(measure1, null, null, 7, null, color1, TEST_FONT_NAME, 10f, true, true); + + crosstabCellStyleTest(measure1, rowGroup1, null, 0, null, Color.MAGENTA, TEST_FONT_NAME, 10f, + true, null); + crosstabCellStyleTest(measure1, rowGroup1, null, 1, null, Color.MAGENTA, TEST_FONT_NAME, 10f, + true, null); + + crosstabCellStyleTest(measure1, rowGroup2, null, 0, null, Color.RED, TEST_FONT_NAME, 10f, null, + null); + crosstabCellStyleTest(measure1, rowGroup2, null, 1, null, Color.RED, TEST_FONT_NAME, 10f, null, + null); + crosstabCellStyleTest(measure1, rowGroup2, null, 2, null, Color.RED, TEST_FONT_NAME, 10f, null, + null); + crosstabCellStyleTest(measure1, rowGroup2, null, 3, null, Color.RED, TEST_FONT_NAME, 10f, null, + null); + + crosstabCellStyleTest(measure1, null, columnGroup1, 0, null, Color.MAGENTA, TEST_FONT_NAME, 10f, + true, null); + crosstabCellStyleTest(measure1, null, columnGroup1, 1, null, color2, TEST_FONT_NAME, 10f, true, + null); + crosstabCellStyleTest(measure1, null, columnGroup1, 2, null, Color.MAGENTA, TEST_FONT_NAME, 10f, + true, null); + crosstabCellStyleTest(measure1, null, columnGroup1, 3, null, color2, TEST_FONT_NAME, 10f, true, + null); + + crosstabCellStyleTest(measure1, null, columnGroup2, 0, null, Color.RED, TEST_FONT_NAME, 10f, + null, null); + crosstabCellStyleTest(measure1, null, columnGroup2, 1, null, color3, TEST_FONT_NAME, 10f, true, + null); + crosstabCellStyleTest(measure1, null, columnGroup2, 2, null, Color.RED, TEST_FONT_NAME, 10f, + null, null); + crosstabCellStyleTest(measure1, null, columnGroup2, 3, null, color3, TEST_FONT_NAME, 10f, true, + null); + + crosstabCellStyleTest(measure1, rowGroup1, columnGroup1, 0, null, Color.MAGENTA, TEST_FONT_NAME, + 10f, true, null); + crosstabCellStyleTest(measure1, rowGroup1, columnGroup2, 0, null, Color.MAGENTA, TEST_FONT_NAME, + 10f, true, null); + + crosstabCellStyleTest(measure1, rowGroup2, columnGroup1, 0, null, Color.MAGENTA, TEST_FONT_NAME, + 10f, true, null); + crosstabCellStyleTest(measure1, rowGroup2, columnGroup2, 0, null, Color.RED, TEST_FONT_NAME, + 10f, null, null); + crosstabCellStyleTest(measure1, rowGroup2, columnGroup1, 1, null, Color.MAGENTA, TEST_FONT_NAME, + 10f, true, null); + crosstabCellStyleTest(measure1, rowGroup2, columnGroup2, 1, null, Color.RED, TEST_FONT_NAME, + 10f, null, null); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5"); + dataSource.add("a", "a", "a", "a", 1); + dataSource.add("a", "b", "a", "b", 1); + dataSource.add("b", "a", "a", "a", 1); + dataSource.add("b", "b", "a", "b", 1); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle5Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle5Test.java new file mode 100644 index 0000000..9385668 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle5Test.java @@ -0,0 +1,116 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.awt.Color; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * Crosstab style tests. + * + * @author Ricardo Mariaca + */ +public class CrosstabStyle5Test extends AbstractJasperCrosstabStyleTest { + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup1; + private CrosstabColumnGroupBuilder columnGroup2; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + final FieldBuilder field1 = field("field1", String.class); + final FieldBuilder field2 = field("field2", String.class); + final StyleBuilder headerStyle = stl.style().setBackgroundColor(Color.LIGHT_GRAY); + final StyleBuilder cellStyle = stl.style().bold(); + final StyleBuilder titleStyle = stl.style(cellStyle).setBackgroundColor(Color.BLUE); + + rowGroup = ctab.rowGroup(field1).setHeaderStyle(headerStyle).setTotalHeaderStyle(headerStyle); + columnGroup1 = + ctab.columnGroup(field1).setHeaderStyle(headerStyle).setTotalHeaderStyle(headerStyle); + columnGroup2 = + ctab.columnGroup(field2).setHeaderStyle(headerStyle).setTotalHeaderStyle(headerStyle); + + measure1 = ctab.measure("m1", "field3", Integer.class, Calculation.SUM); + measure1.setTitleStyle(titleStyle); + measure2 = ctab.measure("m2", "field3", Integer.class, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab().setCellWidth(50).highlightEvenRows() + .setGroupTotalStyle(stl.style().setBackgroundColor(Color.RED)).rowGroups(rowGroup) + .columnGroups(columnGroup1, columnGroup2).measures(measure1, measure2); + + rb.summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + crosstabGroupTitleTotalHeaderStyleTest(columnGroup1, measure1, 0, null, Color.BLUE, + TEST_FONT_NAME, 10f, true, null); + crosstabGroupTitleTotalHeaderStyleTest(columnGroup1, measure2, 0, null, Color.LIGHT_GRAY, + TEST_FONT_NAME, 10f, null, null); + + crosstabGroupTitleHeaderStyleTest(columnGroup2, measure1, 0, null, Color.BLUE, TEST_FONT_NAME, + 10f, true, null); + crosstabGroupTitleTotalHeaderStyleTest(columnGroup2, measure1, 0, null, Color.BLUE, + TEST_FONT_NAME, 10f, true, null); + crosstabGroupTitleHeaderStyleTest(columnGroup2, measure2, 0, null, Color.LIGHT_GRAY, + TEST_FONT_NAME, 10f, null, null); + crosstabGroupTitleTotalHeaderStyleTest(columnGroup2, measure2, 0, null, Color.LIGHT_GRAY, + TEST_FONT_NAME, 10f, null, null); + + crosstabCellStyleTest(measure1, rowGroup, null, 0, null, Color.RED, TEST_FONT_NAME, 10f, null, + null); + crosstabCellStyleTest(measure1, rowGroup, null, 1, null, Color.RED, TEST_FONT_NAME, 10f, null, + null); + crosstabCellStyleTest(measure1, rowGroup, columnGroup1, 0, null, Color.RED, TEST_FONT_NAME, 10f, + null, null); + crosstabCellStyleTest(measure1, rowGroup, columnGroup2, 0, null, Color.RED, TEST_FONT_NAME, 10f, + null, null); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("a", "c", 2); + dataSource.add("a", "d", 3); + dataSource.add("a", "d", 4); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle6Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle6Test.java new file mode 100644 index 0000000..c5555c1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabStyle6Test.java @@ -0,0 +1,111 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.awt.Color; +import java.io.Serializable; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.style.ConditionalStyleBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * Crosstab style tests. + * + * @author Ricardo Mariaca + */ +public class CrosstabStyle6Test extends AbstractJasperCrosstabStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + FieldBuilder field1 = field("field1", String.class); + FieldBuilder field2 = field("field2", String.class); + + rowGroup = ctab.rowGroup(field1).setShowTotal(false); + columnGroup = ctab.columnGroup(field2).setShowTotal(false); + + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + + ConditionalStyleBuilder condition = stl.conditionalStyle(new ConditionExpression()) + .setBackgroundColor(new Color(200, 200, 200)); + + StyleBuilder style = stl.style().conditionalStyles(condition); + + measure1.setStyle(style); + + CrosstabBuilder crosstab = ctab.crosstab().highlightEvenRows().rowGroups(rowGroup) + .columnGroups(columnGroup).measures(measure1).setDataSource(createDataSource1()); + + rb.summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + Color color1 = new Color(240, 240, 240); + Color color2 = new Color(200, 200, 200); + + crosstabCellStyleTest(measure1, null, null, 0, null, color2, TEST_FONT_NAME, 10f, null, null); + crosstabCellStyleTest(measure1, null, null, 1, null, color1, TEST_FONT_NAME, 10f, null, null); + crosstabCellStyleTest(measure1, null, null, 2, null, color2, TEST_FONT_NAME, 10f, null, null); + } + + protected JRDataSource createDataSource1() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("b", "c", 1); + dataSource.add("c", "c", 1); + return dataSource; + } + + private class ConditionExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Boolean evaluate(ReportParameters reportParameters) { + return reportParameters.getCrosstabRowNumber() == 1 + || reportParameters.getCrosstabRowNumber() == 3; + } + + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabTest.java new file mode 100644 index 0000000..ba05544 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabTest.java @@ -0,0 +1,77 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.test.jasper.AbstractJasperTest; +import net.sf.jasperreports.crosstabs.base.JRBaseCrosstab; +import net.sf.jasperreports.crosstabs.type.CrosstabColumnPositionEnum; +import net.sf.jasperreports.crosstabs.type.CrosstabRowPositionEnum; +import net.sf.jasperreports.engine.type.RunDirectionEnum; + + +/** + * @author Ricardo Mariaca + */ +class CrosstabTest extends AbstractJasperTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + final TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + final TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + final TextColumnBuilder column3 = col.column("Column3", "field3", Integer.class); + + final CrosstabBuilder crosstab = ctab.crosstab() + .setRepeatColumnHeaders(false) + .setRepeatRowHeaders(false) + .setColumnBreakOffset(100) + .setIgnoreWidth(true) + .setRunDirection(RunDirection.RIGHT_TO_LEFT) + .rowGroups(ctab.rowGroup(column1)) + .columnGroups(ctab.columnGroup(column2)) + .measures(ctab.measure(column3, Calculation.SUM)); + + rb.columns(column1, column2, column3).summary(crosstab); + } + + @Override + public void test() + { + super.test(); + + final JRBaseCrosstab crosstab = (JRBaseCrosstab)this.getJasperReport().getSummary().getElementByKey("summary.crosstab1"); + Assertions.assertFalse(crosstab.isRepeatColumnHeaders()); + Assertions.assertFalse(crosstab.isRepeatRowHeaders()); + Assertions.assertEquals(100, crosstab.getColumnBreakOffset()); + Assertions.assertTrue(crosstab.getIgnoreWidth()); + Assertions.assertEquals(RunDirectionEnum.RTL, crosstab.getRunDirectionValue()); + Assertions.assertEquals(CrosstabRowPositionEnum.STRETCH, crosstab.getRowGroups()[0].getPositionValue()); + Assertions.assertEquals(CrosstabColumnPositionEnum.STRETCH, crosstab.getColumnGroups()[0].getPositionValue()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabWhenNoDataTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabWhenNoDataTest.java new file mode 100644 index 0000000..fe646b7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/CrosstabWhenNoDataTest.java @@ -0,0 +1,63 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabWhenNoDataTest extends AbstractJasperCrosstabPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + TextColumnBuilder column3 = col.column("Column3", "field3", Integer.class); + TextColumnBuilder column4 = col.column("Column4", "field4", Double.class); + + CrosstabBuilder crosstab = ctab.crosstab() + .whenNoDataCell(cmp.text("text"), cmp.text("text")) + .rowGroups(ctab.rowGroup(column1)) + .columnGroups(ctab.columnGroup(column2)) + .measures(ctab.measure(column3, Calculation.SUM), ctab.measure(column4, Calculation.SUM)); + + rb.setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL).columns(column1, column2, column3, column4).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + crosstabWhenNoDataElementPositionTest("textField1", 0, 0, 0, 575, 16); + crosstabWhenNoDataElementPositionTest("textField2", 0, 0, 16, 575, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/ExpressionCrosstabTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/ExpressionCrosstabTest.java new file mode 100644 index 0000000..ba53354 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/ExpressionCrosstabTest.java @@ -0,0 +1,153 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class ExpressionCrosstabTest extends AbstractJasperCrosstabValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabVariableBuilder variable1; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + private CrosstabMeasureBuilder measure3; + + @Override + protected void configureReport(JasperReportBuilder rb) { + variable1 = ctab.variable("field4", Integer.class, Calculation.SUM); + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + measure2 = ctab.measure(new MeasureExpression1(), Calculation.SUM); + measure3 = ctab.measure(new MeasureExpression2()); + + CrosstabBuilder crosstab = ctab.crosstab() + .rowGroups(rowGroup = ctab.rowGroup("field1", String.class)) + .columnGroups(columnGroup = ctab.columnGroup("field2", String.class)) + .variables(variable1) + .measures(measure1, measure2, measure3); + + rb.setLocale(Locale.ENGLISH).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group + crosstabGroupHeaderCountTest(columnGroup, 2); + crosstabGroupHeaderValueTest(columnGroup, "c", "d"); + crosstabGroupTotalHeaderCountTest(columnGroup, 1); + crosstabGroupTotalHeaderValueTest(columnGroup, "Total"); + + // row group + crosstabGroupHeaderCountTest(rowGroup, 2); + crosstabGroupHeaderValueTest(rowGroup, "a", "b"); + crosstabGroupTotalHeaderCountTest(rowGroup, 1); + crosstabGroupTotalHeaderValueTest(rowGroup, "Total"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 4); + crosstabCellValueTest(measure1, null, null, "15", "11", "7", "3"); + crosstabCellCountTest(measure1, null, columnGroup, 2); + crosstabCellValueTest(measure1, null, columnGroup, "26", "10"); + crosstabCellCountTest(measure1, rowGroup, null, 2); + crosstabCellValueTest(measure1, rowGroup, null, "22", "14"); + crosstabCellCountTest(measure1, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure1, rowGroup, columnGroup, "36"); + + // measure2 + crosstabCellCountTest(measure2, null, null, 4); + crosstabCellValueTest(measure2, null, null, "15.0", "11.0", "7.0", "3.0"); + crosstabCellCountTest(measure2, null, columnGroup, 2); + crosstabCellValueTest(measure2, null, columnGroup, "26.0", "10.0"); + crosstabCellCountTest(measure2, rowGroup, null, 2); + crosstabCellValueTest(measure2, rowGroup, null, "22.0", "14.0"); + crosstabCellCountTest(measure2, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure2, rowGroup, columnGroup, "36.0"); + + // measure3 + crosstabCellCountTest(measure3, null, null, 4); + crosstabCellValueTest(measure3, null, null, "7.5", "5.5", "3.5", "1.5"); + crosstabCellCountTest(measure3, null, columnGroup, 2); + crosstabCellValueTest(measure3, null, columnGroup, "6.5", "2.5"); + crosstabCellCountTest(measure3, rowGroup, null, 2); + crosstabCellValueTest(measure3, rowGroup, null, "5.5", "3.5"); + crosstabCellCountTest(measure3, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure3, rowGroup, columnGroup, "4.5"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add("a", "c", 8, 1); + dataSource.add("a", "c", 7, 1); + dataSource.add("a", "d", 6, 1); + dataSource.add("a", "d", 5, 1); + dataSource.add("b", "c", 4, 1); + dataSource.add("b", "c", 3, 1); + dataSource.add("b", "d", 2, 1); + dataSource.add("b", "d", 1, 1); + return dataSource; + } + + private class MeasureExpression1 extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Double evaluate(ReportParameters reportParameters) { + Integer value1 = reportParameters.getValue("field3"); + Integer value2 = reportParameters.getValue("field4"); + return value1.doubleValue() / value2.doubleValue(); + } + } + + private class MeasureExpression2 extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Double evaluate(ReportParameters reportParameters) { + Integer value1 = reportParameters.getValue(measure1); + Integer value2 = reportParameters.getValue(variable1); + return value1.doubleValue() / value2.doubleValue(); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/GroupExpressionCrosstabTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/GroupExpressionCrosstabTest.java new file mode 100644 index 0000000..2e69fe0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/GroupExpressionCrosstabTest.java @@ -0,0 +1,183 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; + +/** + * @author Ricardo Mariaca + */ +public class GroupExpressionCrosstabTest extends AbstractJasperCrosstabValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup1; + private CrosstabColumnGroupBuilder columnGroup2; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab() + .setCellWidth(50) + .rowGroups(rowGroup = ctab.rowGroup("field1", String.class)) + .columnGroups(columnGroup1 = ctab.columnGroup(new GroupExpression1()), columnGroup2 = ctab.columnGroup(new GroupExpression2())) + .measures(measure1); + + rb.setLocale(Locale.ENGLISH).setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).fields(field("field2", Date.class)).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group 1 + crosstabGroupHeaderCountTest(columnGroup1, 2); + crosstabGroupHeaderValueTest(columnGroup1, "2010", "2011"); + crosstabGroupTotalHeaderCountTest(columnGroup1, 1); + crosstabGroupTotalHeaderValueTest(columnGroup1, "Total"); + + // column group 2 + crosstabGroupHeaderCountTest(columnGroup2, 5); + crosstabGroupHeaderValueTest(columnGroup2, "Q1", "Q2", "Q3", "Q4", "Q1"); + crosstabGroupTotalHeaderCountTest(columnGroup2, 2); + crosstabGroupTotalHeaderValueTest(columnGroup2, "Total", "Total"); + + // row group + crosstabGroupHeaderCountTest(rowGroup, 2); + crosstabGroupHeaderValueTest(rowGroup, "a", "b"); + crosstabGroupTotalHeaderCountTest(rowGroup, 1); + crosstabGroupTotalHeaderValueTest(rowGroup, "Total"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 10); + crosstabCellValueTest(measure1, null, null, "6", "15", "24", "33", "27", "39", "30", "21", "12", "3"); + crosstabCellCountTest(measure1, null, columnGroup1, 2); + crosstabCellValueTest(measure1, null, columnGroup1, "105", "105"); + crosstabCellCountTest(measure1, null, columnGroup2, 4); + crosstabCellValueTest(measure1, null, columnGroup2, "78", "27", "102", "3"); + crosstabCellCountTest(measure1, rowGroup, null, 5); + crosstabCellValueTest(measure1, rowGroup, null, "45", "45", "45", "45", "30"); + crosstabCellCountTest(measure1, rowGroup, columnGroup1, 1); + crosstabCellValueTest(measure1, rowGroup, columnGroup1, "210"); + crosstabCellCountTest(measure1, rowGroup, columnGroup2, 2); + crosstabCellValueTest(measure1, rowGroup, columnGroup2, "180", "30"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", toDate(2010, 1, 1), 1); + dataSource.add("a", toDate(2010, 2, 1), 2); + dataSource.add("a", toDate(2010, 3, 1), 3); + dataSource.add("a", toDate(2010, 4, 1), 4); + dataSource.add("a", toDate(2010, 5, 1), 5); + dataSource.add("a", toDate(2010, 6, 1), 6); + dataSource.add("a", toDate(2010, 7, 1), 7); + dataSource.add("a", toDate(2010, 8, 1), 8); + dataSource.add("a", toDate(2010, 9, 1), 9); + dataSource.add("a", toDate(2010, 10, 1), 10); + dataSource.add("a", toDate(2010, 11, 1), 11); + dataSource.add("a", toDate(2010, 12, 1), 12); + dataSource.add("a", toDate(2011, 1, 1), 13); + dataSource.add("a", toDate(2011, 2, 1), 14); + + dataSource.add("b", toDate(2010, 1, 1), 14); + dataSource.add("b", toDate(2010, 2, 1), 13); + dataSource.add("b", toDate(2010, 3, 1), 12); + dataSource.add("b", toDate(2010, 4, 1), 11); + dataSource.add("b", toDate(2010, 5, 1), 10); + dataSource.add("b", toDate(2010, 6, 1), 9); + dataSource.add("b", toDate(2010, 7, 1), 8); + dataSource.add("b", toDate(2010, 8, 1), 7); + dataSource.add("b", toDate(2010, 9, 1), 6); + dataSource.add("b", toDate(2010, 10, 1), 5); + dataSource.add("b", toDate(2010, 11, 1), 4); + dataSource.add("b", toDate(2010, 12, 1), 3); + dataSource.add("b", toDate(2011, 1, 1), 2); + dataSource.add("b", toDate(2011, 2, 1), 1); + return dataSource; + } + + private class GroupExpression1 extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Integer evaluate(ReportParameters reportParameters) { + Date date = reportParameters.getValue("field2"); + Calendar c = Calendar.getInstance(); + c.setTime(date); + return c.get(Calendar.YEAR); + } + } + + private class GroupExpression2 extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public String evaluate(ReportParameters reportParameters) { + Date date = reportParameters.getValue("field2"); + Calendar c = Calendar.getInstance(); + c.setTime(date); + switch (c.get(Calendar.MONTH)) { + case 0: + case 1: + case 2: + return "Q1"; + case 3: + case 4: + case 5: + return "Q2"; + case 6: + case 7: + case 8: + return "Q3"; + case 9: + case 10: + case 11: + return "Q4"; + } + return null; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/HyperLinkCrosstabTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/HyperLinkCrosstabTest.java new file mode 100644 index 0000000..977a3dd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/HyperLinkCrosstabTest.java @@ -0,0 +1,161 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.hyperLink; + +import java.io.Serializable; +import java.util.List; +import java.util.Locale; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.expression.AbstractComplexExpression; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import software.xdev.dynamicreports.test.jasper.JasperTestUtils; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRPrintElement; +import net.sf.jasperreports.engine.JRPrintText; + + +/** + * @author Ricardo Mariaca + */ +public class HyperLinkCrosstabTest extends AbstractJasperCrosstabValueTest implements Serializable +{ + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure; + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + this.rowGroup = ctab.rowGroup("field1", String.class); + this.rowGroup.setHeaderHyperLink(hyperLink(new HyperLinkExpression1(this.rowGroup))); + this.columnGroup = ctab.columnGroup("field2", String.class); + this.columnGroup.setHeaderHyperLink(hyperLink(new HyperLinkExpression1(this.columnGroup))); + this.measure = ctab.measure("field3", Integer.class, Calculation.SUM); + this.measure.setHyperLink(hyperLink(new HyperLinkExpression2(this.rowGroup, this.columnGroup, this.measure))); + + final CrosstabBuilder crosstab = ctab.crosstab().rowGroups(this.rowGroup).columnGroups(this.columnGroup).measures( + this.measure); + + rb.setLocale(Locale.ENGLISH).summary(crosstab); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + this.setCrosstabBand("summary"); + + List elements = + this.findElement(this.getPrefix(1) + JasperTestUtils.getCrosstabGroupHeaderName(this.rowGroup)); + Assertions.assertEquals(2, elements.size()); + JRPrintText element = (JRPrintText)elements.get(0); + Assertions.assertEquals("a", element.getHyperlinkReference()); + element = (JRPrintText)elements.get(1); + Assertions.assertEquals("b", element.getHyperlinkReference()); + + elements = this.findElement(this.getPrefix(1) + JasperTestUtils.getCrosstabGroupHeaderName(this.columnGroup)); + Assertions.assertEquals(2, elements.size()); + element = (JRPrintText)elements.get(0); + Assertions.assertEquals("c", element.getHyperlinkReference()); + element = (JRPrintText)elements.get(1); + Assertions.assertEquals( "d", element.getHyperlinkReference()); + + elements = this.findElement(this.getPrefix(1) + JasperTestUtils.getCrosstabCellName(this.measure, null, null)); + Assertions.assertEquals(4, elements.size()); + element = (JRPrintText)elements.get(0); + Assertions.assertEquals("a c 3", element.getHyperlinkReference()); + element = (JRPrintText)elements.get(1); + Assertions.assertEquals("a d 7", element.getHyperlinkReference()); + element = (JRPrintText)elements.get(2); + Assertions.assertEquals("b c 11", element.getHyperlinkReference()); + element = (JRPrintText)elements.get(3); + Assertions.assertEquals("b d 15", element.getHyperlinkReference()); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("a", "c", 2); + dataSource.add("a", "d", 3); + dataSource.add("a", "d", 4); + dataSource.add("b", "c", 5); + dataSource.add("b", "c", 6); + dataSource.add("b", "d", 7); + dataSource.add("b", "d", 8); + return dataSource; + } + + private static class HyperLinkExpression1 extends AbstractComplexExpression + { + private static final long serialVersionUID = 1L; + + public HyperLinkExpression1(final AbstractCrosstabGroupBuilder group) + { + this.addExpression(group); + } + + @Override + public String evaluate(final List values, final ReportParameters reportParameters) + { + return (String)values.get(0); + } + } + + + private class HyperLinkExpression2 extends AbstractComplexExpression + { + private static final long serialVersionUID = 1L; + + public HyperLinkExpression2( + final AbstractCrosstabGroupBuilder group1, + final AbstractCrosstabGroupBuilder group2, + final CrosstabMeasureBuilder measure) + { + this.addExpression(group1); + this.addExpression(group2); + this.addExpression(measure); + } + + @Override + public String evaluate(final List values, final ReportParameters reportParameters) + { + return values.get(0) + " " + values.get(1) + " " + values.get(2); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/OrderCrosstabTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/OrderCrosstabTest.java new file mode 100644 index 0000000..6135955 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/crosstab/OrderCrosstabTest.java @@ -0,0 +1,97 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.crosstab; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.OrderType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class OrderCrosstabTest extends AbstractJasperCrosstabValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab() + .rowGroups(rowGroup = ctab.rowGroup("field1", String.class).setOrderType(OrderType.DESCENDING).setShowTotal(false)) + .columnGroups(columnGroup = ctab.columnGroup("field2", String.class).setShowTotal(false).orderBy(measure1).setOrderType(OrderType.DESCENDING)) + .measures(measure1); + + rb.setLocale(Locale.ENGLISH).summary(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("summary"); + + // column group + crosstabGroupHeaderCountTest(columnGroup, 2); + crosstabGroupHeaderValueTest(columnGroup, "c", "d"); + crosstabGroupTotalHeaderCountTest(columnGroup, 0); + + // row group + crosstabGroupHeaderCountTest(rowGroup, 2); + crosstabGroupHeaderValueTest(rowGroup, "b", "a"); + crosstabGroupTotalHeaderCountTest(rowGroup, 0); + + // measure1 + crosstabCellCountTest(measure1, null, null, 4); + crosstabCellValueTest(measure1, null, null, "7", "3", "15", "11"); + crosstabCellCountTest(measure1, null, columnGroup, 0); + crosstabCellCountTest(measure1, rowGroup, null, 0); + crosstabCellCountTest(measure1, rowGroup, columnGroup, 0); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 8); + dataSource.add("a", "c", 7); + dataSource.add("a", "d", 6); + dataSource.add("a", "d", 5); + dataSource.add("b", "c", 4); + dataSource.add("b", "c", 3); + dataSource.add("b", "d", 2); + dataSource.add("b", "d", 1); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDataset1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDataset1Test.java new file mode 100644 index 0000000..ab61853 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDataset1Test.java @@ -0,0 +1,153 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.dataset; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabDataset1Test extends AbstractJasperCrosstabValueTest { + private CrosstabRowGroupBuilder rowGroup1; + private CrosstabRowGroupBuilder rowGroup2; + private CrosstabColumnGroupBuilder columnGroup1; + private CrosstabColumnGroupBuilder columnGroup2; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + FieldBuilder field1 = field("field1", String.class); + FieldBuilder field2 = field("field2", String.class); + FieldBuilder field3 = field("field3", String.class); + FieldBuilder field4 = field("field4", String.class); + FieldBuilder field5 = field("field5", Integer.class); + + measure1 = ctab.measure("measure1", field5, Calculation.SUM); + measure2 = ctab.measure("measure2", field5, Calculation.SUM); + + CrosstabBuilder crosstab = ctab.crosstab() + .setDataSource(createCrosstabDataSource()) + .headerCell(cmp.text("Header")) + .setCellWidth(20) + .rowGroups(rowGroup1 = ctab.rowGroup(field1), rowGroup2 = ctab.rowGroup(field2)) + .columnGroups(columnGroup1 = ctab.columnGroup(field3), columnGroup2 = ctab.columnGroup(field4)) + .measures(measure1, measure2); + + rb.setLocale(Locale.ENGLISH).setPageFormat(PageType.A3, PageOrientation.LANDSCAPE).title(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("title"); + + crosstabHeaderElementCountTest("textField1", 1); + crosstabHeaderElementValueTest("textField1", "Header"); + + // column group + crosstabGroupHeaderCountTest(columnGroup1, 2); + crosstabGroupHeaderValueTest(columnGroup1, "g", "h"); + crosstabGroupTotalHeaderCountTest(columnGroup1, 1); + crosstabGroupTotalHeaderValueTest(columnGroup1, "Total"); + crosstabGroupHeaderCountTest(columnGroup2, 4); + crosstabGroupHeaderValueTest(columnGroup2, "i", "j", "k", "l"); + crosstabGroupTotalHeaderCountTest(columnGroup2, 2); + crosstabGroupTotalHeaderValueTest(columnGroup2, "Total", "Total"); + + // column group title + crosstabGroupTitleHeaderCountTest(columnGroup1, measure1, 0); + crosstabGroupTitleTotalHeaderCountTest(columnGroup1, measure1, 1); + crosstabGroupTitleTotalHeaderValueTest(columnGroup1, measure1, "measure1"); + crosstabGroupTitleHeaderCountTest(columnGroup2, measure1, 4); + crosstabGroupTitleHeaderValueTest(columnGroup2, measure1, "measure1", "measure1", "measure1", "measure1"); + crosstabGroupTitleTotalHeaderCountTest(columnGroup2, measure1, 2); + crosstabGroupTitleTotalHeaderValueTest(columnGroup2, measure1, "measure1", "measure1"); + + crosstabGroupTitleHeaderCountTest(columnGroup1, measure2, 0); + crosstabGroupTitleTotalHeaderCountTest(columnGroup1, measure2, 1); + crosstabGroupTitleTotalHeaderValueTest(columnGroup1, measure2, "measure2"); + crosstabGroupTitleHeaderCountTest(columnGroup2, measure2, 4); + crosstabGroupTitleHeaderValueTest(columnGroup2, measure2, "measure2", "measure2", "measure2", "measure2"); + crosstabGroupTitleTotalHeaderCountTest(columnGroup2, measure2, 2); + crosstabGroupTitleTotalHeaderValueTest(columnGroup2, measure2, "measure2", "measure2"); + + // row group + crosstabGroupHeaderCountTest(rowGroup1, 2); + crosstabGroupHeaderValueTest(rowGroup1, "a", "b"); + crosstabGroupTotalHeaderCountTest(rowGroup1, 1); + crosstabGroupTotalHeaderValueTest(rowGroup1, "Total"); + crosstabGroupHeaderCountTest(rowGroup2, 4); + crosstabGroupHeaderValueTest(rowGroup2, "c", "d", "e", "f"); + crosstabGroupTotalHeaderCountTest(rowGroup2, 2); + crosstabGroupTotalHeaderValueTest(rowGroup2, "Total", "Total"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 16); + crosstabCellValueTest(measure1, null, null, "1", "2", "0", "0", "3", "4", "0", "0", "0", "0", "5", "6", "0", "0", "7", "8"); + crosstabCellCountTest(measure1, null, columnGroup1, 4); + crosstabCellValueTest(measure1, null, columnGroup1, "3", "7", "11", "15"); + crosstabCellCountTest(measure1, null, columnGroup2, 8); + crosstabCellValueTest(measure1, null, columnGroup2, "3", "0", "7", "0", "0", "11", "0", "15"); + crosstabCellCountTest(measure1, rowGroup1, null, 4); + crosstabCellValueTest(measure1, rowGroup1, null, "4", "6", "12", "14"); + crosstabCellCountTest(measure1, rowGroup2, null, 8); + crosstabCellValueTest(measure1, rowGroup2, null, "4", "6", "0", "0", "0", "0", "12", "14"); + crosstabCellCountTest(measure1, rowGroup1, columnGroup1, 1); + crosstabCellValueTest(measure1, rowGroup1, columnGroup1, "36"); + crosstabCellCountTest(measure1, rowGroup2, columnGroup2, 4); + crosstabCellValueTest(measure1, rowGroup2, columnGroup2, "10", "0", "0", "26"); + crosstabCellCountTest(measure1, rowGroup1, columnGroup2, 2); + crosstabCellValueTest(measure1, rowGroup1, columnGroup2, "10", "26"); + crosstabCellCountTest(measure1, rowGroup2, columnGroup1, 2); + crosstabCellValueTest(measure1, rowGroup2, columnGroup1, "10", "26"); + } + + private JRDataSource createCrosstabDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5"); + dataSource.add("a", "c", "g", "i", 1); + dataSource.add("a", "c", "g", "j", 2); + dataSource.add("a", "d", "g", "i", 3); + dataSource.add("a", "d", "g", "j", 4); + dataSource.add("b", "e", "h", "k", 5); + dataSource.add("b", "e", "h", "l", 6); + dataSource.add("b", "f", "h", "k", 7); + dataSource.add("b", "f", "h", "l", 8); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDataset2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDataset2Test.java new file mode 100644 index 0000000..57781a7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDataset2Test.java @@ -0,0 +1,137 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.dataset; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractValueFormatter; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabDataset2Test extends AbstractJasperCrosstabValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + measure1.setValueFormatter(new ValueFormatter1()); + + CrosstabBuilder crosstab = ctab.crosstab() + .setDataSource(createCrosstabDataSource()) + .rowGroups(rowGroup = ctab.rowGroup("field1", String.class).setHeaderValueFormatter(new ValueFormatter2())) + .columnGroups(columnGroup = ctab.columnGroup("field2", String.class).setHeaderValueFormatter(new ValueFormatter2())) + .measures(measure1); + + rb.setLocale(Locale.ENGLISH).addParameter("parameter", "parameter_value").title(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("title"); + + // column group + crosstabGroupHeaderCountTest(columnGroup, 2); + crosstabGroupHeaderValueTest(columnGroup, "value = c", "value = d"); + crosstabGroupTotalHeaderCountTest(columnGroup, 1); + crosstabGroupTotalHeaderValueTest(columnGroup, "Total"); + + // row group + crosstabGroupHeaderCountTest(rowGroup, 2); + crosstabGroupHeaderValueTest(rowGroup, "value = a", "value = b"); + crosstabGroupTotalHeaderCountTest(rowGroup, 1); + crosstabGroupTotalHeaderValueTest(rowGroup, "Total"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 4); + crosstabCellValueTest(measure1, null, null, "value = 3", "value = 7", "value = 11", "value = 15"); + crosstabCellCountTest(measure1, null, columnGroup, 2); + crosstabCellValueTest(measure1, null, columnGroup, "value = 10", "value = 26"); + crosstabCellCountTest(measure1, rowGroup, null, 2); + crosstabCellValueTest(measure1, rowGroup, null, "value = 14", "value = 22"); + crosstabCellCountTest(measure1, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure1, rowGroup, columnGroup, "value = 36"); + } + + private JRDataSource createCrosstabDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("a", "c", 2); + dataSource.add("a", "d", 3); + dataSource.add("a", "d", 4); + dataSource.add("b", "c", 5); + dataSource.add("b", "c", 6); + dataSource.add("b", "d", 7); + dataSource.add("b", "d", 8); + return dataSource; + } + + private class ValueFormatter1 extends AbstractValueFormatter { + private static final long serialVersionUID = 1L; + + @Override + public String format(Integer value, ReportParameters reportParameters) { + Assertions.assertNotNull(reportParameters.getMasterParameters()); + try { + reportParameters.getValue("parameter"); + Assertions.fail("parameter is not null"); + } catch (Exception e) { + } + Assertions.assertEquals("parameter_value", reportParameters.getMasterParameters().getValue("parameter")); + return "value = " + value; + } + } + + private class ValueFormatter2 extends AbstractValueFormatter { + private static final long serialVersionUID = 1L; + + @Override + public String format(String value, ReportParameters reportParameters) { + Assertions.assertNotNull(reportParameters.getMasterParameters()); + try { + reportParameters.getValue("parameter"); + Assertions.fail("parameter is not null"); + } catch (Exception e) { + } + Assertions.assertEquals("parameter_value", reportParameters.getMasterParameters().getValue("parameter")); + return "value = " + value; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDataset3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDataset3Test.java new file mode 100644 index 0000000..436e0db --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDataset3Test.java @@ -0,0 +1,168 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.dataset; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabVariableBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; + +/** + * @author Ricardo Mariaca + */ +public class CrosstabDataset3Test extends AbstractJasperCrosstabValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabVariableBuilder variable1; + private CrosstabMeasureBuilder measure1; + private CrosstabMeasureBuilder measure2; + private CrosstabMeasureBuilder measure3; + + @Override + protected void configureReport(JasperReportBuilder rb) { + variable1 = ctab.variable("field4", Integer.class, Calculation.SUM); + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + measure2 = ctab.measure(new MeasureExpression1(), Calculation.SUM); + measure3 = ctab.measure(new MeasureExpression2()); + + CrosstabBuilder crosstab = ctab.crosstab() + .setDataSource(createCrosstabDataSource()) + .rowGroups(rowGroup = ctab.rowGroup("field1", String.class)) + .columnGroups(columnGroup = ctab.columnGroup("field2", String.class)) + .variables(variable1) + .measures(measure1, measure2, measure3); + + rb.setLocale(Locale.ENGLISH).addParameter("parameter", "parameter_value").title(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("title"); + + // column group + crosstabGroupHeaderCountTest(columnGroup, 2); + crosstabGroupHeaderValueTest(columnGroup, "c", "d"); + crosstabGroupTotalHeaderCountTest(columnGroup, 1); + crosstabGroupTotalHeaderValueTest(columnGroup, "Total"); + + // row group + crosstabGroupHeaderCountTest(rowGroup, 2); + crosstabGroupHeaderValueTest(rowGroup, "a", "b"); + crosstabGroupTotalHeaderCountTest(rowGroup, 1); + crosstabGroupTotalHeaderValueTest(rowGroup, "Total"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 4); + crosstabCellValueTest(measure1, null, null, "15", "11", "7", "3"); + crosstabCellCountTest(measure1, null, columnGroup, 2); + crosstabCellValueTest(measure1, null, columnGroup, "26", "10"); + crosstabCellCountTest(measure1, rowGroup, null, 2); + crosstabCellValueTest(measure1, rowGroup, null, "22", "14"); + crosstabCellCountTest(measure1, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure1, rowGroup, columnGroup, "36"); + + // measure2 + crosstabCellCountTest(measure2, null, null, 4); + crosstabCellValueTest(measure2, null, null, "15.0", "11.0", "7.0", "3.0"); + crosstabCellCountTest(measure2, null, columnGroup, 2); + crosstabCellValueTest(measure2, null, columnGroup, "26.0", "10.0"); + crosstabCellCountTest(measure2, rowGroup, null, 2); + crosstabCellValueTest(measure2, rowGroup, null, "22.0", "14.0"); + crosstabCellCountTest(measure2, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure2, rowGroup, columnGroup, "36.0"); + + // measure3 + crosstabCellCountTest(measure3, null, null, 4); + crosstabCellValueTest(measure3, null, null, "7.5", "5.5", "3.5", "1.5"); + crosstabCellCountTest(measure3, null, columnGroup, 2); + crosstabCellValueTest(measure3, null, columnGroup, "6.5", "2.5"); + crosstabCellCountTest(measure3, rowGroup, null, 2); + crosstabCellValueTest(measure3, rowGroup, null, "5.5", "3.5"); + crosstabCellCountTest(measure3, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure3, rowGroup, columnGroup, "4.5"); + } + + private JRDataSource createCrosstabDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add("a", "c", 8, 1); + dataSource.add("a", "c", 7, 1); + dataSource.add("a", "d", 6, 1); + dataSource.add("a", "d", 5, 1); + dataSource.add("b", "c", 4, 1); + dataSource.add("b", "c", 3, 1); + dataSource.add("b", "d", 2, 1); + dataSource.add("b", "d", 1, 1); + return dataSource; + } + + private class MeasureExpression1 extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Double evaluate(ReportParameters reportParameters) { + Assertions.assertNotNull(reportParameters.getMasterParameters()); + try { + reportParameters.getValue("parameter"); + Assertions.fail("parameter is not null"); + } catch (Exception e) { + } + Assertions.assertEquals("parameter_value", reportParameters.getMasterParameters().getValue("parameter")); + Integer value1 = reportParameters.getValue("field3"); + Integer value2 = reportParameters.getValue("field4"); + return value1.doubleValue() / value2.doubleValue(); + } + } + + private class MeasureExpression2 extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Double evaluate(ReportParameters reportParameters) { + Assertions.assertNotNull(reportParameters.getMasterParameters()); + try { + reportParameters.getValue("parameter"); + Assertions.fail("parameter is not null"); + } catch (Exception e) { + } + Assertions.assertEquals("parameter_value", reportParameters.getMasterParameters().getValue("parameter")); + Integer value1 = reportParameters.getValue(measure1); + Integer value2 = reportParameters.getValue(variable1); + return value1.doubleValue() / value2.doubleValue(); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDatasetStyleTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDatasetStyleTest.java new file mode 100644 index 0000000..f52168d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/dataset/CrosstabDatasetStyleTest.java @@ -0,0 +1,146 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.dataset; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.awt.Color; +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +import org.junit.jupiter.api.Assertions; + +/** + * Crosstab dataset style tests. + * + * @author Ricardo Mariaca + */ +public class CrosstabDatasetStyleTest extends AbstractJasperCrosstabStyleTest + implements Serializable { + private static final long serialVersionUID = 1L; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + FieldBuilder field1 = field("field1", String.class); + FieldBuilder field2 = field("field2", String.class); + + final StyleBuilder cellStyle = + stl.style().conditionalStyles(stl.conditionalStyle(new ConditionExpression(10, 15, 14, 36)) + .setBackgroundColor(Color.ORANGE)); + + rowGroup = ctab.rowGroup(field1); + columnGroup = ctab.columnGroup(field2); + + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + measure1.setStyle(cellStyle); + + CrosstabBuilder crosstab = ctab.crosstab().setDataSource(createCrosstabDataSource()) + .highlightEvenRows().rowGroups(rowGroup).columnGroups(columnGroup).measures(measure1); + + rb.addParameter("parameter", "parameter_value").title(crosstab); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + setCrosstabBand("title"); + + Color color = new Color(240, 240, 240); + + crosstabCellStyleTest(measure1, null, null, 0, null, null, TEST_FONT_NAME, 10f, null, null); + crosstabCellStyleTest(measure1, null, null, 1, null, null, TEST_FONT_NAME, 10f, null, null); + crosstabCellStyleTest(measure1, null, null, 2, null, color, TEST_FONT_NAME, 10f, null, null); + crosstabCellStyleTest(measure1, null, null, 3, null, Color.ORANGE, TEST_FONT_NAME, 10f, null, + null); + + crosstabCellStyleTest(measure1, rowGroup, null, 0, null, Color.ORANGE, TEST_FONT_NAME, 10f, + null, null); + crosstabCellStyleTest(measure1, rowGroup, null, 1, null, null, TEST_FONT_NAME, 10f, null, null); + + crosstabCellStyleTest(measure1, null, columnGroup, 0, null, Color.ORANGE, TEST_FONT_NAME, 10f, + null, null); + crosstabCellStyleTest(measure1, null, columnGroup, 1, null, color, TEST_FONT_NAME, 10f, null, + null); + + crosstabCellStyleTest(measure1, rowGroup, columnGroup, 0, null, Color.ORANGE, TEST_FONT_NAME, + 10f, null, null); + + } + + private JRDataSource createCrosstabDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("a", "c", 2); + dataSource.add("a", "d", 3); + dataSource.add("a", "d", 4); + dataSource.add("b", "c", 5); + dataSource.add("b", "c", 6); + dataSource.add("b", "d", 7); + dataSource.add("b", "d", 8); + return dataSource; + } + + private class ConditionExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + private List values; + + private ConditionExpression(Integer... values) { + this.values = Arrays.asList(values); + } + + @Override + public Boolean evaluate(ReportParameters reportParameters) { + Assertions.assertNotNull(reportParameters.getMasterParameters()); + try { + reportParameters.getValue("parameter"); + Assertions.fail("parameter is not null"); + } catch (Exception e) { + // required + } + Assertions.assertEquals("parameter_value", + reportParameters.getMasterParameters().getValue("parameter")); + Integer value = reportParameters.getValue(measure1); + return values.contains(value); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/DatabaseReportTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/DatabaseReportTest.java new file mode 100644 index 0000000..7c52305 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/DatabaseReportTest.java @@ -0,0 +1,98 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.datasource; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class DatabaseReportTest extends AbstractJasperValueTest { + private Connection connection; + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + + @Override + public void init() { + try { + Class.forName("org.hsqldb.jdbcDriver"); + connection = DriverManager.getConnection("jdbc:hsqldb:mem:test"); + createTable(); + } catch (Exception e) { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + super.init(); + } + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setLocale(Locale.ENGLISH) + .columns(column1 = col.column("Column1", "field1", type.stringType()), column2 = col.column("Column2", "field2", type.integerType()), + column3 = col.column("Column3", "field3", type.bigDecimalType())) + .setDataSource("SELECT * FROM test_table1", connection); + } + + @Override + protected boolean serializableTest() { + return false; + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnTitleCountTest(column1, 1); + columnTitleValueTest(column1, "Column1"); + columnDetailCountTest(column1, 1); + columnDetailValueTest(column1, 0, "text"); + // column2 + columnTitleCountTest(column2, 1); + columnTitleValueTest(column2, "Column2"); + columnDetailCountTest(column2, 1); + columnDetailValueTest(column2, 0, "5"); + // column3 + columnTitleCountTest(column3, 1); + columnTitleValueTest(column3, "Column3"); + columnDetailCountTest(column3, 1); + columnDetailValueTest(column3, 0, "100.00"); + } + + private void createTable() throws SQLException { + Statement st = connection.createStatement(); + st.execute("CREATE TABLE test_table1 (field1 VARCHAR(50), field2 INTEGER, field3 DECIMAL)"); + st.execute("INSERT INTO test_table1 VALUES ('text', 5, 100)"); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/DatabaseSubreportTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/DatabaseSubreportTest.java new file mode 100644 index 0000000..752329f --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/DatabaseSubreportTest.java @@ -0,0 +1,130 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.datasource; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.component.SubreportBuilder; +import software.xdev.dynamicreports.report.builder.expression.AbstractComplexExpression; +import software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.List; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class DatabaseSubreportTest extends AbstractJasperValueTest { + private Connection connection; + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + + @Override + public void init() { + try { + Class.forName("org.hsqldb.jdbcDriver"); + connection = DriverManager.getConnection("jdbc:hsqldb:mem:test"); + createTable(); + } catch (Exception e) { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + super.init(); + } + + @Override + protected void configureReport(JasperReportBuilder rb) { + SubreportBuilder subreport = cmp.subreport(new SubreportExpression()); + subreport.setConnection(connection); + + CustomGroupBuilder group = grp.group(field("field4", Integer.class)); + group.footer(subreport); + + rb.groupBy(group).setDataSource("SELECT * FROM test_table2", connection); + } + + @Override + protected boolean serializableTest() { + return false; + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnTitleCountTest(column1, 2); + columnTitleValueTest(column1, "Column1", "Column1"); + columnDetailCountTest(column1, 3); + columnDetailValueTest(column1, "text", "text", "text"); + // column2 + columnTitleCountTest(column2, 2); + columnTitleValueTest(column2, "Column2", "Column2"); + columnDetailCountTest(column2, 3); + columnDetailValueTest(column2, "5", "6", "7"); + // column3 + columnTitleCountTest(column3, 2); + columnTitleValueTest(column3, "Column3", "Column3"); + columnDetailCountTest(column3, 3); + columnDetailValueTest(column3, "100.00", "200.00", "300.00"); + } + + private void createTable() throws SQLException { + Statement st = connection.createStatement(); + st.execute("CREATE TABLE test_table2 (field1 VARCHAR(50), field2 INTEGER, field3 DECIMAL, field4 INTEGER)"); + st.execute("INSERT INTO test_table2 VALUES ('text', 5, 100, 1)"); + st.execute("INSERT INTO test_table2 VALUES ('text', 6, 200, 1)"); + st.execute("INSERT INTO test_table2 VALUES ('text', 7, 300, 2)"); + } + + private class SubreportExpression extends AbstractComplexExpression { + private static final long serialVersionUID = 1L; + + public SubreportExpression() { + addExpression(field("field4", Integer.class)); + } + + @Override + public JasperReportBuilder evaluate(List values, ReportParameters reportParameters) { + JasperReportBuilder report = report(); + report.setLocale(Locale.ENGLISH) + .columns(column1 = col.column("Column1", "field1", type.stringType()), column2 = col.column("Column2", "field2", type.integerType()), + column3 = col.column("Column3", "field3", type.bigDecimalType())) + .setQuery("SELECT * FROM test_table2 WHERE field4 = " + values.get(0)); + return report; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/FilterTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/FilterTest.java new file mode 100644 index 0000000..d080d65 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/FilterTest.java @@ -0,0 +1,154 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.datasource; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.DatasetBuilder; +import software.xdev.dynamicreports.report.builder.DynamicReports; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabMeasureBuilder; +import software.xdev.dynamicreports.report.builder.crosstab.CrosstabRowGroupBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperCrosstabValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.ctab; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class FilterTest extends AbstractJasperCrosstabValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + + private CrosstabRowGroupBuilder rowGroup; + private CrosstabColumnGroupBuilder columnGroup; + private CrosstabMeasureBuilder measure1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + measure1 = ctab.measure("field3", Integer.class, Calculation.SUM); + + DatasetBuilder dataset = DynamicReports.dataset(); + dataset.setDataSource(createCrosstabDataSource()); + dataset.setFilterExpression(new CrosstabFilterExpression()); + + CrosstabBuilder crosstab = + ctab.crosstab().setSubDataset(dataset).rowGroups(rowGroup = ctab.rowGroup("field1", String.class)).columnGroups(columnGroup = ctab.columnGroup("field2", String.class)).measures(measure1); + + rb.columns(column1 = col.column("Column1", "field1", type.stringType()), column2 = col.column("Column2", "field2", type.stringType())) + .title(crosstab) + .setFilterExpression(new FilterExpression()); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnTitleCountTest(column1, 1); + columnTitleValueTest(column1, "Column1"); + columnDetailCountTest(column1, 1); + columnDetailValueTest(column1, "1"); + // column2 + columnTitleCountTest(column2, 1); + columnTitleValueTest(column2, "Column2"); + columnDetailCountTest(column2, 1); + columnDetailValueTest(column2, "text1"); + + setCrosstabBand("title"); + + // column group + crosstabGroupHeaderCountTest(columnGroup, 2); + crosstabGroupHeaderValueTest(columnGroup, "c", "d"); + crosstabGroupTotalHeaderCountTest(columnGroup, 1); + crosstabGroupTotalHeaderValueTest(columnGroup, "Total"); + + // row group + crosstabGroupHeaderCountTest(rowGroup, 1); + crosstabGroupHeaderValueTest(rowGroup, "a"); + crosstabGroupTotalHeaderCountTest(rowGroup, 1); + crosstabGroupTotalHeaderValueTest(rowGroup, "Total"); + + // measure1 + crosstabCellCountTest(measure1, null, null, 2); + crosstabCellValueTest(measure1, null, null, "3", "7"); + crosstabCellCountTest(measure1, null, columnGroup, 1); + crosstabCellValueTest(measure1, null, columnGroup, "10"); + crosstabCellCountTest(measure1, rowGroup, null, 2); + crosstabCellValueTest(measure1, rowGroup, null, "3", "7"); + crosstabCellCountTest(measure1, rowGroup, columnGroup, 1); + crosstabCellValueTest(measure1, rowGroup, columnGroup, "10"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + dataSource.add("1", "text1"); + dataSource.add("2", "text2"); + dataSource.add("3", "text3"); + dataSource.add("4", "text4"); + return dataSource; + } + + private JRDataSource createCrosstabDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("a", "c", 1); + dataSource.add("a", "c", 2); + dataSource.add("a", "d", 3); + dataSource.add("a", "d", 4); + dataSource.add("b", "c", 5); + dataSource.add("b", "c", 6); + dataSource.add("b", "d", 7); + dataSource.add("b", "d", 8); + return dataSource; + } + + private class FilterExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Boolean evaluate(ReportParameters reportParameters) { + String value = reportParameters.getValue("field1"); + return value.equals("1"); + } + } + + private class CrosstabFilterExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Boolean evaluate(ReportParameters reportParameters) { + String value = reportParameters.getValue("field1"); + return value.equals("a"); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/SubDatasourceTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/SubDatasourceTest.java new file mode 100644 index 0000000..0fd435c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/SubDatasourceTest.java @@ -0,0 +1,122 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.datasource; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.util.Arrays; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.exp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class SubDatasourceTest extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columns(column1 = col.column("Column1", "field1", type.stringType()), column2 = col.column("Column2", "field2", type.stringType())) + .detailFooter(cmp.subreport(createSubreport()).setDataSource(exp.subDatasourceBeanCollection("field3"))); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnTitleCountTest(column1, 1); + columnTitleValueTest(column1, "Column1"); + columnDetailCountTest(column1, 2); + columnDetailValueTest(column1, "1", "2"); + // column2 + columnTitleCountTest(column2, 1); + columnTitleValueTest(column2, "Column2"); + columnDetailCountTest(column2, 2); + columnDetailValueTest(column2, "text1", "text2"); + + // column3 + columnTitleCountTest(column3, 2); + columnTitleValueTest(column3, "Column3", "Column3"); + columnDetailCountTest(column3, 3); + columnDetailValueTest(column3, "texta1", "texta3", "textb1"); + // column4 + columnTitleCountTest(column4, 2); + columnTitleValueTest(column4, "Column4", "Column4"); + columnDetailCountTest(column4, 3); + columnDetailValueTest(column4, "texta2", "texta4", "textb2"); + + } + + private JasperReportBuilder createSubreport() { + JasperReportBuilder report = report(); + report.columns(column3 = col.column("Column3", "field3", type.stringType()), column4 = col.column("Column4", "field4", type.stringType())); + return report; + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("1", "text1", Arrays.asList(new SubData("texta1", "texta2"), new SubData("texta3", "texta4"))); + dataSource.add("2", "text2", Arrays.asList(new SubData("textb1", "textb2"))); + return dataSource; + } + + public class SubData { + private String field3; + private String field4; + + private SubData(String field3, String field4) { + this.field3 = field3; + this.field4 = field4; + + } + + public String getField3() { + return field3; + } + + public void setField3(String field3) { + this.field3 = field3; + } + + public String getField4() { + return field4; + } + + public void setField4(String field4) { + this.field4 = field4; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/XmlReportTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/XmlReportTest.java new file mode 100644 index 0000000..fedd9f0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/datasource/XmlReportTest.java @@ -0,0 +1,117 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.datasource; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.QueryLanguage; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.data.JRXmlDataSource; +import net.sf.jasperreports.engine.query.JRXPathQueryExecuterFactory; +import net.sf.jasperreports.engine.util.JRXmlUtils; +import org.junit.jupiter.api.Assertions; + +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class XmlReportTest extends AbstractJasperValueTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private TextColumnBuilder column5; + private TextColumnBuilder column6; + + @Override + protected void configureReport(JasperReportBuilder rb) { + try { + rb.setLocale(Locale.ENGLISH) + .columns(column1 = col.column("Column1", field("field1", type.stringType()).setDescription("@field1")), column2 = col.column("Column2", field("field2", type.integerType())), + column3 = col.column("Column3", field("field3", type.bigDecimalType()))) + .setQuery("/data/row1", QueryLanguage.XPATH) + .setParameter(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, JRXmlUtils.parse(XmlReportTest.class.getResourceAsStream("data.xml"))) + .summary(cmp.subreport(createSubreport())); + } catch (JRException e) { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } + + private JasperReportBuilder createSubreport() throws JRException { + JasperReportBuilder report = report(); + report.setLocale(Locale.ENGLISH) + .columns(column4 = col.column("Column4", field("field4", type.stringType()).setDescription("@field4")), + column5 = col.column("Column5", field("field5", type.integerType()).setDescription("field5")), column6 = col.column("Column6", field("field6", type.bigDecimalType()))) + .setUseFieldNameAsDescription(false) + .setDataSource(new JRXmlDataSource(XmlReportTest.class.getResourceAsStream("data.xml"), "/data/row2")); + return report; + } + + @Override + protected boolean serializableTest() { + return false; + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnTitleCountTest(column1, 1); + columnTitleValueTest(column1, "Column1"); + columnDetailCountTest(column1, 1); + columnDetailValueTest(column1, 0, "text1"); + // column2 + columnTitleCountTest(column2, 1); + columnTitleValueTest(column2, "Column2"); + columnDetailCountTest(column2, 1); + columnDetailValueTest(column2, 0, "5"); + // column3 + columnTitleCountTest(column3, 1); + columnTitleValueTest(column3, "Column3"); + columnDetailCountTest(column3, 1); + columnDetailValueTest(column3, 0, "100.00"); + + // column4 + columnTitleCountTest(column4, 1); + columnTitleValueTest(column4, "Column4"); + columnDetailCountTest(column4, 1); + columnDetailValueTest(column4, 0, "text2"); + // column5 + columnTitleCountTest(column5, 1); + columnTitleValueTest(column5, "Column5"); + columnDetailCountTest(column5, 1); + columnDetailValueTest(column5, 0, "1"); + // column6 + columnTitleCountTest(column6, 1); + columnTitleValueTest(column6, "Column6"); + columnDetailCountTest(column6, 1); + columnDetailValueTest(column6, 0, "10.00"); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/CustomGroupTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/CustomGroupTest.java new file mode 100644 index 0000000..8e38a8e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/CustomGroupTest.java @@ -0,0 +1,93 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.group; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; + +/** + * @author Ricardo Mariaca + */ +public class CustomGroupTest extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private CustomGroupBuilder group1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + YearExpression yearExpression = new YearExpression(); + rb.columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", yearExpression)).groupBy(group1 = grp.group(yearExpression)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnTitleCountTest(column1, 1); + columnTitleValueTest(column1, "Column1"); + columnDetailCountTest(column1, 2); + columnDetailValueTest(column1, "2009-12-01", "2010-01-01"); + + // column2 + columnTitleCountTest(column2, 1); + columnTitleValueTest(column2, "Column2"); + columnDetailCountTest(column2, 2); + columnDetailValueTest(column2, "2009", "2010"); + + // group1 + groupHeaderTitleCountTest(group1, 0); + groupHeaderCountTest(group1, 2); + groupHeaderValueTest(group1, "2009", "2010"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 1; i++) { + dataSource.add("2009-12-01"); + dataSource.add("2010-01-01"); + } + return dataSource; + } + + private class YearExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public String evaluate(ReportParameters reportParameters) { + String orderDate = reportParameters.getValue("field1"); + return orderDate.split("-")[0]; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/DataTypeGroupTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/DataTypeGroupTest.java new file mode 100644 index 0000000..8b6a36c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/DataTypeGroupTest.java @@ -0,0 +1,76 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.group; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.util.Date; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class DataTypeGroupTest extends AbstractJasperValueTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private ColumnGroupBuilder group1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setLocale(Locale.ENGLISH) + .columns(column1 = col.column("Column1", "field1", type.dateMonthType()), column2 = col.column("Column2", "field1", type.dateType())) + .groupBy(group1 = grp.group(column1).groupByDataType()); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column2 + columnTitleCountTest(column2, 1); + columnTitleValueTest(column2, "Column2"); + columnDetailCountTest(column2, 2); + columnDetailValueTest(column2, "01/01/2010", "02/01/2010"); + + // group1 + groupHeaderTitleCountTest(group1, 0); + groupHeaderCountTest(group1, 2); + groupHeaderValueTest(group1, "January", "February"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 1; i++) { + dataSource.add(toDate(2010, 1, 1)); + dataSource.add(toDate(2010, 2, 1)); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/Group1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/Group1Test.java new file mode 100644 index 0000000..869d1c6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/Group1Test.java @@ -0,0 +1,126 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.group; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.group.CustomGroupBuilder; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; + +/** + * @author Ricardo Mariaca + */ +public class Group1Test extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private ColumnGroupBuilder group1; + private ColumnGroupBuilder group2; + private ColumnGroupBuilder group3; + private CustomGroupBuilder group4; + private CustomGroupBuilder group5; + private ColumnGroupBuilder group6; + private FieldBuilder field3; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1; + + rb.setLocale(Locale.ENGLISH) + .columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class), column3 = col.column("Column3", "field4", String.class), + column4 = col.column("Column4", "field5", Integer.class).setPattern("#,###.00")) + .groupBy(group1 = grp.group(column1), group2 = grp.group(column3).setHeaderLayout(GroupHeaderLayout.EMPTY).setHideColumn(false), + group3 = grp.group(column1).setHeaderLayout(GroupHeaderLayout.TITLE_AND_VALUE), group4 = grp.group(field3 = field("field3", String.class)), + group5 = grp.group(new ValueExpression()).setTitle("Expression"), group6 = grp.group(column4)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + // group1 + groupHeaderTitleCountTest(group1, 0); + groupHeaderCountTest(group1, 2); + groupHeaderValueTest(group1, "group1", "group2"); + // group2 + groupHeaderTitleCountTest(group1, 0); + groupHeaderCountTest(group2, 0); + // group3 + groupHeaderTitleCountTest(group3, 2); + groupHeaderTitleValueTest(group3, "Column1", "Column1"); + groupHeaderCountTest(group3, 2); + groupHeaderValueTest(group3, "group1", "group2"); + // group4 + groupHeaderCountTest(group4, 2); + groupHeaderValueTest(group4, "group1_1", "group2_1"); + // group5 + groupHeaderTitleCountTest(group5, 2); + groupHeaderTitleValueTest(group5, "Expression", "Expression"); + groupHeaderCountTest(group5, 2); + groupHeaderValueTest(group5, "group1_1_1", "group2_1_1"); + // group6 + groupHeaderTitleCountTest(group6, 0); + groupHeaderCountTest(group6, 2); + groupHeaderValueTest(group6, "1.00", "2.00"); + // column2 + columnDetailCountTest(column2, 20); + columnDetailValueTest(column2, "0", "1"); + // column3 + columnDetailCountTest(column3, 20); + columnDetailValueTest(column3, "group1", "group1"); + columnDetailValueTest(column3, 10, "group2"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5"); + for (int i = 0; i < 10; i++) { + dataSource.add("group1", i, "group1_1", "group1", 1); + } + for (int i = 0; i < 10; i++) { + dataSource.add("group2", i, "group2_1", "group2", 2); + } + return dataSource; + } + + private class ValueExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public String evaluate(ReportParameters reportParameters) { + return reportParameters.getValue(field3) + "_1"; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/Group2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/Group2Test.java new file mode 100644 index 0000000..d15eab2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/Group2Test.java @@ -0,0 +1,109 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.group; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.exp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class Group2Test extends AbstractJasperValueTest { + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1; + ColumnGroupBuilder group1; + + rb.setLocale(Locale.ENGLISH) + .columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class), column3 = col.column("Column3", "field3", Integer.class), + column4 = col.column("Column4", "field4", Integer.class)) + .groupBy(grp.group(column1).setStartInNewPage(true).header(cmp.text("header1")).footer(cmp.text("footer1")), group1 = grp.group(column1) + .header(cmp.text("header2")) + .footer(cmp.text("footer2")) + .setShowColumnHeaderAndFooter(true) + .setReprintHeaderOnEachPage(true) + .setPrintSubtotalsWhenExpression(exp.printNotInFirstPage())) + .subtotalsAtGroupFooter(group1, subtotal1 = sbt.sum(column4)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(3); + + columnTitleCountTest(column2, 3); + columnTitleValueTest(column2, "Column2", "Column2", "Column2"); + columnTitleCountTest(column3, 3); + columnTitleValueTest(column3, "Column3", "Column3", "Column3"); + columnTitleCountTest(column4, 3); + columnTitleValueTest(column4, "Column4", "Column4", "Column4"); + + elementCountTest("columnHeaderForGroup.column_field2.title1", 3); + elementValueTest("columnHeaderForGroup.column_field2.title1", "Column2", "Column2", "Column2"); + elementCountTest("columnHeaderForGroup.column_field3.title1", 3); + elementValueTest("columnHeaderForGroup.column_field3.title1", "Column3", "Column3", "Column3"); + elementCountTest("columnHeaderForGroup.column_field4.title1", 3); + elementValueTest("columnHeaderForGroup.column_field4.title1", "Column4", "Column4", "Column4"); + + elementCountTest("groupHeader.textField1", 2); + elementValueTest("groupHeader.textField1", "header1", "header1"); + + elementCountTest("groupFooter.textField1", 2); + elementValueTest("groupFooter.textField1", "footer1", "footer1"); + + elementCountTest("groupHeader.textField2", 3); + elementValueTest("groupHeader.textField2", "header2", "header2", "header2"); + + elementCountTest("groupFooter.textField2", 2); + elementValueTest("groupFooter.textField2", "footer2", "footer2"); + + subtotalCountTest(subtotal1, 1); + subtotalValueTest(subtotal1, "1,225"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + for (int i = 0; i < 10; i++) { + dataSource.add("group1", i, i, i); + } + for (int i = 0; i < 50; i++) { + dataSource.add("group2", i, i, i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/Group3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/Group3Test.java new file mode 100644 index 0000000..ab34b8a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/Group3Test.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.group; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; + +/** + * @author Ricardo Mariaca + */ +public class Group3Test extends AbstractJasperValueTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setShowColumnTitle(false) + .columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", String.class)) + .groupBy(grp.group(column1).setShowColumnHeaderAndFooter(true)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + columnTitleCountTest(column1, 0); + columnTitleCountTest(column2, 0); + + elementCountTest("columnHeaderForGroup.column_field2.title1", 1); + elementValueTest("columnHeaderForGroup.column_field2.title1", "Column2"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 0; i < 1; i++) { + dataSource.add("1", "1"); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/GroupPosition1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/GroupPosition1Test.java new file mode 100644 index 0000000..65c1362 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/GroupPosition1Test.java @@ -0,0 +1,71 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.group; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; + +/** + * @author Ricardo Mariaca + */ +public class GroupPosition1Test extends AbstractJasperPositionTest { + + private ColumnGroupBuilder group1; + private TextColumnBuilder column2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1; + + rb.columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class)).groupBy(group1 = grp.group(column1)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 16); + elementPositionTest("columnHeader.filler1", 0, 0, 0, 10, 16); + elementPositionTest("detail.list1", 0, 10, 42, 575, 16); + elementPositionTest("detail.list1", 1, 10, 58, 575, 16); + + // group1 + groupHeaderPositionTest(group1, 0, 10, 26, 575, 16); + // column2 + columnTitlePositionTest(column2, 0, 10, 0, 565, 16); + columnDetailPositionTest(column2, 0, 10, 0, 565, 16); + columnDetailPositionTest(column2, 1, 10, 0, 565, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 0; i < 2; i++) { + dataSource.add("group1", i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/GroupPosition2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/GroupPosition2Test.java new file mode 100644 index 0000000..50a1f66 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/GroupPosition2Test.java @@ -0,0 +1,91 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.group; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class GroupPosition2Test extends AbstractJasperPositionTest { + private ColumnGroupBuilder group1; + private ColumnGroupBuilder group2; + private TextColumnBuilder column3; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1, column2; + + rb.columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", String.class), column3 = col.column("Column3", "field3", Integer.class)) + .groupBy(group1 = grp.group(column1), group2 = grp.group(column2).setHeaderLayout(GroupHeaderLayout.TITLE_AND_VALUE).header(cmp.text("header")).footer(cmp.text("footer"))) + .subtotalsAtGroupFooter(group2, subtotal1 = sbt.sum(column3)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 16); + elementPositionTest("columnHeader.filler1", 0, 0, 0, 20, 16); + elementPositionTest("detail.list1", 0, 10, 74, 575, 16); + elementPositionTest("detail.list1", 1, 10, 90, 575, 16); + + // group1 + groupHeaderPositionTest(group1, 0, 10, 26, 575, 16); + // group2 + elementPositionTest("groupHeaderTitleAndValue.list1", 0, 10, 42, 575, 16); + groupHeaderTitlePositionTest(group2, 0, 10, 0, 100, 16); + groupHeaderPositionTest(group2, 0, 110, 0, 465, 16); + + elementPositionTest("groupHeader.list1", 0, 10, 58, 575, 16); + elementPositionTest("groupHeader.textField1", 0, 10, 0, 565, 16); + + elementPositionTest("subtotalGroupFooter.list1", 0, 10, 106, 575, 16); + subtotalPositionTest(subtotal1, 0, 20, 0, 555, 16); + + elementPositionTest("groupFooter.list1", 0, 10, 122, 575, 16); + elementPositionTest("groupFooter.textField1", 0, 10, 0, 565, 16); + // column3 + columnTitlePositionTest(column3, 0, 20, 0, 555, 16); + columnDetailPositionTest(column3, 0, 20, 0, 555, 16); + columnDetailPositionTest(column3, 1, 20, 0, 555, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + for (int i = 0; i < 2; i++) { + dataSource.add("group1", "group2", i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/GroupPosition3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/GroupPosition3Test.java new file mode 100644 index 0000000..005c2ab --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/GroupPosition3Test.java @@ -0,0 +1,100 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.group; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.constant.GroupFooterPosition; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRGroup; + + +/** + * @author Ricardo Mariaca + */ +public class GroupPosition3Test extends AbstractJasperPositionTest +{ + + private ColumnGroupBuilder group1; + private TextColumnBuilder column2; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + final TextColumnBuilder column1; + + rb.columns( + column1 = col.column("Column1", "field1", String.class), + this.column2 = col.column("Column2", "field2", Integer.class)) + .groupBy(this.group1 = grp.group(column1) + .setFooterPosition(GroupFooterPosition.FORCE_AT_BOTTOM) + .keepTogether() + .setMinHeightToStartNewPage(100)) + .subtotalsAtFirstGroupFooter(this.subtotal1 = sbt.sum(this.column2)); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + this.elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 16); + this.elementPositionTest("columnHeader.filler1", 0, 0, 0, 10, 16); + this.elementPositionTest("detail.list1", 0, 10, 42, 575, 16); + this.elementPositionTest("detail.list1", 1, 10, 58, 575, 16); + + // group1 + this.groupHeaderPositionTest(this.group1, 0, 10, 26, 575, 16); + // column2 + this.columnTitlePositionTest(this.column2, 0, 10, 0, 565, 16); + this.columnDetailPositionTest(this.column2, 0, 10, 0, 565, 16); + this.columnDetailPositionTest(this.column2, 1, 10, 0, 565, 16); + // summary + this.elementPositionTest("subtotalGroupFooter.list1", 0, 10, 816, 575, 16); + this.subtotalPositionTest(this.subtotal1, 0, 10, 0, 565, 16); + + final JRGroup jrGroup = this.getJasperReport().getGroups()[0]; + Assertions.assertTrue(jrGroup.isKeepTogether()); + // Assertions.assertEquals("Min height to start new page", new Integer(100), jrGroup + // .getMinHeightToStartNewPage()); // remove this ambiguous function call + Assertions.assertEquals(100, jrGroup.getMinHeightToStartNewPage()); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1", "field2"); + for(int i = 0; i < 10; i++) + { + dataSource.add("group1", i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/PercentageGroup1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/PercentageGroup1Test.java new file mode 100644 index 0000000..94a9f38 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/PercentageGroup1Test.java @@ -0,0 +1,74 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.group; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.PercentageColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.PercentageTotalType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class PercentageGroup1Test extends AbstractJasperValueTest { + private PercentageColumnBuilder percentage1; + private PercentageColumnBuilder percentage2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1; + TextColumnBuilder column2; + + rb.setLocale(Locale.ENGLISH) + .columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class), percentage1 = col.percentageColumn(column2), + percentage2 = col.percentageColumn(column2).setTotalType(PercentageTotalType.REPORT)) + .groupBy(column1); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + // percentage1 + columnDetailCountTest(percentage1, 6); + columnDetailValueTest(percentage1, "16.67%", "33.33%", "50.00%", "26.67%", "33.33%", "40.00%"); + // percentage2 + columnDetailCountTest(percentage2, 6); + columnDetailValueTest(percentage2, "4.76%", "9.52%", "14.29%", "19.05%", "23.81%", "28.57%"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 1; i <= 3; i++) { + dataSource.add("group1", i); + } + for (int i = 4; i <= 6; i++) { + dataSource.add("group2", i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/PercentageGroup2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/PercentageGroup2Test.java new file mode 100644 index 0000000..ac187d7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/group/PercentageGroup2Test.java @@ -0,0 +1,149 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.group; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.PercentageColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.PercentageSubtotalBuilder; +import software.xdev.dynamicreports.report.constant.PercentageTotalType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class PercentageGroup2Test extends AbstractJasperValueTest { + private PercentageColumnBuilder percentage1; + private PercentageColumnBuilder percentage2; + private PercentageColumnBuilder percentage3; + private PercentageColumnBuilder percentage4; + private PercentageSubtotalBuilder subtotal1; + private PercentageSubtotalBuilder subtotal2; + private PercentageSubtotalBuilder subtotal3; + private PercentageSubtotalBuilder subtotal4; + private PercentageSubtotalBuilder subtotal5; + private PercentageSubtotalBuilder subtotal6; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1 = col.column("Column1", "field1", String.class); + TextColumnBuilder column2 = col.column("Column2", "field2", String.class); + TextColumnBuilder column3 = col.column("Column3", "field3", String.class); + TextColumnBuilder column4 = col.column("Column4", "field4", Integer.class); + ColumnGroupBuilder group1 = grp.group(column1); + ColumnGroupBuilder group2 = grp.group(column2); + ColumnGroupBuilder group3 = grp.group(column3); + + rb.setLocale(Locale.ENGLISH) + .columns(column1, column2, column3, column4, percentage1 = col.percentageColumn(column4), percentage2 = col.percentageColumn(column4).setTotalGroup(group2), + percentage3 = col.percentageColumn(column4).setTotalGroup(group1), percentage4 = col.percentageColumn(column4).setTotalType(PercentageTotalType.REPORT)) + .groupBy(group1, group2, group3) + .subtotalsOfPercentageAtGroupFooter(group3, subtotal1 = sbt.percentage(column4), subtotal2 = sbt.percentage(column4).setTotalGroup(group1), + subtotal3 = sbt.percentage(column4).setTotalType(PercentageTotalType.REPORT)) + .subtotalsOfPercentageAtGroupFooter(group2, subtotal4 = sbt.percentage(column4), subtotal5 = sbt.percentage(column4).setTotalType(PercentageTotalType.REPORT)) + .subtotalsOfPercentageAtGroupFooter(group1, subtotal6 = sbt.percentage(column4)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(2); + // percentage1 + columnDetailCountTest(percentage1, 24); + columnDetailValueTest(percentage1, "16.67%", "33.33%", "50.00%", "26.67%", "33.33%", "40.00%", "29.17%", "33.33%", "37.50%", "30.30%", "33.33%", "36.36%", "30.95%", "33.33%", "35.71%", + "31.37%", "33.33%", "35.29%", "31.67%", "33.33%", "35.00%", "31.88%", "33.33%", "34.78%"); + // percentage2 + columnDetailCountTest(percentage2, 24); + columnDetailValueTest(percentage2, "4.76%", "9.52%", "14.29%", "19.05%", "23.81%", "28.57%", "12.28%", "14.04%", "15.79%", "17.54%", "19.30%", "21.05%", "13.98%", "15.05%", "16.13%", "17.20%", + "18.28%", "19.35%", "14.73%", "15.50%", "16.28%", "17.05%", "17.83%", "18.60%"); + // percentage3 + columnDetailCountTest(percentage3, 24); + columnDetailValueTest(percentage3, "1.28%", "2.56%", "3.85%", "5.13%", "6.41%", "7.69%", "8.97%", "10.26%", "11.54%", "12.82%", "14.10%", "15.38%", "5.86%", "6.31%", "6.76%", "7.21%", "7.66%", + "8.11%", "8.56%", "9.01%", "9.46%", "9.91%", "10.36%", "10.81%"); + // percentage4 + columnDetailCountTest(percentage4, 24); + columnDetailValueTest(percentage4, "0.33%", "0.67%", "1.00%", "1.33%", "1.67%", "2.00%", "2.33%", "2.67%", "3.00%", "3.33%", "3.67%", "4.00%", "4.33%", "4.67%", "5.00%", "5.33%", "5.67%", + "6.00%", "6.33%", "6.67%", "7.00%", "7.33%", "7.67%", "8.00%"); + + // subtotal1 + subtotalIndexCountTest(subtotal1, 4, 8); + subtotalIndexValueTest(subtotal1, 4, "28.57%", "71.43%", "42.11%", "57.89%", "45.16%", "54.84%", "46.51%", "53.49%"); + + // subtotal2 + subtotalIndexCountTest(subtotal2, 5, 8); + subtotalIndexValueTest(subtotal2, 5, "7.69%", "19.23%", "30.77%", "42.31%", "18.92%", "22.97%", "27.03%", "31.08%"); + + // subtotal3 + subtotalIndexCountTest(subtotal3, 6, 8); + subtotalIndexValueTest(subtotal3, 6, "2.00%", "5.00%", "8.00%", "11.00%", "14.00%", "17.00%", "20.00%", "23.00%"); + + // subtotal4 + subtotalIndexCountTest(subtotal4, 2, 4); + subtotalIndexValueTest(subtotal4, 2, "26.92%", "73.08%", "41.89%", "58.11%"); + + // subtotal5 + subtotalIndexCountTest(subtotal5, 3, 4); + subtotalIndexValueTest(subtotal5, 3, "7.00%", "19.00%", "31.00%", "43.00%"); + + // subtotal6 + subtotalCountTest(subtotal6, 2); + subtotalValueTest(subtotal6, "26.00%", "74.00%"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + int count = 1; + for (int i = 1; i <= 3; i++) { + dataSource.add("group1", "group1_1", "group1_1_1", count++); + } + for (int i = 1; i <= 3; i++) { + dataSource.add("group1", "group1_1", "group1_1_2", count++); + } + for (int i = 1; i <= 3; i++) { + dataSource.add("group1", "group1_2", "group1_2_1", count++); + } + for (int i = 1; i <= 3; i++) { + dataSource.add("group1", "group1_2", "group1_2_2", count++); + } + + for (int i = 1; i <= 3; i++) { + dataSource.add("group2", "group2_1", "group2_1_1", count++); + } + for (int i = 1; i <= 3; i++) { + dataSource.add("group2", "group2_1", "group2_1_2", count++); + } + for (int i = 1; i <= 3; i++) { + dataSource.add("group2", "group2_2", "group2_2_1", count++); + } + for (int i = 1; i <= 3; i++) { + dataSource.add("group2", "group2_2", "group2_2_2", count++); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/BandTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/BandTest.java new file mode 100644 index 0000000..2273fc6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/BandTest.java @@ -0,0 +1,167 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class BandTest extends AbstractJasperPositionTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column2; + private ColumnGroupBuilder group1; + private AggregationSubtotalBuilder subtotal1; + private AggregationSubtotalBuilder subtotal2; + private AggregationSubtotalBuilder subtotal3; + private AggregationSubtotalBuilder subtotal4; + private AggregationSubtotalBuilder subtotal5; + private AggregationSubtotalBuilder subtotal6; + private AggregationSubtotalBuilder subtotal7; + private AggregationSubtotalBuilder subtotal8; + private AggregationSubtotalBuilder subtotal9; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1; + + rb.setPageColumnsPerPage(2) + .columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class).setWidth(500)) + .groupBy(group1 = grp.group(column1)) + + .subtotalsAtTitle(subtotal1 = sbt.sum(column2)) + .subtotalsAtPageHeader(subtotal2 = sbt.sum(column2)) + .subtotalsAtPageFooter(subtotal3 = sbt.sum(column2)) + .subtotalsAtColumnHeader(subtotal4 = sbt.sum(column2)) + .subtotalsAtColumnFooter(subtotal5 = sbt.sum(column2)) + .subtotalsAtGroupHeader(group1, subtotal6 = sbt.sum(column2)) + .subtotalsAtGroupFooter(group1, subtotal7 = sbt.sum(column2)) + .subtotalsAtLastPageFooter(subtotal8 = sbt.sum(column2)) + .subtotalsAtSummary(subtotal9 = sbt.sum(column2)) + + .title(cmp.text("title")) + .pageHeader(cmp.text("pageHeader")) + .pageFooter(cmp.text("pageFooter")) + .columnHeader(cmp.text("columnHeader")) + .columnFooter(cmp.text("columnFooter")) + .groupHeader(group1, cmp.text("groupHeader")) + .groupFooter(group1, cmp.text("groupFooter")) + .detail(cmp.text("detail")) + .lastPageFooter(cmp.text("lastPageFooter")) + .summary(cmp.text("summary")) + .background(cmp.text("background")); + + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(2); + + // title + // elementPositionTest("title.list1", 0, 10, 10, 575, 32); + elementPositionTest("title.textField1", 0, 10, 10, 575, 16); + elementPositionTest("title.list2", 0, 10, 26, 575, 16); + subtotalPositionTest(subtotal1, 0, 10, 0, 277, 16); + + // page header + // elementPositionTest("pageHeader.list1", 0, 10, 42, 575, 32); + elementPositionTest("pageHeader.textField1", 0, 10, 42, 575, 16); + elementPositionTest("pageHeader.list2", 0, 10, 58, 575, 16); + subtotalPositionTest(subtotal2, 0, 10, 0, 277, 16); + + // page footer + // elementPositionTest("pageFooter.list1", 0, 10, 800, 575, 32); + elementPositionTest("pageFooter.list2", 0, 10, 800, 575, 16); + subtotalPositionTest(subtotal3, 0, 10, 0, 277, 16); + elementPositionTest("pageFooter.textField1", 0, 10, 816, 575, 16); + + // column header + // elementPositionTest("columnHeader.list1", 0, 10, 74, 287, 48); + elementPositionTest("columnHeader.list2", 0, 10, 74, 287, 16); + columnTitlePositionTest(column2, 0, 10, 0, 277, 16); + elementPositionTest("columnHeader.textField1", 0, 10, 90, 287, 16); + elementPositionTest("columnHeader.list3", 0, 10, 106, 287, 16); + subtotalPositionTest(subtotal4, 0, 10, 0, 277, 16); + + // column footer + // elementPositionTest("columnFooter.list1", 0, 10, 768, 287, 32); + elementPositionTest("columnFooter.list2", 0, 10, 768, 287, 16); + subtotalPositionTest(subtotal5, 0, 10, 0, 277, 16); + elementPositionTest("columnFooter.textField1", 0, 10, 784, 287, 16); + + // group header + groupHeaderPositionTest(group1, 0, 10, 122, 287, 16); + elementPositionTest("groupHeader.textField1", 0, 10, 138, 287, 16); + elementPositionTest("subtotalGroupHeader.list1", 0, 10, 154, 287, 16); + subtotalPositionTest(subtotal6, 0, 10, 0, 277, 16); + + // group footer + elementPositionTest("subtotalGroupFooter.list1", 0, 297, 346, 287, 16); + subtotalPositionTest(subtotal7, 0, 10, 0, 277, 16); + elementPositionTest("groupFooter.textField1", 0, 297, 362, 287, 16); + + // detail + // elementPositionTest("detail.list1", 0, 10, 170, 287, 32); + elementPositionTest("detail.textField1", 0, 10, 170, 287, 16); + elementPositionTest("detail.list2", 0, 10, 186, 287, 16); + columnDetailPositionTest(column2, 0, 10, 0, 277, 16); + + // last page footer + // elementPositionTest("lastPageFooter.list1", 0, 10, 800, 575, 32); + elementPositionTest("lastPageFooter.list2", 0, 10, 800, 575, 16); + subtotalPositionTest(subtotal8, 0, 10, 0, 277, 16); + elementPositionTest("lastPageFooter.textField1", 0, 10, 816, 575, 16); + + // summary + // elementPositionTest("summary.list1", 0, 10, 602, 575, 32); + elementPositionTest("summary.list2", 0, 10, 602, 575, 16); + subtotalPositionTest(subtotal9, 0, 10, 0, 277, 16); + elementPositionTest("summary.textField1", 0, 10, 618, 575, 16); + + // background + elementPositionTest("background.textField1", 0, 10, 10, 575, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 0; i < 25; i++) { + dataSource.add("group1", i); + } + for (int i = 0; i < 25; i++) { + dataSource.add("group2", i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ColumnGridTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ColumnGridTest.java new file mode 100644 index 0000000..6e09980 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ColumnGridTest.java @@ -0,0 +1,124 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class ColumnGridTest extends AbstractJasperPositionTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private TextColumnBuilder column5; + private TextColumnBuilder column6; + private TextColumnBuilder column7; + private TextColumnBuilder column8; + private AggregationSubtotalBuilder subtotal1; + private AggregationSubtotalBuilder subtotal2; + private AggregationSubtotalBuilder subtotal3; + private AggregationSubtotalBuilder subtotal4; + private AggregationSubtotalBuilder subtotal5; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setTextStyle(stl.style().setPadding(1)) + .columnGrid(ListType.HORIZONTAL_FLOW) + .columns(column1 = col.column("Column1", "field1", Integer.class), column2 = col.column("Column2", "field2", Integer.class), column3 = col.column("Column3", "field3", Integer.class), + column4 = col.column("Column4", "field4", Integer.class), column5 = col.column("Column5", "field5", Integer.class), column6 = col.column("Column6", "field6", Integer.class), + column7 = col.column("Column7", "field7", Integer.class), column8 = col.column("Column8", "field8", Integer.class)) + .subtotalsAtSummary(subtotal1 = sbt.sum(column1), subtotal2 = sbt.sum(column5), subtotal3 = sbt.aggregate(column5, Calculation.AVERAGE), subtotal4 = sbt.sum(column7), + subtotal5 = sbt.aggregate(column7, Calculation.AVERAGE)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + // column header + // elementPositionTest("columnHeader.list1", 0, 10, 10, 575, 28); + + elementPositionTest("columnHeader.list2", 0, 10, 10, 575, 14); + columnTitlePositionTest(column1, 0, 0, 0, 115, 14); + columnTitlePositionTest(column2, 0, 115, 0, 115, 14); + columnTitlePositionTest(column3, 0, 230, 0, 115, 14); + columnTitlePositionTest(column4, 0, 345, 0, 115, 14); + columnTitlePositionTest(column5, 0, 460, 0, 115, 14); + + elementPositionTest("columnHeader.list3", 0, 10, 24, 575, 14); + columnTitlePositionTest(column6, 0, 0, 0, 191, 14); + columnTitlePositionTest(column7, 0, 191, 0, 192, 14); + columnTitlePositionTest(column8, 0, 383, 0, 192, 14); + + // detail + // elementPositionTest("detail.list1", 0, 10, 38, 575, 28); + + elementPositionTest("detail.list2", 0, 10, 38, 575, 14); + columnDetailPositionTest(column1, 0, 0, 0, 115, 14); + columnDetailPositionTest(column2, 0, 115, 0, 115, 14); + columnDetailPositionTest(column3, 0, 230, 0, 115, 14); + columnDetailPositionTest(column4, 0, 345, 0, 115, 14); + columnDetailPositionTest(column5, 0, 460, 0, 115, 14); + + elementPositionTest("detail.list3", 0, 10, 52, 575, 14); + columnDetailPositionTest(column6, 0, 0, 0, 191, 14); + columnDetailPositionTest(column7, 0, 191, 0, 192, 14); + columnDetailPositionTest(column8, 0, 383, 0, 192, 14); + + // subtotal + // elementPositionTest("summary.list1", 0, 10, 318, 575, 56); + + elementPositionTest("summary.list2", 0, 10, 318, 575, 28); + subtotalPositionTest(subtotal1, 0, 0, 0, 115, 14); + // elementPositionTest("summary.list3", 0, 460, 0, 115, 28); + subtotalPositionTest(subtotal2, 0, 460, 0, 115, 14); + subtotalIndexPositionTest(subtotal3, 2, 0, 460, 14, 115, 14); + + elementPositionTest("summary.list4", 0, 10, 346, 575, 28); + // elementPositionTest("summary.list5", 0, 191, 0, 192, 28); + subtotalPositionTest(subtotal4, 0, 191, 0, 192, 14); + subtotalIndexPositionTest(subtotal5, 2, 0, 191, 14, 192, 14); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5", "field6", "field7", "field8"); + for (int i = 0; i < 10; i++) { + dataSource.add(1, 1, 1, 1, 1, 1, 1, 1); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ColumnsPerPageTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ColumnsPerPageTest.java new file mode 100644 index 0000000..4eb519a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ColumnsPerPageTest.java @@ -0,0 +1,164 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.report.constant.ListType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class ColumnsPerPageTest extends AbstractJasperPositionTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private TextColumnBuilder column5; + private AggregationSubtotalBuilder subtotal1; + private AggregationSubtotalBuilder subtotal2; + private AggregationSubtotalBuilder subtotal3; + private AggregationSubtotalBuilder subtotal4; + private AggregationSubtotalBuilder subtotal5; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setTextStyle(stl.style().setPadding(1)) + .setPageColumnSpace(10) + .setPageColumnsPerPage(3) + .columnGrid(ListType.HORIZONTAL_FLOW) + .columns(column1 = col.column("Column1", "field1", Integer.class).setWidth(50), column2 = col.column("Column2", "field2", Integer.class).setWidth(50), + column3 = col.column("Column3", "field3", Integer.class).setWidth(50), column4 = col.column("Column4", "field4", Integer.class).setWidth(50), + column5 = col.column("Column5", "field5", Integer.class).setWidth(50)) + .subtotalsAtColumnFooter(subtotal1 = sbt.sum(column1).setLabel("sum"), subtotal2 = sbt.sum(column3).setLabel("sum"), subtotal3 = sbt.aggregate(column3, Calculation.AVERAGE).setLabel("avg"), + subtotal4 = sbt.sum(column4).setLabel("sum"), subtotal5 = sbt.aggregate(column4, Calculation.AVERAGE).setLabel("avg")) + .subtotalsAtSummary(subtotal1 = sbt.sum(column1).setLabel("sum"), subtotal2 = sbt.sum(column3).setLabel("sum"), subtotal3 = sbt.aggregate(column3, Calculation.AVERAGE).setLabel("avg"), + subtotal4 = sbt.sum(column4).setLabel("sum"), subtotal5 = sbt.aggregate(column4, Calculation.AVERAGE).setLabel("avg")); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(2); + // column header + // elementPositionTest("columnHeader.list1", 0, 10, 10, 185, 28); + // elementPositionTest("columnHeader.list1", 1, 205, 10, 185, 28); + // elementPositionTest("columnHeader.list1", 2, 400, 10, 185, 28); + // elementPositionTest("columnHeader.list1", 3, 10, 10, 185, 28); + + elementPositionTest("columnHeader.list2", 0, 10, 10, 185, 14); + columnTitlePositionTest(column1, 0, 0, 0, 61, 14); + columnTitlePositionTest(column2, 0, 61, 0, 62, 14); + columnTitlePositionTest(column3, 0, 123, 0, 62, 14); + + elementPositionTest("columnHeader.list3", 0, 10, 24, 185, 14); + columnTitlePositionTest(column4, 0, 0, 0, 92, 14); + columnTitlePositionTest(column5, 0, 92, 0, 93, 14); + + // detail + // elementPositionTest("detail.list1", 0, 10, 38, 185, 28); + // elementPositionTest("detail.list1", 24, 205, 38, 185, 28); + // elementPositionTest("detail.list1", 48, 400, 38, 185, 28); + // elementPositionTest("detail.list1", 72, 10, 38, 185, 28); + + elementPositionTest("detail.list2", 0, 10, 38, 185, 14); + columnDetailPositionTest(column1, 0, 0, 0, 61, 14); + columnDetailPositionTest(column2, 0, 61, 0, 62, 14); + columnDetailPositionTest(column3, 0, 123, 0, 62, 14); + + elementPositionTest("detail.list3", 0, 10, 52, 185, 14); + columnDetailPositionTest(column4, 0, 0, 0, 92, 14); + columnDetailPositionTest(column5, 0, 92, 0, 93, 14); + + // subtotal at column footer + // elementPositionTest("columnFooter.list1", 0, 10, 720, 185, 112); + // elementPositionTest("columnFooter.list1", 1, 205, 720, 185, 112); + // elementPositionTest("columnFooter.list1", 2, 400, 720, 185, 112); + // elementPositionTest("columnFooter.list1", 3, 10, 720, 185, 112); + + elementPositionTest("columnFooter.list2", 0, 10, 720, 185, 56); + // elementPositionTest("columnFooter.list3", 0, 0, 0, 61, 28); + subtotalLabelPositionTest(subtotal1, 0, 0, 0, 61, 14); + subtotalPositionTest(subtotal1, 0, 0, 14, 61, 14); + + // elementPositionTest("columnFooter.list4", 0, 123, 0, 62, 56); + // elementPositionTest("columnFooter.list5", 0, 0, 0, 62, 28); + subtotalLabelPositionTest(subtotal2, 0, 123, 0, 62, 14); + subtotalPositionTest(subtotal2, 0, 123, 14, 62, 14); + // elementPositionTest("columnFooter.list6", 0, 0, 28, 62, 28); + subtotalLabelPositionTest(subtotal3, 0, 123, 0, 62, 14); + subtotalPositionTest(subtotal3, 0, 123, 14, 62, 14); + + elementPositionTest("columnFooter.list7", 0, 10, 776, 185, 56); + // elementPositionTest("columnFooter.list8", 0, 0, 0, 92, 56); + // elementPositionTest("columnFooter.list9", 0, 0, 0, 92, 28); + subtotalLabelPositionTest(subtotal4, 0, 0, 0, 92, 14); + subtotalPositionTest(subtotal4, 0, 0, 14, 92, 14); + // elementPositionTest("columnFooter.list10", 0, 0, 28, 92, 28); + subtotalLabelPositionTest(subtotal5, 0, 0, 0, 92, 14); + subtotalPositionTest(subtotal5, 0, 0, 14, 92, 14); + + // subtotal at summary + elementPositionTest("summary.list1", 0, 10, 262, 575, 112); + + // elementPositionTest("summary.list2", 0, 0, 0, 185, 112); + elementPositionTest("summary.list3", 0, 0, 0, 185, 56); + subtotalLabelPositionTest(subtotal1, 0, 0, 0, 61, 14); + subtotalPositionTest(subtotal1, 0, 0, 14, 61, 14); + + // elementPositionTest("summary.list4", 0, 0, 0, 61, 28); + // elementPositionTest("summary.list5", 0, 123, 0, 62, 56); + subtotalLabelPositionTest(subtotal2, 0, 123, 0, 62, 14); + subtotalPositionTest(subtotal2, 0, 123, 14, 62, 14); + // elementPositionTest("summary.list6", 0, 0, 0, 62, 28); + subtotalLabelPositionTest(subtotal3, 0, 123, 0, 62, 14); + subtotalPositionTest(subtotal3, 0, 123, 14, 62, 14); + + // elementPositionTest("summary.list7", 0, 0, 28, 62, 28); + elementPositionTest("summary.list8", 0, 0, 56, 185, 56); + // elementPositionTest("summary.list9", 0, 0, 0, 92, 56); + subtotalLabelPositionTest(subtotal4, 0, 0, 0, 92, 14); + subtotalPositionTest(subtotal4, 0, 0, 14, 92, 14); + // elementPositionTest("summary.list10", 0, 0, 0, 92, 28); + subtotalLabelPositionTest(subtotal5, 0, 0, 0, 92, 14); + subtotalPositionTest(subtotal5, 0, 0, 14, 92, 14); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5"); + for (int i = 0; i < 80; i++) { + dataSource.add(1, 1, 1, 1, 1); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport1Test.java new file mode 100644 index 0000000..e20a16c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport1Test.java @@ -0,0 +1,84 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.concatenatedReport; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; + +import java.io.ByteArrayOutputStream; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.exception.DRException; + + +/** + * @author Ricardo Mariaca + */ +class ConcatenatedReport1Test +{ + JasperConcatenatedReportBuilder concatenatedReport; + + @BeforeEach + public void init() + { + final JasperReportBuilder report1 = report().title(cmp.text("text1")).pageFooter(cmp.pageNumber()); + final JasperReportBuilder report2 = report().title(cmp.text("text2")).pageFooter(cmp.pageNumber()); + final JasperReportBuilder report3 = report().title(cmp.text("text3")).pageFooter(cmp.pageNumber()); + + this.concatenatedReport = concatenatedReport(); + this.concatenatedReport.concatenate(report1, report2, report3); + } + + @Test + void test() + { + try + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals( + "text1\n1\ntext2\n1\ntext3\n1\n", + bos.toString()); + + this.concatenatedReport.continuousPageNumbering(); + bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals( + "text1\n1\ntext2\n2\ntext3\n3\n", + bos.toString()); + + this.concatenatedReport.setContinuousPageNumbering(false); + bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals( + "text1\n1\ntext2\n1\ntext3\n1\n", + bos.toString()); + } + catch(final DRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport2Test.java new file mode 100644 index 0000000..1062109 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport2Test.java @@ -0,0 +1,100 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.concatenatedReport; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; + +import java.io.ByteArrayOutputStream; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.JRDataSource; + + +/** + * @author Ricardo Mariaca + */ +class ConcatenatedReport2Test +{ + JasperConcatenatedReportBuilder concatenatedReport; + + @BeforeEach + public void init() + { + final JasperReportBuilder report1 = + report().columns(col.column("field1", String.class)).pageFooter(cmp.pageNumber()).setDataSource( + this.createDataSource("text1")); + final JasperReportBuilder report2 = + report().columns(col.column("field1", String.class)).pageFooter(cmp.pageNumber()).setDataSource( + this.createDataSource("text2")); + final JasperReportBuilder report3 = + report().columns(col.column("field1", String.class)).pageFooter(cmp.pageNumber()).setDataSource( + this.createDataSource("text3")); + + this.concatenatedReport = concatenatedReport(); + this.concatenatedReport.concatenate(report1, report2, report3); + } + + @Test + void test() + { + try + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals( + "text1\n1\ntext2\n1\ntext3\n1\n", + bos.toString()); + + this.concatenatedReport.continuousPageNumbering(); + bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals( + "text1\n1\ntext2\n2\ntext3\n3\n", + bos.toString()); + + this.concatenatedReport.setContinuousPageNumbering(false); + bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals( + "text1\n1\ntext2\n1\ntext3\n1\n", + bos.toString()); + } + catch(final DRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } + + private JRDataSource createDataSource(final String text) + { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add(text); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport3Test.java new file mode 100644 index 0000000..e6c6fec --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport3Test.java @@ -0,0 +1,85 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.concatenatedReport; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; + +import java.io.ByteArrayOutputStream; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.jasper.base.reporthandler.JasperPrintListFileHandler; +import software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.fill.JRSwapFileVirtualizer; +import net.sf.jasperreports.engine.util.JRSwapFile; + + +/** + * @author Ricardo Mariaca + */ +class ConcatenatedReport3Test +{ + JasperConcatenatedReportBuilder concatenatedReport; + + @BeforeEach + public void init() + { + final JasperReportBuilder report1 = report().title(cmp.text("text1")).pageFooter(cmp.pageNumber()); + final JasperReportBuilder report2 = report().title(cmp.text("text2")).pageFooter(cmp.pageNumber()); + final JasperReportBuilder report3 = report().title(cmp.text("text3")).pageFooter(cmp.pageNumber()); + + final JRSwapFile swapFile = new JRSwapFile(System.getProperty("java.io.tmpdir"), 2000, 5000); + this.concatenatedReport = concatenatedReport(new JasperPrintListFileHandler( + System.getProperty("java.io.tmpdir"), + new JRSwapFileVirtualizer(3, swapFile))); + this.concatenatedReport.continuousPageNumbering(); + this.concatenatedReport.concatenate(report1, report2, report3); + } + + @Test + void test() + { + try + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals( + "text1\n1\ntext2\n2\ntext3\n3\n", + new String(bos.toByteArray())); + + this.concatenatedReport.setContinuousPageNumbering(false); + bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals( + "text1\n1\ntext2\n2\ntext3\n3\n", + new String(bos.toByteArray())); + } + catch(final DRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport4Test.java new file mode 100644 index 0000000..3e007a0 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport4Test.java @@ -0,0 +1,79 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.concatenatedReport; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; + +import java.io.ByteArrayOutputStream; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.jasper.base.reporthandler.JasperPrintListHandler; +import software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.exception.DRException; + + +/** + * @author Ricardo Mariaca + */ +class ConcatenatedReport4Test +{ + JasperConcatenatedReportBuilder concatenatedReport; + + @BeforeEach + public void init() + { + final JasperReportBuilder report1 = report().title(cmp.text("text1")).pageFooter(cmp.pageNumber()); + final JasperReportBuilder report2 = report().title(cmp.text("text2")).pageFooter(cmp.pageNumber()); + final JasperReportBuilder report3 = report().title(cmp.text("text3")).pageFooter(cmp.pageNumber()); + + this.concatenatedReport = concatenatedReport(new JasperPrintListHandler()); + this.concatenatedReport.continuousPageNumbering(); + this.concatenatedReport.concatenate(report1, report2, report3); + } + + @Test + void test() + { + try + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals( + "text1\n1\ntext2\n2\ntext3\n3\n", + bos.toString()); + + this.concatenatedReport.setContinuousPageNumbering(false); + bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals( + "text1\n1\ntext2\n2\ntext3\n3\n", + bos.toString()); + } + catch(final DRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport5Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport5Test.java new file mode 100644 index 0000000..62e67b7 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ConcatenatedReport5Test.java @@ -0,0 +1,104 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.concatenatedReport; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; + +import java.io.ByteArrayOutputStream; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRField; + + +/** + * @author Ricardo Mariaca + */ +class ConcatenatedReport5Test +{ + JasperConcatenatedReportBuilder concatenatedReport; + + @BeforeEach + public void init() + { + final JasperReportBuilder report1 = report().title(cmp.text("text1")) + .setWhenNoDataType(WhenNoDataType.BLANK_PAGE) + .setDataSource(new DataSource()); + final JasperReportBuilder report2 = report().title(cmp.text("text2")) + .setWhenNoDataType(WhenNoDataType.BLANK_PAGE) + .setDataSource(new DataSource()); + final JasperReportBuilder report3 = report().title(cmp.text("text3")) + .setWhenNoDataType(WhenNoDataType.BLANK_PAGE) + .setDataSource(new DataSource()); + + this.concatenatedReport = concatenatedReport(); + this.concatenatedReport.concatenate(report1, report2, report3); + } + + @Test + void test() + { + try + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals("text1\ntext2\ntext3\n", new String(bos.toByteArray())); + + bos = new ByteArrayOutputStream(); + this.concatenatedReport.toCsv(bos); + Assertions.assertEquals("text1\ntext2\ntext3\n", new String(bos.toByteArray())); + } + catch(final DRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } + + private class DataSource implements JRDataSource + { + private boolean next = true; + + @Override + public boolean next() throws JRException + { + if(this.next) + { + this.next = false; + return true; + } + return this.next; + } + + @Override + public Object getFieldValue(final JRField jrField) throws JRException + { + return null; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/CustomFontTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/CustomFontTest.java new file mode 100644 index 0000000..161a39c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/CustomFontTest.java @@ -0,0 +1,71 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class CustomFontTest extends AbstractJasperPositionTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + StyleBuilder style = stl.style().setFontName("FreeUniversal"); + + rb.columns(column1 = col.column("Column1", "field1", type.stringType())).subtotalsAtColumnFooter(subtotal1 = sbt.text("text", column1).setStyle(style)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnTitlePositionTest(column1, 0, 10, 10, 575, 16); + columnDetailPositionTest(column1, 0, 10, 26, 575, 16); + + // subtotal1 + subtotalPositionTest(subtotal1, 0, 10, 818, 575, 14); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add("1"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/DetailBand1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/DetailBand1Test.java new file mode 100644 index 0000000..fbc4016 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/DetailBand1Test.java @@ -0,0 +1,69 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class DetailBand1Test extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columns(column1 = col.column("Column1", "field1", String.class)).detailHeader(cmp.text("detailHeader")).detailFooter(cmp.text("detailFooter")); + + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementCountTest("detailHeader.textField1", 2); + elementValueTest("detailHeader.textField1", "detailHeader", "detailHeader"); + + columnDetailCountTest(column1, 2); + columnDetailValueTest(column1, "detail", "detail"); + + elementCountTest("detailFooter.textField1", 2); + elementValueTest("detailFooter.textField1", "detailFooter", "detailFooter"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 2; i++) { + dataSource.add("detail"); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/DetailBand2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/DetailBand2Test.java new file mode 100644 index 0000000..97b1501 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/DetailBand2Test.java @@ -0,0 +1,63 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class DetailBand2Test extends AbstractJasperPositionTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.columns(column1 = col.column("Column1", "field1", String.class)).detailHeader(cmp.filler().setFixedHeight(10)).detailFooter(cmp.filler().setFixedHeight(15)); + + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + columnDetailPositionTest(column1, 0, 10, 36, 575, 16); + columnDetailPositionTest(column1, 1, 10, 77, 575, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 2; i++) { + dataSource.add("detail"); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ExportTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ExportTest.java new file mode 100644 index 0000000..31c0002 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ExportTest.java @@ -0,0 +1,110 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.concatenatedReport; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; + +import java.io.ByteArrayOutputStream; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import net.sf.jasperreports.engine.JRDataSource; +import software.xdev.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.exception.DRException; + + +/** + * @author Ricardo Mariaca + */ +class ExportTest +{ + JasperReportBuilder report; + JasperConcatenatedReportBuilder concatenatedReport; + + @BeforeEach + public void init() + { + this.report = report(); + this.report.columns(col.column("Column1", "field1", String.class)); + this.report.setDataSource(this.createDataSource()); + + this.concatenatedReport = concatenatedReport(); + this.concatenatedReport.concatenate(this.report, this.report, this.report); + } + + @Test + void exportTest() + { + try + { + this.report.toJrXml(new ByteArrayOutputStream()); + this.report.toCsv(new ByteArrayOutputStream()); + this.report.toDocx(new ByteArrayOutputStream()); + this.report.toHtml(new ByteArrayOutputStream()); + this.report.toOds(new ByteArrayOutputStream()); + this.report.toOdt(new ByteArrayOutputStream()); + this.report.toPdf(new ByteArrayOutputStream()); + this.report.toRtf(new ByteArrayOutputStream()); + this.report.toText(new ByteArrayOutputStream()); + this.report.toXlsx(new ByteArrayOutputStream()); + this.report.toPptx(new ByteArrayOutputStream()); + } + catch(final DRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } + + @Test + void concatenatedExportTest() + { + try + { + this.concatenatedReport.toPng(new ByteArrayOutputStream()); + this.concatenatedReport.toCsv(new ByteArrayOutputStream()); + this.concatenatedReport.toDocx(new ByteArrayOutputStream()); + this.concatenatedReport.toHtml(new ByteArrayOutputStream()); + this.concatenatedReport.toOds(new ByteArrayOutputStream()); + this.concatenatedReport.toOdt(new ByteArrayOutputStream()); + this.concatenatedReport.toPdf(new ByteArrayOutputStream()); + this.concatenatedReport.toRtf(new ByteArrayOutputStream()); + this.concatenatedReport.toText(new ByteArrayOutputStream()); + this.concatenatedReport.toXlsx(new ByteArrayOutputStream()); + this.concatenatedReport.toPptx(new ByteArrayOutputStream()); + } + catch(final DRException e) + { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } + + private JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add("field1"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ExpressionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ExpressionTest.java new file mode 100644 index 0000000..a042ec2 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ExpressionTest.java @@ -0,0 +1,91 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; + +import java.io.Serializable; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class ExpressionTest extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + @SuppressWarnings("unchecked") + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setLocale(Locale.ENGLISH).title(cmp.text(new Expression1()), cmp.text(new Expression2("text2")), cmp.text(new Expression4()).setDataType(type.integerType())); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementValueTest("title.textField1", "text1"); + elementValueTest("title.textField2", "text2"); + elementValueTest("title.textField3", "1,000"); + } + + @SuppressWarnings("rawtypes") + private class Expression1 extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Object evaluate(ReportParameters reportParameters) { + return "text1"; + } + } + + private class Expression2 extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + private T value; + + private Expression2(T value) { + this.value = value; + } + + @Override + public T evaluate(ReportParameters reportParameters) { + return value; + } + } + + private class Expression3 extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public Integer evaluate(ReportParameters reportParameters) { + return 1000; + } + } + + private class Expression4 extends Expression3 { + private static final long serialVersionUID = 1L; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/FieldDataTypeTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/FieldDataTypeTest.java new file mode 100644 index 0000000..fa68820 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/FieldDataTypeTest.java @@ -0,0 +1,194 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.FieldBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.Locale; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class FieldDataTypeTest extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + + private AggregationSubtotalBuilder subtotal1; + private AggregationSubtotalBuilder subtotal2; + private AggregationSubtotalBuilder subtotal3; + private AggregationSubtotalBuilder subtotal4; + private AggregationSubtotalBuilder subtotal5; + private AggregationSubtotalBuilder subtotal6; + private AggregationSubtotalBuilder subtotal7; + private AggregationSubtotalBuilder subtotal8; + private AggregationSubtotalBuilder subtotal9; + + private AggregationSubtotalBuilder subtotal10; + private AggregationSubtotalBuilder subtotal11; + private AggregationSubtotalBuilder subtotal12; + private AggregationSubtotalBuilder subtotal13; + private AggregationSubtotalBuilder subtotal14; + private AggregationSubtotalBuilder subtotal15; + private AggregationSubtotalBuilder subtotal16; + private AggregationSubtotalBuilder subtotal17; + private AggregationSubtotalBuilder subtotal18; + + private AggregationSubtotalBuilder subtotal19; + private AggregationSubtotalBuilder subtotal20; + private AggregationSubtotalBuilder subtotal21; + private AggregationSubtotalBuilder subtotal22; + private AggregationSubtotalBuilder subtotal23; + + private AggregationSubtotalBuilder subtotal24; + private AggregationSubtotalBuilder subtotal25; + private AggregationSubtotalBuilder subtotal26; + private AggregationSubtotalBuilder subtotal27; + private AggregationSubtotalBuilder subtotal28; + + @Override + protected void configureReport(JasperReportBuilder rb) { + FieldBuilder field1; + FieldBuilder field2; + FieldBuilder field3; + FieldBuilder field4; + + rb.setLocale(Locale.ENGLISH) + .fields(field1 = field("field1", type.bigDecimalType()), field2 = field("field2", type.integerType()), field3 = field("field3", type.stringType()), field4 = field("field4", type.dateType())) + .columns(column1 = col.column("Column1", field1), column2 = col.column("Column2", field2), column3 = col.column("Column2", field3), column4 = col.column("Column3", field4)) + .subtotalsAtSummary(subtotal1 = sbt.sum(field1, column1), subtotal2 = sbt.avg(field1, column1), subtotal3 = sbt.count(field1, column1), subtotal4 = sbt.distinctCount(field1, column1), + subtotal5 = sbt.first(field1, column1), subtotal6 = sbt.min(field1, column1), subtotal7 = sbt.max(field1, column1), subtotal8 = sbt.stdDev(field1, column1), + subtotal9 = sbt.var(field1, column1), + + subtotal10 = sbt.sum(field2, column2), subtotal11 = sbt.avg(field2, column2), subtotal12 = sbt.count(field2, column2), subtotal13 = sbt.distinctCount(field2, column2), + subtotal14 = sbt.first(field2, column2), subtotal15 = sbt.min(field2, column2), subtotal16 = sbt.max(field2, column2), subtotal17 = sbt.stdDev(field2, column2), + subtotal18 = sbt.var(field2, column2), + + subtotal19 = sbt.count(field3, column3), subtotal20 = sbt.distinctCount(field3, column3), subtotal21 = sbt.first(field3, column3), subtotal22 = sbt.min(field3, column3), + subtotal23 = sbt.max(field3, column3), + + subtotal24 = sbt.count(field4, column4), subtotal25 = sbt.distinctCount(field4, column4), subtotal26 = sbt.first(field4, column4), subtotal27 = sbt.min(field4, column4), + subtotal28 = sbt.max(field4, column4)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column + columnDetailCountTest(column1, 5); + columnDetailValueTest(column1, "1.01", "2.01", "9.01", "11.01", "2.01"); + columnDetailCountTest(column2, 5); + columnDetailValueTest(column2, "5", "5", "8", "12", "6"); + columnDetailCountTest(column3, 5); + columnDetailValueTest(column3, "value8", "value2", "value3", "value3", "value1"); + columnDetailCountTest(column4, 5); + columnDetailValueTest(column4, "01/01/2010", "02/01/2010", "02/01/2010", "03/01/2010", "04/01/2010"); + + // summary + subtotalIndexCountTest(subtotal1, 1, 1); + subtotalIndexValueTest(subtotal1, 1, "25.05"); + subtotalIndexCountTest(subtotal2, 2, 1); + subtotalIndexValueTest(subtotal2, 2, "5"); + subtotalIndexCountTest(subtotal3, 3, 1); + subtotalIndexValueTest(subtotal3, 3, "5"); + subtotalIndexCountTest(subtotal4, 4, 1); + subtotalIndexValueTest(subtotal4, 4, "4"); + subtotalIndexCountTest(subtotal5, 5, 1); + subtotalIndexValueTest(subtotal5, 5, "1.01"); + subtotalIndexCountTest(subtotal6, 6, 1); + subtotalIndexValueTest(subtotal6, 6, "1.01"); + subtotalIndexCountTest(subtotal7, 7, 1); + subtotalIndexValueTest(subtotal7, 7, "11.01"); + subtotalIndexCountTest(subtotal8, 8, 1); + subtotalIndexValueTest(subtotal8, 8, "4.1"); + subtotalIndexCountTest(subtotal9, 9, 1); + subtotalIndexValueTest(subtotal9, 9, "17.2"); + + subtotalIndexCountTest(subtotal10, 1, 1); + subtotalIndexValueTest(subtotal10, 1, "36"); + subtotalIndexCountTest(subtotal11, 2, 1); + subtotalIndexValueTest(subtotal11, 2, "7.2"); + subtotalIndexCountTest(subtotal12, 3, 1); + subtotalIndexValueTest(subtotal12, 3, "5"); + subtotalIndexCountTest(subtotal13, 4, 1); + subtotalIndexValueTest(subtotal13, 4, "4"); + subtotalIndexCountTest(subtotal14, 5, 1); + subtotalIndexValueTest(subtotal14, 5, "5"); + subtotalIndexCountTest(subtotal15, 6, 1); + subtotalIndexValueTest(subtotal15, 6, "5"); + subtotalIndexCountTest(subtotal16, 7, 1); + subtotalIndexValueTest(subtotal16, 7, "12"); + subtotalIndexCountTest(subtotal17, 8, 1); + subtotalIndexValueTest(subtotal17, 8, "2.6"); + subtotalIndexCountTest(subtotal18, 9, 1); + subtotalIndexValueTest(subtotal18, 9, "7"); + + subtotalIndexCountTest(subtotal19, 1, 1); + subtotalIndexValueTest(subtotal19, 1, "5"); + subtotalIndexCountTest(subtotal20, 2, 1); + subtotalIndexValueTest(subtotal20, 2, "4"); + subtotalIndexCountTest(subtotal21, 3, 1); + subtotalIndexValueTest(subtotal21, 3, "value8"); + subtotalIndexCountTest(subtotal22, 4, 1); + subtotalIndexValueTest(subtotal22, 4, "value1"); + subtotalIndexCountTest(subtotal23, 5, 1); + subtotalIndexValueTest(subtotal23, 5, "value8"); + + subtotalIndexCountTest(subtotal24, 1, 1); + subtotalIndexValueTest(subtotal24, 1, "5"); + subtotalIndexCountTest(subtotal25, 2, 1); + subtotalIndexValueTest(subtotal25, 2, "4"); + subtotalIndexCountTest(subtotal26, 3, 1); + subtotalIndexValueTest(subtotal26, 3, "01/01/2010"); + subtotalIndexCountTest(subtotal27, 4, 1); + subtotalIndexValueTest(subtotal27, 4, "01/01/2010"); + subtotalIndexCountTest(subtotal28, 5, 1); + subtotalIndexValueTest(subtotal28, 5, "04/01/2010"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add(new BigDecimal(1.01), 5, "value8", toDate(2010, 1, 1)); + dataSource.add(new BigDecimal(2.01), 5, "value2", toDate(2010, 2, 1)); + dataSource.add(new BigDecimal(9.01), 8, "value3", toDate(2010, 2, 1)); + dataSource.add(new BigDecimal(11.01), 12, "value3", toDate(2010, 3, 1)); + dataSource.add(new BigDecimal(2.01), 6, "value1", toDate(2010, 4, 1)); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/HyperLinkTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/HyperLinkTest.java new file mode 100644 index 0000000..ea95d73 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/HyperLinkTest.java @@ -0,0 +1,82 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.hyperLink; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.HyperLinkBuilder; +import software.xdev.dynamicreports.report.constant.HyperLinkTarget; +import software.xdev.dynamicreports.report.constant.HyperLinkType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRPrintText; +import net.sf.jasperreports.engine.type.HyperlinkTargetEnum; +import net.sf.jasperreports.engine.type.HyperlinkTypeEnum; + + +/** + * @author Ricardo Mariaca + */ +public class HyperLinkTest extends AbstractJasperValueTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + final HyperLinkBuilder hyperLink1 = hyperLink().setReference("reference") + .setTooltip("tooltip") + .setAnchor("anchor") + .setPage(1) + .setType(HyperLinkType.LOCAL_ANCHOR) + .setTarget(HyperLinkTarget.TOP); + final HyperLinkBuilder hyperLink2 = hyperLink().setType("customType").setTarget("customTarget"); + + rb.title( + cmp.text("title 1").setHyperLink(hyperLink1).setAnchorName("anchorName").setBookmarkLevel(1), + cmp.text("title 2").setHyperLink(hyperLink2)); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + JRPrintText textField = (JRPrintText)this.getElementAt("title.textField1", 0); + Assertions.assertEquals("reference", textField.getHyperlinkReference()); + Assertions.assertEquals("tooltip", textField.getHyperlinkTooltip()); + Assertions.assertEquals("anchor", textField.getHyperlinkAnchor()); + Assertions.assertEquals("anchorName", textField.getAnchorName()); + Assertions.assertEquals(1, textField.getBookmarkLevel()); + Assertions.assertEquals(Integer.valueOf(1), textField.getHyperlinkPage()); + Assertions.assertEquals(HyperlinkTypeEnum.LOCAL_ANCHOR, textField.getHyperlinkTypeValue()); + Assertions.assertEquals(HyperlinkTypeEnum.LOCAL_ANCHOR.getName(), textField.getLinkType()); + Assertions.assertEquals(HyperlinkTargetEnum.TOP, textField.getHyperlinkTargetValue()); + Assertions.assertEquals(HyperlinkTargetEnum.TOP.getName(), textField.getLinkTarget()); + + textField = (JRPrintText)this.getElementAt("title.textField2", 0); + Assertions.assertEquals(HyperlinkTypeEnum.CUSTOM, textField.getHyperlinkTypeValue()); + Assertions.assertEquals("customType", textField.getLinkType()); + Assertions.assertEquals(HyperlinkTargetEnum.CUSTOM, textField.getHyperlinkTargetValue()); + Assertions.assertEquals("customTarget", textField.getLinkTarget()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/IgnorePageWidthTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/IgnorePageWidthTest.java new file mode 100644 index 0000000..86a2528 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/IgnorePageWidthTest.java @@ -0,0 +1,92 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class IgnorePageWidthTest extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private TextColumnBuilder column5; + private TextColumnBuilder column6; + private TextColumnBuilder column7; + private TextColumnBuilder column8; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.ignorePageWidth() + .title(cmp.text("text")) + .columns(column1 = col.column("Column2", "field1", String.class), column2 = col.column("Column2", "field2", String.class), column3 = col.column("Column3", "field3", String.class), + column4 = col.column("Column4", "field4", String.class).setWidth(150), column5 = col.column("Column5", "field5", String.class).setFixedWidth(50), + column6 = col.column("Column6", "field6", String.class), column7 = col.column("Column7", "field7", String.class), column8 = col.column("Column8", "field8", String.class)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("title.textField1", 0, 10, 10, 800, 16); + elementPositionTest("columnHeader.list1", 0, 10, 26, 800, 16); + + // column1 + columnTitlePositionTest(column1, 0, 0, 0, 100, 16); + columnDetailPositionTest(column1, 0, 0, 0, 100, 16); + // column2 + columnTitlePositionTest(column2, 0, 100, 0, 100, 16); + columnDetailPositionTest(column2, 0, 100, 0, 100, 16); + // column3 + columnTitlePositionTest(column3, 0, 200, 0, 100, 16); + columnDetailPositionTest(column3, 0, 200, 0, 100, 16); + // column4 + columnTitlePositionTest(column4, 0, 300, 0, 150, 16); + columnDetailPositionTest(column4, 0, 300, 0, 150, 16); + // column5 + columnTitlePositionTest(column5, 0, 450, 0, 50, 16); + columnDetailPositionTest(column5, 0, 450, 0, 50, 16); + // column6 + columnTitlePositionTest(column6, 0, 500, 0, 100, 16); + columnDetailPositionTest(column6, 0, 500, 0, 100, 16); + // column7 + columnTitlePositionTest(column7, 0, 600, 0, 100, 16); + columnDetailPositionTest(column7, 0, 600, 0, 100, 16); + // column8 + columnTitlePositionTest(column8, 0, 700, 0, 100, 16); + columnDetailPositionTest(column8, 0, 700, 0, 100, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4", "field5", "field6", "field7", "field8"); + dataSource.add("text", "text", "text", "text", "text", "text", "text", "text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/IgnorePaginationTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/IgnorePaginationTest.java new file mode 100644 index 0000000..de4cacd --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/IgnorePaginationTest.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.type.OrientationEnum; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class IgnorePaginationTest extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(JasperReportBuilder rb) { + + rb.columns(col.column("Column1", "field1", Integer.class)).setIgnorePagination(true); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + JasperPrint jasperPrint = getJasperPrint(); + Assertions.assertEquals(OrientationEnum.PORTRAIT, jasperPrint.getOrientationValue()); + Assertions.assertEquals(595, jasperPrint.getPageWidth()); + Assertions.assertEquals(1636, jasperPrint.getPageHeight()); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 100; i++) { + dataSource.add(i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/JasperExpressionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/JasperExpressionTest.java new file mode 100644 index 0000000..c9d9c16 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/JasperExpressionTest.java @@ -0,0 +1,89 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.exp; + +import java.io.ByteArrayOutputStream; +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.exception.DRException; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + + +/** + * @author Ricardo Mariaca + */ +public class JasperExpressionTest extends AbstractJasperValueTest implements Serializable +{ + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column2; + private TextColumnBuilder column3; + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.columns( + this.column2 = col.column("field2", Integer.class).setTitle(exp.jasperSyntax("\"Column2\"", String.class)), + this.column3 = col.column(exp.jasperSyntax("$F{field1} - $F{field2}", Integer.class))); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + this.columnTitleCountTest(this.column2, 1); + this.columnTitleValueTest(this.column2, "Column2"); + + this.columnDetailValueTest(this.column3, "0", "8", "3"); + + try + { + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); + this.getReportBuilder().toJrXml(bos); + final String jrxml = bos.toString(); + Assertions.assertFalse(StringUtils.contains(jrxml, "software.xdev.dynamicreports")); + } + catch(final DRException e) + { + Assertions.fail(e.getMessage()); + } + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1", "field2"); + dataSource.add(1, 1); + dataSource.add(10, 2); + dataSource.add(5, 2); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ListDataTypeTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ListDataTypeTest.java new file mode 100644 index 0000000..83f02e5 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ListDataTypeTest.java @@ -0,0 +1,73 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.util.ArrayList; +import java.util.List; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +/** + * @author Ricardo Mariaca + */ +public class ListDataTypeTest extends AbstractJasperValueTest { + private TextColumnBuilder column1; + @SuppressWarnings("rawtypes") + private TextColumnBuilder column2; + @SuppressWarnings("rawtypes") + private TextColumnBuilder column3; + + @Override + protected void configureReport(JasperReportBuilder rb) { + + rb.columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", List.class), column3 = col.column("Column3", "field2", type.listType())); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + columnDetailValueTest(column1, "row1", "row2"); + columnDetailValueTest(column2, "comment1\ncomment2\ncomment3", "comment1\ncomment2"); + columnDetailValueTest(column3, "comment1\ncomment2\ncomment3", "comment1\ncomment2"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + List comments = new ArrayList(); + comments.add("comment1"); + comments.add("comment2"); + comments.add("comment3"); + dataSource.add("row1", comments); + comments = new ArrayList(); + comments.add("comment1"); + comments.add("comment2"); + dataSource.add("row2", comments); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/MarkupTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/MarkupTest.java new file mode 100644 index 0000000..bf59453 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/MarkupTest.java @@ -0,0 +1,71 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.constant.Markup; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class MarkupTest extends AbstractJasperValueTest { + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + StyleBuilder style = stl.style().setMarkup(Markup.HTML); + + rb.setColumnStyle(style) + .columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class)) + .subtotalsAtSummary(subtotal1 = sbt.sum(column2).setLabel("subtotal subtotal subtotal").setLabelStyle(style)) + .title(cmp.text("title title title").setMarkup(Markup.HTML)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + columnDetailValueTest(column1, "column column"); + elementValueTest("title.textField1", "title title"); + subtotalLabelValueTest(subtotal1, "subtotal subtotal"); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 0; i < 1; i++) { + dataSource.add("column column column", i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/NoDataSectionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/NoDataSectionTest.java new file mode 100644 index 0000000..b47b348 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/NoDataSectionTest.java @@ -0,0 +1,43 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class NoDataSectionTest extends AbstractJasperValueTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.noData(cmp.text("Empty data")); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + elementCountTest("noData.textField1", 1); + elementValueTest("noData.textField1", "Empty data"); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/NoDetailSectionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/NoDetailSectionTest.java new file mode 100644 index 0000000..6f05260 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/NoDetailSectionTest.java @@ -0,0 +1,43 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class NoDetailSectionTest extends AbstractJasperValueTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.title(cmp.text("Empty data")); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + elementCountTest("title.textField1", 1); + elementValueTest("title.textField1", "Empty data"); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ParametersTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ParametersTest.java new file mode 100644 index 0000000..112fb75 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ParametersTest.java @@ -0,0 +1,95 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.report.exception.DRException; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.JasperReport; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class ParametersTest extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.title(cmp.text(new TitleExpression())).addParameter("title", String.class); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementValueTest("title.textField1", ""); + + try { + JasperReport jasperReport = getJasperReport(); + JasperPrint jasperPrint = getJasperPrint(); + getReportBuilder().setParameter("title", "1"); + build(); + elementValueTest("title.textField1", "1"); + Assertions.assertSame(jasperReport, getJasperReport()); + Assertions.assertNotSame(jasperPrint, getJasperPrint()); + + jasperReport = getJasperReport(); + jasperPrint = getJasperPrint(); + getReportBuilder().setParameter("title", "2"); + build(); + elementValueTest("title.textField1", "2"); + Assertions.assertSame(jasperReport, getJasperReport()); + Assertions.assertNotSame(jasperPrint, getJasperPrint()); + + jasperReport = getJasperReport(); + jasperPrint = getJasperPrint(); + Map parameters = new HashMap(); + parameters.put("title", "3"); + getReportBuilder().setParameters(parameters); + build(); + elementValueTest("title.textField1", "3"); + Assertions.assertSame(jasperReport, getJasperReport()); + Assertions.assertNotSame(jasperPrint, getJasperPrint()); + } catch (DRException e) { + e.printStackTrace(); + Assertions.fail(e.getMessage()); + } + } + + private class TitleExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + @Override + public String evaluate(ReportParameters reportParameters) { + return reportParameters.getValue("title"); + } + + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/PrintWhenExpressionTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/PrintWhenExpressionTest.java new file mode 100644 index 0000000..8dcde1b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/PrintWhenExpressionTest.java @@ -0,0 +1,55 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.exp; + +/** + * @author Ricardo Mariaca + */ +public class PrintWhenExpressionTest extends AbstractJasperValueTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.title(cmp.text("title1").setPrintWhenExpression(exp.value(true)), cmp.text("title2").setPrintWhenExpression(exp.value(false))) + .summary(cmp.text("summary1")) + .setSummaryPrintWhenExpression(exp.value(true)) + .pageFooter(cmp.text("pageFooter1")) + .setPageFooterPrintWhenExpression(exp.value(false)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementCountTest("title.textField1", 1); + elementValueTest("title.textField1", "title1"); + elementCountTest("title.textField2", 0); + + elementCountTest("summary.textField1", 1); + elementValueTest("summary.textField1", "summary1"); + + elementCountTest("pageFooter.textField1", 0); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report1Test.java new file mode 100644 index 0000000..8d3fb3b --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report1Test.java @@ -0,0 +1,136 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.exp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.parameter; + +import java.math.BigDecimal; +import java.util.ListResourceBundle; +import java.util.Locale; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.AbstractScriptlet; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.report.constant.WhenResourceMissingType; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.DefaultJasperReportsContext; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.fonts.FontUtil; +import net.sf.jasperreports.engine.type.OrientationEnum; + +/** + * @author Ricardo Mariaca + */ +public class Report1Test extends AbstractJasperValueTest { + private TextColumnBuilder column1; + private ReportScriptlet scriptlet; + private BigDecimal parameter1; + private BigDecimal parameter2; + + @Override + protected void configureReport(final JasperReportBuilder rb) { + rb.columns(this.column1 = col.column("Column1", "field1", Integer.class)) + .title(cmp.text(exp.jasperSyntax("$R{bundleKey3}", String.class)), + cmp.multiPageList(cmp.text(exp.jasperSyntax("$R{bundleKey3}", String.class)), cmp.text(exp.jasperSyntax("$R{bundleKey1}", String.class)))) + .setLocale(Locale.ENGLISH) + .setResourceBundle(new ResourceBundle()) + .setWhenResourceMissingType(WhenResourceMissingType.KEY) + .setShowColumnTitle(false) + .setShowColumnValues(false) + .setPageFormat(PageType.A3, PageOrientation.LANDSCAPE) + .scriptlets(this.scriptlet = new ReportScriptlet()) + .parameters(parameter("parameter1", this.parameter1 = new BigDecimal(10))) + .addParameter("parameter2", this.parameter2 = new BigDecimal(20)); + } + + @Override + public void test() { + super.test(); + + this.numberOfPagesTest(1); + this.columnTitleCountTest(this.column1, 0); + this.columnDetailCountTest(this.column1, 0); + + this.elementCountTest("title.textField1", 3); + this.elementValueTest("title.textField1", "bundleKey3", "bundleKey3", "bundleValue"); + + final FontUtil fontUtil = FontUtil.getInstance(DefaultJasperReportsContext.getInstance()); + Assertions.assertFalse(fontUtil.getFontFamilyNames().isEmpty()); + + final JasperPrint jasperPrint = this.getJasperPrint(); + Assertions.assertEquals("Report", jasperPrint.getName()); + Assertions.assertEquals(OrientationEnum.LANDSCAPE, jasperPrint.getOrientationValue()); + Assertions.assertEquals(1190, jasperPrint.getPageWidth()); + Assertions.assertEquals(842, jasperPrint.getPageHeight()); + + Assertions.assertEquals(50, this.scriptlet.count); + } + + @Override + protected boolean serializableTest() { + return false; + } + + @Override + protected JRDataSource createDataSource() { + final DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 50; i++) { + dataSource.add(i); + } + return dataSource; + } + + private class ResourceBundle extends ListResourceBundle { + + @Override + protected Object[][] getContents() { + return new Object[][] {{"bundleKey1", "bundleValue"}, {"bundleKey2", "bundleValue {0} - {1}"}}; + } + } + + private class ReportScriptlet extends AbstractScriptlet { + private int count; + + @Override + public void afterReportInit(final ReportParameters reportParameters) { + super.afterReportInit(reportParameters); + Assertions.assertEquals(Locale.ENGLISH, reportParameters.getLocale()); + Assertions.assertEquals("bundleValue", reportParameters.getMessage("bundleKey1")); + Assertions.assertEquals("bundleValue a - b", reportParameters.getMessage("bundleKey2", new Object[] {"a", "b"})); + Assertions.assertEquals(Report1Test.this.parameter1, reportParameters.getValue("parameter1")); + Assertions.assertEquals(Report1Test.this.parameter2, reportParameters.getValue("parameter2")); + Assertions.assertEquals(this, reportParameters.getScriptlet(this.getName())); + } + + @Override + public void afterDetailEval(final ReportParameters reportParameters) { + super.afterDetailEval(reportParameters); + this.count++; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report2Test.java new file mode 100644 index 0000000..bf9081e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report2Test.java @@ -0,0 +1,79 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; + +/** + * @author Ricardo Mariaca + */ +public class Report2Test extends AbstractJasperPositionTest implements Serializable { + private static final long serialVersionUID = 1L; + + private AggregationSubtotalBuilder subtotal1; + private AggregationSubtotalBuilder subtotal2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1; + + rb.setTitleOnANewPage(true) + .setSummaryOnANewPage(true) + .setFloatColumnFooter(true) + .columns(column1 = col.column("Column1", "field1", Integer.class)) + .subtotalsAtColumnFooter(subtotal1 = sbt.sum(column1)) + .subtotalsAtSummary(subtotal2 = sbt.sum(column1)) + .title(cmp.text("title")); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(3); + + // title + elementPositionTest("title.textField1", 0, 10, 10, 575, 16); + + // column footer + subtotalPositionTest(subtotal1, 0, 10, 186, 575, 16); + + // summary + subtotalPositionTest(subtotal2, 0, 10, 10, 575, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 10; i++) { + dataSource.add(i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report3Test.java new file mode 100644 index 0000000..520127a --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report3Test.java @@ -0,0 +1,68 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JasperPrint; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class Report3Test extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setReportName("report1") + .setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL) + .setSummaryOnANewPage(true) + .setSummaryWithPageHeaderAndFooter(true) + .pageHeader(cmp.text("page header")) + .pageFooter(cmp.text("page footer")) + .summary(cmp.text("summary")); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(2); + + JasperPrint jasperPrint = getJasperPrint(); + Assertions.assertEquals("report1", jasperPrint.getName()); + + // page header + elementCountTest("pageHeader.textField1", 2); + elementValueTest("pageHeader.textField1", "page header", "page header"); + + // page footer + elementCountTest("pageFooter.textField1", 2); + elementValueTest("pageFooter.textField1", "page footer", "page footer"); + + // summary + elementCountTest("summary.textField1", 1); + elementValueTest("summary.textField1", "summary"); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report4Test.java new file mode 100644 index 0000000..89354a4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report4Test.java @@ -0,0 +1,66 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.Language; +import software.xdev.dynamicreports.report.constant.Orientation; +import software.xdev.dynamicreports.report.constant.RunDirection; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; +import net.sf.jasperreports.engine.JRDataSource; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; + +/** + * @author Ricardo Mariaca + */ +public class Report4Test extends AbstractJasperPositionTest { + private TextColumnBuilder column1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setPageColumnsPerPage(2) + .setPrintOrder(Orientation.HORIZONTAL) + .setColumnDirection(RunDirection.RIGHT_TO_LEFT) + .setLanguage(Language.GROOVY) + .columns(column1 = col.column("Column1", "field1", Integer.class)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + columnDetailPositionTest(column1, 0, 298, 26, 287, 16); + columnDetailPositionTest(column1, 1, 11, 26, 287, 16); + columnDetailPositionTest(column1, 2, 298, 42, 287, 16); + columnDetailPositionTest(column1, 3, 11, 42, 287, 16); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + for (int i = 0; i < 4; i++) { + dataSource.add(i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report5Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report5Test.java new file mode 100644 index 0000000..bfdb793 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/Report5Test.java @@ -0,0 +1,100 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import org.junit.jupiter.api.Assertions; +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.component.SubreportBuilder; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JREmptyDataSource; +import net.sf.jasperreports.engine.JRParameter; +import net.sf.jasperreports.engine.JasperPrint; + +import java.util.HashMap; +import java.util.ListResourceBundle; +import java.util.Locale; +import java.util.Map; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.exp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; + +/** + * @author Ricardo Mariaca + */ +public class Report5Test extends AbstractJasperValueTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + SubreportBuilder detailSubreport = cmp.subreport(detailSubreport()).setParameters(new SubreportParametersExpression()); + + rb.title(cmp.text(exp.jasperSyntax("$R{bundleKey1}", String.class))).detail(detailSubreport).setLocale(Locale.ENGLISH).setResourceBundle(new ResourceBundle()); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementCountTest("title.textField1", 3); + elementValueTest("title.textField1", "bundleValue1", "bundleValue1", "bundleValue1"); + + JasperPrint jasperPrint = getJasperPrint(); + Assertions.assertEquals(Locale.ENGLISH.getLanguage(), jasperPrint.getLocaleCode()); + } + + @Override + protected boolean serializableTest() { + return false; + } + + @Override + protected JRDataSource createDataSource() { + return new JREmptyDataSource(2); + } + + private JasperReportBuilder detailSubreport() { + JasperReportBuilder report = report(); + report.title(cmp.text(exp.jasperSyntax("$R{bundleKey1}", String.class))); + return report; + } + + private class SubreportParametersExpression extends AbstractSimpleExpression> { + private static final long serialVersionUID = 1L; + + @Override + public Map evaluate(ReportParameters reportParameters) { + Map parameters = new HashMap(); + parameters.put(JRParameter.REPORT_LOCALE, reportParameters.getParameterValue(JRParameter.REPORT_LOCALE)); + parameters.put(JRParameter.REPORT_RESOURCE_BUNDLE, reportParameters.getParameterValue(JRParameter.REPORT_RESOURCE_BUNDLE)); + return parameters; + } + } + + private class ResourceBundle extends ListResourceBundle { + + @Override + protected Object[][] getContents() { + return new Object[][] {{"bundleKey1", "bundleValue1"}}; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ReportBackground1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ReportBackground1Test.java new file mode 100644 index 0000000..cf42194 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ReportBackground1Test.java @@ -0,0 +1,47 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class ReportBackground1Test extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).background(cmp.text("text")).setBackgroundStyle(stl.style()); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("background.list1", 0, 10, 10, 822, 575); + elementPositionTest("background.textField1", 0, 0, 0, 822, 16); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ReportBackground2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ReportBackground2Test.java new file mode 100644 index 0000000..5b476f6 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ReportBackground2Test.java @@ -0,0 +1,45 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class ReportBackground2Test extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).setBackgroundStyle(stl.style()); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("background.list1", 0, 10, 10, 822, 575); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ReportBackground3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ReportBackground3Test.java new file mode 100644 index 0000000..5bd673c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ReportBackground3Test.java @@ -0,0 +1,46 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.PageOrientation; +import software.xdev.dynamicreports.report.constant.PageType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperPositionTest; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class ReportBackground3Test extends AbstractJasperPositionTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE).setBackgroundBackgroundComponent(cmp.rectangle()); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + elementPositionTest("background.list1", 0, 10, 10, 822, 575); + elementPositionTest("background.list1.background", 0, 0, 0, 822, 575); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/TitleTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/TitleTest.java new file mode 100644 index 0000000..0594f34 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/TitleTest.java @@ -0,0 +1,87 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.exp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.hyperLink; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRPrintText; +import net.sf.jasperreports.engine.type.HyperlinkTypeEnum; + + +/** + * @author Ricardo Mariaca + */ +class TitleTest extends AbstractJasperValueTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.setResourceBundle("software.xdev.dynamicreports.test.jasper.report.test") + .columns(col.column("Column1", "field1", Integer.class)) + .title(cmp.text("title 1").setHyperLink(hyperLink("link").setTooltip("tooltip")), + cmp.text("title 2"), + cmp.text("title 3"), + cmp.text(exp.message("title")), + cmp.multiPageList(cmp.text(exp.message("title")))); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(2); + this.elementCountTest("title.textField1", 2); + this.elementValueTest("title.textField1", "title 1", "test title"); + + final JRPrintText textField = (JRPrintText)this.getElementAt("title.textField1", 0); + Assertions.assertEquals("link", textField.getHyperlinkReference()); + Assertions.assertEquals("tooltip", textField.getHyperlinkTooltip()); + Assertions.assertEquals(HyperlinkTypeEnum.REFERENCE, textField.getHyperlinkTypeValue()); + + this.elementCountTest("title.textField2", 1); + this.elementValueTest("title.textField2", "title 2"); + + this.elementCountTest("title.textField3", 1); + this.elementValueTest("title.textField3", "title 3"); + + this.elementCountTest("title.textField4", 1); + this.elementValueTest("title.textField4", "test title"); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1"); + for(int i = 0; i < 50; i++) + { + dataSource.add(i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ValueTypeNamesTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ValueTypeNamesTest.java new file mode 100644 index 0000000..f9b9f44 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/ValueTypeNamesTest.java @@ -0,0 +1,81 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.parameter; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import java.io.Serializable; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; + + +/** + * @author Ricardo Mariaca + */ +public class ValueTypeNamesTest extends AbstractJasperValueTest implements Serializable +{ + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.columns(col.column("Column1", new ColumnExpression())) + .fields(field("field1", type.stringType())) + .parameters(parameter("field1", "parameterValue")); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add("fieldValue"); + return dataSource; + } + + private class ColumnExpression extends AbstractSimpleExpression + { + private static final long serialVersionUID = 1L; + + @Override + public String evaluate(final ReportParameters reportParameters) + { + Assertions.assertEquals("fieldValue", reportParameters.getValue("field1")); + Assertions.assertEquals("fieldValue", reportParameters.getFieldValue("field1")); + Assertions.assertEquals("parameterValue", reportParameters.getParameterValue("field1")); + return ""; + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/VariableTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/VariableTest.java new file mode 100644 index 0000000..433a9f8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/VariableTest.java @@ -0,0 +1,58 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.VariableBuilder; +import software.xdev.dynamicreports.report.constant.Calculation; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; + +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.exp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.variable; + +/** + * @author Ricardo Mariaca + */ +public class VariableTest extends AbstractJasperValueTest implements Serializable { + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(JasperReportBuilder rb) { + VariableBuilder variable1 = variable("field1", Integer.class, Calculation.SUM); + VariableBuilder variable2 = variable(exp.number(5), Calculation.SUM); + variable2.setInitialValueExpression(exp.jasperSyntax("new Integer(10)")); + + rb.summary(cmp.text(variable1), cmp.text(variable2)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // summary + elementCountTest("summary.textField1", 1); + elementValueTest("summary.textField1", ""); + elementCountTest("summary.textField2", 1); + elementValueTest("summary.textField2", "10"); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/VirtualizerTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/VirtualizerTest.java new file mode 100644 index 0000000..0b972c1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/report/VirtualizerTest.java @@ -0,0 +1,56 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.report; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperValueTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JREmptyDataSource; +import net.sf.jasperreports.engine.fill.JRFileVirtualizer; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; + +/** + * @author Ricardo Mariaca + */ +public class VirtualizerTest extends AbstractJasperValueTest { + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.title(cmp.text("title")).setVirtualizer(new JRFileVirtualizer(2)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + elementCountTest("title.textField1", 1); + elementValueTest("title.textField1", "title"); + } + + @Override + protected boolean serializableTest() { + return false; + } + + @Override + protected JRDataSource createDataSource() { + return new JREmptyDataSource(10); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/BandStyle1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/BandStyle1Test.java new file mode 100644 index 0000000..ce1f032 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/BandStyle1Test.java @@ -0,0 +1,152 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.awt.Color; +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class BandStyle1Test extends AbstractJasperStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + Color color1 = new Color(240, 240, 240); + Color color2 = new Color(230, 230, 230); + Color color3 = new Color(220, 220, 220); + Color color4 = new Color(210, 210, 210); + Color color5 = new Color(190, 190, 190); + Color color6 = new Color(180, 180, 180); + Color color7 = new Color(170, 170, 170); + Color color8 = new Color(160, 160, 160); + Color color9 = new Color(150, 150, 150); + Color color10 = new Color(140, 140, 140); + Color color11 = new Color(130, 130, 130); + Color color12 = new Color(120, 120, 120); + Color color13 = new Color(110, 110, 110); + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1; + TextColumnBuilder column2; + ColumnGroupBuilder group1; + + rb.setPageColumnsPerPage(2) + .columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class)) + .groupBy(group1 = grp.group(column1).setHeaderLayout(GroupHeaderLayout.TITLE_AND_VALUE)) + + .subtotalsAtTitle(sbt.sum(column2)) + .subtotalsAtPageHeader(sbt.sum(column2)) + .subtotalsAtPageFooter(sbt.sum(column2)) + .subtotalsAtColumnHeader(sbt.sum(column2)) + .subtotalsAtColumnFooter(sbt.sum(column2)) + .subtotalsAtGroupHeader(group1, sbt.sum(column2)) + .subtotalsAtGroupFooter(group1, sbt.sum(column2)) + .subtotalsAtLastPageFooter(sbt.sum(column2)) + .subtotalsAtSummary(sbt.sum(column2)) + + .title(cmp.text("title")) + .setTitleStyle(stl.style().setBackgroundColor(color1)) + + .pageHeader(cmp.text("pageHeader")) + .setPageHeaderStyle(stl.style().setBackgroundColor(color2)) + + .pageFooter(cmp.text("pageFooter")) + .setPageFooterStyle(stl.style().setBackgroundColor(color3)) + + .columnHeader(cmp.text("columnHeader")) + .setColumnHeaderStyle(stl.style().setBackgroundColor(color4)) + + .columnFooter(cmp.text("columnFooter")) + .setColumnFooterStyle(stl.style().setBackgroundColor(color5)) + + .groupHeader(group1, cmp.text("groupHeader")) + .setGroupHeaderStyle(group1, stl.style().setBackgroundColor(color6)) + + .groupFooter(group1, cmp.text("groupFooter")) + .setGroupFooterStyle(group1, stl.style().setBackgroundColor(color7)) + + .detailHeader(cmp.text("detailHeader")) + .setDetailHeaderStyle(stl.style().setBackgroundColor(color8)) + + .detail(cmp.text("detail")) + .setDetailStyle(stl.style().setBackgroundColor(color9)) + + .detailFooter(cmp.text("detailFooter")) + .setDetailFooterStyle(stl.style().setBackgroundColor(color10)) + + .lastPageFooter(cmp.text("lastPageFooter")) + .setLastPageFooterStyle(stl.style().setBackgroundColor(color11)) + + .summary(cmp.text("summary")) + .setSummaryStyle(stl.style().setBackgroundColor(color12)) + + .background(cmp.text("background")) + .setBackgroundStyle(stl.style().setBackgroundColor(color13)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(2); + + styleTest("title.list1", 0, null, color1, "SansSerif", null, null, null); + styleTest("pageHeader.list1", 0, null, color2, "SansSerif", null, null, null); + styleTest("pageFooter.list1", 0, null, color3, "SansSerif", null, null, null); + styleTest("columnHeader.list1", 0, null, color4, "SansSerif", null, null, null); + styleTest("columnFooter.list1", 0, null, color5, "SansSerif", null, null, null); + styleTest("groupHeaderTitleAndValue.list1", 0, null, color6, "SansSerif", null, null, null); + styleTest("groupHeader.list1", 0, null, color6, "SansSerif", null, null, null); + styleTest("subtotalGroupHeader.list1", 0, null, color6, "SansSerif", null, null, null); + styleTest("groupFooter.list1", 0, null, color7, "SansSerif", null, null, null); + styleTest("subtotalGroupFooter.list1", 0, null, color7, "SansSerif", null, null, null); + styleTest("detailHeader.list1", 0, null, color8, "SansSerif", null, null, null); + styleTest("detail.list1", 0, null, color9, "SansSerif", null, null, null); + styleTest("detailFooter.list1", 0, null, color10, "SansSerif", null, null, null); + styleTest("lastPageFooter.list1", 0, null, color11, "SansSerif", null, null, null); + styleTest("summary.list1", 0, null, color12, "SansSerif", null, null, null); + styleTest("background.list1", 0, null, color13, "SansSerif", null, null, null); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 0; i < 10; i++) { + dataSource.add("group1", i); + } + for (int i = 0; i < 10; i++) { + dataSource.add("group2", i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/BandStyle2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/BandStyle2Test.java new file mode 100644 index 0000000..4896390 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/BandStyle2Test.java @@ -0,0 +1,143 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.ReportTemplateBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.awt.Color; +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; +import static software.xdev.dynamicreports.report.builder.DynamicReports.template; + +/** + * @author Ricardo Mariaca + */ +public class BandStyle2Test extends AbstractJasperStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + Color color1 = new Color(240, 240, 240); + Color color2 = new Color(230, 230, 230); + Color color3 = new Color(220, 220, 220); + Color color4 = new Color(210, 210, 210); + Color color5 = new Color(190, 190, 190); + Color color6 = new Color(180, 180, 180); + Color color7 = new Color(170, 170, 170); + Color color8 = new Color(160, 160, 160); + Color color9 = new Color(150, 150, 150); + Color color10 = new Color(140, 140, 140); + Color color11 = new Color(130, 130, 130); + Color color12 = new Color(120, 120, 120); + Color color13 = new Color(110, 110, 110); + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1; + TextColumnBuilder column2; + ColumnGroupBuilder group1; + + ReportTemplateBuilder template = template().setTitleStyle(stl.style().setBackgroundColor(color1)) + .setPageHeaderStyle(stl.style().setBackgroundColor(color2)) + .setPageFooterStyle(stl.style().setBackgroundColor(color3)) + .setColumnHeaderStyle(stl.style().setBackgroundColor(color4)) + .setColumnFooterStyle(stl.style().setBackgroundColor(color5)) + .setGroupHeaderStyle(stl.style().setBackgroundColor(color6)) + .setGroupFooterStyle(stl.style().setBackgroundColor(color7)) + .setDetailHeaderStyle(stl.style().setBackgroundColor(color8)) + .setDetailStyle(stl.style().setBackgroundColor(color9)) + .setDetailFooterStyle(stl.style().setBackgroundColor(color10)) + .setLastPageFooterStyle(stl.style().setBackgroundColor(color11)) + .setSummaryStyle(stl.style().setBackgroundColor(color12)) + .setBackgroundStyle(stl.style().setBackgroundColor(color13)); + + rb.setPageColumnsPerPage(2) + .setTemplate(template) + .columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class)) + .groupBy(group1 = grp.group(column1).setHeaderLayout(GroupHeaderLayout.TITLE_AND_VALUE)) + + .subtotalsAtTitle(sbt.sum(column2)) + .subtotalsAtPageHeader(sbt.sum(column2)) + .subtotalsAtPageFooter(sbt.sum(column2)) + .subtotalsAtColumnHeader(sbt.sum(column2)) + .subtotalsAtColumnFooter(sbt.sum(column2)) + .subtotalsAtGroupHeader(group1, sbt.sum(column2)) + .subtotalsAtGroupFooter(group1, sbt.sum(column2)) + .subtotalsAtLastPageFooter(sbt.sum(column2)) + .subtotalsAtSummary(sbt.sum(column2)) + .title(cmp.text("title")) + .pageHeader(cmp.text("pageHeader")) + .pageFooter(cmp.text("pageFooter")) + .columnHeader(cmp.text("columnHeader")) + .columnFooter(cmp.text("columnFooter")) + .groupHeader(group1, cmp.text("groupHeader")) + .groupFooter(group1, cmp.text("groupFooter")) + .detailHeader(cmp.text("detailHeader")) + .detail(cmp.text("detail")) + .detailFooter(cmp.text("detailFooter")) + .lastPageFooter(cmp.text("lastPageFooter")) + .summary(cmp.text("summary")) + .background(cmp.text("background")); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(2); + + styleTest("title.list1", 0, null, color1, "SansSerif", null, null, null); + styleTest("pageHeader.list1", 0, null, color2, "SansSerif", null, null, null); + styleTest("pageFooter.list1", 0, null, color3, "SansSerif", null, null, null); + styleTest("columnHeader.list1", 0, null, color4, "SansSerif", null, null, null); + styleTest("columnFooter.list1", 0, null, color5, "SansSerif", null, null, null); + styleTest("groupHeaderTitleAndValue.list1", 0, null, color6, "SansSerif", null, null, null); + styleTest("groupHeader.list1", 0, null, color6, "SansSerif", null, null, null); + styleTest("subtotalGroupHeader.list1", 0, null, color6, "SansSerif", null, null, null); + styleTest("groupFooter.list1", 0, null, color7, "SansSerif", null, null, null); + styleTest("subtotalGroupFooter.list1", 0, null, color7, "SansSerif", null, null, null); + styleTest("detailHeader.list1", 0, null, color8, "SansSerif", null, null, null); + styleTest("detail.list1", 0, null, color9, "SansSerif", null, null, null); + styleTest("detailFooter.list1", 0, null, color10, "SansSerif", null, null, null); + styleTest("lastPageFooter.list1", 0, null, color11, "SansSerif", null, null, null); + styleTest("summary.list1", 0, null, color12, "SansSerif", null, null, null); + styleTest("background.list1", 0, null, color13, "SansSerif", null, null, null); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 0; i < 10; i++) { + dataSource.add("group1", i); + } + for (int i = 0; i < 10; i++) { + dataSource.add("group2", i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/BandStyle3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/BandStyle3Test.java new file mode 100644 index 0000000..f3a6c32 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/BandStyle3Test.java @@ -0,0 +1,131 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +import java.awt.Color; +import java.io.Serializable; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +/** + * @author Ricardo Mariaca + */ +public class BandStyle3Test extends AbstractJasperStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + Color color1 = new Color(240, 240, 240); + Color color2 = new Color(230, 230, 230); + Color color3 = new Color(220, 220, 220); + Color color4 = new Color(210, 210, 210); + Color color5 = new Color(190, 190, 190); + Color color6 = new Color(180, 180, 180); + Color color7 = new Color(170, 170, 170); + Color color8 = new Color(160, 160, 160); + Color color9 = new Color(150, 150, 150); + Color color10 = new Color(140, 140, 140); + Color color11 = new Color(130, 130, 130); + Color color12 = new Color(120, 120, 120); + Color color13 = new Color(110, 110, 110); + + @Override + protected void configureReport(JasperReportBuilder rb) { + TextColumnBuilder column1; + TextColumnBuilder column2; + ColumnGroupBuilder group1; + + rb.setPageColumnsPerPage(2) + .columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class)) + .groupBy(group1 = grp.group(column1).setHeaderLayout(GroupHeaderLayout.TITLE_AND_VALUE)) + .setTitleStyle(stl.style().setBackgroundColor(color1)) + .setPageHeaderStyle(stl.style().setBackgroundColor(color2)) + .setPageFooterStyle(stl.style().setBackgroundColor(color3)) + .setColumnHeaderStyle(stl.style().setBackgroundColor(color4)) + .setColumnFooterStyle(stl.style().setBackgroundColor(color5)) + .setGroupHeaderStyle(group1, stl.style().setBackgroundColor(color6)) + .setGroupFooterStyle(group1, stl.style().setBackgroundColor(color7)) + .setDetailHeaderStyle(stl.style().setBackgroundColor(color8)) + .setDetailStyle(stl.style().setBackgroundColor(color9)) + .setDetailFooterStyle(stl.style().setBackgroundColor(color10)) + .setLastPageFooterStyle(stl.style().setBackgroundColor(color11)) + .setSummaryStyle(stl.style().setBackgroundColor(color12)) + .setBackgroundStyle(stl.style().setBackgroundColor(color13)) + .subtotalsAtGroupHeader(group1, sbt.sum(column2)) + .subtotalsAtGroupFooter(group1, sbt.sum(column2)) + .title(cmp.verticalGap(10), cmp.verticalGap(10)) + .pageHeader(cmp.verticalGap(10)) + .pageFooter(cmp.verticalGap(10)) + .columnHeader(cmp.verticalGap(10)) + .columnFooter(cmp.verticalGap(10)) + .groupHeader(group1, cmp.verticalGap(10)) + .groupFooter(group1, cmp.verticalGap(10)) + .detailHeader(cmp.verticalGap(10)) + .detail(cmp.verticalGap(10)) + .detailFooter(cmp.verticalGap(10)) + .lastPageFooter(cmp.verticalGap(10)) + .summary(cmp.verticalGap(10)) + .background(cmp.verticalGap(10)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(2); + + styleTest("title.list1", 0, null, color1, "SansSerif", null, null, null); + styleTest("pageHeader.list1", 0, null, color2, "SansSerif", null, null, null); + styleTest("pageFooter.list1", 0, null, color3, "SansSerif", null, null, null); + styleTest("columnHeader.list1", 0, null, color4, "SansSerif", null, null, null); + styleTest("columnFooter.list1", 0, null, color5, "SansSerif", null, null, null); + styleTest("groupHeaderTitleAndValue.list1", 0, null, color6, "SansSerif", null, null, null); + styleTest("groupHeader.list1", 0, null, color6, "SansSerif", null, null, null); + styleTest("subtotalGroupHeader.list1", 0, null, color6, "SansSerif", null, null, null); + styleTest("groupFooter.list1", 0, null, color7, "SansSerif", null, null, null); + styleTest("subtotalGroupFooter.list1", 0, null, color7, "SansSerif", null, null, null); + styleTest("detailHeader.list1", 0, null, color8, "SansSerif", null, null, null); + styleTest("detail.list1", 0, null, color9, "SansSerif", null, null, null); + styleTest("detailFooter.list1", 0, null, color10, "SansSerif", null, null, null); + styleTest("lastPageFooter.list1", 0, null, color11, "SansSerif", null, null, null); + styleTest("summary.list1", 0, null, color12, "SansSerif", null, null, null); + styleTest("background.list1", 0, null, color13, "SansSerif", null, null, null); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + for (int i = 0; i < 10; i++) { + dataSource.add("group1", i); + } + for (int i = 0; i < 10; i++) { + dataSource.add("group2", i); + } + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/DefaultFontTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/DefaultFontTest.java new file mode 100644 index 0000000..7933d34 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/DefaultFontTest.java @@ -0,0 +1,79 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import java.awt.Color; +import java.io.Serializable; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.style.FontBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * Default font tests. + * + * @author Ricardo Mariaca + */ +public class DefaultFontTest extends AbstractJasperStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + + @Override + protected void configureReport(JasperReportBuilder rb) { + FontBuilder defaultFont = stl.font().setFontSize(12); + + rb.setDefaultFont(defaultFont).columns( + column1 = col.column("Column1", "field1", type.stringType()).setStyle(stl.style().bold()), + column2 = col.column("Column2", "field2", type.stringType())); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnDetailStyleTest(column1, 0, null, null, TEST_FONT_NAME, 12f, true, null); + columnDetailStyleTest(column1, 1, null, null, TEST_FONT_NAME, 12f, true, null); + columnDetailStyleTest(column1, 2, null, null, TEST_FONT_NAME, 12f, true, null); + + // column2 + columnDetailStyleTest(column2, 0, Color.BLACK, null, TEST_FONT_NAME, 12f, null, null); + columnDetailStyleTest(column2, 1, Color.BLACK, null, TEST_FONT_NAME, 12f, null, null); + columnDetailStyleTest(column2, 2, Color.BLACK, null, TEST_FONT_NAME, 12f, null, null); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("1", "1", "1"); + dataSource.add("1", "1", "1"); + dataSource.add("1", "1", "1"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style1Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style1Test.java new file mode 100644 index 0000000..393a298 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style1Test.java @@ -0,0 +1,180 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.awt.Color; +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.base.expression.AbstractSimpleExpression; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.report.definition.ReportParameters; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.type.LineStyleEnum; + +/** + * Style tests. + * + * @author Ricardo Mariaca + */ +public class Style1Test extends AbstractJasperStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + StyleBuilder textStyle = stl.style().setForegroundColor(Color.BLACK).setPadding(2); + StyleBuilder columnStyle = stl.style(textStyle).italic(); + + StyleBuilder columnStyle1 = stl.style(columnStyle).conditionalStyles( + stl.conditionalStyle(new ConditionExpression(2, 5, 6, 7)).bold(), + stl.conditionalStyle(new ConditionExpression(16)).setBackgroundColor(Color.ORANGE)); + + StyleBuilder columnStyle2 = stl.style(columnStyle).bold(); + StyleBuilder titleStyle0 = stl.style(textStyle).bold(); + StyleBuilder titleStyle = stl.style(titleStyle0).setBottomBorder(stl.pen2Point()); + StyleBuilder columnTitleStyle3 = stl.style(titleStyle).setBorder(stl.pen2Point()); + StyleBuilder subtotalStyle = + stl.style(textStyle).bold().setTopBorder(stl.pen1Point()).setBackgroundColor(Color.YELLOW); + + rb.columns(column1 = col.column("Column1", "field1", Integer.class).setStyle(columnStyle1), + column2 = col.column("Column2", "field2", Integer.class).setStyle(columnStyle2), + column3 = col.column("Column3", "field3", Integer.class).setTitleStyle(columnTitleStyle3)) + .setTextStyle(textStyle).setColumnTitleStyle(titleStyle).setColumnStyle(columnStyle) + .setSubtotalStyle(subtotalStyle).setHighlightDetailOddRows(true) + .setHighlightDetailEvenRows(true).subtotalsAtSummary(subtotal1 = sbt.sum(column1)) + .detailRowHighlighters( + stl.conditionalStyle(new ConditionExpression(5, 16)).setBackgroundColor(Color.RED), + stl.conditionalStyle(new ConditionExpression(2, 9)).setForegroundColor(Color.RED)) + .title(cmp.horizontalList().setStyle(stl.style(stl.pen1Point())) + .add(cmp.text("text").setStyle(stl.style(textStyle).setBold(true).setFontSize(15))) + .add(cmp.text("text"))); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + final Color color1 = new Color(240, 240, 240); + final Color color2 = new Color(200, 200, 200); + + // column1 + columnTitleStyleTest(column1, 0, Color.BLACK, null, TEST_FONT_NAME, 10f, true, null); + columnTitleBorderTest(column1, 0, Color.BLACK, LineStyleEnum.SOLID, 0, Color.BLACK, + LineStyleEnum.SOLID, 2, Color.BLACK, LineStyleEnum.SOLID, 0, Color.BLACK, + LineStyleEnum.SOLID, 0); + columnTitlePaddingTest(column1, 0, 2, 2, 2, 2); + + columnDetailPaddingTest(column1, 0, 2, 2, 2, 2); + columnDetailStyleTest(column1, 0, Color.BLACK, color1, TEST_FONT_NAME, 10f, null, true); + columnDetailStyleTest(column1, 1, Color.BLACK, color2, TEST_FONT_NAME, 10f, null, true); + columnDetailStyleTest(column1, 2, Color.RED, color1, TEST_FONT_NAME, 10f, true, true); + columnDetailStyleTest(column1, 5, Color.BLACK, Color.RED, TEST_FONT_NAME, 10f, true, true); + columnDetailStyleTest(column1, 6, Color.BLACK, color1, TEST_FONT_NAME, 10f, true, true); + columnDetailStyleTest(column1, 9, Color.RED, color2, TEST_FONT_NAME, 10f, null, true); + columnDetailStyleTest(column1, 16, Color.BLACK, Color.ORANGE, TEST_FONT_NAME, 10f, null, true); + + // column2 + columnTitleStyleTest(column2, 0, Color.BLACK, null, TEST_FONT_NAME, 10f, true, null); + columnTitleBorderTest(column2, 0, Color.BLACK, LineStyleEnum.SOLID, 0, Color.BLACK, + LineStyleEnum.SOLID, 2, Color.BLACK, LineStyleEnum.SOLID, 0, Color.BLACK, + LineStyleEnum.SOLID, 0); + columnTitlePaddingTest(column2, 0, 2, 2, 2, 2); + + columnDetailPaddingTest(column2, 0, 2, 2, 2, 2); + columnDetailStyleTest(column2, 0, Color.BLACK, color1, TEST_FONT_NAME, 10f, true, true); + columnDetailStyleTest(column2, 1, Color.BLACK, color2, TEST_FONT_NAME, 10f, true, true); + columnDetailStyleTest(column2, 2, Color.RED, color1, TEST_FONT_NAME, 10f, true, true); + columnDetailStyleTest(column2, 5, Color.BLACK, Color.RED, TEST_FONT_NAME, 10f, true, true); + columnDetailStyleTest(column2, 6, Color.BLACK, color1, TEST_FONT_NAME, 10f, true, true); + columnDetailStyleTest(column2, 9, Color.RED, color2, TEST_FONT_NAME, 10f, true, true); + columnDetailStyleTest(column2, 16, Color.BLACK, Color.RED, TEST_FONT_NAME, 10f, true, true); + + // column3 + columnTitleStyleTest(column3, 0, Color.BLACK, null, TEST_FONT_NAME, 10f, true, null); + columnTitleBorderTest(column3, 0, Color.BLACK, LineStyleEnum.SOLID, 2, Color.BLACK, + LineStyleEnum.SOLID, 2, Color.BLACK, LineStyleEnum.SOLID, 2, Color.BLACK, + LineStyleEnum.SOLID, 2); + columnTitlePaddingTest(column3, 0, 2, 2, 2, 2); + + columnDetailPaddingTest(column3, 0, 2, 2, 2, 2); + columnDetailStyleTest(column3, 0, Color.BLACK, color1, TEST_FONT_NAME, 10f, null, true); + columnDetailStyleTest(column3, 1, Color.BLACK, color2, TEST_FONT_NAME, 10f, null, true); + columnDetailStyleTest(column3, 2, Color.RED, color1, TEST_FONT_NAME, 10f, null, true); + columnDetailStyleTest(column3, 5, Color.BLACK, Color.RED, TEST_FONT_NAME, 10f, null, true); + columnDetailStyleTest(column3, 6, Color.BLACK, color1, TEST_FONT_NAME, 10f, null, true); + columnDetailStyleTest(column3, 9, Color.RED, color2, TEST_FONT_NAME, 10f, null, true); + columnDetailStyleTest(column3, 16, Color.BLACK, Color.RED, TEST_FONT_NAME, 10f, null, true); + + // subtotal1 + subtotalStyleTest(subtotal1, 0, Color.BLACK, Color.YELLOW, TEST_FONT_NAME, 10f, true, null); + subtotalBorderTest(subtotal1, 0, Color.BLACK, LineStyleEnum.SOLID, 1, Color.BLACK, + LineStyleEnum.SOLID, 0, Color.BLACK, LineStyleEnum.SOLID, 0, Color.BLACK, + LineStyleEnum.SOLID, 0); + subtotalPaddingTest(subtotal1, 0, 2, 2, 2, 2); + + // title + styleTest("title.list1", 0, null, null, "SansSerif", null, null, null); + borderTest("title.list1", 0, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, null, + LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1); + paddingTest("title.list1", 0, 0, 0, 0, 0); + styleTest("title.textField1", 0, Color.BLACK, null, TEST_FONT_NAME, 15f, true, null); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + for (int i = 0; i < 20; i++) { + dataSource.add(i, i + 1, i + 2); + } + return dataSource; + } + + private class ConditionExpression extends AbstractSimpleExpression { + private static final long serialVersionUID = 1L; + + private List values; + + private ConditionExpression(Integer... values) { + this.values = Arrays.asList(values); + } + + @Override + public Boolean evaluate(ReportParameters reportParameters) { + Integer value = (Integer) reportParameters.getValue("field1"); + return values.contains(value); + } + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style2Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style2Test.java new file mode 100644 index 0000000..5418e60 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style2Test.java @@ -0,0 +1,93 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.sbt; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import java.io.Serializable; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.builder.subtotal.AggregationSubtotalBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.type.LineStyleEnum; + +/** + * Style tests. + * + * @author Ricardo Mariaca + */ +public class Style2Test extends AbstractJasperStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private ColumnGroupBuilder group1; + private AggregationSubtotalBuilder subtotal1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + StyleBuilder textStyle = stl.style().setPadding(2); + StyleBuilder titleStyle = stl.style(textStyle).bold(); + StyleBuilder subtotalStyle = stl.style(2).setTopBorder(stl.pen1Point()).bold(); + + rb.setTextStyle(textStyle).setColumnTitleStyle(titleStyle).setSubtotalStyle(subtotalStyle) + .columns(column1 = col.column("Column1", "field1", type.integerType()), + column2 = + col.column("Column2", "field2", type.stringType()).setStyle(stl.style().bold())) + .groupBy(group1 = grp.group(column2)).subtotalsAtSummary( + subtotal1 = sbt.sum(column1).setLabel("total").setLabelStyle(stl.style().bold())); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnTitleStyleTest(column1, 0, null, null, TEST_FONT_NAME, 10f, true, null); + columnTitlePaddingTest(column1, 0, 2, 2, 2, 2); + + columnDetailStyleTest(column1, 0, null, null, TEST_FONT_NAME, 10f, null, null); + columnDetailPaddingTest(column1, 0, 2, 2, 2, 2); + + // column2 + groupHeaderStyleTest(group1, 0, null, null, TEST_FONT_NAME, 10f, true, null); + + // subtotal + subtotalLabelStyleTest(subtotal1, 0, null, null, TEST_FONT_NAME, 10f, true, null); + subtotalLabelBorderTest(subtotal1, 0, null, LineStyleEnum.SOLID, 0, null, LineStyleEnum.SOLID, + 0, null, LineStyleEnum.SOLID, 0, null, LineStyleEnum.SOLID, 0); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2"); + dataSource.add(1, "1"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style3Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style3Test.java new file mode 100644 index 0000000..52e07b8 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style3Test.java @@ -0,0 +1,95 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import java.awt.Color; +import java.io.Serializable; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.constant.GroupHeaderLayout; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * Style tests. + * + * @author Ricardo Mariaca + */ +public class Style3Test extends AbstractJasperStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + private TextColumnBuilder column4; + private ColumnGroupBuilder group1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + StyleBuilder titleStyle = stl.style().setForegroundColor(Color.RED); + StyleBuilder columnStyle = stl.style().setForegroundColor(Color.BLUE); + + rb.setColumnTitleStyle(titleStyle).setColumnStyle(columnStyle).columns( + column1 = col.column("Column1", "field1", type.stringType()).setStyle(stl.style().italic()) + .setTitleStyle(stl.style().bold()), + column2 = col.column("Column2", "field2", type.stringType()), + column3 = col.column("Column3", "field3", type.stringType()).setStyle(stl.style().bold()), + column4 = col.column("Column4", "field4", type.stringType()) + .setStyle(stl.style(columnStyle).bold()).setTitleStyle(stl.style().italic())) + .groupBy(group1 = grp.group(column1).setHeaderLayout(GroupHeaderLayout.TITLE_AND_VALUE)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column2 + columnTitleStyleTest(column2, 0, Color.RED, null, TEST_FONT_NAME, 10f, null, null); + columnDetailStyleTest(column2, 0, Color.BLUE, null, TEST_FONT_NAME, 10f, null, null); + + // column3 + columnTitleStyleTest(column3, 0, Color.RED, null, TEST_FONT_NAME, 10f, null, null); + columnDetailStyleTest(column3, 0, null, null, TEST_FONT_NAME, 10f, true, null); + + // column4 + columnTitleStyleTest(column4, 0, null, null, TEST_FONT_NAME, 10f, null, true); + columnDetailStyleTest(column4, 0, Color.BLUE, null, TEST_FONT_NAME, 10f, true, null); + + // group1 + groupHeaderTitleStyleTest(group1, 0, null, null, TEST_FONT_NAME, 10f, true, null); + groupHeaderStyleTest(group1, 0, null, null, TEST_FONT_NAME, 10f, null, true); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("1", "1", "1"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style4Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style4Test.java new file mode 100644 index 0000000..a05758e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style4Test.java @@ -0,0 +1,83 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.grp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import java.awt.Color; +import java.io.Serializable; +import java.util.Date; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.group.ColumnGroupBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.constant.HorizontalTextAlignment; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.type.HorizontalTextAlignEnum; + +/** + * Style tests. + * + * @author Ricardo Mariaca + */ +public class Style4Test extends AbstractJasperStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private ColumnGroupBuilder group1; + + @Override + protected void configureReport(JasperReportBuilder rb) { + StyleBuilder groupStyle = + stl.style().bold().setHorizontalTextAlignment(HorizontalTextAlignment.LEFT); + + column1 = col.column("field1", type.dateYearType()); + + group1 = grp.group(column1).setHideColumn(false).groupByDataType().setStyle(groupStyle); + + rb.columns(column1).groupBy(group1); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + columnDetailStyleTest(column1, 0, Color.BLACK, null, TEST_FONT_NAME, 10f, null, null); + columnDetailAlignmentTest(column1, 0, HorizontalTextAlignEnum.RIGHT); + + // group1 + groupHeaderStyleTest(group1, 0, null, null, TEST_FONT_NAME, 10f, true, null); + groupHeaderAlignmentTest(group1, 0, HorizontalTextAlignEnum.LEFT); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1"); + dataSource.add(new Date()); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style5Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style5Test.java new file mode 100644 index 0000000..2b6f06e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style5Test.java @@ -0,0 +1,64 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.io.Serializable; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.constant.WhenNoDataType; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.type.HorizontalTextAlignEnum; +import net.sf.jasperreports.engine.type.LineStyleEnum; + +/** + * Style tests. + * + * @author Ricardo Mariaca + */ +public class Style5Test extends AbstractJasperStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(JasperReportBuilder rb) { + rb.setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL) + .setTextStyle(stl.style(stl.pen1Point()).setPadding(2)).pageFooter(cmp.pageXofY()); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + // column1 + styleTest("pageFooter.textField1", 0, null, null, TEST_FONT_NAME, 10f, null, null); + horizontalAlignmentTest("pageFooter.textField1", 0, HorizontalTextAlignEnum.RIGHT); + paddingTest("pageFooter.textField1", 0, 2, 2, 2, 0); + borderTest("pageFooter.textField1", 0, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, + 1, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 0); + + styleTest("pageFooter.textField2", 0, null, null, TEST_FONT_NAME, 10f, null, null); + horizontalAlignmentTest("pageFooter.textField2", 0, HorizontalTextAlignEnum.LEFT); + paddingTest("pageFooter.textField2", 0, 2, 2, 0, 2); + borderTest("pageFooter.textField2", 0, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, + 1, null, LineStyleEnum.SOLID, 0, null, LineStyleEnum.SOLID, 1); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style6Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style6Test.java new file mode 100644 index 0000000..c11b658 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style6Test.java @@ -0,0 +1,99 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cnd; +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.field; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import java.awt.Color; +import java.io.Serializable; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.builder.style.ConditionalStyleBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRDataSource; + +/** + * Style tests. + * + * @author Ricardo Mariaca + */ +public class Style6Test extends AbstractJasperStyleTest implements Serializable { + private static final long serialVersionUID = 1L; + + private TextColumnBuilder column1; + private TextColumnBuilder column2; + private TextColumnBuilder column3; + + @Override + protected void configureReport(JasperReportBuilder rb) { + StyleBuilder style = stl.style(); + style.setBackgroundColor(Color.WHITE); + ConditionalStyleBuilder conditionalStyle = + stl.conditionalStyle(cnd.equal(field("field3", type.stringType()), "2")); + conditionalStyle.setForegroundColor(Color.BLUE); + style.conditionalStyles(conditionalStyle); + + rb.highlightDetailEvenRows().columns( + column1 = col.column("Column1", "field1", type.stringType()) + .setStyle(stl.style().setBackgroundColor(Color.BLUE)), + column2 = col.column("Column2", "field2", type.stringType()), + column3 = col.column("Column3", "field3", type.stringType()).setStyle(style)); + } + + @Override + public void test() { + super.test(); + + numberOfPagesTest(1); + + final Color color1 = new Color(60, 60, 251); + final Color color2 = new Color(240, 240, 240); + final Color color3 = new Color(251, 251, 251); + + // column1 + columnDetailStyleTest(column1, 0, null, color1, TEST_FONT_NAME, 10f, null, null); + columnDetailStyleTest(column1, 1, null, Color.BLUE, TEST_FONT_NAME, 10f, null, null); + columnDetailStyleTest(column1, 2, null, color1, TEST_FONT_NAME, 10f, null, null); + + // column2 + columnDetailStyleTest(column2, 0, Color.BLACK, color2, TEST_FONT_NAME, 10f, null, null); + columnDetailStyleTest(column2, 1, Color.BLACK, null, TEST_FONT_NAME, 10f, null, null); + columnDetailStyleTest(column2, 2, Color.BLACK, color2, TEST_FONT_NAME, 10f, null, null); + + // column3 + columnDetailStyleTest(column3, 0, null, color3, TEST_FONT_NAME, 10f, null, null); + columnDetailStyleTest(column3, 1, Color.BLUE, Color.WHITE, TEST_FONT_NAME, 10f, null, null); + columnDetailStyleTest(column3, 2, null, color3, TEST_FONT_NAME, 10f, null, null); + } + + @Override + protected JRDataSource createDataSource() { + DRDataSource dataSource = new DRDataSource("field1", "field2", "field3"); + dataSource.add("1", "1", "1"); + dataSource.add("1", "1", "2"); + dataSource.add("1", "1", "1"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style7Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style7Test.java new file mode 100644 index 0000000..397fb68 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style7Test.java @@ -0,0 +1,83 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.io.Serializable; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.constant.LineSpacing; +import software.xdev.dynamicreports.report.constant.TabStopAlignment; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRStyle; +import net.sf.jasperreports.engine.TabStop; +import net.sf.jasperreports.engine.type.LineSpacingEnum; +import net.sf.jasperreports.engine.type.TabStopAlignEnum; + + +/** + * @author Ricardo Mariaca + */ +class Style7Test extends AbstractJasperStyleTest implements Serializable +{ + private static final long serialVersionUID = 1L; + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + final StyleBuilder style = stl.style() + .setLineSpacing(LineSpacing.DOUBLE) + .setLineSpacingSize(2f) + .setFirstLineIndent(10) + .setLeftIndent(15) + .setRightIndent(20) + .setSpacingBefore(5) + .setSpacingAfter(6) + .setTabStopWidth(9) + .addTabStop(12, TabStopAlignment.CENTER); + + rb.setTextStyle(style).title(cmp.text("")); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + final JRStyle style = this.getElementAt("title.textField1", 0).getStyle(); + Assertions.assertEquals(LineSpacingEnum.DOUBLE, style.getParagraph().getLineSpacing()); + Assertions.assertEquals(Float.valueOf(2), style.getParagraph().getLineSpacingSize()); + Assertions.assertEquals(Integer.valueOf(10), style.getParagraph().getFirstLineIndent()); + Assertions.assertEquals(Integer.valueOf(15), style.getParagraph().getLeftIndent()); + Assertions.assertEquals(Integer.valueOf(20), style.getParagraph().getRightIndent()); + Assertions.assertEquals(Integer.valueOf(5), style.getParagraph().getSpacingBefore()); + Assertions.assertEquals(Integer.valueOf(6), style.getParagraph().getSpacingAfter()); + Assertions.assertEquals(Integer.valueOf(9), style.getParagraph().getTabStopWidth()); + final TabStop[] tabStops = style.getParagraph().getTabStops(); + Assertions.assertNotNull(tabStops); + Assertions.assertEquals(12, tabStops[0].getPosition()); + Assertions.assertEquals(TabStopAlignEnum.CENTER, tabStops[0].getAlignment()); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style8Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style8Test.java new file mode 100644 index 0000000..9ae09a3 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style8Test.java @@ -0,0 +1,103 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.col; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; +import static software.xdev.dynamicreports.report.builder.DynamicReports.type; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.column.BooleanColumnBuilder; +import software.xdev.dynamicreports.report.builder.column.TextColumnBuilder; +import software.xdev.dynamicreports.report.constant.HorizontalImageAlignment; +import software.xdev.dynamicreports.report.constant.VerticalImageAlignment; +import software.xdev.dynamicreports.report.datasource.DRDataSource; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.type.HorizontalImageAlignEnum; +import net.sf.jasperreports.engine.type.HorizontalTextAlignEnum; +import net.sf.jasperreports.engine.type.LineStyleEnum; +import net.sf.jasperreports.engine.type.VerticalImageAlignEnum; +import net.sf.jasperreports.engine.type.VerticalTextAlignEnum; + + +/** + * Style tests. + * + * @author Ricardo Mariaca + */ +public class Style8Test extends AbstractJasperStyleTest +{ + private BooleanColumnBuilder column1; + private BooleanColumnBuilder column2; + private BooleanColumnBuilder column3; + private TextColumnBuilder column4; + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + rb.setColumnStyle(stl.style(stl.pen1Point()).bold()).columns( + this.column1 = col.booleanColumn("field1"), + this.column2 = col.booleanColumn("field2") + .setHorizontalImageAlignment(HorizontalImageAlignment.RIGHT), + this.column3 = col.booleanColumn("field3") + .setStyle(stl.style(stl.pen2Point()) + .setHorizontalImageAlignment(HorizontalImageAlignment.CENTER) + .setVerticalImageAlignment(VerticalImageAlignment.MIDDLE)), + this.column4 = col.column("field4", type.stringType())); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + this.columnDetailStyleTest(this.column1, 0, null, null, TEST_FONT_NAME, 10f, true, null); + this.columnDetailBorderTest( + this.column1, 0, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, + null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1); + this.columnDetailBorderTest( + this.column2, 0, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, + null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1); + this.columnDetailBorderTest( + this.column3, 0, null, LineStyleEnum.SOLID, 2, null, LineStyleEnum.SOLID, 2, + null, LineStyleEnum.SOLID, 2, null, LineStyleEnum.SOLID, 2); + this.columnDetailStyleTest(this.column4, 0, null, null, TEST_FONT_NAME, 10f, true, null); + this.columnDetailBorderTest( + this.column4, 0, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, + null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1); + + this.columnDetailAlignmentTest(this.column1, 0, HorizontalTextAlignEnum.CENTER); + this.columnDetailAlignmentTest(this.column2, 0, HorizontalImageAlignEnum.RIGHT); + this.columnDetailAlignmentTest(this.column3, 0, HorizontalImageAlignEnum.CENTER); + + this.columnDetailAlignmentTest(this.column1, 0, VerticalTextAlignEnum.TOP); + this.columnDetailAlignmentTest(this.column2, 0, VerticalImageAlignEnum.TOP); + this.columnDetailAlignmentTest(this.column3, 0, VerticalImageAlignEnum.MIDDLE); + } + + @Override + protected JRDataSource createDataSource() + { + final DRDataSource dataSource = new DRDataSource("field1", "field2", "field3", "field4"); + dataSource.add(true, true, true, "text"); + return dataSource; + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style9Test.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style9Test.java new file mode 100644 index 0000000..a32f99c --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/Style9Test.java @@ -0,0 +1,60 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.awt.Color; + +import org.junit.jupiter.api.Assertions; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.test.jasper.AbstractJasperStyleTest; +import net.sf.jasperreports.engine.JRStyle; + + +/** + * Style tests. + * + * @author Ricardo Mariaca + */ +public class Style9Test extends AbstractJasperStyleTest +{ + + @Override + protected void configureReport(final JasperReportBuilder rb) + { + final StyleBuilder style = stl.style().bold().setForegroundColor(Color.BLUE); + + rb.title(cmp.rectangle().setStyle(style), cmp.text("text").setStyle(style)); + } + + @Override + public void test() + { + super.test(); + + this.numberOfPagesTest(1); + + final JRStyle style = this.getElementAt("title.rectangle1", 0).getStyle(); + Assertions.assertEquals(Color.BLUE, style.getForecolor()); + this.styleTest("title.textField1", 0, Color.BLUE, null, TEST_FONT_NAME, 10f, true, null); + } +} diff --git a/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/StyleNamesTest.java b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/StyleNamesTest.java new file mode 100644 index 0000000..0dbd524 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/java/software/xdev/dynamicreports/test/jasper/style/StyleNamesTest.java @@ -0,0 +1,89 @@ +/* + * dynamicreports-core-for-grid-exporter - dynamicreports-core-for-grid-exporter + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package software.xdev.dynamicreports.test.jasper.style; + +import static software.xdev.dynamicreports.report.builder.DynamicReports.cmp; +import static software.xdev.dynamicreports.report.builder.DynamicReports.report; +import static software.xdev.dynamicreports.report.builder.DynamicReports.stl; + +import java.io.ByteArrayInputStream; +import java.nio.charset.Charset; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import software.xdev.dynamicreports.jasper.builder.JasperReportBuilder; +import software.xdev.dynamicreports.report.builder.style.StyleBuilder; +import software.xdev.dynamicreports.report.builder.style.TemplateStyleBuilder; +import software.xdev.dynamicreports.report.exception.DRException; +import net.sf.jasperreports.engine.JRStyle; +import net.sf.jasperreports.engine.design.JasperDesign; + + +/** + * @author Ramunas Belkauskas + */ +class StyleNamesTest +{ + + private static final String jrtxStr = + "\n" + + "\n" + + + "\n" + " + + + + + + + + + <band height="16"> + <textField isStretchWithOverflow="true" isBlankWhenNull="true"> + <reportElement key="title.textField1" style="style_2_" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="575" height="16"/> + <textElement/> + <textFieldExpression class="java.lang.String"><![CDATA["Subreport" + $P{MASTER_REPORT_PARAMETERS}.getReportRowNumber()]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport1.jrxml b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport1.jrxml new file mode 100644 index 0000000..0ebe330 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport1.jrxml @@ -0,0 +1,37 @@ + + + + + + + <band height="16"> + <textField isStretchWithOverflow="true" isBlankWhenNull="true"> + <reportElement key="title.textField1" style="style_22_" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="575" height="16"/> + <textElement/> + <textFieldExpression class="java.lang.String"><![CDATA["Subreport" + $P{MASTER_REPORT_PARAMETERS}.getReportRowNumber()]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport2.jrxml b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport2.jrxml new file mode 100644 index 0000000..47b2acc --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport2.jrxml @@ -0,0 +1,54 @@ + + + + + + + + <band height="16"> + <textField isStretchWithOverflow="true" isBlankWhenNull="true"> + <reportElement key="title.textField1" style="style_27_" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="575" height="16"/> + <textElement/> + <textFieldExpression class="java.lang.String"><![CDATA["Subreport" + $P{MASTER_REPORT_PARAMETERS}.getReportRowNumber()]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport3.jrxml b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport3.jrxml new file mode 100644 index 0000000..36a9300 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport3.jrxml @@ -0,0 +1,65 @@ + + + + + + + + + <band height="16"> + <textField isStretchWithOverflow="true" isBlankWhenNull="true"> + <reportElement key="title.textField1" style="style_33_" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="575" height="16"/> + <textElement/> + <textFieldExpression class="java.lang.String"><![CDATA["Subreport" + $P{MASTER_REPORT_PARAMETERS}.getReportRowNumber()]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport4.jrxml b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport4.jrxml new file mode 100644 index 0000000..2a2cd4e --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/subreport4.jrxml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/titlesubreport.jrxml b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/titlesubreport.jrxml new file mode 100644 index 0000000..03385c4 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/subreport/titlesubreport.jrxml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign1.jrxml b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign1.jrxml new file mode 100644 index 0000000..e7c0461 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign1.jrxml @@ -0,0 +1,63 @@ + + + + + + + + + + + + <band height="79" splitType="Stretch"> + <staticText> + <reportElement key="templateDesign.title1" x="126" y="28" width="100" height="20"/> + <textElement/> + <text><![CDATA[title]]></text> + </staticText> + <textField> + <reportElement key="templateDesign.title2" x="336" y="27" width="100" height="20"/> + <textElement/> + <textFieldExpression class="java.lang.String"><![CDATA[$P{parameter}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign2.jrxml b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign2.jrxml new file mode 100644 index 0000000..eb9e3d1 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign2.jrxml @@ -0,0 +1,30 @@ + + + + + + + <band height="79" splitType="Stretch"> + </band> + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign3.jrxml b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign3.jrxml new file mode 100644 index 0000000..de505ac --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign3.jrxml @@ -0,0 +1,30 @@ + + + + + + + <band height="10" splitType="Stretch"> + </band> + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign4.jrxml b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign4.jrxml new file mode 100644 index 0000000..a85be06 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign4.jrxml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign5.jrxml b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign5.jrxml new file mode 100644 index 0000000..b6ec40d --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign5.jrxml @@ -0,0 +1,63 @@ + + + + + + + + + + + + <band height="79" splitType="Stretch"> + <staticText> + <reportElement key="templateDesign.title1" x="126" y="28" width="100" height="20"/> + <textElement/> + <text><![CDATA[title]]></text> + </staticText> + <textField> + <reportElement key="templateDesign.title2" x="336" y="27" width="100" height="20"/> + <textElement/> + <textFieldExpression class="java.lang.String"><![CDATA[$P{parameter}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign6.jrxml b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign6.jrxml new file mode 100644 index 0000000..30cbd15 --- /dev/null +++ b/dynamicreports-core-for-grid-exporter/src/test/resources/software/xdev/dynamicreports/test/jasper/templatedesign/templatedesign6.jrxml @@ -0,0 +1,25 @@ + + + + + + + + + + <band height="79" splitType="Stretch"> + <staticText> + <reportElement key="templateDesign.title1" style="columnTitleStyle3" x="126" y="28" width="100" height="20"/> + <textElement/> + <text><![CDATA[title1]]></text> + </staticText> + <staticText> + <reportElement key="templateDesign.title2" style="style1" x="336" y="27" width="100" height="20"/> + <textElement/> + <text><![CDATA[title2]]></text> + </staticText> + </band> + + diff --git a/pom.xml b/pom.xml index ada9282..bfd3cc9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.xdev-software - standard-maven-template-root + dynamicreports-core-for-grid-exporter-root 1.0.0-SNAPSHOT pom @@ -15,14 +15,14 @@ - standard-maven-template - standard-maven-template-demo + dynamicreports-core-for-grid-exporter + dynamicreports-core-for-grid-exporter-demo - Apache License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt + GNU Lesser General Public License version 3 + https://www.gnu.org/licenses/lgpl-3.0.en.html repo