merging code arham1
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package com.billpaymentservice.bbps.util;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.*;
|
||||
|
||||
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.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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user