本文整理汇总了Java中org.gbif.api.model.registry.Dataset.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java Dataset.setTitle方法的具体用法?Java Dataset.setTitle怎么用?Java Dataset.setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gbif.api.model.registry.Dataset
的用法示例。
在下文中一共展示了Dataset.setTitle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: DatasetServiceFileImpl
import org.gbif.api.model.registry.Dataset; //导入方法依赖的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());
}
示例3: matchDataset
import org.gbif.api.model.registry.Dataset; //导入方法依赖的package包/类
/**
* Updates a datasets nub matches.
* Uses the internal Lookup to generate a complete id map and then does postgres writes in a separate thread ?!
*/
public DatasetMatchSummary matchDataset(UUID key) throws DatasetMatchFailed {
Dataset d = new Dataset();
d.setKey(key);
d.setTitle("Dataset " + key);
final DatasetMatchSummary summary = new DatasetMatchSummary(d.getKey());
if (Constants.NUB_DATASET_KEY.equals(d.getKey())) {
LOG.warn("Cannot match backbone to itself. Ignore");
return summary;
}
LOG.info("Rematch checklist {} to Backbone", d.getKey());
Map<Integer, Integer> relations = Maps.newHashMap();
try (ClbSource src = new ClbSource(cfg, d)) {
// read in postgres usages
LOG.info("Copy usages for {} from pg into neo", d.getKey());
src.init(false, false);
NubUsage unknown = new NubUsage();
unknown.usageKey = Kingdom.INCERTAE_SEDIS.nubUsageKey();
unknown.kingdom = Kingdom.INCERTAE_SEDIS;
// this is a taxonomically sorted iteration. We remember the parent kingdom using the ParentStack
ParentStack parents = new ParentStack(unknown);
for (SrcUsage u : src) {
parents.add(u);
if (u.parsedName == null || !u.parsedName.isParsed()) {
summary.addUnparsable();
}
LookupUsage match = nubLookup.match(u.parsedName.canonicalName(), u.parsedName.getAuthorship(), u.parsedName.getYear(), u.rank, parents.nubKingdom());
if (match != null) {
summary.addMatch(u.rank);
// add to relations
relations.put(u.key, match.getKey());
// store current kingdom in parent stack for further nub lookups of children
NubUsage nub = new NubUsage();
nub.kingdom = match.getKingdom();
parents.put(nub);
} else {
summary.addNoMatch(u.rank);
LOG.debug("No match for {} in dataset {}. Parsed name: {}", u, d.getKey(), u.parsedName);
// also store no matches as nulls so we can flag an issue
relations.put(u.key, null);
}
}
// warn if matches are little
// but ignore very small datasets where chances are high due to higher taxa often not matching
if (summary.percBackboneRelevantNoMatches() < 25 || (summary.percMatches() < 25 && summary.getTotalUsages() > 25)) {
LOG.warn("Only {}% of all names and {}% of genera and below in dataset {} were matching", summary.percMatches(), summary.percBackboneRelevantNoMatches(), d.getKey());
}
if (sqlService != null) {
LOG.info("Updating {} nub relations with {} ({}%) matches and {} unparsable names from dataset {}",
relations.size(),
summary.getMatches(),
summary.percMatches(),
summary.getUnparsable(),
d.getKey()
);
sqlService.insertNubRelations(d.getKey(), relations);
solrService.insertNubRelations(d.getKey(), relations);
counter++;
} else {
LOG.warn("No sql service configured to persist the matches for dataset {}!", d.getKey());
}
} catch (Exception e) {
LOG.error("Failed to match checklist {} {}", d.getKey(), d.getTitle());
throw new DatasetMatchFailed(d.getKey(), e);
}
LOG.info("{}", summary);
return summary;
}
示例4: init
import org.gbif.api.model.registry.Dataset; //导入方法依赖的package包/类
@Before
public void init() {
ds = Mockito.mock(DatasetService.class);
Dataset squirrel = new Dataset();
squirrel.setKey(CHECKLIST_KEY);
squirrel.setTitle("Squirrels");
squirrel.setType(DatasetType.CHECKLIST);
when(ds.get(eq(CHECKLIST_KEY))).thenReturn(squirrel);
os = Mockito.mock(OrganizationService.class);
Organization org1 = new Organization();
org1.setKey(ORG_KEY);
org1.setTitle("Org1");
when(os.get(eq(ORG_KEY))).thenReturn(org1);
oldDKey = UUID.randomUUID();
final Date now = new Date();
PagingResponse<Dataset> resp3 = new PagingResponse<Dataset>();
PagingResponse<Dataset> respEmpty = new PagingResponse<Dataset>();
respEmpty.setCount(0l);
respEmpty.setEndOfRecords(true);
Dataset orgD = new Dataset();
orgD.setKey(oldDKey);
orgD.setTitle("orgD");
orgD.setCreated(now);
orgD.setType(DatasetType.CHECKLIST);
Dataset orgD2 = new Dataset();
orgD2.setKey(UUID.randomUUID());
orgD2.setTitle("orgD2");
orgD2.setCreated(new Date(now.getTime() - 100000));
orgD2.setType(DatasetType.CHECKLIST);
resp3.setCount(2l);
resp3.getResults().add(orgD);
resp3.getResults().add(orgD2);
when(os.publishedDatasets(Matchers.<UUID>any(), any(PagingRequest.class))).thenReturn(respEmpty);
when(os.publishedDatasets(AdditionalMatchers.not(eq(org1.getKey())), any(PagingRequest.class))).thenReturn(resp3);
is = Mockito.mock(InstallationService.class);
Installation ins1 = new Installation();
org1.setKey(INS_KEY);
org1.setTitle("Ins1");
when(is.get(eq(INS_KEY))).thenReturn(ins1);
when(is.getHostedDatasets(Matchers.<UUID>any(), any(PagingRequest.class))).thenReturn(respEmpty);
when(is.getHostedDatasets(AdditionalMatchers.not(eq(ins1.getKey())), any(PagingRequest.class))).thenReturn(resp3);
// use default prod API
Properties props = dbSetup.getProperties();
cfg.clb.databaseName = props.getProperty("checklistbank.db.dataSource.databaseName");
cfg.clb.serverName = props.getProperty("checklistbank.db.dataSource.serverName");
cfg.clb.user = props.getProperty("checklistbank.db.dataSource.user");
cfg.clb.password = props.getProperty("checklistbank.db.dataSource.password");
cfg.sourceList = URI.create("nub-test-sources.txt");
src = new ClbSourceList(ds, os, is, cfg);
}
示例5: dataset
import org.gbif.api.model.registry.Dataset; //导入方法依赖的package包/类
private static Dataset dataset(UUID key) {
Dataset d = new Dataset();
d.setKey(key);
d.setTitle("Dataset " + key);
return d;
}