当前位置: 首页>>代码示例>>Java>>正文


Java Entity.setMediaETag方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:ODataJsonSerializerTest.java

示例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);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:ODataJsonSerializerv01Test.java

示例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;
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:34,代码来源:DataCreator.java

示例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;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:41,代码来源:DataCreator.java

示例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;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:16,代码来源:TransactionalEntityManager.java

示例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() + "\"");
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:7,代码来源:DataProvider.java

示例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;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:53,代码来源:ODataBinderImpl.java


注:本文中的org.apache.olingo.commons.api.data.Entity.setMediaETag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。