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


Java SerializerResult类代码示例

本文整理汇总了Java中org.apache.olingo.server.api.serializer.SerializerResult的典型用法代码示例。如果您正苦于以下问题:Java SerializerResult类的具体用法?Java SerializerResult怎么用?Java SerializerResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SerializerResult类属于org.apache.olingo.server.api.serializer包,在下文中一共展示了SerializerResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
/**
 * Method is a template to provide behavior for all read processors.
 */
@Override
public void read(ODataRequest request, ODataResponse response, UriInfo uriInfo,
        ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
    this.request = request;
    ESRequest searchRequest = createRequest(uriInfo);
    ElasticEdmEntitySet entitySet = searchRequest.getEntitySet();
    SearchResponse searchResponse = searchRequest.execute();
    InstanceData<T, V> data = parseResponse(searchResponse, entitySet);

    ODataSerializer serializer = odata.createSerializer(responseFormat);
    SerializerResult serializerResult = serialize(serializer, data, entitySet, uriInfo);
    response.setContent(serializerResult.getContent());
    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:19,代码来源:AbstractESReadProcessor.java

示例2: serialize

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
@Override
protected SerializerResult serialize(ODataSerializer serializer,
        InstanceData<EdmPrimitiveType, Property> data, ElasticEdmEntitySet entitySet,
        UriInfo uriInfo) throws SerializerException {
    List<UriResource> resourceParts = uriInfo.getUriResourceParts();
    UriResourceProperty uriProperty = (UriResourceProperty) resourceParts
            .get(resourceParts.size() - 1);
    ElasticEdmProperty edmProperty = (ElasticEdmProperty) uriProperty.getProperty();
    String propertyName = edmProperty.getName();
    return serializer.primitive(serviceMetadata, data.getType(), data.getValue(),
            PrimitiveSerializerOptions.with()
                    .contextURL(createContextUrl(entitySet, true, null, null, propertyName))
                    .scale(edmProperty.getScale()).nullable(edmProperty.isNullable())
                    .precision(edmProperty.getPrecision()).maxLength(edmProperty.getMaxLength())
                    .unicode(edmProperty.isUnicode()).build());
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:17,代码来源:PrimitiveProcessorImpl.java

示例3: serializeDeltaPayloads

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
private SerializerResult serializeDeltaPayloads(final ODataRequest request, final Delta delta, 
    final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
    final ContentType requestedFormat, final ExpandOption expand, final SelectOption select,
    final CountOption countOption, String id) throws ODataLibraryException {

  return odata.createEdmDeltaSerializer(requestedFormat, request.getHeaders(HttpHeader.ODATA_VERSION))
      .entityCollection(serviceMetadata,
      edmEntityType, delta,
      EntityCollectionSerializerOptions.with()
      .contextURL(isODataMetadataNone(requestedFormat) ? null :
        getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, false, expand, select, false))
    .count(countOption)
    .expand(expand).select(select)
    .id(id)
    .build());
 
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:TechnicalEntityProcessor.java

示例4: serializeEntityCollection

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
private SerializerResult serializeEntityCollection(final ODataRequest request, final EntityCollection
    entityCollection, final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
    final ContentType requestedFormat, final ExpandOption expand, final SelectOption select,
    final CountOption countOption, String id, final boolean isContNav) throws ODataLibraryException {

  return odata.createSerializer(requestedFormat, request.getHeaders(HttpHeader.ODATA_VERSION))
      .entityCollection(
      serviceMetadata,
      edmEntityType,
      entityCollection,
      EntityCollectionSerializerOptions.with()
          .contextURL(isODataMetadataNone(requestedFormat) ? null :
              getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, false, expand, select, isContNav))
          .count(countOption)
          .expand(expand).select(select)
          .id(id)
          .build());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:TechnicalEntityProcessor.java

示例5: serializeEntity

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
private SerializerResult serializeEntity(final ODataRequest request, final Entity entity,
    final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
    final ContentType requestedFormat,
    final ExpandOption expand, final SelectOption select, final boolean isContNav)
    throws ODataLibraryException {

  ContextURL contextUrl = isODataMetadataNone(requestedFormat) ? null :
      getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, true, expand, null,isContNav);
  return odata.createSerializer(requestedFormat, request.getHeaders(HttpHeader.ODATA_VERSION)).entity(
      serviceMetadata,
      edmEntityType,
      entity,
      EntitySerializerOptions.with()
          .contextURL(contextUrl)
          .expand(expand).select(select)
          .build());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:TechnicalEntityProcessor.java

示例6: entityCollectionReference

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
@Test
public void entityCollectionReference() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EntityCollection entityCollection = data.readAll(edmEntitySet);

  final SerializerResult serializerResult = serializer.referenceCollection(metadata,
      edmEntitySet,
      entityCollection,
      ReferenceCollectionSerializerOptions.with()
          .contextURL(ContextURL.with().asCollection().suffix(Suffix.REFERENCE).build())
          .build());

  final String resultString = IOUtils.toString(serializerResult.getContent());

  Assert.assertEquals("{\"@odata.context\":\"$metadata#Collection($ref)\","
      + "\"value\":[{\"@odata.id\":\"ESAllPrim(32767)\"},"
      + "{\"@odata.id\":\"ESAllPrim(-32768)\"},"
      + "{\"@odata.id\":\"ESAllPrim(0)\"}]}",
      resultString);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:ODataJsonSerializerTest.java

示例7: entityCollectionReferenceEmpty

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
@Test
public void entityCollectionReferenceEmpty() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EntityCollection entityCollection = new EntityCollection();

  final SerializerResult serializerResult = serializer.referenceCollection(metadata,
      edmEntitySet, entityCollection,
      ReferenceCollectionSerializerOptions.with()
          .contextURL(ContextURL.with().asCollection().suffix(Suffix.REFERENCE).build())
          .build());

  final String resultString = IOUtils.toString(serializerResult.getContent());

  Assert.assertEquals("{\"@odata.context\":\"$metadata#Collection($ref)\","
      + "\"value\":[]}", resultString);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:ODataJsonSerializerTest.java

示例8: entityCollectionReference

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
@Test
public void entityCollectionReference() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EntityCollection entityCollection = data.readAll(edmEntitySet);

  final SerializerResult serializerResult = serializer.referenceCollection(metadata,
      edmEntitySet,
      entityCollection,
      ReferenceCollectionSerializerOptions.with()
          .contextURL(ContextURL.with().asCollection().suffix(Suffix.REFERENCE).build())
          .build());

  final String resultString = IOUtils.toString(serializerResult.getContent());

  Assert.assertEquals("{\"@context\":\"$metadata#Collection($ref)\","
      + "\"value\":[{\"@id\":\"ESAllPrim(32767)\"},"
      + "{\"@id\":\"ESAllPrim(-32768)\"},"
      + "{\"@id\":\"ESAllPrim(0)\"}]}",
      resultString);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:ODataJsonSerializerv01Test.java

示例9: entityCollectionReferenceEmpty

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
@Test
public void entityCollectionReferenceEmpty() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EntityCollection entityCollection = new EntityCollection();

  final SerializerResult serializerResult = serializer.referenceCollection(metadata,
      edmEntitySet, entityCollection,
      ReferenceCollectionSerializerOptions.with()
          .contextURL(ContextURL.with().asCollection().suffix(Suffix.REFERENCE).build())
          .build());

  final String resultString = IOUtils.toString(serializerResult.getContent());

  Assert.assertEquals("{\"@context\":\"$metadata#Collection($ref)\","
      + "\"value\":[]}", resultString);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:ODataJsonSerializerv01Test.java

示例10: entityCollectionReference

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
@Test
public void entityCollectionReference() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EntityCollection entityCollection = data.readAll(edmEntitySet);

  ReferenceCollectionSerializerOptions options = ReferenceCollectionSerializerOptions.with()
      .contextURL(ContextURL.with().asCollection().suffix(Suffix.REFERENCE).build()).build();

  final SerializerResult serializerResult = serializer.referenceCollection(metadata,
      edmEntitySet,
      entityCollection, options);

  final String resultString = IOUtils.toString(serializerResult.getContent());
  String expected = "<?xml version='1.0' encoding='UTF-8'?>\n" +
      "<a:feed xmlns:a=\"http://www.w3.org/2005/Atom\"\n" +
      "  xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
      "  m:context=\"$metadata#Collection($ref)\">\n" +
      "  <m:ref id=\"ESAllPrim(32767)\" />\n" +
      "  <m:ref id=\"ESAllPrim(-32768)\" />\n" +
      "  <m:ref id=\"ESAllPrim(0)\" />\n" +
      "</a:feed>";
  checkXMLEqual(expected, resultString);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:ODataXmlSerializerTest.java

示例11: entityCollectionReferenceEmpty

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
@Test
public void entityCollectionReferenceEmpty() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EntityCollection entityCollection = new EntityCollection();

  ReferenceCollectionSerializerOptions options = ReferenceCollectionSerializerOptions.with()
      .contextURL(ContextURL.with().asCollection().suffix(Suffix.REFERENCE).build()).build();

  final SerializerResult serializerResult = serializer.referenceCollection(metadata,
      edmEntitySet,
      entityCollection, options);

  final String resultString = IOUtils.toString(serializerResult.getContent());

  String expected = "<?xml version='1.0' encoding='UTF-8'?>\n" +
      "<a:feed xmlns:a=\"http://www.w3.org/2005/Atom\"\n" +
      "  xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
      "  m:context=\"$metadata#Collection($ref)\">\n" +
      "</a:feed>";
  checkXMLEqual(expected, resultString);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:ODataXmlSerializerTest.java

示例12: createMediaEntity

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
@Override
public void createMediaEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
    ContentType requestFormat, ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
  
  final EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
  final byte[] mediaContent = odata.createFixedFormatDeserializer().binary(request.getBody());
  
  final Entity entity = storage.createMediaEntity(edmEntitySet.getEntityType(), 
                                                  requestFormat.toContentTypeString(), 
                                                  mediaContent);
  
  final ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build();
  final EntitySerializerOptions opts = EntitySerializerOptions.with().contextURL(contextUrl).build();
  final SerializerResult serializerResult = odata.createSerializer(responseFormat).entity(serviceMetadata,
      edmEntitySet.getEntityType(), entity, opts);
  
  final String location = request.getRawBaseUri() + '/'
      + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entity);
  response.setContent(serializerResult.getContent());
  response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
  response.setHeader(HttpHeader.LOCATION, location);
  response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:DemoEntityProcessor.java

示例13: createEntity

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
@Override
public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat,
		ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {

	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(resourcePaths.size() - 1);
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
	EdmEntityType entityType = edmEntitySet.getEntityType();	
	InputStream requestInputStream = request.getBody();
	ODataDeserializer deserializer = this.odata.createDeserializer(requestFormat);
	DeserializerResult result = deserializer.entity(requestInputStream, entityType);
	Entity requestEntity = result.getEntity();		  
	Entity createdEntity = createEntityData(edmEntitySet, requestEntity);		  
	ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).build();		  
	EntitySerializerOptions options = EntitySerializerOptions.with().contextURL(contextUrl).build();
	ODataSerializer serializer = this.odata.createSerializer(responseFormat);
	SerializerResult serializedResponse = serializer.entity(serviceMetadata, entityType, createdEntity, options);
	response.setContent(serializedResponse.getContent());
	response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
	response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());

}
 
开发者ID:jbaliuka,项目名称:sql-analytic,代码行数:23,代码来源:SQLEntityProcessor.java

示例14: readEntity

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
@Override
public void readEntity(
    ODataRequest request,
    ODataResponse response,
    UriInfo uriInfo,
    ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {

  // First path segment is Entity Set.
  List<UriResource> resourceParts = uriInfo.getUriResourceParts();
  UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourceParts.get(0);
  EdmEntitySet entitySet = uriResourceEntitySet.getEntitySet();
  List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();

  // Retrieve entity from backend.
  Entity entity = entityRepository.read(entitySet, keyPredicates);

  // Serialize to response format.
  ContextURL contextUrl = ContextURL.with()
      .entitySet(entitySet)
      .suffix(ContextURL.Suffix.ENTITY)
      .build();
  EntitySerializerOptions options = EntitySerializerOptions.with()
      .contextURL(contextUrl)
      .build();
  ODataSerializer serializer = odata.createSerializer(responseFormat);
  SerializerResult serializerResult = serializer.entity(
      serviceMetadata, entitySet.getEntityType(), entity, options);

  // Set response attributes.
  response.setContent(serializerResult.getContent());
  response.setStatusCode(HttpStatusCode.OK.getStatusCode());
  response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
 
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:34,代码来源:ElasticsearchEntityProcessor.java

示例15: readEntityCollection

import org.apache.olingo.server.api.serializer.SerializerResult; //导入依赖的package包/类
@Override
public void readEntityCollection(
    ODataRequest request,
    ODataResponse response,
    UriInfo uriInfo,
    ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {

  // First path segment is Entity Set.
  List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
  UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
  EdmEntitySet entitySet = uriResourceEntitySet.getEntitySet();

  // Retrieve entities from backend.
  EntityCollection entityCollection = entityRepository.list(entitySet, uriInfo);

  // Serialize to response format.
  ContextURL contextUrl = ContextURL.with()
      .entitySet(entitySet)
      .build();
  EntityCollectionSerializerOptions options = EntityCollectionSerializerOptions.with()
      .id(request.getRawBaseUri() + "/" + entitySet.getName())
      .contextURL(contextUrl)
      .build();
  ODataSerializer serializer = odata.createSerializer(responseFormat);
  SerializerResult serializerResult = serializer.entityCollection(
      serviceMetadata, entitySet.getEntityType(), entityCollection, options);

  // Set response attributes.
  response.setContent(serializerResult.getContent());
  response.setStatusCode(HttpStatusCode.OK.getStatusCode());
  response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
 
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:33,代码来源:ElasticsearchEntityCollectionProcessor.java


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