本文整理汇总了Java中org.apache.olingo.commons.api.data.Entity.setMediaETag方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.setMediaETag方法的具体用法?Java Entity.setMediaETag怎么用?Java Entity.setMediaETag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.commons.api.data.Entity
的用法示例。
在下文中一共展示了Entity.setMediaETag方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: entityMediaWithMetadataFull
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void entityMediaWithMetadataFull() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMedia");
final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
entity.setMediaETag("W/\\\"08D25949E3BFB7AB\\\"");
InputStream result = serializerFullMetadata
.entity(metadata, edmEntitySet.getEntityType(), entity,
EntitySerializerOptions.with().contextURL(ContextURL.with()
.entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()).build())
.getContent();
final String resultString = IOUtils.toString(result);
final String expectedResult = "{\"@odata.context\":\"$metadata#ESMedia/$entity\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@odata.mediaEtag\":\"W/\\\\\\\"08D25949E3BFB7AB\\\\\\\"\",\"@odata.mediaContentType\":\"image/svg+xml\","
+ "\"@odata.mediaEditLink\":\"ESMedia(1)/$value\","
+ "\"@odata.type\":\"#olingo.odata.test1.ETMedia\",\"@odata.id\":\"ESMedia(1)\","
+ "\"[email protected]\":\"#Int16\",\"PropertyInt16\":1}";
Assert.assertEquals(expectedResult, resultString);
}
示例2: entityMediaWithMetadataFull
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void entityMediaWithMetadataFull() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMedia");
final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
entity.setMediaETag("W/\\\"08D25949E3BFB7AB\\\"");
InputStream result = serializerFullMetadata
.entity(metadata, edmEntitySet.getEntityType(), entity,
EntitySerializerOptions.with().contextURL(ContextURL.with()
.entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()).build())
.getContent();
final String resultString = IOUtils.toString(result);
final String expectedResult = "{\"@context\":\"$metadata#ESMedia/$entity\","
+ "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@mediaEtag\":\"W/\\\\\\\"08D25949E3BFB7AB\\\\\\\"\",\"@mediaContentType\":\"image/svg+xml\","
+ "\"@mediaEditLink\":\"ESMedia(1)/$value\","
+ "\"@type\":\"#olingo.odata.test1.ETMedia\",\"@id\":\"ESMedia(1)\","
+ "\"[email protected]\":\"#Int16\",\"PropertyInt16\":1}";
Assert.assertEquals(expectedResult, resultString);
}
示例3: createESMedia
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private EntityCollection createESMedia(final Edm edm, final OData odata) {
EntityCollection entityCollection = new EntityCollection();
Entity entity =
new Entity().addProperty(createPrimitive("PropertyInt16", (short) 1)).addProperty(
createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("darkturquoise")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"1\"");
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(1)/$value"));
entityCollection.getEntities().add(entity);
entity = new Entity().addProperty(createPrimitive("PropertyInt16", (short) 2))
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("royalblue")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"2\"");
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(2)/$value"));
entityCollection.getEntities().add(entity);
entity = new Entity().addProperty(createPrimitive("PropertyInt16", (short) 3))
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("crimson")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"3\"");
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(3)/$value"));
entityCollection.getEntities().add(entity);
entity = new Entity().addProperty(createPrimitive("PropertyInt16", (short) 4))
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("black")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"4\"");
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(4)/$value"));
entityCollection.getEntities().add(entity);
setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETMedia));
createEntityId(edm, odata, "ESMedia", entityCollection);
return entityCollection;
}
示例4: createESMedia
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private EntityCollection createESMedia(final Edm edm, final OData odata) {
EntityCollection entityCollection = new EntityCollection();
Entity entity = new Entity()
.addProperty(createPrimitive("PropertyInt16", (short) 1))
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("darkturquoise")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"1\"");
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(1)/$value"));
entityCollection.getEntities().add(entity);
entity = new Entity()
.addProperty(createPrimitive("PropertyInt16", (short) 2))
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("royalblue")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"2\"");
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(2)/$value"));
entityCollection.getEntities().add(entity);
entity = new Entity()
.addProperty(createPrimitive("PropertyInt16", (short) 3))
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("crimson")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"3\"");
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(3)/$value"));
entityCollection.getEntities().add(entity);
entity = new Entity()
.addProperty(createPrimitive("PropertyInt16", (short) 4))
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("black")));
entity.setMediaContentType("image/svg+xml");
entity.setMediaETag("W/\"4\"");
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(4)/$value"));
entityCollection.getEntities().add(entity);
setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETMedia));
createEntityId(edm, odata, "ESMedia", entityCollection);
createOperations("ESMedia", entityCollection, EntityTypeProvider.nameETMedia);
return entityCollection;
}
示例5: copyEntity
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private Entity copyEntity(final Entity entity) {
final Entity newEntity = new Entity();
newEntity.setBaseURI(entity.getBaseURI());
newEntity.setEditLink(entity.getEditLink());
newEntity.setETag(entity.getETag());
newEntity.setId(entity.getId());
newEntity.setMediaContentSource(entity.getMediaContentSource());
newEntity.setMediaContentType(entity.getMediaContentType());
newEntity.setSelfLink(entity.getSelfLink());
newEntity.setMediaETag(entity.getMediaETag());
newEntity.setType(entity.getType());
newEntity.getProperties().addAll(entity.getProperties());
return newEntity;
}
示例6: setMedia
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
public void setMedia(final Entity entity, final byte[] media, final String type) {
entity.getProperties().remove(entity.getProperty(MEDIA_PROPERTY_NAME));
entity.addProperty(DataCreator.createPrimitive(MEDIA_PROPERTY_NAME, media));
entity.setMediaContentType(type);
entity.setMediaETag("W/\"" + UUID.randomUUID() + "\"");
}
示例7: getEntity
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Override
public Entity getEntity(final ClientEntity odataEntity) {
final Entity entity = new Entity();
entity.setType(odataEntity.getTypeName() == null ? null : odataEntity.getTypeName().toString());
// -------------------------------------------------------------
// Add edit and self link
// -------------------------------------------------------------
final URI odataEditLink = odataEntity.getEditLink();
if (odataEditLink != null) {
final Link editLink = new Link();
editLink.setTitle(entity.getType());
editLink.setHref(odataEditLink.toASCIIString());
editLink.setRel(Constants.EDIT_LINK_REL);
entity.setEditLink(editLink);
}
if (odataEntity.isReadOnly()) {
final Link selfLink = new Link();
selfLink.setTitle(entity.getType());
selfLink.setHref(odataEntity.getLink().toASCIIString());
selfLink.setRel(Constants.SELF_LINK_REL);
entity.setSelfLink(selfLink);
}
// -------------------------------------------------------------
links(odataEntity, entity);
// -------------------------------------------------------------
// Append edit-media links
// -------------------------------------------------------------
for (ClientLink link : odataEntity.getMediaEditLinks()) {
LOG.debug("Append edit-media link\n{}", link);
entity.getMediaEditLinks().add(getLink(link));
}
// -------------------------------------------------------------
if (odataEntity.isMediaEntity()) {
entity.setMediaContentSource(odataEntity.getMediaContentSource());
entity.setMediaContentType(odataEntity.getMediaContentType());
entity.setMediaETag(odataEntity.getMediaETag());
}
for (ClientProperty property : odataEntity.getProperties()) {
entity.getProperties().add(getProperty(property));
}
entity.setId(odataEntity.getId());
annotations(odataEntity, entity);
return entity;
}