private Order loadOrder(File orderFile) {

    Order result = null;

    String errorDescription = null;
    SAXReader reader = new SAXReader();
    Document doc;
    try {
      doc = reader.read(orderFile);
      doc.normalize();
      Element rootNode = doc.getRootElement();
      if (rootNode.getName().equals(OrderTableModel.ORDER_NODE)) {
        String orderNumber = rootNode.element(OrderTableModel.ORDER_NUMBER_NODE)
            .getText();
        String itemNumber = rootNode.element(OrderTableModel.ITEM_NUMBER_NODE)
            .getText();
        int numItemsPlanned = Integer.parseInt(
            rootNode.element(OrderTableModel.NUM_ITEMS_PLANNED_NODE).getText());
        double cycle = Double
            .parseDouble(rootNode.element(OrderTableModel.CYCLE_NODE).getText());
        int numActiveCavities = Integer.parseInt(rootNode
            .element(OrderTableModel.NUM_ACTIVE_CAVITIES_NODE).getText());
        int shift = Integer
            .parseInt(rootNode.element(OrderTableModel.SHIFT_NODE).getText());
        String machineId = rootNode.element(OrderTableModel.MACHINE_ID_NODE)
            .getText();
        Date date = AssemblyMonitoring.STORAGE_DATE_FORMAT
            .parse(rootNode.element(OrderTableModel.DATE_NODE).getText());
        Date sysDate = AssemblyMonitoring.STORAGE_DATE_FORMAT
            .parse(rootNode.element(OrderTableModel.SYS_DATE_NODE).getText());
        result = new Order(orderNumber, itemNumber, machineId, date);
        result.setNumActiveCavities(numActiveCavities);
        result.setNumItemsPlanned(numItemsPlanned);
        result.setCycle(cycle);
        result.setShift(shift);
        result.setSysDate(sysDate);
        Element monitoringsNode = rootNode
            .element(OrderTableModel.MONITORINGS_NODE);
        if (monitoringsNode != null) {
          List monitoringElements = monitoringsNode
              .elements(OrderTableModel.MONITORING_NODE);
          LinkedList<Monitoring> monitorings = new LinkedList<Monitoring>();
          for (Object object : monitoringElements) {
            Element monitoring = (Element) object;
            int monitoringPieces = Integer.parseInt(monitoring
                .element(OrderTableModel.MONITORING_PIECES_NODE).getText());
            //TODO: remove latter - stays here only for backwards compatibility
            Element nonOkPieces = monitoring
                .element(OrderTableModel.MONITORING_NOK_PIECES_NODE);
            int monitoringNokProcessed = 0;
            int monitoringNokLoaded = 0;
            if (nonOkPieces != null){
              monitoringNokProcessed = Integer.parseInt(nonOkPieces.getText());  
            }
            else{
              monitoringNokProcessed = Integer.parseInt(monitoring
                  .element(OrderTableModel.MONITORING_NOK_PIECES_PROCESSED_NODE).getText());;
              monitoringNokLoaded = Integer.parseInt(monitoring
                  .element(OrderTableModel.MONITORING_NOK_PIECES_LOADED_NODE).getText());
            }            
            int monitoringBreak = Integer.parseInt(monitoring
                .element(OrderTableModel.MONITORING_BREAK_NODE).getText());
            int monitoringPause = Integer.parseInt(monitoring
                .element(OrderTableModel.MONITORING_PAUSE_NODE).getText());
            int monitoringShift = Integer.parseInt(monitoring
                .element(OrderTableModel.MONITORING_SHIFT_NODE).getText());
            String monitoringUserId = monitoring
                .element(OrderTableModel.MONITORING_USER_ID_NODE).getText();
            String monitoringComment = monitoring
                .element(OrderTableModel.MONITORING_COMMENT_NODE).getText();
            Date monitoringDate = AssemblyMonitoring.STORAGE_DATE_FORMAT
                .parse(monitoring.element(OrderTableModel.MONITORING_DATE_NODE)
                    .getText());
            Date monitoringSysDate = AssemblyMonitoring.STORAGE_DATE_FORMAT
                .parse(
                    monitoring.element(OrderTableModel.MONITORING_SYS_DATE_NODE)
                        .getText());
            Date monitoringFromTime = AssemblyMonitoring.STORAGE_DATE_FORMAT
                .parse(monitoring
                    .element(OrderTableModel.MONITORING_FROM_TIME_NODE)
                    .getText());
            Date monitoringToTime = AssemblyMonitoring.STORAGE_DATE_FORMAT
                .parse(
                    monitoring.element(OrderTableModel.MONITORING_TO_TIME_NODE)
                        .getText());
            Monitoring monitoringEntity = new Monitoring(result,
                result.getOrderNumber(), monitoringDate, monitoringUserId);
            monitoringEntity.setSysDate(monitoringSysDate);
            monitoringEntity.setFromTime(monitoringFromTime);
            monitoringEntity.setToTime(monitoringToTime);
            monitoringEntity.setShift(monitoringShift);
            monitoringEntity.setPieces(monitoringPieces);
            monitoringEntity.setComment(monitoringComment);
            monitoringEntity.setNonOkProcessed(monitoringNokProcessed);
            monitoringEntity.setNonOkLoaded(monitoringNokLoaded);
            monitoringEntity.setBreakTime(monitoringBreak);
            monitoringEntity.setPauseTime(monitoringPause);
            monitorings.addLast(monitoringEntity);
          }
          result.setMonitoring(monitorings);
        }
      } else {
        errorDescription = "Hlavny element suboru musi byt "
            + OrderTableModel.ORDER_NODE;
      }
    } catch (DocumentException e) {
      errorDescription = e.toString();
    } catch (NullPointerException jlnpe) {
      errorDescription = jlnpe.toString();
    } catch (ParseException pe) {
      errorDescription = pe.toString();
    }

    if (errorDescription != null) {
      errorDescription = "Subor " + orderFile.getAbsoluteFile()
          + " nebol uspesne nacitany.\n" + "Detaily chyby:\n"
          + errorDescription;
      MessageBox.displayMessageBox(table.getShell(), SWT.ERROR, "Chyba!",
          errorDescription);
      result = null;
    }
    return result;
  }