Java Code Examples for org.apache.olingo.commons.api.data.Entity#setMediaContentSource()
The following examples show how to use
org.apache.olingo.commons.api.data.Entity#setMediaContentSource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EdmAssistedJsonSerializerTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void metadataMin() throws Exception { final ServiceMetadata metadata = oData.createServiceMetadata(null, Collections.<EdmxReference> emptyList(), new MetadataETagSupport("W/\"42\"")); Entity entity = new Entity(); entity.setType("Namespace.EntityType"); entity.setId(URI.create("ID")); entity.setETag("W/\"1000\""); Link link = new Link(); link.setHref("editLink"); entity.setEditLink(link); entity.setMediaContentSource(URI.create("media")); entity.addProperty(new Property(null, "Property1", ValueType.PRIMITIVE, UUID.fromString("12345678-ABCD-1234-CDEF-123456789012"))); EntityCollection entityCollection = new EntityCollection(); entityCollection.getEntities().add(entity); Assert.assertEquals("{\"@odata.context\":\"$metadata#EntitySet(Property1)\"," + "\"@odata.metadataEtag\":\"W/\\\"42\\\"\",\"value\":[{" + "\"@odata.etag\":\"W/\\\"1000\\\"\"," + "\"Property1\":\"12345678-abcd-1234-cdef-123456789012\"," + "\"@odata.editLink\":\"editLink\"," + "\"@odata.mediaReadLink\":\"editLink/$value\"}]}", serialize(serializerMin, metadata, null, entityCollection, null)); }
Example 2
Source File: TransactionalEntityManager.java From olingo-odata4 with Apache License 2.0 | 5 votes |
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; }
Example 3
Source File: TransactionalEntityManager.java From olingo-odata4 with Apache License 2.0 | 5 votes |
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; }
Example 4
Source File: TransactionalEntityManager.java From olingo-odata4 with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: ODataBinderImpl.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@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; }