diff --git a/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java b/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java index 2ef93add68e..badd42a58e1 100644 --- a/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java +++ b/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java @@ -185,7 +185,6 @@ import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_EXTERNALSERVICES; import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_EXTERNAL_ASSET_OWNER; import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_EXTERNAL_ASSET_OWNER_LOAN_PRODUCT_ATTRIBUTE; -import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_FAMILYMEMBERS; import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_FINANCIALACTIVITYACCOUNT; import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_FIXEDDEPOSITACCOUNT; import static org.apache.fineract.commands.domain.CommandWrapperConstants.ENTITY_FIXEDDEPOSITPRODUCT; @@ -382,30 +381,6 @@ public CommandWrapperBuilder updateClientAddress(final long clientId) { return this; } - public CommandWrapperBuilder addFamilyMembers(final long clientId) { - this.actionName = ACTION_CREATE; - this.entityName = ENTITY_FAMILYMEMBERS; - this.href = "/clients/" + clientId + "/familymembers"; - this.clientId = clientId; - return this; - } - - public CommandWrapperBuilder updateFamilyMembers(final long familyMemberId) { - this.actionName = ACTION_UPDATE; - this.entityName = ENTITY_FAMILYMEMBERS; - this.href = "/clients/" + clientId + "/familymembers"; - this.entityId = familyMemberId; - return this; - } - - public CommandWrapperBuilder deleteFamilyMembers(final long familyMemberId) { - this.actionName = ACTION_DELETE; - this.entityName = ENTITY_FAMILYMEMBERS; - this.href = "/clients/" + clientId + "/familymembers"; - this.entityId = familyMemberId; - return this; - } - public CommandWrapperBuilder withLoanId(final Long withLoanId) { this.loanId = withLoanId; return this; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientFamilyMembersApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientFamilyMembersApiResource.java index 5ef45336771..6e410b39e07 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientFamilyMembersApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientFamilyMembersApiResource.java @@ -16,12 +16,13 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.fineract.portfolio.client.api; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; import jakarta.ws.rs.GET; @@ -32,15 +33,20 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; import java.util.List; +import java.util.function.Supplier; import lombok.RequiredArgsConstructor; -import org.apache.fineract.commands.domain.CommandWrapper; -import org.apache.fineract.commands.service.CommandWrapperBuilder; -import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer; +import org.apache.fineract.command.core.CommandDispatcher; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; -import org.apache.fineract.portfolio.client.data.ClientFamilyMemberRequest; +import org.apache.fineract.portfolio.client.command.FamilyMemberCreateCommand; +import org.apache.fineract.portfolio.client.command.FamilyMemberDeleteCommand; +import org.apache.fineract.portfolio.client.command.FamilyMemberUpdateCommand; import org.apache.fineract.portfolio.client.data.ClientFamilyMembersData; +import org.apache.fineract.portfolio.client.data.FamilyMemberCreateRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberCreateResponse; +import org.apache.fineract.portfolio.client.data.FamilyMemberDeleteRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberDeleteResponse; +import org.apache.fineract.portfolio.client.data.FamilyMemberUpdateRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberUpdateResponse; import org.apache.fineract.portfolio.client.service.ClientFamilyMembersReadPlatformService; import org.springframework.stereotype.Component; @@ -51,10 +57,10 @@ public class ClientFamilyMembersApiResource { private static final String RESOURCE_NAME_FOR_PERMISSIONS = "FamilyMembers"; + private final PlatformSecurityContext context; private final ClientFamilyMembersReadPlatformService readPlatformService; - private final ToApiJsonSerializer toApiJsonSerializer; - private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; + private final CommandDispatcher dispatcher; @GET @Path("/{familyMemberId}") @@ -62,9 +68,7 @@ public class ClientFamilyMembersApiResource { @Operation(summary = "Retrieve a client family member", operationId = "retrieveOneClientFamilyMember") public ClientFamilyMembersData getFamilyMember(@PathParam("familyMemberId") final Long familyMemberId, @PathParam("clientId") @Parameter(description = "clientId") final Long clientId) { - this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS); - return this.readPlatformService.getClientFamilyMember(clientId, familyMemberId); } @@ -85,41 +89,48 @@ public ClientFamilyMembersData getTemplate(@PathParam("clientId") final long cli return this.readPlatformService.retrieveTemplate(); } - @PUT - @Path("/{familyMemberId}") + @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @Operation(summary = "Update a client family member", operationId = "updateClientFamilyMember") - public CommandProcessingResult updateClientFamilyMembers(@PathParam("familyMemberId") final long familyMemberId, - ClientFamilyMemberRequest clientFamilyMemberRequest, - @PathParam("clientId") @Parameter(description = "clientId") final Long clientId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateFamilyMembers(familyMemberId) - .withJson(toApiJsonSerializer.serialize(clientFamilyMemberRequest)).build(); - - return this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + @Operation(summary = "Add a client family member", operationId = "createClientFamilyMember") + public FamilyMemberCreateResponse addClientFamilyMembers( + @PathParam("clientId") @Parameter(description = "clientId") final Long clientId, + @RequestBody(required = true) @Valid FamilyMemberCreateRequest request) { + request.setClientId(clientId); + final var command = new FamilyMemberCreateCommand(); + command.setPayload(request); + final Supplier response = dispatcher.dispatch(command); + return response.get(); } - @POST + @PUT + @Path("/{familyMemberId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @Operation(summary = "Add a client family member", operationId = "createClientFamilyMember") - public CommandProcessingResult addClientFamilyMembers(@PathParam("clientId") final long clientid, - ClientFamilyMemberRequest clientFamilyMemberRequest) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().addFamilyMembers(clientid) - .withJson(toApiJsonSerializer.serialize(clientFamilyMemberRequest)).build(); - - return this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + @Operation(summary = "Update a client family member", operationId = "updateClientFamilyMember") + public FamilyMemberUpdateResponse updateClientFamilyMembers( + @PathParam("familyMemberId") @Parameter(description = "familyMemberId") final Long familyMemberId, + @PathParam("clientId") @Parameter(description = "clientId") final Long clientId, + @RequestBody(required = true) @Valid FamilyMemberUpdateRequest request) { + request.setId(familyMemberId); + request.setClientId(clientId); + final var command = new FamilyMemberUpdateCommand(); + command.setPayload(request); + final Supplier response = dispatcher.dispatch(command); + return response.get(); } @DELETE @Path("/{familyMemberId}") @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Delete a client family member", operationId = "deleteClientFamilyMember") - public CommandProcessingResult deleteClientFamilyMembers(@PathParam("familyMemberId") final long familyMemberId, + public FamilyMemberDeleteResponse deleteClientFamilyMembers( + @PathParam("familyMemberId") @Parameter(description = "familyMemberId") final Long familyMemberId, @PathParam("clientId") @Parameter(description = "clientId") final Long clientId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteFamilyMembers(familyMemberId).build(); - - return this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + final var request = FamilyMemberDeleteRequest.builder().id(familyMemberId).clientId(clientId).build(); + final var command = new FamilyMemberDeleteCommand(); + command.setPayload(request); + final Supplier response = dispatcher.dispatch(command); + return response.get(); } - } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/command/FamilyMemberCreateCommand.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/command/FamilyMemberCreateCommand.java new file mode 100644 index 00000000000..fa8fde0585b --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/command/FamilyMemberCreateCommand.java @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.client.data.FamilyMemberCreateRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class FamilyMemberCreateCommand extends Command {} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/command/FamilyMemberDeleteCommand.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/command/FamilyMemberDeleteCommand.java new file mode 100644 index 00000000000..024a779cfc2 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/command/FamilyMemberDeleteCommand.java @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.client.data.FamilyMemberDeleteRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class FamilyMemberDeleteCommand extends Command {} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/command/FamilyMemberUpdateCommand.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/command/FamilyMemberUpdateCommand.java new file mode 100644 index 00000000000..cf5d88f4626 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/command/FamilyMemberUpdateCommand.java @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.client.data.FamilyMemberUpdateRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class FamilyMemberUpdateCommand extends Command {} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberCreateRequest.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberCreateRequest.java new file mode 100644 index 00000000000..6dd53694e43 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberCreateRequest.java @@ -0,0 +1,88 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.data; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Hidden; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Past; +import jakarta.validation.constraints.Positive; +import java.io.Serial; +import java.io.Serializable; +import java.time.LocalDate; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class FamilyMemberCreateRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Hidden + private Long clientId; + + @NotNull(message = "{org.apache.fineract.portfolio.client.familymember.firstname.not-null}") + @Length(max = 100, message = "{org.apache.fineract.portfolio.client.familymember.firstname.max}") + private String firstName; + + @Length(max = 100, message = "{org.apache.fineract.portfolio.client.familymember.middlename.max}") + private String middleName; + + @NotNull(message = "{org.apache.fineract.portfolio.client.familymember.lastname.not-null}") + @Length(max = 100, message = "{org.apache.fineract.portfolio.client.familymember.lastname.max}") + private String lastName; + + @Length(max = 100, message = "{org.apache.fineract.portfolio.client.familymember.qualification.max}") + private String qualification; + + @Length(max = 100, message = "{org.apache.fineract.portfolio.client.familymember.mobile-number.max}") + private String mobileNumber; + + @Positive(message = "{org.apache.fineract.portfolio.client.familymember.age.positive}") + private Long age; + + @JsonProperty("isDependent") + private Boolean isDependent; + + @NotNull(message = "{org.apache.fineract.portfolio.client.familymember.relationship-id.not-null}") + @Positive(message = "{org.apache.fineract.portfolio.client.familymember.relationship-id.positive}") + private Long relationshipId; + + @Positive(message = "{org.apache.fineract.portfolio.client.familymember.marital-status-id.positive}") + private Long maritalStatusId; + + @Positive(message = "{org.apache.fineract.portfolio.client.familymember.gender-id.positive}") + private Long genderId; + + @Positive(message = "{org.apache.fineract.portfolio.client.familymember.profession-id.positive}") + private Long professionId; + + @Past(message = "{org.apache.fineract.portfolio.client.familymember.date-of-birth.past}") + private LocalDate dateOfBirth; + + private String locale; + private String dateFormat; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberCreateResponse.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberCreateResponse.java new file mode 100644 index 00000000000..6fd32480147 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberCreateResponse.java @@ -0,0 +1,34 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.data; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class FamilyMemberCreateResponse { + + private Long clientId; + private Long resourceId; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberDeleteRequest.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberDeleteRequest.java new file mode 100644 index 00000000000..d9143060b50 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberDeleteRequest.java @@ -0,0 +1,43 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.data; + +import io.swagger.v3.oas.annotations.Hidden; +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class FamilyMemberDeleteRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Hidden + private Long id; + + @Hidden + private Long clientId; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberDeleteResponse.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberDeleteResponse.java new file mode 100644 index 00000000000..30067b04527 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberDeleteResponse.java @@ -0,0 +1,34 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.data; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class FamilyMemberDeleteResponse { + + private Long clientId; + private Long resourceId; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberUpdateRequest.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberUpdateRequest.java new file mode 100644 index 00000000000..213ea61e4bb --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberUpdateRequest.java @@ -0,0 +1,89 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.data; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Hidden; +import jakarta.validation.constraints.Past; +import jakarta.validation.constraints.Positive; +import java.io.Serial; +import java.io.Serializable; +import java.time.LocalDate; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.FieldNameConstants; +import org.hibernate.validator.constraints.Length; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +@FieldNameConstants +public class FamilyMemberUpdateRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Hidden + private Long id; + + @Hidden + private Long clientId; + + @Length(max = 100, message = "{org.apache.fineract.portfolio.client.familymember.firstname.max}") + private String firstName; + + @Length(max = 100, message = "{org.apache.fineract.portfolio.client.familymember.middlename.max}") + private String middleName; + + @Length(max = 100, message = "{org.apache.fineract.portfolio.client.familymember.lastname.max}") + private String lastName; + + @Length(max = 100, message = "{org.apache.fineract.portfolio.client.familymember.qualification.max}") + private String qualification; + + @Length(max = 100, message = "{org.apache.fineract.portfolio.client.familymember.mobile-number.max}") + private String mobileNumber; + + @Positive(message = "{org.apache.fineract.portfolio.client.familymember.age.positive}") + private Long age; + + @JsonProperty("isDependent") + private Boolean isDependent; + + @Positive(message = "{org.apache.fineract.portfolio.client.familymember.relationship-id.positive}") + private Long relationshipId; + + @Positive(message = "{org.apache.fineract.portfolio.client.familymember.marital-status-id.positive}") + private Long maritalStatusId; + + @Positive(message = "{org.apache.fineract.portfolio.client.familymember.gender-id.positive}") + private Long genderId; + + @Positive(message = "{org.apache.fineract.portfolio.client.familymember.profession-id.positive}") + private Long professionId; + + @Past(message = "{org.apache.fineract.portfolio.client.familymember.date-of-birth.past}") + private LocalDate dateOfBirth; + + private String locale; + private String dateFormat; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberUpdateResponse.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberUpdateResponse.java new file mode 100644 index 00000000000..9cc27814063 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/FamilyMemberUpdateResponse.java @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.data; + +import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class FamilyMemberUpdateResponse { + + private Long clientId; + private Long resourceId; + private Map changes; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientFamilyMembers.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientFamilyMembers.java index 5517b42a529..d51e47eadbe 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientFamilyMembers.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientFamilyMembers.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.fineract.portfolio.client.domain; import jakarta.persistence.Column; @@ -25,9 +24,13 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import java.time.LocalDate; +import lombok.Getter; +import lombok.Setter; import org.apache.fineract.infrastructure.codes.domain.CodeValue; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; +@Getter +@Setter @Entity @Table(name = "m_family_members") public class ClientFamilyMembers extends AbstractPersistableCustom { @@ -76,138 +79,23 @@ public class ClientFamilyMembers extends AbstractPersistableCustom { @Column(name = "date_of_birth", nullable = true) private LocalDate dateOfBirth; - private ClientFamilyMembers(final Client client, final String firstName, final String middleName, final String lastName, - final String qualification, final String mobileNumber, final Long age, final Boolean isDependent, final CodeValue relationship, - final CodeValue maritalStatus, final CodeValue gender, final LocalDate dateOfBirth, final CodeValue profession) { - - this.client = client; - this.firstName = firstName; - this.middleName = middleName; - this.lastName = lastName; - this.qualification = qualification; - this.age = age; - this.mobileNumber = mobileNumber; - this.isDependent = isDependent; - this.relationship = relationship; - this.maritalStatus = maritalStatus; - this.gender = gender; - this.dateOfBirth = dateOfBirth; - this.profession = profession; - } - - public ClientFamilyMembers() { - - } - public static ClientFamilyMembers fromJson(final Client client, final String firstName, final String middleName, final String lastName, final String qualification, final String mobileNumber, final Long age, final Boolean isDependent, final CodeValue relationship, final CodeValue maritalStatus, final CodeValue gender, final LocalDate dateOfBirth, final CodeValue profession) { - return new ClientFamilyMembers(client, firstName, middleName, lastName, qualification, mobileNumber, age, isDependent, relationship, - maritalStatus, gender, dateOfBirth, profession); - } - - public Client getClient() { - return this.client; - } - - public void setClient(Client client) { - this.client = client; - } - - public String getFirstName() { - return this.firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getMiddleName() { - return this.middleName; - } - - public void setMiddleName(String middleName) { - this.middleName = middleName; - } - - public String getLastName() { - return this.lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getQualification() { - return this.qualification; - } - - public void setQualification(String qualification) { - this.qualification = qualification; - } - - public CodeValue getRelationship() { - return this.relationship; + ClientFamilyMembers entity = new ClientFamilyMembers(); + entity.setClient(client); + entity.setFirstName(firstName); + entity.setMiddleName(middleName); + entity.setLastName(lastName); + entity.setQualification(qualification); + entity.setMobileNumber(mobileNumber); + entity.setAge(age); + entity.setIsDependent(isDependent); + entity.setRelationship(relationship); + entity.setMaritalStatus(maritalStatus); + entity.setGender(gender); + entity.setDateOfBirth(dateOfBirth); + entity.setProfession(profession); + return entity; } - - public void setRelationship(CodeValue relationship) { - this.relationship = relationship; - } - - public CodeValue getMaritalStatus() { - return this.maritalStatus; - } - - public void setMaritalStatus(CodeValue maritalStatus) { - this.maritalStatus = maritalStatus; - } - - public CodeValue getGender() { - return this.gender; - } - - public void setGender(CodeValue gender) { - this.gender = gender; - } - - public CodeValue getProfession() { - return this.profession; - } - - public void setProfession(CodeValue profession) { - this.profession = profession; - } - - public LocalDate getDateOfBirth() { - return this.dateOfBirth; - } - - public void setDateOfBirth(LocalDate dateOfBirth) { - this.dateOfBirth = dateOfBirth; - } - - public String getMobileNumber() { - return this.mobileNumber; - } - - public void setMobileNumber(String mobileNumber) { - this.mobileNumber = mobileNumber; - } - - public Long getAge() { - return this.age; - } - - public void setAge(Long age) { - this.age = age; - } - - public Boolean getIsDependent() { - return this.isDependent; - } - - public void setIsDependent(Boolean isDependent) { - this.isDependent = isDependent; - } - } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/AddClientFamilyMemberCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/AddClientFamilyMemberCommandHandler.java deleted file mode 100644 index 2677e72002b..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/AddClientFamilyMemberCommandHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.fineract.portfolio.client.handler; - -import lombok.RequiredArgsConstructor; -import org.apache.fineract.commands.annotation.CommandType; -import org.apache.fineract.commands.handler.NewCommandSourceHandler; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.portfolio.client.service.ClientFamilyMembersWritePlatformService; -import org.springframework.stereotype.Service; - -@Service -@CommandType(entity = "FAMILYMEMBERS", action = "CREATE") -@RequiredArgsConstructor -public class AddClientFamilyMemberCommandHandler implements NewCommandSourceHandler { - - private final ClientFamilyMembersWritePlatformService clientFamilyMembersWritePlatformService; - - @Override - public CommandProcessingResult processCommand(JsonCommand command) { - - return this.clientFamilyMembersWritePlatformService.addFamilyMember(command.getClientId(), command); - } - -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/DeleteClientFamilyMemberCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/DeleteClientFamilyMemberCommandHandler.java deleted file mode 100644 index 2aaebe59ccc..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/DeleteClientFamilyMemberCommandHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.fineract.portfolio.client.handler; - -import lombok.RequiredArgsConstructor; -import org.apache.fineract.commands.annotation.CommandType; -import org.apache.fineract.commands.handler.NewCommandSourceHandler; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.portfolio.client.service.ClientFamilyMembersWritePlatformService; -import org.springframework.stereotype.Service; - -@Service -@CommandType(entity = "FAMILYMEMBERS", action = "DELETE") -@RequiredArgsConstructor -public class DeleteClientFamilyMemberCommandHandler implements NewCommandSourceHandler { - - private final ClientFamilyMembersWritePlatformService clientFamilyMembersWritePlatformService; - - @Override - public CommandProcessingResult processCommand(JsonCommand command) { - - return this.clientFamilyMembersWritePlatformService.deleteFamilyMember(command.entityId(), command); - } -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/FamilyMemberCreateCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/FamilyMemberCreateCommandHandler.java new file mode 100644 index 00000000000..a2493d1efd0 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/FamilyMemberCreateCommandHandler.java @@ -0,0 +1,50 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.handler; + +import io.github.resilience4j.retry.annotation.Retry; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.command.core.CommandHandler; +import org.apache.fineract.portfolio.client.data.FamilyMemberCreateRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberCreateResponse; +import org.apache.fineract.portfolio.client.service.FamilyMemberWriteService; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Component +@RequiredArgsConstructor +public class FamilyMemberCreateCommandHandler implements CommandHandler { + + private final FamilyMemberWriteService writeService; + + @Retry(name = "commandFamilyMemberCreate", fallbackMethod = "fallback") + @Override + @Transactional + public FamilyMemberCreateResponse handle(Command command) { + return writeService.createFamilyMember(command.getPayload()); + } + + @Override + public FamilyMemberCreateResponse fallback(Command command, Throwable t) { + return CommandHandler.super.fallback(command, t); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/FamilyMemberDeleteCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/FamilyMemberDeleteCommandHandler.java new file mode 100644 index 00000000000..2333dcc5883 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/FamilyMemberDeleteCommandHandler.java @@ -0,0 +1,50 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.handler; + +import io.github.resilience4j.retry.annotation.Retry; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.command.core.CommandHandler; +import org.apache.fineract.portfolio.client.data.FamilyMemberDeleteRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberDeleteResponse; +import org.apache.fineract.portfolio.client.service.FamilyMemberWriteService; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Component +@RequiredArgsConstructor +public class FamilyMemberDeleteCommandHandler implements CommandHandler { + + private final FamilyMemberWriteService writeService; + + @Retry(name = "commandFamilyMemberDelete", fallbackMethod = "fallback") + @Override + @Transactional + public FamilyMemberDeleteResponse handle(Command command) { + return writeService.deleteFamilyMember(command.getPayload()); + } + + @Override + public FamilyMemberDeleteResponse fallback(Command command, Throwable t) { + return CommandHandler.super.fallback(command, t); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/FamilyMemberUpdateCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/FamilyMemberUpdateCommandHandler.java new file mode 100644 index 00000000000..fbd4ab07981 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/FamilyMemberUpdateCommandHandler.java @@ -0,0 +1,50 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.handler; + +import io.github.resilience4j.retry.annotation.Retry; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.command.core.CommandHandler; +import org.apache.fineract.portfolio.client.data.FamilyMemberUpdateRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberUpdateResponse; +import org.apache.fineract.portfolio.client.service.FamilyMemberWriteService; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Component +@RequiredArgsConstructor +public class FamilyMemberUpdateCommandHandler implements CommandHandler { + + private final FamilyMemberWriteService writeService; + + @Retry(name = "commandFamilyMemberUpdate", fallbackMethod = "fallback") + @Override + @Transactional + public FamilyMemberUpdateResponse handle(Command command) { + return writeService.updateFamilyMember(command.getPayload()); + } + + @Override + public FamilyMemberUpdateResponse fallback(Command command, Throwable t) { + return CommandHandler.super.fallback(command, t); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/UpdateClientFamilyMemberCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/UpdateClientFamilyMemberCommandHandler.java deleted file mode 100644 index 5080400d4aa..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/UpdateClientFamilyMemberCommandHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.fineract.portfolio.client.handler; - -import lombok.RequiredArgsConstructor; -import org.apache.fineract.commands.annotation.CommandType; -import org.apache.fineract.commands.handler.NewCommandSourceHandler; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.portfolio.client.service.ClientFamilyMembersWritePlatformService; -import org.springframework.stereotype.Service; - -@Service -@CommandType(entity = "FAMILYMEMBERS", action = "UPDATE") -@RequiredArgsConstructor -public class UpdateClientFamilyMemberCommandHandler implements NewCommandSourceHandler { - - private final ClientFamilyMembersWritePlatformService clientFamilyMembersWritePlatformService; - - @Override - public CommandProcessingResult processCommand(JsonCommand command) { - - return this.clientFamilyMembersWritePlatformService.updateFamilyMember(command.entityId(), command); - } - -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/mapper/FamilyMemberCreateRequestMapper.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/mapper/FamilyMemberCreateRequestMapper.java new file mode 100644 index 00000000000..bf31404cf0f --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/mapper/FamilyMemberCreateRequestMapper.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.mapper; + +import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig; +import org.apache.fineract.portfolio.client.data.FamilyMemberCreateRequest; +import org.apache.fineract.portfolio.client.domain.ClientFamilyMembers; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +@Mapper(config = MapstructMapperConfig.class) +public abstract class FamilyMemberCreateRequestMapper { + + @Mapping(ignore = true, target = "id") + @Mapping(ignore = true, target = "client") + @Mapping(ignore = true, target = "relationship") + @Mapping(ignore = true, target = "maritalStatus") + @Mapping(ignore = true, target = "gender") + @Mapping(ignore = true, target = "profession") + public abstract ClientFamilyMembers map(FamilyMemberCreateRequest source); +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientFamilyMembersWritePlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientFamilyMembersWritePlatformService.java index 9b7dd7edbb3..df2fc9a0d05 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientFamilyMembersWritePlatformService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientFamilyMembersWritePlatformService.java @@ -25,12 +25,6 @@ public interface ClientFamilyMembersWritePlatformService { - CommandProcessingResult addFamilyMember(long clientId, JsonCommand command); - CommandProcessingResult addClientFamilyMember(Client client, JsonCommand command); - CommandProcessingResult updateFamilyMember(Long familyMemberId, JsonCommand command); - - CommandProcessingResult deleteFamilyMember(Long familyMemberId, JsonCommand command); - } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientFamilyMembersWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientFamilyMembersWritePlatformServiceImpl.java index 4400f4c3d80..fb59b35f089 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientFamilyMembersWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientFamilyMembersWritePlatformServiceImpl.java @@ -64,72 +64,6 @@ public ClientFamilyMembersWritePlatformServiceImpl(final PlatformSecurityContext } - @Override - public CommandProcessingResult addFamilyMember(final long clientId, final JsonCommand command) { - - Long relationshipId = null; - CodeValue relationship = null; - CodeValue maritalStatus = null; - Long maritalStatusId = null; - Long genderId = null; - CodeValue gender = null; - Long professionId = null; - CodeValue profession = null; - String firstName = ""; - String middleName = ""; - String lastName = ""; - String qualification = ""; - String mobileNumber = ""; - Long age = null; - Boolean isDependent = false; - LocalDate dateOfBirth = null; - - this.context.authenticatedUser(); - apiJsonDeserializer.validateForCreate(clientId, command.json()); - - Client client = clientRepositoryWrapper.findOneWithNotFoundDetection(clientId); - firstName = command.stringValueOfParameterNamed("firstName"); - middleName = command.stringValueOfParameterNamed("middleName"); - lastName = command.stringValueOfParameterNamed("lastName"); - qualification = command.stringValueOfParameterNamed("qualification"); - mobileNumber = command.stringValueOfParameterNamed("mobileNumber"); - age = command.longValueOfParameterNamed("age"); - isDependent = command.booleanObjectValueOfParameterNamed("isDependent"); - - if (command.longValueOfParameterNamed("relationshipId") != null) { - relationshipId = command.longValueOfParameterNamed("relationshipId"); - relationship = this.codeValueRepository.getReferenceById(relationshipId); - } - - if (command.longValueOfParameterNamed("maritalStatusId") != null) { - maritalStatusId = command.longValueOfParameterNamed("maritalStatusId"); - maritalStatus = this.codeValueRepository.getReferenceById(maritalStatusId); - } - - if (command.longValueOfParameterNamed("genderId") != null) { - genderId = command.longValueOfParameterNamed("genderId"); - gender = this.codeValueRepository.getReferenceById(genderId); - } - - if (command.longValueOfParameterNamed("professionId") != null) { - professionId = command.longValueOfParameterNamed("professionId"); - profession = this.codeValueRepository.getReferenceById(professionId); - } - - dateOfBirth = command.localDateValueOfParameterNamed("dateOfBirth"); - - ClientFamilyMembers clientFamilyMembers = ClientFamilyMembers.fromJson(client, firstName, middleName, lastName, qualification, - mobileNumber, age, isDependent, relationship, maritalStatus, gender, dateOfBirth, profession); - - this.clientFamilyRepository.saveAndFlush(clientFamilyMembers); - - return new CommandProcessingResultBuilder() // - .withCommandId(command.commandId()) // - .withEntityId(clientFamilyMembers.getId()) // - .build(); - - } - @Override public CommandProcessingResult addClientFamilyMember(final Client client, final JsonCommand command) { @@ -247,133 +181,4 @@ public CommandProcessingResult addClientFamilyMember(final Client client, final } - @Override - public CommandProcessingResult updateFamilyMember(Long familyMemberId, JsonCommand command) { - - Long relationshipId = null; - CodeValue relationship = null; - CodeValue maritalStatus = null; - Long maritalStatusId = null; - Long genderId = null; - CodeValue gender = null; - Long professionId = null; - CodeValue profession = null; - String firstName = ""; - String middleName = ""; - String lastName = ""; - String qualification = ""; - LocalDate dateOfBirth = null; - String mobileNumber = ""; - Long age = null; - Boolean isDependent = false; - // long clientFamilyMemberId=0; - - this.context.authenticatedUser(); - - apiJsonDeserializer.validateForUpdate(familyMemberId, command.json()); - - /* - * if (command.stringValueOfParameterNamed("clientFamilyMemberId") != null) { clientFamilyMemberId = - * command.longValueOfParameterNamed("clientFamilyMemberId"); } - */ - - ClientFamilyMembers clientFamilyMember = clientFamilyRepository.getReferenceById(familyMemberId); - - // Client - // client=clientRepositoryWrapper.findOneWithNotFoundDetection(clientId); - - if (command.stringValueOfParameterNamed("firstName") != null) { - firstName = command.stringValueOfParameterNamed("firstName"); - clientFamilyMember.setFirstName(firstName); - } - - if (command.stringValueOfParameterNamed("middleName") != null) { - middleName = command.stringValueOfParameterNamed("middleName"); - clientFamilyMember.setMiddleName(middleName); - } - - if (command.stringValueOfParameterNamed("lastName") != null) { - lastName = command.stringValueOfParameterNamed("lastName"); - clientFamilyMember.setLastName(lastName); - } - - if (command.stringValueOfParameterNamed("qualification") != null) { - qualification = command.stringValueOfParameterNamed("qualification"); - clientFamilyMember.setQualification(qualification); - } - - if (command.stringValueOfParameterNamed("mobileNumber") != null) { - mobileNumber = command.stringValueOfParameterNamed("mobileNumber"); - clientFamilyMember.setMobileNumber(mobileNumber); - } - - if (command.longValueOfParameterNamed("age") != null) { - age = command.longValueOfParameterNamed("age"); - clientFamilyMember.setAge(age); - } - - if (command.booleanObjectValueOfParameterNamed("isDependent") != null) { - isDependent = command.booleanObjectValueOfParameterNamed("isDependent"); - clientFamilyMember.setIsDependent(isDependent); - } - - if (command.longValueOfParameterNamed("relationShipId") != null) { - relationshipId = command.longValueOfParameterNamed("relationShipId"); - relationship = this.codeValueRepository.getReferenceById(relationshipId); - clientFamilyMember.setRelationship(relationship); - } - - if (command.longValueOfParameterNamed("maritalStatusId") != 0) { - maritalStatusId = command.longValueOfParameterNamed("maritalStatusId"); - maritalStatus = this.codeValueRepository.getReferenceById(maritalStatusId); - clientFamilyMember.setMaritalStatus(maritalStatus); - } - - if (command.longValueOfParameterNamed("genderId") != 0) { - genderId = command.longValueOfParameterNamed("genderId"); - gender = this.codeValueRepository.getReferenceById(genderId); - clientFamilyMember.setGender(gender); - } - - if (command.longValueOfParameterNamed("professionId") != 0) { - professionId = command.longValueOfParameterNamed("professionId"); - profession = this.codeValueRepository.getReferenceById(professionId); - clientFamilyMember.setProfession(profession); - } - - if (command.localDateValueOfParameterNamed("dateOfBirth") != null) { - dateOfBirth = command.localDateValueOfParameterNamed("dateOfBirth"); - clientFamilyMember.setDateOfBirth(dateOfBirth); - - } - - // ClientFamilyMembers - // clientFamilyMembers=ClientFamilyMembers.fromJson(client, firstName, - // middleName, lastName, qualification, relationship, maritalStatus, - // gender, dateOfBirth, profession); - - this.clientFamilyRepository.saveAndFlush(clientFamilyMember); - - return new CommandProcessingResultBuilder() // - .withCommandId(command.commandId()) // - .withEntityId(clientFamilyMember.getId()) // - .build(); - } - - @Override - public CommandProcessingResult deleteFamilyMember(Long clientFamilyMemberId, JsonCommand command) { - this.context.authenticatedUser(); - - apiJsonDeserializer.validateForDelete(clientFamilyMemberId); - - ClientFamilyMembers clientFamilyMember = clientFamilyRepository.getReferenceById(clientFamilyMemberId); - clientFamilyRepository.delete(clientFamilyMember); - - return new CommandProcessingResultBuilder() // - .withCommandId(command.commandId()) // - .withEntityId(clientFamilyMember.getId()) // - .build(); - - } - } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/FamilyMemberWriteService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/FamilyMemberWriteService.java new file mode 100644 index 00000000000..e94f67cf52b --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/FamilyMemberWriteService.java @@ -0,0 +1,35 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.service; + +import org.apache.fineract.portfolio.client.data.FamilyMemberCreateRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberCreateResponse; +import org.apache.fineract.portfolio.client.data.FamilyMemberDeleteRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberDeleteResponse; +import org.apache.fineract.portfolio.client.data.FamilyMemberUpdateRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberUpdateResponse; + +public interface FamilyMemberWriteService { + + FamilyMemberCreateResponse createFamilyMember(FamilyMemberCreateRequest request); + + FamilyMemberUpdateResponse updateFamilyMember(FamilyMemberUpdateRequest request); + + FamilyMemberDeleteResponse deleteFamilyMember(FamilyMemberDeleteRequest request); +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/FamilyMemberWriteServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/FamilyMemberWriteServiceImpl.java new file mode 100644 index 00000000000..796cd90b0a3 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/FamilyMemberWriteServiceImpl.java @@ -0,0 +1,179 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.service; + +import jakarta.persistence.PersistenceException; +import java.util.HashMap; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository; +import org.apache.fineract.infrastructure.core.exception.ErrorHandler; +import org.apache.fineract.portfolio.client.data.FamilyMemberCreateRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberCreateResponse; +import org.apache.fineract.portfolio.client.data.FamilyMemberDeleteRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberDeleteResponse; +import org.apache.fineract.portfolio.client.data.FamilyMemberUpdateRequest; +import org.apache.fineract.portfolio.client.data.FamilyMemberUpdateResponse; +import org.apache.fineract.portfolio.client.domain.Client; +import org.apache.fineract.portfolio.client.domain.ClientFamilyMembers; +import org.apache.fineract.portfolio.client.domain.ClientFamilyMembersRepository; +import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper; +import org.apache.fineract.portfolio.client.exception.FamilyMemberNotFoundException; +import org.apache.fineract.portfolio.client.mapper.FamilyMemberCreateRequestMapper; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.orm.jpa.JpaSystemException; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@RequiredArgsConstructor +public class FamilyMemberWriteServiceImpl implements FamilyMemberWriteService { + + private final ClientRepositoryWrapper clientRepositoryWrapper; + private final ClientFamilyMembersRepository clientFamilyRepository; + private final CodeValueRepository codeValueRepository; + private final FamilyMemberCreateRequestMapper familyMemberCreateRequestMapper; + + @Transactional + @Override + public FamilyMemberCreateResponse createFamilyMember(final FamilyMemberCreateRequest request) { + try { + var entity = familyMemberCreateRequestMapper.map(request); + + Client client = clientRepositoryWrapper.findOneWithNotFoundDetection(request.getClientId()); + entity.setClient(client); + + entity.setRelationship(codeValueRepository.getReferenceById(request.getRelationshipId())); + + if (request.getMaritalStatusId() != null) { + entity.setMaritalStatus(codeValueRepository.getReferenceById(request.getMaritalStatusId())); + } + if (request.getGenderId() != null) { + entity.setGender(codeValueRepository.getReferenceById(request.getGenderId())); + } + if (request.getProfessionId() != null) { + entity.setProfession(codeValueRepository.getReferenceById(request.getProfessionId())); + } + + clientFamilyRepository.saveAndFlush(entity); + + return FamilyMemberCreateResponse.builder().resourceId(entity.getId()).clientId(request.getClientId()).build(); + } catch (final JpaSystemException | DataIntegrityViolationException dve) { + throw handleDataIntegrityIssues(dve.getMostSpecificCause(), dve); + } catch (final PersistenceException dve) { + var throwable = ExceptionUtils.getRootCause(dve.getCause()); + throw handleDataIntegrityIssues(throwable, dve); + } + } + + @Transactional + @Override + public FamilyMemberUpdateResponse updateFamilyMember(final FamilyMemberUpdateRequest request) { + try { + ClientFamilyMembers entity = findFamilyMemberForClient(request.getId(), request.getClientId()); + + var changes = new HashMap(); + + if (StringUtils.isNotEmpty(request.getFirstName())) { + entity.setFirstName(request.getFirstName()); + changes.put(FamilyMemberUpdateRequest.Fields.firstName, request.getFirstName()); + } + if (StringUtils.isNotEmpty(request.getMiddleName())) { + entity.setMiddleName(request.getMiddleName()); + changes.put(FamilyMemberUpdateRequest.Fields.middleName, request.getMiddleName()); + } + if (StringUtils.isNotEmpty(request.getLastName())) { + entity.setLastName(request.getLastName()); + changes.put(FamilyMemberUpdateRequest.Fields.lastName, request.getLastName()); + } + if (StringUtils.isNotEmpty(request.getQualification())) { + entity.setQualification(request.getQualification()); + changes.put(FamilyMemberUpdateRequest.Fields.qualification, request.getQualification()); + } + if (StringUtils.isNotEmpty(request.getMobileNumber())) { + entity.setMobileNumber(request.getMobileNumber()); + changes.put(FamilyMemberUpdateRequest.Fields.mobileNumber, request.getMobileNumber()); + } + if (request.getAge() != null) { + entity.setAge(request.getAge()); + changes.put(FamilyMemberUpdateRequest.Fields.age, request.getAge()); + } + if (request.getIsDependent() != null) { + entity.setIsDependent(request.getIsDependent()); + changes.put(FamilyMemberUpdateRequest.Fields.isDependent, request.getIsDependent()); + } + if (request.getRelationshipId() != null) { + entity.setRelationship(codeValueRepository.getReferenceById(request.getRelationshipId())); + changes.put(FamilyMemberUpdateRequest.Fields.relationshipId, request.getRelationshipId()); + } + if (request.getMaritalStatusId() != null) { + entity.setMaritalStatus(codeValueRepository.getReferenceById(request.getMaritalStatusId())); + changes.put(FamilyMemberUpdateRequest.Fields.maritalStatusId, request.getMaritalStatusId()); + } + if (request.getGenderId() != null) { + entity.setGender(codeValueRepository.getReferenceById(request.getGenderId())); + changes.put(FamilyMemberUpdateRequest.Fields.genderId, request.getGenderId()); + } + if (request.getProfessionId() != null) { + entity.setProfession(codeValueRepository.getReferenceById(request.getProfessionId())); + changes.put(FamilyMemberUpdateRequest.Fields.professionId, request.getProfessionId()); + } + if (request.getDateOfBirth() != null) { + entity.setDateOfBirth(request.getDateOfBirth()); + changes.put(FamilyMemberUpdateRequest.Fields.dateOfBirth, request.getDateOfBirth()); + } + + var response = FamilyMemberUpdateResponse.builder().resourceId(entity.getId()).clientId(request.getClientId()); + if (!changes.isEmpty()) { + response.changes(changes); + clientFamilyRepository.saveAndFlush(entity); + } + return response.build(); + } catch (final JpaSystemException | DataIntegrityViolationException dve) { + throw handleDataIntegrityIssues(dve.getMostSpecificCause(), dve); + } catch (final PersistenceException dve) { + var throwable = ExceptionUtils.getRootCause(dve.getCause()); + throw handleDataIntegrityIssues(throwable, dve); + } + } + + @Transactional + @Override + public FamilyMemberDeleteResponse deleteFamilyMember(final FamilyMemberDeleteRequest request) { + ClientFamilyMembers entity = findFamilyMemberForClient(request.getId(), request.getClientId()); + clientFamilyRepository.delete(entity); + return FamilyMemberDeleteResponse.builder().resourceId(request.getId()).clientId(request.getClientId()).build(); + } + + private ClientFamilyMembers findFamilyMemberForClient(final Long familyMemberId, final Long clientId) { + ClientFamilyMembers entity = clientFamilyRepository.findById(familyMemberId) + .orElseThrow(() -> new FamilyMemberNotFoundException(familyMemberId, clientId, null)); + if (entity.getClient() == null || !entity.getClient().getId().equals(clientId)) { + throw new FamilyMemberNotFoundException(familyMemberId, clientId, null); + } + return entity; + } + + private RuntimeException handleDataIntegrityIssues(final Throwable realCause, final Exception dve) { + log.error("Error occurred.", dve); + return ErrorHandler.getMappable(dve, "error.msg.familymember.unknown.data.integrity.issue", + "Unknown data integrity issue with resource: " + realCause.getMessage()); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/starter/FamilyMemberConfiguration.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/starter/FamilyMemberConfiguration.java new file mode 100644 index 00000000000..450fb0cc605 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/starter/FamilyMemberConfiguration.java @@ -0,0 +1,43 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.client.starter; + +import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository; +import org.apache.fineract.portfolio.client.domain.ClientFamilyMembersRepository; +import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper; +import org.apache.fineract.portfolio.client.mapper.FamilyMemberCreateRequestMapper; +import org.apache.fineract.portfolio.client.service.FamilyMemberWriteService; +import org.apache.fineract.portfolio.client.service.FamilyMemberWriteServiceImpl; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +class FamilyMemberConfiguration { + + @Bean + @ConditionalOnMissingBean(FamilyMemberWriteService.class) + FamilyMemberWriteService familyMemberWriteService(ClientRepositoryWrapper clientRepositoryWrapper, + ClientFamilyMembersRepository clientFamilyRepository, CodeValueRepository codeValueRepository, + FamilyMemberCreateRequestMapper familyMemberCreateRequestMapper) { + return new FamilyMemberWriteServiceImpl(clientRepositoryWrapper, clientFamilyRepository, codeValueRepository, + familyMemberCreateRequestMapper); + } +} diff --git a/fineract-provider/src/main/resources/application.properties b/fineract-provider/src/main/resources/application.properties index d8eed37f191..d7074618234 100644 --- a/fineract-provider/src/main/resources/application.properties +++ b/fineract-provider/src/main/resources/application.properties @@ -714,6 +714,21 @@ resilience4j.retry.instances.commandStaffCreate.wait-duration=${FINERACT_COMMAND resilience4j.retry.instances.commandStaffCreate.enable-exponential-backoff=${FINERACT_COMMAND_STAFF_CREATE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} resilience4j.retry.instances.commandStaffCreate.exponential-backoff-multiplier=${FINERACT_COMMAND_STAFF_CREATE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} resilience4j.retry.instances.commandStaffCreate.retryExceptions=${FINERACT_COMMAND_STAFF_CREATE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} +resilience4j.retry.instances.commandFamilyMemberCreate.max-attempts=${FINERACT_COMMAND_FAMILY_MEMBER_CREATE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandFamilyMemberCreate.wait-duration=${FINERACT_COMMAND_FAMILY_MEMBER_CREATE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandFamilyMemberCreate.enable-exponential-backoff=${FINERACT_COMMAND_FAMILY_MEMBER_CREATE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandFamilyMemberCreate.exponential-backoff-multiplier=${FINERACT_COMMAND_FAMILY_MEMBER_CREATE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandFamilyMemberCreate.retryExceptions=${FINERACT_COMMAND_FAMILY_MEMBER_CREATE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} +resilience4j.retry.instances.commandFamilyMemberUpdate.max-attempts=${FINERACT_COMMAND_FAMILY_MEMBER_UPDATE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandFamilyMemberUpdate.wait-duration=${FINERACT_COMMAND_FAMILY_MEMBER_UPDATE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandFamilyMemberUpdate.enable-exponential-backoff=${FINERACT_COMMAND_FAMILY_MEMBER_UPDATE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandFamilyMemberUpdate.exponential-backoff-multiplier=${FINERACT_COMMAND_FAMILY_MEMBER_UPDATE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandFamilyMemberUpdate.retryExceptions=${FINERACT_COMMAND_FAMILY_MEMBER_UPDATE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} +resilience4j.retry.instances.commandFamilyMemberDelete.max-attempts=${FINERACT_COMMAND_FAMILY_MEMBER_DELETE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandFamilyMemberDelete.wait-duration=${FINERACT_COMMAND_FAMILY_MEMBER_DELETE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandFamilyMemberDelete.enable-exponential-backoff=${FINERACT_COMMAND_FAMILY_MEMBER_DELETE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandFamilyMemberDelete.exponential-backoff-multiplier=${FINERACT_COMMAND_FAMILY_MEMBER_DELETE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandFamilyMemberDelete.retryExceptions=${FINERACT_COMMAND_FAMILY_MEMBER_DELETE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} resilience4j.retry.instances.commandStaffUpdate.max-attempts=${FINERACT_COMMAND_STAFF_UPDATE_RETRY_MAX_ATTEMPTS:3} resilience4j.retry.instances.commandStaffUpdate.wait-duration=${FINERACT_COMMAND_STAFF_UPDATE_RETRY_WAIT_DURATION:1s} diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ClientFamilyMemberTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ClientFamilyMemberTest.java index 176050b0297..017f3b3fc69 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ClientFamilyMemberTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ClientFamilyMemberTest.java @@ -22,7 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import org.apache.fineract.client.models.ClientFamilyMemberRequest; +import org.apache.fineract.client.models.FamilyMemberCreateRequest; import org.apache.fineract.client.models.PostClientsRequest; import org.apache.fineract.client.models.PostCodeValuesDataRequest; import org.apache.fineract.client.services.ClientFamilyMemberApi; @@ -58,7 +58,7 @@ public void retrieveFamilyMemberReturns404ForAnotherClientsMember() { new PostCodeValuesDataRequest().name(Utils.randomStringGenerator("Relative_", 4)).position(1).isActive(true))) .getSubResourceId(); Long familyMemberId = ok(familyMemberApi.createClientFamilyMember(ownerClientId, - new ClientFamilyMemberRequest().firstName("Ada").lastName("Lovelace").relationshipId(relationshipId))).getResourceId(); + new FamilyMemberCreateRequest().firstName("Ada").lastName("Lovelace").relationshipId(relationshipId))).getResourceId(); // sanity: reachable through the owning client assertEquals(familyMemberId, ok(familyMemberApi.retrieveOneClientFamilyMember(familyMemberId, ownerClientId)).getId());