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


Java NameUsage類代碼示例

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


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

示例1: list

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
public List<NameUsage> list(@Nullable UUID datasetKey, @Nullable String sourceId, @Nullable Locale ... locales)
throws IOException
   {
PagingResponse<NameUsage> response = list(null, datasetKey,sourceId, locales);
if (response == null)
    return null;
List<NameUsage> nameUsages = Lists.newArrayList(response.getResults());
boolean isInitial = true;
int limit = -1;
while(!Pager.isEndOfRecords(response)) {
    if(isInitial) {
	limit = Pager.getMaxLimit(response);
    }
    response.setOffset(response.getOffset() + response.getLimit());
    if(isInitial) {
	response.setLimit(limit);
	isInitial = false;
    }
    response = list(response, datasetKey,sourceId, locales);
    nameUsages.addAll(response.getResults());
}
return nameUsages;
   }
 
開發者ID:nomencurator,項目名稱:taxonaut,代碼行數:24,代碼來源:SpeciesAPIClient.java

示例2: listByCanonicalName

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
public List<NameUsage> listByCanonicalName(String canonicalName, @Nullable List<Locale> locales, @Nullable UUID ... datasetKey)
throws IOException
   {
PagingResponse<NameUsage> response = listByCanonicalName(null, canonicalName, locales, datasetKey);
if (response == null)
    return null;
List<NameUsage> nameUsages = Lists.newArrayList(response.getResults());
boolean isInitial = true;
int limit = -1;
while(!Pager.isEndOfRecords(response)) {
    if (isInitial) {
	limit = Pager.getMaxLimit(response);
    }
    response.setOffset(response.getOffset() + response.getLimit());
    if (isInitial) {
	response.setLimit(limit);
	isInitial = false;
    }
    response = listByCanonicalName(response, canonicalName, locales, datasetKey);
    nameUsages.addAll(response.getResults());
}

return nameUsages;
   }
 
開發者ID:nomencurator,項目名稱:taxonaut,代碼行數:25,代碼來源:SpeciesAPIClient.java

示例3: listChildren

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
@Override
   public List<NameUsage> listChildren(int parentKey, @Nullable Locale ... locales) {
PagingResponse<NameUsage> response = listChildren(null, parentKey, locales);
if (response == null) {
    return null;
}
List<NameUsage> result = Lists.newArrayList(response.getResults());
boolean isInitial = true;
int limit = -1;
while(!Pager.isEndOfRecords(response)) {
    if(isInitial) {
	limit = Pager.getMaxLimit(response);
    }
    response.setOffset(response.getOffset() + response.getLimit());
    if(isInitial) {
	response.setLimit(limit);
	isInitial = false;
    }
    response = listChildren(response, parentKey, locales);
    result.addAll(response.getResults());
}
return result;
   }
 
開發者ID:nomencurator,項目名稱:taxonaut,代碼行數:24,代碼來源:SpeciesAPIClient.java

示例4: listRelated

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
protected List<NameUsage> listRelated(int nubKey, @Nullable String languages, @Nullable List<Locale> locales, @Nullable UUID... datasetKey)
   {
PagingResponse<NameUsage> response = listRelated(nubKey, languages, locales, null, datasetKey);
if (response == null)
    return null;
List<NameUsage> result = Lists.newArrayList(response.getResults());
boolean isInitial = true;
int limit = -1;
while(!Pager.isEndOfRecords(response)) {
    if(isInitial) {
	limit = Pager.getMaxLimit(response);
    }
    response.setOffset(response.getOffset() + response.getLimit());
    if(isInitial) {
	response.setLimit(limit);
	isInitial = false;
    }
    response = listRelated(nubKey, languages, locales, response, datasetKey);
    result.addAll(response.getResults());
}
return result;
   }
 
開發者ID:nomencurator,項目名稱:taxonaut,代碼行數:23,代碼來源:SpeciesAPIClient.java

示例5: listRoot

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
@Override
   public List<NameUsage> listRoot(UUID datasetKey, @Nullable Locale ... locales) {
PagingResponse<NameUsage> response = listRoot(null, datasetKey, locales);
if (response == null)
    return null;
List<NameUsage> result = Lists.newArrayList(response.getResults());
boolean isInitial = true;
int limit = -1;
while(!Pager.isEndOfRecords(response)) {
    if(isInitial) {
	limit = Pager.getMaxLimit(response);
    }
    response.setOffset(response.getOffset() + response.getLimit());
    if(isInitial) {
	response.setLimit(limit);
	isInitial = false;
    }
    response = listRoot(response, datasetKey, locales);
    result.addAll(response.getResults());
}
return result;
   }
 
開發者ID:nomencurator,項目名稱:taxonaut,代碼行數:23,代碼來源:SpeciesAPIClient.java

示例6: listSynonyms

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
public List<NameUsage> listSynonyms(int usageKey, @Nullable Locale ... locales) {
PagingResponse<NameUsage> response = listSynonyms(null, usageKey,  locales);
if (response == null) {
    return null;
}
List<NameUsage> result = Lists.newArrayList(response.getResults());
boolean isInitial = true;
int limit = -1;
while(!Pager.isEndOfRecords(response)) {
    if(isInitial) {
	limit = Pager.getMaxLimit(response);
    }
    response.setOffset(response.getOffset() + response.getLimit());
    if(isInitial) {
	response.setLimit(limit);
	isInitial = false;
    }
    response = listSynonyms(response, usageKey,  locales);
    result.addAll(response.getResults());
}
return result;
   }
 
開發者ID:nomencurator,項目名稱:taxonaut,代碼行數:23,代碼來源:SpeciesAPIClient.java

示例7: get_w_not_null_locale

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
@Test
   public void get_w_not_null_locale () {
SpeciesAPIClient sut = new SpeciesAPIClient();
NameUsage expected = createNameUsage5231190(Locale.ENGLISH);
NameUsage actual = sut.get(5231190, Locale.ENGLISH);
/*
System.out.println("de:" + sut.get(5231190, Locale.GERMAN));
System.out.println("de:" + sut.get(107881308, Locale.GERMAN));
System.out.println("en:" + sut.get(107881308, Locale.ENGLISH));
System.out.println("es:" + sut.get(5231190, new Locale("es")));
System.out.println("sw:" + sut.get(5231190, new Locale("SWEDISH")));
System.out.println("ja:" + sut.get(5231190, new Locale("ja")));
System.out.println("kr:" + sut.get(5231190, new Locale("kr")));
System.out.println("zh:" + sut.get(5231190, new Locale("zh")));
*/

printObjects("get_w_not_null_locale", actual, expected);

assertThat(actual, is(expected));
   }
 
開發者ID:nomencurator,項目名稱:taxonaut,代碼行數:21,代碼來源:SpeciesAPIClientTest.java

示例8: testVernacularNames

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
@Test
public void testVernacularNames() throws Exception {
  ExtensionInterpreter interp = new ExtensionInterpreter();
  NameUsage u = new NameUsage();
  VerbatimNameUsage v = new VerbatimNameUsage();

  Map<Term, String> v1 = Maps.newHashMap();
  v1.put(DwcTerm.vernacularName, "palmeirinha");
  v1.put(DcTerm.language, "PORTUGUES");
  v1.put(DwcTerm.locality, "Acre");

  Map<Term, String> v2 = Maps.newHashMap();
  v2.put(DwcTerm.vernacularName, "ubim");
  v2.put(DcTerm.language, "PORTUGUES");
  v2.put(DwcTerm.locality, "Acre");

  v.getExtensions().put(Extension.VERNACULAR_NAME, Lists.newArrayList(v1, v2));

  UsageExtensions ext = interp.interpret(u, v);
  assertEquals(2, ext.vernacularNames.size());
  assertTrue(u.getIssues().isEmpty());
  assertEquals("palmeirinha", ext.vernacularNames.get(0).getVernacularName());
  assertEquals(Language.PORTUGUESE, ext.vernacularNames.get(0).getLanguage());
  assertEquals("Acre", ext.vernacularNames.get(0).getArea());
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:26,代碼來源:ExtensionInterpreterTest.java

示例9: insertOrUpdateByKey

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
private void insertOrUpdateByKey(Iterable<Integer> keys) {
  insertOrUpdate(Iterables.transform(keys, new Function<Integer, SolrUsage>() {
    @Nullable
    @Override
    public SolrUsage apply(Integer id) {
      int key = id;
      // we use the list service for just one record cause its more effective
      // leaving out fields that we do not index in solr
      List<NameUsage> range = usageService.listRange(key, key);
      if (range.isEmpty()) {
        return null;

      } else {
        NameUsage u = range.get(0);
        UsageExtensions ext = new UsageExtensions();
        ext.distributions = distributionService.listByUsage(key, page).getResults();
        ext.descriptions = descriptionService.listByUsage(key, page).getResults();
        ext.vernacularNames = vernacularNameService.listByUsage(key, page).getResults();
        ext.speciesProfiles = speciesProfileService.listByUsage(key, page).getResults();
        return new SolrUsage(u, usageService.listParents(key), ext);
      }
    }
  }));
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:25,代碼來源:NameUsageIndexServiceSolr.java

示例10: call

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
@Override
public List<NameUsage> call() throws Exception {
  insertOrUpdate(Lists.transform(usages, new Function<NameUsage, SolrUsage>() {
    @Override
    public SolrUsage apply(NameUsage u) {
      // the pro parte usage itself might not yet be synced...
      // so we get list of parent ids from parent which must exist in postgres already!
      List<Integer> parents = Lists.newArrayList();
      if (u.getAcceptedKey() != null) {
        parents.add(u.getAcceptedKey());
        parents.addAll(usageService.listParents(u.getAcceptedKey()));
      } else if (u.getParentKey() != null) {
        parents.add(u.getParentKey());
        parents.addAll(usageService.listParents(u.getParentKey()));
      }
      return new SolrUsage(u, parents,null);
    }
  }));
  return usages;
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:21,代碼來源:NameUsageIndexServiceSolr.java

示例11: assertClassification

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
@Override
public void assertClassification(int usageKey, String... classification) {
  Iterator<String> expected = Lists.newArrayList(classification).iterator();
  Iterator<NameUsage> parents = Lists.reverse(usageService.listParents(usageKey, null)).iterator();

  try {
    while (expected.hasNext()) {
      Assert.assertTrue(parents.hasNext());
      Assert.assertEquals(expected.next(), parents.next().getCanonicalName());
    }
    Assert.assertFalse(parents.hasNext());

  } catch (AssertionError e) {
    valid = false;
    LOG.error("Classification for usage {} wrong", usageKey, e);
  }
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:18,代碼來源:PgAssertionEngine.java

示例12: initNeo

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
@Override
public void initNeo(NeoUsageWriter writer) throws Exception {
  UsageDao dao = normalize();
  LOG.info("Import source usages");
  try (Transaction tx = dao.beginTx()) {
    for (Node n : dao.allNodes()) {
      NameUsage u = dao.readUsage(n, true);
      TaxonomicStatus status = u.getTaxonomicStatus();
      if (status == null) {
        status = u.isSynonym() ? TaxonomicStatus.SYNONYM : TaxonomicStatus.ACCEPTED;
      }
      String[] row = new String[8];
      row[0] = String.valueOf(n.getId());
      row[1] = nullsafeString(status.isSynonym() ? u.getAcceptedKey() : u.getParentKey());
      row[2] = nullsafeString(u.getBasionymKey());
      row[3] = nullsafeString(u.getRank());
      row[4] = status.name();
      //TODO: nom status
      row[5] = null;
      row[6] = u.getScientificName();
      row[7] = u.getPublishedIn();
      writer.addRow(row);
    }
  }
  dao.closeAndDelete();
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:27,代碼來源:DwcaSource.java

示例13: create

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
protected NameUsageNode create(NameUsage u, boolean isRoot) {
  Node n = dao.createTaxon();
  if (u.getTaxonomicStatus() != null && u.getTaxonomicStatus().isSynonym()) {
    n.addLabel(Labels.SYNONYM);
  }
  if (isRoot) {
    n.addLabel(Labels.ROOT);
  }

  // parse name and store it
  ParsedName pn = PARSER.parseQuietly(u.getScientificName(), u.getRank());
  dao.store(n.getId(), pn);

  // update canonical and store usage
  //u.setCanonicalName(pn.canonicalNameWithMarker());
  NameUsageNode nn = new NameUsageNode(n, u, true);
  dao.store(nn, true);

  return nn;
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:21,代碼來源:ImportDb.java

示例14: UsageDao

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
/**
 * @param kvp
 * @param neoDir
 * @param neoFactory
 * @param registry
 */
private UsageDao(DB kvp, File neoDir, @Nullable File kvpStore, GraphDatabaseBuilder neoFactory, @Nullable MetricRegistry registry) {
  try {
    this.neoFactory = neoFactory;
    this.neoDir = neoDir;
    this.kvpStore = kvpStore;
    this.kvp = kvp;
    this.registry = registry;

    names = createKvpMap("names", ParsedName.class, 128);
    facts = createKvpMap("facts", UsageFacts.class, 128);
    verbatim = createKvpMap("verbatim", VerbatimNameUsage.class, 512);
    usages = createKvpMap("usages", NameUsage.class, 256);
    extensions = createKvpMap("extensions", UsageExtensions.class, 512);
    srcUsages = createKvpMap("srcUsages", SrcUsage.class, 256);
    nubUsages = createKvpMap("nubUsages", NubUsage.class, 256);

    openNeo();
  } catch (Exception e) {
    LOG.error("Failed to initialize a new DAO", e);
    close();
    throw e;
  }
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:30,代碼來源:UsageDao.java

示例15: end

import org.gbif.api.model.checklistbank.NameUsage; //導入依賴的package包/類
@Override
public void end(Node n) {
    depth--;
    NameUsage u = dao.readUsage(n, false);
    // final data update
    NameUsageMetrics metrics = parentCounts.removeLast();
    metrics.setNumSynonyms(processSynonyms(n));
    metrics.setNumDescendants(counter - metrics.getNumDescendants());

    // persist data and classification with nub key
    UsageFacts facts = new UsageFacts();
    facts.metrics = metrics;
    facts.classification = classification;
    dao.store(n.getId(), facts);

    // remove this rank from current classification
    if (u.getRank() != null && u.getRank().isLinnean()) {
        ClassificationUtils.setHigherRankKey(classification, u.getRank(), null);
        ClassificationUtils.setHigherRank(classification, u.getRank(), null);
    }
    if (debug) LOG.info("end: {} {} {} #  {}-{}-{}", u.getTaxonID(), u.getRank(), u.getScientificName(), metrics.getNumDescendants(), metrics.getNumSynonyms(), parentCounts.size());
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:23,代碼來源:UsageMetricsHandler.java


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