コード例 #1
0
  /**
   * Executes an import by getting the parameters from the notification.
   *
   * @param notification the notification
   * @return the status of the import
   */
  protected ImportJobStatus executeImport(final ImportNotification notification) {
    ImportJob importJob = notification.getImportJob();

    // update the CSV file path with the local file path
    notification.setImportSource(getRemoteCsvFileName(notification.getImportSource()));

    // Validate again
    final ImportDataType importDataType =
        importService.findImportDataType(importJob.getImportDataTypeName());
    if (importDataType == null) {
      throw new EpSystemException(
          "ImportJob specifies unknown importDataType " + importJob.getImportDataTypeName());
    }

    ImportJobRunner importJobRunner =
        getImportJobRunner(importDataType.getImportJobRunnerBeanName());
    importJobRunner.init(notification, notification.getProcessId());

    updateTotalRowsNumber(importJobRunner.getTotalRows(), notification.getProcessId());

    importJobStatusHandler.reportImportJobState(
        notification.getProcessId(), ImportJobState.RUNNING);
    // Start the runner.
    LOG.info("Launch import job runner: " + importJobRunner);
    importJobRunner.run();

    return importJobStatusHandler.getImportJobStatus(notification.getProcessId());
  }
コード例 #2
0
  /**
   * Process the validation by using the import job runner.
   *
   * @param notification the notification
   * @return a list of bad rows
   */
  protected List<ImportBadRow> processValidation(final ImportNotification notification) {
    ImportJob importJob = notification.getImportJob();

    // update the CSV file path with the local file path
    notification.setImportSource(getRemoteCsvFileName(notification.getImportSource()));

    // Validate again
    final ImportDataType importDataType =
        importService.findImportDataType(importJob.getImportDataTypeName());
    if (importDataType == null) {
      throw new EpSystemException(
          "ImportJob specifies unknown importDataType " + importJob.getImportDataTypeName());
    }

    ImportJobRunner importJobRunner =
        getImportJobRunner(importDataType.getImportJobRunnerBeanName());
    importJobRunner.init(notification, notification.getProcessId());

    return importJobRunner.validate(notification.getReportingLocale());
  }