-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FINERACT-2081: Ability to assign settlement information to loan produ…
…ct when asset is externally owned
- Loading branch information
Showing
31 changed files
with
1,715 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...org/apache/fineract/investor/api/ExternalAssetOwnerLoanProductAttributesApiConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* 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.investor.api; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import org.apache.fineract.investor.domain.ExternalAssetOwnerLoanProductAttributes; | ||
|
||
public final class ExternalAssetOwnerLoanProductAttributesApiConstants { | ||
|
||
private ExternalAssetOwnerLoanProductAttributesApiConstants() { | ||
|
||
} | ||
|
||
// parameters | ||
private static final String loanProductIdParamName = "loanProductId"; | ||
private static final String attributeKeyParamName = "attributeKey"; | ||
private static final String attributeValueParamName = "attributeValue"; | ||
private static final String id = "id"; | ||
|
||
/** | ||
* These parameters will match the class level parameters of {@link ExternalAssetOwnerLoanProductAttributes}. Where | ||
* possible, we try to get response parameters to match those of request parameters. | ||
*/ | ||
static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>( | ||
Arrays.asList(id, loanProductIdParamName, attributeKeyParamName, attributeValueParamName)); | ||
} |
131 changes: 131 additions & 0 deletions
131
.../org/apache/fineract/investor/api/ExternalAssetOwnerLoanProductAttributesApiResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/** | ||
* 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.investor.api; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.parameters.RequestBody; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.PUT; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.QueryParam; | ||
import jakarta.ws.rs.core.Context; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.UriInfo; | ||
import lombok.RequiredArgsConstructor; | ||
import org.apache.fineract.commands.domain.CommandWrapper; | ||
import org.apache.fineract.commands.service.CommandWrapperBuilder; | ||
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; | ||
import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; | ||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; | ||
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; | ||
import org.apache.fineract.infrastructure.core.service.Page; | ||
import org.apache.fineract.infrastructure.security.service.PlatformUserRightsContext; | ||
import org.apache.fineract.investor.config.InvestorModuleIsEnabledCondition; | ||
import org.apache.fineract.investor.data.ExternalTransferLoanProductAttributesData; | ||
import org.apache.fineract.investor.service.ExternalAssetOwnerLoanProductAttributesReadService; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Path("/v1/external-asset-owners/loan-product") | ||
@Component | ||
@Tag(name = "External Asset Owner Loan Product Attributes", description = "External Asset Owner Loan Product Attributes") | ||
@RequiredArgsConstructor | ||
@Conditional(InvestorModuleIsEnabledCondition.class) | ||
public class ExternalAssetOwnerLoanProductAttributesApiResource { | ||
|
||
private final PlatformUserRightsContext platformUserRightsContext; | ||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; | ||
private final ExternalAssetOwnerLoanProductAttributesReadService externalAssetOwnerLoanProductAttributesReadService; | ||
private final ApiRequestParameterHelper apiRequestParameterHelper; | ||
private final DefaultToApiJsonSerializer<ExternalTransferLoanProductAttributesData> toApiJsonSerializer; | ||
|
||
@POST | ||
@Path("/{loanProductId}/attributes") | ||
@Consumes({ MediaType.APPLICATION_JSON }) | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = ExternalAssetOwnerLoanProductAttributesApiResourceSwagger.PostExternalAssetOwnerLoanProductAttributeRequest.class))) | ||
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), | ||
@ApiResponse(responseCode = "400", description = "Invalid Request"), | ||
@ApiResponse(responseCode = "403", description = "Resource Already Exists"), | ||
@ApiResponse(responseCode = "404", description = "Not Found"), | ||
@ApiResponse(responseCode = "500", description = "Internal Server Error") }) | ||
public CommandProcessingResult postExternalAssetOwnerLoanProductAttribute( | ||
@PathParam("loanProductId") @Parameter(description = "loanProductId") final Long loanProductId, | ||
@Parameter(hidden = true) final String apiRequestBodyAsJson) { | ||
platformUserRightsContext.isAuthenticated(); | ||
final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); | ||
CommandWrapper request = builder.createExternalAssetOwnerLoanProductAttribute(loanProductId).build(); | ||
|
||
return commandsSourceWritePlatformService.logCommandSource(request); | ||
} | ||
|
||
@GET | ||
@Path("/{loanProductId}/attributes") | ||
@Consumes({ MediaType.APPLICATION_JSON }) | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
@Operation(tags = { | ||
"External Asset Owner Loan Product Attributes" }, summary = "Retrieve All Loan Product Attributes", description = "Retrieves all Loan Product Attributes with a given loanProductId", parameters = { | ||
@Parameter(name = "loanProductId", description = "loanProductId"), | ||
@Parameter(name = "attributeKey", description = "attributeKey") }) | ||
@ApiResponses({ @ApiResponse(responseCode = "200", description = "A paginated group of loan product attributes is returned"), | ||
@ApiResponse(responseCode = "404", description = "Not Found"), | ||
@ApiResponse(responseCode = "500", description = "Internal Server Error") }) | ||
public Page<ExternalTransferLoanProductAttributesData> getExternalAssetOwnerLoanProductAttributes(@Context final UriInfo uriInfo, | ||
@PathParam("loanProductId") @Parameter(description = "loanProductId") final Long loanProductId, | ||
@QueryParam("attributeKey") @Parameter(description = "attributeKey") final String attributeKey) { | ||
platformUserRightsContext.isAuthenticated(); | ||
|
||
return externalAssetOwnerLoanProductAttributesReadService.retrieveAllLoanProductAttributesByLoanProductId(loanProductId, | ||
attributeKey); | ||
} | ||
|
||
@PUT | ||
@Path("/{loanProductId}/attributes/{id}") | ||
@Consumes({ MediaType.APPLICATION_JSON }) | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = ExternalAssetOwnerLoanProductAttributesApiResourceSwagger.PutExternalAssetOwnerLoanProductAttributeRequest.class))) | ||
@Operation(tags = { | ||
"External Asset Owner Loan Product Attributes" }, summary = "Update a Loan Product Attribute", description = "Updates a loan product attribute with a given loan product id and attribute id", parameters = { | ||
@Parameter(name = "loanProductId", description = "loanProductId"), | ||
@Parameter(name = "attributeId", description = "attributeId") }) | ||
@ApiResponses({ @ApiResponse(responseCode = "200", description = "A loan product attribute filtered by id is returned"), | ||
@ApiResponse(responseCode = "404", description = "Not Found"), | ||
@ApiResponse(responseCode = "500", description = "Internal Server Error") }) | ||
public CommandProcessingResult updateLoanProductAttribute( | ||
@PathParam("loanProductId") @Parameter(description = "loanProductId") final Long loanProductId, | ||
@PathParam("id") @Parameter(description = "attributeId") final Long attributeId, | ||
@Parameter(hidden = true) final String apiRequestBodyAsJson) { | ||
platformUserRightsContext.isAuthenticated(); | ||
final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); | ||
CommandWrapper request = builder.updateExternalAssetOwnerLoanProductAttribute(loanProductId, attributeId).build(); | ||
|
||
return commandsSourceWritePlatformService.logCommandSource(request); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...ache/fineract/investor/api/ExternalAssetOwnerLoanProductAttributesApiResourceSwagger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* 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.investor.api; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@SuppressWarnings({ "MemberName" }) | ||
final class ExternalAssetOwnerLoanProductAttributesApiResourceSwagger { | ||
|
||
private ExternalAssetOwnerLoanProductAttributesApiResourceSwagger() {} | ||
|
||
@Schema(description = "PostExternalAssetOwnerLoanProductAttributeRequest") | ||
public static final class PostExternalAssetOwnerLoanProductAttributeRequest { | ||
|
||
private PostExternalAssetOwnerLoanProductAttributeRequest() {} | ||
|
||
@Schema(example = "SETTLEMENT_MODEL") | ||
public String attributeKey; | ||
|
||
@Schema(example = "DELAYED_SETTLEMENT") | ||
public String attributeValue; | ||
} | ||
|
||
@Schema(description = "PutExternalAssetOwnerLoanProductAttributeRequest") | ||
public static final class PutExternalAssetOwnerLoanProductAttributeRequest { | ||
|
||
private PutExternalAssetOwnerLoanProductAttributeRequest() {} | ||
|
||
@Schema(example = "SETTLEMENT_MODEL") | ||
public String attributeKey; | ||
|
||
@Schema(example = "DELAYED_SETTLEMENT_DISABLED") | ||
public String attributeValue; | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...pache/fineract/investor/data/ExternalAssetOwnerLoanProductAttributeRequestParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* 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.investor.data; | ||
|
||
public final class ExternalAssetOwnerLoanProductAttributeRequestParameters { | ||
|
||
private ExternalAssetOwnerLoanProductAttributeRequestParameters() {} | ||
|
||
public static final String ATTRIBUTE_KEY = "attributeKey"; | ||
public static final String ATTRIBUTE_VALUE = "attributeValue"; | ||
} |
37 changes: 37 additions & 0 deletions
37
...ain/java/org/apache/fineract/investor/data/ExternalTransferLoanProductAttributesData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.investor.data; | ||
|
||
import java.io.Serializable; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
|
||
/** | ||
* Data object representing an external transfer loan product attribute | ||
*/ | ||
|
||
@Data | ||
@Getter | ||
public class ExternalTransferLoanProductAttributesData implements Serializable { | ||
|
||
private Long attributeId; | ||
private Long loanProductId; | ||
private String attributeKey; | ||
private String attributeValue; | ||
} |
Oops, something went wrong.