Exemple #1
0
  /**
   * Adding execution expressions informations from a list of IBatch.
   *
   * @param conf
   * @param listBatchs
   */
  private void addExecutionInformations(
      IBatchConfiguration conf, List<? extends IBatch> listBatchs) {

    if (isEmpty(listBatchs)) {
      return;
    }

    IBatch latestExecution = null;

    for (IBatch batch : listBatchs) {
      if (latestExecution == null || latestExecution.getStartDate().before(batch.getEndDate())) {
        latestExecution = batch;
      }
    }
    conf.setLastExecution(latestExecution.getStartDate());
  }
Exemple #2
0
  @Override
  public void doGet(StatusWebHandler webHandler, HttpServletRequest req, HttpServletResponse resp)
      throws UnsupportedEncodingException, IOException {

    setup(resp, "text/html");
    ServletOutputStream os = resp.getOutputStream();
    Map<String, String> valuesMap = new HashMap<String, String>();
    StrBuilder sbRunningBatchesBatchesTable = new StrBuilder();
    StrBuilder sbFinishedBatchesBatchesTable = new StrBuilder();
    StrBuilder sbErrorsBatchesBatchesTable = new StrBuilder();
    StrBuilder sbConfBatchesBatchesTable = new StrBuilder();

    IBatchManager manager = webHandler.getAppStatus().getBatchManager();
    List<IBatch> runningBatches = manager.getRunningBatches();
    if (generateBeginTable(sbRunningBatchesBatchesTable, runningBatches.size())) {

      generateHeaders(
          sbRunningBatchesBatchesTable,
          "",
          "Id",
          "Group",
          "Name",
          "Start",
          "Progress", //
          "End (est.)",
          "Status",
          "Task",
          "Last Msg",
          "Items",
          "Rejected",
          "Last Update");

      for (IBatch batch : runningBatches) {
        generateRow(
            sbRunningBatchesBatchesTable,
            getIcon(batch),
            generateId(resp, batch.getUuid()), //
            escapeHtml4(batch.getGroup()),
            escapeHtml4(batch.getName()),
            batch.getStartDate(),
            getProgressBar(batch), //
            batch.getEndDate(),
            batch.getStatus(),
            batch.getCurrentTask(), //
            escapeHtml4(batch.getLastMessage()),
            batch.getItemCount(),
            HtmlUtils.countAndDetail(batch.getRejectedItemsId()), //
            batch.getLastUpdate(), //
            batch.getStatus() != IBatch.STATUS_ZOMBIE
                ? "" //
                : "<form action='?p=batch' method='post'><input type='submit' name='"
                    + CLEAR_ITEM //
                    + "' value='Delete'  class='btn btn-small' /><input type=hidden name='" //
                    + ITEM_UUID
                    + "' value='"
                    + escapeHtml4(batch.getUuid())
                    + "'/></form>");
      }

      generateEndTable(sbRunningBatchesBatchesTable, runningBatches.size());
    }

    // Batch Schedule
    List<IBatchConfiguration> batchConfigurations = new ArrayList<IBatchConfiguration>();

    IBatchScheduleManager scheduleManager = webHandler.getAppStatus().getBatchScheduleManager();
    if (scheduleManager != null) {
      batchConfigurations.addAll(scheduleManager.getBatchConfigurations());
    }

    if (HtmlUtils.generateBeginTable(sbConfBatchesBatchesTable, batchConfigurations.size())) {
      HtmlUtils.generateHeaders(
          sbConfBatchesBatchesTable, "", "Group", "Name", "Last run", "Next", "Exec. expr");

      for (IBatchConfiguration batch : batchConfigurations) {
        addExecutionInformations(batch, manager.getBatches(batch.getGroup(), batch.getName()));
        generateRow(
            sbConfBatchesBatchesTable,
            Resources.STATUS_JOB,
            escapeHtml4(batch.getGroup()),
            escapeHtml4(batch.getName()),
            batch.getLastExecution(),
            batch.getNextExecution(),
            batch.getSchedule());
      }

      generateEndTable(sbConfBatchesBatchesTable, runningBatches.size());
    }

    List<IBatch> finishedBatches = manager.getFinishedBatches();

    if (generateBeginTable(sbFinishedBatchesBatchesTable, finishedBatches.size())) {

      generateHeaders(
          sbFinishedBatchesBatchesTable,
          "",
          "Id",
          "Group",
          "Name",
          "Start",
          "Progress", //
          "End",
          "Status",
          "Task",
          "Last Msg",
          "Items",
          "Rejected",
          "Last Update",
          "");
      for (IBatch batch : finishedBatches) {
        generateRow(
            sbFinishedBatchesBatchesTable,
            getIcon(batch),
            generateId(resp, batch.getUuid()), //
            escapeHtml4(batch.getGroup()),
            escapeHtml4(batch.getName()),
            batch.getStartDate(),
            getProgressBar(batch), //
            batch.getEndDate(),
            batch.getStatus(),
            batch.getCurrentTask(),
            escapeHtml4(batch.getLastMessage()), //
            batch.getItemCount(),
            countAndDetail(batch.getRejectedItemsId()), //
            batch.getLastUpdate(), //
            "<form action='?p=batch' method='post'><input type='submit' name='" //
                + CLEAR_ITEM
                + "' value='Delete'  class='btn btn-small' /><input type=hidden name='" //
                + ITEM_UUID
                + "' value='"
                + escapeHtml4(batch.getUuid())
                + "'/></form>");
      }

      generateEndTable(sbFinishedBatchesBatchesTable, finishedBatches.size());
    }

    List<IBatch> errorBatches = manager.getErrorBatches();

    if (generateBeginTable(sbErrorsBatchesBatchesTable, errorBatches.size())) {

      generateHeaders(
          sbErrorsBatchesBatchesTable,
          "",
          "Id",
          "Group",
          "Name",
          "Start",
          "Progress", //
          "End",
          "Status",
          "Task",
          "Last Msg",
          "Items",
          "Rejected",
          "Last Update",
          "");

      for (IBatch batch : errorBatches) {
        generateRow(
            sbErrorsBatchesBatchesTable,
            getIcon(batch),
            generateId(resp, batch.getUuid()), //
            escapeHtml4(batch.getGroup()),
            escapeHtml4(batch.getName()),
            batch.getStartDate(),
            getProgressBar(batch), //
            batch.getEndDate(),
            batch.getStatus(),
            batch.getCurrentTask(),
            escapeHtml4(batch.getLastMessage()), //
            batch.getItemCount(),
            HtmlUtils.countAndDetail(batch.getRejectedItemsId()), //
            batch.getLastUpdate(), //
            "<form action='?p=batch' method='post'><input type='submit' name='" //
                + CLEAR_ITEM
                + "' value='Delete' class='btn btn-small'/><input type=hidden name='" //
                + ITEM_UUID
                + "' value='"
                + escapeHtml4(batch.getUuid())
                + "'/></form>");
      }
      generateEndTable(sbErrorsBatchesBatchesTable, errorBatches.size());
    }

    valuesMap.put("confBatchesBatchesTable", sbConfBatchesBatchesTable.toString());
    valuesMap.put("runningBatchesBatchesTable", sbRunningBatchesBatchesTable.toString());
    valuesMap.put("finishedBatchesBatchesTable", sbFinishedBatchesBatchesTable.toString());
    valuesMap.put("errorsBatchesBatchesTable", sbErrorsBatchesBatchesTable.toString());
    valuesMap.put("clearActions", generateClearActions());

    String content = applyLayout(valuesMap, PAGECONTENTLAYOUT);

    valuesMap.clear();
    valuesMap.put("content", content);

    os.write(getPage(webHandler, valuesMap).getBytes(ENCODING));
  }