Skip to content

FINERACT-2239: New command processing - Resource Notes (org.apache.fineract.portfolio.note) #4811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Collections;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.portfolio.note.data.NoteData;
import org.apache.fineract.portfolio.note.data.NoteResponse;
import org.apache.fineract.portfolio.note.service.NoteReadPlatformService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -38,12 +38,12 @@ public void afterPropertiesSet() throws Exception {
}

@Override
public NoteData retrieveNote(Long noteId, Long resourceId, Integer noteTypeId) {
public NoteResponse retrieveNote(Long noteId, Long resourceId, Integer noteTypeId) {
return null;
}

@Override
public List<NoteData> retrieveNotesByResource(Long resourceId, Integer noteTypeId) {
public List<NoteResponse> retrieveNotesByResource(Long resourceId, Integer noteTypeId) {
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
package com.acme.fineract.portfolio.note.service;

import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.note.data.NoteCreateRequest;
import org.apache.fineract.portfolio.note.data.NoteCreateResponse;
import org.apache.fineract.portfolio.note.data.NoteDeleteByResourceIdRequest;
import org.apache.fineract.portfolio.note.data.NoteDeleteRequest;
import org.apache.fineract.portfolio.note.data.NoteDeleteResponse;
import org.apache.fineract.portfolio.note.data.NoteUpdateRequest;
import org.apache.fineract.portfolio.note.data.NoteUpdateResponse;
import org.apache.fineract.portfolio.note.service.NoteWritePlatformService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -38,27 +42,22 @@ public void afterPropertiesSet() throws Exception {
}

@Override
public CommandProcessingResult createNote(JsonCommand command) {
public NoteCreateResponse createNote(NoteCreateRequest request) {
throw new UnsupportedOperationException("createNote() is not yet implemented.");
}

@Override
public void createLoanTransactionNote(Long loanTransactionId, String note) {
throw new UnsupportedOperationException("createLoanTransactionNote() is not yet implemented.");
}

@Override
public CommandProcessingResult updateNote(JsonCommand command) {
public NoteUpdateResponse updateNote(NoteUpdateRequest request) {
throw new UnsupportedOperationException("updateNote() is not yet implemented.");
}

@Override
public CommandProcessingResult deleteNote(JsonCommand command) {
public NoteDeleteResponse deleteNote(NoteDeleteRequest request) {
throw new UnsupportedOperationException("deleteNote() is not yet implemented.");
}

@Override
public void createAndPersistClientNote(Client client, JsonCommand command) {
log.warn("createAndPersistClientNote() is intentionally left empty and does nothing.");
public void deleteByResource(NoteDeleteByResourceIdRequest request) {
throw new UnsupportedOperationException("deleteBySavingsAccount() is not yet implemented.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionRepository;
import org.apache.fineract.portfolio.note.domain.NoteRepository;
import org.apache.fineract.portfolio.note.serialization.NoteCommandFromApiJsonDeserializer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;
Expand Down Expand Up @@ -82,9 +81,4 @@ public LoanRepositoryWrapper loanRepository() {
public LoanTransactionRepository loanTransactionRepository() {
return mock(LoanTransactionRepository.class);
}

@Bean
public NoteCommandFromApiJsonDeserializer fromApiJsonDeserializer(FromJsonHelper fromJsonHelper) {
return new NoteCommandFromApiJsonDeserializer(fromJsonHelper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@

import static org.mockito.Mockito.mock;

import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.infrastructure.core.service.database.RoutingDataSource;
import org.apache.fineract.infrastructure.core.service.database.RoutingDataSourceServiceFactory;
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.group.domain.GroupRepository;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionRepository;
import org.apache.fineract.portfolio.note.domain.NoteRepository;
import org.apache.fineract.portfolio.note.serialization.NoteCommandFromApiJsonDeserializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.jdbc.core.JdbcTemplate;
Expand All @@ -37,11 +35,6 @@
public class TestOverrideConfiguration {
// NOTE: unfortunately an abastract base class that contains all these mock functions won't work

@Bean
public FromJsonHelper fromJsonHelper() {
return mock(FromJsonHelper.class);
}

@Bean
public RoutingDataSourceServiceFactory routingDataSourceServiceFactory() {
return mock(RoutingDataSourceServiceFactory.class);
Expand Down Expand Up @@ -81,9 +74,4 @@ public LoanRepositoryWrapper loanRepository() {
public LoanTransactionRepository loanTransactionRepository() {
return mock(LoanTransactionRepository.class);
}

@Bean
public NoteCommandFromApiJsonDeserializer fromApiJsonDeserializer(FromJsonHelper fromJsonHelper) {
return new NoteCommandFromApiJsonDeserializer(fromJsonHelper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.portfolio.note.data.NoteData;
import org.apache.fineract.portfolio.note.data.NoteResponse;
import org.apache.fineract.portfolio.paymentdetail.data.PaymentDetailData;

@RequiredArgsConstructor
Expand All @@ -29,13 +29,13 @@ public class TransactionDetailData {

private final Long transactionId;
private final PaymentDetailData paymentDetails;
private final NoteData noteData;
private final NoteResponse noteResponse;
private final TransactionTypeEnumData transactionType;

public TransactionDetailData(final Long transactionId, final PaymentDetailData paymentDetails, final NoteData noteData) {
public TransactionDetailData(final Long transactionId, final PaymentDetailData paymentDetails, final NoteResponse noteResponse) {
this.transactionId = transactionId;
this.paymentDetails = paymentDetails;
this.noteData = noteData;
this.noteResponse = noteResponse;
this.transactionType = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.http.MediaType.APPLICATION_PROBLEM_JSON_VALUE;

import jakarta.validation.Valid;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.util.UUID;
Expand Down Expand Up @@ -55,7 +56,7 @@ class DummyApiController {

@PostMapping("/sync")
DummyResponse dummySync(@RequestHeader(value = COMMAND_REQUEST_ID, required = false) UUID requestId,
@RequestHeader(value = "x-fineract-tenant-id", required = false) String tenantId, @RequestBody DummyRequest request) {
@RequestHeader(value = "x-fineract-tenant-id", required = false) String tenantId, @Valid @RequestBody DummyRequest request) {
var command = new DummyCommand();
command.setId(requestId);
command.setPayload(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1837,55 +1837,6 @@ public CommandWrapperBuilder deleteCalendar(final String supportedEntityType, fi
return this;
}

public CommandWrapperBuilder createNote(final CommandWrapper resourceDetails, final String resourceType, final Long resourceId) {
this.actionName = "CREATE";
this.entityName = resourceDetails.entityName();// Note supports multiple
// resources. Note
// Permissions are set
// for each resource.
this.clientId = resourceDetails.getClientId();
this.loanId = resourceDetails.getLoanId();
this.savingsId = resourceDetails.getSavingsId();
this.groupId = resourceDetails.getGroupId();
this.subentityId = resourceDetails.subresourceId();
this.href = "/" + resourceType + "/" + resourceId + "/notes/template";
return this;
}

public CommandWrapperBuilder updateNote(final CommandWrapper resourceDetails, final String resourceType, final Long resourceId,
final Long noteId) {
this.actionName = "UPDATE";
this.entityName = resourceDetails.entityName();// Note supports multiple
// resources. Note
// Permissions are set
// for each resource.
this.entityId = noteId;
this.clientId = resourceDetails.getClientId();
this.loanId = resourceDetails.getLoanId();
this.savingsId = resourceDetails.getSavingsId();
this.groupId = resourceDetails.getGroupId();
this.subentityId = resourceDetails.subresourceId();
this.href = "/" + resourceType + "/" + resourceId + "/notes";
return this;
}

public CommandWrapperBuilder deleteNote(final CommandWrapper resourceDetails, final String resourceType, final Long resourceId,
final Long noteId) {
this.actionName = "DELETE";
this.entityName = resourceDetails.entityName();// Note supports multiple
// resources. Note
// Permissions are set
// for each resource.
this.entityId = noteId;
this.clientId = resourceDetails.getClientId();
this.loanId = resourceDetails.getLoanId();
this.savingsId = resourceDetails.getSavingsId();
this.groupId = resourceDetails.getGroupId();
this.subentityId = resourceDetails.subresourceId();
this.href = "/" + resourceType + "/" + resourceId + "/calendars/" + noteId;
return this;
}

public CommandWrapperBuilder createGroup() {
this.actionName = "CREATE";
this.entityName = "GROUP";
Expand Down Expand Up @@ -3581,13 +3532,6 @@ public CommandWrapperBuilder updateRate(final Long rateId) {
return this;
}

public CommandWrapperBuilder updateBusinessDate() {
this.actionName = "UPDATE";
this.entityName = "BUSINESS_DATE";
this.href = "/businessdate";
return this;
}

public CommandWrapperBuilder createDelinquencyRange() {
this.actionName = "CREATE";
this.entityName = "DELINQUENCY_RANGE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,6 @@ private NewCommandSourceHandler findCommandHandler(final CommandWrapper wrapper)
} else {
throw new UnsupportedCommandException(wrapper.commandName());
}
} else if (wrapper.isNoteResource()) {
if (wrapper.isCreate()) {
handler = applicationContext.getBean("createNoteCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isUpdate()) {
handler = applicationContext.getBean("updateNoteCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDelete()) {
handler = applicationContext.getBean("deleteNoteCommandHandler", NewCommandSourceHandler.class);
} else {
throw new UnsupportedCommandException(wrapper.commandName());
}
} else if (wrapper.isSurveyResource()) {
if (wrapper.isRegisterSurvey()) {
handler = applicationContext.getBean("registerSurveyCommandHandler", NewCommandSourceHandler.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
package org.apache.fineract.infrastructure.businessdate.api;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
Expand Down Expand Up @@ -64,15 +64,15 @@ public List<BusinessDateResponse> getBusinessDates() {
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Retrieve a specific Business date", description = "")
public BusinessDateResponse getBusinessDate(@PathParam("type") @Parameter(description = "type") final String type) {
public BusinessDateResponse getBusinessDate(@PathParam("type") final String type) {
return this.readPlatformService.findByType(type);
}

@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Update Business Date", description = "")
public BusinessDateResponse updateBusinessDate(@HeaderParam("Idempotency-Key") String idempotencyKey,
public BusinessDateResponse updateBusinessDate(@HeaderParam("Idempotency-Key") @DefaultValue("") String idempotencyKey,
@Valid BusinessDateUpdateRequest request) {

final var command = new BusinessDateUpdateCommand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import jakarta.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
import java.time.OffsetDateTime;
import java.util.Optional;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.domain.Auditable;
import org.springframework.data.jpa.domain.AbstractAuditable;

Expand All @@ -44,30 +43,45 @@
* Abstract base class for auditable entities. Stores the audit values in persistent fields.
*/
@MappedSuperclass
@Getter
@Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public abstract class AbstractAuditableWithUTCDateTimeCustom<T extends Serializable> extends AbstractPersistableCustom<T>
implements Auditable<Long, T, OffsetDateTime> {

@Serial
private static final long serialVersionUID = 141481953116476081L;

@Column(name = CREATED_BY_DB_FIELD, updatable = false, nullable = false)
@Setter(onMethod_ = @Override)
private Long createdBy;

@Column(name = CREATED_DATE_DB_FIELD, updatable = false, nullable = false)
@Setter(onMethod_ = @Override)
private OffsetDateTime createdDate;

@Column(name = LAST_MODIFIED_BY_DB_FIELD, nullable = false)
@Setter(onMethod_ = @Override)
private Long lastModifiedBy;

@Column(name = LAST_MODIFIED_DATE_DB_FIELD, nullable = false)
@Setter(onMethod_ = @Override)
private OffsetDateTime lastModifiedDate;

@Override
public void setCreatedBy(Long createdBy) {
this.createdBy = createdBy;
}

@Override
public void setCreatedDate(OffsetDateTime createdDate) {
this.createdDate = createdDate;
}

@Override
public void setLastModifiedBy(Long lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}

@Override
public void setLastModifiedDate(OffsetDateTime lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}

@Override
@NotNull
public Optional<Long> getCreatedBy() {
Expand Down
Loading
Loading