This is an automated email from the ASF dual-hosted git repository.
adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new a770597dc FINERACT-1926: Fineract Asset Externalization events - fix
for LoanTransactionData events
a770597dc is described below
commit a770597dc0c659faec132063bb94e483e4551641
Author: abraham.menyhart <[email protected]>
AuthorDate: Fri Jun 9 16:33:55 2023 +0200
FINERACT-1926: Fineract Asset Externalization events - fix for
LoanTransactionData events
---
.../enricher/LoanTransactionDataV1Enricher.java | 45 ++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git
a/fineract-investor/src/main/java/org/apache/fineract/investor/enricher/LoanTransactionDataV1Enricher.java
b/fineract-investor/src/main/java/org/apache/fineract/investor/enricher/LoanTransactionDataV1Enricher.java
new file mode 100644
index 000000000..8c8f4d4d1
--- /dev/null
+++
b/fineract-investor/src/main/java/org/apache/fineract/investor/enricher/LoanTransactionDataV1Enricher.java
@@ -0,0 +1,45 @@
+/**
+ * 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.enricher;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.fineract.avro.loan.v1.LoanTransactionDataV1;
+import org.apache.fineract.infrastructure.core.service.DataEnricher;
+import
org.apache.fineract.infrastructure.event.external.service.serialization.mapper.support.ExternalIdMapper;
+import
org.apache.fineract.investor.domain.ExternalAssetOwnerTransferRepository;
+import org.springframework.stereotype.Component;
+
+@Component
+@RequiredArgsConstructor
+public class LoanTransactionDataV1Enricher implements
DataEnricher<LoanTransactionDataV1> {
+
+ private final ExternalAssetOwnerTransferRepository
externalAssetOwnerTransferRepository;
+ private final ExternalIdMapper externalIdMapper;
+
+ @Override
+ public boolean isDataTypeSupported(Class<LoanTransactionDataV1> dataType) {
+ return dataType.isAssignableFrom(LoanTransactionDataV1.class);
+ }
+
+ @Override
+ public void enrich(LoanTransactionDataV1 data) {
+
externalAssetOwnerTransferRepository.findActiveOwnerByLoanId(data.getLoanId())
+ .ifPresent(owner ->
data.setExternalOwnerId(externalIdMapper.mapExternalId(owner.getExternalId())));
+ }
+}