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


Java ClientServiceDocument类代码示例

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


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

示例1: readServiceDocument

import org.apache.olingo.client.api.domain.ClientServiceDocument; //导入依赖的package包/类
@Test
public void readServiceDocument() {
  ODataServiceDocumentRequest request = getClient().getRetrieveRequestFactory()
      .getServiceDocumentRequest(SERVICE_URI);
  assertNotNull(request);
  setCookieHeader(request);

  ODataRetrieveResponse<ClientServiceDocument> response = request.execute();
  saveCookieHeader(response);
  assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());

  ClientServiceDocument serviceDocument = response.getBody();
  assertNotNull(serviceDocument);
  assertThat(serviceDocument.getEntitySetNames(), hasItem(ES_ALL_PRIM));
  assertThat(serviceDocument.getFunctionImportNames(), hasItem("FICRTCollCTTwoPrim"));
  assertThat(serviceDocument.getSingletonNames(), hasItem("SIMedia"));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:BasicITCase.java

示例2: readServiceDocument

import org.apache.olingo.client.api.domain.ClientServiceDocument; //导入依赖的package包/类
@Test
public void readServiceDocument() throws Exception {
  ODataServiceDocumentRequest request = getClient().getRetrieveRequestFactory()
      .getServiceDocumentRequest(TecSvcConst.BASE_URI);
  setCookieHeader(request);
  ODataRetrieveResponse<ClientServiceDocument> response = request.execute();
  saveCookieHeader(response);
  assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());

  request = getClient().getRetrieveRequestFactory().getServiceDocumentRequest(TecSvcConst.BASE_URI);
  request.setIfNoneMatch(response.getETag());
  setCookieHeader(request);
  response = request.execute();
  saveCookieHeader(response);
  assertEquals(HttpStatusCode.NOT_MODIFIED.getStatusCode(), response.getStatusCode());

  request = getClient().getRetrieveRequestFactory().getServiceDocumentRequest(TecSvcConst.BASE_URI);
  request.setIfMatch("W/\"0\"");
  setCookieHeader(request);
  executeAndExpectError(request, HttpStatusCode.PRECONDITION_FAILED);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:ConditionalITCase.java

示例3: getODataServiceDocument

import org.apache.olingo.client.api.domain.ClientServiceDocument; //导入依赖的package包/类
@Override
public ClientServiceDocument getODataServiceDocument(final ServiceDocument resource) {
  final ClientServiceDocument serviceDocument = new ClientServiceDocument();

  for (ServiceDocumentItem entitySet : resource.getEntitySets()) {
    serviceDocument.getEntitySets().
        put(entitySet.getName(), URIUtils.getURI(resource.getBaseURI(), entitySet.getUrl()));
  }
  for (ServiceDocumentItem functionImport : resource.getFunctionImports()) {
    serviceDocument.getFunctionImports().put(
        functionImport.getName() == null ? functionImport.getUrl() : functionImport.getName(),
        URIUtils.getURI(resource.getBaseURI(), functionImport.getUrl()));
  }
  for (ServiceDocumentItem singleton : resource.getSingletons()) {
    serviceDocument.getSingletons().put(
        singleton.getName() == null ? singleton.getUrl() : singleton.getName(),
        URIUtils.getURI(resource.getBaseURI(), singleton.getUrl()));
  }
  for (ServiceDocumentItem sdoc : resource.getRelatedServiceDocuments()) {
    serviceDocument.getRelatedServiceDocuments().put(
        sdoc.getName() == null ? sdoc.getUrl() : sdoc.getName(),
        URIUtils.getURI(resource.getBaseURI(), sdoc.getUrl()));
  }

  return serviceDocument;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:ODataBinderImpl.java

示例4: getBody

import org.apache.olingo.client.api.domain.ClientServiceDocument; //导入依赖的package包/类
@Override
public ClientServiceDocument getBody() {
  if (serviceDocument == null) {
    try {
      final ResWrap<ServiceDocument> resource = odataClient.
              getDeserializer(ContentType.parse(getContentType())).toServiceDocument(getRawResponse());

      serviceDocument = odataClient.getBinder().getODataServiceDocument(resource.getPayload());
    } catch (final ODataDeserializerException e) {
      throw new IllegalArgumentException(e);
    } finally {
      this.close();
    }
  }
  return serviceDocument;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:ODataServiceDocumentRequestImpl.java

示例5: parse

import org.apache.olingo.client.api.domain.ClientServiceDocument; //导入依赖的package包/类
private ClientServiceDocument parse(final ContentType contentType) throws ODataDeserializerException {
  ResWrap<ServiceDocument> service = client.getDeserializer(contentType).toServiceDocument(
      getClass().getResourceAsStream("serviceDocument." + getSuffix(contentType)));

  assertEquals(URI.create("http://host/service/$metadata"), service.getContextURL());
  assertEquals("W/\"MjAxMy0wNS0xM1QxNDo1NFo=\"", service.getMetadataETag());

  final ClientServiceDocument serviceDocument = client.getBinder().getODataServiceDocument(service.getPayload());
  assertNotNull(serviceDocument);

  assertTrue(serviceDocument.getEntitySetNames().contains("Order Details"));
  assertEquals(URI.create("http://host/service/TopProducts"),
      serviceDocument.getFunctionImportURI("TopProducts"));
  assertEquals(URI.create("http://host/HR/"),
      serviceDocument.getRelatedServiceDocumentsURIs().iterator().next());

  return serviceDocument;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:ServiceDocumentTest.java

示例6: testServiceReq

import org.apache.olingo.client.api.domain.ClientServiceDocument; //导入依赖的package包/类
@Test
public void testServiceReq() {
	ODataServiceDocumentRequest serviceReq =
			client.getRetrieveRequestFactory().getServiceDocumentRequest(serviceRoot);
	ODataRetrieveResponse<ClientServiceDocument> serviceRes = serviceReq.execute();
	ClientServiceDocument serviceBody = serviceRes.getBody();		
	Collection<String> names = serviceBody.getEntitySetNames();
	assertFalse(names.isEmpty());
}
 
开发者ID:jbaliuka,项目名称:sql-analytic,代码行数:10,代码来源:SQLODataServletTest.java

示例7: readServiceDocument

import org.apache.olingo.client.api.domain.ClientServiceDocument; //导入依赖的package包/类
@Override
public ClientServiceDocument readServiceDocument(final InputStream input, final ContentType contentType)
    throws ODataDeserializerException {
  return client.getBinder().getODataServiceDocument(
      client.getDeserializer(contentType).toServiceDocument(input).getPayload());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:7,代码来源:ODataReaderImpl.java

示例8: execute

import org.apache.olingo.client.api.domain.ClientServiceDocument; //导入依赖的package包/类
@Override
public ODataRetrieveResponse<ClientServiceDocument> execute() {
  final HttpResponse res = doExecute();
  return new ODataServiceResponseImpl(odataClient, httpClient, res);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:6,代码来源:ODataServiceDocumentRequestImpl.java

示例9: testRead

import org.apache.olingo.client.api.domain.ClientServiceDocument; //导入依赖的package包/类
@Test
public void testRead() throws Exception {

    CamelContext camelctx = createCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        public void configure() {
            // test routes for read
            from("direct://readmetadata").to("olingo4://read/$metadata");

            from("direct://readdocument").to("olingo4://read/");

            from("direct://readentities").to("olingo4://read/People?$top=5&$orderby=FirstName asc");

            from("direct://readcount").to("olingo4://read/People/$count");

            from("direct://readvalue").to("olingo4://read/People('russellwhyte')/Gender/$value");

            from("direct://readsingleprop").to("olingo4://read/Airports('KSFO')/Name");

            from("direct://readcomplexprop").to("olingo4://read/Airports('KSFO')/Location");

            from("direct://readentitybyid").to("olingo4://read/People('russellwhyte')");

            from("direct://callunboundfunction").to("olingo4://read/GetNearestAirport(lat=33,lon=-118)");
        }
    });
    camelctx.start();

    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        final Map<String, Object> headers = new HashMap<String, Object>();

        // Read metadata ($metadata) object
        final Edm metadata = (Edm) template.requestBodyAndHeaders("direct://readmetadata", null, headers);
        Assert.assertNotNull(metadata);
        Assert.assertEquals(1, metadata.getSchemas().size());

        // Read service document object
        final ClientServiceDocument document = (ClientServiceDocument) template.requestBodyAndHeaders("direct://readdocument", null, headers);

        Assert.assertNotNull(document);
        Assert.assertTrue(document.getEntitySets().size() > 1);
        LOG.info("Service document has {} entity sets", document.getEntitySets().size());

        // Read entity set of the People object
        final ClientEntitySet entities = (ClientEntitySet) template.requestBodyAndHeaders("direct://readentities", null, headers);
        Assert.assertNotNull(entities);
        Assert.assertEquals(5, entities.getEntities().size());

        // Read object count with query options passed through header
        final Long count = (Long) template.requestBodyAndHeaders("direct://readcount", null, headers);
        Assert.assertEquals(20, count.intValue());

        final ClientPrimitiveValue value = (ClientPrimitiveValue) template.requestBodyAndHeaders("direct://readvalue", null, headers);
        LOG.info("Client value \"{}\" has type {}", value.toString(), value.getTypeName());
        Assert.assertEquals("Male", value.asPrimitive().toString());

        final ClientPrimitiveValue singleProperty = (ClientPrimitiveValue) template.requestBodyAndHeaders("direct://readsingleprop", null, headers);
        Assert.assertTrue(singleProperty.isPrimitive());
        Assert.assertEquals("San Francisco International Airport", singleProperty.toString());

        final ClientComplexValue complexProperty = (ClientComplexValue) template.requestBodyAndHeaders("direct://readcomplexprop", null, headers);
        Assert.assertTrue(complexProperty.isComplex());
        Assert.assertEquals("San Francisco", complexProperty.get("City").getComplexValue().get("Name").getValue().toString());

        final ClientEntity entity = (ClientEntity) template.requestBodyAndHeaders("direct://readentitybyid", null, headers);
        Assert.assertNotNull(entity);
        Assert.assertEquals("Russell", entity.getProperty("FirstName").getValue().toString());

        final ClientEntity unbFuncReturn = (ClientEntity) template.requestBodyAndHeaders("direct://callunboundfunction", null, headers);
        Assert.assertNotNull(unbFuncReturn);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:76,代码来源:Olingo4IntegrationTest.java

示例10: readServiceDocument

import org.apache.olingo.client.api.domain.ClientServiceDocument; //导入依赖的package包/类
/**
 * Parses an OData service document.
 *
 * @param input stream to de-serialize.
 * @param contentType de-serialize as XML or JSON
 * @return List of URIs.
 * @throws ODataDeserializerException
 */
ClientServiceDocument readServiceDocument(InputStream input, ContentType contentType) 
    throws ODataDeserializerException;
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:11,代码来源:ODataReader.java

示例11: getODataServiceDocument

import org.apache.olingo.client.api.domain.ClientServiceDocument; //导入依赖的package包/类
/**
 * Gets <tt>ODataServiceDocument</tt> from the given service document resource.
 *
 * @param resource service document resource.
 * @return <tt>ODataServiceDocument</tt> object.
 */
ClientServiceDocument getODataServiceDocument(ServiceDocument resource);
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:8,代码来源:ODataBinder.java


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