public static Ordering toPersistentOrdering( transferFiles.model.order.Ordering orderingTO, Denomination denomination) { Ordering ordering = createPersistentOrderingFromTO(orderingTO); ordering.setFund(Fund.toPersistentFund(orderingTO.getFund(), ordering)); List<Denomination> orderDenoms = new LinkedList<>(); for (transferFiles.model.denomination.Denomination orderingTOdenom : orderingTO.getDenominations()) { if ((denomination != null) && (orderingTOdenom.getId() == denomination.getId())) { orderDenoms.add(denomination); } else { orderDenoms.add(Denomination.toPersistentDenomination(orderingTOdenom, ordering)); } } ordering.setDenominations(orderDenoms); return ordering; }
public transferFiles.model.order.Ordering toTransferOrdering( transferFiles.model.denomination.Denomination denominationTO) { transferFiles.model.order.Ordering orderingTO = createOrderingTO(); orderingTO.setFund(this.fund.toTransferFund(orderingTO)); List<transferFiles.model.denomination.Denomination> denomsTO = new LinkedList<>(); try { for (Denomination denomination : denominations) { if (denomination.getId() == denominationTO.getId()) { denomsTO.add(denominationTO); } else { denomsTO.add(denomination.toDenominationTO(orderingTO)); } } } catch (LazyInitializationException e) { denomsTO = null; } orderingTO.setDenominations(denomsTO); return orderingTO; }