Skip to content

Conversation

@igorcampos-dev
Copy link
Owner

@igorcampos-dev igorcampos-dev commented Aug 31, 2025

…sperReports and add related configurations

Summary by CodeRabbit

  • New Features

    • Added bill PDF generation, available under new bill-dev and bill-local profiles.
    • Added local and dev configurations for bill profiles, including default ports and app names.
    • Introduced client list PDF generation via dedicated services for dev and local profiles.
  • Documentation

    • Updated README: refined client-list-dev description; added bill-dev and bill-local entries; removed client-list-local entry.
  • Bug Fixes

    • Corrected client-list local application name typo in configuration.

@coderabbitai
Copy link

coderabbitai bot commented Aug 31, 2025

Walkthrough

Refactors client list reporting to use a new ClientsReportService with dev/local profile-specific implementations, replaces old ReportService classes, adds a JasperReader utility, introduces a new bill reporting feature (controller, service interfaces/implementations, DTO, templates), updates README profiles, and adds profile-specific application YAMLs.

Changes

Cohort / File(s) Summary of Changes
Documentation
spring-jasper-example/README.md
Updated profiles list: removed client-list-local; revised client-list-dev text; added bill-dev and bill-local entries.
Jasper utility
spring-jasper-example/src/main/java/com/io/example/base/JasperReader.java
New utility with static methods to export PDFs from JRXML and JASPER templates using classpath resources.
Client list controller refactor
spring-jasper-example/src/main/java/com/io/example/clientList/controller/ClientsController.java
Renamed controller and switched dependency from ReportService to ClientsReportService; updated service call.
Client list service interface and implementations (added)
.../clientList/service/ClientsReportService.java, .../clientList/service/ClientsReportDevServiceImpl.java, .../clientList/service/ClientsReportLocalServiceImpl.java
Introduced new service interface and two profile-specific implementations generating PDFs from .jasper (dev) and .jrxml (local).
Client list legacy services (removed)
.../clientList/service/ReportService.java, .../clientList/service/ReportDevService.java, .../clientList/service/ReportLocalService.java
Removed old interface and dev/local implementations that generated client reports.
Bill reporting: controller and DTO
.../dataUsageBill/controller/BillController.java, .../dataUsageBill/dto/BillDto.java
Added REST controller (profiles bill-dev/bill-local) to serve bill PDF; added DTO with fields used by bill template.
Bill reporting: services
.../dataUsageBill/service/BillReportService.java, .../dataUsageBill/service/BillReportDevServiceImpl.java, .../dataUsageBill/service/BillReportLocalServiceImpl.java
Added service interface and two implementations for dev (.jasper) and local (.jrxml) bill PDF generation.
Profiles configuration
spring-jasper-example/src/main/resources/application-bill-dev.yml, spring-jasper-example/src/main/resources/application-bill-local.yml, spring-jasper-example/src/main/resources/application-client-list-local.yml
Added bill profile YAMLs with ports and app names; corrected client-list-local application name.
Jasper template (bill)
spring-jasper-example/src/main/resources/reports/bill-template.jrxml
New JRXML template defining fields/variables and layout for bill report.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Feat/spring jasper example #54 — Touches the same module and transitions around ReportController/ReportService, related to this PR’s refactor to ClientsController/ClientsReportService and new JasperReader/bill reporting.

Suggested labels

doc: documentation

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/spring-jasper-bill-example

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@igorcampos-dev igorcampos-dev merged commit e82460b into master Aug 31, 2025
4 of 5 checks passed
@igorcampos-dev igorcampos-dev deleted the feat/spring-jasper-bill-example branch August 31, 2025 22:21
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 23

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
spring-jasper-example/src/main/java/com/io/example/clientList/controller/ClientsController.java (1)

19-25: Declare produces=application/pdf on the endpoint.
Helps content negotiation and explicitness.

Apply:

-    @GetMapping("/reports/clients")
+    @GetMapping(value = "/reports/clients", produces = MediaType.APPLICATION_PDF_VALUE)

Optional: consider StreamingResponseBody to avoid buffering large PDFs in memory.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 42e2190 and eb6c105.

📒 Files selected for processing (18)
  • spring-jasper-example/README.md (1 hunks)
  • spring-jasper-example/src/main/java/com/io/example/base/JasperReader.java (1 hunks)
  • spring-jasper-example/src/main/java/com/io/example/clientList/controller/ClientsController.java (2 hunks)
  • spring-jasper-example/src/main/java/com/io/example/clientList/service/ClientsReportDevServiceImpl.java (1 hunks)
  • spring-jasper-example/src/main/java/com/io/example/clientList/service/ClientsReportLocalServiceImpl.java (1 hunks)
  • spring-jasper-example/src/main/java/com/io/example/clientList/service/ClientsReportService.java (1 hunks)
  • spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportDevService.java (0 hunks)
  • spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportLocalService.java (0 hunks)
  • spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportService.java (0 hunks)
  • spring-jasper-example/src/main/java/com/io/example/dataUsageBill/controller/BillController.java (1 hunks)
  • spring-jasper-example/src/main/java/com/io/example/dataUsageBill/dto/BillDto.java (1 hunks)
  • spring-jasper-example/src/main/java/com/io/example/dataUsageBill/service/BillReportDevServiceImpl.java (1 hunks)
  • spring-jasper-example/src/main/java/com/io/example/dataUsageBill/service/BillReportLocalServiceImpl.java (1 hunks)
  • spring-jasper-example/src/main/java/com/io/example/dataUsageBill/service/BillReportService.java (1 hunks)
  • spring-jasper-example/src/main/resources/application-bill-dev.yml (1 hunks)
  • spring-jasper-example/src/main/resources/application-bill-local.yml (1 hunks)
  • spring-jasper-example/src/main/resources/application-client-list-local.yml (1 hunks)
  • spring-jasper-example/src/main/resources/reports/bill-template.jrxml (1 hunks)
💤 Files with no reviewable changes (3)
  • spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportService.java
  • spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportLocalService.java
  • spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportDevService.java
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: igorcampos-dev
PR: igorcampos-dev/spring-integrations-examples#21
File: spring-kafka-example/README.md:12-17
Timestamp: 2025-07-22T01:35:41.406Z
Learning: User igorcampos-dev prefers minimal, high-level documentation in README files without detailed version specifications, choosing to keep tech stack information simple rather than adding precise version numbers.
🧬 Code graph analysis (14)
spring-jasper-example/src/main/java/com/io/example/dataUsageBill/service/BillReportDevServiceImpl.java (2)
spring-jasper-example/src/main/java/com/io/example/dataUsageBill/service/BillReportLocalServiceImpl.java (1)
  • Service (11-46)
spring-jasper-example/src/main/java/com/io/example/base/JasperReader.java (1)
  • JasperReader (12-37)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ClientsReportService.java (4)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportService.java (2)
  • ReportService (3-5)
  • generateClientReport (4-4)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportLocalService.java (3)
  • Service (12-39)
  • Override (22-25)
  • exportReportToPdf (27-37)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportDevService.java (3)
  • Service (13-49)
  • Override (23-26)
  • exportReportToPdf (37-47)
spring-jasper-example/src/main/java/com/io/example/clientList/controller/ReportController.java (2)
  • RestController (12-28)
  • GetMapping (19-26)
spring-jasper-example/src/main/java/com/io/example/dataUsageBill/service/BillReportService.java (2)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportService.java (2)
  • ReportService (3-5)
  • generateClientReport (4-4)
spring-jasper-example/src/main/java/com/io/example/clientList/controller/ReportController.java (2)
  • RestController (12-28)
  • GetMapping (19-26)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ClientsReportLocalServiceImpl.java (2)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ClientsReportDevServiceImpl.java (1)
  • Service (10-26)
spring-jasper-example/src/main/java/com/io/example/base/JasperReader.java (1)
  • JasperReader (12-37)
spring-jasper-example/src/main/java/com/io/example/base/JasperReader.java (4)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportLocalService.java (3)
  • Service (12-39)
  • exportReportToPdf (27-37)
  • Override (22-25)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportDevService.java (3)
  • exportReportToPdf (37-47)
  • Service (13-49)
  • Override (23-26)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportService.java (2)
  • ReportService (3-5)
  • generateClientReport (4-4)
spring-jasper-example/src/main/java/com/io/example/clientList/controller/ReportController.java (1)
  • RestController (12-28)
spring-jasper-example/src/main/java/com/io/example/clientList/controller/ClientsController.java (3)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportLocalService.java (3)
  • Service (12-39)
  • Override (22-25)
  • exportReportToPdf (27-37)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportDevService.java (3)
  • Service (13-49)
  • Override (23-26)
  • exportReportToPdf (37-47)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportService.java (2)
  • ReportService (3-5)
  • generateClientReport (4-4)
spring-jasper-example/src/main/java/com/io/example/dataUsageBill/dto/BillDto.java (1)
spring-jasper-example/src/main/java/com/io/example/clientList/dto/ClientDto.java (1)
  • Data (7-16)
spring-jasper-example/src/main/resources/application-bill-local.yml (1)
spring-jasper-example/src/main/java/com/io/example/SpringJasperExampleApplication.java (2)
  • SpringBootApplication (6-13)
  • main (9-11)
spring-jasper-example/src/main/resources/application-bill-dev.yml (1)
spring-jasper-example/src/main/java/com/io/example/SpringJasperExampleApplication.java (2)
  • SpringBootApplication (6-13)
  • main (9-11)
spring-jasper-example/src/main/java/com/io/example/dataUsageBill/service/BillReportLocalServiceImpl.java (2)
spring-jasper-example/src/main/java/com/io/example/dataUsageBill/service/BillReportDevServiceImpl.java (1)
  • Service (11-46)
spring-jasper-example/src/main/java/com/io/example/base/JasperReader.java (1)
  • JasperReader (12-37)
spring-jasper-example/src/main/resources/reports/bill-template.jrxml (2)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportLocalService.java (1)
  • Service (12-39)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportDevService.java (2)
  • Service (13-49)
  • exportReportToPdf (37-47)
spring-jasper-example/README.md (3)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportDevService.java (3)
  • Service (13-49)
  • exportReportToPdf (37-47)
  • Override (23-26)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportLocalService.java (2)
  • Service (12-39)
  • Override (22-25)
spring-jasper-example/src/main/java/com/io/example/clientList/controller/ReportController.java (1)
  • RestController (12-28)
spring-jasper-example/src/main/java/com/io/example/dataUsageBill/controller/BillController.java (2)
spring-jasper-example/src/main/java/com/io/example/clientList/controller/ClientsController.java (1)
  • RestController (12-28)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ReportService.java (1)
  • ReportService (3-5)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ClientsReportDevServiceImpl.java (2)
spring-jasper-example/src/main/java/com/io/example/clientList/service/ClientsReportLocalServiceImpl.java (1)
  • Service (10-25)
spring-jasper-example/src/main/java/com/io/example/base/JasperReader.java (1)
  • JasperReader (12-37)
🪛 YAMLlint (1.37.1)
spring-jasper-example/src/main/resources/application-client-list-local.yml

[error] 7-7: no new line character at the end of file

(new-line-at-end-of-file)

spring-jasper-example/src/main/resources/application-bill-local.yml

[error] 7-7: no new line character at the end of file

(new-line-at-end-of-file)

spring-jasper-example/src/main/resources/application-bill-dev.yml

[error] 7-7: no new line character at the end of file

(new-line-at-end-of-file)

🪛 LanguageTool
spring-jasper-example/README.md

[grammar] ~22-~22: There might be a mistake here.
Context: ...e that generates a simple client report. - client-list-local – Used locally, acti...

(QB_NEW_EN)


[grammar] ~23-~23: Make sure you are using the right part of speech
Context: ...at generates a simple client report and use .jrxml. - bill-dev – Used in Dock...

(QB_NEW_EN_OTHER_ERROR_IDS_21)


[grammar] ~23-~23: There might be a mistake here.
Context: ...a simple client report and use .jrxml. - bill-dev – Used in Docker, Activates t...

(QB_NEW_EN)


[grammar] ~24-~24: There might be a mistake here.
Context: ...ule that generates a simple bill report. - bill-local – Used locally, activates t...

(QB_NEW_EN)


[grammar] ~25-~25: Make sure you are using the right part of speech
Context: ...that generates a simple bill report and use .jrxml.

(QB_NEW_EN_OTHER_ERROR_IDS_21)


[grammar] ~25-~25: There might be a mistake here.
Context: ...s a simple bill report and use .jrxml.

(QB_NEW_EN)

🔇 Additional comments (6)
spring-jasper-example/src/main/resources/application-client-list-local.yml (1)

7-7: App name fix looks good.

Hyphenation correction improves consistency with other profiles.

spring-jasper-example/src/main/java/com/io/example/dataUsageBill/service/BillReportService.java (1)

3-5: LGTM: simple service contract fits current use.
No changes needed.

spring-jasper-example/src/main/java/com/io/example/clientList/service/ClientsReportDevServiceImpl.java (1)

6-6: Avoid wildcard import – replace import java.util.* with explicit imports for only the types actually used (e.g. java.util.List, java.util.Arrays, java.util.Map, etc.) and rerun Checkstyle to confirm no missing imports.

spring-jasper-example/src/main/java/com/io/example/clientList/service/ClientsReportLocalServiceImpl.java (2)

20-23: LGTM for local JRXML generation path.

Implementation aligns with the dev variant and JasperReader usage.


22-22: Resource exists in classpath
reports/client-list-template.jrxml is present under src/main/resources/reports — no action required.

spring-jasper-example/src/main/java/com/io/example/dataUsageBill/service/BillReportLocalServiceImpl.java (1)

15-18: LGTM: correct use of JRXML export for bill-local.

Comment on lines +22 to +25
- **client-list-dev** – Used in Docker, Activates the internal module that generates a simple client report.
- **client-list-local** – Used locally, activates the internal module that generates a simple client report and use `.jrxml`.

- **bill-dev** – Used in Docker, Activates the internal module that generates a simple bill report.
- **bill-local** – Used locally, activates the internal module that generates a simple bill report and use `.jrxml`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Fix casing/grammar in profile descriptions.

Lowercase “activates” and use “uses” for JRXML.

-- **client-list-dev** – Used in Docker, Activates the internal module that generates a simple client report.
+- **client-list-dev** – Used in Docker, activates the internal module that generates a simple client report.
 - **client-list-local** – Used locally, activates the internal module that generates a simple client report and use `.jrxml`.
-- **bill-dev** – Used in Docker, Activates the internal module that generates a simple bill report.
-- **bill-local** – Used locally, activates the internal module that generates a simple bill report and use `.jrxml`.
+- **bill-dev** – Used in Docker, activates the internal module that generates a simple bill report.
+- **bill-local** – Used locally, activates the internal module that generates a simple bill report and uses `.jrxml`.

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 LanguageTool

[grammar] ~22-~22: There might be a mistake here.
Context: ...e that generates a simple client report. - client-list-local – Used locally, acti...

(QB_NEW_EN)


[grammar] ~23-~23: Make sure you are using the right part of speech
Context: ...at generates a simple client report and use .jrxml. - bill-dev – Used in Dock...

(QB_NEW_EN_OTHER_ERROR_IDS_21)


[grammar] ~23-~23: There might be a mistake here.
Context: ...a simple client report and use .jrxml. - bill-dev – Used in Docker, Activates t...

(QB_NEW_EN)


[grammar] ~24-~24: There might be a mistake here.
Context: ...ule that generates a simple bill report. - bill-local – Used locally, activates t...

(QB_NEW_EN)


[grammar] ~25-~25: Make sure you are using the right part of speech
Context: ...that generates a simple bill report and use .jrxml.

(QB_NEW_EN_OTHER_ERROR_IDS_21)


[grammar] ~25-~25: There might be a mistake here.
Context: ...s a simple bill report and use .jrxml.

(QB_NEW_EN)

🤖 Prompt for AI Agents
In spring-jasper-example/README.md around lines 22 to 25, fix casing and grammar
in the four profile descriptions: change "Activates" to "activates" and change
"use `.jrxml`" to "uses `.jrxml`" so each line reads e.g. "Used in Docker,
activates the internal module..." or "Used locally, activates the internal
module... and uses `.jrxml`".


- **client-list-dev** – Used in Docker, in the future, it will use pre-compiled `.jasper` files instead of `.jrxml`. Activates the internal module that generates a simple client report.
- **client-list-dev** – Used in Docker, Activates the internal module that generates a simple client report.
- **client-list-local** – Used locally, activates the internal module that generates a simple client report and use `.jrxml`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Grammar nit: “uses” (not “use”).

Keep it consistent with the bill-local entry.

-**client-list-local** – Used locally, activates the internal module that generates a simple client report and use `.jrxml`.
+**client-list-local** – Used locally, activates the internal module that generates a simple client report and uses `.jrxml`.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- **client-list-local** – Used locally, activates the internal module that generates a simple client report and use `.jrxml`.
**client-list-local** – Used locally, activates the internal module that generates a simple client report and uses `.jrxml`.
🧰 Tools
🪛 LanguageTool

[grammar] ~23-~23: Make sure you are using the right part of speech
Context: ...at generates a simple client report and use .jrxml. - bill-dev – Used in Dock...

(QB_NEW_EN_OTHER_ERROR_IDS_21)


[grammar] ~23-~23: There might be a mistake here.
Context: ...a simple client report and use .jrxml. - bill-dev – Used in Docker, Activates t...

(QB_NEW_EN)

🤖 Prompt for AI Agents
In spring-jasper-example/README.md around line 23, the description for
"client-list-local" uses incorrect verb agreement ("use"); change it to "uses"
to match grammar and keep the phrasing consistent with the "bill-local"
entry—update the sentence to read that it "activates the internal module that
generates a simple client report and uses `.jrxml`."

Comment on lines +8 to +11
import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace unused HashMap import; prefer Collections.

We’ll switch to Collections.emptyMap() below; update imports accordingly.

 import java.io.InputStream;
 import java.util.Collection;
-import java.util.HashMap;
+import java.util.Collections;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;
import java.io.InputStream;
import java.util.Collection;
import java.util.Collections;
🤖 Prompt for AI Agents
In spring-jasper-example/src/main/java/com/io/example/base/JasperReader.java
around lines 8 to 11, remove the unused import of java.util.HashMap and replace
it with java.util.Collections so you can call Collections.emptyMap() below;
update the import list by deleting HashMap and adding Collections (or import
java.util.* if project style allows) and then change any usage of new
HashMap<>() to Collections.emptyMap() where appropriate.

Comment on lines +12 to +13
public class JasperReader {

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Make utility class non-instantiable.

Mark class final and add a private constructor.

-public class JasperReader {
+public final class JasperReader {
+
+    private JasperReader() {}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public class JasperReader {
public final class JasperReader {
private JasperReader() {}
🤖 Prompt for AI Agents
In spring-jasper-example/src/main/java/com/io/example/base/JasperReader.java
around lines 12 to 13, the utility class is currently instantiable; make it
non-instantiable by marking the class as final and adding a private no-args
constructor to prevent instantiation and subclassing, keeping existing static
utility methods intact.

Comment on lines +14 to +35
public static byte[] exportReportJrxmlToPdf(Collection<?> beanCollection, String path){
try {
InputStream stream = new ClassPathResource(path).getInputStream();
JasperReport jasperReport = JasperCompileManager.compileReport(stream);
JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(beanCollection);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap<>(), dataSource);
return JasperExportManager.exportReportToPdf(jasperPrint);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public static byte[] exportReportJasperToPdf(Collection<?> beanCollection, String path){
try (InputStream stream = new ClassPathResource(path).getInputStream()) {
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(stream);
JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(beanCollection);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap<>(), dataSource);
return JasperExportManager.exportReportToPdf(jasperPrint);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Optional: de-duplicate fill/export logic.

Consider a private helper that accepts a JasperReport and collection, returning the PDF; both public methods would prepare the JasperReport and delegate.

🤖 Prompt for AI Agents
In spring-jasper-example/src/main/java/com/io/example/base/JasperReader.java
around lines 14 to 35, the fill-and-export-to-PDF logic is duplicated between
exportReportJrxmlToPdf and exportReportJasperToPdf; extract a private helper
method that accepts a JasperReport and Collection<?> (or JRDataSource) and
returns byte[] PDF, then have each public method prepare/compile/load the
JasperReport, build the JRBeanCollectionDataSource, and delegate to that helper;
ensure the helper handles JasperFillManager.fillReport and
JasperExportManager.exportReportToPdf and propagates exceptions consistently.

Comment on lines +25 to +27
<variable name="toltalAm1" resetType="Column" calculation="Sum" class="java.lang.Integer">
<expression><![CDATA[$F{toltalAm}]]></expression>
</variable>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Variable reset scope: use Report-level sum.

Prevents per-column resets and aligns with typical totals.

-    <variable name="toltalAm1" resetType="Column" calculation="Sum" class="java.lang.Integer">
+    <variable name="toltalAm1" resetType="Report" calculation="Sum" class="java.lang.Integer">
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<variable name="toltalAm1" resetType="Column" calculation="Sum" class="java.lang.Integer">
<expression><![CDATA[$F{toltalAm}]]></expression>
</variable>
<variable name="toltalAm1" resetType="Report" calculation="Sum" class="java.lang.Integer">
<expression><![CDATA[$F{toltalAm}]]></expression>
</variable>
🤖 Prompt for AI Agents
In spring-jasper-example/src/main/resources/reports/bill-template.jrxml around
lines 25 to 27, the variable currently uses resetType="Column" which causes
per-column resets; change the variable's resetType to "Report" so the Sum
aggregates across the whole report (i.e., use resetType="Report") to produce a
report-level total.

<text><![CDATA[Department Name]]></text>
</element>
<element kind="staticText" uuid="267f032d-a98a-4177-b5b9-757dba3a7a27" x="20" y="110" width="100" height="20">
<text><![CDATA[Devision Name]]></text>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix user-facing typo: “Devision” → “Division”.

-            <text><![CDATA[Devision Name]]></text>
+            <text><![CDATA[Division Name]]></text>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<text><![CDATA[Devision Name]]></text>
<text><![CDATA[Division Name]]></text>
🤖 Prompt for AI Agents
In spring-jasper-example/src/main/resources/reports/bill-template.jrxml around
line 45, fix the user-facing typo by replacing the text node content "Devision
Name" with the correct spelling "Division Name" so the rendered report shows the
proper word; update the CDATA value accordingly and save the JRXML.

Comment on lines +53 to +55
<element kind="textField" uuid="fed3f44e-c42d-4e85-8eb3-7a6d405e07ec" x="270" y="10" width="100" height="13" fontSize="10.0" pattern="MMMMM dd, yyyy">
<expression><![CDATA[new java.util.Date()]]></expression>
</element>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Correct date pattern for full month name.

Use MMMM, not MMMMM (which prints a single-letter month).

-        <element kind="textField" uuid="fed3f44e-c42d-4e85-8eb3-7a6d405e07ec" x="270" y="10" width="100" height="13" fontSize="10.0" pattern="MMMMM dd, yyyy">
+        <element kind="textField" uuid="fed3f44e-c42d-4e85-8eb3-7a6d405e07ec" x="270" y="10" width="100" height="13" fontSize="10.0" pattern="MMMM dd, yyyy">
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<element kind="textField" uuid="fed3f44e-c42d-4e85-8eb3-7a6d405e07ec" x="270" y="10" width="100" height="13" fontSize="10.0" pattern="MMMMM dd, yyyy">
<expression><![CDATA[new java.util.Date()]]></expression>
</element>
<element kind="textField" uuid="fed3f44e-c42d-4e85-8eb3-7a6d405e07ec" x="270" y="10" width="100" height="13" fontSize="10.0" pattern="MMMM dd, yyyy">
<expression><![CDATA[new java.util.Date()]]></expression>
</element>
🤖 Prompt for AI Agents
spring-jasper-example/src/main/resources/reports/bill-template.jrxml around
lines 53 to 55: the date format pattern uses "MMMMM" which outputs a
single-letter month; change the pattern to "MMMM" to render the full month name
(e.g., "January") so update the pattern attribute accordingly.

Comment on lines +62 to +67
<element kind="textField" uuid="fb083231-e511-4c79-af82-4fa2549cba04" x="170" y="130" width="180" height="20">
<expression><![CDATA[$F{devName}]]></expression>
</element>
<element kind="textField" uuid="4106684d-ae0b-4bcd-b1fd-02cd6dda7478" x="170" y="110" width="180" height="20">
<expression><![CDATA[$F{groupName}]]></expression>
</element>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Swap field bindings: labels don’t match fields (devName/groupName).

Currently “Group Name” shows devName and “Devision Name” shows groupName.

-        <element kind="textField" uuid="fb083231-e511-4c79-af82-4fa2549cba04" x="170" y="130" width="180" height="20">
-            <expression><![CDATA[$F{devName}]]></expression>
+        <element kind="textField" uuid="fb083231-e511-4c79-af82-4fa2549cba04" x="170" y="130" width="180" height="20">
+            <expression><![CDATA[$F{groupName}]]></expression>
         </element>
-        <element kind="textField" uuid="4106684d-ae0b-4bcd-b1fd-02cd6dda7478" x="170" y="110" width="180" height="20">
-            <expression><![CDATA[$F{groupName}]]></expression>
+        <element kind="textField" uuid="4106684d-ae0b-4bcd-b1fd-02cd6dda7478" x="170" y="110" width="180" height="20">
+            <expression><![CDATA[$F{devName}]]></expression>
         </element>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<element kind="textField" uuid="fb083231-e511-4c79-af82-4fa2549cba04" x="170" y="130" width="180" height="20">
<expression><![CDATA[$F{devName}]]></expression>
</element>
<element kind="textField" uuid="4106684d-ae0b-4bcd-b1fd-02cd6dda7478" x="170" y="110" width="180" height="20">
<expression><![CDATA[$F{groupName}]]></expression>
</element>
<element kind="textField" uuid="fb083231-e511-4c79-af82-4fa2549cba04" x="170" y="130" width="180" height="20">
<expression><![CDATA[$F{groupName}]]></expression>
</element>
<element kind="textField" uuid="4106684d-ae0b-4bcd-b1fd-02cd6dda7478" x="170" y="110" width="180" height="20">
<expression><![CDATA[$F{devName}]]></expression>
</element>
🤖 Prompt for AI Agents
In spring-jasper-example/src/main/resources/reports/bill-template.jrxml around
lines 62 to 67, the two textField elements have their field expressions swapped
causing “Group Name” to show devName and “Devision Name” to show groupName;
update the first element’s expression to use $F{groupName} and the second
element’s expression to use $F{devName} (i.e., swap the CDATA expressions for
those two elements), and verify the field names match the defined report fields.

Comment on lines +145 to +172
<element kind="textField" uuid="40d28c41-8840-4cdb-8776-18863a6ac025" x="440" y="80" width="101" height="25">
<expression><![CDATA[$F{dtoOMamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="3ce3e918-29da-4f85-9967-8bac7a2c56d7" x="440" y="102" width="101" height="28">
<expression><![CDATA[$F{dtoONamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="857ee5e2-b80a-4dd1-944f-cee64d011f6e" x="440" y="130" width="101" height="25">
<expression><![CDATA[$F{dtoOLamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="aaa960c4-c2f2-4759-a57d-3c03080e6b8e" x="440" y="155" width="100" height="24">
<expression><![CDATA[$F{dtoDLamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="464f3752-1f0e-4dc1-85fd-45c2dcfcdeec" x="440" y="180" width="100" height="24">
<expression><![CDATA[$F{dtoDNamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="3cc9ea12-51a7-4be0-8d06-3a2eb00f2eac" x="440" y="205" width="100" height="24">
<expression><![CDATA[$F{dtoDamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="873a89fc-e601-4ab3-8758-d2094535ea00" x="440" y="235" width="100" height="30">
<expression><![CDATA[$F{toltalAm}]]></expression>
<box leftPadding="10"/>
</element>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Add numeric/currency formatting to amount fields.

Improves readability; example shown—apply similarly to all amount fields.

-        <element kind="textField" uuid="40d28c41-8840-4cdb-8776-18863a6ac025" x="440" y="80" width="101" height="25">
-            <expression><![CDATA[$F{dtoOMamount}]]></expression>
+        <element kind="textField" uuid="40d28c41-8840-4cdb-8776-18863a6ac025" x="440" y="80" width="101" height="25" pattern="#,##0.00">
+            <expression><![CDATA[$F{dtoOMamount}]]></expression>
         </element>

If you adopt BigDecimal in DTO, update field classes and patterns accordingly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<element kind="textField" uuid="40d28c41-8840-4cdb-8776-18863a6ac025" x="440" y="80" width="101" height="25">
<expression><![CDATA[$F{dtoOMamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="3ce3e918-29da-4f85-9967-8bac7a2c56d7" x="440" y="102" width="101" height="28">
<expression><![CDATA[$F{dtoONamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="857ee5e2-b80a-4dd1-944f-cee64d011f6e" x="440" y="130" width="101" height="25">
<expression><![CDATA[$F{dtoOLamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="aaa960c4-c2f2-4759-a57d-3c03080e6b8e" x="440" y="155" width="100" height="24">
<expression><![CDATA[$F{dtoDLamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="464f3752-1f0e-4dc1-85fd-45c2dcfcdeec" x="440" y="180" width="100" height="24">
<expression><![CDATA[$F{dtoDNamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="3cc9ea12-51a7-4be0-8d06-3a2eb00f2eac" x="440" y="205" width="100" height="24">
<expression><![CDATA[$F{dtoDamount}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="873a89fc-e601-4ab3-8758-d2094535ea00" x="440" y="235" width="100" height="30">
<expression><![CDATA[$F{toltalAm}]]></expression>
<box leftPadding="10"/>
</element>
<element kind="textField" uuid="40d28c41-8840-4cdb-8776-18863a6ac025" x="440" y="80" width="101" height="25" pattern="#,##0.00">
<expression><![CDATA[$F{dtoOMamount}]]></expression>
<box leftPadding="10"/>
</element>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants