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


Java Occurrence類代碼示例

本文整理匯總了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;
}
 
開發者ID:gbif,項目名稱:metrics,代碼行數:24,代碼來源:OccurrenceComparisonUtilTest.java

示例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;
}
 
開發者ID:gbif,項目名稱:metrics,代碼行數:26,代碼來源:OccurrenceCubeTest.java

示例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);
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:26,代碼來源:OccurrenceDeletionServiceTest.java

示例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;
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:19,代碼來源:OccurrencePersistenceServiceImpl.java

示例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());
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:17,代碼來源:OccurrencePersistenceServiceImplTest.java

示例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()));
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:19,代碼來源:OccurrenceDwcXMLBodyWriterTest.java

示例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);
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:19,代碼來源:OccurrenceSearchTestIT.java

示例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());
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:27,代碼來源:TaxonomyInterpreter.java

示例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());
  }
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:18,代碼來源:MultiMediaInterpreterTest.java

示例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());
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:21,代碼來源:LocationInterpreterTest.java

示例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));
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:20,代碼來源:LocationInterpreterTest.java

示例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;
  }
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:13,代碼來源:HBasePredicateWriter.java

示例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());
}
 
開發者ID:gbif,項目名稱:metrics,代碼行數:31,代碼來源:OccurrenceComparisonUtil.java

示例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;
}
 
開發者ID:gbif,項目名稱:metrics,代碼行數:8,代碼來源:OccurrenceUuidIntMapCubeUpdaterService.java

示例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();
    }

  };
}
 
開發者ID:gbif,項目名稱:metrics,代碼行數:14,代碼來源:Application.java


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