@Override public PurchaseOrder toDTO() { PurchaseOrder purchaseOrder = initializeDTO(); purchaseOrder.setOperator(this.operator.toDTO()); if (this.controller != null) { purchaseOrder.setController(this.controller.toDTO()); } return purchaseOrder; }
private PurchaseOrder initializeDTO() { PurchaseOrder purchaseOrder = new PurchaseOrderDTO(); purchaseOrder.setId(this.id); purchaseOrder.setCustomer(this.customer); purchaseOrder.setDate(this.date); purchaseOrder.setRef(this.ref); purchaseOrder.setPriority(this.priority); List<PurchaseOrderLine> tmpPurchaseOrderLines = new ArrayList<PurchaseOrderLine>(); for (PurchaseOrderLineDB purchaseOrderLine : this.purchaseOrderLines) { PurchaseOrderLine purchaseOrderLineDTO = purchaseOrderLine.toDTO(); purchaseOrderLineDTO.setPurchaseOrder(purchaseOrder); tmpPurchaseOrderLines.add(purchaseOrderLineDTO); } purchaseOrder.setPurchaseOrderLines(tmpPurchaseOrderLines); return purchaseOrder; }
public PurchaseOrderDB(PurchaseOrder purchaseOrder) { if (purchaseOrder.getOperator() != null) { this.operator = new DispatcherDB(purchaseOrder.getOperator()); } if (purchaseOrder.getController() != null) { this.controller = new DispatcherDB(purchaseOrder.getController()); } this.id = purchaseOrder.getId(); this.customer = purchaseOrder.getCustomer(); this.date = purchaseOrder.getDate(); this.ref = purchaseOrder.getRef(); this.priority = purchaseOrder.getPriority(); List<PurchaseOrderLineDB> purchaseOrderLineDBs = new ArrayList<PurchaseOrderLineDB>(); if (purchaseOrder.getPurchaseOrderLines() != null) { List<PurchaseOrderLine> purchaseOrderLines2 = purchaseOrder.getPurchaseOrderLines(); for (PurchaseOrderLine purchaseOrderLine : purchaseOrderLines2) { PurchaseOrderLineDB purchaseOrderLineDB = new PurchaseOrderLineDB(purchaseOrderLine); purchaseOrderLineDB.setPurchaseOrder(this); purchaseOrderLineDBs.add(purchaseOrderLineDB); } } this.purchaseOrderLines = purchaseOrderLineDBs; }