diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/api/SmsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/api/SmsApiResource.java index 7c72a329a..eabe973e6 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/api/SmsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/api/SmsApiResource.java @@ -47,14 +47,12 @@ import org.apache.fineract.infrastructure.core.service.SearchParameters; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.sms.data.SmsData; import org.apache.fineract.infrastructure.sms.service.SmsReadPlatformService; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @Path("/sms") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @Component -@Scope("singleton") @Tag(name = "SMS", description = "") @RequiredArgsConstructor public class SmsApiResource { @@ -69,33 +67,25 @@ public class SmsApiResource { @GET public String retrieveAll(@Context final UriInfo uriInfo) { - - this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); - - final Collection smsMessages = this.readPlatformService.retrieveAll(); - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, smsMessages); + context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions); + final Collection smsMessages = readPlatformService.retrieveAll(); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, smsMessages); } @POST public String create(final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createSms().withJson(apiRequestBodyAsJson).build(); - - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } @GET @Path("{resourceId}") public String retrieveOne(@PathParam("resourceId") final Long resourceId, @Context final UriInfo uriInfo) { - - final SmsData smsMessage = this.readPlatformService.retrieveOne(resourceId); - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, smsMessage); + final SmsData smsMessage = readPlatformService.retrieveOne(resourceId); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, smsMessage); } @GET @@ -106,9 +96,7 @@ public class SmsApiResource { @QueryParam("dateFormat") final String dateFormat, @QueryParam("sqlSearch") final String sqlSearch, @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder) { - context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions); - final SearchParameters searchParameters = SearchParameters.forSMSCampaign(sqlSearch, offset, limit, orderBy, sortOrder); LocalDate fromDate = null; @@ -130,22 +118,16 @@ public class SmsApiResource { @PUT @Path("{resourceId}") public String update(@PathParam("resourceId") final Long resourceId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateSms(resourceId).withJson(apiRequestBodyAsJson).build(); - - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } @DELETE @Path("{resourceId}") public String delete(@PathParam("resourceId") final Long resourceId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteSms(resourceId).build(); - - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/domain/SmsMessage.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/domain/SmsMessage.java index 381a2ea51..ea3516268 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/domain/SmsMessage.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/domain/SmsMessage.java @@ -49,47 +49,41 @@ import org.apache.fineract.portfolio.group.domain.Group; @Accessors(chain = true) public class SmsMessage extends AbstractPersistableCustom { - @Column(name = "external_id", nullable = true) + @Column(name = "external_id") private String externalId; @ManyToOne - @JoinColumn(name = "group_id", nullable = true) + @JoinColumn(name = "group_id") private Group group; @ManyToOne - @JoinColumn(name = "client_id", nullable = true) + @JoinColumn(name = "client_id") private Client client; @ManyToOne - @JoinColumn(name = "staff_id", nullable = true) + @JoinColumn(name = "staff_id") private Staff staff; @ManyToOne - @JoinColumn(name = "campaign_id", nullable = true) + @JoinColumn(name = "campaign_id") private SmsCampaign smsCampaign; @Column(name = "status_enum", nullable = false) private Integer statusType; - @Column(name = "mobile_no", nullable = true, length = 50) + @Column(name = "mobile_no", length = 50) private String mobileNo; @Column(name = "message", nullable = false) private String message; - // @Column(name = "provider_id", nullable = true) - // private Long providerId; - // - // @Column(name = "campaign_name", nullable = true) - // private String campaignName; - - @Column(name = "submittedon_date", nullable = true) + @Column(name = "submittedon_date") private LocalDate submittedOnDate; - @Column(name = "delivered_on_date", nullable = true) + @Column(name = "delivered_on_date") private LocalDateTime deliveredOnDate; - @Column(name = "is_notification", nullable = true) + @Column(name = "is_notification") private boolean isNotification; public static SmsMessage pendingSms(final String externalId, final Group group, final Client client, final Staff staff, diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/service/SmsReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/service/SmsReadPlatformServiceImpl.java index b42bce5af..82794bd60 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/service/SmsReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/sms/service/SmsReadPlatformServiceImpl.java @@ -124,7 +124,6 @@ public class SmsReadPlatformServiceImpl implements SmsReadPlatformService { public SmsData retrieveOne(final Long resourceId) { try { final String sql = "select " + this.smsRowMapper.schema() + " where smo.id = ?"; - return this.jdbcTemplate.queryForObject(sql, this.smsRowMapper, new Object[] { resourceId }); // NOSONAR } catch (final EmptyResultDataAccessException e) { throw new SmsNotFoundException(resourceId, e); diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/office/api/OfficesApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/office/api/OfficesApiResource.java index a28755e72..b07348b54 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/office/api/OfficesApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/office/api/OfficesApiResource.java @@ -45,6 +45,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -62,14 +63,12 @@ import org.apache.fineract.organisation.office.data.OfficeData; import org.apache.fineract.organisation.office.service.OfficeReadPlatformService; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @Path("/offices") @Component -@Scope("singleton") @Tag(name = "Offices", description = "Offices are used to model an MFIs structure. A hierarchical representation of offices is supported. There will always be at least one office (which represents the MFI or an MFIs head office). All subsequent offices added must have a parent office.") +@RequiredArgsConstructor public class OfficesApiResource { /** @@ -88,21 +87,6 @@ public class OfficesApiResource { private final BulkImportWorkbookService bulkImportWorkbookService; private final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService; - @Autowired - public OfficesApiResource(final PlatformSecurityContext context, final OfficeReadPlatformService readPlatformService, - final DefaultToApiJsonSerializer toApiJsonSerializer, final ApiRequestParameterHelper apiRequestParameterHelper, - final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, - final BulkImportWorkbookService bulkImportWorkbookService, - final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService) { - this.context = context; - this.readPlatformService = readPlatformService; - this.toApiJsonSerializer = toApiJsonSerializer; - this.apiRequestParameterHelper = apiRequestParameterHelper; - this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; - this.bulkImportWorkbookService = bulkImportWorkbookService; - this.bulkImportWorkbookPopulatorService = bulkImportWorkbookPopulatorService; - } - @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @@ -114,15 +98,11 @@ public class OfficesApiResource { @DefaultValue("false") @QueryParam("includeAllOffices") @Parameter(description = "includeAllOffices") final boolean onlyManualEntries, @QueryParam("orderBy") @Parameter(description = "orderBy") final String orderBy, @QueryParam("sortOrder") @Parameter(description = "sortOrder") final String sortOrder) { - - this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); - + context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); final SearchParameters searchParameters = SearchParameters.forOffices(orderBy, sortOrder); - - final Collection offices = this.readPlatformService.retrieveAllOffices(onlyManualEntries, searchParameters); - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, offices, RESPONSE_DATA_PARAMETERS); + final Collection offices = readPlatformService.retrieveAllOffices(onlyManualEntries, searchParameters); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, offices, RESPONSE_DATA_PARAMETERS); } @GET @@ -134,16 +114,12 @@ public class OfficesApiResource { @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = OfficesApiResourceSwagger.GetOfficesTemplateResponse.class))) }) public String retrieveOfficeTemplate(@Context final UriInfo uriInfo) { - - this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); - - OfficeData office = this.readPlatformService.retrieveNewOfficeTemplate(); - - final Collection allowedParents = this.readPlatformService.retrieveAllOfficesForDropdown(); + context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); + OfficeData office = readPlatformService.retrieveNewOfficeTemplate(); + final Collection allowedParents = readPlatformService.retrieveAllOfficesForDropdown(); office = OfficeData.appendedTemplate(office, allowedParents); - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, office, RESPONSE_DATA_PARAMETERS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, office, RESPONSE_DATA_PARAMETERS); } @POST @@ -154,15 +130,12 @@ public class OfficesApiResource { @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = OfficesApiResourceSwagger.PostOfficesResponse.class))) }) public String createOffice(@Parameter(hidden = true) final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder() // .createOffice() // .withJson(apiRequestBodyAsJson) // .build(); - - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } @GET @@ -173,20 +146,16 @@ public class OfficesApiResource { + "offices/1?template=true\n" + "\n" + "\n" + "offices/1?fields=id,name,parentName") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = OfficesApiResourceSwagger.GetOfficesResponse.class))) }) - public String retreiveOffice(@PathParam("officeId") @Parameter(description = "officeId") final Long officeId, + public String retrieveOffice(@PathParam("officeId") @Parameter(description = "officeId") final Long officeId, @Context final UriInfo uriInfo) { - - this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - - OfficeData office = this.readPlatformService.retrieveOffice(officeId); + context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + OfficeData office = readPlatformService.retrieveOffice(officeId); if (settings.isTemplate()) { - final Collection allowedParents = this.readPlatformService.retrieveAllowedParents(officeId); + final Collection allowedParents = readPlatformService.retrieveAllowedParents(officeId); office = OfficeData.appendedTemplate(office, allowedParents); } - - return this.toApiJsonSerializer.serialize(settings, office, RESPONSE_DATA_PARAMETERS); + return toApiJsonSerializer.serialize(settings, office, RESPONSE_DATA_PARAMETERS); } @PUT @@ -199,15 +168,12 @@ public class OfficesApiResource { @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = OfficesApiResourceSwagger.PutOfficesOfficeIdResponse.class))) }) public String updateOffice(@PathParam("officeId") @Parameter(description = "officeId") final Long officeId, @Parameter(hidden = true) final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder() // .updateOffice(officeId) // .withJson(apiRequestBodyAsJson) // .build(); - - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } @GET @@ -225,8 +191,8 @@ public class OfficesApiResource { public String postOfficeTemplate(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("locale") final String locale, @FormDataParam("dateFormat") final String dateFormat) { - final Long importDocumentId = this.bulkImportWorkbookService.importWorkbook(GlobalEntityType.OFFICES.toString(), - uploadedInputStream, fileDetail, locale, dateFormat); - return this.toApiJsonSerializer.serialize(importDocumentId); + final Long importDocumentId = bulkImportWorkbookService.importWorkbook(GlobalEntityType.OFFICES.toString(), uploadedInputStream, + fileDetail, locale, dateFormat); + return toApiJsonSerializer.serialize(importDocumentId); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/office/domain/Office.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/office/domain/Office.java index 6da5a1936..c45434ae9 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/office/domain/Office.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/office/domain/Office.java @@ -54,7 +54,7 @@ public class Office extends AbstractPersistableCustom implements Serializable { @Column(name = "name", nullable = false, length = 100) private String name; - @Column(name = "hierarchy", nullable = true, length = 50) + @Column(name = "hierarchy", length = 50) private String hierarchy; @Column(name = "opening_date", nullable = false) diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResource.java index 89ca2e42a..38a2e0d48 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResource.java @@ -45,6 +45,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -63,14 +64,12 @@ import org.apache.fineract.organisation.staff.data.StaffData; import org.apache.fineract.organisation.staff.service.StaffReadPlatformService; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @Path("/staff") @Component -@Scope("singleton") @Tag(name = "Staff", description = "Allows you to model staff members. At present the key role of significance is whether this staff member is a loan officer or not.") +@RequiredArgsConstructor public class StaffApiResource { /** @@ -90,23 +89,6 @@ public class StaffApiResource { private final BulkImportWorkbookService bulkImportWorkbookService; private final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService; - @Autowired - public StaffApiResource(final PlatformSecurityContext context, final StaffReadPlatformService readPlatformService, - final OfficeReadPlatformService officeReadPlatformService, final DefaultToApiJsonSerializer toApiJsonSerializer, - final ApiRequestParameterHelper apiRequestParameterHelper, - final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, - final BulkImportWorkbookService bulkImportWorkbookService, - final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService) { - this.context = context; - this.readPlatformService = readPlatformService; - this.officeReadPlatformService = officeReadPlatformService; - this.toApiJsonSerializer = toApiJsonSerializer; - this.apiRequestParameterHelper = apiRequestParameterHelper; - this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; - this.bulkImportWorkbookService = bulkImportWorkbookService; - this.bulkImportWorkbookPopulatorService = bulkImportWorkbookPopulatorService; - } - @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @@ -122,18 +104,15 @@ public class StaffApiResource { @DefaultValue("false") @QueryParam("staffInOfficeHierarchy") @Parameter(description = "staffInOfficeHierarchy") final boolean staffInOfficeHierarchy, @DefaultValue("false") @QueryParam("loanOfficersOnly") @Parameter(description = "loanOfficersOnly") final boolean loanOfficersOnly, @DefaultValue("active") @QueryParam("status") @Parameter(description = "status") final String status) { - - this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); - + context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); final Collection staff; if (staffInOfficeHierarchy) { - staff = this.readPlatformService.retrieveAllStaffInOfficeAndItsParentOfficeHierarchy(officeId, loanOfficersOnly); + staff = readPlatformService.retrieveAllStaffInOfficeAndItsParentOfficeHierarchy(officeId, loanOfficersOnly); } else { - staff = this.readPlatformService.retrieveAllStaff(officeId, loanOfficersOnly, status); + staff = readPlatformService.retrieveAllStaff(officeId, loanOfficersOnly, status); } - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, staff, RESPONSE_DATA_PARAMETERS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, staff, RESPONSE_DATA_PARAMETERS); } @POST @@ -145,12 +124,9 @@ public class StaffApiResource { @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = StaffApiResourceSwagger.CreateStaffResponse.class))) }) public String create(@Parameter(hidden = true) final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createStaff().withJson(apiRequestBodyAsJson).build(); - - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } @GET @@ -163,17 +139,14 @@ public class StaffApiResource { @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = StaffApiResourceSwagger.RetrieveOneResponse.class))) }) public String retrieveOne(@PathParam("staffId") @Parameter(description = "staffId") final Long staffId, @Context final UriInfo uriInfo) { - - this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - - StaffData staff = this.readPlatformService.retrieveStaff(staffId); + context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + StaffData staff = readPlatformService.retrieveStaff(staffId); if (settings.isTemplate()) { - final Collection allowedOffices = this.officeReadPlatformService.retrieveAllOfficesForDropdown(); + final Collection allowedOffices = officeReadPlatformService.retrieveAllOfficesForDropdown(); staff = StaffData.templateData(staff, allowedOffices); } - return this.toApiJsonSerializer.serialize(settings, staff, RESPONSE_DATA_PARAMETERS); + return toApiJsonSerializer.serialize(settings, staff, RESPONSE_DATA_PARAMETERS); } @PUT @@ -186,12 +159,9 @@ public class StaffApiResource { @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = StaffApiResourceSwagger.UpdateStaffResponse.class))) }) public String update(@PathParam("staffId") @Parameter(description = "staffId") final Long staffId, @Parameter(hidden = true) final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateStaff(staffId).withJson(apiRequestBodyAsJson).build(); - - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } @GET @@ -209,8 +179,8 @@ public class StaffApiResource { public String postTemplate(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("locale") final String locale, @FormDataParam("dateFormat") final String dateFormat) { - final Long importDocumentId = this.bulkImportWorkbookService.importWorkbook(GlobalEntityType.STAFF.toString(), uploadedInputStream, + final Long importDocumentId = bulkImportWorkbookService.importWorkbook(GlobalEntityType.STAFF.toString(), uploadedInputStream, fileDetail, locale, dateFormat); - return this.toApiJsonSerializer.serialize(importDocumentId); + return toApiJsonSerializer.serialize(importDocumentId); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/domain/Staff.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/domain/Staff.java index 261d885e3..258139b0d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/domain/Staff.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/domain/Staff.java @@ -53,7 +53,7 @@ public class Staff extends AbstractPersistableCustom { @Column(name = "mobile_no", length = 50, nullable = false, unique = true) private String mobileNo; - @Column(name = "external_id", length = 100, nullable = true, unique = true) + @Column(name = "external_id", length = 100, unique = true) private String externalId; @Column(name = "email_address", length = 50, unique = true) @@ -66,21 +66,21 @@ public class Staff extends AbstractPersistableCustom { @Column(name = "is_loan_officer", nullable = false) private boolean loanOfficer; - @Column(name = "organisational_role_enum", nullable = true) + @Column(name = "organisational_role_enum") private Integer organisationalRoleType; @Column(name = "is_active", nullable = false) private boolean active; - @Column(name = "joining_date", nullable = true) + @Column(name = "joining_date") private LocalDate joiningDate; @ManyToOne - @JoinColumn(name = "organisational_role_parent_staff_id", nullable = true) + @JoinColumn(name = "organisational_role_parent_staff_id") private Staff organisationalRoleParentStaff; @OneToOne(optional = true) - @JoinColumn(name = "image_id", nullable = true) + @JoinColumn(name = "image_id") private Image image; public static Staff fromJson(final Office staffOffice, final JsonCommand command) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java index 04a7a9d05..b083761e1 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java @@ -73,12 +73,10 @@ import org.apache.fineract.portfolio.savings.data.SavingsAccountData; import org.apache.fineract.portfolio.savings.service.SavingsAccountReadPlatformService; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @Path("/clients") @Component -@Scope("singleton") @Tag(name = "Client", description = "Clients are people and businesses that have applied (or may apply) to an MFI for loans.\n" + "\n" + "Clients can be created in Pending or straight into Active state.") @RequiredArgsConstructor @@ -109,24 +107,24 @@ public class ClientsApiResource { @QueryParam("commandParam") @Parameter(description = "commandParam") final String commandParam, @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @Parameter(description = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { - this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); + context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); ClientData clientData = null; - this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); + context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); if (is(commandParam, "close")) { - clientData = this.clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_CLOSURE_REASON); + clientData = clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_CLOSURE_REASON); } else if (is(commandParam, "acceptTransfer")) { - clientData = this.clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_CLOSURE_REASON); + clientData = clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_CLOSURE_REASON); } else if (is(commandParam, "reject")) { - clientData = this.clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_REJECT_REASON); + clientData = clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_REJECT_REASON); } else if (is(commandParam, "withdraw")) { - clientData = this.clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_WITHDRAW_REASON); + clientData = clientReadPlatformService.retrieveAllNarrations(ClientApiConstants.CLIENT_WITHDRAW_REASON); } else { - clientData = this.clientReadPlatformService.retrieveTemplate(officeId, staffInSelectedOfficeOnly); + clientData = clientReadPlatformService.retrieveTemplate(officeId, staffInSelectedOfficeOnly); } - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, clientData, ClientApiConstants.CLIENT_RESPONSE_DATA_PARAMETERS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, clientData, ClientApiConstants.CLIENT_RESPONSE_DATA_PARAMETERS); } @GET @@ -152,24 +150,20 @@ public class ClientsApiResource { @QueryParam("sortOrder") @Parameter(description = "sortOrder") final String sortOrder, @QueryParam("orphansOnly") @Parameter(description = "orphansOnly") final Boolean orphansOnly) { - return this.retrieveAll(uriInfo, sqlSearch, officeId, externalId, displayName, firstname, lastname, status, hierarchy, offset, - limit, orderBy, sortOrder, orphansOnly, false); + return retrieveAll(uriInfo, sqlSearch, officeId, externalId, displayName, firstname, lastname, status, hierarchy, offset, limit, + orderBy, sortOrder, orphansOnly, false); } public String retrieveAll(final UriInfo uriInfo, final String sqlSearch, final Long officeId, final String externalId, final String displayName, final String firstname, final String lastname, final String status, final String hierarchy, final Integer offset, final Integer limit, final String orderBy, final String sortOrder, final Boolean orphansOnly, final boolean isSelfUser) { - - this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); - + context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); final SearchParameters searchParameters = SearchParameters.forClients(sqlSearch, officeId, externalId, displayName, firstname, lastname, status, hierarchy, offset, limit, orderBy, sortOrder, orphansOnly, isSelfUser); - - final Page clientData = this.clientReadPlatformService.retrieveAll(searchParameters); - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, clientData, ClientApiConstants.CLIENT_RESPONSE_DATA_PARAMETERS); + final Page clientData = clientReadPlatformService.retrieveAll(searchParameters); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, clientData, ClientApiConstants.CLIENT_RESPONSE_DATA_PARAMETERS); } @GET @@ -184,22 +178,21 @@ public class ClientsApiResource { @Context final UriInfo uriInfo, @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @Parameter(description = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { - this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); + context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - ClientData clientData = this.clientReadPlatformService.retrieveOne(clientId); + ClientData clientData = clientReadPlatformService.retrieveOne(clientId); if (settings.isTemplate()) { - final ClientData templateData = this.clientReadPlatformService.retrieveTemplate(clientData.getOfficeId(), - staffInSelectedOfficeOnly); + final ClientData templateData = clientReadPlatformService.retrieveTemplate(clientData.getOfficeId(), staffInSelectedOfficeOnly); clientData = ClientData.templateOnTop(clientData, templateData); - Collection savingAccountOptions = this.savingsAccountReadPlatformService.retrieveForLookup(clientId, null); + Collection savingAccountOptions = savingsAccountReadPlatformService.retrieveForLookup(clientId, null); if (savingAccountOptions != null && savingAccountOptions.size() > 0) { clientData = ClientData.templateWithSavingAccountOptions(clientData, savingAccountOptions); } } - return this.toApiJsonSerializer.serialize(settings, clientData, ClientApiConstants.CLIENT_RESPONSE_DATA_PARAMETERS); + return toApiJsonSerializer.serialize(settings, clientData, ClientApiConstants.CLIENT_RESPONSE_DATA_PARAMETERS); } @POST @@ -220,9 +213,9 @@ public class ClientsApiResource { .withJson(apiRequestBodyAsJson) // .build(); // - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + return toApiJsonSerializer.serialize(result); } @PUT @@ -244,9 +237,9 @@ public class ClientsApiResource { .withJson(apiRequestBodyAsJson) // .build(); // - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + return toApiJsonSerializer.serialize(result); } @DELETE @@ -263,9 +256,9 @@ public class ClientsApiResource { .deleteClient(clientId) // .build(); // - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + return toApiJsonSerializer.serialize(result); } @POST @@ -315,51 +308,51 @@ public class ClientsApiResource { CommandWrapper commandRequest = null; if (is(commandParam, "activate")) { commandRequest = builder.activateClient(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "assignStaff")) { commandRequest = builder.assignClientStaff(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "unassignStaff")) { commandRequest = builder.unassignClientStaff(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "close")) { commandRequest = builder.closeClient(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "proposeTransfer")) { commandRequest = builder.proposeClientTransfer(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "proposeAndAcceptTransfer")) { commandRequest = builder.proposeAndAcceptClientTransfer(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "withdrawTransfer")) { commandRequest = builder.withdrawClientTransferRequest(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "acceptTransfer")) { commandRequest = builder.acceptClientTransfer(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "rejectTransfer")) { commandRequest = builder.rejectClientTransfer(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "updateSavingsAccount")) { commandRequest = builder.updateClientSavingsAccount(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "reject")) { commandRequest = builder.rejectClient(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "withdraw")) { commandRequest = builder.withdrawClient(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "reactivate")) { commandRequest = builder.reActivateClient(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "undoRejection")) { commandRequest = builder.undoRejection(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "undoWithdrawal")) { commandRequest = builder.undoWithdrawal(clientId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } if (result == null) { @@ -368,7 +361,7 @@ public class ClientsApiResource { "acceptTransfer", "rejectTransfer", "updateSavingsAccount", "reject", "withdraw", "reactivate" }); } - return this.toApiJsonSerializer.serialize(result); + return toApiJsonSerializer.serialize(result); } private boolean is(final String commandParam, final String commandValue) { @@ -388,15 +381,15 @@ public class ClientsApiResource { public String retrieveAssociatedAccounts(@PathParam("clientId") @Parameter(description = "clientId") final Long clientId, @Context final UriInfo uriInfo) { - this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); + context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); - final AccountSummaryCollectionData clientAccount = this.accountDetailsReadPlatformService.retrieveClientAccountDetails(clientId); + final AccountSummaryCollectionData clientAccount = accountDetailsReadPlatformService.retrieveClientAccountDetails(clientId); final Set CLIENT_ACCOUNTS_DATA_PARAMETERS = new HashSet<>( Arrays.asList("loanAccounts", "savingsAccounts", "shareAccounts")); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.clientAccountSummaryToApiJsonSerializer.serialize(settings, clientAccount, CLIENT_ACCOUNTS_DATA_PARAMETERS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return clientAccountSummaryToApiJsonSerializer.serialize(settings, clientAccount, CLIENT_ACCOUNTS_DATA_PARAMETERS); } @GET @@ -417,7 +410,7 @@ public class ClientsApiResource { @FormDataParam("locale") final String locale, @FormDataParam("dateFormat") final String dateFormat) { final Long importDocumentId = bulkImportWorkbookService.importWorkbook(legalFormType, uploadedInputStream, fileDetail, locale, dateFormat); - return this.toApiJsonSerializer.serialize(importDocumentId); + return toApiJsonSerializer.serialize(importDocumentId); } @GET @@ -426,11 +419,11 @@ public class ClientsApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String retrieveObligeeDetails(@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo) { - this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); + context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); - final List ObligeeList = this.guarantorReadPlatformService.retrieveObligeeDetails(clientId); + final List ObligeeList = guarantorReadPlatformService.retrieveObligeeDetails(clientId); - return this.toApiJsonSerializer.serialize(ObligeeList); + return toApiJsonSerializer.serialize(ObligeeList); } @GET @@ -439,8 +432,8 @@ public class ClientsApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String retrieveTransferTemplate(@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo) { - this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); - final LocalDate transferDate = this.clientReadPlatformService.retrieveClientTransferProposalDate(clientId); - return this.toApiJsonSerializer.serialize(transferDate); + context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); + final LocalDate transferDate = clientReadPlatformService.retrieveClientTransferProposalDate(clientId); + return toApiJsonSerializer.serialize(transferDate); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/Client.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/Client.java index 4a269c2e2..bb5429663 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/Client.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/Client.java @@ -69,11 +69,11 @@ public class Client extends AbstractAuditableWithUTCDateTimeCustom { private Office office; @ManyToOne - @JoinColumn(name = "transfer_to_office_id", nullable = true) + @JoinColumn(name = "transfer_to_office_id") private Office transferToOffice; @OneToOne(optional = true) - @JoinColumn(name = "image_id", nullable = true) + @JoinColumn(name = "image_id") private Image image; /** @@ -83,31 +83,31 @@ public class Client extends AbstractAuditableWithUTCDateTimeCustom { private Integer status; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "sub_status", nullable = true) + @JoinColumn(name = "sub_status") private CodeValue subStatus; - @Column(name = "activation_date", nullable = true) + @Column(name = "activation_date") private LocalDate activationDate; - @Column(name = "office_joining_date", nullable = true) + @Column(name = "office_joining_date") private LocalDate officeJoiningDate; - @Column(name = "firstname", length = 50, nullable = true) + @Column(name = "firstname", length = 50) private String firstname; - @Column(name = "middlename", length = 50, nullable = true) + @Column(name = "middlename", length = 50) private String middlename; - @Column(name = "lastname", length = 50, nullable = true) + @Column(name = "lastname", length = 50) private String lastname; - @Column(name = "fullname", length = 100, nullable = true) + @Column(name = "fullname", length = 100) private String fullname; @Column(name = "display_name", length = 100, nullable = false) private String displayName; - @Column(name = "mobile_no", length = 50, nullable = true, unique = true) + @Column(name = "mobile_no", length = 50, unique = true) private String mobileNo; @Column(name = "email_address", length = 50, unique = true) @@ -116,14 +116,14 @@ public class Client extends AbstractAuditableWithUTCDateTimeCustom { @Column(name = "is_staff", nullable = false) private boolean isStaff; - @Column(name = "external_id", length = 100, nullable = true, unique = true) + @Column(name = "external_id", length = 100, unique = true) private String externalId; - @Column(name = "date_of_birth", nullable = true) + @Column(name = "date_of_birth") private LocalDate dateOfBirth; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "gender_cv_id", nullable = true) + @JoinColumn(name = "gender_cv_id") private CodeValue gender; @ManyToOne @@ -138,87 +138,87 @@ public class Client extends AbstractAuditableWithUTCDateTimeCustom { private boolean accountNumberRequiresAutoGeneration = false; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "closure_reason_cv_id", nullable = true) + @JoinColumn(name = "closure_reason_cv_id") private CodeValue closureReason; - @Column(name = "closedon_date", nullable = true) + @Column(name = "closedon_date") private LocalDate closureDate; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "reject_reason_cv_id", nullable = true) + @JoinColumn(name = "reject_reason_cv_id") private CodeValue rejectionReason; - @Column(name = "rejectedon_date", nullable = true) + @Column(name = "rejectedon_date") private LocalDate rejectionDate; @ManyToOne(optional = true, fetch = FetchType.LAZY) - @JoinColumn(name = "rejectedon_userid", nullable = true) + @JoinColumn(name = "rejectedon_userid") private AppUser rejectedBy; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "withdraw_reason_cv_id", nullable = true) + @JoinColumn(name = "withdraw_reason_cv_id") private CodeValue withdrawalReason; - @Column(name = "withdrawn_on_date", nullable = true) + @Column(name = "withdrawn_on_date") private LocalDate withdrawalDate; @ManyToOne(optional = true, fetch = FetchType.LAZY) - @JoinColumn(name = "withdraw_on_userid", nullable = true) + @JoinColumn(name = "withdraw_on_userid") private AppUser withdrawnBy; - @Column(name = "reactivated_on_date", nullable = true) + @Column(name = "reactivated_on_date") private LocalDate reactivateDate; @ManyToOne(optional = true, fetch = FetchType.LAZY) - @JoinColumn(name = "reactivated_on_userid", nullable = true) + @JoinColumn(name = "reactivated_on_userid") private AppUser reactivatedBy; @ManyToOne(optional = true, fetch = FetchType.LAZY) - @JoinColumn(name = "closedon_userid", nullable = true) + @JoinColumn(name = "closedon_userid") private AppUser closedBy; - @Column(name = "submittedon_date", nullable = true) + @Column(name = "submittedon_date") private LocalDate submittedOnDate; /* * Deprecated since common Auditable fields were introduced. Columns and data left untouched to help migration. * - * @Column(name = "updated_on", nullable = true) private LocalDate updatedOnDate; + * @Column(name = "updated_on") private LocalDate updatedOnDate; * * @ManyToOne(optional = true, fetch = FetchType.LAZY) * - * @JoinColumn(name = "updated_by", nullable = true) private AppUser updatedBy; + * @JoinColumn(name = "updated_by") private AppUser updatedBy; */ @ManyToOne(optional = true, fetch = FetchType.LAZY) - @JoinColumn(name = "activatedon_userid", nullable = true) + @JoinColumn(name = "activatedon_userid") private AppUser activatedBy; - @Column(name = "default_savings_product", nullable = true) + @Column(name = "default_savings_product") private Long savingsProductId; - @Column(name = "default_savings_account", nullable = true) + @Column(name = "default_savings_account") private Long savingsAccountId; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "client_type_cv_id", nullable = true) + @JoinColumn(name = "client_type_cv_id") private CodeValue clientType; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "client_classification_cv_id", nullable = true) + @JoinColumn(name = "client_classification_cv_id") private CodeValue clientClassification; - @Column(name = "legal_form_enum", nullable = true) + @Column(name = "legal_form_enum") private Integer legalForm; - @Column(name = "reopened_on_date", nullable = true) + @Column(name = "reopened_on_date") private LocalDate reopenedDate; @ManyToOne(optional = true, fetch = FetchType.LAZY) - @JoinColumn(name = "reopened_by_userid", nullable = true) + @JoinColumn(name = "reopened_by_userid") private AppUser reopenedBy; - @Column(name = "proposed_transfer_date", nullable = true) + @Column(name = "proposed_transfer_date") private LocalDate proposedTransferDate; @OneToMany(mappedBy = "client", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResource.java index 8e8a41236..dff3b9b19 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResource.java @@ -41,6 +41,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -52,14 +53,12 @@ import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSer import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.fund.data.FundData; import org.apache.fineract.portfolio.fund.service.FundReadPlatformService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @Path("/funds") @Component -@Scope("singleton") @Tag(name = "Funds", description = "") +@RequiredArgsConstructor public class FundsApiResource { /** @@ -75,17 +74,6 @@ public class FundsApiResource { private final ApiRequestParameterHelper apiRequestParameterHelper; private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; - @Autowired - public FundsApiResource(final PlatformSecurityContext context, final FundReadPlatformService readPlatformService, - final DefaultToApiJsonSerializer toApiJsonSerializer, final ApiRequestParameterHelper apiRequestParameterHelper, - final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) { - this.context = context; - this.readPlatformService = readPlatformService; - this.toApiJsonSerializer = toApiJsonSerializer; - this.apiRequestParameterHelper = apiRequestParameterHelper; - this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; - } - @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @@ -93,13 +81,10 @@ public class FundsApiResource { @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = FundsApiResourceSwagger.GetFundsResponse.class)))) }) public String retrieveFunds(@Context final UriInfo uriInfo) { - - this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); - - final Collection funds = this.readPlatformService.retrieveAllFunds(); - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, funds, RESPONSE_DATA_PARAMETERS); + context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); + final Collection funds = readPlatformService.retrieveAllFunds(); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, funds, RESPONSE_DATA_PARAMETERS); } @POST @@ -110,12 +95,9 @@ public class FundsApiResource { @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = FundsApiResourceSwagger.PostFundsResponse.class))) }) public String createFund(@Parameter(hidden = true) final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createFund().withJson(apiRequestBodyAsJson).build(); - - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } @GET @@ -126,14 +108,11 @@ public class FundsApiResource { + "funds/1") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = FundsApiResourceSwagger.GetFundsResponse.class))) }) - public String retreiveFund(@PathParam("fundId") @Parameter(description = "fundId") final Long fundId, @Context final UriInfo uriInfo) { - - this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); - - final FundData fund = this.readPlatformService.retrieveFund(fundId); - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, fund, RESPONSE_DATA_PARAMETERS); + public String retrieveFund(@PathParam("fundId") @Parameter(description = "fundId") final Long fundId, @Context final UriInfo uriInfo) { + context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); + final FundData fund = readPlatformService.retrieveFund(fundId); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, fund, RESPONSE_DATA_PARAMETERS); } @PUT @@ -146,11 +125,8 @@ public class FundsApiResource { @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = FundsApiResourceSwagger.PutFundsFundIdResponse.class))) }) public String updateFund(@PathParam("fundId") @Parameter(description = "fundId") final Long fundId, @Parameter(hidden = true) final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateFund(fundId).withJson(apiRequestBodyAsJson).build(); - - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java index a3b965d2b..873928014 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java @@ -49,6 +49,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -96,17 +97,15 @@ import org.apache.fineract.portfolio.savings.data.GSIMContainer; import org.apache.fineract.portfolio.savings.service.GSIMReadPlatformService; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @Path("/groups") @Component -@Scope("singleton") @Tag(name = "Groups", description = "Groups are used to provide a distinctive banking distribution channel used in microfinances throughout the world. The Group is an administrative unit. It can contain as few as 5 people or as many as 40 depending on how its used.\n" + "\n" + "Different styles of group lending - Joint-Liability Group, Grameen Model (Center-Group), Self-Help Groups, Village/Communal Banks)") +@RequiredArgsConstructor public class GroupsApiResource { private final PlatformSecurityContext context; @@ -132,50 +131,6 @@ public class GroupsApiResource { private final GLIMAccountInfoReadPlatformService glimAccountInfoReadPlatformService; private final GSIMReadPlatformService gsimReadPlatformService; - @Autowired - public GroupsApiResource(final PlatformSecurityContext context, final GroupReadPlatformService groupReadPlatformService, - final CenterReadPlatformService centerReadPlatformService, final ClientReadPlatformService clientReadPlatformService, - final ToApiJsonSerializer toApiJsonSerializer, - final ToApiJsonSerializer groupTopOfHierarchyApiJsonSerializer, - final ToApiJsonSerializer groupSummaryToApiJsonSerializer, - final ToApiJsonSerializer glimContainerToApiJsonSerializer, - final ToApiJsonSerializer gsimContainerToApiJsonSerializer, - final ApiRequestParameterHelper apiRequestParameterHelper, - final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, - final CollectionSheetReadPlatformService collectionSheetReadPlatformService, final FromJsonHelper fromJsonHelper, - final GroupRolesReadPlatformService groupRolesReadPlatformService, - final AccountDetailsReadPlatformService accountDetailsReadPlatformService, - final CalendarReadPlatformService calendarReadPlatformService, final MeetingReadPlatformService meetingReadPlatformService, - final EntityDatatableChecksReadService entityDatatableChecksReadService, - final BulkImportWorkbookService bulkImportWorkbookService, - final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService, - final GLIMAccountInfoReadPlatformService glimAccountInfoReadPlatformService, - final GSIMReadPlatformService gsimReadPlatformService) { - this.context = context; - this.groupReadPlatformService = groupReadPlatformService; - this.centerReadPlatformService = centerReadPlatformService; - this.clientReadPlatformService = clientReadPlatformService; - this.toApiJsonSerializer = toApiJsonSerializer; - this.groupGeneralApiJsonSerializer = groupTopOfHierarchyApiJsonSerializer; - this.groupSummaryToApiJsonSerializer = groupSummaryToApiJsonSerializer; - this.glimContainerToApiJsonSerializer = glimContainerToApiJsonSerializer; - this.gsimContainerToApiJsonSerializer = gsimContainerToApiJsonSerializer; - this.apiRequestParameterHelper = apiRequestParameterHelper; - this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; - this.collectionSheetReadPlatformService = collectionSheetReadPlatformService; - this.fromJsonHelper = fromJsonHelper; - this.groupRolesReadPlatformService = groupRolesReadPlatformService; - this.accountDetailsReadPlatformService = accountDetailsReadPlatformService; - this.calendarReadPlatformService = calendarReadPlatformService; - this.meetingReadPlatformService = meetingReadPlatformService; - this.entityDatatableChecksReadService = entityDatatableChecksReadService; - this.bulkImportWorkbookPopulatorService = bulkImportWorkbookPopulatorService; - this.bulkImportWorkbookService = bulkImportWorkbookService; - this.glimAccountInfoReadPlatformService = glimAccountInfoReadPlatformService; - this.gsimReadPlatformService = gsimReadPlatformService; - - } - @GET @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @@ -193,32 +148,31 @@ public class GroupsApiResource { @QueryParam("command") @Parameter(description = "command") final String commandParam, @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @Parameter(description = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { - this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME); + context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME); if (is(commandParam, "close")) { - final GroupGeneralData groupClosureTemplate = this.groupReadPlatformService.retrieveGroupWithClosureReasons(); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.groupGeneralApiJsonSerializer.serialize(settings, groupClosureTemplate, + final GroupGeneralData groupClosureTemplate = groupReadPlatformService.retrieveGroupWithClosureReasons(); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return groupGeneralApiJsonSerializer.serialize(settings, groupClosureTemplate, GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS); } - final List datatableTemplates = this.entityDatatableChecksReadService + final List datatableTemplates = entityDatatableChecksReadService .retrieveTemplates(StatusEnum.CREATE.getCode().longValue(), EntityTables.GROUP.getName(), null); if (centerId != null) { - final GroupGeneralData centerGroupTemplate = this.centerReadPlatformService.retrieveCenterGroupTemplate(centerId); + final GroupGeneralData centerGroupTemplate = centerReadPlatformService.retrieveCenterGroupTemplate(centerId); centerGroupTemplate.setDatatables(datatableTemplates); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.groupGeneralApiJsonSerializer.serialize(settings, centerGroupTemplate, + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return groupGeneralApiJsonSerializer.serialize(settings, centerGroupTemplate, GroupingTypesApiConstants.CENTER_GROUP_RESPONSE_DATA_PARAMETERS); } - final GroupGeneralData groupTemplate = this.groupReadPlatformService.retrieveTemplate(officeId, isCenterGroup, + final GroupGeneralData groupTemplate = groupReadPlatformService.retrieveTemplate(officeId, isCenterGroup, staffInSelectedOfficeOnly); groupTemplate.setDatatables(datatableTemplates); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.groupGeneralApiJsonSerializer.serialize(settings, groupTemplate, - GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return groupGeneralApiJsonSerializer.serialize(settings, groupTemplate, GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS); } @GET @@ -242,19 +196,19 @@ public class GroupsApiResource { @QueryParam("sortOrder") @Parameter(description = "sortOrder") final String sortOrder, @QueryParam("orphansOnly") @Parameter(description = "orphansOnly") final Boolean orphansOnly) { - this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME); + context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME); final PaginationParameters parameters = PaginationParameters.instance(paged, offset, limit, orderBy, sortOrder); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); final SearchParameters searchParameters = SearchParameters.forGroups(officeId, staffId, externalId, name, hierarchy, offset, limit, orderBy, sortOrder, orphansOnly); if (parameters.isPaged()) { - final Page groups = this.groupReadPlatformService.retrievePagedAll(searchParameters, parameters); - return this.toApiJsonSerializer.serialize(settings, groups, GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS); + final Page groups = groupReadPlatformService.retrievePagedAll(searchParameters, parameters); + return toApiJsonSerializer.serialize(settings, groups, GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS); } - final Collection groups = this.groupReadPlatformService.retrieveAll(searchParameters, parameters); - return this.toApiJsonSerializer.serialize(settings, groups, GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS); + final Collection groups = groupReadPlatformService.retrieveAll(searchParameters, parameters); + return toApiJsonSerializer.serialize(settings, groups, GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS); } @GET @@ -269,11 +223,11 @@ public class GroupsApiResource { @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @Parameter(description = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, @QueryParam("roleId") @Parameter(description = "roleId") final Long roleId) { - this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME); + context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME); final Set associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters()); - GroupGeneralData group = this.groupReadPlatformService.retrieveOne(groupId); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + GroupGeneralData group = groupReadPlatformService.retrieveOne(groupId); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); // associations Collection membersOfGroup = null; @@ -289,26 +243,26 @@ public class GroupsApiResource { Arrays.asList("clientMembers", "activeClientMembers", "groupRoles", "calendars", "collectionMeetingCalendar")); } if (associationParameters.contains("clientMembers")) { - membersOfGroup = this.clientReadPlatformService.retrieveClientMembersOfGroup(groupId); + membersOfGroup = clientReadPlatformService.retrieveClientMembersOfGroup(groupId); if (CollectionUtils.isEmpty(membersOfGroup)) { membersOfGroup = null; } } if (associationParameters.contains("activeClientMembers")) { - activeClientMembers = this.clientReadPlatformService.retrieveActiveClientMembersOfGroup(groupId); + activeClientMembers = clientReadPlatformService.retrieveActiveClientMembersOfGroup(groupId); if (CollectionUtils.isEmpty(activeClientMembers)) { activeClientMembers = null; } } if (associationParameters.contains("groupRoles")) { - groupRoles = this.groupRolesReadPlatformService.retrieveGroupRoles(groupId); + groupRoles = groupRolesReadPlatformService.retrieveGroupRoles(groupId); if (CollectionUtils.isEmpty(groupRoles)) { groupRoles = null; } } if (associationParameters.contains("parentCalendars")) { final List calendarTypeOptions = CalendarUtils.createIntegerListFromQueryParameter("all"); - calendars = this.calendarReadPlatformService.retrieveParentCalendarsByEntity(groupId, CalendarEntityType.GROUPS.getValue(), + calendars = calendarReadPlatformService.retrieveParentCalendarsByEntity(groupId, CalendarEntityType.GROUPS.getValue(), calendarTypeOptions); if (CollectionUtils.isEmpty(calendars)) { calendars = null; @@ -316,22 +270,22 @@ public class GroupsApiResource { } if (associationParameters.contains("collectionMeetingCalendar")) { if (group.isChildGroup()) { - collectionMeetingCalendar = this.calendarReadPlatformService.retrieveCollctionCalendarByEntity(group.getParentId(), + collectionMeetingCalendar = calendarReadPlatformService.retrieveCollctionCalendarByEntity(group.getParentId(), CalendarEntityType.CENTERS.getValue()); } else { - collectionMeetingCalendar = this.calendarReadPlatformService.retrieveCollctionCalendarByEntity(groupId, + collectionMeetingCalendar = calendarReadPlatformService.retrieveCollctionCalendarByEntity(groupId, CalendarEntityType.GROUPS.getValue()); } if (collectionMeetingCalendar != null) { final boolean withHistory = true; final LocalDate tillDate = null; - final Collection recurringDates = this.calendarReadPlatformService + final Collection recurringDates = calendarReadPlatformService .generateRecurringDates(collectionMeetingCalendar, withHistory, tillDate); - final Collection nextTenRecurringDates = this.calendarReadPlatformService + final Collection nextTenRecurringDates = calendarReadPlatformService .generateNextTenRecurringDates(collectionMeetingCalendar); - final MeetingData lastMeeting = this.meetingReadPlatformService + final MeetingData lastMeeting = meetingReadPlatformService .retrieveLastMeeting(collectionMeetingCalendar.getCalendarInstanceId()); - final LocalDate recentEligibleMeetingDate = this.calendarReadPlatformService + final LocalDate recentEligibleMeetingDate = calendarReadPlatformService .generateNextEligibleMeetingDateForCollection(collectionMeetingCalendar, lastMeeting); collectionMeetingCalendar = CalendarData.withRecurringDates(collectionMeetingCalendar, recurringDates, nextTenRecurringDates, recentEligibleMeetingDate); @@ -343,7 +297,7 @@ public class GroupsApiResource { } if (roleId != null) { - selectedRole = this.groupRolesReadPlatformService.retrieveGroupRole(groupId, roleId); + selectedRole = groupRolesReadPlatformService.retrieveGroupRole(groupId, roleId); if (selectedRole != null) { group = GroupGeneralData.updateSelectedRole(group, selectedRole); } @@ -351,12 +305,12 @@ public class GroupsApiResource { final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters()); if (template) { - final GroupGeneralData templateGroup = this.groupReadPlatformService.retrieveTemplate(group.officeId(), false, + final GroupGeneralData templateGroup = groupReadPlatformService.retrieveTemplate(group.officeId(), false, staffInSelectedOfficeOnly); group = GroupGeneralData.withTemplate(templateGroup, group); } - return this.groupGeneralApiJsonSerializer.serialize(settings, group, GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS); + return groupGeneralApiJsonSerializer.serialize(settings, group, GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS); } @POST @@ -374,8 +328,8 @@ public class GroupsApiResource { .createGroup() // .withJson(apiRequestBodyAsJson) // .build(); // - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } @POST @@ -393,8 +347,8 @@ public class GroupsApiResource { .unassignGroupStaff(groupId) // .withJson(apiRequestBodyAsJson) // .build(); // - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } @@ -413,8 +367,8 @@ public class GroupsApiResource { .updateGroup(groupId) // .withJson(apiRequestBodyAsJson) // .build(); // - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } @DELETE @@ -429,8 +383,8 @@ public class GroupsApiResource { final CommandWrapper commandRequest = new CommandWrapperBuilder() // .deleteGroup(groupId) // .build(); // - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } @POST @@ -480,55 +434,54 @@ public class GroupsApiResource { CommandProcessingResult result = null; if (is(commandParam, "activate")) { final CommandWrapper commandRequest = builder.activateGroup(groupId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "associateClients")) { final CommandWrapper commandRequest = builder.associateClientsToGroup(groupId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "disassociateClients")) { final CommandWrapper commandRequest = builder.disassociateClientsFromGroup(groupId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "generateCollectionSheet")) { - final JsonElement parsedQuery = this.fromJsonHelper.parse(apiRequestBodyAsJson); - final JsonQuery query = JsonQuery.from(apiRequestBodyAsJson, parsedQuery, this.fromJsonHelper); - final JLGCollectionSheetData collectionSheet = this.collectionSheetReadPlatformService.generateGroupCollectionSheet(groupId, - query); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, collectionSheet, GroupingTypesApiConstants.COLLECTIONSHEET_DATA_PARAMETERS); + final JsonElement parsedQuery = fromJsonHelper.parse(apiRequestBodyAsJson); + final JsonQuery query = JsonQuery.from(apiRequestBodyAsJson, parsedQuery, fromJsonHelper); + final JLGCollectionSheetData collectionSheet = collectionSheetReadPlatformService.generateGroupCollectionSheet(groupId, query); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, collectionSheet, GroupingTypesApiConstants.COLLECTIONSHEET_DATA_PARAMETERS); } else if (is(commandParam, "saveCollectionSheet")) { final CommandWrapper commandRequest = builder.saveGroupCollectionSheet(groupId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "unassignStaff")) { final CommandWrapper commandRequest = builder.unassignGroupStaff(groupId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "assignStaff")) { final CommandWrapper commandRequest = builder.assignGroupStaff(groupId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "assignRole")) { final CommandWrapper commandRequest = builder.assignRole(groupId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "unassignRole")) { final CommandWrapper commandRequest = builder.unassignRole(groupId, roleId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "updateRole")) { final CommandWrapper commandRequest = builder.updateRole(groupId, roleId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "transferClients")) { final CommandWrapper commandRequest = builder.transferClientsBetweenGroups(groupId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "close")) { final CommandWrapper commandRequest = builder.closeGroup(groupId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else { throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "activate", "generateCollectionSheet", "saveCollectionSheet", "unassignStaff", "assignRole", "unassignRole", "updateassignRole" }); @@ -552,15 +505,15 @@ public class GroupsApiResource { public String retrieveAccounts(@PathParam("groupId") @Parameter(description = "groupId") final Long groupId, @Context final UriInfo uriInfo) { - this.context.authenticatedUser().validateHasReadPermission("GROUP"); + context.authenticatedUser().validateHasReadPermission("GROUP"); - final AccountSummaryCollectionData groupAccount = this.accountDetailsReadPlatformService.retrieveGroupAccountDetails(groupId); + final AccountSummaryCollectionData groupAccount = accountDetailsReadPlatformService.retrieveGroupAccountDetails(groupId); final Set GROUP_ACCOUNTS_DATA_PARAMETERS = new HashSet<>(Arrays.asList("loanAccounts", "groupLoanIndividualMonitoringAccounts", "savingsAccounts", "memberLoanAccounts", "memberSavingsAccounts")); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.groupSummaryToApiJsonSerializer.serialize(settings, groupAccount, GROUP_ACCOUNTS_DATA_PARAMETERS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return groupSummaryToApiJsonSerializer.serialize(settings, groupAccount, GROUP_ACCOUNTS_DATA_PARAMETERS); } @GET @@ -579,9 +532,9 @@ public class GroupsApiResource { public String postGroupTemplate(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("locale") final String locale, @FormDataParam("dateFormat") final String dateFormat) { - final Long importDocumentId = this.bulkImportWorkbookService.importWorkbook(GlobalEntityType.GROUPS.toString(), uploadedInputStream, + final Long importDocumentId = bulkImportWorkbookService.importWorkbook(GlobalEntityType.GROUPS.toString(), uploadedInputStream, fileDetail, locale, dateFormat); - return this.toApiJsonSerializer.serialize(importDocumentId); + return toApiJsonSerializer.serialize(importDocumentId); } @GET @@ -590,7 +543,7 @@ public class GroupsApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String retrieveglimAccounts(@PathParam("groupId") final Long groupId, @QueryParam("parentLoanAccountNo") final String parentLoanAccountNo, @Context final UriInfo uriInfo) { - this.context.authenticatedUser().validateHasReadPermission("GROUP"); + context.authenticatedUser().validateHasReadPermission("GROUP"); List glimContainer = Collections.emptyList(); if (parentLoanAccountNo == null) { glimContainer = (List) glimAccountInfoReadPlatformService.findGlimAccount(groupId); @@ -602,8 +555,8 @@ public class GroupsApiResource { final Set GLIM_ACCOUNTS_DATA_PARAMETERS = new HashSet<>( Arrays.asList("groupId", "accountNumber", "childGLIMAccounts", "memberLoanAccounts", "parentPrincipalAmount")); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.glimContainerToApiJsonSerializer.serialize(settings, glimContainer, GLIM_ACCOUNTS_DATA_PARAMETERS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return glimContainerToApiJsonSerializer.serialize(settings, glimContainer, GLIM_ACCOUNTS_DATA_PARAMETERS); } @@ -615,23 +568,22 @@ public class GroupsApiResource { @QueryParam("parentGSIMAccountNo") final String parentGSIMAccountNo, @QueryParam("parentGSIMId") final Long parentGSIMId, @Context final UriInfo uriInfo) { List gsimContainer; - this.context.authenticatedUser().validateHasReadPermission("GROUP"); + context.authenticatedUser().validateHasReadPermission("GROUP"); if (parentGSIMAccountNo == null && parentGSIMId != null) { - gsimContainer = this.gsimReadPlatformService.findGsimAccountContainerbyGsimAccountId(parentGSIMId); + gsimContainer = gsimReadPlatformService.findGsimAccountContainerbyGsimAccountId(parentGSIMId); } else if (parentGSIMAccountNo != null && parentGSIMId == null) { - gsimContainer = (List) this.gsimReadPlatformService - .findGsimAccountContainerbyGsimAccountNumber(parentGSIMAccountNo); + gsimContainer = (List) gsimReadPlatformService.findGsimAccountContainerbyGsimAccountNumber(parentGSIMAccountNo); } else { - gsimContainer = (List) this.gsimReadPlatformService.findGSIMAccountContainerByGroupId(groupId); + gsimContainer = (List) gsimReadPlatformService.findGSIMAccountContainerByGroupId(groupId); } final Set GSIM_ACCOUNTS_DATA_PARAMETERS = new HashSet<>( Arrays.asList("gsimId", "groupId", "accountNumber", "childGSIMAccounts", "parentBalance", "savingsStatus")); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.gsimContainerToApiJsonSerializer.serialize(settings, gsimContainer, GSIM_ACCOUNTS_DATA_PARAMETERS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return gsimContainerToApiJsonSerializer.serialize(settings, gsimContainer, GSIM_ACCOUNTS_DATA_PARAMETERS); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResource.java index 2778b3302..ccd158429 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResource.java @@ -65,12 +65,10 @@ import org.apache.fineract.portfolio.loanaccount.data.LoanInstallmentChargeData; import org.apache.fineract.portfolio.loanaccount.exception.LoanNotFoundException; import org.apache.fineract.portfolio.loanaccount.service.LoanChargeReadPlatformService; import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @Path("/loans") @Component -@Scope("singleton") @Tag(name = "Loan Charges", description = "Its typical for MFIs to add extra costs for their loan products. They can be either Fees or Penalties.\n" + "\n" + "Loan Charges are instances of Charges and represent either fees and penalties for loan products. Refer Charges for documentation of the various properties of a charge, Only additional properties ( specific to the context of a Charge being associated with a Loan) are described here") diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java index 7c3da1a92..691d6c799 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java @@ -68,13 +68,11 @@ import org.apache.fineract.portfolio.loanaccount.service.LoanChargePaidByReadPla import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @Path("/loans") @Component @AllArgsConstructor -@Scope("singleton") @Tag(name = "Loan Transactions", description = "Capabilities include loan repayment's, interest waivers and the ability to 'adjust' an existing transaction. An 'adjustment' of a transaction is really a 'reversal' of existing transaction followed by creation of a new transaction with the provided details.") public class LoanTransactionsApiResource { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java index ad4148635..a168fe814 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java @@ -151,13 +151,11 @@ import org.apache.fineract.portfolio.savings.DepositAccountType; import org.apache.fineract.portfolio.savings.domain.SavingsAccountStatusType; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @Path("/loans") @Component -@Scope("singleton") @Tag(name = "Loans", description = "The API concept of loans models the loan application process and the loan contract/monitoring process.\n" + "\n" + "Field Descriptions\n" + "accountNo\n" + "The account no. associated with this loan. Is auto generated if not provided at loan application creation time.\n" diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java index a49e51f67..babae83b8 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java @@ -44,6 +44,7 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService; import org.apache.fineract.accounting.glaccount.data.GLAccountData; import org.apache.fineract.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper; @@ -83,14 +84,12 @@ import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.apache.fineract.portfolio.rate.data.RateData; import org.apache.fineract.portfolio.rate.service.RateReadService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @Path("/loanproducts") @Component -@Scope("singleton") @Tag(name = "Loan Products", description = "A Loan product is a template that is used when creating a loan. Much of the template definition can be overridden during loan creation.") +@RequiredArgsConstructor public class LoanProductsApiResource { private static final Set LOAN_PRODUCT_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "name", "shortName", "description", @@ -136,43 +135,6 @@ public class LoanProductsApiResource { private final ConfigurationDomainService configurationDomainService; private final DelinquencyReadPlatformService delinquencyReadPlatformService; - @Autowired - public LoanProductsApiResource(final PlatformSecurityContext context, final LoanProductReadPlatformService readPlatformService, - final ChargeReadPlatformService chargeReadPlatformService, final CurrencyReadPlatformService currencyReadPlatformService, - final FundReadPlatformService fundReadPlatformService, final LoanDropdownReadPlatformService dropdownReadPlatformService, - final DefaultToApiJsonSerializer toApiJsonSerializer, - final ApiRequestParameterHelper apiRequestParameterHelper, - final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, - final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService, - final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService, - final DefaultToApiJsonSerializer productMixDataApiJsonSerializer, - final ProductMixReadPlatformService productMixReadPlatformService, - final DropdownReadPlatformService commonDropdownReadPlatformService, - PaymentTypeReadPlatformService paymentTypeReadPlatformService, - final FloatingRatesReadPlatformService floatingRateReadPlatformService, final RateReadService rateReadService, - final ConfigurationDomainService configurationDomainService, - final DelinquencyReadPlatformService delinquencyReadPlatformService) { - this.context = context; - this.loanProductReadPlatformService = readPlatformService; - this.chargeReadPlatformService = chargeReadPlatformService; - this.currencyReadPlatformService = currencyReadPlatformService; - this.fundReadPlatformService = fundReadPlatformService; - this.dropdownReadPlatformService = dropdownReadPlatformService; - this.toApiJsonSerializer = toApiJsonSerializer; - this.apiRequestParameterHelper = apiRequestParameterHelper; - this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; - this.accountMappingReadPlatformService = accountMappingReadPlatformService; - this.accountingDropdownReadPlatformService = accountingDropdownReadPlatformService; - this.productMixDataApiJsonSerializer = productMixDataApiJsonSerializer; - this.productMixReadPlatformService = productMixReadPlatformService; - this.commonDropdownReadPlatformService = commonDropdownReadPlatformService; - this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; - this.floatingRateReadPlatformService = floatingRateReadPlatformService; - this.rateReadService = rateReadService; - this.configurationDomainService = configurationDomainService; - this.delinquencyReadPlatformService = delinquencyReadPlatformService; - } - @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResource.java index b2f4f7dea..f292d8398 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResource.java @@ -45,6 +45,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -71,15 +72,13 @@ import org.apache.fineract.portfolio.savings.service.SavingsAccountChargeReadPla import org.apache.fineract.portfolio.savings.service.SavingsAccountReadPlatformService; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @Path("/savingsaccounts") @Component -@Scope("singleton") @Tag(name = "Savings Account", description = "Savings accounts are instances of a particular savings product created for an individual or group. An application process around the creation of accounts is also supported.") +@RequiredArgsConstructor public class SavingsAccountsApiResource { private final SavingsAccountReadPlatformService savingsAccountReadPlatformService; @@ -91,24 +90,6 @@ public class SavingsAccountsApiResource { private final BulkImportWorkbookService bulkImportWorkbookService; private final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService; - @Autowired - public SavingsAccountsApiResource(final SavingsAccountReadPlatformService savingsAccountReadPlatformService, - final PlatformSecurityContext context, final DefaultToApiJsonSerializer toApiJsonSerializer, - final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, - final ApiRequestParameterHelper apiRequestParameterHelper, - final SavingsAccountChargeReadPlatformService savingsAccountChargeReadPlatformService, - final BulkImportWorkbookService bulkImportWorkbookService, - final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService) { - this.savingsAccountReadPlatformService = savingsAccountReadPlatformService; - this.context = context; - this.toApiJsonSerializer = toApiJsonSerializer; - this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; - this.apiRequestParameterHelper = apiRequestParameterHelper; - this.savingsAccountChargeReadPlatformService = savingsAccountChargeReadPlatformService; - this.bulkImportWorkbookService = bulkImportWorkbookService; - this.bulkImportWorkbookPopulatorService = bulkImportWorkbookPopulatorService; - } - @GET @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @@ -124,14 +105,13 @@ public class SavingsAccountsApiResource { @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @Parameter(description = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, @Context final UriInfo uriInfo) { - this.context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME); + context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME); - final SavingsAccountData savingsAccount = this.savingsAccountReadPlatformService.retrieveTemplate(clientId, groupId, productId, + final SavingsAccountData savingsAccount = savingsAccountReadPlatformService.retrieveTemplate(clientId, groupId, productId, staffInSelectedOfficeOnly); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, savingsAccount, - SavingsApiSetConstants.SAVINGS_ACCOUNT_RESPONSE_DATA_PARAMETERS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, savingsAccount, SavingsApiSetConstants.SAVINGS_ACCOUNT_RESPONSE_DATA_PARAMETERS); } @GET @@ -150,14 +130,14 @@ public class SavingsAccountsApiResource { @QueryParam("orderBy") @Parameter(description = "orderBy") final String orderBy, @QueryParam("sortOrder") @Parameter(description = "sortOrder") final String sortOrder) { - this.context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME); + context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME); final SearchParameters searchParameters = SearchParameters.forSavings(sqlSearch, externalId, offset, limit, orderBy, sortOrder); - final Page products = this.savingsAccountReadPlatformService.retrieveAll(searchParameters); + final Page products = savingsAccountReadPlatformService.retrieveAll(searchParameters); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, products, SavingsApiSetConstants.SAVINGS_ACCOUNT_RESPONSE_DATA_PARAMETERS); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, products, SavingsApiSetConstants.SAVINGS_ACCOUNT_RESPONSE_DATA_PARAMETERS); } @POST @@ -175,9 +155,9 @@ public class SavingsAccountsApiResource { final CommandWrapper commandRequest = new CommandWrapperBuilder().createSavingsAccount().withJson(apiRequestBodyAsJson).build(); - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + return toApiJsonSerializer.serialize(result); } @POST @@ -188,9 +168,9 @@ public class SavingsAccountsApiResource { final CommandWrapper commandRequest = new CommandWrapperBuilder().createGSIMAccount().withJson(apiRequestBodyAsJson).build(); - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + return toApiJsonSerializer.serialize(result); } @GET @@ -206,21 +186,21 @@ public class SavingsAccountsApiResource { @DefaultValue("all") @QueryParam("chargeStatus") @Parameter(description = "chargeStatus") final String chargeStatus, @Context final UriInfo uriInfo) { - this.context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME); + context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME); if (!(is(chargeStatus, "all") || is(chargeStatus, "active") || is(chargeStatus, "inactive"))) { throw new UnrecognizedQueryParamException("status", chargeStatus, new Object[] { "all", "active", "inactive" }); } - final SavingsAccountData savingsAccount = this.savingsAccountReadPlatformService.retrieveOne(accountId); + final SavingsAccountData savingsAccount = savingsAccountReadPlatformService.retrieveOne(accountId); final Set mandatoryResponseParameters = new HashSet<>(); final SavingsAccountData savingsAccountTemplate = populateTemplateAndAssociations(accountId, savingsAccount, staffInSelectedOfficeOnly, chargeStatus, uriInfo, mandatoryResponseParameters); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters(), + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters(), mandatoryResponseParameters); - return this.toApiJsonSerializer.serialize(settings, savingsAccountTemplate, + return toApiJsonSerializer.serialize(settings, savingsAccountTemplate, SavingsApiSetConstants.SAVINGS_ACCOUNT_RESPONSE_DATA_PARAMETERS); } @@ -240,7 +220,7 @@ public class SavingsAccountsApiResource { if (associationParameters.contains(SavingsApiConstants.transactions)) { mandatoryResponseParameters.add(SavingsApiConstants.transactions); - final Collection currentTransactions = this.savingsAccountReadPlatformService + final Collection currentTransactions = savingsAccountReadPlatformService .retrieveAllTransactions(accountId, DepositAccountType.SAVINGS_DEPOSIT); if (!CollectionUtils.isEmpty(currentTransactions)) { transactions = currentTransactions; @@ -249,7 +229,7 @@ public class SavingsAccountsApiResource { if (associationParameters.contains(SavingsApiConstants.charges)) { mandatoryResponseParameters.add(SavingsApiConstants.charges); - final Collection currentCharges = this.savingsAccountChargeReadPlatformService + final Collection currentCharges = savingsAccountChargeReadPlatformService .retrieveSavingsAccountCharges(accountId, chargeStatus); if (!CollectionUtils.isEmpty(currentCharges)) { charges = currentCharges; @@ -258,10 +238,10 @@ public class SavingsAccountsApiResource { } SavingsAccountData templateData = null; - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); if (settings.isTemplate()) { - templateData = this.savingsAccountReadPlatformService.retrieveTemplate(savingsAccount.getClientId(), - savingsAccount.getGroupId(), savingsAccount.getSavingsProductId(), staffInSelectedOfficeOnly); + templateData = savingsAccountReadPlatformService.retrieveTemplate(savingsAccount.getClientId(), savingsAccount.getGroupId(), + savingsAccount.getSavingsProductId(), staffInSelectedOfficeOnly); } return SavingsAccountData.withTemplateOptions(savingsAccount, templateData, transactions, charges); @@ -286,43 +266,29 @@ public class SavingsAccountsApiResource { if (is(commandParam, "updateWithHoldTax")) { final CommandWrapper commandRequest = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson).updateWithHoldTax(accountId) .build(); - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } final CommandWrapper commandRequest = new CommandWrapperBuilder().updateSavingsAccount(accountId).withJson(apiRequestBodyAsJson) .build(); - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + return toApiJsonSerializer.serialize(result); } @PUT @Path("/gsim/{parentAccountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - /* - * public String updateGsim(@PathParam("parentAccountId") final Long parentAccountId, final String - * apiRequestBodyAsJson, - * - * @QueryParam("command") final String commandParam) { - */ public String updateGsim(@PathParam("parentAccountId") final Long parentAccountId, final String apiRequestBodyAsJson) { - - /* - * if (is(commandParam, "updateWithHoldTax")) { final CommandWrapper commandRequest = new - * CommandWrapperBuilder().withJson(apiRequestBodyAsJson). updateWithHoldTax(accountId) .build(); final - * CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource( commandRequest); - * return this.toApiJsonSerializer.serialize(result); } - */ - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateGSIMAccount(parentAccountId).withJson(apiRequestBodyAsJson) .build(); - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + return toApiJsonSerializer.serialize(result); } @POST @@ -342,31 +308,31 @@ public class SavingsAccountsApiResource { CommandProcessingResult result = null; if (is(commandParam, "reject")) { final CommandWrapper commandRequest = builder.rejectGSIMAccountApplication(parentAccountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "withdrawnByApplicant")) { final CommandWrapper commandRequest = builder.withdrawSavingsAccountApplication(parentAccountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "approve")) { final CommandWrapper commandRequest = builder.approveGSIMAccountApplication(parentAccountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "undoapproval")) { final CommandWrapper commandRequest = builder.undoGSIMApplicationApproval(parentAccountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "activate")) { final CommandWrapper commandRequest = builder.gsimAccountActivation(parentAccountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "calculateInterest")) { final CommandWrapper commandRequest = builder.withNoJsonBody().savingsAccountInterestCalculation(parentAccountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "postInterest")) { final CommandWrapper commandRequest = builder.savingsAccountInterestPosting(parentAccountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "applyAnnualFees")) { final CommandWrapper commandRequest = builder.savingsAccountApplyAnnualFees(parentAccountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "close")) { final CommandWrapper commandRequest = builder.closeGSIMApplication(parentAccountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } if (result == null) { throw new UnrecognizedQueryParamException("command", commandParam, @@ -377,7 +343,7 @@ public class SavingsAccountsApiResource { SavingsApiConstants.COMMAND_BLOCK_ACCOUNT, SavingsApiConstants.COMMAND_UNBLOCK_ACCOUNT }); } - return this.toApiJsonSerializer.serialize(result); + return toApiJsonSerializer.serialize(result); } @POST @@ -433,57 +399,57 @@ public class SavingsAccountsApiResource { CommandProcessingResult result = null; if (is(commandParam, "reject")) { final CommandWrapper commandRequest = builder.rejectSavingsAccountApplication(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "withdrawnByApplicant")) { final CommandWrapper commandRequest = builder.withdrawSavingsAccountApplication(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "approve")) { final CommandWrapper commandRequest = builder.approveSavingsAccountApplication(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "undoapproval")) { final CommandWrapper commandRequest = builder.undoSavingsAccountApplication(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "activate")) { final CommandWrapper commandRequest = builder.savingsAccountActivation(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "calculateInterest")) { final CommandWrapper commandRequest = builder.withNoJsonBody().savingsAccountInterestCalculation(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "postInterest")) { final CommandWrapper commandRequest = builder.savingsAccountInterestPosting(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "applyAnnualFees")) { final CommandWrapper commandRequest = builder.savingsAccountApplyAnnualFees(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "close")) { final CommandWrapper commandRequest = builder.closeSavingsAccountApplication(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "assignSavingsOfficer")) { final CommandWrapper commandRequest = builder.assignSavingsOfficer(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, "unassignSavingsOfficer")) { final CommandWrapper commandRequest = builder.unassignSavingsOfficer(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); + return toApiJsonSerializer.serialize(result); } else if (is(commandParam, SavingsApiConstants.COMMAND_BLOCK_DEBIT)) { final CommandWrapper commandRequest = builder.blockDebitsFromSavingsAccount(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, SavingsApiConstants.COMMAND_UNBLOCK_DEBIT)) { final CommandWrapper commandRequest = builder.unblockDebitsFromSavingsAccount(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, SavingsApiConstants.COMMAND_BLOCK_CREDIT)) { final CommandWrapper commandRequest = builder.blockCreditsToSavingsAccount(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, SavingsApiConstants.COMMAND_UNBLOCK_CREDIT)) { final CommandWrapper commandRequest = builder.unblockCreditsToSavingsAccount(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, SavingsApiConstants.COMMAND_BLOCK_ACCOUNT)) { final CommandWrapper commandRequest = builder.blockSavingsAccount(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, SavingsApiConstants.COMMAND_UNBLOCK_ACCOUNT)) { final CommandWrapper commandRequest = builder.unblockSavingsAccount(accountId).build(); - result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + result = commandsSourceWritePlatformService.logCommandSource(commandRequest); } if (result == null) { @@ -496,7 +462,7 @@ public class SavingsAccountsApiResource { SavingsApiConstants.COMMAND_BLOCK_ACCOUNT, SavingsApiConstants.COMMAND_UNBLOCK_ACCOUNT }); } - return this.toApiJsonSerializer.serialize(result); + return toApiJsonSerializer.serialize(result); } private boolean is(final String commandParam, final String commandValue) { @@ -514,9 +480,9 @@ public class SavingsAccountsApiResource { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteSavingsAccount(accountId).build(); - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + final CommandProcessingResult result = commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + return toApiJsonSerializer.serialize(result); } @GET @@ -535,9 +501,9 @@ public class SavingsAccountsApiResource { public String postSavingsTemplate(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("locale") final String locale, @FormDataParam("dateFormat") final String dateFormat) { - final Long importDocumentId = this.bulkImportWorkbookService.importWorkbook(GlobalEntityType.SAVINGS_ACCOUNT.toString(), + final Long importDocumentId = bulkImportWorkbookService.importWorkbook(GlobalEntityType.SAVINGS_ACCOUNT.toString(), uploadedInputStream, fileDetail, locale, dateFormat); - return this.toApiJsonSerializer.serialize(importDocumentId); + return toApiJsonSerializer.serialize(importDocumentId); } @GET @@ -556,8 +522,8 @@ public class SavingsAccountsApiResource { public String postSavingsTransactionTemplate(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("locale") final String locale, @FormDataParam("dateFormat") final String dateFormat) { - final Long importDocumentId = this.bulkImportWorkbookService.importWorkbook(GlobalEntityType.SAVINGS_TRANSACTIONS.toString(), + final Long importDocumentId = bulkImportWorkbookService.importWorkbook(GlobalEntityType.SAVINGS_TRANSACTIONS.toString(), uploadedInputStream, fileDetail, locale, dateFormat); - return this.toApiJsonSerializer.serialize(importDocumentId); + return toApiJsonSerializer.serialize(importDocumentId); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/shareaccounts/api/SelfShareAccountsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/shareaccounts/api/SelfShareAccountsApiResource.java index 99ada8b57..ddf12917f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/shareaccounts/api/SelfShareAccountsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/shareaccounts/api/SelfShareAccountsApiResource.java @@ -40,6 +40,7 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; +import lombok.RequiredArgsConstructor; import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; @@ -59,22 +60,18 @@ import org.apache.fineract.portfolio.self.shareaccounts.service.AppUserShareAcco import org.apache.fineract.portfolio.shareaccounts.data.ShareAccountData; import org.apache.fineract.portfolio.shareaccounts.service.ShareAccountReadPlatformService; import org.apache.fineract.useradministration.domain.AppUser; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @Path("/self/shareaccounts") @Component -@Scope("singleton") - @Tag(name = "Self Share Accounts", description = "") +@RequiredArgsConstructor public class SelfShareAccountsApiResource { private final PlatformSecurityContext context; private final AccountsApiResource accountsApiResource; private final ShareAccountReadPlatformService readPlatformService; private final ApiRequestParameterHelper apiRequestParameterHelper; - private final DefaultToApiJsonSerializer toApiJsonSerializer; private final AppuserClientMapperReadService appuserClientMapperReadService; private final SelfShareAccountsDataValidator selfShareAccountsDataValidator; @@ -82,26 +79,6 @@ public class SelfShareAccountsApiResource { private final ChargeReadPlatformService chargeReadPlatformService; private final AppUserShareAccountsMapperReadPlatformService appUserShareAccountsMapperReadPlatformService; - @Autowired - public SelfShareAccountsApiResource(final PlatformSecurityContext context, final AccountsApiResource accountsApiResource, - final ShareAccountReadPlatformService readPlatformService, final DefaultToApiJsonSerializer toApiJsonSerializer, - final ApiRequestParameterHelper apiRequestParameterHelper, final AppuserClientMapperReadService appuserClientMapperReadService, - final SelfShareAccountsDataValidator selfShareAccountsDataValidator, - final ShareProductReadPlatformService shareProductReadPlatformService, - final ChargeReadPlatformService chargeReadPlatformService, - final AppUserShareAccountsMapperReadPlatformService appUserShareAccountsMapperReadPlatformService) { - this.context = context; - this.accountsApiResource = accountsApiResource; - this.readPlatformService = readPlatformService; - this.toApiJsonSerializer = toApiJsonSerializer; - this.apiRequestParameterHelper = apiRequestParameterHelper; - this.selfShareAccountsDataValidator = selfShareAccountsDataValidator; - this.appuserClientMapperReadService = appuserClientMapperReadService; - this.shareProductReadPlatformService = shareProductReadPlatformService; - this.chargeReadPlatformService = chargeReadPlatformService; - this.appUserShareAccountsMapperReadPlatformService = appUserShareAccountsMapperReadPlatformService; - } - @GET @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @@ -128,10 +105,10 @@ public class SelfShareAccountsApiResource { String clientName = null; - final Collection chargeOptions = this.chargeReadPlatformService.retrieveSharesApplicableCharges(); + final Collection chargeOptions = chargeReadPlatformService.retrieveSharesApplicableCharges(); final ShareAccountData accountData = new ShareAccountData(clientId, clientName, productOptions, chargeOptions); - return this.toApiJsonSerializer.serialize(accountData); + return toApiJsonSerializer.serialize(accountData); } @@ -145,11 +122,11 @@ public class SelfShareAccountsApiResource { @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = SelfShareAccountsApiResourceSwagger.PostNewShareApplicationResponse.class)))) }) public String createAccount(final String apiRequestBodyAsJson) { - HashMap attr = this.selfShareAccountsDataValidator.validateShareAccountApplication(apiRequestBodyAsJson); + HashMap attr = selfShareAccountsDataValidator.validateShareAccountApplication(apiRequestBodyAsJson); final Long clientId = (Long) attr.get(ShareAccountApiConstants.clientid_paramname); validateAppuserClientsMapping(clientId); String accountType = ShareAccountApiConstants.shareEntityType; - return this.accountsApiResource.createAccount(accountType, apiRequestBodyAsJson); + return accountsApiResource.createAccount(accountType, apiRequestBodyAsJson); } @GET @@ -158,32 +135,25 @@ public class SelfShareAccountsApiResource { @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Retrieve a share application/account", description = "\n" + "\n" + "\n" + "Example Requests:\n" + "\n" + "self/shareaccounts/12\n") - // TODO actually write - // SelfShareAccountsApiResourceSwagger.GetShareAccountResponse (it currently - // does not exist) - // @ApiResponses({@ApiResponse(responseCode = "200", description = "OK", - // responseContainer - // = "List", schema = @Schema(implementation = - // SelfShareAccountsApiResourceSwagger.GetShareAccountResponse.class)}) public String retrieveShareAccount(@PathParam("accountId") final Long accountId, @Context final UriInfo uriInfo) { validateAppuserShareAccountMapping(accountId); final boolean includeTemplate = false; - AccountData accountData = this.readPlatformService.retrieveOne(accountId, includeTemplate); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, accountData, readPlatformService.getResponseDataParams()); + AccountData accountData = readPlatformService.retrieveOne(accountId, includeTemplate); + final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return toApiJsonSerializer.serialize(settings, accountData, readPlatformService.getResponseDataParams()); } private void validateAppuserShareAccountMapping(final Long accountId) { - AppUser user = this.context.authenticatedUser(); - final boolean isMapped = this.appUserShareAccountsMapperReadPlatformService.isShareAccountsMappedToUser(accountId, user.getId()); + AppUser user = context.authenticatedUser(); + final boolean isMapped = appUserShareAccountsMapperReadPlatformService.isShareAccountsMappedToUser(accountId, user.getId()); if (!isMapped) { throw new ShareAccountNotFoundException(accountId); } } private void validateAppuserClientsMapping(final Long clientId) { - AppUser user = this.context.authenticatedUser(); - final boolean mappedClientId = this.appuserClientMapperReadService.isClientMappedToUser(clientId, user.getId()); + AppUser user = context.authenticatedUser(); + final boolean mappedClientId = appuserClientMapperReadService.isClientMappedToUser(clientId, user.getId()); if (!mappedClientId) { throw new ClientNotFoundException(clientId); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/domain/ShareAccount.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/domain/ShareAccount.java index 28932aeb9..9ecf7c616 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/domain/ShareAccount.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/domain/ShareAccount.java @@ -49,11 +49,11 @@ import org.apache.fineract.useradministration.domain.AppUser; public class ShareAccount extends AbstractPersistableCustom { @ManyToOne - @JoinColumn(name = "client_id", nullable = true) + @JoinColumn(name = "client_id") private Client client; @ManyToOne - @JoinColumn(name = "product_id", nullable = true) + @JoinColumn(name = "product_id") private ShareProduct shareProduct; @Column(name = "status_enum", nullable = false) @@ -63,42 +63,42 @@ public class ShareAccount extends AbstractPersistableCustom { private LocalDate submittedDate; @ManyToOne(optional = true) - @JoinColumn(name = "submitted_userid", nullable = true) + @JoinColumn(name = "submitted_userid") protected AppUser submittedBy; @Column(name = "approved_date") protected LocalDate approvedDate; @ManyToOne(optional = true) - @JoinColumn(name = "approved_userid", nullable = true) + @JoinColumn(name = "approved_userid") protected AppUser approvedBy; @Column(name = "rejected_date") protected LocalDate rejectedDate; @ManyToOne(optional = true) - @JoinColumn(name = "rejected_userid", nullable = true) + @JoinColumn(name = "rejected_userid") protected AppUser rejectedBy; - @Column(name = "activated_date", nullable = true) + @Column(name = "activated_date") protected LocalDate activatedDate; @ManyToOne(optional = true) - @JoinColumn(name = "activated_userid", nullable = true) + @JoinColumn(name = "activated_userid") protected AppUser activatedBy; @Column(name = "closed_date") protected LocalDate closedDate; @ManyToOne(optional = true) - @JoinColumn(name = "closed_userid", nullable = true) + @JoinColumn(name = "closed_userid") protected AppUser closedBy; @Column(name = "lastmodified_date") protected LocalDateTime modifiedDate; @ManyToOne(optional = true) - @JoinColumn(name = "lastmodifiedby_id", nullable = true) + @JoinColumn(name = "lastmodifiedby_id") protected AppUser modifiedBy; @Column(name = "external_id") @@ -120,7 +120,7 @@ public class ShareAccount extends AbstractPersistableCustom { private Boolean allowDividendCalculationForInactiveClients; @ManyToOne - @JoinColumn(name = "savings_account_id", nullable = true) + @JoinColumn(name = "savings_account_id") private SavingsAccount savingsAccount; @OneToMany(cascade = CascadeType.ALL, mappedBy = "shareAccount", orphanRemoval = true, fetch = FetchType.EAGER) @@ -130,14 +130,14 @@ public class ShareAccount extends AbstractPersistableCustom { private Integer lockinPeriodFrequency; @Enumerated(EnumType.ORDINAL) - @Column(name = "lockin_period_frequency_enum", nullable = true) + @Column(name = "lockin_period_frequency_enum") private PeriodFrequencyType lockinPeriodFrequencyType; @Column(name = "minimum_active_period_frequency") private Integer minimumActivePeriodFrequency; @Enumerated(EnumType.ORDINAL) - @Column(name = "minimum_active_period_frequency_enum", nullable = true) + @Column(name = "minimum_active_period_frequency_enum") private PeriodFrequencyType minimumActivePeriodFrequencyType; @OneToMany(cascade = CascadeType.ALL, mappedBy = "shareAccount", orphanRemoval = true, fetch = FetchType.EAGER)