當前位置: 首頁>>代碼示例>>Java>>正文


Java Constants類代碼示例

本文整理匯總了Java中org.gbif.api.model.Constants的典型用法代碼示例。如果您正苦於以下問題:Java Constants類的具體用法?Java Constants怎麽用?Java Constants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Constants類屬於org.gbif.api.model包,在下文中一共展示了Constants類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: suggest

import org.gbif.api.model.Constants; //導入依賴的package包/類
@Override
public List<NameUsageSuggestResult> suggest(NameUsageSuggestRequest request) {
  // add defaults
  if (!request.getParameters().containsKey(NameUsageSearchParameter.DATASET_KEY)) {
    // if the datasetKey parameters is not in the list, the GBIF nub is used by default
    request.addParameter(NameUsageSearchParameter.DATASET_KEY, Constants.NUB_DATASET_KEY.toString());
  }
  if (request.getLimit() < 1 || request.getLimit() > MAX_SUGGEST_LIMIT) {
    LOG.info("Suggest request with limit {} found. Reset to default {}", request.getLimit(), DEFAULT_SUGGEST_LIMIT);
    request.setLimit(DEFAULT_SUGGEST_LIMIT);
  }
  if (request.getOffset() > 0) {
    LOG.debug("Suggest request with offset {} found", request.getOffset());
  }

  // execute
  SolrQuery solrQuery = queryBuilder.build(request);
  QueryResponse response = query(solrQuery);
  return responseBuilder.buildSuggest(response);
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:21,代碼來源:NameUsageSearchServiceImpl.java

示例2: rematchChecklists

import org.gbif.api.model.Constants; //導入依賴的package包/類
private void rematchChecklists() {
  try {
    LOG.info("Start sending match dataset messages for all checklists, starting with CoL");

    int counter = 1;
    // make sure we match CoL first as we need that to analyze datasets (nub & col overlap of names)
    publisher.send(new MatchDatasetMessage(Constants.COL_DATASET_KEY));
    for (Dataset d : Iterables.datasets(DatasetType.CHECKLIST, datasetService)) {
      if (Constants.COL_DATASET_KEY.equals(d.getKey()) || Constants.NUB_DATASET_KEY.equals(d.getKey())) {
        continue;
      }
      publisher.send(new MatchDatasetMessage(d.getKey()));
      counter++;
    }
    LOG.info("Send dataset match message for all {} checklists", counter);

  } catch (Exception e) {
    LOG.error("Failed to handle BackboneChangedMessage", e);
  }
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:21,代碼來源:NubChangedService.java

示例3: doRun

import org.gbif.api.model.Constants; //導入依賴的package包/類
@Override
protected void doRun() {
  NubBuilder builder = NubBuilder.create(cfg);
  builder.run();
  builder.report(cfg.reportDir);

  if (cfg.autoImport) {
    try {
      MessagePublisher publisher = new DefaultMessagePublisher(cfg.messaging.getConnectionParameters());
      publisher.send(new ChecklistNormalizedMessage(Constants.NUB_DATASET_KEY));
      LOG.info("Sending ChecklistNormalizedMessage for backbone dataset {}", Constants.NUB_DATASET_KEY);
      publisher.close();
    } catch (IOException e) {
      Throwables.propagate(e);
    }
  }
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:18,代碼來源:NubBuildCommand.java

示例4: testMissingGenusFloraBrazil

import org.gbif.api.model.Constants; //導入依賴的package包/類
/**
 * http://dev.gbif.org/issues/browse/POR-2755
 */
@Test
public void testMissingGenusFloraBrazil() throws Exception {
  final UUID datasetKey = NormalizerTest.datasetKey(19);

  // insert neo db
  NormalizerStats stats = insertNeo(datasetKey);
  assertEquals(3, stats.getRoots());
  assertEquals(151, stats.getCount());
  assertEquals(62, stats.getSynonyms());
  assertEquals(3, stats.getCountByOrigin(Origin.VERBATIM_PARENT));
  assertEquals(1, stats.getCountByOrigin(Origin.VERBATIM_ACCEPTED));
  assertEquals(60, stats.getCountByOrigin(Origin.MISSING_ACCEPTED));
  assertEquals(87, stats.getCountByOrigin(Origin.SOURCE));

  // 1st import
  runImport(datasetKey);
  assertTrue(usageService.maxUsageKey(datasetKey) > Constants.NUB_MAXIMUM_KEY);
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:22,代碼來源:ImporterIT.java

示例5: getModules

import org.gbif.api.model.Constants; //導入依賴的package包/類
@Override
protected List<Module> getModules(Properties properties) {
  List<Module> modules = Lists.newArrayList();

  ChecklistBankServiceMyBatisModule clbMod = new ChecklistBankServiceMyBatisModule(properties);
  modules.add(clbMod);
  toBeClosed.add(clbMod);

  boolean incDeleted = PropertiesUtil.propertyAsBool(properties, INCL_DELETED, false);
  UUID datasetKey = UUID.fromString(properties.getProperty(NUB_DATASET_KEY, Constants.NUB_DATASET_KEY.toString()));
  NubMatchingModule nubMod = new NubMatchingModule(new File(properties.getProperty(INDEX_DIR)), incDeleted, datasetKey);
  modules.add(nubMod);
  toBeClosed.add(nubMod);
  // use the line below to run the webservice locally with the json test index data from the nub module
  // modules.add(new NubMatchingTestModule());
  return modules;
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:18,代碼來源:NubWsListener.java

示例6: insertNewUsage

import org.gbif.api.model.Constants; //導入依賴的package包/類
/**
 * @return the usage key for the inserted record
 */
private int insertNewUsage(NameUsage u, ParsedName pn, NameUsageMetrics metrics) {
  final UUID datasetKey = u.getDatasetKey();

  // insert main usage, creating name and citation records before
  NameUsageWritable uw = toWritable(datasetKey, u, pn, metrics);
  nameUsageMapper.insert(uw);
  u.setKey(uw.getKey());

  // update self references indicated by -1 so that the usage does not contain any bad foreign keys anymore
  // this is needed for subsequent syncing of solr!
  updateSelfReferences(u);

  // insert usage metrics
  metrics.setKey(uw.getKey());
  metricsMapper.insert(datasetKey, metrics);

  // insert nub mapping
  if (u.getNubKey() != null && !u.getDatasetKey().equals(Constants.NUB_DATASET_KEY)) {
    nubRelMapper.insert(datasetKey, u.getKey(), u.getNubKey());
  }

  return uw.getKey();
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:27,代碼來源:UsageSyncServiceMyBatis.java

示例7: updateUsage

import org.gbif.api.model.Constants; //導入依賴的package包/類
/**
 * Updates an existing usage record and all its related extensions.
 * Checking whether a usage has changed is a bit of work and error prone so we always update currently.
 * In the future we should try to update only when needed though. We would need to compare the usage itself,
 * the raw data, the usage metrics and all extension data in the container though.
 *
 * @param u updated usage
 */
private void updateUsage(NameUsage u, ParsedName pn, NameUsageMetrics metrics) {
  final UUID datasetKey = u.getDatasetKey();

  // update self references indicated by -1
  updateSelfReferences(u);
  // insert main usage, creating name and citation records before
  NameUsageWritable uw = toWritable(datasetKey, u, pn, metrics);
  nameUsageMapper.update(uw);

  // update usage metrics
  metrics.setKey(u.getKey());
  metricsMapper.update(metrics);

  // update nub mapping for non backbone records
  if (!Constants.NUB_DATASET_KEY.equals(u.getDatasetKey())) {
    nubRelMapper.delete(u.getKey());
    if (u.getNubKey() != null) {
      nubRelMapper.insert(datasetKey, u.getKey(), u.getNubKey());
    }
  }
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:30,代碼來源:UsageSyncServiceMyBatis.java

示例8: insertNubRelationBatch

import org.gbif.api.model.Constants; //導入依賴的package包/類
@Transactional(
    executorType = ExecutorType.BATCH,
    isolationLevel = TransactionIsolationLevel.READ_UNCOMMITTED,
    exceptionMessage = "Something went wrong while inserting nub relations batch for dataset {0}"
)
private void insertNubRelationBatch(UUID datasetKey, Map<Integer, Integer> relations, Iterable<Integer> usageKeyBatch) {
  for (Integer usageKey : usageKeyBatch) {
    Set<NameUsageIssue> issues = nameUsageMapper.getIssues(usageKey).getIssues();
    if (relations.get(usageKey) == null) {
      // no match, add issue if not existing yet
      if (!issues.contains(NameUsageIssue.BACKBONE_MATCH_NONE)) {
        issues.add(NameUsageIssue.BACKBONE_MATCH_NONE);
        nameUsageMapper.updateIssues(usageKey, issues);
      }

    } else {
      if (issues.remove(NameUsageIssue.BACKBONE_MATCH_NONE) || issues.remove(NameUsageIssue.BACKBONE_MATCH_FUZZY)) {
        nameUsageMapper.updateIssues(usageKey, issues);
      }
      nubRelMapper.insert(datasetKey, usageKey, relations.get(usageKey));
      // for CoL with its instable ids update source key
      if (Constants.COL_DATASET_KEY.equals(datasetKey)) {
        usageMapper.updateSourceTaxonKey(relations.get(usageKey), usageKey);
      }
    }
  }
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:28,代碼來源:UsageSyncServiceMyBatis.java

示例9: empty

import org.gbif.api.model.Constants; //導入依賴的package包/類
/**
 * Prepares an empty CLB db before any test is run, truncating tables and resetting sequence counters.
 */
public static ClbDbTestRule empty() {
  return new ClbDbTestRule(null, ImmutableMap.<String, Integer>builder()
      .put("citation_id_seq", 1)
      .put("dataset_metrics_id_seq", 1)
      .put("description_id_seq", 1)
      .put("distribution_id_seq", 1)
      .put("identifier_id_seq", 1)
      .put("literature_id_seq", 1)
      .put("media_id_seq", 1)
      .put("name_usage_id_seq", Constants.NUB_MAXIMUM_KEY + 1)
      .put("name_id_seq", 1)
      .put("species_info_id_seq", 1)
      .put("typification_id_seq", 1)
      .put("vernacular_name_id_seq", 1)
      .build());
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:20,代碼來源:ClbDbTestRule.java

示例10: load

import org.gbif.api.model.Constants; //導入依賴的package包/類
/**
 * Loads known usages from checklistbank backbone.
 */
public IdLookupImpl load(ClbConfiguration clb, boolean includeDeleted) throws SQLException, IOException {
  try (Connection c = clb.connect()) {
    final CopyManager cm = new CopyManager((BaseConnection) c);
    final String delClause = includeDeleted ? "" : " AND deleted is null";

    // first read bulk of regular usages - we add pro parte usage later
    LOG.info("Reading existing nub usages {}from postgres ...", includeDeleted ? "incl. deleted " : "");
    try (Writer writer = new UsageWriter()) {
      cm.copyOut("COPY ("
          + "SELECT u.id, coalesce(NULLIF(trim(n.canonical_name), ''), n.scientific_name), n.authorship, n.year, u.rank, u.kingdom_fk, deleted is not null"
          + " FROM name_usage u join name n ON name_fk=n.id"
          + " WHERE dataset_key = '" + Constants.NUB_DATASET_KEY + "'" + delClause + " AND pp_synonym_fk is null)"
          + " TO STDOUT WITH NULL ''", writer);
      LOG.info("Added {} nub usages into id lookup", usages.size());
    }
    final int uCount = usages.size();

    // now load pro parte keys separately saving us from doing complex aggregations
    LOG.info("Reading existing pro parte nub usages {}from postgres ...", includeDeleted ? "incl. deleted " : "");
    try (Writer writer = new ProParteUsageWriter()) {
      cm.copyOut("COPY ("
          + "SELECT u.id, u.parent_fk, u.pp_synonym_fk, coalesce(NULLIF(trim(n.canonical_name), ''), n.scientific_name), n.authorship, n.year, u.rank, u.kingdom_fk, deleted is not null"
          + " FROM name_usage u join name n ON name_fk=n.id"
          + " WHERE dataset_key = '" + Constants.NUB_DATASET_KEY + "'" + delClause + " AND pp_synonym_fk is not null"
          + " ORDER BY pp_synonym_fk)"
          + " TO STDOUT WITH NULL ''", writer);
      LOG.info("Added {} pro parte usages into id lookup", usages.size() - uCount);
    }
    LOG.info("Loaded existing nub with {} usages and max key {} into id lookup", usages.size(), keyMax);
  }
  return this;
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:36,代碼來源:IdLookupImpl.java

示例11: rootNub

import org.gbif.api.model.Constants; //導入依賴的package包/類
@GET
@Path("rootNub")
public TreeContainer<UsageCount, Integer> rootNub() {
  TreeContainer<UsageCount, Integer> tree = new TreeContainer<>();
  // kingdoms
  tree.setRoot(usageCountMapper.root(Constants.NUB_DATASET_KEY));
  for (UsageCount k : tree.getRoot()) {
    // phyla ~140, classes ~350, orders ~1400, families are over 22.000 skip
    addChildrenRecursively(tree, k.getKey(), 0, Rank.PHYLUM, Rank.CLASS, Rank.ORDER);
  }
  return tree;
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:13,代碼來源:SpeciesResource.java

示例12: searchTest

import org.gbif.api.model.Constants; //導入依賴的package包/類
@Test
public void searchTest() {
  NameUsageSearchRequest searchRequest = new NameUsageSearchRequest(DEFAULT_PARAM_OFFSET, DEFAULT_PARAM_LIMIT);
  searchRequest.setQ("puma");
  searchRequest.addFacets(NameUsageSearchParameter.DATASET_KEY);
  searchRequest.addParameter(NameUsageSearchParameter.DATASET_KEY, Constants.NUB_DATASET_KEY.toString());
  searchRequest.setMultiSelectFacets(true);
  SearchResponse<NameUsageSearchResult, NameUsageSearchParameter> response = wsClient.search(searchRequest);
  assertNotNull(response);
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:11,代碼來源:NameUsageSearchWsClientIT.java

示例13: searchTestWithNubKey

import org.gbif.api.model.Constants; //導入依賴的package包/類
@Test
public void searchTestWithNubKey() {
  NameUsageSearchRequest searchRequest = new NameUsageSearchRequest(DEFAULT_PARAM_OFFSET, DEFAULT_PARAM_LIMIT);
  searchRequest.setQ("oenanthe");
  searchRequest.addParameter(NameUsageSearchParameter.HIGHERTAXON_KEY, "3184223");
  searchRequest.addFacets(NameUsageSearchParameter.DATASET_KEY);
  searchRequest.addParameter(NameUsageSearchParameter.DATASET_KEY, Constants.NUB_DATASET_KEY.toString());
  SearchResponse<NameUsageSearchResult, NameUsageSearchParameter> response = wsClient.search(searchRequest);
  assertNotNull(response);
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:11,代碼來源:NameUsageSearchWsClientIT.java

示例14: searchSuggest

import org.gbif.api.model.Constants; //導入依賴的package包/類
/**
 * Utility method for testing suggest service.
 */
private List<NameUsageSuggestResult> searchSuggest(String q) {
  NameUsageSuggestRequest req = new NameUsageSuggestRequest();
  req.setQ(q);
  req.setLimit(50);
  req.addParameter(NameUsageSearchParameter.DATASET_KEY, Constants.NUB_DATASET_KEY.toString());
  return searchService.suggest(req);
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:11,代碼來源:NameUsageSearchServiceSuggestIT.java

示例15: findUsagesByCanonical

import org.gbif.api.model.Constants; //導入依賴的package包/類
private List<NameUsage> findUsagesByCanonical(String name, @Nullable Rank rank) {
  // avoid paging and do a large, single page
  PagingRequest req = new PagingRequest(0, 1000);
  List<NameUsage> matches = Lists.newArrayList();

  for (NameUsage u : usageService.listByCanonicalName(null, name, req, Constants.NUB_DATASET_KEY).getResults()) {
    if (rank == null || rank.equals(u.getRank())) {
      matches.add(u);
    }
  }
  return matches;
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:13,代碼來源:PgAssertionEngine.java


注:本文中的org.gbif.api.model.Constants類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。