本文整理匯總了Java中org.gbif.api.model.checklistbank.NameUsage.setKey方法的典型用法代碼示例。如果您正苦於以下問題:Java NameUsage.setKey方法的具體用法?Java NameUsage.setKey怎麽用?Java NameUsage.setKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.gbif.api.model.checklistbank.NameUsage
的用法示例。
在下文中一共展示了NameUsage.setKey方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convert
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
private NameUsage convert(NubUsage nub) {
NameUsage u = new NameUsage();
u.setKey(nub.usageKey);
u.setConstituentKey(nub.datasetKey);
//TODO: add a scientificNameID property to NameUsage
//nub.scientificNameID
u.setTaxonID("gbif:" + nub.usageKey);
u.setScientificName(nub.parsedName.getScientificName());
u.setCanonicalName(canonicalOrScientificName(nub.parsedName));
u.setRank(nub.rank);
u.setTaxonomicStatus(nub.status);
u.setNomenclaturalStatus(nub.nomStatus);
u.setPublishedIn(nub.publishedIn);
u.setOrigin(nub.origin);
if (!nub.sourceIds.isEmpty()) {
u.setSourceTaxonKey(nub.sourceIds.getInt(0));
} else if (nub.origin.equals(Origin.SOURCE)) {
LOG.warn("Source usage without source id found {} {}", u.getKey(), u.getScientificName());
}
u.setRemarks(remarkJoiner.join(nub.remarks));
u.setIssues(nub.issues);
return u;
}
示例2: setUp
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
mockNameUsageService = mock(NameUsageService.class);
mockVernacularNameService = mock(VernacularNameService.class);
mockTypeSpecimenService = mock(TypeSpecimenService.class);
mockSpeciesProfileService = mock(SpeciesProfileService.class);
mockReferenceService = mock(ReferenceService.class);
mockImageService = mock(MultimediaService.class);
mockDescriptionService = mock(DescriptionService.class);
mockDistributionService = mock(DistributionService.class);
mockIdentifierService = mock(IdentifierService.class);
mockSearchService = mock(NameUsageSearchService.class);
mockUsageCountMapper = mock(UsageCountMapper.class);
searchResponse = new SearchResponse<NameUsageSearchResult, NameUsageSearchParameter>(0, 20);
searchResponse.setCount(1000L);
resource = new SpeciesResource(mockNameUsageService, mockVernacularNameService, mockTypeSpecimenService,
mockSpeciesProfileService, mockReferenceService, mockImageService, mockDescriptionService,
mockDistributionService, mockIdentifierService, mockSearchService, mockUsageCountMapper);
locale = Locale.US;
nameUsage = new NameUsage();
nameUsage.setKey(NAME_USAGE_KEY);
page = new PagingRequest(0, 1);
}
示例3: getMockObject
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
@Override
NameUsage getMockObject() {
NameUsage usage = new NameUsage();
usage.setDatasetKey(datasetKey);
usage.setKey(key);
return usage;
}
示例4: syncProParte
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
private void syncProParte() {
if (!proParteNodes.isEmpty()) {
LOG.info("Syncing {} pro parte usages", proParteNodes.size());
for (List<Long> ids : Iterables.partition(proParteNodes, cfg.chunkSize)) {
List<NameUsage> usages = Lists.newArrayList();
List<ParsedName> names = Lists.newArrayList();
try (Transaction tx = dao.getNeo().beginTx()) {
for (Long id : ids) {
Node n = dao.getNeo().getNodeById(id);
NameUsage primary = readUsage(n);
ParsedName pn = readName(id);
// modify as a template for all cloned pro parte usages
primary.setProParteKey(primary.getKey());
primary.setOrigin(Origin.PROPARTE);
primary.setTaxonID(null); // if we keep the original id we will do an update, not an insert
primary.setParentKey(null);
for (Relationship rel : n.getRelationships(RelType.PROPARTE_SYNONYM_OF, Direction.OUTGOING)) {
// pro parte synonyms keep their id in the relation, read it
// http://dev.gbif.org/issues/browse/POR-2872
NameUsage u = clone(primary);
u.setKey( (Integer) rel.getProperty(NeoProperties.USAGE_KEY, null));
Node accN = rel.getEndNode();
// all nodes should be synced by now, so clb keys must be known
u.setAcceptedKey(clbKeys.get((int) accN.getId()));
// use accepted taxon classification for this synonym record
applyClbClassification(u, accN.getId());
usages.add(u);
names.add(pn);
}
}
}
// submit sync job
syncCounterProParte = syncCounterProParte + usages.size();
proParteFuture = sqlService.sync(datasetKey, this, usages, names);
}
}
}
示例5: usage
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
public static NameUsage usage(int key, Rank rank) {
NameUsage u = new NameUsage();
u.setKey(key);
u.setKingdomKey(key);
u.setParentKey(key);
u.setAcceptedKey(key);
u.setScientificName("Abies alba Mill.");
u.setCanonicalName("Abies alba");
u.setRank(rank);
u.setTaxonomicStatus(TaxonomicStatus.ACCEPTED);
return u;
}
示例6: getUsageByNode
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
private NameUsage getUsageByNode(Node n) {
NameUsage u = null;
if (n != null) {
u = dao.readUsage(n, true);
if (u != null) {
u.setKey((int)n.getId());
}
}
return u;
}
示例7: createNameUsage5231190
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
private NameUsage createNameUsage5231190(Locale locale) {
NameUsage nameUsage = new NameUsage();
nameUsage.setKey(5231190);
nameUsage.setKingdom("Animalia");
nameUsage.setPhylum("Chordata");
nameUsage.setClazz("Aves");
nameUsage.setOrder("Passeriformes");
nameUsage.setFamily("Passeridae");
nameUsage.setGenus("Passer");
nameUsage.setSpecies("Passer domesticus");
nameUsage.setKingdomKey(1);
nameUsage.setPhylumKey(44);
nameUsage.setClassKey(212);
nameUsage.setOrderKey(729);
nameUsage.setFamilyKey(5264);
nameUsage.setGenusKey(2492321);
nameUsage.setSpeciesKey(5231190);
nameUsage.setDatasetKey(UUID.fromString("d7dddbf4-2cf0-4f39-9b2a-bb099caae36c"));
nameUsage.setNubKey(5231190);
nameUsage.setParentKey(2492321);
nameUsage.setParent("Passer");
nameUsage.setScientificName("Passer domesticus (Linnaeus, 1758)");
nameUsage.setCanonicalName("Passer domesticus");
if(locale != null) {
if(locale.equals(Locale.ENGLISH))
nameUsage.setVernacularName("House Sparrow");
}
nameUsage.setAuthorship(" (Linnaeus, 1758)");
nameUsage.setNameType(NameType.SCIENTIFIC);
nameUsage.setRank(Rank.SPECIES);
nameUsage.setOrigin(Origin.SOURCE);
nameUsage.setTaxonomicStatus(TaxonomicStatus.ACCEPTED);
//nameUsage.setNomenclaturalStatus();
nameUsage.setAccordingTo("The Catalogue of Life, 3rd January 2011");
nameUsage.setNumDescendants(12);
// nameUsage.setSourceId("119127243");
nameUsage.setTaxonID("119127243");
/*
nameUsage.setSynonym(false);
Identifier identifier = new Identifier();
identifier.setKey(3191745);
identifier.setUsageKey(5231190);
identifier.setDatasetKey(UUID.fromString("d7dddbf4-2cf0-4f39-9b2a-bb099caae36c"));
identifier.setIdentifier("119127243");
// identifier.setType(IdentifierType.SOURCE_ID);
List<Identifier> identifiers = newArrayList();
identifiers.add(identifier);
nameUsage.setIdentifiers(identifiers);
*/
nameUsage.setModified(parseDateTime("2013-02-08T03:15:41.847+0000"));
nameUsage.setLastInterpreted(parseDateTime("2014-11-03T15:22:26.302+0000"));
return nameUsage;
}
示例8: list_wo_page
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
@Test
public void list_wo_page() {
PagingResponse<NameUsage> expected = new PagingResponse<NameUsage>(0,20);
expected.setEndOfRecords(true);
List<NameUsage> results = newArrayList();
expected.setResults(results);
NameUsage result = new NameUsage();
results.add(result);
result.setKey(113490264);
result.setKingdom("Plantae");
result.setPhylum("Magnoliophyta");
result.setClazz("Magnoliopsida");
result.setOrder("Sapindales");
result.setFamily("Sapindaceae");
result.setGenus("Acer");
result.setSpecies("Acer sterculiaceum");
result.setKingdomKey(127971322);
result.setPhylumKey(127971328);
result.setClassKey(127971374);
result.setOrderKey(127971477);
result.setFamilyKey(127971478);
result.setGenusKey(127971479);
result.setSpeciesKey(113490264);
result.setDatasetKey(UUID.fromString("00a0607f-fd7e-4268-9707-0f53aa265f1f"));
result.setNubKey(7262989);
result.setParentKey(127971479);
result.setParent("Acer");
result.setScientificName("Acer sterculiaceum");
result.setCanonicalName("Acer sterculiaceum");
result.setAuthorship("");
result.setNameType(NameType.SCIENTIFIC);
result.setRank(Rank.SPECIES);
result.setOrigin(Origin.SOURCE);
result.setNumDescendants(0);
/*
Identifier identifier = new Identifier();
result.addIdentifier(identifier);
identifier.setKey(12524207);
identifier.setUsageKey(113490264);
identifier.setDatasetKey(UUID.fromString("00a0607f-fd7e-4268-9707-0f53aa265f1f"));
identifier.setIdentifier("ICIMOD_Barsey_Plants_001");
// identifier.setType(IdentifierType.SOURCE_ID);
*/
result.setTaxonID("ICIMOD_Barsey_Plants_001");
result.setModified(parseDateTime("2013-12-12T13:56:13.204+0000"));
result.setLastInterpreted(parseDateTime("2014-11-03T15:22:26.302+0000"));
// result.setSynonym(false);
SpeciesAPIClient sut = new SpeciesAPIClient();
PagingResponse<NameUsage> actual = sut.list(Locale.ENGLISH, UUID.fromString("00a0607f-fd7e-4268-9707-0f53aa265f1f"),"ICIMOD_Barsey_Plants_001",null);
printCollections("list_wo_page", actual.getResults(), results);
assertThat(actual, is(expected));
}
示例9: createSynonyms100710497
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
/**
* Creates response to http://api.gbif.org/v1/species/100710497/synonyms
*/
private PagingResponse<NameUsage> createSynonyms100710497 ()
{
PagingResponse<NameUsage> expected = new PagingResponse<NameUsage>(0,20);
expected.setEndOfRecords(true);
List<NameUsage> results = newArrayList();
expected.setResults(results);
NameUsage result = new NameUsage();
results.add(result);
result.setKey(102382983);
result.setNubKey(3204909);
result.setTaxonID("1290714");
result.setKingdom("Protista");
result.setPhylum("Ciliophora");
result.setClazz("Oligohymenophora");
result.setOrder("Scuticociliatida");
result.setFamily("Cohnilembidae");
result.setGenus("Cohnilembus");
result.setKingdomKey(102545060);
result.setPhylumKey(102545140);
result.setClassKey(102514394);
result.setOrderKey(102143947);
result.setFamilyKey(102238321);
result.setGenusKey(100710497);
result.setDatasetKey(UUID.fromString("0938172b-2086-439c-a1dd-c21cb0109ed5"));
result.setParentKey(102238321);
result.setParent("Cohnilembidae");
result.setAcceptedKey(100710497);
result.setAccepted("Cohnilembus Kahl, 1933");
result.setScientificName("Lembus Cohn, 1866");
result.setCanonicalName("Lembus");
result.setAuthorship("Cohn, 1866");
result.setNameType(NameType.SCIENTIFIC);
result.setRank(Rank.GENUS);
result.setOrigin(Origin.SOURCE);
result.setTaxonomicStatus(TaxonomicStatus.SYNONYM);
result.setRemarks("See Cohnilembus Kahl 1933. (Nomen. Zool.).");
result.setPublishedIn("Z. wiss. Zool. , 16, 270.");
result.setAccordingTo("SN2000 unverified; Nomenclator Zoologicus");
result.setNumDescendants(0);
result.setModified(parseDateTime("2014-06-15T15:45:33.692+0000"));
result.setLastInterpreted(parseDateTime("2014-11-03T15:22:26.302+0000"));
result.setSynonym(true);
return expected;
}
示例10: createSynonyms126926284
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
/**
* Creates response to http://api.gbif.org/v1/species/126926284/synonyms
*/
private PagingResponse<NameUsage> createSynonyms126926284 () {
PagingResponse<NameUsage> expected = new PagingResponse<NameUsage>(0,20);
expected.setEndOfRecords(true);
List<NameUsage> results = newArrayList();
expected.setResults(results);
NameUsage result = new NameUsage();
results.add(result);
result.setKey(100496585);
result.setKingdom("Protista");
result.setPhylum("Ciliophora");
result.setClazz("Oligohymenophora");
result.setOrder("Scuticociliatida");
result.setFamily("Cohnilembidae");
result.setKingdomKey(126940483);
result.setPhylumKey(100533110);
result.setClassKey(126940663);
result.setOrderKey(126940683);
result.setFamilyKey(126940686);
result.setDatasetKey(UUID.fromString("714c64e3-2dc1-4bb7-91e4-54be5af4da12"));
result.setNubKey(3204909);
result.setParentKey(126940686);
result.setParent("Cohnilembidae");
result.setAcceptedKey(126926284);
result.setAccepted("Cohnilembus");
result.setScientificName("Lembus Cohn, 1866");
result.setCanonicalName("Lembus");
result.setAuthorship("Cohn, 1866");
result.setNameType(NameType.SCIENTIFIC);
result.setRank(Rank.GENUS);
result.setOrigin(Origin.SOURCE);
result.setTaxonomicStatus(TaxonomicStatus.SYNONYM);
result.setRemarks("See Cohnilembus Kahl 1933. (Nomen. Zool.).");
result.setPublishedIn("Z. wiss. Zool. , 16, 270.");
result.setAccordingTo("SN2000 unverified; Nomenclator Zoologicus");
result.setNumDescendants(0);
/*
Identifier identifier = new Identifier();
result.addIdentifier(identifier);
identifier.setKey(4467557);
identifier.setUsageKey(100496585);
identifier.setDatasetKey(UUID.fromString("714c64e3-2dc1-4bb7-91e4-54be5af4da12"));
identifier.setIdentifier("1290714");
// identifier.setType(IdentifierType.SOURCE_ID);
*/
// result.setTaxonID("1290714");
result.setSynonym(true);
return expected;
}
示例11: testToObject
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
@Test
public void testToObject() throws Exception {
NameUsageDocConverter conv = new NameUsageDocConverter();
NameUsage u = new NameUsage();
u.setKey(12);
u.setDatasetKey(UUID.randomUUID());
u.setScientificName("Abies alba Mill.");
u.setCanonicalName("Abies alba");
u.setRank(Rank.SPECIES);
u.setOrigin(Origin.SOURCE);
u.setTaxonomicStatus(TaxonomicStatus.ACCEPTED);
u.setParentKey(1);
u.setFamilyKey(1024);
u.setFamily("Pinaceae");
u.getIssues().add(NameUsageIssue.RANK_INVALID);
u.getIssues().add(NameUsageIssue.CLASSIFICATION_NOT_APPLIED);
UsageExtensions ext = new UsageExtensions();
SpeciesProfile sp = new SpeciesProfile();
sp.setTerrestrial(true);
sp.setHabitat("brackish");
ext.speciesProfiles.add(sp);
VernacularName v1 = new VernacularName();
v1.setLanguage(Language.GERMAN);
v1.setVernacularName("Weißtanne");
VernacularName v2 = new VernacularName();
v2.setLanguage(Language.GERMAN);
v2.setVernacularName("Kohl Tanne");
ext.vernacularNames.add(v1);
ext.vernacularNames.add(v2);
SolrInputDocument doc = conv.toDoc(u, Lists.newArrayList(12, 15, 20, 100), ext);
assertEquals(u.getKey(), doc.get("key").getValue());
assertEquals(u.getDatasetKey().toString(), doc.get("dataset_key").getValue());
assertEquals(u.getParentKey(), doc.get("parent_key").getValue());
assertEquals(u.getFamily(), doc.get("family").getValue());
assertEquals(u.getFamilyKey(), doc.get("family_key").getValue());
assertEquals(u.getScientificName(), doc.get("scientific_name").getValue());
assertEquals(u.getCanonicalName(), doc.get("canonical_name").getValue());
assertEquals(u.getOrigin().ordinal(), doc.get("origin_key").getValue());
assertEquals(u.getTaxonomicStatus().ordinal(), doc.get("taxonomic_status_key").getValue());
assertEquals(u.getRank().ordinal(), doc.get("rank_key").getValue());
assertThat((List<Integer>) doc.get("issues").getValue()).contains(NameUsageIssue.RANK_INVALID.ordinal(),
NameUsageIssue.CLASSIFICATION_NOT_APPLIED.ordinal());
assertThat((List<Integer>) doc.get("habitat_key").getValue()).containsOnlyOnce(Habitat.TERRESTRIAL.ordinal(), Habitat.FRESHWATER.ordinal());
assertThat((List<Integer>) doc.get("higher_taxon_key").getValue()).containsOnlyOnce(12, 15, 20, 100);
// trip back
NameUsageSearchResult u2 = conv.toSearchUsage(ClientUtils.toSolrDocument(doc), true);
assertEquals(ClassificationUtils.getHigherClassificationMap(u2), ClassificationUtils.getHigherClassificationMap(u));
assertEquals(u2.getKey(), u.getKey());
assertEquals(u2.getDatasetKey(), u.getDatasetKey());
assertEquals(u2.getParentKey(), u.getParentKey());
assertEquals(u2.getScientificName(), u.getScientificName());
assertEquals(u2.getCanonicalName(), u.getCanonicalName());
assertEquals(u2.getOrigin(), u.getOrigin());
assertEquals(u2.getTaxonomicStatus(), u.getTaxonomicStatus());
assertEquals(u2.getRank(), u.getRank());
}
示例12: readUsage
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
/**
* Reads the full name usage from neo and updates all foreign keys to use CLB usage keys.
*/
private NameUsage readUsage(Node n) {
// this is using neo4j internal node ids as keys:
NameUsage u = dao.readUsage(n, true);
Preconditions.checkNotNull(u, "Node %s not found in kvp store", n.getId());
Integer id = (int) n.getId();
if (clbKeys.containsKey(id)) {
u.setKey(clbKeys.get(id));
}
UsageFacts facts;
if (n.hasLabel(Labels.SYNONYM)) {
// use the classification of the parent in case of synonyms
facts = dao.readFacts(u.getAcceptedKey());
u.setTaxonomicStatus(u.getTaxonomicStatus() == null ? TaxonomicStatus.SYNONYM : u.getTaxonomicStatus());
u.setAcceptedKey(clbForeignKey(n.getId(), u.getAcceptedKey(), KeyType.ACCEPTED));
} else {
facts = dao.readFacts(n.getId());
u.setTaxonomicStatus(u.getTaxonomicStatus() == null ? TaxonomicStatus.ACCEPTED : u.getTaxonomicStatus());
u.setParentKey(clbForeignKey(n.getId(), u.getParentKey(), KeyType.PARENT));
}
if (facts != null && facts.classification != null) {
ClassificationUtils.copyLinneanClassificationKeys(facts.classification, u);
ClassificationUtils.copyLinneanClassification(facts.classification, u);
}
u.setBasionymKey(clbForeignKey(n.getId(), u.getBasionymKey(), KeyType.BASIONYM));
for (Rank r : Rank.DWC_RANKS) {
try {
ClassificationUtils.setHigherRankKey(u, r, clbForeignKey(n.getId(), u.getHigherRankKey(r), KeyType.CLASSIFICATION));
} catch (IllegalStateException e) {
LOG.error("{} (nodeID={}) has unprocessed {} reference to nodeId {}", n.getProperty(NeoProperties.SCIENTIFIC_NAME, "no name"), n.getId(), r, u.getHigherRankKey(r));
throw e;
}
}
u.setDatasetKey(datasetKey);
// update usage status and ppkey for primary pro parte usages
if (isProParteNode(n)) {
u.setTaxonomicStatus(TaxonomicStatus.PROPARTE_SYNONYM);
u.setProParteKey(SELF_ID);
}
return u;
}
示例13: testRegularImport
import org.gbif.api.model.checklistbank.NameUsage; //導入方法依賴的package包/類
/**
* pro parte usages are synced differently and not tested here
*/
@Test
public void testRegularImport() throws ExecutionException, InterruptedException {
ParsedName pn = new ParsedName();
pn.setGenusOrAbove("Abies");
pn.setSpecificEpithet("alba");
pn.setAuthorship("Mill.");
pn.setScientificName(pn.fullName());
pn.setType(NameType.SCIENTIFIC);
NameUsage u = new NameUsage();
u.setKey(USAGE_ID);
u.setScientificName(pn.getScientificName());
u.setCanonicalName(pn.canonicalName());
u.setNameType(pn.getType());
u.setAuthorship(pn.getAuthorship());
u.setRank(Rank.SPECIES);
u.setDatasetKey(Constants.NUB_DATASET_KEY);
u.setOrigin(Origin.SOURCE);
u.getIssues().add(NameUsageIssue.CONFLICTING_BASIONYM_COMBINATION);
u.getIssues().add(NameUsageIssue.ACCEPTED_NAME_MISSING);
UsageExtensions ext = new UsageExtensions();
VerbatimNameUsage v = new VerbatimNameUsage();
NameUsageMetrics m = new NameUsageMetrics();
DummyData data = new DummyData(u, pn, ext, v, m);
Future<?> f = service.sync(u.getDatasetKey(), data, Lists.newArrayList(1));
f.get();
NameUsageService usageService = getInstance(NameUsageService.class);
NameUsage u2 = usageService.get(USAGE_ID, null);
u2.setLastInterpreted(null);
// name key is newly assigned
u.setNameKey(u2.getNameKey());
u.setNameKey(u2.getNameKey());
assertNotNull(u.getNameKey());
assertFalse(u2.getIssues().isEmpty());
assertEquals(u, u2);
}