-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
14,097 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
integration-tests/src/main/jasperreports/JsonCustomersReport.jrxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<jasperReport name="JsonCustomersReport" language="java" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50" uuid="bbe115b5-a5a0-4b39-9b73-7092dc59ab6d"> | ||
<property name="net.sf.jasperreports.json.source" value="data/northwind.json"/> | ||
<style name="Sans_Normal" default="true" fontName="DejaVu Sans" fontSize="12.0" bold="false" italic="false" underline="false" strikeThrough="false"/> | ||
<style name="Sans_Bold" fontName="DejaVu Sans" fontSize="12.0" bold="true" italic="false" underline="false" strikeThrough="false"/> | ||
<style name="Sans_Italic" fontName="DejaVu Sans" fontSize="12.0" bold="false" italic="true" underline="false" strikeThrough="false"/> | ||
<query language="json"><![CDATA[Northwind.Customers]]></query> | ||
<field name="CustomerID" class="java.lang.String"> | ||
<property name="net.sf.jasperreports.json.field.expression" value="CustomerID"/> | ||
</field> | ||
<field name="CompanyName" class="java.lang.String"> | ||
<property name="net.sf.jasperreports.json.field.expression" value="CompanyName"/> | ||
</field> | ||
<title height="50"> | ||
<element kind="line" uuid="fc148b4e-50df-4a12-aa14-8505a4cfa6e1" x="0" y="0" width="515" height="1"/> | ||
<element kind="staticText" uuid="5bf7651c-cd6b-4eaf-b65a-1413d60faab0" x="0" y="10" width="515" height="30" fontSize="22.0" hTextAlign="Center" style="Sans_Normal"> | ||
<text><![CDATA[Customer Orders Report JSON]]></text> | ||
</element> | ||
</title> | ||
<pageHeader height="21"> | ||
<element kind="staticText" uuid="da0f1cad-f552-424b-bf19-b41cabbfa4ac" mode="Opaque" x="0" y="5" width="515" height="15" forecolor="#FFFFFF" backcolor="#333333" style="Sans_Bold"> | ||
<text><![CDATA[Customer Order List]]></text> | ||
</element> | ||
</pageHeader> | ||
<detail> | ||
<band height="50"> | ||
<element kind="textField" uuid="0aaeed6e-7ba1-4ab9-be59-d6ca702995fc" x="5" y="5" width="100" height="15" printWhenDetailOverflows="true" style="Sans_Bold"> | ||
<expression><![CDATA[$F{CustomerID}]]></expression> | ||
</element> | ||
<element kind="staticText" uuid="68e08f51-8c24-4c85-95f3-616e40c8ddab" x="404" y="5" width="100" height="15" printWhenDetailOverflows="true" printRepeatedValues="false" style="Sans_Bold"> | ||
<text><![CDATA[(continued)]]></text> | ||
</element> | ||
<element kind="line" uuid="6d76c22c-329f-4e77-a886-8580d3cb6bc1" x="0" y="20" width="515" height="1" printWhenDetailOverflows="true"/> | ||
<element kind="subreport" uuid="122eb7b3-e2bf-49eb-859d-4c29bfd6882e" x="5" y="25" width="507" height="20" backcolor="#FFCC99" printRepeatedValues="false" removeLineWhenBlank="true"> | ||
<expression><![CDATA["JsonOrdersReport.jasper"]]></expression> | ||
<parameter name="net.sf.jasperreports.json.date.pattern"> | ||
<expression><![CDATA[$P{net.sf.jasperreports.json.date.pattern}]]></expression> | ||
</parameter> | ||
<parameter name="net.sf.jasperreports.json.number.pattern"> | ||
<expression><![CDATA[$P{net.sf.jasperreports.json.number.pattern}]]></expression> | ||
</parameter> | ||
<parameter name="JSON_LOCALE"> | ||
<expression><![CDATA[$P{JSON_LOCALE}]]></expression> | ||
</parameter> | ||
<parameter name="CustomerID"> | ||
<expression><![CDATA[$F{CustomerID}]]></expression> | ||
</parameter> | ||
<parameter name="net.sf.jasperreports.json.source"> | ||
<expression><![CDATA["data/northwind.json"]]></expression> | ||
</parameter> | ||
</element> | ||
<element kind="textField" uuid="9a4a0a5d-4b75-4d2b-a647-aa495101df48" x="109" y="5" width="291" height="15" printWhenDetailOverflows="true" style="Sans_Bold"> | ||
<expression><![CDATA[$F{CompanyName}]]></expression> | ||
</element> | ||
</band> | ||
</detail> | ||
<pageFooter height="40"> | ||
<element kind="line" uuid="1371178a-a590-4616-affe-a4e1a24bcc84" x="0" y="10" width="515" height="1"/> | ||
<element kind="textField" uuid="3eb302d8-0855-4f82-a666-3c9628dce372" x="200" y="20" width="80" height="15" hTextAlign="Right"> | ||
<expression><![CDATA["Page " + String.valueOf($V{PAGE_NUMBER}) + " of"]]></expression> | ||
</element> | ||
<element kind="textField" uuid="86f46fca-dbcb-4a60-b2f7-f8da6a4224f7" x="280" y="20" width="75" height="15" evaluationTime="Report"> | ||
<expression><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></expression> | ||
</element> | ||
</pageFooter> | ||
</jasperReport> |
67 changes: 67 additions & 0 deletions
67
integration-tests/src/main/jasperreports/JsonOrdersReport.jrxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<jasperReport name="JsonOrdersReport" language="java" pageWidth="500" pageHeight="842" columnWidth="500" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="5a62986f-c97c-4e2f-b4ed-d9f38960dab4"> | ||
<style name="Sans_Normal" default="true" fontName="DejaVu Sans" fontSize="8.0" bold="false" italic="false" underline="false" strikeThrough="false"/> | ||
<style name="Sans_Bold" fontName="DejaVu Sans" fontSize="8.0" bold="true" italic="false" underline="false" strikeThrough="false"/> | ||
<style name="Sans_Italic" fontName="DejaVu Sans" fontSize="8.0" bold="false" italic="true" underline="false" strikeThrough="false"/> | ||
<parameter name="CustomerID" class="java.lang.String"/> | ||
<query language="json"><![CDATA[Northwind.Orders(CustomerID == $P{CustomerID})]]></query> | ||
<field name="Id" class="java.lang.String"> | ||
<property name="net.sf.jasperreports.json.field.expression" value="OrderID"/> | ||
</field> | ||
<field name="OrderDate" class="java.util.Date"> | ||
<property name="net.sf.jasperreports.json.field.expression" value="OrderDate"/> | ||
</field> | ||
<field name="ShipCity" class="java.lang.String"> | ||
<property name="net.sf.jasperreports.json.field.expression" value="ShipCity"/> | ||
</field> | ||
<field name="Freight" class="java.lang.Float"> | ||
<property name="net.sf.jasperreports.json.field.expression" value="Freight"/> | ||
</field> | ||
<variable name="TotalFreight" calculation="Sum" class="java.lang.Float"> | ||
<expression><![CDATA[$F{Freight}]]></expression> | ||
</variable> | ||
<pageHeader height="14"> | ||
<element kind="frame" uuid="e9af134f-31eb-48be-bd9b-292188f2554f" mode="Opaque" x="0" y="2" width="356" height="10" forecolor="#CCFFFF" backcolor="#CCFFFF"> | ||
<element kind="staticText" uuid="62e5e770-7b05-4ecd-a254-ab0c7f643a37" mode="Opaque" x="0" y="0" width="48" height="10" backcolor="#CCFFFF" hTextAlign="Right" style="Sans_Bold"> | ||
<text><![CDATA[ID]]></text> | ||
</element> | ||
<element kind="staticText" uuid="c472f825-47f4-4e16-a782-cc4b02572cb0" mode="Opaque" x="54" y="0" width="87" height="10" backcolor="#CCFFFF" hTextAlign="Center" style="Sans_Bold"> | ||
<text><![CDATA[Order Date]]></text> | ||
</element> | ||
<element kind="staticText" uuid="89b5edba-1606-4f5d-89cb-144042c1fcdd" mode="Opaque" x="146" y="0" width="108" height="10" backcolor="#CCFFFF" style="Sans_Bold"> | ||
<text><![CDATA[Ship City]]></text> | ||
</element> | ||
<element kind="staticText" uuid="e7c6fbe3-ecb2-4c65-83d6-7c813448cec6" mode="Opaque" x="259" y="0" width="92" height="10" backcolor="#CCFFFF" hTextAlign="Right" style="Sans_Bold"> | ||
<text><![CDATA[Freight]]></text> | ||
</element> | ||
</element> | ||
</pageHeader> | ||
<detail> | ||
<band height="14"> | ||
<element kind="textField" uuid="ec54687d-3c95-4647-9db5-fa71a6e81009" x="0" y="2" width="51" height="10" hTextAlign="Right"> | ||
<expression><![CDATA[$F{Id}]]></expression> | ||
</element> | ||
<element kind="textField" uuid="a112ba7b-c321-467c-91ec-ffb513c23338" positionType="Float" x="54" y="2" width="87" height="10" textAdjust="StretchHeight" pattern="yyyy, MMM dd" hTextAlign="Center"> | ||
<expression><![CDATA[$F{OrderDate}]]></expression> | ||
</element> | ||
<element kind="textField" uuid="6a61edb3-239e-4791-a046-a6459343ac07" positionType="Float" x="146" y="2" width="108" height="10" textAdjust="StretchHeight"> | ||
<expression><![CDATA[$F{ShipCity}]]></expression> | ||
</element> | ||
<element kind="textField" uuid="61a8a117-6a43-46a7-9b96-10c5beb578ab" positionType="Float" x="259" y="2" width="92" height="10" textAdjust="StretchHeight" pattern="¤ #,##0.00" hTextAlign="Right"> | ||
<expression><![CDATA[$F{Freight}]]></expression> | ||
</element> | ||
</band> | ||
</detail> | ||
<summary height="14"> | ||
<element kind="frame" uuid="084cfbb4-f390-4302-8bf5-2e65b34829b8" mode="Opaque" x="0" y="2" width="356" height="10" forecolor="#33CCCC" backcolor="#33CCCC"> | ||
<element kind="staticText" uuid="06753d49-aed5-46c8-be06-b107f81d7c2f" mode="Opaque" x="160" y="0" width="67" height="10" backcolor="#33CCCC" hTextAlign="Right" style="Sans_Bold"> | ||
<text><![CDATA[Total :]]></text> | ||
</element> | ||
<element kind="textField" uuid="a713b487-68a2-4391-a231-9bf9aa740090" mode="Opaque" x="259" y="0" width="92" height="10" backcolor="#33CCCC" hTextAlign="Right" style="Sans_Bold"> | ||
<expression><![CDATA[$V{TotalFreight}]]></expression> | ||
</element> | ||
<element kind="textField" uuid="d8edf4da-1e47-45ec-bbf3-f63b3bf0b93b" mode="Opaque" x="227" y="0" width="27" height="10" backcolor="#33CCCC" hTextAlign="Right" style="Sans_Bold"> | ||
<expression><![CDATA[$V{REPORT_COUNT}]]></expression> | ||
</element> | ||
</element> | ||
</summary> | ||
</jasperReport> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...ration-tests/src/main/java/io/quarkiverse/jasperreports/it/JasperReportsJsonResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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. | ||
*/ | ||
package io.quarkiverse.jasperreports.it; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.util.HashMap; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.ServerErrorException; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; | ||
import org.eclipse.microprofile.openapi.annotations.media.Content; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; | ||
|
||
import io.quarkus.logging.Log; | ||
import net.sf.jasperreports.engine.JRException; | ||
import net.sf.jasperreports.engine.JRParameter; | ||
import net.sf.jasperreports.engine.JasperFillManager; | ||
import net.sf.jasperreports.engine.JasperPrint; | ||
import net.sf.jasperreports.engine.util.JRLoader; | ||
import net.sf.jasperreports.json.query.JsonQueryExecuterFactory; | ||
|
||
@Path("/jasper/json/") | ||
@ApplicationScoped | ||
@Produces(MediaType.APPLICATION_OCTET_STREAM) | ||
public class JasperReportsJsonResource extends AbstractJasperResource { | ||
|
||
private static final String TEST_REPORT_NAME = "JsonCustomersReport"; | ||
|
||
@GET | ||
@Path("ds") | ||
@APIResponse(responseCode = "200", description = "Document downloaded", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM, schema = @Schema(type = SchemaType.STRING, format = "binary"))) | ||
public Response jsonDatasource() { | ||
try { | ||
long start = System.currentTimeMillis(); | ||
Map<String, Object> params = new HashMap<>(); | ||
params.put(JsonQueryExecuterFactory.JSON_DATE_PATTERN, "yyyy-MM-dd"); | ||
params.put(JsonQueryExecuterFactory.JSON_NUMBER_PATTERN, "#,##0.##"); | ||
params.put(JsonQueryExecuterFactory.JSON_LOCALE, Locale.ENGLISH); | ||
params.put(JRParameter.REPORT_LOCALE, Locale.US); | ||
|
||
JasperFillManager.fillReportToFile("target/classes/jasperreports/" + TEST_REPORT_NAME + ".jasper", params); | ||
Log.infof("Report : JsonDatasourceCustomersReport.jasper. Filling time : %d", (System.currentTimeMillis() - start)); | ||
|
||
JasperPrint jasperPrint = (JasperPrint) JRLoader | ||
.loadObject( | ||
JRLoader.getLocationInputStream("target/classes/jasperreports/" + TEST_REPORT_NAME + ".jrprint")); | ||
ByteArrayOutputStream outputStream = exportCsv(jasperPrint); | ||
|
||
Log.infof("CSV creation time : %s", (System.currentTimeMillis() - start)); | ||
final Response.ResponseBuilder response = Response.ok(outputStream.toByteArray()); | ||
response.header("Content-Disposition", "attachment;filename=jsondatasource.csv"); | ||
response.header("Content-Type", "text/csv"); | ||
return response.build(); | ||
} catch (final JRException ex) { | ||
Log.error("Unexpected DB Error", ex); | ||
throw new ServerErrorException(Response.Status.INTERNAL_SERVER_ERROR, ex); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.