FINERACT-1724: Refactoring the business event serializers for better extensability
This commit is contained in:
committed by
Arnold Gálovics
parent
d2a12c3cfc
commit
a7d737b215
+44
@@ -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.infrastructure.event.external.service.serialization.serializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public abstract class AbstractBusinessEventSerializer implements BusinessEventSerializer {
|
||||
|
||||
@Setter(onMethod = @__({ @Autowired }))
|
||||
private ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
ByteBufferSerializable avroDto = toAvroDTO(rawEvent);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
}
|
||||
|
||||
protected abstract <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent);
|
||||
}
|
||||
+5
-10
@@ -18,27 +18,24 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.client.v1.ClientDataV1;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.client.ClientBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.client.ClientDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.client.data.ClientData;
|
||||
import org.apache.fineract.portfolio.client.service.ClientReadPlatformService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ClientBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class ClientBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final ClientReadPlatformService service;
|
||||
private final ClientDataMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -46,12 +43,10 @@ public class ClientBusinessEventSerializer implements BusinessEventSerializer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
ClientBusinessEvent event = (ClientBusinessEvent) rawEvent;
|
||||
ClientData data = service.retrieveOne(event.get().getId());
|
||||
ClientDataV1 avroDto = mapper.map(data);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return mapper.map(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -18,16 +18,14 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.fixeddeposit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.fixeddeposit.v1.FixedDepositAccountDataV1;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.deposit.FixedDepositAccountBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.fixeddeposit.FixedDepositAccountDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.savings.DepositAccountType;
|
||||
import org.apache.fineract.portfolio.savings.data.FixedDepositAccountData;
|
||||
import org.apache.fineract.portfolio.savings.service.DepositAccountReadPlatformService;
|
||||
@@ -35,11 +33,10 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class FixedDepositAccountBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class FixedDepositAccountBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final DepositAccountReadPlatformService service;
|
||||
private final FixedDepositAccountDataMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -47,12 +44,10 @@ public class FixedDepositAccountBusinessEventSerializer implements BusinessEvent
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
FixedDepositAccountBusinessEvent event = (FixedDepositAccountBusinessEvent) rawEvent;
|
||||
FixedDepositAccountData data = (FixedDepositAccountData) service.retrieveOne(DepositAccountType.FIXED_DEPOSIT, event.get().getId());
|
||||
FixedDepositAccountDataV1 avroDto = mapper.map(data);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return mapper.map(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -18,24 +18,21 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.group;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.generic.v1.CommandProcessingResultV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.group.GroupsBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.generic.CommandProcessingResultMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class GroupsBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class GroupsBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final CommandProcessingResultMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -43,11 +40,9 @@ public class GroupsBusinessEventSerializer implements BusinessEventSerializer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
GroupsBusinessEvent event = (GroupsBusinessEvent) rawEvent;
|
||||
CommandProcessingResultV1 avroDto = mapper.map(event.get());
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return mapper.map(event.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-11
@@ -18,17 +18,15 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.loan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.loan.v1.LoanTransactionAdjustmentDataV1;
|
||||
import org.apache.fineract.avro.loan.v1.LoanTransactionDataV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.loan.LoanAdjustTransactionBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.loan.LoanTransactionDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
|
||||
import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService;
|
||||
@@ -36,11 +34,10 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class LoanAdjustTransactionBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class LoanAdjustTransactionBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final LoanReadPlatformService service;
|
||||
private final LoanTransactionDataMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -48,7 +45,7 @@ public class LoanAdjustTransactionBusinessEventSerializer implements BusinessEve
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
LoanAdjustTransactionBusinessEvent event = (LoanAdjustTransactionBusinessEvent) rawEvent;
|
||||
LoanTransaction transactionToAdjust = event.get().getTransactionToAdjust();
|
||||
LoanTransactionData transactionToAdjustData = service.retrieveLoanTransaction(transactionToAdjust.getLoan().getId(),
|
||||
@@ -63,10 +60,7 @@ public class LoanAdjustTransactionBusinessEventSerializer implements BusinessEve
|
||||
newTransactionDetailAvroDto = mapper.map(newTransactionDetailData);
|
||||
|
||||
}
|
||||
LoanTransactionAdjustmentDataV1 avroDto = new LoanTransactionAdjustmentDataV1(transactionToAdjustAvroDto,
|
||||
newTransactionDetailAvroDto);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return new LoanTransactionAdjustmentDataV1(transactionToAdjustAvroDto, newTransactionDetailAvroDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -18,27 +18,24 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.loan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.loan.v1.LoanAccountDataV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.loan.LoanBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.loan.LoanAccountDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanAccountData;
|
||||
import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class LoanBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class LoanBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final LoanReadPlatformService service;
|
||||
private final LoanAccountDataMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -46,12 +43,10 @@ public class LoanBusinessEventSerializer implements BusinessEventSerializer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
LoanBusinessEvent event = (LoanBusinessEvent) rawEvent;
|
||||
LoanAccountData data = service.retrieveOne(event.get().getId());
|
||||
LoanAccountDataV1 avroDto = mapper.map(data);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return mapper.map(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -18,27 +18,24 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.loan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.loan.v1.LoanChargeDataV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.loan.charge.LoanChargeBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.loan.LoanChargeDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanChargeData;
|
||||
import org.apache.fineract.portfolio.loanaccount.service.LoanChargeReadPlatformService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class LoanChargeBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class LoanChargeBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final LoanChargeReadPlatformService service;
|
||||
private final LoanChargeDataMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -46,12 +43,10 @@ public class LoanChargeBusinessEventSerializer implements BusinessEventSerialize
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
LoanChargeBusinessEvent event = (LoanChargeBusinessEvent) rawEvent;
|
||||
LoanChargeData data = service.retrieveLoanChargeDetails(event.get().getId(), event.get().getLoan().getId());
|
||||
LoanChargeDataV1 avroDto = mapper.map(data);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return mapper.map(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-8
@@ -18,14 +18,13 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.loan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.loan.v1.LoanChargeDeletedV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.loan.charge.LoanDeleteChargeBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
|
||||
import org.springframework.core.Ordered;
|
||||
@@ -35,7 +34,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Order(Ordered.LOWEST_PRECEDENCE - 1)
|
||||
public class LoanChargeDeletedBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class LoanChargeDeletedBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@@ -45,14 +44,12 @@ public class LoanChargeDeletedBusinessEventSerializer implements BusinessEventSe
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
LoanDeleteChargeBusinessEvent event = (LoanDeleteChargeBusinessEvent) rawEvent;
|
||||
LoanCharge loanCharge = event.get();
|
||||
Long id = loanCharge.getId();
|
||||
Long chargeId = loanCharge.getCharge().getId();
|
||||
LoanChargeDeletedV1 avroDto = new LoanChargeDeletedV1(id, chargeId);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return new LoanChargeDeletedV1(id, chargeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -18,27 +18,24 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.loan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.loan.v1.LoanProductDataV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.loan.product.LoanProductBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.loan.LoanProductDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.loanproduct.data.LoanProductData;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class LoanProductBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class LoanProductBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final LoanProductReadPlatformService service;
|
||||
private final LoanProductDataMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -46,12 +43,10 @@ public class LoanProductBusinessEventSerializer implements BusinessEventSerializ
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
LoanProductBusinessEvent event = (LoanProductBusinessEvent) rawEvent;
|
||||
LoanProductData data = service.retrieveLoanProduct(event.get().getId());
|
||||
LoanProductDataV1 avroDto = mapper.map(data);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return mapper.map(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -18,27 +18,24 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.loan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.loan.v1.LoanTransactionDataV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanTransactionBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.loan.LoanTransactionDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class LoanTransactionBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class LoanTransactionBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final LoanReadPlatformService service;
|
||||
private final LoanTransactionDataMapper loanTransactionMapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -46,14 +43,12 @@ public class LoanTransactionBusinessEventSerializer implements BusinessEventSeri
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
LoanTransactionBusinessEvent event = (LoanTransactionBusinessEvent) rawEvent;
|
||||
Long loanId = event.get().getLoan().getId();
|
||||
Long loanTransactionId = event.get().getId();
|
||||
LoanTransactionData transactionData = service.retrieveLoanTransaction(loanId, loanTransactionId);
|
||||
LoanTransactionDataV1 avroDto = loanTransactionMapper.map(transactionData);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return loanTransactionMapper.map(transactionData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -18,16 +18,14 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.recurringdeposit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.recurringdeposit.v1.RecurringDepositAccountDataV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.deposit.RecurringDepositAccountBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.recurringdeposit.RecurringDepositAccountDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.savings.DepositAccountType;
|
||||
import org.apache.fineract.portfolio.savings.data.RecurringDepositAccountData;
|
||||
import org.apache.fineract.portfolio.savings.service.DepositAccountReadPlatformService;
|
||||
@@ -35,11 +33,10 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class RecurringDepositAccountBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class RecurringDepositAccountBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final DepositAccountReadPlatformService service;
|
||||
private final RecurringDepositAccountDataMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -47,13 +44,11 @@ public class RecurringDepositAccountBusinessEventSerializer implements BusinessE
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
RecurringDepositAccountBusinessEvent event = (RecurringDepositAccountBusinessEvent) rawEvent;
|
||||
RecurringDepositAccountData data = (RecurringDepositAccountData) service.retrieveOne(DepositAccountType.RECURRING_DEPOSIT,
|
||||
event.get().getId());
|
||||
RecurringDepositAccountDataV1 avroDto = mapper.map(data);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return mapper.map(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -18,27 +18,24 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.savings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.savings.v1.SavingsAccountDataV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.savings.SavingsAccountBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.savings.SavingsAccountDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountData;
|
||||
import org.apache.fineract.portfolio.savings.service.SavingsAccountReadPlatformService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class SavingsAccountBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class SavingsAccountBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final SavingsAccountReadPlatformService service;
|
||||
private final SavingsAccountDataMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -46,12 +43,10 @@ public class SavingsAccountBusinessEventSerializer implements BusinessEventSeria
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
SavingsAccountBusinessEvent event = (SavingsAccountBusinessEvent) rawEvent;
|
||||
SavingsAccountData data = service.retrieveOne(event.get().getId());
|
||||
SavingsAccountDataV1 avroDto = mapper.map(data);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return mapper.map(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -18,16 +18,14 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.savings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.savings.v1.SavingsAccountTransactionDataV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.savings.transaction.SavingsAccountTransactionBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.savings.SavingsAccountTransactionDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionData;
|
||||
import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction;
|
||||
import org.apache.fineract.portfolio.savings.service.SavingsAccountReadPlatformService;
|
||||
@@ -35,11 +33,10 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class SavingsAccountTransactionBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class SavingsAccountTransactionBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final SavingsAccountReadPlatformService service;
|
||||
private final SavingsAccountTransactionDataMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -47,14 +44,12 @@ public class SavingsAccountTransactionBusinessEventSerializer implements Busines
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
SavingsAccountTransactionBusinessEvent event = (SavingsAccountTransactionBusinessEvent) rawEvent;
|
||||
SavingsAccountTransaction tx = event.get();
|
||||
SavingsAccountTransactionData data = service.retrieveSavingsTransaction(tx.getSavingsAccount().getId(), tx.getId(),
|
||||
tx.getSavingsAccount().depositAccountType());
|
||||
SavingsAccountTransactionDataV1 avroDto = mapper.map(data);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return mapper.map(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -18,27 +18,24 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.share;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.share.v1.ShareAccountDataV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.share.ShareAccountBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.share.ShareAccountDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.shareaccounts.data.ShareAccountData;
|
||||
import org.apache.fineract.portfolio.shareaccounts.service.ShareAccountReadPlatformService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ShareAccountBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class ShareAccountBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final ShareAccountReadPlatformService service;
|
||||
private final ShareAccountDataMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -46,12 +43,10 @@ public class ShareAccountBusinessEventSerializer implements BusinessEventSeriali
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
ShareAccountBusinessEvent event = (ShareAccountBusinessEvent) rawEvent;
|
||||
ShareAccountData data = service.retrieveOne(event.get().getId(), false);
|
||||
ShareAccountDataV1 avroDto = mapper.map(data);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return mapper.map(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-10
@@ -18,27 +18,24 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.share;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.avro.generic.GenericContainer;
|
||||
import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
||||
import org.apache.fineract.avro.share.v1.ShareProductDataV1;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.share.ShareProductDividentsCreateBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.share.ShareProductDataMapper;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
|
||||
import org.apache.fineract.infrastructure.event.external.service.support.ByteBufferConverter;
|
||||
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventSerializer;
|
||||
import org.apache.fineract.portfolio.products.service.ShareProductReadPlatformService;
|
||||
import org.apache.fineract.portfolio.shareproducts.data.ShareProductData;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ShareProductDividentsCreateBusinessEventSerializer implements BusinessEventSerializer {
|
||||
public class ShareProductDividentsCreateBusinessEventSerializer extends AbstractBusinessEventSerializer {
|
||||
|
||||
private final ShareProductReadPlatformService service;
|
||||
private final ShareProductDataMapper mapper;
|
||||
private final ByteBufferConverter byteBufferConverter;
|
||||
|
||||
@Override
|
||||
public <T> boolean canSerialize(BusinessEvent<T> event) {
|
||||
@@ -46,12 +43,10 @@ public class ShareProductDividentsCreateBusinessEventSerializer implements Busin
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> byte[] serialize(BusinessEvent<T> rawEvent) throws IOException {
|
||||
protected <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
|
||||
ShareProductDividentsCreateBusinessEvent event = (ShareProductDividentsCreateBusinessEvent) rawEvent;
|
||||
ShareProductData data = (ShareProductData) service.retrieveOne(event.get(), false);
|
||||
ShareProductDataV1 avroDto = mapper.map(data);
|
||||
ByteBuffer buffer = avroDto.toByteBuffer();
|
||||
return byteBufferConverter.convert(buffer);
|
||||
return mapper.map(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user