当前位置: 首页>>代码示例>>Java>>正文


Java EndpointType类代码示例

本文整理汇总了Java中org.gbif.api.vocabulary.EndpointType的典型用法代码示例。如果您正苦于以下问题:Java EndpointType类的具体用法?Java EndpointType怎么用?Java EndpointType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EndpointType类属于org.gbif.api.vocabulary包,在下文中一共展示了EndpointType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CrawlJob

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
/**
 * Creates a new crawl job.
 *
 * @param datasetKey  of the dataset to crawl
 * @param endpointType of the dataset
 * @param targetUrl    of the dataset
 * @param attempt      a monotonously increasing counter, increased every time we try to crawl a dataset whether that
 *                     attempt is successful or not
 * @param properties   a way to provide protocol or crawl specific options
 */
@JsonCreator
public CrawlJob(
  @JsonProperty("datasetKey") UUID datasetKey,
  @JsonProperty("endpointType") EndpointType endpointType,
  @JsonProperty("targetUrl") URI targetUrl,
  @JsonProperty("attempt") int attempt,
  @Nullable @JsonProperty("properties") Map<String, String> properties
) {
  this.datasetKey = checkNotNull(datasetKey);
  this.endpointType = checkNotNull(endpointType);
  this.targetUrl = checkNotNull(targetUrl);
  checkArgument(attempt > 0, "attempt has to be greater than 0");
  this.attempt = attempt;

  if (properties == null) {
    this.properties = ImmutableMap.of();
  } else {
    this.properties = ImmutableMap.copyOf(properties);
  }
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:31,代码来源:CrawlJob.java

示例2: testVerbatimConstructor

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
@Test
public void testVerbatimConstructor() {
  VerbatimOccurrence verb = new VerbatimOccurrence();
  verb.setKey(123);
  verb.setDatasetKey(UUID.randomUUID());
  verb.setPublishingOrgKey(UUID.randomUUID());
  verb.setPublishingCountry(Country.AFGHANISTAN);
  verb.setLastCrawled(new Date());
  verb.setProtocol(EndpointType.BIOCASE);
  for (Term term : DwcTerm.values()) {
    verb.setVerbatimField(term, "I am " + term);
  }

  Occurrence occ = new Occurrence(verb);
  assertEquals(occ.getKey(), verb.getKey());
  assertEquals(occ.getDatasetKey(), verb.getDatasetKey());
  assertEquals(occ.getPublishingOrgKey(), verb.getPublishingOrgKey());
  assertEquals(occ.getPublishingCountry(), verb.getPublishingCountry());
  assertEquals(occ.getProtocol(), verb.getProtocol());
  assertEquals(occ.getLastCrawled(), verb.getLastCrawled());
  assertEquals(occ.getVerbatimFields().size(), verb.getVerbatimFields().size());
  assertEquals(occ.getVerbatimField(DwcTerm.acceptedNameUsage), verb.getVerbatimField(DwcTerm.acceptedNameUsage));
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:24,代码来源:OccurrenceTest.java

示例3: testEquals

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
@Test
public void testEquals() {
  Map<String, String> m1 = Maps.newHashMap();
  m1.put("foo", "bar");
  CrawlJob c1 = new CrawlJob(UUID.randomUUID(), EndpointType.BIOCASE, URI.create("http://www.foo.com"), 1, m1);

  Map<String, String> m2 = Maps.newHashMap();
  m2.put("foo", "bar");
  CrawlJob c2 = new CrawlJob(UUID.fromString(c1.getDatasetKey().toString()),
                             EndpointType.BIOCASE,
                             URI.create("http://www.foo.com"),
                             1,
                             m2);

  assertEquals(c1, c2);
  assertEquals(c1.hashCode(), c2.hashCode());
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:18,代码来源:CrawlJobTest.java

示例4: buildOccurrence

import org.gbif.api.vocabulary.EndpointType; //导入依赖的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

示例5: readFields

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
@Override
public void readFields(DataInput in) throws IOException {
  kingdomKey = readInt(in);
  phylumKey = readInt(in);
  classKey = readInt(in);
  orderKey = readInt(in);
  familyKey = readInt(in);
  subgenusKey = readInt(in);
  genusKey = readInt(in);
  speciesKey = readInt(in);
  taxonKey = readInt(in);
  issues = readIssueSet(in);
  pubOrgKey = readUuid(in);
  datasetKey = readUuid(in);
  country = readEnum(in, Country.class);
  publishingCountry = readEnum(in, Country.class);
  latitude = readDouble(in);
  longitude = readDouble(in);
  year = readInt(in);
  basisOfRecord = readEnum(in, BasisOfRecord.class);
  count = readInt(in);
  protocol = readEnum(in, EndpointType.class);
  typeStatus = readEnum(in, TypeStatus.class);
}
 
开发者ID:gbif,项目名称:metrics,代码行数:25,代码来源:OccurrenceWritable.java

示例6: testSerDe

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
@Test
public void testSerDe() {
  OccurrenceWritable o = buildOcc();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  DataOutput out = new DataOutputStream(baos);
  try {
    o.write(out);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    o = new OccurrenceWritable();
    o.readFields(new DataInputStream(bais));
    assertEquals(new Integer(1), o.getKingdomKey());
    assertEquals(new Integer(2012), o.getYear());
    assertEquals(Country.UNITED_KINGDOM, o.getPublishingCountry());
    assertNull(o.getPhylumKey());
    assertEquals(0.89d, o.getLatitude().doubleValue(), 0.0001);
    assertNull(o.getLongitude());
    assertEquals(BasisOfRecord.FOSSIL_SPECIMEN, o.getBasisOfRecord());
    assertEquals(EndpointType.DWC_ARCHIVE, o.getProtocol());

  } catch (IOException e) {
    fail(e.getMessage());
  }
}
 
开发者ID:gbif,项目名称:metrics,代码行数:24,代码来源:OccurrenceWritableTest.java

示例7: testSubtraction

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
@Test
public void testSubtraction() throws InterruptedException, AsyncException, IOException {
  final UUID ds1 = UUID.randomUUID();
  final Occurrence o1 =
    occurrenceOf(123456, 1, 2, 3, 4, 5, 6, 7, 7, ds1, BasisOfRecord.OBSERVATION, Country.UKRAINE, 2012, 10.0, 11.0,
      EndpointType.DWC_ARCHIVE);

  cubeIo.writeAsync(OccurrenceAddressUtil.cubeMutation(o1, new LongOp(1)));
  cubeIo.writeAsync(OccurrenceAddressUtil.cubeMutation(o1, new LongOp(1)));
  cubeIo.flush();
  Assert.assertEquals(2L, getCount(new ReadBuilder(OccurrenceCube.INSTANCE).at(OccurrenceCube.TAXON_KEY, 1)));
  Assert.assertEquals(2L, getCount(new ReadBuilder(OccurrenceCube.INSTANCE).at(OccurrenceCube.DATASET_KEY, ds1)));

  cubeIo.writeAsync(OccurrenceAddressUtil.cubeMutation(o1, new LongOp(-1)));
  cubeIo.flush();
  Assert.assertEquals(1L, getCount(new ReadBuilder(OccurrenceCube.INSTANCE).at(OccurrenceCube.TAXON_KEY, 1)));
  Assert.assertEquals(1L, getCount(new ReadBuilder(OccurrenceCube.INSTANCE).at(OccurrenceCube.DATASET_KEY, ds1)));
}
 
开发者ID:gbif,项目名称:metrics,代码行数:19,代码来源:OccurrenceCubeTest.java

示例8: occurrenceOf

import org.gbif.api.vocabulary.EndpointType; //导入依赖的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

示例9: testUpdateVerbatimRemovingFields

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
@Test
public void testUpdateVerbatimRemovingFields() {
  VerbatimOccurrence orig = occurrenceService.getVerbatim(KEY);
  orig.setPublishingCountry(Country.VENEZUELA);
  orig.setPublishingOrgKey(UUID.randomUUID());
  orig.setLastCrawled(new Date());
  orig.setProtocol(EndpointType.DIGIR_MANIS);
  addTerms(orig, "I was ");
  Map<Term, String> fields = orig.getVerbatimFields();
  fields.remove(DwcTerm.acceptedNameUsage);
  fields.remove(DcTerm.accessRights);
  fields.remove(IucnTerm.threatStatus);
  orig.setVerbatimFields(fields);
  occurrenceService.update(orig);

  VerbatimOccurrence got = occurrenceService.getVerbatim(KEY);
  assertNotNull(got);
  assertEquivalence(orig, got);
  assertNull(got.getVerbatimField(DwcTerm.acceptedNameUsage));
  assertNull(got.getVerbatimField(DcTerm.accessRights));
  assertNull(got.getVerbatimField(IucnTerm.threatStatus));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:23,代码来源:OccurrencePersistenceServiceImplTest.java

示例10: testNewAbcd206Single

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
@Test
public void testNewAbcd206Single() {
  UUID datasetKey = UUID.randomUUID();
  OccurrenceSchemaType schemaType = OccurrenceSchemaType.ABCD_2_0_6;
  EndpointType protocol = EndpointType.BIOCASE;
  Integer crawlId = 1;
  fragmentProcessor.buildFragments(datasetKey, abcd206Single.getBytes(), schemaType, protocol, crawlId, null);

  Fragment got = fragmentPersistenceService.get(1);
  assertTrue(got.getKey() > 0);
  Calendar resultCal = Calendar.getInstance();
  resultCal.setTime(got.getHarvestedDate());
  Calendar cal = Calendar.getInstance();
  assertEquals(cal.get(Calendar.DAY_OF_YEAR), resultCal.get(Calendar.DAY_OF_YEAR));
  assertEquals(Fragment.FragmentType.XML, got.getFragmentType());
  assertEquals(schemaType, got.getXmlSchema());
  assertEquals(datasetKey, got.getDatasetKey());
  assertEquals(protocol, got.getProtocol());
  assertEquals(crawlId, got.getCrawlId());
  assertTrue(Arrays.equals(abcd206Single.getBytes(), got.getData()));
  assertTrue(Arrays.equals(DigestUtils.md5(abcd206Single), got.getDataHash()));
  assertNull(got.getUnitQualifier());
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:24,代码来源:FragmentProcessorTest.java

示例11: setUp

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  long now = new Date().getTime();
  zkServer = new TestingServer();
  curator = CuratorFrameworkFactory.builder().connectString(zkServer.getConnectString()).namespace("crawler")
    .retryPolicy(new RetryNTimes(1, 1000)).build();
  curator.start();
  zookeeperConnector = new ZookeeperConnector(curator);

  fragmentService = new FragmentPersistenceServiceMock(new OccurrenceKeyPersistenceServiceMock());
  String json = Resources.toString(Resources.getResource("fragment.json"), org.apache.commons.io.Charsets.UTF_8);
  Fragment fragment = new Fragment(DATASET_KEY, json.getBytes(Charsets.UTF_8), json.getBytes(Charsets.UTF_8),
    Fragment.FragmentType.JSON, EndpointType.DWC_ARCHIVE, new Date(), 1, null, null, new Date().getTime());
  Set<UniqueIdentifier> uniqueIds = Sets.newHashSet();
  uniqueIds.add(new HolyTriplet(DATASET_KEY, "ic", "cc", "cn", null));
  fragmentService.insert(fragment, uniqueIds);
  occurrenceService = new OccurrencePersistenceServiceMock(fragmentService);
  verbatimProcessor = new VerbatimProcessor(fragmentService, occurrenceService, messagePublisher, zookeeperConnector);
  FragmentPersistedListener fragmentPersistedListener = new FragmentPersistedListener(verbatimProcessor);
  MessageListener messageListener = new MessageListener(CONNECTION_PARAMETERS);
  messageListener.listen("frag_persisted_test_" + now, 1, fragmentPersistedListener);
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:23,代码来源:VerbatimProcessorTest.java

示例12: setUp

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  ApiClientConfiguration cfg = new ApiClientConfiguration();;
  cfg.url = URI.create("http://api.gbif-dev.org/v1/");

  FragmentPersistenceService fragmentPersister =
    new FragmentPersistenceServiceMock(new OccurrenceKeyPersistenceServiceMock());
  Fragment fragment = new Fragment(DATASET_KEY, "fake".getBytes(Charsets.UTF_8), "fake".getBytes(Charsets.UTF_8),
    Fragment.FragmentType.JSON, EndpointType.DWC_ARCHIVE, new Date(), 1, null, null, new Date().getTime());
  Set<UniqueIdentifier> uniqueIds = Sets.newHashSet();
  uniqueIds.add(new HolyTriplet(DATASET_KEY, "ic", "cc", "cn", null));
  fragmentPersister.insert(fragment, uniqueIds);
  interpreter = new OccurrenceInterpreter(new DatasetInfoInterpreter(cfg.newApiClient()),
    new TaxonomyInterpreter(cfg.newApiClient()),
    new LocationInterpreter(new CoordinateInterpreter(cfg.newApiClient())));

  verb = buildVerbatim(fragment.getKey());

  verbMod = buildVerbatim(fragment.getKey());
  verbMod.setVerbatimField(DwcTerm.scientificName, "Panthera onca goldmani");
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:22,代码来源:OccurrenceInterpreterTest.java

示例13: DatasetServiceFileImpl

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
/**
 * TAB delimited file with columns:
 * key (UUID)
 * title (String)
 * dwca url (URL)
 */
public DatasetServiceFileImpl(File dataFile) {
  datasets = Maps.newTreeMap();

  try (InputStream in = new FileInputStream(dataFile)) {
    CSVReader reader = CSVReaderFactory.buildUtf8TabReader(in);
    int endKey = 1;
    while (reader.hasNext()) {
      String[] row = reader.next();
      if (row != null && row.length >= 3 && !row[0].startsWith("#")) {
        Dataset d = new Dataset();
        d.setType(DatasetType.CHECKLIST);
        d.setKey(UUID.fromString(row[0].trim()));
        d.setTitle(row[1].trim());

        Endpoint end = new Endpoint();
        end.setKey(endKey++);
        end.setType(EndpointType.DWC_ARCHIVE);
        end.setUrl(URI.create(row[2].trim()));
        d.getEndpoints().add(end);

        datasets.put(d.getKey(), d);
      }
    }
  } catch (IOException e) {
    Throwables.propagate(e);
  }
  LOG.info("Loaded {} datasets into registry from {}", datasets.size(), dataFile.getAbsolutePath());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:35,代码来源:DatasetServiceFileImpl.java

示例14: testProtocolAndPublishingCountry

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
@Test
public void testProtocolAndPublishingCountry() {
  Occurrence occ = new Occurrence();
  occ.setKey(1);
  occ.setDatasetKey(UUID.randomUUID());
  occ.setProtocol(EndpointType.BIOCASE);
  occ.setPublishingCountry(Country.AFGHANISTAN);

  assertEquals(EndpointType.BIOCASE, occ.getProtocol());
  assertEquals(Country.AFGHANISTAN, occ.getPublishingCountry());
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:12,代码来源:OccurrenceTest.java

示例15: buildOcc

import org.gbif.api.vocabulary.EndpointType; //导入依赖的package包/类
private OccurrenceWritable buildOcc() {
  OccurrenceWritable ow = new OccurrenceWritable();
  ow.setTaxonKey(1);
  ow.setKingdomKey(1);
  ow.setDatasetKey(testUuid);
  ow.setPublishingCountry(Country.UNITED_KINGDOM);
  ow.setBasisOfRecord(BasisOfRecord.FOSSIL_SPECIMEN);
  ow.setProtocol(EndpointType.DWC_ARCHIVE);
  ow.setLatitude(0.89);
  ow.setLongitude(null);
  ow.setYear(2012);
  ow.setCount(1);
  return ow;
}
 
开发者ID:gbif,项目名称:metrics,代码行数:15,代码来源:OccurrenceWritableTest.java


注:本文中的org.gbif.api.vocabulary.EndpointType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。