本文整理汇总了Java中org.gbif.api.vocabulary.Extension类的典型用法代码示例。如果您正苦于以下问题:Java Extension类的具体用法?Java Extension怎么用?Java Extension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Extension类属于org.gbif.api.vocabulary包,在下文中一共展示了Extension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interpretVernacularNames
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
private void interpretVernacularNames(NameUsage u, UsageExtensions e, VerbatimNameUsage v) {
if (v.hasExtension(Extension.VERNACULAR_NAME)) {
for (Map<Term, String> rec : v.getExtensions().get(Extension.VERNACULAR_NAME)) {
VernacularName vn = new VernacularName();
vn.setVernacularName(value(rec, DwcTerm.vernacularName));
if (vn.getVernacularName() == null) {
u.addIssue(NameUsageIssue.VERNACULAR_NAME_INVALID);
continue;
}
// locationID > locality
vn.setArea(value(rec, DwcTerm.locationID, DwcTerm.locality));
vn.setCountry(enumify(rec, null, countryParser, u,
DwcTerm.countryCode, DwcTerm.country, DwcTerm.locationID, DwcTerm.locality));
vn.setLanguage(enumify(rec, NameUsageIssue.VERNACULAR_NAME_INVALID, languageParser, u, DcTerm.language));
vn.setLifeStage(enumify(rec, NameUsageIssue.VERNACULAR_NAME_INVALID, lifeStageParser, u, DwcTerm.lifeStage));
vn.setPlural(bool(rec, NameUsageIssue.VERNACULAR_NAME_INVALID, u, GbifTerm.isPlural));
vn.setPreferred(bool(rec, NameUsageIssue.VERNACULAR_NAME_INVALID, u, GbifTerm.isPreferredName));
vn.setSex(enumify(rec, NameUsageIssue.VERNACULAR_NAME_INVALID, sexParser, u, DwcTerm.sex));
vn.setSource(value(rec, DcTerm.source));
// interpret rec
e.vernacularNames.add(vn);
}
}
}
示例2: interpretTypes
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
/**
* We only keep type names and ignore specimens...
*/
private void interpretTypes(NameUsage u, UsageExtensions e, VerbatimNameUsage v) {
if (v.hasExtension(Extension.TYPES_AND_SPECIMEN)) {
for (Map<Term, String> rec : v.getExtensions().get(Extension.TYPES_AND_SPECIMEN)) {
TypeSpecimen t = new TypeSpecimen();
// interpret
t.setScientificName(expandGenus(value(rec, DwcTerm.scientificName), u.getScientificName()));
if (t.getScientificName() == null || t.getScientificName().equalsIgnoreCase(u.getScientificName())) {
LOG.debug("Ignore type name for {} as the name is the same as the taxon", u.getScientificName());
continue;
}
t.setTypeDesignatedBy(value(rec, GbifTerm.typeDesignatedBy));
t.setTypeStatus(enumify(rec, null, typeStatusParser, u, DwcTerm.typeStatus));
t.setSource(value(rec, DcTerm.source));
//t.setCitation(value(rec, DcTerm.bibliographicCitation));
//t.setTypeDesignationType(value(rec, GbifTerm.typeDesignatedType));
e.typeSpecimens.add(t);
}
}
}
示例3: interpretSpeciesProfiles
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
private void interpretSpeciesProfiles(NameUsage u, UsageExtensions e, VerbatimNameUsage v) {
if (v.hasExtension(Extension.SPECIES_PROFILE)) {
for (Map<Term, String> rec : v.getExtensions().get(Extension.SPECIES_PROFILE)) {
SpeciesProfile s = new SpeciesProfile();
// interpret rec
s.setSource(value(rec, DcTerm.source));
s.setAgeInDays(integer(rec, NameUsageIssue.SPECIES_PROFILE_INVALID, u, GbifTerm.ageInDays));
s.setMassInGram(integer(rec, NameUsageIssue.SPECIES_PROFILE_INVALID, u, GbifTerm.massInGram));
s.setSizeInMillimeter(integer(rec, NameUsageIssue.SPECIES_PROFILE_INVALID, u, GbifTerm.sizeInMillimeter));
s.setHybrid(bool(rec, NameUsageIssue.SPECIES_PROFILE_INVALID, u, GbifTerm.isHybrid));
s.setMarine(bool(rec, NameUsageIssue.SPECIES_PROFILE_INVALID, u, GbifTerm.isMarine));
s.setFreshwater(bool(rec, NameUsageIssue.SPECIES_PROFILE_INVALID, u, GbifTerm.isFreshwater));
s.setTerrestrial(bool(rec, NameUsageIssue.SPECIES_PROFILE_INVALID, u, GbifTerm.isTerrestrial));
s.setExtinct(bool(rec, NameUsageIssue.SPECIES_PROFILE_INVALID, u, GbifTerm.isExtinct));
s.setLivingPeriod(value(rec, GbifTerm.livingPeriod));
s.setLifeForm(value(rec, GbifTerm.lifeForm));
s.setHabitat(value(rec, DwcTerm.habitat));
e.speciesProfiles.add(s);
}
}
}
示例4: interpretReference
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
private void interpretReference(NameUsage u, UsageExtensions e, VerbatimNameUsage v) {
if (v.hasExtension(Extension.REFERENCE)) {
for (Map<Term, String> rec : v.getExtensions().get(Extension.REFERENCE)) {
Reference r = new Reference();
// interpret rec
r.setType(value(rec, DcTerm.type));
r.setCitation(value(rec, DcTerm.bibliographicCitation));
r.setTitle(value(rec, DcTerm.title));
r.setAuthor(value(rec, DcTerm.creator));
r.setDate(value(rec, DcTerm.date, DcTerm.created));
r.setSource(value(rec, DcTerm.source));
r.setRemarks(value(rec, DwcTerm.taxonRemarks));
// TODO: need to check this mapping!
r.setDoi(value(rec, DcTerm.identifier));
r.setLink(value(rec, DcTerm.references));
e.referenceList.add(r);
}
}
}
示例5: interpretMultimedia
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
private void interpretMultimedia(NameUsage u, UsageExtensions e, VerbatimNameUsage v) {
extractMedia(u, e, v, Extension.IMAGE, false);
extractMedia(u, e, v, Extension.MULTIMEDIA, false);
extractMedia(u, e, v, Extension.EOL_MEDIA, true);
extractMedia(u, e, v, Extension.AUDUBON, false);
extractMediaCore(u, e, v);
/**
* merges media records if the same image URL or link is given several times.
* Remove any media that has not either a file or webpage uri.
*/
Map<String, NameUsageMediaObject> media = Maps.newLinkedHashMap();
for (NameUsageMediaObject m : e.media) {
// we can get file uris or weblinks. Prefer file URIs as they clearly identify a single image
URI uri = m.getIdentifier() != null ? m.getIdentifier() : m.getReferences();
if (uri != null) {
String url = uri.toString();
if (media.containsKey(url)) {
// TODO: merge infos about the same image?
} else {
media.put(url, m);
}
}
}
e.media = Lists.newArrayList(media.values());
}
示例6: interpretIdentifier
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
private void interpretIdentifier(NameUsage u, UsageExtensions e, VerbatimNameUsage v) {
if (v.hasExtension(Extension.IDENTIFIER)) {
for (Map<Term, String> rec : v.getExtensions().get(Extension.IDENTIFIER)) {
Identifier i = new Identifier();
// interpret rec
i.setIdentifier(value(rec, DcTerm.identifier));
if (i.getIdentifier() == null) {
u.addIssue(NameUsageIssue.ALT_IDENTIFIER_INVALID);
continue;
}
i.setTitle(value(rec, DcTerm.title));
i.setType(IdentifierType.inferFrom(i.getIdentifier()));
e.identifiers.add(i);
}
}
}
示例7: testVernacularNames
import org.gbif.api.vocabulary.Extension; //导入依赖的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());
}
示例8: testRoundTripping
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
@Test
public void testRoundTripping() throws Exception {
VerbatimNameUsage v = new VerbatimNameUsage();
v.setCoreField(DwcTerm.scientificName, "Abies alba");
v.setCoreField(DwcTerm.taxonRank, "Gattung");
v.setCoreField(DwcTerm.taxonID, "dqwd23");
v.setCoreField(GbifTerm.depth, "1200");
v.setCoreField(new UnknownTerm(qname1), "1200");
v.setCoreField(new UnknownTerm(qname2), null);
List<Map<Term, String>> vernaculars = Lists.newArrayList();
vernaculars.add(map(DwcTerm.vernacularName, "Tanne", DcTerm.language, "de"));
vernaculars.add(map(DwcTerm.vernacularName, "Fir", DcTerm.language, "en", new UnknownTerm(qname2), ""));
v.getExtensions().put(Extension.VERNACULAR_NAME, vernaculars);
List<Map<Term, String>> infos = Lists.newArrayList();
infos.add(map(GbifTerm.ageInDays, "750", IucnTerm.threatStatus, "extinct", GbifTerm.isExtinct, "true"));
v.getExtensions().put(Extension.SPECIES_PROFILE, infos);
String json = mapper.write(v);
VerbatimNameUsage v2 = mapper.read(json);
assertEquals(v, v2);
}
示例9: testHasExtension
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
@Test
public void testHasExtension() throws IOException {
VerbatimNameUsage v1 = new VerbatimNameUsage();
v1.setCoreField(DwcTerm.taxonID, "IPNI342");
v1.setCoreField(DwcTerm.scientificName, "Abies alba");
v1.setCoreField(DwcTerm.scientificNameAuthorship, "Miller");
v1.setCoreField(DwcTerm.taxonRank, "species");
assertFalse(v1.hasExtension(Extension.IDENTIFICATION));
List<Map<Term, String>> exts = Lists.newArrayList();
v1.getExtensions().put(Extension.IDENTIFICATION, exts);
assertFalse(v1.hasExtension(Extension.IDENTIFICATION));
assertFalse(v1.hasExtension(DwcTerm.Identification));
exts.add(Maps.<Term, String>newHashMap());
assertTrue(v1.hasExtension(Extension.IDENTIFICATION));
assertTrue(v1.hasExtension(DwcTerm.Identification));
assertFalse(v1.hasExtension(DwcTerm.MeasurementOrFact));
}
示例10: extractMedia
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
private void extractMedia(NameUsage u, UsageExtensions e, VerbatimNameUsage v, Extension ext, boolean requireType) {
if (v.hasExtension(ext)) {
for (Map<Term, String> rec : v.getExtensions().get(ext)) {
URI uri = UrlParser.parse(value(rec, AcTerm.accessURI, DcTerm.identifier, DcElement.identifier));
URI link = UrlParser.parse(value(rec, AcTerm.furtherInformationURL, DcTerm.references, AcTerm.attributionLinkURL));
// EOL media extension is also used to publish text descriptions - avoid those
MediaType type = enumify(rec, null, mediaTypeParser, u, DcTerm.type, DcElement.type);
if (requireType && type == null) {
continue;
}
// link or media uri must exist
if (uri == null && link == null) {
u.addIssue(NameUsageIssue.MULTIMEDIA_INVALID);
} else {
NameUsageMediaObject m = new NameUsageMediaObject();
m.setType(type);
m.setIdentifier(uri);
m.setReferences(link);
m.setTitle(value(rec, DcTerm.title, AcTerm.caption));
m.setDescription(value(rec, DcTerm.description));
m.setLicense(value(rec, DcTerm.license, XmpRightsTerm.UsageTerms, DcTerm.rights));
m.setPublisher(value(rec, DcTerm.publisher));
m.setContributor(value(rec, DcTerm.contributor));
m.setSource(value(rec, AcTerm.derivedFrom, DcTerm.source));
m.setAudience(value(rec, DcTerm.audience));
m.setRightsHolder(value(rec, XmpRightsTerm.Owner, DcTerm.rightsHolder));
m.setCreator(value(rec, DcTerm.creator));
m.setFormat(mediaParser.parseMimeType(value(rec, DcTerm.format)));
String created = value(rec, XmpTerm.CreateDate, DcTerm.created, DcTerm.date);
if (created != null) {
m.setCreated(DateParseUtils.parse(created).getPayload());
}
mediaParser.detectType(m);
e.media.add(m);
}
}
}
}
示例11: interpretDistribution
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
private void interpretDistribution(NameUsage u, UsageExtensions e, VerbatimNameUsage v) {
if (v.hasExtension(Extension.DISTRIBUTION)) {
for (Map<Term, String> rec : v.getExtensions().get(Extension.DISTRIBUTION)) {
Distribution d = new Distribution();
// interpret rec
d.setLocality(value(rec, DwcTerm.locality));
d.setLocationId(value(rec, DwcTerm.locationID));
d.setCountry(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, countryParser, u, DwcTerm.country, DwcTerm.countryCode));
// some location is required, otherwise its pointless
if (d.getLocality() == null && d.getLocationId() == null && d.getCountry() == null) {
u.addIssue(NameUsageIssue.DISTRIBUTION_INVALID);
continue;
}
d.setStatus(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, occurrenceStatusParser, u, DwcTerm.occurrenceStatus));
d.setEstablishmentMeans(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, establishmentMeansParser, u, DwcTerm.establishmentMeans));
d.setAppendixCites(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, citesAppendixParser, u, GbifTerm.appendixCITES));
d.setThreatStatus(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, threatStatusParser, u, IucnTerm.threatStatus));
d.setLifeStage(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, lifeStageParser, u, DwcTerm.lifeStage));
d.setTemporal(value(rec, DwcTerm.eventDate, DcTerm.temporal));
d.setEndDayOfYear(integer(rec, NameUsageIssue.DISTRIBUTION_INVALID, u, DwcTerm.endDayOfYear));
d.setStartDayOfYear(integer(rec, NameUsageIssue.DISTRIBUTION_INVALID, u, DwcTerm.startDayOfYear));
d.setRemarks(value(rec, DwcTerm.occurrenceRemarks, DwcTerm.taxonRemarks));
d.setSource(value(rec, DcTerm.source));
e.distributions.add(d);
}
}
}
示例12: testEolMedia
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
@Test
public void testEolMedia() throws Exception {
ExtensionInterpreter interp = new ExtensionInterpreter();
NameUsage u = new NameUsage();
VerbatimNameUsage v = new VerbatimNameUsage();
Map<Term, String> doc1 = Maps.newHashMap();
doc1.put(DcTerm.type, "http://purl.org/dc/dcmitype/StillImage");
doc1.put(DcTerm.format, "image/jpeg");
doc1.put(DcTerm.language, "en");
doc1.put(DcTerm.identifier, "1013-sp1-Image-1");
doc1.put(DwcTerm.taxonID, "1013-sp1");
doc1.put(AcTerm.accessURI, "http://pwt.pensoft.net//showfigure.php?filename=big_4805.jpg");
doc1.put(AcTerm.furtherInformationURL, "http://dx.doi.org/10.3897/BDJ.1.e1013");
Map<Term, String> doc2 = Maps.newHashMap();
doc2.put(DcTerm.type, "http://purl.org/dc/dcmitype/Text");
doc2.put(DcTerm.format, "text/html");
doc2.put(DcTerm.language, "en");
doc2.put(DcTerm.identifier, "1013-sp1-text-3");
doc2.put(DwcTerm.taxonID, "1013-sp1");
doc2.put(DcTerm.description, "Eupolybothrus cavernicolus is so far known only from the caves Miljacka");
doc2.put(DcTerm.title, "Description of the type locality");
doc2.put(AcTerm.furtherInformationURL, "http://dx.doi.org/10.3897/BDJ.1.e1013");
doc2.put(XmpRightsTerm.UsageTerms, "http://creativecommons.org/licenses/by/4.0/");
v.getExtensions().put(Extension.EOL_MEDIA, Lists.newArrayList(doc1, doc2));
UsageExtensions ext = interp.interpret(u, v);
assertEquals(1, ext.media.size());
assertEquals(URI.create("http://pwt.pensoft.net//showfigure.php?filename=big_4805.jpg"), ext.media.get(0).getIdentifier());
assertEquals(URI.create("http://dx.doi.org/10.3897/BDJ.1.e1013"), ext.media.get(0).getReferences());
assertEquals(1, ext.descriptions.size());
assertEquals("Description of the type locality", ext.descriptions.get(0).getType());
assertEquals("http://creativecommons.org/licenses/by/4.0/", ext.descriptions.get(0).getLicense());
assertEquals("Eupolybothrus cavernicolus is so far known only from the caves Miljacka", ext.descriptions.get(0).getDescription());
}
示例13: getExtensions
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
/**
* A map of extension records, holding all verbatim extension terms.
*/
@NotNull
@JsonSerialize(keyUsing = ExtensionSerializer.class, contentUsing = TermMapListSerializer.class)
@JsonDeserialize(keyUsing = ExtensionKeyDeserializer.class, contentUsing = TermMapListDeserializer.class)
public Map<Extension, List<Map<Term, String>>> getExtensions() {
return extensions;
}
示例14: getExtensions
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
/**
* A map holding all verbatim extension terms.
*/
@NotNull
@JsonSerialize(keyUsing = ExtensionSerializer.class, contentUsing = TermMapListSerializer.class)
@JsonDeserialize(keyUsing = ExtensionKeyDeserializer.class, contentUsing = TermMapListDeserializer.class)
public Map<Extension, List<Map<Term, String>>> getExtensions() {
return extensions;
}
示例15: deserialize
import org.gbif.api.vocabulary.Extension; //导入依赖的package包/类
@Override
public Extension deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
if (jp.getCurrentToken() == JsonToken.VALUE_STRING) {
return Extension.fromRowType(jp.getText());
}
throw ctxt.mappingException("Expected JSON String");
}