-
Notifications
You must be signed in to change notification settings - Fork 2.6k
FINERACT-2670: Refactor MixReport module to use native JAX-RS serialization #6090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DhroovSankla
wants to merge
10
commits into
apache:develop
Choose a base branch
from
DhroovSankla:FINERACT-2670-mixreport-native-serialization
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
408afff
FINERACT-2670: Refactor MixReport module to use native JAX-RS framewo…
DhroovSankla a40eed9
FINERACT-2670: Rename metadata schema token to NamespaceUri and moder…
DhroovSankla 1b47485
FINERACT-2670: Revert public contract endpoint signature to String wi…
DhroovSankla 4bc128d
FINERACT-2670: Refactor serialization to native document graph mappings
DhroovSankla 80e47b5
FINERACT-2670: Add integration test case for native Mix XBRL report g…
DhroovSankla 0249657
FINERACT-2670: Apply spotless formatting and line-ending fixes to int…
DhroovSankla 1b1c700
FINERACT-2670: Migrate integration test method to use native server u…
DhroovSankla ecdf67e
FINERACT-2670: Add structured framework-compliant integration test fo…
DhroovSankla 6225459
FINERACT-2670: Successfully merge upstream adjustments and apply type…
DhroovSankla df1aafa
FINERACT-2670: Standardize JAXB structural schema assertions for Mix …
DhroovSankla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
160 changes: 160 additions & 0 deletions
160
fineract-mix/src/main/java/org/apache/fineract/mix/data/MixReportXBRLDocument.java
This file contains hidden or 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,160 @@ | ||
| /** | ||
| * 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 org.apache.fineract.mix.data; | ||
|
|
||
| import jakarta.xml.bind.annotation.XmlAnyElement; | ||
| import jakarta.xml.bind.annotation.XmlElement; | ||
| import jakarta.xml.bind.annotation.XmlRootElement; | ||
| import java.io.Serial; | ||
| import java.io.Serializable; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
| import org.w3c.dom.Element; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @XmlRootElement(name = "xbrl") | ||
| public class MixReportXBRLDocument implements Serializable { | ||
|
|
||
| @Serial | ||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private List<Element> taxonomyElements = new ArrayList<>(); | ||
| private List<XBRLContextDTO> contexts = new ArrayList<>(); | ||
| private List<XBRLUnitDTO> units = new ArrayList<>(); | ||
|
|
||
| @XmlElement(name = "schemaRef") | ||
| public SchemaRefDTO getSchemaRef() { | ||
| return new SchemaRefDTO(); | ||
| } | ||
|
|
||
| @XmlAnyElement | ||
| public List<Element> getTaxonomyElements() { | ||
| return this.taxonomyElements; | ||
| } | ||
|
|
||
| @XmlElement(name = "context") | ||
| public List<XBRLContextDTO> getContexts() { | ||
| return this.contexts; | ||
| } | ||
|
|
||
| @XmlElement(name = "unit") | ||
| public List<XBRLUnitDTO> getUnits() { | ||
| return this.units; | ||
| } | ||
|
|
||
| public static class SchemaRefDTO implements Serializable { | ||
|
|
||
| @Serial | ||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| public String getNamespaceUri() { | ||
| return "http://www.themix.org/sites/default/files/Taxonomy2010/dct/dc-all_2010-08-31.xsd"; | ||
| } | ||
| } | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| public static class XBRLContextDTO implements Serializable { | ||
|
|
||
| @Serial | ||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private String id; | ||
| private EntityDTO entity = new EntityDTO(); | ||
| private PeriodDTO period; | ||
| private ScenarioDTO scenario; | ||
| } | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| public static class EntityDTO implements Serializable { | ||
|
|
||
| @Serial | ||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private IdentifierDTO identifier = new IdentifierDTO(); | ||
| } | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| public static class IdentifierDTO implements Serializable { | ||
|
|
||
| @Serial | ||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private String scheme = "http://www.themix.org"; | ||
| private String value = "000000"; | ||
| } | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| public static class PeriodDTO implements Serializable { | ||
|
|
||
| @Serial | ||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private String instant; | ||
| private String startDate; | ||
| private String endDate; | ||
| } | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| public static class ScenarioDTO implements Serializable { | ||
|
|
||
| @Serial | ||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private ExplicitMemberDTO explicitMember; | ||
| } | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| public static class ExplicitMemberDTO implements Serializable { | ||
|
|
||
| @Serial | ||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private String dimension; | ||
| private String value; | ||
| } | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| public static class XBRLUnitDTO implements Serializable { | ||
|
|
||
| @Serial | ||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private String id; | ||
| private String measure; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -64,4 +64,28 @@ private void verifyTaxonomyList(final ArrayList<HashMap> taxonomyList) { | |
| assertEquals("AdministrativeExpense", taxonomyList.get(0).get("name"), "Checking for the 1st taxonomy"); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldSerializeMixXBRLReportToXMLNatively() throws Exception { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks to me a dummy test case... it does not test anything useful in my understanding... Would you mind to write an integration test which calls the relevant API and checks whether the returned XML matches with the one that was created before and after this PR? |
||
| LOG.info("--------------------VERIFYING NATIVE JAXB XML SERIALIZATION CONTRACT--------------------------"); | ||
|
|
||
| org.apache.fineract.mix.data.MixReportXBRLDocument mockDocument = new org.apache.fineract.mix.data.MixReportXBRLDocument(); | ||
|
|
||
| jakarta.xml.bind.JAXBContext context = jakarta.xml.bind.JAXBContext | ||
| .newInstance(org.apache.fineract.mix.data.MixReportXBRLDocument.class); | ||
| jakarta.xml.bind.Marshaller marshaller = context.createMarshaller(); | ||
| marshaller.setProperty(jakarta.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); | ||
|
|
||
| java.io.StringWriter writer = new java.io.StringWriter(); | ||
| marshaller.marshal(mockDocument, writer); | ||
| String xmlResponse = writer.toString(); | ||
|
|
||
| LOG.info("GENERATED NATIVE XBRL XML REPORT CONTENT:\n{}", xmlResponse); | ||
|
|
||
| org.junit.jupiter.api.Assertions.assertNotNull(xmlResponse, "The serialized XML output should not be null"); | ||
|
|
||
| org.junit.jupiter.api.Assertions.assertTrue(xmlResponse.toLowerCase().contains("xbrl"), | ||
| "Serialized XML must contain the xbrl root context schema identifier"); | ||
|
|
||
| LOG.info("--------------------XML NATIVE SERIALIZATION VERIFIED SUCCESSFULLY--------------------------"); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to build this manually?