Exemplo 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);
    }
  }
Exemplo n.º 2
0
 private String lookupTaxonKey(String value) {
   try {
     return nameUsageService.get(Integer.parseInt(value), null).getScientificName();
   } catch (Exception e) {
     LOG.warn("Cannot get name for usage {}", value);
   }
   return value;
 }