本文整理汇总了Java中org.gbif.api.model.checklistbank.NameUsageMediaObject.setFormat方法的典型用法代码示例。如果您正苦于以下问题:Java NameUsageMediaObject.setFormat方法的具体用法?Java NameUsageMediaObject.setFormat怎么用?Java NameUsageMediaObject.setFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gbif.api.model.checklistbank.NameUsageMediaObject
的用法示例。
在下文中一共展示了NameUsageMediaObject.setFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMedia
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入方法依赖的package包/类
@Test
public void getMedia() {
PagingResponse<NameUsageMediaObject> expected = new PagingResponse<NameUsageMediaObject>(0,20);
expected.setEndOfRecords(true);
List<NameUsageMediaObject> results = new ArrayList<NameUsageMediaObject>();
expected.setResults(results);
NameUsageMediaObject medium = new NameUsageMediaObject();
medium.setType(MediaType.StillImage);
medium.setFormat("image/jpeg");
try {
medium.setIdentifier(new URI("http://upload.wikimedia.org/wikipedia/commons/d/d9/House_sparrowII.jpg"));
medium.setReferences(new URI("http://commons.wikimedia.org/wiki/File:House_sparrowII.jpg"));
}
catch (URISyntaxException e) {
}
medium.setTitle("Haussperling (Männchen)");
medium.setLicense("GFDL-1.2");
results.add(medium);
SpeciesAPIClient sut = new SpeciesAPIClient();
PagingResponse<NameUsageMediaObject> actual = sut.getMedia(5231190, null);
printCollections("getMedia", actual.getResults(), expected.getResults());
assertThat(actual, is(expected));
}
示例2: extractMedia
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入方法依赖的package包/类
private void extractMedia(NameUsage u, UsageExtensions e, VerbatimNameUsage v, Extension ext, boolean requireType) {
if (v.hasExtension(ext)) {
for (Map<Term, String> rec : v.getExtensions().get(ext)) {
URI uri = UrlParser.parse(value(rec, AcTerm.accessURI, DcTerm.identifier, DcElement.identifier));
URI link = UrlParser.parse(value(rec, AcTerm.furtherInformationURL, DcTerm.references, AcTerm.attributionLinkURL));
// EOL media extension is also used to publish text descriptions - avoid those
MediaType type = enumify(rec, null, mediaTypeParser, u, DcTerm.type, DcElement.type);
if (requireType && type == null) {
continue;
}
// link or media uri must exist
if (uri == null && link == null) {
u.addIssue(NameUsageIssue.MULTIMEDIA_INVALID);
} else {
NameUsageMediaObject m = new NameUsageMediaObject();
m.setType(type);
m.setIdentifier(uri);
m.setReferences(link);
m.setTitle(value(rec, DcTerm.title, AcTerm.caption));
m.setDescription(value(rec, DcTerm.description));
m.setLicense(value(rec, DcTerm.license, XmpRightsTerm.UsageTerms, DcTerm.rights));
m.setPublisher(value(rec, DcTerm.publisher));
m.setContributor(value(rec, DcTerm.contributor));
m.setSource(value(rec, AcTerm.derivedFrom, DcTerm.source));
m.setAudience(value(rec, DcTerm.audience));
m.setRightsHolder(value(rec, XmpRightsTerm.Owner, DcTerm.rightsHolder));
m.setCreator(value(rec, DcTerm.creator));
m.setFormat(mediaParser.parseMimeType(value(rec, DcTerm.format)));
String created = value(rec, XmpTerm.CreateDate, DcTerm.created, DcTerm.date);
if (created != null) {
m.setCreated(DateParseUtils.parse(created).getPayload());
}
mediaParser.detectType(m);
e.media.add(m);
}
}
}
}
示例3: testMapper
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入方法依赖的package包/类
@Test
public void testMapper() throws Exception {
assertTrue(mapper.listByChecklistUsage(usageKey, new PagingRequest()).isEmpty());
assertTrue(mapper.listByNubUsage(usageKey, new PagingRequest()).isEmpty());
NameUsageMediaObject obj = new NameUsageMediaObject();
obj.setAudience("audience");
obj.setContributor("contrib");
obj.setCreated(new Date());
obj.setCreator("creator");
obj.setDescription("descr");
obj.setFormat("format");
obj.setIdentifier(URI.create("https://my.id/sharks"));
obj.setLicense("license");
obj.setPublisher("publisher");
obj.setReferences(URI.create("https://my.tv/sharks"));
obj.setRightsHolder("rights holder");
obj.setTitle("title");
obj.setType(MediaType.Sound);
// these should get ignored
obj.setSource("sourcy s");
obj.setSourceTaxonKey(123);
mapper.insert(usageKey, obj, citationKey1);
NameUsageMediaObject 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);
}