100 lines
3.3 KiB
Java
100 lines
3.3 KiB
Java
package com.billpaymentservice.bbps.util;
|
|
import com.billpaymentservice.bbps.entites.BillerDetails;
|
|
import com.billpaymentservice.bbps.entites.BillerResponseParams;
|
|
import com.billpaymentservice.bbps.entites.InterchangeFee;
|
|
import com.billpaymentservice.bbps.entites.TransactionMaster;
|
|
|
|
public class EntityRelationshipUtil {
|
|
|
|
private EntityRelationshipUtil() {
|
|
// prevent instantiation
|
|
}
|
|
|
|
/**
|
|
* Links all parent-child relationships for BillerDetails and nested entities.
|
|
* Ensures bidirectional JPA relationships are correctly set before saving.
|
|
*/
|
|
public static void linkBillerRelationships(BillerDetails entity) {
|
|
|
|
if (entity == null) return;
|
|
|
|
if (entity.getBillerPaymentModes() != null) {
|
|
entity.getBillerPaymentModes().forEach(m -> m.setBiller(entity));
|
|
}
|
|
|
|
if (entity.getBillerPaymentChannels() != null) {
|
|
entity.getBillerPaymentChannels().forEach(c -> c.setBiller(entity));
|
|
}
|
|
|
|
if (entity.getBillerCustomerParams() != null) {
|
|
entity.getBillerCustomerParams().forEach(p -> p.setBiller(entity));
|
|
}
|
|
|
|
if (entity.getBillerAdditionalInfos() != null) {
|
|
entity.getBillerAdditionalInfos().forEach(a -> a.setBiller(entity));
|
|
}
|
|
|
|
if(entity.getBillerAdditionalInfoPayments() != null) {
|
|
entity.getBillerAdditionalInfoPayments().forEach(a -> a.setBiller(entity));
|
|
}
|
|
|
|
|
|
if (entity.getInterchangeFees() != null) {
|
|
for (InterchangeFee fee : entity.getInterchangeFees()) {
|
|
fee.setBiller(entity);
|
|
|
|
if (fee.getInterchangeFeeDetails() != null) {
|
|
fee.getInterchangeFeeDetails().forEach(detail -> detail.setInterchangeFee(fee));
|
|
}
|
|
}
|
|
}
|
|
|
|
if (entity.getInterchangeFeeConves() != null) {
|
|
entity.getInterchangeFeeConves().forEach(fc -> fc.setBiller(entity));
|
|
}
|
|
|
|
if (entity.getCustomerParamGroups() != null)
|
|
entity.getCustomerParamGroups().setBiller(entity);
|
|
|
|
if (entity.getBillerPlanResponseParams() != null)
|
|
entity.getBillerPlanResponseParams().setBiller(entity);
|
|
|
|
if (entity.getBillerResponseParams() != null) {
|
|
BillerResponseParams responseParams = entity.getBillerResponseParams();
|
|
responseParams.setBiller(entity);
|
|
|
|
if (responseParams.getAmountOptions() != null) {
|
|
responseParams.getAmountOptions()
|
|
.forEach(option -> option.setBillerResponseParams(responseParams));
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void linkTransactionMasterRelationships(TransactionMaster entity) {
|
|
|
|
if (entity == null) return;
|
|
|
|
// ✅ DeviceBlockTag relationship link karna
|
|
if (entity.getDeviceBlockTags() != null) {
|
|
entity.getDeviceBlockTags().forEach(tag -> {
|
|
if (tag != null) {
|
|
tag.setTransactionMaster(entity);
|
|
}
|
|
});
|
|
}
|
|
|
|
// ✅ CustomerParamTransaction relationship link karna
|
|
if (entity.getCustomerParams() != null) {
|
|
entity.getCustomerParams().forEach(param -> {
|
|
if (param != null) {
|
|
param.setTransactionMaster(entity);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|