public transferFiles.model.order.Ordering toTransferOrdering() {
   transferFiles.model.order.Ordering orderingTO = createOrderingTO();
   if (this.getFund() != null) orderingTO.setFund(this.getFund().toTransferFund(orderingTO));
   List<transferFiles.model.denomination.Denomination> denomsTO =
       createDenominationsTO(orderingTO);
   orderingTO.setDenominations(denomsTO);
   return orderingTO;
 }
 public transferFiles.model.order.Ordering toTransferOrdering(
     transferFiles.model.fund.Fund fundTo) {
   transferFiles.model.order.Ordering orderingTO = createOrderingTO();
   orderingTO.setFund(fundTo);
   List<transferFiles.model.denomination.Denomination> denomsTO =
       createDenominationsTO(orderingTO);
   orderingTO.setDenominations(denomsTO);
   return orderingTO;
 }
 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 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;
 }
 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;
 }
 private static Ordering createPersistentOrderingFromTO(
     transferFiles.model.order.Ordering orderingTO) {
   return new Ordering(
       orderingTO.getId(),
       ConvertDate.toJavaFromJoda(orderingTO.getDateOrderCreated()),
       ConvertDate.toJavaFromJoda(orderingTO.getDateClientsCome()),
       orderingTO.getAmountOfPeople(),
       orderingTO.getDescription(),
       orderingTO.getAdvancePayment(),
       orderingTO.getWhoTakenOrder() != null
           ? User.toPersistentUser(orderingTO.getWhoTakenOrder())
           : null,
       orderingTO.getWhoServesOrder() != null
           ? User.toPersistentUser(orderingTO.getWhoServesOrder())
           : null,
       orderingTO.getType());
 }