本文整理汇总了Java中org.gbif.api.model.checklistbank.Distribution类的典型用法代码示例。如果您正苦于以下问题:Java Distribution类的具体用法?Java Distribution怎么用?Java Distribution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Distribution类属于org.gbif.api.model.checklistbank包,在下文中一共展示了Distribution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEmptyModels
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
@Test
public void testEmptyModels() throws Exception {
assertSerde(new NameUsage());
assertSerde(new VerbatimNameUsage());
assertSerde(new NameUsageMetrics());
assertSerde(new UsageExtensions());
assertSerde(new ParsedName());
assertSerde(new Description());
assertSerde(new Distribution());
assertSerde(new Identifier());
assertSerde(new NameUsageMediaObject());
assertSerde(new Reference());
assertSerde(new SpeciesProfile());
assertSerde(new NameUsage());
assertSerde(new TypeSpecimen());
assertSerde(new VernacularName());
assertSerde(new DatasetMetrics());
}
示例2: assertObject
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
private void assertObject(Distribution obj, Distribution obj2, String source, Integer sourceTaxonKey) {
assertEquals(obj.getAppendixCites(), obj2.getAppendixCites());
assertEquals(obj.getCountry(), obj2.getCountry());
assertEquals(obj.getEndDayOfYear(), obj2.getEndDayOfYear());
assertEquals(obj.getEstablishmentMeans(), obj2.getEstablishmentMeans());
assertEquals(obj.getLifeStage(), obj2.getLifeStage());
assertEquals(obj.getLocality(), obj2.getLocality());
assertEquals(obj.getLocationId(), obj2.getLocationId());
assertEquals(obj.getRemarks(), obj2.getRemarks());
assertEquals(obj.getStartDayOfYear(), obj2.getStartDayOfYear());
assertEquals(obj.getStatus(), obj2.getStatus());
assertEquals(obj.getTemporal(), obj2.getTemporal());
assertEquals(obj.getThreatStatus(), obj2.getThreatStatus());
assertEquals(source, obj2.getSource());
assertEquals(sourceTaxonKey, obj2.getSourceTaxonKey());
}
示例3: addDistributionsAndThreatStatus
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
/**
* Utility method that iterates over all the {@link org.gbif.api.model.checklistbank.Distribution} objects of a {@link org.gbif.api.model.checklistbank.NameUsage}.
*
* @param doc to be modified by adding the distributions fields
*/
private static void addDistributionsAndThreatStatus(NameUsageAvro nameUsageAvro, UsageExtensions ext) {
if (ext.distributions == null) {
return;
}
List<Integer> threatStatusKeys = Lists.newArrayList();
for (Distribution distribution : ext.distributions) {
if (distribution.getThreatStatus() != null) {
threatStatusKeys.add(distribution.getThreatStatus().ordinal());
}
}
nameUsageAvro.setThreatStatusKey(threatStatusKeys);
}
示例4: testDistributionRange
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
@Test
public void testDistributionRange() throws Exception {
int start = 100000040;
int end = 101000000;
Map<Integer, List<Distribution>> range = distributionService.listRange(start, end);
assertEquals(1, range.size());
assertEquals(10, range.get(100000040).size());
}
示例5: interpretDistribution
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
private void interpretDistribution(NameUsage u, UsageExtensions e, VerbatimNameUsage v) {
if (v.hasExtension(Extension.DISTRIBUTION)) {
for (Map<Term, String> rec : v.getExtensions().get(Extension.DISTRIBUTION)) {
Distribution d = new Distribution();
// interpret rec
d.setLocality(value(rec, DwcTerm.locality));
d.setLocationId(value(rec, DwcTerm.locationID));
d.setCountry(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, countryParser, u, DwcTerm.country, DwcTerm.countryCode));
// some location is required, otherwise its pointless
if (d.getLocality() == null && d.getLocationId() == null && d.getCountry() == null) {
u.addIssue(NameUsageIssue.DISTRIBUTION_INVALID);
continue;
}
d.setStatus(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, occurrenceStatusParser, u, DwcTerm.occurrenceStatus));
d.setEstablishmentMeans(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, establishmentMeansParser, u, DwcTerm.establishmentMeans));
d.setAppendixCites(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, citesAppendixParser, u, GbifTerm.appendixCITES));
d.setThreatStatus(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, threatStatusParser, u, IucnTerm.threatStatus));
d.setLifeStage(enumify(rec, NameUsageIssue.DISTRIBUTION_INVALID, lifeStageParser, u, DwcTerm.lifeStage));
d.setTemporal(value(rec, DwcTerm.eventDate, DcTerm.temporal));
d.setEndDayOfYear(integer(rec, NameUsageIssue.DISTRIBUTION_INVALID, u, DwcTerm.endDayOfYear));
d.setStartDayOfYear(integer(rec, NameUsageIssue.DISTRIBUTION_INVALID, u, DwcTerm.startDayOfYear));
d.setRemarks(value(rec, DwcTerm.occurrenceRemarks, DwcTerm.taxonRemarks));
d.setSource(value(rec, DcTerm.source));
e.distributions.add(d);
}
}
}
示例6: testListByRange
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
@Test
public void testListByRange() {
Map<Integer, List<Distribution>> map = ((DistributionServiceMyBatis) service).listRange(1, 100000020);
assertEquals(1, map.size());
List<Distribution> records = map.get(100000007);
assertEquals(4, records.size());
for (Distribution v : records) {
assertNull(v.getSourceTaxonKey());
}
}
示例7: handleResult
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
@Override
public void handleResult(ResultContext<? extends Distribution> resultContext) {
if (resultContext.getResultObject() != null) {
counter++;
Distribution d = resultContext.getResultObject();
System.out.println(d);
assertNotNull(d.getTaxonKey());
assertNotNull(d.getLocality());
}
}
示例8: testMapper
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
@Test
public void testMapper() throws Exception {
assertTrue(mapper.listByChecklistUsage(usageKey, new PagingRequest()).isEmpty());
assertTrue(mapper.listByNubUsage(usageKey, new PagingRequest()).isEmpty());
Distribution obj = new Distribution();
obj.setAppendixCites(CitesAppendix.II);
obj.setCountry(Country.ALGERIA);
obj.setEndDayOfYear(1990);
obj.setEstablishmentMeans(EstablishmentMeans.NATIVE);
obj.setLifeStage(LifeStage.EMRYO);
obj.setLocality("location location location");
obj.setLocationId("locID");
obj.setRemarks("remarks");
obj.setStartDayOfYear(1989);
obj.setStatus(OccurrenceStatus.COMMON);
obj.setTemporal("aha");
obj.setThreatStatus(ThreatStatus.CRITICALLY_ENDANGERED);
// these should get ignored
obj.setSource("sourcy s");
obj.setSourceTaxonKey(123);
mapper.insert(usageKey, obj, citationKey1);
Distribution obj2 = mapper.listByChecklistUsage(usageKey, new PagingRequest()).get(0);
assertObject(obj, obj2, citation1, null);
obj2 = mapper.listByNubUsage(nubKey, new PagingRequest()).get(0);
// these are now nub source usage values
assertObject(obj, obj2, datasetTitle, usageKey);
}
示例9: DistributionWsClient
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
@Inject
public DistributionWsClient(@ChecklistBankWs WebResource resource) {
super(Distribution.class, new GenericType<PagingResponse<Distribution>>() {
}, resource, Constants.DISTRIBUTIONS_PATH);
}
示例10: DistributionWsClientTest
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
public DistributionWsClientTest() {
super(Distribution.class);
}
示例11: getClient
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
@Override
NameUsageComponentBaseWsClient<Distribution> getClient(WebResource resource) {
return new DistributionWsClient(resource);
}
示例12: getMockObject
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
@Override
Distribution getMockObject() {
Distribution distribution = new Distribution();
distribution.setThreatStatus(ThreatStatus.ENDANGERED);
return distribution;
}
示例13: call
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
/**
* Iterates over the assigned {@link org.gbif.api.model.checklistbank.NameUsage} objects to insert the corresponding {@link org.apache.solr.common.SolrInputDocument}
* objects.
*
* @return the total number of documents added by this Thread.
*/
@Override
public Integer call() throws Exception {
// Timing information initialization
stopWatch.start();
log.info("Adding usages from id {} to {}", startKey, endKey);
int docCount = 0;
// Get all usages
List<NameUsage> usages = nameUsageService.listRange(startKey, endKey);
// get all component maps into memory first
Map<Integer, List<VernacularName>> vernacularNameMap = vernacularNameService.listRange(startKey, endKey);
Map<Integer, List<Description>> descriptionMap = descriptionService.listRange(startKey, endKey);
Map<Integer, List<Distribution>> distributionMap = distributionService.listRange(startKey, endKey);
Map<Integer, List<SpeciesProfile>> speciesProfileMap = speciesProfileService.listRange(startKey, endKey);
File file = new File(startKey+ "-" + endKey + ".avro");
file.createNewFile();
log.info("Creating file " + file.getAbsolutePath());
ClassLoader classLoader = AvroExporter.class.getClassLoader();
Schema schema = new Schema.Parser().parse(classLoader.getResource("solr.avrsc").openStream());
DatumWriter<NameUsageAvro> datumWriter = new SpecificDatumWriter<>(NameUsageAvro.class);
try(DataFileWriter<NameUsageAvro> dataFileWriter = new DataFileWriter<NameUsageAvro>(datumWriter)) {
dataFileWriter.create(schema, file);
// now we're ready to build the solr indices quicky!
for (NameUsage usage : usages) {
if (usage == null) {
log.warn("Unexpected numm usage found in range {}-{}, docCount={}", startKey, endKey, docCount);
continue;
}
try {
UsageExtensions ext = new UsageExtensions();
ext.speciesProfiles = speciesProfileMap.get(usage.getKey());
ext.vernacularNames = vernacularNameMap.get(usage.getKey());
ext.descriptions = descriptionMap.get(usage.getKey());
ext.distributions = distributionMap.get(usage.getKey());
List<Integer> parents = nameUsageService.listParents(usage.getKey());
dataFileWriter.append(nameUsageAvroConverter.toObject(usage, parents, ext));
} catch (Exception e) {
log.error("Error exporting usage {} extension {} to avro", usage, e);
}
docCount++;
NameUsageBatchProcessor.counter.incrementAndGet();
}
}
moveToHdfs(file,nameNode);
log.info(file.getName() + " moved to hdfs");
// job finished notice
stopWatch.stop();
log.info("Finished indexing of usages in range {}-{}. Total time: {}",
new Object[] {startKey, endKey, stopWatch.toString()});
return docCount;
}
示例14: call
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
/**
* Iterates over the assigned {@link NameUsage} objects to insert the corresponding {@link SolrInputDocument}
* objects.
*
* @return the total number of documents added by this Thread.
*/
@Override
public Integer call() throws Exception {
// Timing information initialization
stopWatch.start();
log.info("Adding usages from id {} to {}", startKey, endKey);
int docCount = 0;
// Get all usages
List<NameUsage> usages = nameUsageService.listRange(startKey, endKey);
// get all component maps into memory first
Map<Integer, List<VernacularName>> vernacularNameMap = vernacularNameService.listRange(startKey, endKey);
Map<Integer, List<Description>> descriptionMap = descriptionService.listRange(startKey, endKey);
Map<Integer, List<Distribution>> distributionMap = distributionService.listRange(startKey, endKey);
Map<Integer, List<SpeciesProfile>> speciesProfileMap = speciesProfileService.listRange(startKey, endKey);
// now we're ready to build the solr indices quicky!
for (Iterable<NameUsage> batch : Iterables.partition(usages, batchSize)) {
final List<SolrInputDocument> docs = Lists.newArrayList();
try {
for (NameUsage usage : batch) {
if (usage==null) {
log.warn("Unexpected null usage found in range {}-{}, docCount={}", startKey, endKey, docCount);
continue;
}
UsageExtensions ext = new UsageExtensions();
ext.speciesProfiles = speciesProfileMap.get(usage.getKey());
ext.vernacularNames = vernacularNameMap.get(usage.getKey());
ext.descriptions = descriptionMap.get(usage.getKey());
ext.distributions = distributionMap.get(usage.getKey());
List<Integer> parents = nameUsageService.listParents(usage.getKey());
docs.add(solrDocumentConverter.toDoc(usage, parents, ext));
docCount++;
}
solrClient.add(docs);
NameUsageBatchProcessor.counter.addAndGet(docs.size());
} catch (Exception e) {
log.error("Error indexing document for usage batch", e);
}
}
// job finished notice
stopWatch.stop();
log.info("Finished indexing of usages in range {}-{}. Total time: {}", startKey, endKey, stopWatch.toString());
return docCount;
}
示例15: getDistributions
import org.gbif.api.model.checklistbank.Distribution; //导入依赖的package包/类
public PagingResponse<Distribution> getDistributions(int usageKey, @Nullable Pageable page);