本文整理汇总了Java中org.gbif.api.model.occurrence.Occurrence类的典型用法代码示例。如果您正苦于以下问题:Java Occurrence类的具体用法?Java Occurrence怎么用?Java Occurrence使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Occurrence类属于org.gbif.api.model.occurrence包,在下文中一共展示了Occurrence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildOccurrence
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
private static Occurrence buildOccurrence(UUID datasetKey, UUID ook) {
Occurrence occ1 = new Occurrence();
occ1.setKey(1);
occ1.setDatasetKey(datasetKey);
occ1.setPublishingOrgKey(ook);
occ1.setBasisOfRecord(BasisOfRecord.FOSSIL_SPECIMEN);
occ1.setKingdomKey(1);
occ1.setPhylumKey(1);
occ1.setClassKey(1);
occ1.setOrderKey(1);
occ1.setFamilyKey(1);
occ1.setGenusKey(1);
occ1.setSpeciesKey(1);
occ1.setScientificName("Ursus horribilis");
occ1.addIssue(OccurrenceIssue.COUNTRY_COORDINATE_MISMATCH);
occ1.setDecimalLatitude(1.234);
occ1.setDecimalLongitude(4.567);
occ1.setCountry(Country.AFGHANISTAN);
occ1.setPublishingCountry(Country.CANADA);
occ1.setProtocol(EndpointType.BIOCASE);
return occ1;
}
示例2: occurrenceOf
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
private Occurrence occurrenceOf(
Integer key, Integer kingdom, Integer phylum, Integer classs, Integer order, Integer family, Integer genus,
Integer species, Integer nub,
UUID dataset, BasisOfRecord bor, Country country, Integer year, Double latitude, Double longitude,
EndpointType protocol) {
Occurrence occ = new Occurrence();
occ.setKey(key);
occ.setKingdomKey(kingdom);
occ.setPhylumKey(phylum);
occ.setClassKey(classs);
occ.setOrderKey(order);
occ.setFamilyKey(family);
occ.setGenusKey(genus);
occ.setSpeciesKey(species);
occ.setTaxonKey(nub);
occ.setDatasetKey(dataset);
occ.setBasisOfRecord(bor);
occ.setCountry(country);
occ.setYear(year);
occ.setDecimalLatitude(latitude);
occ.setDecimalLongitude(longitude);
occ.setProtocol(protocol);
return occ;
}
示例3: testSingleOccurrence
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
@Test
public void testSingleOccurrence() {
Occurrence occ = occurrenceService.get(3);
assertNotNull(occ);
occurrenceDeletionService.deleteOccurrence(3, null);
occ = occurrenceService.get(3);
assertNull(occ);
occ = occurrenceService.get(4);
assertNotNull(occ);
occurrenceDeletionService.deleteOccurrence(4, null);
occ = occurrenceService.get(4);
assertNull(occ);
occ = occurrenceService.get(5);
assertNotNull(occ);
//test deletion of a record with a target crawl of 1
occurrenceDeletionService.deleteOccurrence(5, 1);
occ = occurrenceService.get(5);
assertNotNull(occ);
occurrenceDeletionService.deleteOccurrence(5, 2);
occ = occurrenceService.get(5);
assertNull(occ);
}
示例4: buildRowUpdate
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
<T extends VerbatimOccurrence> RowUpdate buildRowUpdate(T occ) {
checkNotNull(occ, "occurrence can't be null");
checkNotNull(occ.getKey(), "occurrence's key can't be null");
RowUpdate upd = new RowUpdate(occ.getKey());
try (Table table = connection.getTable(TableName.valueOf(occurrenceTableName))) {
if (occ instanceof Occurrence) {
populateVerbatimPutDelete(table, upd, occ, false);
populateInterpretedPutDelete(upd, (Occurrence) occ);
} else {
populateVerbatimPutDelete(table, upd, occ, true);
}
} catch (IOException e) {
throw new ServiceUnavailableException("Could not access HBase", e);
}
return upd;
}
示例5: testOccRowMutations
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
@Test
public void testOccRowMutations() {
// identical shouldn't do anything
Occurrence occ = occurrenceService.get(KEY);
RowMutations mutations = occurrenceService.buildRowUpdate(occ).getRowMutations();
assertEquals(0, mutations.getMutations().size());
// one put and three deletes
occ = occurrenceService.get(KEY);
occ.setLastInterpreted(new Date());
occ.setVerbatimField(DwcTerm.acceptedNameUsage, null);
occ.setVerbatimField(DcTerm.accessRights, null);
occ.setVerbatimField(GbifTerm.ageInDays, null);
mutations = occurrenceService.buildRowUpdate(occ).getRowMutations();
assertEquals(4, mutations.getMutations().size());
}
示例6: testOccurrenceXML
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
@Test
public void testOccurrenceXML() throws IOException {
MessageBodyWriter<Occurrence> occurrenceDwcXMLBodyWriter = new OccurrenceDwcXMLBodyWriter();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Occurrence occ = new Occurrence();
occ.setCountry(Country.MADAGASCAR);
occ.setVerbatimField(DwcTerm.verbatimLocality, "mad");
occ.setReferences(URI.create("http://www.gbif.org"));
Term customTerm = TermFactory.instance().findTerm("MyTerm");
occ.setVerbatimField(customTerm, "MyTerm value");
occurrenceDwcXMLBodyWriter.writeTo(occ, null, null, null, null, null, baos);
String expectedContent = IOUtils.toString(new FileInputStream(FileUtils.getClasspathFile("dwc_xml/occurrence.xml")));
assertEquals(CharMatcher.WHITESPACE.removeFrom(expectedContent), CharMatcher.WHITESPACE.removeFrom(baos.toString()));
}
示例7: testSearchByMediaType
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
/**
* Performs a search by MediaType.
*/
@Test
public void testSearchByMediaType() {
// There are 3 occurrences with media objects: 1 still image, 1 video and 1 sound
OccurrenceSearchRequest occurrenceSearchRequest = new OccurrenceSearchRequest();
occurrenceSearchRequest.addMediaTypeFilter(MediaType.StillImage);
SearchResponse<Occurrence, OccurrenceSearchParameter> response =
occurrenceSearchService.search(occurrenceSearchRequest);
Assert.assertTrue(response.getCount() == 1);
occurrenceSearchRequest.addMediaTypeFilter(MediaType.MovingImage);
response = occurrenceSearchService.search(occurrenceSearchRequest);
Assert.assertTrue(response.getCount() == 2);
occurrenceSearchRequest.addMediaTypeFilter(MediaType.Sound);
response = occurrenceSearchService.search(occurrenceSearchRequest);
Assert.assertTrue(response.getCount() == 3);
}
示例8: applyMatch
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
private static void applyMatch(Occurrence occ, NameUsageMatch match, Collection<OccurrenceIssue> issues) {
occ.setTaxonKey(match.getUsageKey());
occ.setScientificName(match.getScientificName());
occ.setTaxonRank(match.getRank());
// copy issues
occ.getIssues().addAll(issues);
// parse name into pieces - we dont get them from the nub lookup
try {
ParsedName pn = PARSER.parse(match.getScientificName(), match.getRank());
occ.setGenericName(pn.getGenusOrAbove());
occ.setSpecificEpithet(pn.getSpecificEpithet());
occ.setInfraspecificEpithet(pn.getInfraSpecificEpithet());
} catch (UnparsableException e) {
if (e.type.isParsable()) {
LOG.warn("Fail to parse backbone {} name for occurrence {}: {}", e.type, occ.getKey(), e.name);
}
}
for (Rank r : Rank.DWC_RANKS) {
org.gbif.api.util.ClassificationUtils.setHigherRank(occ, r, match.getHigherRank(r));
org.gbif.api.util.ClassificationUtils.setHigherRankKey(occ, r, match.getHigherRankKey(r));
}
LOG.debug("Occurrence {} matched to nub {} [{}]", occ.getKey(), occ.getScientificName(), occ.getTaxonKey());
}
示例9: testInterpretMediaCore
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
@Test
public void testInterpretMediaCore() throws Exception {
VerbatimOccurrence v = new VerbatimOccurrence();
Occurrence o = new Occurrence();
v.setVerbatimField(
DwcTerm.associatedMedia,
"http://farm8.staticflickr.com/7093/7039524065_3ed0382368.jpg, http://www.flickr.com/photos/[email protected]/7039524065.png");
MultiMediaInterpreter.interpretMedia(v, o);
assertEquals(2, o.getMedia().size());
for (MediaObject m : o.getMedia()) {
assertEquals(MediaType.StillImage, m.getType());
assertTrue(m.getFormat().startsWith("image/"));
assertNotNull(m.getIdentifier());
}
}
示例10: testCoordinatesUncertaintyIssues
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
@Test
public void testCoordinatesUncertaintyIssues() throws InterruptedException {
verb = new VerbatimOccurrence();
verb.setKey(1);
verb.setDatasetKey(UUID.randomUUID());
verb.setVerbatimField(DwcTerm.country, "CANADA");
verb.setVerbatimField(DwcTerm.verbatimLatitude, "45.5088400");
verb.setVerbatimField(DwcTerm.verbatimLongitude, "-73.5878100");
verb.setVerbatimField(DwcTerm.coordinateUncertaintyInMeters, "abc");
verb.setVerbatimField(DwcTerm.geodeticDatum, "WSG84");
occ = new Occurrence(verb);
interpreter.interpretLocation(verb, occ);
assertNotNull(occ);
assertNull(occ.getCoordinateUncertaintyInMeters());
assertTrue(occ.getIssues().contains(OccurrenceIssue.COORDINATE_UNCERTAINTY_METERS_INVALID));
assertEquals(1, occ.getIssues().size());
}
示例11: testDeriveFromNotEquivalentMappedCountry
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
@Test
public void testDeriveFromNotEquivalentMappedCountry() throws InterruptedException {
verb = new VerbatimOccurrence();
verb.setKey(1);
verb.setDatasetKey(UUID.randomUUID());
verb.setVerbatimField(DwcTerm.country, "France");
verb.setVerbatimField(DwcTerm.decimalLatitude, "-17.65");
verb.setVerbatimField(DwcTerm.decimalLongitude, "-149.46");
verb.setVerbatimField(DwcTerm.geodeticDatum, "EPSG:4326");
occ = new Occurrence(verb);
interpreter.interpretLocation(verb, occ);
assertNotNull(occ);
assertEquals(-17.65, occ.getDecimalLatitude(), 0.0001);
assertEquals(-149.46, occ.getDecimalLongitude(), 0.0001);
assertEquals(Country.FRENCH_POLYNESIA, occ.getCountry());
assertEquals(1, occ.getIssues().size());
assertTrue(occ.getIssues().contains(OccurrenceIssue.COUNTRY_DERIVED_FROM_COORDINATES));
}
示例12: apply
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
/**
* Reads and processes the occurrence object.
*/
@Override
public boolean apply(Occurrence input) {
try {
write(input);
return true;
} catch (IOException e) {
return false;
}
}
示例13: equivalent
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
/**
* True if the subset of fields of occurrence, that are interesting to metrics and cube-updating, are the same.
*/
public static boolean equivalent(Occurrence occ1, Occurrence occ2) {
// TODO: Do we need to compare the holy triple too?
/*
* && Objects.equal(occ1.getInstitutionCode(), occ2.getInstitutionCode())
* && Objects.equal(occ1.getCollectionCode(), occ2.getCollectionCode())
* && Objects.equal(occ1.getCatalogNumber(), occ2.getCatalogNumber())
*/
return Objects.equal(occ1.getKey(), occ2.getKey())
&& Objects.equal(occ1.getDatasetKey(), occ2.getDatasetKey())
&& Objects.equal(occ1.getPublishingOrgKey(), occ2.getPublishingOrgKey())
&& Objects.equal(occ1.getBasisOfRecord(), occ2.getBasisOfRecord())
&& Objects.equal(occ1.getKingdomKey(), occ2.getKingdomKey())
&& Objects.equal(occ1.getPhylumKey(), occ2.getPhylumKey())
&& Objects.equal(occ1.getClassKey(), occ2.getClassKey())
&& Objects.equal(occ1.getOrderKey(), occ2.getOrderKey())
&& Objects.equal(occ1.getFamilyKey(), occ2.getFamilyKey())
&& Objects.equal(occ1.getGenusKey(), occ2.getGenusKey())
&& Objects.equal(occ1.getSpeciesKey(), occ2.getSpeciesKey())
&& Objects.equal(occ1.getScientificName(), occ2.getScientificName())
&& Objects.equal(occ1.hasSpatialIssue(), occ2.hasSpatialIssue())
&& Objects.equal(occ1.getDecimalLatitude(), occ2.getDecimalLatitude())
&& Objects.equal(occ1.getDecimalLongitude(), occ2.getDecimalLongitude())
&& Objects.equal(occ1.getCountry(), occ2.getCountry())
&& Objects.equal(occ1.getPublishingCountry(), occ2.getPublishingCountry())
&& Objects.equal(occ1.getProtocol(), occ2.getProtocol());
}
示例14: OccurrenceUuidIntMapCubeUpdaterService
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
public OccurrenceUuidIntMapCubeUpdaterService(CubeConfiguration configuration, DataCube<UuidIntMap> dataCube,
Dimension<T> dimension, Function<Occurrence, T> valueGetter) {
super(configuration);
this.dataCube = dataCube;
this.dimension = dimension;
this.valueGetter = valueGetter;
}
示例15: countryGetter
import org.gbif.api.model.occurrence.Occurrence; //导入依赖的package包/类
/**
* Function that return the country value from an occurrence object.
*/
private Function<Occurrence, Country> countryGetter() {
return new Function<Occurrence, Country>() {
@Override
public Country apply(Occurrence occurrence) {
return occurrence.getCountry();
}
};
}