catch(final BusinessKeyNotDefinedException e) {
throw new IllegalStateException(e);
}
bk.setPropertyValue("account.id", accountId);
final Interface intf = dao.load(new PrimaryKey<Interface>(Interface.class, interfaceId));
final LinkedHashSet<AccountInterfaceOption> aios = new LinkedHashSet<AccountInterfaceOption>();
InterfaceOptionAccount ioa;
for(final InterfaceOption io : intf.getOptions()) {
bk.setPropertyValue("option.id", io.getId());
try {
ioa = dao.load(bk);
}
catch(final EntityNotFoundException e) {
ioa = null;
}
final AccountInterfaceOption aio = generateAccountInterfaceOption(io, ioa);
aios.add(aio);
}
final AccountInterface ai = entityAssembler.assembleEntity(AccountInterface.class, null, false);
ai.setVersion(1); // mimic non-new entity
ai.setAccountId(accountId);
ai.setInterfaceId(interfaceId);
ai.setName(intf.getName());
ai.setCode(intf.getCode());
ai.setDescription(intf.getDescription());
ai.setAvailableAsp(intf.getIsAvailableAsp());
ai.setAvailableIsp(intf.getIsAvailableIsp());
ai.setAvailableMerchant(intf.getIsAvailableMerchant());
ai.setAvailableCustomer(intf.getIsAvailableCustomer());
ai.setRequiredAsp(intf.getIsRequiredAsp());
ai.setRequiredIsp(intf.getIsRequiredIsp());
ai.setRequiredMerchant(intf.getIsRequiredMerchant());
ai.setRequiredCustomer(intf.getIsRequiredCustomer());
ai.setOptions(aios);
return ai;
}