public void writeReadEntity(EdmEntityType entityType, Entity entity) throws SerializerException { assert (!isClosed()); if (entity == null) { writeNotFound(true); return; } if (ContentTypeHelper.isODataMetadataFull(this.responseContentType)) { EdmAction action = this.metadata.getEdm().getBoundActionWithBindingType( entityType.getFullQualifiedName(), false); if (action != null) { entity.getOperations().add(buildOperation(action, entity.getId().toASCIIString())); } List<EdmFunction> functions = this.metadata.getEdm() .getBoundFunctionsWithBindingType(entityType.getFullQualifiedName(),false); for (EdmFunction function:functions) { entity.getOperations().add(buildOperation(function, entity.getId().toASCIIString())); } } // write the entity to response this.response.setContent(this.serializer.entity(this.metadata, entityType, entity, this.options).getContent()); writeOK(responseContentType); close(); }
@Override public SerializerResult serialize(ODataRequest request, EntityCollection result) throws SerializerException, ODataJPASerializerException { final EdmEntitySet targetEdmEntitySet = Util.determineTargetEntitySet(uriInfo.getUriResourceParts()); final EdmEntityType entityType = targetEdmEntitySet.getEntityType(); final ContextURL contextUrl = ContextURL.with() .entitySet(targetEdmEntitySet) .build(); final EntitySerializerOptions options = EntitySerializerOptions.with() .contextURL(contextUrl) .expand(uriInfo.getExpandOption()) .build(); return serializer.entity(serviceMetadata, entityType, result .getEntities() .get(0), options); }
public void writeReadEntity(EdmEntityType entityType, Entity entity) throws SerializerException { assert (!isClosed()); if (entity == null) { writeNotFound(true); return; } if (ContentTypeHelper.isODataMetadataFull(this.responseContentType)) { EdmAction action = this.metadata.getEdm().getBoundActionWithBindingType( entityType.getFullQualifiedName(), false); if (action != null) { entity.getOperations().add(buildOperation(action, entity.getId().toASCIIString())); } List<EdmFunction> functions = this.metadata.getEdm() .getBoundFunctionsWithBindingType(entityType.getFullQualifiedName(),false); for (EdmFunction function:functions) { entity.getOperations().add(buildOperation(function, entity.getId().toASCIIString())); } } // write the entity to response this.response.setContent(this.serializer.entity(this.metadata, entityType, entity, this.options).getContent()); writeOK(responseContentType); close(); }
@Override public SerializerResult serialize(final Annotatable annotatable, final EdmType entityType) throws SerializerException { final EntityCollection result = (EntityCollection) annotatable; final String selectList = uriHelper.buildContextURLSelectList((EdmEntityType) entityType, uriInfo.getExpandOption(), uriInfo.getSelectOption()); final ContextURL contextUrl = ContextURL.with() .type(entityType) .selectList(selectList) .build(); final EntitySerializerOptions options = EntitySerializerOptions.with() .contextURL(contextUrl) .select(uriInfo.getSelectOption()) .expand(uriInfo.getExpandOption()) .build(); return serializer.entity(serviceMetadata, (EdmEntityType) entityType, result .getEntities() .get(0), options); }
this.response.setContent(this.serializer.entity(this.metadata, entitySet.getEntityType(), entity, this.options) .getContent()); writeCreated(false);
this.response.setContent(this.serializer.entity(this.metadata, entitySet.getEntityType(), entity, this.options) .getContent()); writeCreated(false);