public void entityCollectionIntoStream(ServiceMetadata metadata, EdmEntityType entityType, EntityIterator entitySet, EntityCollectionSerializerOptions options, OutputStream outputStream) throws SerializerException { final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); final String name = contextURL == null ? null : contextURL.getEntitySetOrSingletonOrType(); SerializerException cachedException; writeMetadataETag(metadata, writer); if (options != null && options.getId() != null) { writer.writeStartElement(ATOM, Constants.ATOM_ELEM_ID, NS_ATOM); writer.writeCharacters(options.getId()); writer.writeEndElement(); if (options != null && options.getCount() != null && options.getCount().getValue() && entitySet.getCount() != null) { writeCount(entitySet, writer); writeNextLink(entitySet, writer); boolean writeOnlyRef = (options != null && options.getWriteOnlyReferences()); if (options == null) { writeEntitySet(metadata, entityType, entitySet, null, null, null, null, writer, writeOnlyRef, name, null); } else { writeEntitySet(metadata, entityType, entitySet, options.getExpand(), null, options.getSelect(), options.xml10InvalidCharReplacement(), writer, writeOnlyRef, name, null);
private Builder() { options = new EntityCollectionSerializerOptions(); }
public void write(OutputStream out) { try { writeEntity(iterator, out); } catch (SerializerException e) { final ODataContentWriteErrorCallback errorCallback = options.getODataContentWriteErrorCallback(); if (errorCallback != null) { final WriteErrorContext errorContext = new WriteErrorContext(e); errorCallback.handleError(errorContext, Channels.newChannel(out)); } } } }
protected void writeEntitySet(final ServiceMetadata metadata, final EdmEntityType entityType, final Delta entitySet, final EntityCollectionSerializerOptions options, final JsonGenerator json) throws IOException, SerializerException { json.writeStartArray(); for (final Entity entity : entitySet.getEntities()) { writeAddedUpdatedEntity(metadata, entityType, entity, options.getExpand(), options.getSelect(), options.getContextURL(), false, options.getContextURL() .getEntitySetOrSingletonOrType(), json); } for (final DeletedEntity deletedEntity : entitySet.getDeletedEntities()) { writeDeletedEntity(deletedEntity, options, json); } for (final DeltaLink addedLink : entitySet.getAddedLinks()) { writeLink(addedLink, options, json, true); } for (final DeltaLink deletedLink : entitySet.getDeletedLinks()) { writeLink(deletedLink, options, json, false); } json.writeEndArray(); }
json.writeStartObject(); final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); writeContextURL(contextURL, json); if (options != null && options.getCount() != null && options.getCount().getValue()) { writeInlineCount("", entitySet.getCount(), json); } else { writeEntitySet(metadata, entityType, entitySet, options.getExpand(), null, options.getSelect(), options.getWriteOnlyReferences(), null, name, json);
json.writeStartObject(); final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); writeContextURL(contextURL, json); if (options != null && options.getCount() != null && options.getCount().getValue()) { writeInlineCount(delta.getCount(), json);
try { json.writeStartObject(); String entityId = options.getContextURL().getEntitySetOrSingletonOrType(); String operation = isAdded ? LINK : DELETEDLINK; json.writeStringField(Constants.JSON_CONTEXT, HASH + entityId + operation);
@Override public SerializerResult serialize(final Annotatable annotatable, final EdmType entityType) throws SerializerException, ODataJPASerializerException { final EntityCollection result = (EntityCollection) annotatable; final String selectList = uriHelper.buildContextURLSelectList((EdmEntityType) entityType, uriInfo.getExpandOption(), uriInfo.getSelectOption()); final ContextURL contextUrl = ContextURL.with() .asCollection() .type(entityType) .selectList(selectList) .build(); final EntityCollectionSerializerOptions options = EntityCollectionSerializerOptions.with() .contextURL(contextUrl) .select(uriInfo.getSelectOption()) .expand(uriInfo.getExpandOption()) .build(); return serializer.entityCollection(serviceMetadata, (EdmEntityType) entityType, result, options); }
json.writeStartObject(); final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); writeContextURL(contextURL, json); if (options != null && options.getCount() != null && options.getCount().getValue()) { writeInlineCount("", entitySet.getCount(), json); } else { writeEntitySet(metadata, entityType, entitySet, options.getExpand(), null, options.getSelect(), options.getWriteOnlyReferences(), null, name, json);
protected void writeEntitySet(final ServiceMetadata metadata, final EdmEntityType entityType, final Delta entitySet, final EntityCollectionSerializerOptions options, final JsonGenerator json) throws IOException, SerializerException { json.writeStartArray(); for (final Entity entity : entitySet.getEntities()) { writeAddedUpdatedEntity(metadata, entityType, entity, options.getExpand(), options.getSelect(), options.getContextURL(), false, options.getContextURL().getEntitySetOrSingletonOrType(), json); } for (final DeletedEntity deletedEntity : entitySet.getDeletedEntities()) { writeDeletedEntity(deletedEntity, json); } for (final DeltaLink addedLink : entitySet.getAddedLinks()) { writeLink(addedLink, options, json, true); } for (final DeltaLink deletedLink : entitySet.getDeletedLinks()) { writeLink(deletedLink, options, json, false); } json.writeEndArray(); }
json.writeStartObject(); final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); writeContextURL(contextURL, json); if (options != null && options.getCount() != null && options.getCount().getValue()) { writeInlineCount(delta.getCount(), json);
try { json.writeStartObject(); String entityId = options.getContextURL().getEntitySetOrSingletonOrType();// throw error if not set id String operation = isAdded ? Constants.LINK : Constants.DELETEDLINK; json.writeStringField(Constants.AT + Constants.CONTEXT, Constants.HASH + entityId + operation);
.build(); } else if (serilizerOptions.isAssignableFrom(EntityCollectionSerializerOptions.class)) { return (T) EntityCollectionSerializerOptions.with() .contextURL(contextUrl) .count(uriInfo.getCountOption()).expand(uriInfo.getExpandOption())
public void entityCollectionIntoStream(ServiceMetadata metadata, EdmEntityType entityType, EntityIterator entitySet, EntityCollectionSerializerOptions options, OutputStream outputStream) throws SerializerException { final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); final String name = contextURL == null ? null : contextURL.getEntitySetOrSingletonOrType(); SerializerException cachedException; writeMetadataETag(metadata, writer); if (options != null && options.getId() != null) { writer.writeStartElement(ATOM, Constants.ATOM_ELEM_ID, NS_ATOM); writer.writeCharacters(options.getId()); writer.writeEndElement(); if (options != null && options.getCount() != null && options.getCount().getValue() && entitySet.getCount() != null) { writeCount(entitySet, writer); writeNextLink(entitySet, writer); boolean writeOnlyRef = (options != null && options.getWriteOnlyReferences()); if (options == null) { writeEntitySet(metadata, entityType, entitySet, null, null, null, null, writer, writeOnlyRef, name, null); } else { writeEntitySet(metadata, entityType, entitySet, options.getExpand(), null, options.getSelect(), options.xml10InvalidCharReplacement(), writer, writeOnlyRef, name, null);
json.writeStartObject(); final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); String name = contextURL == null ? null:contextURL.getEntitySetOrSingletonOrType(); writeContextURL(contextURL, json); if (options != null && options.getCount() != null && options.getCount().getValue()) { writeInlineCount("", entitySet.getCount(), json); } else { writeEntitySet(metadata, entityType, entitySet, options.getExpand(), null, options.getSelect(), options.getWriteOnlyReferences(), null, name, json);
protected void writeEntitySet(final ServiceMetadata metadata, final EdmEntityType entityType, final Delta entitySet, final EntityCollectionSerializerOptions options, final JsonGenerator json) throws IOException, SerializerException { json.writeStartArray(); for (final Entity entity : entitySet.getEntities()) { writeAddedUpdatedEntity(metadata, entityType, entity, options.getExpand(), options.getSelect(), options.getContextURL(), false, options.getContextURL().getEntitySetOrSingletonOrType(), json); } for (final DeletedEntity deletedEntity : entitySet.getDeletedEntities()) { writeDeletedEntity(deletedEntity, json); } for (final DeltaLink addedLink : entitySet.getAddedLinks()) { writeLink(addedLink, options, json, true); } for (final DeltaLink deletedLink : entitySet.getDeletedLinks()) { writeLink(deletedLink, options, json, false); } json.writeEndArray(); }
json.writeStartObject(); final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); writeContextURL(contextURL, json); if (options != null && options.getCount() != null && options.getCount().getValue()) { writeInlineCount(delta.getCount(), json);
try { json.writeStartObject(); String entityId = options.getContextURL().getEntitySetOrSingletonOrType(); String operation = isAdded ? LINK : DELETEDLINK; json.writeStringField(Constants.JSON_CONTEXT, HASH + entityId + operation);
.build(); } else if (serilizerOptions.isAssignableFrom(EntityCollectionSerializerOptions.class)) { return (T) EntityCollectionSerializerOptions.with() .contextURL(contextUrl) .count(uriInfo.getCountOption()).expand(uriInfo.getExpandOption())
public void write(OutputStream out) { try { writeEntity(iterator, out); } catch (SerializerException e) { final ODataContentWriteErrorCallback errorCallback = options.getODataContentWriteErrorCallback(); if (errorCallback != null) { final WriteErrorContext errorContext = new WriteErrorContext(e); errorCallback.handleError(errorContext, Channels.newChannel(out)); } } } }