本文整理汇总了Java中org.gbif.api.model.registry.Dataset类的典型用法代码示例。如果您正苦于以下问题:Java Dataset类的具体用法?Java Dataset怎么用?Java Dataset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Dataset类属于org.gbif.api.model.registry包,在下文中一共展示了Dataset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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());
}
示例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;
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}