You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2023/01/14 00:18:09 UTC

[GitHub] [fineract] josehernandezfintecheandomx opened a new pull request, #2881: Fix to update datatable entry is failing after column added lately

josehernandezfintecheandomx opened a new pull request, #2881:
URL: https://github.com/apache/fineract/pull/2881

   ## Description
   
   Fix to update datatable entry is failing after column added lately
   
   [Apache Fineract JIRA ticket](https://github.com/apache/fineract/pull/1284)
   
   <img width="1584" alt="Screenshot 2023-01-13 at 18 16 12" src="https://user-images.githubusercontent.com/44206706/212440453-058d8f28-0c5e-4fab-bb14-e131630735d3.png">
   
   
   ## Checklist
   
   Please make sure these boxes are checked before submitting your pull request - thanks!
   
   - [ ] Write the commit message as per https://github.com/apache/fineract/#pull-requests
   
   - [ ] 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 coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/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
   
   - [ ] Submission is not a "code dump".  (Large changes can be made "in repository" via a branch.  Ask on the developer mailing list for guidance, if required.)
   
   FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2881: Fix to update datatable entry is failing after column added lately

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2881:
URL: https://github.com/apache/fineract/pull/2881#discussion_r1071003269


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/DatatableIntegrationTest.java:
##########
@@ -426,6 +430,92 @@ public void validateInsertNullValues() {
         assertEquals(0, updatedDatatableEntryResponse.getChanges().size());
     }
 
+    @Test
+    public void validateCreateAndEditDatatable() {
+        // Creating client
+        final Integer clientId = ClientHelper.createClientAsPerson(requestSpec, responseSpec);
+        final Integer randomNumber = Utils.randomNumberGenerator(3);
+
+        // Creating datatable for Client Person
+        final String datatableName = Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_", 5);
+        final boolean genericResultSet = true;
+
+        HashMap<String, Object> columnMap = new HashMap<>();
+        List<HashMap<String, Object>> datatableColumnsList = new ArrayList<>();
+        columnMap.put("datatableName", datatableName);
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", CLIENT_PERSON_SUBTYPE_NAME);
+        columnMap.put("multiRow", false);
+        DatatableHelper.addDatatableColumns(datatableColumnsList, "itsANumber", "Number", false, null, null);
+        DatatableHelper.addDatatableColumns(datatableColumnsList, "itsAString", "String", false, 10, null);
+        columnMap.put("columns", datatableColumnsList);
+        String datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map : {}", datatabelRequestJsonString);
+
+        PostDataTablesResponse datatableCreateResponse = this.datatableHelper.createDatatable(datatabelRequestJsonString);
+        assertEquals(datatableName, datatableCreateResponse.getResourceIdentifier());
+        DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, datatableName);
+
+        // Insert first values
+        String value = Utils.randomStringGenerator("Q", 8);
+        HashMap<String, Object> datatableEntryMap = new HashMap<>();
+        datatableEntryMap.put("itsANumber", randomNumber);
+        datatableEntryMap.put("itsAString", value);
+
+        datatableEntryMap.put("locale", "en");
+        datatableEntryMap.put("dateFormat", "yyyy-MM-dd");
+
+        String datatableEntryRequestJsonString = new GsonBuilder().serializeNulls().create().toJson(datatableEntryMap);
+        PostDataTablesAppTableIdResponse datatableEntryResponse = this.datatableHelper.addDatatableEntry(datatableName, clientId,
+                genericResultSet, datatableEntryRequestJsonString);
+        assertNotNull(datatableEntryResponse.getResourceId(), "ERROR IN CREATING THE ENTITY DATATABLE RECORD");
+
+        // Read the Datatable entry generated with genericResultSet in true (default)
+        HashMap<String, Object> items = this.datatableHelper.readDatatableEntry(datatableName, clientId, genericResultSet, null, "");
+        assertNotNull(items);
+        assertEquals(1, ((List) items.get("data")).size());
+
+        assertEquals(clientId, ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(0));
+        assertEquals(value, ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(2));
+
+        // Update DataTable
+        columnMap = new HashMap<>();
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", CLIENT_PERSON_SUBTYPE_NAME);
+        datatableColumnsList = new ArrayList<>();
+        DatatableHelper.addDatatableColumns(datatableColumnsList, "itsAText", "Text", false, null, null);
+        columnMap.put("addColumns", datatableColumnsList);
+        datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map to update : {}", datatabelRequestJsonString);
+        PutDataTablesResponse datatableUpdateResponse = this.datatableHelper.updateDatatable(datatableName, datatabelRequestJsonString);
+        assertNotNull(datatableUpdateResponse);
+        assertEquals(datatableName, datatableUpdateResponse.getResourceIdentifier());
+
+        // Update DataTable Entry after Update DataTable schema

Review Comment:
   Please modify the test accordingly:
   - Update the value of the newly added column only!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2881: Fix to update datatable entry is failing after column added lately

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2881:
URL: https://github.com/apache/fineract/pull/2881#discussion_r1070995800


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -430,7 +430,8 @@ public CommandProcessingResult updateClient(final Long clientId, final JsonComma
             }
 
             final ExternalId externalId = externalIdFactory.createFromCommand(command, ClientApiConstants.externalIdParamName);
-            if (command.isChangeInStringParameterNamed(ClientApiConstants.externalIdParamName, externalId.getValue())) {
+            if (command.isChangeInStringParameterNamed(ClientApiConstants.externalIdParamName,
+                    clientForUpdate.getExternalId().getValue())) {

Review Comment:
   Why do we need to use the `clientForUpdate` instead of the `externalId` variable?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] adamsaghy merged pull request #2881: FINERACT-1856: Fix to update datatable entry is failing after column added lately

Posted by GitBox <gi...@apache.org>.
adamsaghy merged PR #2881:
URL: https://github.com/apache/fineract/pull/2881


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] josehernandezfintecheandomx commented on a diff in pull request #2881: FINERACT-1856: Fix to update datatable entry is failing after column added lately

Posted by GitBox <gi...@apache.org>.
josehernandezfintecheandomx commented on code in PR #2881:
URL: https://github.com/apache/fineract/pull/2881#discussion_r1071246923


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -430,7 +430,8 @@ public CommandProcessingResult updateClient(final Long clientId, final JsonComma
             }
 
             final ExternalId externalId = externalIdFactory.createFromCommand(command, ClientApiConstants.externalIdParamName);
-            if (command.isChangeInStringParameterNamed(ClientApiConstants.externalIdParamName, externalId.getValue())) {
+            if (command.isChangeInStringParameterNamed(ClientApiConstants.externalIdParamName,
+                    clientForUpdate.getExternalId().getValue())) {

Review Comment:
   This is an issue in the client update, In the comparation there is not difference and then If you change the external Id value It is not updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2881: FINERACT-1856: Fix to update datatable entry is failing after column added lately

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2881:
URL: https://github.com/apache/fineract/pull/2881#discussion_r1071289781


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -430,7 +430,8 @@ public CommandProcessingResult updateClient(final Long clientId, final JsonComma
             }
 
             final ExternalId externalId = externalIdFactory.createFromCommand(command, ClientApiConstants.externalIdParamName);
-            if (command.isChangeInStringParameterNamed(ClientApiConstants.externalIdParamName, externalId.getValue())) {
+            if (command.isChangeInStringParameterNamed(ClientApiConstants.externalIdParamName,
+                    clientForUpdate.getExternalId().getValue())) {

Review Comment:
   Would you please raise a separate PR for this? In my understanding it has not much to do with the fix for updating datatable entry properly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2881: FINERACT-1856: Fix to update datatable entry is failing after column added lately

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2881:
URL: https://github.com/apache/fineract/pull/2881#discussion_r1071389564


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/DatatableIntegrationTest.java:
##########
@@ -426,6 +430,89 @@ public void validateInsertNullValues() {
         assertEquals(0, updatedDatatableEntryResponse.getChanges().size());
     }
 
+    @Test
+    public void validateCreateAndEditDatatable() {
+        // Creating client
+        final Integer clientId = ClientHelper.createClientAsPerson(requestSpec, responseSpec);
+        final Integer randomNumber = Utils.randomNumberGenerator(3);
+
+        // Creating datatable for Client Person
+        final String datatableName = Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_", 5);
+        final boolean genericResultSet = true;
+
+        HashMap<String, Object> columnMap = new HashMap<>();
+        List<HashMap<String, Object>> datatableColumnsList = new ArrayList<>();
+        columnMap.put("datatableName", datatableName);
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", CLIENT_PERSON_SUBTYPE_NAME);
+        columnMap.put("multiRow", false);
+        DatatableHelper.addDatatableColumns(datatableColumnsList, "itsANumber", "Number", false, null, null);
+        DatatableHelper.addDatatableColumns(datatableColumnsList, "itsAString", "String", false, 10, null);
+        columnMap.put("columns", datatableColumnsList);
+        String datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map : {}", datatabelRequestJsonString);
+
+        PostDataTablesResponse datatableCreateResponse = this.datatableHelper.createDatatable(datatabelRequestJsonString);
+        assertEquals(datatableName, datatableCreateResponse.getResourceIdentifier());
+        DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, datatableName);
+
+        // Insert first values
+        String value = Utils.randomStringGenerator("Q", 8);
+        HashMap<String, Object> datatableEntryMap = new HashMap<>();
+        datatableEntryMap.put("itsANumber", randomNumber);
+        datatableEntryMap.put("itsAString", value);
+
+        datatableEntryMap.put("locale", "en");
+        datatableEntryMap.put("dateFormat", "yyyy-MM-dd");
+
+        String datatableEntryRequestJsonString = new GsonBuilder().serializeNulls().create().toJson(datatableEntryMap);
+        PostDataTablesAppTableIdResponse datatableEntryResponse = this.datatableHelper.addDatatableEntry(datatableName, clientId,
+                genericResultSet, datatableEntryRequestJsonString);
+        assertNotNull(datatableEntryResponse.getResourceId(), "ERROR IN CREATING THE ENTITY DATATABLE RECORD");
+
+        // Read the Datatable entry generated with genericResultSet in true (default)
+        HashMap<String, Object> items = this.datatableHelper.readDatatableEntry(datatableName, clientId, genericResultSet, null, "");
+        assertNotNull(items);
+        assertEquals(1, ((List) items.get("data")).size());
+
+        assertEquals(clientId, ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(0));
+        assertEquals(value, ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(2));
+
+        // Update DataTable
+        columnMap = new HashMap<>();
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", CLIENT_PERSON_SUBTYPE_NAME);
+        datatableColumnsList = new ArrayList<>();
+        DatatableHelper.addDatatableColumns(datatableColumnsList, "itsAText", "Text", false, null, null);
+        columnMap.put("addColumns", datatableColumnsList);
+        datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map to update : {}", datatabelRequestJsonString);
+        PutDataTablesResponse datatableUpdateResponse = this.datatableHelper.updateDatatable(datatableName, datatabelRequestJsonString);
+        assertNotNull(datatableUpdateResponse);
+        assertEquals(datatableName, datatableUpdateResponse.getResourceIdentifier());
+
+        // Update DataTable Entry after Update DataTable schema
+        datatableEntryMap = new HashMap<>();
+        datatableEntryMap.put("itsAText", Utils.randomStringGenerator(value, 120));
+        datatableEntryMap.put("locale", "en");
+        datatableEntryMap.put("dateFormat", "yyyy-MM-dd");
+
+        datatableEntryRequestJsonString = new GsonBuilder().serializeNulls().create().toJson(datatableEntryMap);
+        LOG.info("map to update : {}", datatableEntryRequestJsonString);
+        PutDataTablesAppTableIdDatatableIdResponse updatedDatatableEntryResponse = this.datatableHelper.updateDatatableEntry(datatableName,
+                clientId, datatableEntryRequestJsonString);
+        assertNotNull(updatedDatatableEntryResponse);
+        assertEquals(1, updatedDatatableEntryResponse.getChanges().size());
+
+        // Read the Datatable entry generated with genericResultSet in true (default)
+        items = this.datatableHelper.readDatatableEntry(datatableName, clientId, genericResultSet, null, "");
+        assertNotNull(items);
+        assertEquals(1, ((List) items.get("data")).size());
+
+        assertEquals(clientId, ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(0));
+        assertEquals(value, ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(2));

Review Comment:
   Please check the updated column value here!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] josehernandezfintecheandomx commented on a diff in pull request #2881: FINERACT-1856: Fix to update datatable entry is failing after column added lately

Posted by GitBox <gi...@apache.org>.
josehernandezfintecheandomx commented on code in PR #2881:
URL: https://github.com/apache/fineract/pull/2881#discussion_r1071252666


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/DatatableIntegrationTest.java:
##########
@@ -426,6 +430,92 @@ public void validateInsertNullValues() {
         assertEquals(0, updatedDatatableEntryResponse.getChanges().size());
     }
 
+    @Test
+    public void validateCreateAndEditDatatable() {
+        // Creating client
+        final Integer clientId = ClientHelper.createClientAsPerson(requestSpec, responseSpec);
+        final Integer randomNumber = Utils.randomNumberGenerator(3);
+
+        // Creating datatable for Client Person
+        final String datatableName = Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_", 5);
+        final boolean genericResultSet = true;
+
+        HashMap<String, Object> columnMap = new HashMap<>();
+        List<HashMap<String, Object>> datatableColumnsList = new ArrayList<>();
+        columnMap.put("datatableName", datatableName);
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", CLIENT_PERSON_SUBTYPE_NAME);
+        columnMap.put("multiRow", false);
+        DatatableHelper.addDatatableColumns(datatableColumnsList, "itsANumber", "Number", false, null, null);
+        DatatableHelper.addDatatableColumns(datatableColumnsList, "itsAString", "String", false, 10, null);
+        columnMap.put("columns", datatableColumnsList);
+        String datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map : {}", datatabelRequestJsonString);
+
+        PostDataTablesResponse datatableCreateResponse = this.datatableHelper.createDatatable(datatabelRequestJsonString);
+        assertEquals(datatableName, datatableCreateResponse.getResourceIdentifier());
+        DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, datatableName);
+
+        // Insert first values
+        String value = Utils.randomStringGenerator("Q", 8);
+        HashMap<String, Object> datatableEntryMap = new HashMap<>();
+        datatableEntryMap.put("itsANumber", randomNumber);
+        datatableEntryMap.put("itsAString", value);
+
+        datatableEntryMap.put("locale", "en");
+        datatableEntryMap.put("dateFormat", "yyyy-MM-dd");
+
+        String datatableEntryRequestJsonString = new GsonBuilder().serializeNulls().create().toJson(datatableEntryMap);
+        PostDataTablesAppTableIdResponse datatableEntryResponse = this.datatableHelper.addDatatableEntry(datatableName, clientId,
+                genericResultSet, datatableEntryRequestJsonString);
+        assertNotNull(datatableEntryResponse.getResourceId(), "ERROR IN CREATING THE ENTITY DATATABLE RECORD");
+
+        // Read the Datatable entry generated with genericResultSet in true (default)
+        HashMap<String, Object> items = this.datatableHelper.readDatatableEntry(datatableName, clientId, genericResultSet, null, "");
+        assertNotNull(items);
+        assertEquals(1, ((List) items.get("data")).size());
+
+        assertEquals(clientId, ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(0));
+        assertEquals(value, ((List) ((Map) ((List) items.get("data")).get(0)).get("row")).get(2));
+
+        // Update DataTable
+        columnMap = new HashMap<>();
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", CLIENT_PERSON_SUBTYPE_NAME);
+        datatableColumnsList = new ArrayList<>();
+        DatatableHelper.addDatatableColumns(datatableColumnsList, "itsAText", "Text", false, null, null);
+        columnMap.put("addColumns", datatableColumnsList);
+        datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map to update : {}", datatabelRequestJsonString);
+        PutDataTablesResponse datatableUpdateResponse = this.datatableHelper.updateDatatable(datatableName, datatabelRequestJsonString);
+        assertNotNull(datatableUpdateResponse);
+        assertEquals(datatableName, datatableUpdateResponse.getResourceIdentifier());
+
+        // Update DataTable Entry after Update DataTable schema

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org