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


Java Occurrence.setCountry方法代碼示例

本文整理匯總了Java中org.gbif.api.model.occurrence.Occurrence.setCountry方法的典型用法代碼示例。如果您正苦於以下問題:Java Occurrence.setCountry方法的具體用法?Java Occurrence.setCountry怎麽用?Java Occurrence.setCountry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.gbif.api.model.occurrence.Occurrence的用法示例。


在下文中一共展示了Occurrence.setCountry方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例4: interpretCountry

import org.gbif.api.model.occurrence.Occurrence; //導入方法依賴的package包/類
private Country interpretCountry(VerbatimOccurrence verbatim, Occurrence occ) {
  OccurrenceParseResult<Country>
    inter = interpretCountry(verbatim.getVerbatimField(DwcTerm.countryCode),
    verbatim.getVerbatimField(DwcTerm.country));
  occ.setCountry(inter.getPayload());
  occ.getIssues().addAll(inter.getIssues());
  return occ.getCountry();
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:9,代碼來源:LocationInterpreter.java

示例5: interpretCoordinates

import org.gbif.api.model.occurrence.Occurrence; //導入方法依賴的package包/類
private void interpretCoordinates(VerbatimOccurrence verbatim, Occurrence occ, Country country) {
  OccurrenceParseResult<CoordinateResult> parsedCoord = coordinateInterpreter.interpretCoordinate(
          verbatim.getVerbatimField(DwcTerm.decimalLatitude), verbatim.getVerbatimField(DwcTerm.decimalLongitude),
          verbatim.getVerbatimField(DwcTerm.geodeticDatum), country);

  if (!parsedCoord.isSuccessful() && verbatim.hasVerbatimField(DwcTerm.verbatimLatitude)
      && verbatim.hasVerbatimField(DwcTerm.verbatimLongitude)) {
    LOG.debug("Decimal coord interpretation, trying verbatim lat/lon");
    // try again with verbatim lat/lon
    parsedCoord = coordinateInterpreter.interpretCoordinate(verbatim.getVerbatimField(DwcTerm.verbatimLatitude),
                                                            verbatim.getVerbatimField(DwcTerm.verbatimLongitude),
                                                            verbatim.getVerbatimField(DwcTerm.geodeticDatum),country);
  }

  if (!parsedCoord.isSuccessful() && verbatim.hasVerbatimField(DwcTerm.verbatimCoordinates)) {
    LOG.debug("Verbatim lat/lon interpretation, trying single verbatimCoordinates");
    // try again with verbatim coordinates
    parsedCoord = coordinateInterpreter.interpretCoordinate(verbatim.getVerbatimField(DwcTerm.verbatimCoordinates),
                                                            verbatim.getVerbatimField(DwcTerm.geodeticDatum),country);
  }

  if (parsedCoord.isSuccessful() && parsedCoord.getPayload() != null) {
    occ.setDecimalLatitude(parsedCoord.getPayload().getLatitude());
    occ.setDecimalLongitude(parsedCoord.getPayload().getLongitude());

    // If the country returned by the co-ordinate interpreter is different, then it's an acceptable
    // swap (e.g. Réunion→France).
    if (country == null || (country != parsedCoord.getPayload().getCountry())) {
      LOG.debug("Swapping provided {} for georeferenced {}", country, parsedCoord.getPayload().getCountry());
      occ.setCountry(parsedCoord.getPayload().getCountry());
    }

    // interpret coordinateUncertaintyInMeters and coordinatePrecision
    interpretCoordinateUncertaintyAndPrecision(occ, verbatim);
  }

  LOG.debug("Adding coord issues to occ [{}]", parsedCoord.getIssues());
  occ.getIssues().addAll(parsedCoord.getIssues());
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:40,代碼來源:LocationInterpreter.java

示例6: testCubeMutation

import org.gbif.api.model.occurrence.Occurrence; //導入方法依賴的package包/類
@Test
public void testCubeMutation() throws Exception {
  final UUID datasetKey = UUID.randomUUID();
  Occurrence occ = new Occurrence();
  occ.setTypeStatus(TypeStatus.HOLOTYPE);
  occ.setDatasetKey(datasetKey);
  occ.setKey(1);
  occ.setElevation(110d);
  occ.setDepth(10d);
  occ.setBasisOfRecord(BasisOfRecord.PRESERVED_SPECIMEN);
  occ.setTaxonKey(1000);
  occ.setKingdomKey(6);
  occ.setPhylumKey(66);
  occ.setClassKey(666);
  occ.setOrderKey(6666);
  occ.setFamilyKey(66666);
  occ.setGenusKey(666666);
  occ.setSubgenusKey(6666666);
  occ.setSpeciesKey(66666666);
  occ.setContinent(Continent.EUROPE);
  occ.setCountry(Country.ALBANIA);
  occ.setProtocol(EndpointType.DWC_ARCHIVE);
  occ.setPublishingCountry(Country.ITALY);
  occ.setYear(1992);
  occ.setMonth(1);
  occ.setDay(31);
  occ.getIssues().add(OccurrenceIssue.TYPE_STATUS_INVALID);
  occ.getIssues().add(OccurrenceIssue.ELEVATION_NON_NUMERIC);

  Batch<LongOp> updates = OccurrenceAddressUtil.cubeMutation(occ, new LongOp(1));

  // make sure we have a single dimension rollup for each dimension
  Set<Dimension<?>> addressed = Sets.newHashSet();
  int nubCounter = 0;
  for (Address a : updates.getMap().keySet()) {
    Dimension<?> singleDim = singleDimensionAddress(a);
    if (singleDim != null) {
      if (OccurrenceCube.TAXON_KEY.equals(singleDim)) {
        nubCounter++;
      } else if (addressed.contains(singleDim)) {
        System.out.println("Warning, single dimension " + singleDim + " used multiple times");
        System.out.println(a);
      }
      addressed.add(singleDim);
    }
  }

  System.out.println(OccurrenceCube.API_MAPPING.values());
  System.out.println(addressed);
  assertEquals("Not all higher taxa are mutated", 9, nubCounter);
  assertEquals("Not all cube dimensions are mutated", OccurrenceCube.API_MAPPING.size(), addressed.size());

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

示例7: testUpdateVerbatimMultimediaUpdate

import org.gbif.api.model.occurrence.Occurrence; //導入方法依賴的package包/類
/**
 * Test the cycle: create a verbtim record, update it and add extension.
 */
@Test
public void testUpdateVerbatimMultimediaUpdate() {
  VerbatimOccurrence orig = occurrenceService.getVerbatim(KEY);
  orig.setPublishingCountry(Country.VENEZUELA);
  orig.setPublishingOrgKey(UUID.randomUUID());
  orig.setProtocol(EndpointType.DIGIR_MANIS);
  orig.setLastParsed(new Date());
  Map<Extension, List<Map<Term, String>>> extensions = Maps.newHashMap();
  List<Map<Term, String>> mediaExtensions = Lists.newArrayList();
  Map<Term, String> verbatimRecord = new HashMap<Term, String>();
  verbatimRecord.put(DcTerm.created, IsoDateFormat.FULL.getDateFormat().format(new Date()));
  verbatimRecord.put(DcTerm.creator, "gbifuser");
  verbatimRecord.put(DcTerm.description, "testDescription");
  verbatimRecord.put(DcTerm.format, "jpeg");
  verbatimRecord.put(DcTerm.license, "licenseTest");
  verbatimRecord.put(DcTerm.publisher, "publisherTest");
  verbatimRecord.put(DcTerm.title, "titleTest");
  verbatimRecord.put(DcTerm.identifier, "http://www.gbif.org/logo.jpg");
  mediaExtensions.add(verbatimRecord);
  extensions.put(Extension.MULTIMEDIA, mediaExtensions);
  orig.setExtensions(extensions);
  occurrenceService.update(orig);


  Occurrence intOcc = occurrenceService.get(KEY);
  intOcc.setCountry(Country.ANGOLA);
  Map<Extension, List<Map<Term, String>>> extensions2 = Maps.newHashMap();
  List<Map<Term, String>> mediaExtensions2 = Lists.newArrayList();
  Map<Term, String> verbatimRecord2 = new HashMap<Term, String>();
  verbatimRecord.put(DcTerm.created, IsoDateFormat.FULL.getDateFormat().format(new Date()));
  verbatimRecord.put(DcTerm.creator, "gbifuser2");
  verbatimRecord.put(DcTerm.description, "testDescription2");
  verbatimRecord.put(DcTerm.format, "jpeg");
  verbatimRecord.put(DcTerm.license, "licenseTest2");
  verbatimRecord.put(DcTerm.publisher, "publisherTest2");
  verbatimRecord.put(DcTerm.title, "titleTest2");
  verbatimRecord.put(DcTerm.identifier, "http://www.gbif.org/logo2.jpg");
  mediaExtensions2.add(verbatimRecord);
  mediaExtensions2.add(verbatimRecord2);
  extensions2.put(Extension.MULTIMEDIA, mediaExtensions2);
  orig.setExtensions(extensions2);
  occurrenceService.update(intOcc);
  occurrenceService.update(orig);
  VerbatimOccurrence got = occurrenceService.getVerbatim(KEY);
  assertNotNull(got);
  assertEquals(got.getExtensions(), orig.getExtensions());
}
 
開發者ID:gbif,項目名稱:occurrence,代碼行數:51,代碼來源:OccurrencePersistenceServiceImplTest.java


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