Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

FINERACT-3283: [SQL 091] Migrate SMS campaign template query to QueryDSL - #7180

Open
jefische wants to merge 3 commits into
apache:developfrom
jefische:fineract-3283
Open

jefische wants to merge 3 commits into
apache:developfrom
jefische:fineract-3283

Conversation

@jefische

@jefische jefische commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Jira: Fineract-3283

Migrates the business-rule lookup in SmsCampaignReadPlatformServiceImpl.retrieveTemplate from native SQL through JdbcTemplate and BusinessRuleMapper to QueryDSL.

  • The new query joins stretchy_report, stretchy_report_parameter and stretchy_parameter. It filters on report_type only when a report type is given; otherwise it returns every report, as before.
  • The joined rows (one per report and parameter) are grouped by report id into one SmsBusinessRulesData per report. Each report's parameters are collected into a parameterLabel -> parameterName map, which keeps the
    behaviour of BusinessRuleMapper. A LinkedHashMap keeps the reports in query order.

The response shape of GET /smscampaigns/template does not change.

Tests

New unit tests in SmsCampaignReadPlatformServiceImplTest:

  • retrieveTemplateMapsAllRules: rows for the same report are merged into one rule with all of its parameters.
  • retrieveTemplateReturnsAllReportsForNullReportType: a null report type adds no where clause and binds no parameter.

To run them:
./gradlew :fineract-provider:test --tests "org.apache.fineract.infrastructure.campaigns.sms.service.SmsCampaignReadPlatformServiceImplTest"

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow our coding conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
  • This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.
  • If merging this PR resolves a JIRA issue, I will mark that issue as resolved and set "Fix Version/s" appropriately.
  • I followed the AI Policy.

Your assigned reviewer(s) will follow our guidelines for code reviews.

  Replace the native SQL query that loads business-rule options in SmsCampaignReadPlatformServiceImpl retrieveTemplate with a QueryDSL query over stretchy_report, stretchy_report_parameter and
  stretchy_parameter.

  - Group the joined rows by report id into one SmsBusinessRulesData per report, with its parameters collected into a label -> name
    map. This keeps the behaviour of BusinessRuleMapper, and the reports stay in query order.
  - Filter on report_type only when a report type is given; otherwise return every report.
  - Add unit tests for the grouping of rules and parameters and for the report-type filter with and without a value.

# Conflicts:
#	fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/sms/service/SmsCampaignReadPlatformServiceImpl.java
#	fineract-provider/src/test/java/org/apache/fineract/infrastructure/campaigns/sms/service/SmsCampaignReadPlatformServiceImplTest.java
  Extend retrieveTemplateMapsAllRules so it covers all of the business-rule grouping, and assert the exact SQL that is generated:

  - Add a report with no parameters. The left joins return one row with null parameter columns, which must map to a {null=null}
    entry, as BusinessRuleMapper produced.
  - Assert every returned rule, including a report with a null subtype and a single parameter, and check the order the rules
    come back in.
  - Compare the full generated SQL with EXPECTED_TEMPLATE_SQL and check that the report type is bound to the first parameter.
  - Remove retrieveTemplateFiltersByReportType. The test above now covers everything it checked.
@jefische
jefische marked this pull request as ready for review December 6, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant