本文整理匯總了Java中org.gbif.api.model.checklistbank.NameUsage.getRank方法的典型用法代碼示例。如果您正苦於以下問題:Java NameUsage.getRank方法的具體用法?Java NameUsage.getRank怎麽用?Java NameUsage.getRank使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.gbif.api.model.checklistbank.NameUsage
的用法示例。
在下文中一共展示了NameUsage.getRank方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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());
}
示例2: 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);
}
}
}
示例3: testIdList
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
@Test
public void testIdList() throws SQLException {
final UUID datasetKey = NormalizerTest.datasetKey(1);
// insert neo db
insertNeo(datasetKey);
// import
runImport(datasetKey);
// test db, all usages must be accepted and there is one root!
PagingResponse<NameUsage> resp = nameUsageService.list(null, datasetKey, null, new PagingRequest(0, 500));
assertEquals(20, resp.getResults().size());
for (NameUsage u : resp.getResults()) {
assertEquals("Bad datasetKey", datasetKey, u.getDatasetKey());
if (u.isSynonym()) {
assertNotNull(u.getAcceptedKey());
assertNotNull(u.getAccepted());
} else {
assertNull(u.getAcceptedKey());
assertNull(u.getAccepted());
}
if (u.getRank() != Rank.KINGDOM) {
assertNotNull(u.getParentKey());
assertNotNull(u.getParent());
}
assertNotNull(u.getOrigin());
assertNotNull(u.getRank());
if (u.getRank().isLinnean()) {
if (u.isSynonym()) {
assertFalse("Higher classification key for synonym " + u.getScientificName() + " cannot point to itself!",
u.getKey().equals(ClassificationUtils.getHigherRankKey(u, u.getRank())));
} else {
assertEquals("Bad higher classification key for " + u.getScientificName() + " of rank " + u.getRank(),
u.getKey(), ClassificationUtils.getHigherRankKey(u, u.getRank()));
}
}
}
}
示例4: 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);
}
}
示例5: getStats
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
public NormalizerStats getStats() {
int roots = 0;
int depth = -1;
int synonyms = 0;
int ignored = 0;
Map<Origin, Integer> countByOrigin = Maps.newHashMap();
Map<Rank, Integer> countByRank = Maps.newHashMap();
for (Node n : dao.getNeo().getAllNodes()) {
if (!n.hasLabel(Labels.TAXON)) {
ignored++;
continue;
}
NameUsage u = dao.readUsage(n, false);
if (n.hasLabel(Labels.ROOT)) {
roots++;
}
// pro parte relations count as extra synonyms!
final int countAs = n.hasLabel(Labels.SYNONYM) ? (int) Iterables.count(Traversals.ACCEPTED.traverse(n).nodes()) : 1;
if (n.hasLabel(Labels.SYNONYM)) {
synonyms = synonyms + countAs;
if (!n.hasRelationship(RelType.SYNONYM_OF)) {
throw new IllegalStateException("Node "+n.getId()+" with synonym label but without synonymOf relationship found");
}
} else if (u.isSynonym()) {
throw new IllegalStateException("Node "+n.getId()+" without synonym label but usage has isSynonym=true");
}
if (!countByOrigin.containsKey(u.getOrigin())) {
countByOrigin.put(u.getOrigin(), countAs);
} else {
countByOrigin.put(u.getOrigin(), countByOrigin.get(u.getOrigin()) + countAs);
}
if (u.getRank() != null) {
if (!countByRank.containsKey(u.getRank())) {
countByRank.put(u.getRank(), countAs);
} else {
countByRank.put(u.getRank(), countByRank.get(u.getRank()) + countAs);
}
}
}
return new NormalizerStats(roots, depth, synonyms, ignored, countByOrigin, countByRank, Lists.<String>newArrayList());
}