Ejemplo n.º 1
0
  /**
   * Checks to see if there have been any failed imports. If any are found then they are sent to be
   * re-done.
   */
  public void checkForFailedImports() {
    LOG.info("Check for missed data collections.");
    TypedQuery<ImportCheck> failedImportQuery =
        manager.createQuery("SELECT ic FROM ImportCheck ic WHERE ic.passed = 0", ImportCheck.class);

    List<ImportCheck> failedImports = failedImportQuery.getResultList();

    if (!failedImports.isEmpty()) {

      for (ImportCheck ic : failedImports) {

        String type = ic.getType();
        LocalDate failedDate = convertToLocalDate(ic.getCheckDate());

        LOG.info("Found a failed import for " + type + " on the " + failedDate.toString());

        if ("instrument".equals(type)) {
          counter.performInstrumentMetaCollection(failedDate, failedDate.plusDays(1));
        } else if ("investigation".equals(type)) {
          counter.performInvestigationMetaCollection(failedDate, failedDate.plusDays(1));

        } else if ("entity".equals(type)) {
          counter.performEntityCountCollection(failedDate, failedDate.plusDays(1));
        }
      }
    }
    LOG.info("Finished checking for missed data collections.");
  }
Ejemplo n.º 2
0
  /** * Initialises the collection of entity information from the ICAT into the Dashboard. */
  private void initialiseEntityCollection() {

    LocalDate today = LocalDate.now();

    LOG.info("Data Collection initiated for " + today.toString());

    LocalDate earliestEntityImport = getNextImportDate("entity");
    LocalDate earliestInstrumentImport = getNextImportDate("instrument");
    LocalDate earliestInvestigationImport = getNextImportDate("investigation");

    // Import data into Dashboard even if the import script has never been run
    if (earliestEntityImport == null
        && earliestInstrumentImport == null
        && earliestInvestigationImport == null) {
      LocalDate past = LocalDate.now().minusWeeks(1);
      counter.performEntityCountCollection(past, today);
      counter.performInstrumentMetaCollection(past, today);
      counter.performInvestigationMetaCollection(past, today);
    }

    // An actual import has happened.
    if (earliestEntityImport != null) {
      counter.performEntityCountCollection(earliestEntityImport, today);
    }
    if (earliestInstrumentImport != null) {
      counter.performInstrumentMetaCollection(earliestInstrumentImport, today);
    }
    if (earliestInvestigationImport != null) {
      counter.performInvestigationMetaCollection(earliestInvestigationImport, today);
    }

    LOG.info("Data collection completed for " + today.toString());
  }