You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "b0c1 (via GitHub)" <gi...@apache.org> on 2023/08/25 11:01:04 UTC

[GitHub] [fineract] b0c1 opened a new pull request, #3401: FINERACT-1760: Update office by external id

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

   FINERACT-1760: Update office by external id
   - [x] Add new resource to update
   - [x] Integration test
   


-- 
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] galovics commented on a diff in pull request #3401: FINERACT-1760: Update office by external id

Posted by "galovics (via GitHub)" <gi...@apache.org>.
galovics commented on code in PR #3401:
URL: https://github.com/apache/fineract/pull/3401#discussion_r1307047821


##########
fineract-provider/src/main/java/org/apache/fineract/organisation/office/api/OfficesApiResource.java:
##########
@@ -176,6 +176,25 @@ public String updateOffice(@PathParam("officeId") @Parameter(description = "offi
         return toApiJsonSerializer.serialize(result);
     }
 
+    @PUT

Review Comment:
   Can't we use the new serializers to do this API? i.e. return the object directly from the method, etc so that you don't need this many swagger annotations.



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/common/OfficeHelper.java:
##########
@@ -82,13 +88,33 @@ public Integer updateOffice(int id, String name, String openingDate) {
                 new Gson().toJson(map), "resourceId");
     }
 
+    public Integer updateOfficeUsingExternalId(String externalId, String name, String openingDate) {

Review Comment:
   Can't we use the generated Office API?



##########
fineract-core/src/main/java/org/apache/fineract/organisation/office/service/OfficeReadPlatformService.java:
##########
@@ -31,6 +31,8 @@ public interface OfficeReadPlatformService {
 
     OfficeData retrieveOffice(Long officeId);
 
+    OfficeData retrieveOfficeWithExternalId(String externalId);

Review Comment:
   ExternalId class?



##########
fineract-provider/src/main/java/org/apache/fineract/organisation/office/service/OfficeReadPlatformServiceImpl.java:
##########
@@ -210,6 +210,22 @@ public OfficeData retrieveOffice(final Long officeId) {
         }
     }
 
+    @Override
+    public OfficeData retrieveOfficeWithExternalId(String externalId) {

Review Comment:
   Not to my liking to be honest. This should be solved by using JPQL + a projection. I wouldn't breed more native queries unnecessarily although I understand it was a copy paste.



##########
fineract-core/src/main/java/org/apache/fineract/organisation/office/exception/OfficeNotFoundException.java:
##########
@@ -33,4 +33,8 @@ public OfficeNotFoundException(final Long id) {
     public OfficeNotFoundException(Long id, EmptyResultDataAccessException e) {
         super("error.msg.office.id.invalid", "Office with identifier " + id + " does not exist", id, e);
     }
+
+    public OfficeNotFoundException(String externalId, EmptyResultDataAccessException e) {

Review Comment:
   Should be ExternalId class, not String.



-- 
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] b0c1 commented on a diff in pull request #3401: FINERACT-1760: Update office by external id

Posted by "b0c1 (via GitHub)" <gi...@apache.org>.
b0c1 commented on code in PR #3401:
URL: https://github.com/apache/fineract/pull/3401#discussion_r1308734131


##########
fineract-provider/src/main/java/org/apache/fineract/organisation/office/service/OfficeReadPlatformServiceImpl.java:
##########
@@ -34,35 +37,29 @@
 import org.apache.fineract.organisation.monetary.service.CurrencyReadPlatformService;
 import org.apache.fineract.organisation.office.data.OfficeData;
 import org.apache.fineract.organisation.office.data.OfficeTransactionData;
+import org.apache.fineract.organisation.office.domain.OfficeRepository;
 import org.apache.fineract.organisation.office.exception.OfficeNotFoundException;
+import org.apache.fineract.organisation.office.mapper.OfficeDataMapper;
 import org.apache.fineract.useradministration.domain.AppUser;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.stereotype.Service;
 
 @Service
+@RequiredArgsConstructor
 public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService {
 
     private final JdbcTemplate jdbcTemplate;
     private final DatabaseSpecificSQLGenerator sqlGenerator;
     private final PlatformSecurityContext context;
     private final CurrencyReadPlatformService currencyReadPlatformService;
     private final ColumnValidator columnValidator;
-    private static final String nameDecoratedBaseOnHierarchy = "concat(substring('........................................', 1, ((LENGTH(o.hierarchy) - LENGTH(REPLACE(o.hierarchy, '.', '')) - 1) * 4)), o.name)";
 
-    @Autowired
-    public OfficeReadPlatformServiceImpl(final PlatformSecurityContext context,
-            final CurrencyReadPlatformService currencyReadPlatformService, final JdbcTemplate jdbcTemplate,
-            final ColumnValidator columnValidator, DatabaseSpecificSQLGenerator sqlGenerator) {
-        this.context = context;
-        this.currencyReadPlatformService = currencyReadPlatformService;
-        this.columnValidator = columnValidator;
-        this.jdbcTemplate = jdbcTemplate;
-        this.sqlGenerator = sqlGenerator;
-    }
+    private final OfficeRepository officeRepository;
+    private final OfficeDataMapper officeDataMapper;
+    private static final String nameDecoratedBaseOnHierarchy = "concat(substring('........................................', 1, ((LENGTH(o.hierarchy) - LENGTH(REPLACE(o.hierarchy, '.', '')) - 1) * 4)), o.name)";

Review Comment:
   Still needed for the old codes.



-- 
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] galovics merged pull request #3401: FINERACT-1760: Update office by external id

Posted by "galovics (via GitHub)" <gi...@apache.org>.
galovics merged PR #3401:
URL: https://github.com/apache/fineract/pull/3401


-- 
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] galovics commented on a diff in pull request #3401: FINERACT-1760: Update office by external id

Posted by "galovics (via GitHub)" <gi...@apache.org>.
galovics commented on code in PR #3401:
URL: https://github.com/apache/fineract/pull/3401#discussion_r1308715049


##########
fineract-core/src/main/java/org/apache/fineract/organisation/office/mapper/OfficeDataMapper.java:
##########
@@ -0,0 +1,31 @@
+/**
+ * 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.organisation.office.mapper;
+
+import org.apache.fineract.organisation.office.data.OfficeData;
+import org.apache.fineract.organisation.office.domain.Office;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+
+@Mapper(componentModel = "spring")
+public interface OfficeDataMapper {

Review Comment:
   Pls use MapstructMapperConfig as a base configuration for every mapper.



##########
fineract-provider/src/main/java/org/apache/fineract/organisation/office/service/OfficeReadPlatformServiceImpl.java:
##########
@@ -34,35 +37,29 @@
 import org.apache.fineract.organisation.monetary.service.CurrencyReadPlatformService;
 import org.apache.fineract.organisation.office.data.OfficeData;
 import org.apache.fineract.organisation.office.data.OfficeTransactionData;
+import org.apache.fineract.organisation.office.domain.OfficeRepository;
 import org.apache.fineract.organisation.office.exception.OfficeNotFoundException;
+import org.apache.fineract.organisation.office.mapper.OfficeDataMapper;
 import org.apache.fineract.useradministration.domain.AppUser;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.stereotype.Service;
 
 @Service
+@RequiredArgsConstructor
 public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService {
 
     private final JdbcTemplate jdbcTemplate;
     private final DatabaseSpecificSQLGenerator sqlGenerator;
     private final PlatformSecurityContext context;
     private final CurrencyReadPlatformService currencyReadPlatformService;
     private final ColumnValidator columnValidator;
-    private static final String nameDecoratedBaseOnHierarchy = "concat(substring('........................................', 1, ((LENGTH(o.hierarchy) - LENGTH(REPLACE(o.hierarchy, '.', '')) - 1) * 4)), o.name)";
 
-    @Autowired
-    public OfficeReadPlatformServiceImpl(final PlatformSecurityContext context,
-            final CurrencyReadPlatformService currencyReadPlatformService, final JdbcTemplate jdbcTemplate,
-            final ColumnValidator columnValidator, DatabaseSpecificSQLGenerator sqlGenerator) {
-        this.context = context;
-        this.currencyReadPlatformService = currencyReadPlatformService;
-        this.columnValidator = columnValidator;
-        this.jdbcTemplate = jdbcTemplate;
-        this.sqlGenerator = sqlGenerator;
-    }
+    private final OfficeRepository officeRepository;
+    private final OfficeDataMapper officeDataMapper;
+    private static final String nameDecoratedBaseOnHierarchy = "concat(substring('........................................', 1, ((LENGTH(o.hierarchy) - LENGTH(REPLACE(o.hierarchy, '.', '')) - 1) * 4)), o.name)";

Review Comment:
   Are we using this?



##########
fineract-provider/src/main/java/org/apache/fineract/organisation/office/api/OfficeSwaggerMapper.java:
##########
@@ -0,0 +1,37 @@
+/**
+ * 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.organisation.office.api;
+
+import java.util.Map;
+import java.util.Optional;
+import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
+import org.mapstruct.Mapper;
+
+@Mapper(componentModel = "spring")
+public interface OfficeSwaggerMapper {

Review Comment:
   Same as for the other: MapstructMapperConfig



-- 
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