• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Dataset类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: list

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
public List<Dataset> list() {
PagingResponse<Dataset> response = list((Pageable)null);
if(response == null)
    return null;

List<Dataset> datasets = Lists.newArrayList(response.getResults());
boolean isInitial = false;
int limit = -1;
while(Pager.isEndOfRecords(response)) {
    if(isInitial) {
	limit = Pager.getMaxLimit(response);
    }
    response.setOffset(response.getOffset() + response.getLimit());
    if(isInitial) {
	response.setLimit(limit);
	isInitial = false;
    }

    response = list(response);
    datasets.addAll(response.getResults());
}

return datasets;
   }
 
开发者ID:nomencurator,项目名称:taxonaut,代码行数:25,代码来源:DatasetAPIClient.java


示例2: listConstituents

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
public List<Dataset> listConstituents(UUID datasetKey)
   {
PagingResponse<Dataset> response = listConstituents(datasetKey, null);
if(response == null)
    return null;

List<Dataset> datasets = Lists.newArrayList(response.getResults());
while(Pager.isEndOfRecords(response)) {
    response.setOffset(response.getOffset() + response.getLimit());
    response = listConstituents(datasetKey, response);
    datasets.addAll(response.getResults());
}

return datasets;

   }
 
开发者ID:nomencurator,项目名称:taxonaut,代码行数:17,代码来源:DatasetAPIClient.java


示例3: setDataset

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
public boolean setDataset(Dataset dataset)
   {
NameUsage<? extends NubNameUsage> n = getNameUsage();
if(n != this) {
    if(n instanceof NubNameUsage) {
	return ((NubNameUsage)n).setDataset(dataset);
    }
}

if(dataset != null) {
    if(scientificNameUsage != null
       && ! Objects.equals(scientificNameUsage.getDatasetKey(), dataset.getKey())) {
       return false;
    }

    if(nameUsageSearchResult != null
       && ! Objects.equals(nameUsageSearchResult.getDatasetKey(), dataset.getKey())) {
       return false;
    }
}

this.dataset = dataset;

return true;
   }
 
开发者ID:nomencurator,项目名称:taxonaut,代码行数:26,代码来源:NubNameUsage.java


示例4: setConstituentDataset

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
public boolean setConstituentDataset(Dataset dataset)
   {
NameUsage<? extends NubNameUsage> n = getNameUsage();
if(n != this) {
    if(n instanceof NubNameUsage) {
	return ((NubNameUsage)n).setConstituentDataset(dataset);
    }
}

if(dataset != null) {
    if(scientificNameUsage != null
       && ! Objects.equals(scientificNameUsage.getConstituentKey(), dataset.getKey())) {
       return false;
    }

    if(nameUsageSearchResult != null
       && ! Objects.equals(nameUsageSearchResult.getConstituentKey(), dataset.getKey())) {
       return false;
    }
}

this.constituentDataset = dataset;

return true;
   }
 
开发者ID:nomencurator,项目名称:taxonaut,代码行数:26,代码来源:NubNameUsage.java


示例5: getDataset

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
protected Dataset getDataset(UUID datasetKey)
throws IOException
   {
if(datasetKey == null)
    return null;

Dataset dataset = null;
synchronized(datasets) {
    dataset = datasets.get(datasetKey);
}

if(dataset == null) {
    dataset = datasetSource.get(datasetKey);
    if(dataset != null) {
	synchronized(datasets) {
	    Dataset reconfirm = datasets.get(datasetKey);
	    if(reconfirm != null) {
		dataset = reconfirm;
	    }
	    datasets.put(datasetKey, dataset);
	}
    }
}

return dataset;
   }
 
开发者ID:nomencurator,项目名称:taxonaut,代码行数:27,代码来源:NubExchanger.java


示例6: write

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
@Test
public void write() throws Exception {
    File dwca = FileUtils.createTempDir();
    Map<Term, Integer> mapping = ImmutableMap.of(
            DwcTerm.taxonID, 0,
            DwcTerm.scientificName, 1,
            DwcTerm.taxonRank, 2);
    try (DwcaStreamWriter dwcaWriter = new DwcaStreamWriter(dwca, DwcTerm.Taxon, DwcTerm.taxonID, true)){
        Dataset d = new Dataset();
        d.setTitle("Abies of the Alps");
        d.setDescription("Abies of the Alps excl Switzerland.");
        dwcaWriter.setMetadata(d);
        dwcaWriter.write(DwcTerm.Taxon, 0, mapping, ImmutableList.<String[]>builder()
                .add(new String[] { "tax-1", "Abies Mill.", "genus" })
                .add(new String[] { "tax-2", "Abies alba Mill.", "species" })
                .add(new String[] { "tax-3", "Piceae abies L.", "species" })
                .add(new String[] { "tax-4", "Piceae abies subsp. helvetica L.", "subspecies" })
                .build()
        );

    } finally {
        org.apache.commons.io.FileUtils.deleteQuietly(dwca);
    }
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:25,代码来源:DwcaStreamWriterTest.java


示例7: cleanup

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
private void cleanup(Dataset d) throws IOException {
  try {
    if (cfg.zookeeper.isConfigured()) {
      zk().delete(ZookeeperUtils.getCrawlInfoPath(d.getKey(), null));
      LOG.info("Removed crawl {} from ZK running queue", d.getKey());

      //TODO: clear pending & running queues
    }

    // cleanup repo files
    final File dwcaFile = new File(cfg.archiveRepository, d.getKey() + DWCA_SUFFIX);
    FileUtils.deleteQuietly(dwcaFile);
    File dir = cfg.archiveDir(d.getKey());
    if (dir.exists() && dir.isDirectory()) {
      FileUtils.deleteDirectory(dir);
    }
    LOG.info("Removed dwca files from repository {}", dwcaFile);

    RegistryService.deleteStorageFiles(cfg.neo, d.getKey());

  } catch (Exception e) {
    LOG.error("Failed to cleanup dataset {}", d.getKey(), e);
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:25,代码来源:AdminCommand.java


示例8: rematchChecklists

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
private void rematchChecklists() {
  try {
    LOG.info("Start sending match dataset messages for all checklists, starting with CoL");

    int counter = 1;
    // make sure we match CoL first as we need that to analyze datasets (nub & col overlap of names)
    publisher.send(new MatchDatasetMessage(Constants.COL_DATASET_KEY));
    for (Dataset d : Iterables.datasets(DatasetType.CHECKLIST, datasetService)) {
      if (Constants.COL_DATASET_KEY.equals(d.getKey()) || Constants.NUB_DATASET_KEY.equals(d.getKey())) {
        continue;
      }
      publisher.send(new MatchDatasetMessage(d.getKey()));
      counter++;
    }
    LOG.info("Send dataset match message for all {} checklists", counter);

  } catch (Exception e) {
    LOG.error("Failed to handle BackboneChangedMessage", e);
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:21,代码来源:NubChangedService.java


示例9: downloadAndExtract

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
private void downloadAndExtract(Dataset d, URI dwcaUri) throws IOException, UnsupportedArchiveException {
  final File dwca = cfg.archiveFile(d.getKey());
  if (dwca.exists()) {
    dwca.delete();
    LOG.debug("Removed previous dwc archive at {}", dwca.getAbsolutePath());
  }
  http.download(dwcaUri, dwca);

  // success!
  LOG.info("Downloaded dwc archive for dataset {} from {} to {}", d.getTitle(), dwcaUri, dwca.getAbsolutePath());

  // open archive
  final File archiveDir = cfg.archiveDir(d.getKey());
  if (archiveDir.exists()) {
    FileUtils.deleteDirectory(archiveDir);
    LOG.debug("Removed previous dwc archive dir {}", dwca.getAbsolutePath());
  }
  ArchiveFactory.openArchive(dwca, archiveDir);
  LOG.debug("Opened dwc archive successfully for dataset {} at {}", d.getTitle(), dwca, archiveDir.getAbsolutePath());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:21,代码来源:CrawlerService.java


示例10: handleMessage

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
@Override
public void handleMessage(RegistryChangeMessage msg) {
  if (Dataset.class.equals(msg.getObjectClass())) {
    Dataset d = (Dataset) ObjectUtils.coalesce(msg.getNewObject(), msg.getOldObject());
    if (d != null && DatasetType.CHECKLIST == d.getType()) {
      DatasetCore dc = new DatasetCore(d);
      switch (msg.getChangeType()) {
        case DELETED:
          delete(d.getKey());
          break;
        case UPDATED:
          datasetMapper.update(dc);
          break;
        case CREATED:
          datasetMapper.insert(dc);
          break;
      }
    }
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:21,代码来源:RegistryService.java


示例11: list

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
@Override
public PagingResponse<Dataset> list(@Nullable Pageable page) {
  if (page == null) {
    page = new PagingResponse<Dataset>();
  }
  PagingResponse<Dataset> resp = new PagingResponse<Dataset>();
  int idx = 1;
  for (Map.Entry<UUID, Dataset> e: datasets.entrySet()) {
    if (idx >= page.getOffset()) {
      if (idx >= page.getLimit()) {
        break;
      }
      resp.getResults().add(e.getValue());
    }
    idx++;
  }
  resp.setCount((long) datasets.size());
  return resp;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:20,代码来源:DatasetServiceFileImpl.java


示例12: writeCitation

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
private static String writeCitation(Writer citationWriter, Dataset dataset, UUID constituentId)
  throws IOException {
  // citation
  String citationLink = null;
  if (dataset.getCitation() != null && !Strings.isNullOrEmpty(dataset.getCitation().getText())) {
    citationWriter.write('\n' + dataset.getCitation().getText());
    if (!Strings.isNullOrEmpty(dataset.getCitation().getIdentifier())) {
      citationLink = ", " + dataset.getCitation().getIdentifier();
      citationWriter.write(citationLink);
    }
  } else {
    LOG.error(String.format("Constituent dataset misses mandatory citation for id: %s", constituentId));
  }
  if (dataset.getDoi() != null) {
    citationWriter.write(" " + dataset.getDoi());
  }
  return citationLink;
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:19,代码来源:DwcaArchiveBuilder.java


示例13: DwcaArchiveBuilder

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
@VisibleForTesting
protected DwcaArchiveBuilder(
  DatasetService datasetService,
  DatasetOccurrenceDownloadUsageService datasetUsageService,
  OccurrenceDownloadService occurrenceDownloadService,
  FileSystem sourceFs,
  FileSystem targetFs,
  File archiveDir,
  TitleLookup titleLookup,
  DownloadJobConfiguration configuration,
  WorkflowConfiguration workflowConfiguration
) {
  this.datasetService = datasetService;
  this.datasetUsageService = datasetUsageService;
  this.occurrenceDownloadService = occurrenceDownloadService;
  this.sourceFs = sourceFs;
  this.targetFs = targetFs;
  this.archiveDir = archiveDir;
  this.titleLookup = titleLookup;
  dataset = new Dataset();
  this.configuration = configuration;
  this.workflowConfiguration = workflowConfiguration;
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:24,代码来源:DwcaArchiveBuilder.java


示例14: persistDatasetUsage

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
/**
 * Persists the dataset usage information and swallows any exception to avoid an error during the file building.
 */
private void persistDatasetUsage(Integer count, String downloadKey, UUID datasetKey) {
  try {
    Dataset dataset = datasetService.get(datasetKey);
    if (dataset != null) { //the dataset still exists
      DatasetOccurrenceDownloadUsage datasetUsage = new DatasetOccurrenceDownloadUsage();
      datasetUsage.setDatasetKey(datasetKey);
      datasetUsage.setNumberRecords(count);
      datasetUsage.setDownloadKey(downloadKey);
      datasetUsage.setDatasetDOI(dataset.getDoi());
      if (dataset.getCitation() != null && dataset.getCitation().getText() != null) {
        datasetUsage.setDatasetCitation(dataset.getCitation().getText());
      }
      datasetUsage.setDatasetTitle(dataset.getTitle());
      datasetUsageService.create(datasetUsage);
    }
  } catch (Exception e) {
    LOG.error("Error persisting dataset usage information, downloadKey: {}, datasetKey: {}", downloadKey,
              datasetKey, e);
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:24,代码来源:DwcaArchiveBuilder.java


示例15: persistDatasetUsage

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
/**
 * Persists the dataset usage information and swallows any exception to avoid an error during the file building.
 */
private static void persistDatasetUsage(Entry<UUID, Long> usage, String downloadKey,
                                        DatasetOccurrenceDownloadUsageService datasetOccUsageService,
                                        DatasetService datasetService) {
  try {
    Dataset dataset = datasetService.get(usage.getKey());
    if (dataset != null) { //the dataset still exists
      DatasetOccurrenceDownloadUsage datasetUsage = new DatasetOccurrenceDownloadUsage();
      datasetUsage.setDatasetKey(dataset.getKey());
      datasetUsage.setNumberRecords(usage.getValue());
      datasetUsage.setDownloadKey(downloadKey);
      datasetUsage.setDatasetDOI(dataset.getDoi());
      if (dataset.getCitation() != null && dataset.getCitation().getText() != null) {
        datasetUsage.setDatasetCitation(dataset.getCitation().getText());
      }
      datasetUsage.setDatasetTitle(dataset.getTitle());
      datasetOccUsageService.create(datasetUsage);
    }
  } catch (Exception e) {
    LOG.error("Error persisting dataset usage information", e);
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:25,代码来源:CitationsFileWriter.java


示例16: getContentProviderContact

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
/**
 * Checks the contacts of a dataset and finds the preferred contact that should be used as the main author
 * of a dataset.
 *
 * @return preferred author contact or null
 */
public static Contact getContentProviderContact(Dataset dataset) {
  Contact author = findFirstAuthor(dataset);
  if (author != null) {
    Contact provider = new Contact();
    try {
      PropertyUtils.copyProperties(provider, author);
      provider.setKey(null);
      provider.setType(ContactType.CONTENT_PROVIDER);
      provider.setPrimary(false);
      return provider;
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
      LOG.error("Error setting provider contact", e);
    }
  }
  return author;
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:23,代码来源:DwcaContactsUtil.java


示例17: apply

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
@Override
public boolean apply(@Nullable DatasetOccurrenceDownloadUsage input) {
  try {
    Dataset dataset = datasetService.get(input.getDatasetKey());
    if (dataset != null) { //the dataset still exists
      input.setDatasetDOI(dataset.getDoi());
      if (dataset.getCitation() != null && dataset.getCitation().getText() != null) {
        input.setDatasetCitation(dataset.getCitation().getText());
      }
      input.setDatasetTitle(dataset.getTitle());
      datasetUsageService.create(input);
    }
  } catch (Exception e) {
    LOG.error("Error persisting dataset usage information {}", input, e);
    return false;
  }
  return true;
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:19,代码来源:CitationsFileReader.java


示例18: getOrgByDataset

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
/**
 * Find and return the organization which publishes the dataset for the given datasetKey.
 *
 * @param datasetKey the dataset publisher to find
 * @return the organization that publishes the dataset
 */
@Nullable
@VisibleForTesting
protected Organization getOrgByDataset(UUID datasetKey) {
  checkNotNull(datasetKey, "datasetKey can't be null");

  Organization org = null;
  try {
    Dataset dataset = datasetCache.get(datasetKey);
    if (dataset != null && dataset.getPublishingOrganizationKey() != null) {
      org = orgCache.get(dataset.getPublishingOrganizationKey());
    }
  } catch (UncheckedExecutionException | ExecutionException e) {
    LOG.warn("WS failure while looking up org for dataset [{}]", datasetKey, e);
  }

  return org == null ? null : org;
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:24,代码来源:DatasetInfoInterpreter.java


示例19: getDatasetLicense

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
/**
 * Find and return the organization which publishes the dataset for the given datasetKey.
 *
 * @param datasetKey the dataset publisher to find
 * @return the dataset license
 */
@Nullable
@VisibleForTesting
protected License getDatasetLicense(UUID datasetKey) {
  checkNotNull(datasetKey, "datasetKey can't be null");

  License license = null;
  try {
    Dataset dataset = datasetCache.get(datasetKey);
    if (dataset != null && dataset.getLicense() != null) {
      license = dataset.getLicense();
    }
  } catch (UncheckedExecutionException | ExecutionException e) {
    LOG.warn("WS failure while looking up org for dataset [{}]", datasetKey, e);
  }

  return license == null ? null : license;
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:24,代码来源:DatasetInfoInterpreter.java


示例20: setup

import org.gbif.api.model.registry.Dataset; //导入依赖的package包/类
@Override
protected void setup(Context context) throws IOException, InterruptedException {
  super.setup(context);

  datasetCache = CacheBuilder.newBuilder()
          .maximumSize(MAX_DATASET_CACHE)
          .build(
                  new CacheLoader<UUID, Dataset>() {
                    public Dataset load(UUID datasetKey) {
                      return datasetService.get(datasetKey);
                    }
                  });

  organizationCache = CacheBuilder.newBuilder()
          .maximumSize(MAX_ORGANIZATION_CACHE)
          .build(
                  new CacheLoader<UUID, Organization>() {
                    public Organization load(UUID key) {
                      return orgService.get(key);
                    }
                  });
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:23,代码来源:OccurrenceRegistryMapper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AMSimulator类代码示例发布时间:2022-05-22
下一篇:
Java JBrowserDriver类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap