private List<transferFiles.model.denomination.Denomination> createDenominationsTO(
     transferFiles.model.order.Ordering orderingTO) {
   List<transferFiles.model.denomination.Denomination> denomsTO = new LinkedList<>();
   for (Denomination denomination : denominations) {
     denomsTO.add(denomination.toDenominationTO(orderingTO));
   }
   return denomsTO;
 }
 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;
 }
 public static Ordering toPersistentOrdering(
     transferFiles.model.order.Ordering orderingTO, Fund fund) {
   Ordering ordering = createPersistentOrderingFromTO(orderingTO);
   ordering.setFund(fund);
   List<Denomination> orderDenoms = new LinkedList<>();
   for (transferFiles.model.denomination.Denomination orderingTOdenom :
       orderingTO.getDenominations()) {
     orderDenoms.add(Denomination.toPersistentDenomination(orderingTOdenom, ordering));
   }
   ordering.setDenominations(orderDenoms);
   return ordering;
 }
 public static Ordering toPersistentOrdering(transferFiles.model.order.Ordering orderingTO) {
   Ordering ordering = createPersistentOrderingFromTO(orderingTO);
   ordering.setFund(
       orderingTO.getFund() != null
           ? Fund.toPersistentFund(orderingTO.getFund(), ordering)
           : null);
   List<Denomination> orderDenoms = new LinkedList<>();
   if (orderingTO.getDenominations() != null) {
     for (transferFiles.model.denomination.Denomination orderingTOdenom :
         orderingTO.getDenominations()) {
       orderDenoms.add(Denomination.toPersistentDenomination(orderingTOdenom));
     }
   }
   ordering.setDenominations(orderDenoms);
   return ordering;
 }