catch(final BusinessKeyNotDefinedException e) {
throw new IllegalStateException(e);
}
bk.setPropertyValue("account.id", accountKey);
final Interface intf = dao.load(Interface.class, interfaceKey);
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);
ai.setVersion(Integer.valueOf(1)); // mimic non-new entity
ai.setAccountKey(accountKey);
ai.setInterfaceKey(interfaceKey);
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;
}