当前位置: 首页>>代码示例>>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;未经允许,请勿转载。