本文整理汇总了Java中org.gbif.api.model.checklistbank.NameUsageMediaObject类的典型用法代码示例。如果您正苦于以下问题:Java NameUsageMediaObject类的具体用法?Java NameUsageMediaObject怎么用?Java NameUsageMediaObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NameUsageMediaObject类属于org.gbif.api.model.checklistbank包,在下文中一共展示了NameUsageMediaObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMedia
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的package包/类
public List<NameUsageMediaObject> getMedia(int usageKey) {
//PagingResponse<Image> response = getImages(usageKey, null);
PagingResponse<NameUsageMediaObject> response = getMedia(usageKey, null);
if (response == null) {
return null;
}
//List<Image> result = Lists.newArrayList(response.getResults());
List<NameUsageMediaObject> result = Lists.newArrayList(response.getResults());
boolean isInitial = true;
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 = getMedia(usageKey, response);
result.addAll(response.getResults());
}
return result;
}
示例2: 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));
}
示例3: interpretMultimedia
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的package包/类
private void interpretMultimedia(NameUsage u, UsageExtensions e, VerbatimNameUsage v) {
extractMedia(u, e, v, Extension.IMAGE, false);
extractMedia(u, e, v, Extension.MULTIMEDIA, false);
extractMedia(u, e, v, Extension.EOL_MEDIA, true);
extractMedia(u, e, v, Extension.AUDUBON, false);
extractMediaCore(u, e, v);
/**
* merges media records if the same image URL or link is given several times.
* Remove any media that has not either a file or webpage uri.
*/
Map<String, NameUsageMediaObject> media = Maps.newLinkedHashMap();
for (NameUsageMediaObject m : e.media) {
// we can get file uris or weblinks. Prefer file URIs as they clearly identify a single image
URI uri = m.getIdentifier() != null ? m.getIdentifier() : m.getReferences();
if (uri != null) {
String url = uri.toString();
if (media.containsKey(url)) {
// TODO: merge infos about the same image?
} else {
media.put(url, m);
}
}
}
e.media = Lists.newArrayList(media.values());
}
示例4: testEmptyModels
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的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());
}
示例5: testBadUri
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的package包/类
@Test
public void testBadUri() {
List<NameUsageMediaObject> media = service.listByUsage(100000030, null).getResults();
assertEquals(2, media.size());
// http less URL, should work
NameUsageMediaObject img = media.get(0);
assertNotNull(img);
assertEquals(89, img.getCreated().getYear());
assertEquals(10, img.getCreated().getMonth());
assertEquals(URI.create(
"http://www.wikimedia.org/wikipedia/commons/thumb/d/d8/Sciurus_anomalus_-_Jeita_Grotto.jpg/724px-Sciurus_anomalus_-_Jeita_Grotto.jpg"),
img.getIdentifier());
assertEquals(URI.create("http://www.gbif.org"), img.getReferences());
assertEquals("Persian Squirrel in a cage", img.getDescription());
assertEquals(MediaType.StillImage, img.getType());
// citation instead of URI, should be ignored
img = media.get(1);
assertNotNull(img);
assertEquals(89, img.getCreated().getYear());
assertEquals(10, img.getCreated().getMonth());
assertEquals("Persian Squirrel in a cage", img.getDescription());
assertNull(img.getIdentifier());
assertNull(img.getReferences());
assertNull(img.getType());
}
示例6: assertObject
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的package包/类
private void assertObject(NameUsageMediaObject obj, NameUsageMediaObject obj2, String source, Integer sourceTaxonKey) {
assertEquals(obj.getAudience(), obj2.getAudience());
assertEquals(obj.getContributor(), obj2.getContributor());
assertEquals(obj.getCreated(), obj2.getCreated());
assertEquals(obj.getCreator(), obj2.getCreator());
assertEquals(obj.getDescription(), obj2.getDescription());
assertEquals(obj.getFormat(), obj2.getFormat());
assertEquals(obj.getIdentifier(), obj2.getIdentifier());
assertEquals(obj.getLicense(), obj2.getLicense());
assertEquals(obj.getPublisher(), obj2.getPublisher());
assertEquals(obj.getReferences(), obj2.getReferences());
assertEquals(obj.getRightsHolder(), obj2.getRightsHolder());
assertEquals(obj.getTitle(), obj2.getTitle());
assertEquals(source, obj2.getSource());
assertEquals(sourceTaxonKey, obj2.getSourceTaxonKey());
}
示例7: 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);
}
}
}
}
示例8: extractMediaCore
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的package包/类
private void extractMediaCore(NameUsage u, UsageExtensions e, VerbatimNameUsage v) {
if (v.hasCoreField(DwcTerm.associatedMedia)) {
for (URI uri : UrlParser.parseUriList(v.getCoreField(DwcTerm.associatedMedia))) {
if (uri != null) {
NameUsageMediaObject m = new NameUsageMediaObject();
m.setIdentifier(uri);
mediaParser.detectType(m);
e.media.add(m);
}
}
}
}
示例9: listByUsage
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的package包/类
@Override
public PagingResponse<NameUsageMediaObject> listByUsage(int usageKey, @Nullable Pageable page) {
PagingResponse<NameUsageMediaObject> result = super.listByUsage(usageKey, page);
//TODO: avoid live interpretations until we store the type properly
for (NameUsageMediaObject m : result.getResults()) {
MediaTypeUtils.detectType(m);
}
return result;
}
示例10: 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);
}
示例11: handleResult
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的package包/类
@Override
public void handleResult(ResultContext<? extends NameUsageMediaObject> resultContext) {
if (resultContext.getResultObject() != null) {
counter++;
NameUsageMediaObject d = resultContext.getResultObject();
System.out.println(d);
assertNotNull(d.getTaxonKey());
}
}
示例12: MultimediaWsClient
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的package包/类
@Inject
public MultimediaWsClient(@ChecklistBankWs WebResource resource) {
super(NameUsageMediaObject.class, new GenericType<PagingResponse<NameUsageMediaObject>>() {
}, resource, Constants.MEDIA_PATH);
}
示例13: MultimediaWsClientTest
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的package包/类
public MultimediaWsClientTest() {
super(NameUsageMediaObject.class);
}
示例14: getMockObject
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的package包/类
@Override
NameUsageMediaObject getMockObject() {
NameUsageMediaObject image = new NameUsageMediaObject();
image.setIdentifier(URI.create("http://imageurl.jpg"));
return image;
}
示例15: getClient
import org.gbif.api.model.checklistbank.NameUsageMediaObject; //导入依赖的package包/类
@Override
NameUsageComponentBaseWsClient<NameUsageMediaObject> getClient(WebResource resource) {
return new MultimediaWsClient(resource);
}