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


Java NameUsage.getOrigin方法代碼示例

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


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

示例1: count

import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
private void count(NameUsage u) {
    if (u.getOrigin() != null) {
        if (!countByOrigin.containsKey(u.getOrigin())) {
            countByOrigin.put(u.getOrigin(), 1);
        } else {
            countByOrigin.put(u.getOrigin(), countByOrigin.get(u.getOrigin()) + 1);
        }
    }
    if (u.getRank() != null) {
        if (!countByRank.containsKey(u.getRank())) {
            countByRank.put(u.getRank(), 1);
        } else {
            countByRank.put(u.getRank(), countByRank.get(u.getRank()) + 1);
        }
    }
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:17,代碼來源:UsageMetricsHandler.java

示例2: toObject

import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
/**
 * Takes a Generic object and transform it into a {@link org.apache.solr.common.SolrInputDocument}.
 *
 * @param usage container to be transformed into a {@link org.apache.solr.common.SolrInputDocument}.
 *              vernacular names, descriptions, species profiles and distributions are used, so populate them!
 *
 * @return a {@link org.apache.solr.common.SolrInputDocument} using the Object parameter.
 */
public static NameUsageAvro toObject(NameUsage usage, List<Integer> parents, @Nullable UsageExtensions extensions) {
  try {
    NameUsageAvro nameUsageAvro = new NameUsageAvro();
    nameUsageAvro.setKey(usage.getKey());
    nameUsageAvro.setNubKey(usage.getNubKey());
    if(usage.getDatasetKey() != null) {
      nameUsageAvro.setDatasetKey(usage.getDatasetKey().toString());
    }
    if(usage.getConstituentKey() != null) {
      nameUsageAvro.setConstituentKey(usage.getConstituentKey().toString());
    }
    nameUsageAvro.setParent(usage.getParent());
    nameUsageAvro.setParentKey(usage.getParentKey());
    nameUsageAvro.setAccepted(usage.getAccepted());
    nameUsageAvro.setAcceptedKey(usage.getAcceptedKey());
    nameUsageAvro.setBasionym(usage.getBasionym());
    nameUsageAvro.setBasionymKey(usage.getBasionymKey());
    nameUsageAvro.setScientificName(usage.getScientificName());
    nameUsageAvro.setCanonicalName(usage.getCanonicalName());
    nameUsageAvro.setAuthorship(usage.getAuthorship());
    nameUsageAvro.setPublishedIn(usage.getPublishedIn());
    nameUsageAvro.setAccordingTo(usage.getAccordingTo());
    nameUsageAvro.setKingdom(usage.getKingdom());
    nameUsageAvro.setKingdomKey(usage.getKingdomKey());
    nameUsageAvro.setPhylum(usage.getPhylum());
    nameUsageAvro.setPhylumKey(usage.getPhylumKey());
    nameUsageAvro.setClazz(usage.getClazz());
    nameUsageAvro.setClassKey(usage.getClassKey());
    nameUsageAvro.setOrder(usage.getOrder());
    nameUsageAvro.setOrderKey(usage.getOrderKey());
    nameUsageAvro.setFamily(usage.getFamily());
    nameUsageAvro.setFamilyKey(usage.getFamilyKey());
    nameUsageAvro.setGenus(usage.getGenus());
    nameUsageAvro.setGenusKey(usage.getGenusKey());
    nameUsageAvro.setSubgenus(usage.getSubgenus());
    nameUsageAvro.setSubgenusKey(usage.getSubgenusKey());
    nameUsageAvro.setSpecies(usage.getSpecies());
    nameUsageAvro.setSpeciesKey(usage.getSpeciesKey());
    nameUsageAvro.setNumDescendants(usage.getNumDescendants());
    nameUsageAvro.setIsSynonym(usage.isSynonym());

    // higher taxa
    nameUsageAvro.setHigherTaxonKey(parents);
    // enums
    if(usage.getNameType() != null) {
      nameUsageAvro.setNameType(usage.getNameType().ordinal());
    }
    nameUsageAvro.setIssues(getOrdinals(usage.getIssues()));
    nameUsageAvro.setNomenclaturalStatusKey(getOrdinals(usage.getNomenclaturalStatus()));
    if(usage.getOrigin() != null) {
      nameUsageAvro.setOriginKey(usage.getOrigin().ordinal());
    }
    if(usage.getTaxonomicStatus() != null) {
      nameUsageAvro.setTaxonomicStatusKey(usage.getTaxonomicStatus().ordinal());
    }
    if(usage.getRank() != null) {
      nameUsageAvro.setRankKey(usage.getRank().ordinal());
    }

    // extract extension infos
    if (extensions != null) {
      addVernacularNames(nameUsageAvro, extensions);
      addDescriptions(nameUsageAvro, extensions);
      addDistributionsAndThreatStatus(nameUsageAvro, extensions);
      addSpeciesProfiles(nameUsageAvro, extensions);
    }
    return nameUsageAvro;

  } catch (Exception e) {
    LOG.error("Error converting usage {} extension {} and parent {} to avro", usage, extensions, parents, e);
    throw new RuntimeException(e);
  }
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:82,代碼來源:NameUsageAvroConverter.java

示例3: testDenormedIndexFungorumSmall

import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
@Test
public void testDenormedIndexFungorumSmall() throws Exception {
  NormalizerStats stats = normalize(20);
  assertEquals(1, stats.getRoots());
  assertEquals(9, stats.getCountByOrigin(Origin.SOURCE));
  // all distinct higher taxa but the synonym genera and the explicit genus Chaetosphaeria
  assertEquals(24, stats.getCountByOrigin(Origin.DENORMED_CLASSIFICATION));
  assertEquals(33, stats.getCount());

  try (Transaction tx = beginTx()) {
    // make sure we only have one such genus
    NameUsage u = getUsageByCanonical("Chaetosphaeria");
    assertUsage("970",
        false,
        "Chaetosphaeria Tul. & C.Tul.",
        null,
        null,
        Rank.GENUS,
        "Chaetosphaeriaceae",
        "Chaetosphaeriales",
        "Sordariomycetes",
        "Ascomycota",
        "Fungi");

    // verify all denormed usages
    Map<String, Rank> expected = Maps.newHashMap();
    expected.put("Fungi", Rank.KINGDOM);
    expected.put("Ascomycota", Rank.PHYLUM);
    expected.put("Arthoniomycetes", Rank.CLASS);
    expected.put("Dothideomycetes", Rank.CLASS);
    expected.put("Incertae sedis", Rank.CLASS);
    expected.put("Lecanoromycetes", Rank.CLASS);
    expected.put("Sordariomycetes", Rank.CLASS);
    expected.put("Arthoniales", Rank.ORDER);
    expected.put("Capnodiales", Rank.ORDER);
    expected.put("Chaetosphaeriales", Rank.ORDER);
    expected.put("Lecanorales", Rank.ORDER);
    expected.put("Pleosporales", Rank.ORDER);
    expected.put("Triblidiales", Rank.ORDER);
    expected.put("Arthoniaceae", Rank.FAMILY);
    expected.put("Arthopyreniaceae", Rank.FAMILY);
    expected.put("Chaetosphaeriaceae", Rank.FAMILY);
    expected.put("Mycosphaerellaceae", Rank.FAMILY);
    expected.put("Parmeliaceae", Rank.FAMILY);
    expected.put("Triblidiaceae", Rank.FAMILY);
    expected.put("Arthopyrenia", Rank.GENUS);
    expected.put("Blitridium", Rank.GENUS);
    expected.put("Pseudocercospora", Rank.GENUS);
    expected.put("Septoria", Rank.GENUS);
    expected.put("Sphaerella", Rank.GENUS);

    for (Node n : Iterators.loop(dao.allTaxa())) {
      u = dao.readUsage(n, true);
      if (u.getOrigin() == Origin.DENORMED_CLASSIFICATION) {
        Rank r = expected.remove(u.getScientificName());
        if (r == null) {
          fail("Missing denormed usage " + u.getScientificName());
        } else if (!r.equals(u.getRank())) {
          fail("Wrong rank for denormed usage " + u.getScientificName());
        }
      }
    }
    assertTrue(expected.isEmpty());
  }
}
 
開發者ID:gbif,項目名稱:checklistbank,代碼行數:66,代碼來源:NormalizerTest.java


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