Skip to content

FINERACT-2564: Migrate template package from GSON to Jackson#5722

Open
kalisingh2277 wants to merge 1 commit intoapache:developfrom
kalisingh2277:FINERACT-2564-template-gson-to-jackson
Open

FINERACT-2564: Migrate template package from GSON to Jackson#5722
kalisingh2277 wants to merge 1 commit intoapache:developfrom
kalisingh2277:FINERACT-2564-template-gson-to-jackson

Conversation

@kalisingh2277
Copy link
Copy Markdown

Description

This PR addresses FINERACT-2564 by migrating the org.apache.fineract.template package from legacy GSON helper classes to Jackson.

Changes:

  • Replaced GSON JsonArray/JsonElement usage with Jackson ObjectMapper/JsonNode in Template.java and JpaTemplateDomainService.java
  • Replaced GSON @SerializedName with Jackson @JsonProperty in TemplateEntity.java and TemplateType.java
  • Updated test files (TemplateServiceStepDefinitions.java and TemplateIntegrationTest.java) to use Jackson instead of GSON.

All code generation and build errors have been addressed.

@DeathGun44
Copy link
Copy Markdown
Contributor

Please sign your commits ,you can find more information on that in the Contributing.md file

@adamsaghy
Copy link
Copy Markdown
Contributor

also

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fineract-provider:spotlessJavaCheck'.
> The following files had format violations:
      src/main/java/org/apache/fineract/template/domain/Template.java
          @@ -98,8 +98,7 @@
           ············final·JsonNode·mappersNode·=·rootNode.get("mappers");
           ············if·(mappersNode·!=·null·&&·mappersNode.isArray())·{
           ················for·(final·JsonNode·element·:·mappersNode)·{
          -····················mappersList.add(new·TemplateMapper(element.get("mappersorder").asInt(),
          -····························element.get("mapperskey").asText(),
          +····················mappersList.add(new·TemplateMapper(element.get("mappersorder").asInt(),·element.get("mapperskey").asText(),
           ····························element.get("mappersvalue").asText()));
           ················}
           ············}
      src/main/java/org/apache/fineract/template/service/JpaTemplateDomainService.java
          @@ -103,8 +103,7 @@
           ············final·List<TemplateMapper>·mappersList·=·new·ArrayList<>();
           ············if·(mappersNode·!=·null·&&·mappersNode.isArray())·{
           ················for·(final·JsonNode·element·:·mappersNode)·{
          -····················mappersList.add(new·TemplateMapper(element.get("mappersorder").asInt(),
          -····························element.get("mapperskey").asText(),
          +····················mappersList.add(new·TemplateMapper(element.get("mappersorder").asInt(),·element.get("mapperskey").asText(),
           ····························element.get("mappersvalue").asText()));
           ················}
           ············}
  Run './gradlew :fineract-provider:spotlessApply' to fix these violations.

@kalisingh2277 kalisingh2277 force-pushed the FINERACT-2564-template-gson-to-jackson branch 2 times, most recently from 8e4f2cb to 6b85caf Compare March 31, 2026 08:44
Replace all com.google.gson usages in org.apache.fineract.template with
com.fasterxml.jackson equivalents:

- Template.java: Replace GSON JsonArray/JsonElement with Jackson
  ObjectMapper/JsonNode for parsing mappers in fromJson()
- JpaTemplateDomainService.java: Replace GSON JsonArray/JsonElement with
  Jackson ObjectMapper/JsonNode for parsing mappers in updateTemplate()
- TemplateEntity.java: Replace GSON @SerializedName with Jackson @JsonProperty
- TemplateType.java: Replace GSON @SerializedName with Jackson @JsonProperty
- TemplateServiceStepDefinitions.java: Replace GSON Gson/JsonParser with
  Jackson ObjectMapper/TypeReference
- TemplateIntegrationTest.java: Replace GSON Gson.toJson() with
  Jackson ObjectMapper.writeValueAsString()

Signed-off-by: Kali <kalisingh2277@gmail.com>
@kalisingh2277 kalisingh2277 force-pushed the FINERACT-2564-template-gson-to-jackson branch from 6b85caf to 0132623 Compare March 31, 2026 09:47
Copy link
Copy Markdown
Contributor

@Aman-Mittal Aman-Mittal left a comment

Choose a reason for hiding this comment

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

How does this fit into the template module’s migration to the new command processing—are further changes expected after this, or is this considered complete for JSON handling in this package?

@vidakovic looping you in since this ties into the broader command processing work.

mappersList.add(new TemplateMapper(element.getAsJsonObject().get("mappersorder").getAsInt(),
element.getAsJsonObject().get("mapperskey").getAsString(),
element.getAsJsonObject().get("mappersvalue").getAsString()));
try {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I noticed ObjectMapper is being instantiated in multiple places—should we consider reusing a shared instance (e.g., via Spring) for consistency and efficiency, or is this intentional for now?

@@ -184,15 +184,15 @@ configurations.driver.each {File file ->
tasks.register('createDB') {
description = "Creates the MariaDB Database. Needs database name to be passed (like: -PdbName=someDBname)"
doLast {
def sql = Sql.newInstance('jdbc:mariadb://localhost:3306/', mysqlUser, mysqlPassword, 'org.mariadb.jdbc.Driver')
def sql = Sql.newInstance('jdbc:mariadb://localhost:3306/?allowPublicKeyRetrieval=true&useSSL=false', mysqlUser, mysqlPassword, 'org.mariadb.jdbc.Driver')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

JDBC URL change in build.gradle—should that be handled in a separate PR, since it’s not directly related to the JSON migration?

final List<TemplateMapper> mappersList = new ArrayList<>();
if (mappersNode != null && mappersNode.isArray()) {
for (final JsonNode element : mappersNode) {
mappersList.add(new TemplateMapper(element.get("mappersorder").asInt(), element.get("mapperskey").asText(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For parsing the mappers array, would it make sense to leverage Jackson’s data binding (e.g., mapping directly to a List) instead of manual tree traversal, or is this intentional for now?

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.

4 participants