コード例 #1
0
  @Override
  public String execute() throws Exception {
    TaskId taskId = new TaskId(TaskCategory.DATAMART, currentUserService.getCurrentUser());

    notifier.clear(taskId);

    ScheduledTasks tasks = new ScheduledTasks();

    // ---------------------------------------------------------------------
    // Analytics
    // ---------------------------------------------------------------------

    if (analytics) {
      analyticsTableTask.setTaskId(taskId);

      tasks.addTask(resourceTableTask);
      tasks.addTask(analyticsTableTask);
    }

    // ---------------------------------------------------------------------
    // Data mart
    // ---------------------------------------------------------------------

    if (dataMart) {
      Date start = DateUtils.getMediumDate(startDate);
      Date end = DateUtils.getMediumDate(endDate);

      List<Period> periods = new ArrayList<Period>();

      for (String type : periodTypes) {
        CalendarPeriodType periodType = (CalendarPeriodType) PeriodType.getPeriodTypeByName(type);

        periods.addAll(periodType.generatePeriods(start, end));
      }

      if (periods.size() > 0) {
        dataMartTask.setPeriods(periods);
        dataMartTask.setTaskId(taskId);

        tasks.addTask(dataMartTask);
      }
    }

    if (!tasks.isEmpty()) {
      scheduler.executeTask(tasks);
    }

    return SUCCESS;
  }
コード例 #2
0
  private void startAsyncImport(
      ImportOptions importOptions,
      HttpServletResponse response,
      HttpServletRequest request,
      MetaData metaData) {
    String userUid = currentUserService.getCurrentUser().getUid();

    TaskId taskId = new TaskId(TaskCategory.METADATA_IMPORT, currentUserService.getCurrentUser());

    scheduler.executeTask(
        new ImportMetaDataTask(userUid, importService, importOptions, taskId, metaData));

    response.setHeader(
        "Location",
        ContextUtils.getRootPath(request) + "/system/tasks/" + TaskCategory.METADATA_IMPORT);
    response.setStatus(HttpServletResponse.SC_ACCEPTED);
  }