Esempio n. 1
0
  /**
   * Loads a name usage and its checklist by the id parameter.
   *
   * @throws NotFoundException if no usage for the given id can be found
   */
  public void loadUsage() {
    if (id == null) {
      throw new NotFoundException("No checklist usage id given");
    }
    NameUsage u = usageService.get(id, getLocale());
    if (u == null) {
      throw new NotFoundException("No usage found with id " + id);
    }
    usage = new NameUsageContainer(u);
    // load checklist
    dataset = datasetService.get(usage.getDatasetKey());
    if (dataset == null) {
      throw new ReferentialIntegrityException(
          NameUsage.class, id, "Missing dataset " + usage.getDatasetKey());
    }

    try {
      metrics = metricsService.get(usage.getDatasetKey());
    } catch (ServiceUnavailableException e) {
      LOG.error("Failed to load checklist metrics for dataset {}", usage.getDatasetKey());
    }

    try {
      numOccurrences =
          occurrenceCubeService.get(new ReadBuilder().at(OccurrenceCube.NUB_KEY, usage.getKey()));
      numGeoreferencedOccurrences =
          occurrenceCubeService.get(
              new ReadBuilder()
                  .at(OccurrenceCube.NUB_KEY, usage.getKey())
                  .at(OccurrenceCube.IS_GEOREFERENCED, true));
    } catch (ServiceUnavailableException e) {
      LOG.error("Failed to load occurrence metrics for usage {}", usage.getKey(), e);
    }
  }
Esempio n. 2
0
 public boolean isNub() {
   return usage.isNub();
 }