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

[PR] FINERACT-2169: Refactor calendar controller and service; [fineract]

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

   ## Description
   
   1) Replace String req/res to DTO;
   2) Change return type Collection to List;
   3) Enhance code style and add Lombok;  
   
   ## 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


Re: [PR] FINERACT-2169: Refactor calendar controller and service; [fineract]

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/api/CalendarsApiResource.java:
##########
@@ -87,26 +83,23 @@ public class CalendarsApiResource {
     @Path("{calendarId}")
     @Consumes({ MediaType.APPLICATION_JSON })
     @Produces({ MediaType.APPLICATION_JSON })
-    public String retrieveCalendar(@PathParam("calendarId") final Long calendarId, @PathParam("entityType") final String entityType,
+    public CalendarData retrieveCalendar(@PathParam("calendarId") final Long calendarId, @PathParam("entityType") final String entityType,
             @PathParam("entityId") final Long entityId, @Context final UriInfo uriInfo) {
 
-        this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
+        context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
         final Integer entityTypeId = CalendarEntityType.valueOf(entityType.toUpperCase()).getValue();
-        CalendarData calendarData = this.readPlatformService.retrieveCalendar(calendarId, entityId, entityTypeId);
+        final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
 
-        // Include recurring date details
-        final boolean withHistory = true;
-        final LocalDate tillDate = null;
-        final Collection<LocalDate> recurringDates = this.readPlatformService.generateRecurringDates(calendarData, withHistory, tillDate);
-        final Collection<LocalDate> nextTenRecurringDates = this.readPlatformService.generateNextTenRecurringDates(calendarData);
-        final LocalDate recentEligibleMeetingDate = null;
-        calendarData = CalendarData.withRecurringDates(calendarData, recurringDates, nextTenRecurringDates, recentEligibleMeetingDate);
+        final CalendarData calendarData = readPlatformService.retrieveCalendar(calendarId, entityId, entityTypeId);
+        final Collection<LocalDate> recurringDates = readPlatformService.generateRecurringDates(calendarData, true, null);
+        final Collection<LocalDate> nextTenRecurringDates = readPlatformService.generateNextTenRecurringDates(calendarData);
+        calendarData.setRecurringDates(recurringDates);
+        calendarData.setNextTenRecurringDates(nextTenRecurringDates);
 
-        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
         if (settings.isTemplate()) {
-            calendarData = handleTemplate(calendarData);
+            handleTemplate(calendarData);

Review Comment:
   handleTemplate returns new object. We should use it!



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


Re: [PR] FINERACT-2169: Refactor calendar controller and service; [fineract]

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/api/CalendarsApiResource.java:
##########
@@ -87,26 +83,23 @@ public class CalendarsApiResource {
     @Path("{calendarId}")
     @Consumes({ MediaType.APPLICATION_JSON })
     @Produces({ MediaType.APPLICATION_JSON })
-    public String retrieveCalendar(@PathParam("calendarId") final Long calendarId, @PathParam("entityType") final String entityType,
+    public CalendarData retrieveCalendar(@PathParam("calendarId") final Long calendarId, @PathParam("entityType") final String entityType,
             @PathParam("entityId") final Long entityId, @Context final UriInfo uriInfo) {
 
-        this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
+        context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
         final Integer entityTypeId = CalendarEntityType.valueOf(entityType.toUpperCase()).getValue();
-        CalendarData calendarData = this.readPlatformService.retrieveCalendar(calendarId, entityId, entityTypeId);
+        final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
 
-        // Include recurring date details
-        final boolean withHistory = true;
-        final LocalDate tillDate = null;
-        final Collection<LocalDate> recurringDates = this.readPlatformService.generateRecurringDates(calendarData, withHistory, tillDate);
-        final Collection<LocalDate> nextTenRecurringDates = this.readPlatformService.generateNextTenRecurringDates(calendarData);
-        final LocalDate recentEligibleMeetingDate = null;
-        calendarData = CalendarData.withRecurringDates(calendarData, recurringDates, nextTenRecurringDates, recentEligibleMeetingDate);
+        final CalendarData calendarData = readPlatformService.retrieveCalendar(calendarId, entityId, entityTypeId);
+        final Collection<LocalDate> recurringDates = readPlatformService.generateRecurringDates(calendarData, true, null);
+        final Collection<LocalDate> nextTenRecurringDates = readPlatformService.generateNextTenRecurringDates(calendarData);
+        calendarData.setRecurringDates(recurringDates);
+        calendarData.setNextTenRecurringDates(nextTenRecurringDates);
 
-        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
         if (settings.isTemplate()) {
-            calendarData = handleTemplate(calendarData);
+            handleTemplate(calendarData);

Review Comment:
   I meant the following:
   handleTemplate has an incoming parameter which is the `calendarData`. 
   
   The handleTemplate method creates a new object and add additional values and return a new `calendarData` we should return as result this new object, not the old one...



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


Re: [PR] FINERACT-2169: Refactor calendar controller and service; [fineract]

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


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


Re: [PR] FINERACT-2169: Refactor calendar controller and service; [fineract]

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/api/CalendarsApiResource.java:
##########
@@ -87,26 +83,23 @@ public class CalendarsApiResource {
     @Path("{calendarId}")
     @Consumes({ MediaType.APPLICATION_JSON })
     @Produces({ MediaType.APPLICATION_JSON })
-    public String retrieveCalendar(@PathParam("calendarId") final Long calendarId, @PathParam("entityType") final String entityType,
+    public CalendarData retrieveCalendar(@PathParam("calendarId") final Long calendarId, @PathParam("entityType") final String entityType,
             @PathParam("entityId") final Long entityId, @Context final UriInfo uriInfo) {
 
-        this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
+        context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
         final Integer entityTypeId = CalendarEntityType.valueOf(entityType.toUpperCase()).getValue();
-        CalendarData calendarData = this.readPlatformService.retrieveCalendar(calendarId, entityId, entityTypeId);
+        final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
 
-        // Include recurring date details
-        final boolean withHistory = true;
-        final LocalDate tillDate = null;
-        final Collection<LocalDate> recurringDates = this.readPlatformService.generateRecurringDates(calendarData, withHistory, tillDate);
-        final Collection<LocalDate> nextTenRecurringDates = this.readPlatformService.generateNextTenRecurringDates(calendarData);
-        final LocalDate recentEligibleMeetingDate = null;
-        calendarData = CalendarData.withRecurringDates(calendarData, recurringDates, nextTenRecurringDates, recentEligibleMeetingDate);
+        final CalendarData calendarData = readPlatformService.retrieveCalendar(calendarId, entityId, entityTypeId);
+        final Collection<LocalDate> recurringDates = readPlatformService.generateRecurringDates(calendarData, true, null);
+        final Collection<LocalDate> nextTenRecurringDates = readPlatformService.generateNextTenRecurringDates(calendarData);
+        calendarData.setRecurringDates(recurringDates);
+        calendarData.setNextTenRecurringDates(nextTenRecurringDates);
 
-        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
         if (settings.isTemplate()) {
-            calendarData = handleTemplate(calendarData);
+            handleTemplate(calendarData);

Review Comment:
   I'm apologize, I'm not sure I understood that. Yes, handleTemplate returns new object, but i'm a little bit confuse for what it..?:) 
   If we'll have 1 million request here, so, we'll have 1 million object in memory which not use and jvm should be run GC to remove this object.. Is it ok ? 
   I have investigated and realized that this is same object but in handleTemplate() has additional data and we have wrapped to new object... I don't get it for what..?:)



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


Re: [PR] FINERACT-2169: Refactor calendar controller and service; [fineract]

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/api/CalendarsApiResource.java:
##########
@@ -87,26 +83,23 @@ public class CalendarsApiResource {
     @Path("{calendarId}")
     @Consumes({ MediaType.APPLICATION_JSON })
     @Produces({ MediaType.APPLICATION_JSON })
-    public String retrieveCalendar(@PathParam("calendarId") final Long calendarId, @PathParam("entityType") final String entityType,
+    public CalendarData retrieveCalendar(@PathParam("calendarId") final Long calendarId, @PathParam("entityType") final String entityType,
             @PathParam("entityId") final Long entityId, @Context final UriInfo uriInfo) {
 
-        this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
+        context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
         final Integer entityTypeId = CalendarEntityType.valueOf(entityType.toUpperCase()).getValue();
-        CalendarData calendarData = this.readPlatformService.retrieveCalendar(calendarId, entityId, entityTypeId);
+        final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
 
-        // Include recurring date details
-        final boolean withHistory = true;
-        final LocalDate tillDate = null;
-        final Collection<LocalDate> recurringDates = this.readPlatformService.generateRecurringDates(calendarData, withHistory, tillDate);
-        final Collection<LocalDate> nextTenRecurringDates = this.readPlatformService.generateNextTenRecurringDates(calendarData);
-        final LocalDate recentEligibleMeetingDate = null;
-        calendarData = CalendarData.withRecurringDates(calendarData, recurringDates, nextTenRecurringDates, recentEligibleMeetingDate);
+        final CalendarData calendarData = readPlatformService.retrieveCalendar(calendarId, entityId, entityTypeId);
+        final Collection<LocalDate> recurringDates = readPlatformService.generateRecurringDates(calendarData, true, null);
+        final Collection<LocalDate> nextTenRecurringDates = readPlatformService.generateNextTenRecurringDates(calendarData);
+        calendarData.setRecurringDates(recurringDates);
+        calendarData.setNextTenRecurringDates(nextTenRecurringDates);
 
-        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
         if (settings.isTemplate()) {
-            calendarData = handleTemplate(calendarData);
+            handleTemplate(calendarData);

Review Comment:
   I have modified it and ready to review or merge.



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