private void saveOrder(Order order) {
    Document document = DocumentHelper.createDocument();
    Element orderElement = document.addElement(OrderTableModel.ORDER_NODE);
    orderElement.addElement(OrderTableModel.ORDER_NUMBER_NODE)
        .addText(order.getOrderNumber());
    orderElement.addElement(OrderTableModel.ITEM_NUMBER_NODE)
        .addText(order.getItemNumber());
    orderElement.addElement(OrderTableModel.MACHINE_ID_NODE)
        .addText(order.getMachineId());
    orderElement.addElement(OrderTableModel.DATE_NODE).addText(
        AssemblyMonitoring.STORAGE_DATE_FORMAT.format(order.getDate()));
    orderElement.addElement(OrderTableModel.SYS_DATE_NODE).addText(
        AssemblyMonitoring.STORAGE_DATE_FORMAT.format(order.getSysDate()));
    orderElement.addElement(OrderTableModel.CYCLE_NODE)
        .addText(String.valueOf(order.getCycle()));
    orderElement.addElement(OrderTableModel.SHIFT_NODE)
        .addText(String.valueOf(order.getShift()));
    orderElement.addElement(OrderTableModel.NUM_ACTIVE_CAVITIES_NODE)
        .addText(String.valueOf(order.getNumActiveCavities()));
    orderElement.addElement(OrderTableModel.NUM_ITEMS_PLANNED_NODE)
        .addText(String.valueOf(order.getNumItemsPlanned()));
    List<Monitoring> monitorings = order.getMonitoring();
    if (monitorings != null && monitorings.size() > 0) {
      Collections.sort(monitorings, new CompareMonitoringByDate());
      Element monitoringsElement = orderElement
          .addElement(OrderTableModel.MONITORINGS_NODE);
      for (Monitoring monitoring : monitorings) {
        if (monitoring.getOrderNumber() != "?"
            && !monitoring.getOrderNumber().equals(order.getOrderNumber())) {
          MessageBox.displayMessageBox(table.getShell(), SWT.ERROR, "Chyba !",
              "Data objednavky c.: " + order.getOrderNumber()
                  + " obsahuju zaznamy monitoringu ktore maju cislo objednavky: "
                  + monitoring.getOrderNumber()
                  + ".\nZapiste si obidve cisla objednavky a opravte data rucne");
        }
        Element monitoringElement = monitoringsElement
            .addElement(OrderTableModel.MONITORING_NODE);
        monitoringElement.addElement(OrderTableModel.MONITORING_DATE_NODE)
            .addText(AssemblyMonitoring.STORAGE_DATE_FORMAT
                .format(monitoring.getDate()));
        monitoringElement.addElement(OrderTableModel.MONITORING_SYS_DATE_NODE)
            .addText(AssemblyMonitoring.STORAGE_DATE_FORMAT
                .format(monitoring.getSysDate()));
        monitoringElement.addElement(OrderTableModel.MONITORING_SHIFT_NODE)
            .addText(String.valueOf(monitoring.getShift()));
        monitoringElement.addElement(OrderTableModel.MONITORING_PIECES_NODE)
            .addText(String.valueOf(monitoring.getPieces()));
        monitoringElement.addElement(OrderTableModel.MONITORING_NOK_PIECES_PROCESSED_NODE)
            .addText(String.valueOf(monitoring.getNonOkProcessed()));
        monitoringElement.addElement(OrderTableModel.MONITORING_NOK_PIECES_LOADED_NODE)
            .addText(String.valueOf(monitoring.getNonOkLoaded()));
        monitoringElement.addElement(OrderTableModel.MONITORING_BREAK_NODE)
            .addText(String.valueOf(monitoring.getBreakTime()));
        monitoringElement.addElement(OrderTableModel.MONITORING_PAUSE_NODE)
            .addText(String.valueOf(monitoring.getPauseTime()));
        monitoringElement.addElement(OrderTableModel.MONITORING_FROM_TIME_NODE)
            .addText(AssemblyMonitoring.STORAGE_DATE_FORMAT
                .format(monitoring.getFromTime()));
        monitoringElement.addElement(OrderTableModel.MONITORING_TO_TIME_NODE)
            .addText(AssemblyMonitoring.STORAGE_DATE_FORMAT
                .format(monitoring.getToTime()));
        monitoringElement.addElement(OrderTableModel.MONITORING_COMMENT_NODE)
            .addText(monitoring.getComment());
        monitoringElement.addElement(OrderTableModel.MONITORING_USER_ID_NODE)
            .addText(monitoring.getUserId());

      }
    }
    // Pretty print the document to System.out
    OutputFormat format = OutputFormat.createPrettyPrint();
    XMLWriter writer;
    try {
      writer = new XMLWriter(
          new FileWriter(AssemblyMonitoring.DATA_LOCATION + File.separator
              + (order.getOrderNumber() == null
                  || order.getOrderNumber().equals("?") ? "unknown"
                      : order.getOrderNumber())
              + ".xml"),
          format);
      writer.write(document);
      writer.close();
    } catch (IOException e) {
      MessageBox.displayMessageBox(table.getShell(), SWT.ERROR, "Chyba !",
          "Chyba pri zapise dat!\n" + "Data neboli spravne ulozene!\n" + e);
    }
  }