Java Code Examples for org.apache.olingo.odata2.api.edm.Edm#getDefaultEntityContainer()

The following examples show how to use org.apache.olingo.odata2.api.edm.Edm#getDefaultEntityContainer() . 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: CMODataAbapClient.java    From devops-cm-client with Apache License 2.0 7 votes vote down vote up
public void updateTransport(Transport transport) throws IOException, URISyntaxException, ODataException, UnexpectedHttpResponseException
{
  Edm edm = getEntityDataModel();
  try (CloseableHttpClient client = clientFactory.createClient()) {
    
    HttpPut put = requestBuilder.updateTransport(transport.getTransportID());
    put.setHeader("x-csrf-token", getCSRFToken());
    EdmEntityContainer entityContainer = edm.getDefaultEntityContainer();
    EdmEntitySet entitySet = entityContainer.getEntitySet(TransportRequestBuilder.getEntityKey());
    URI rootUri = new URI(endpoint.toASCIIString() + "/");
    EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(rootUri).build();
    ODataResponse response = null;
    try {
        response = EntityProvider.writeEntry(put.getHeaders(HttpHeaders.CONTENT_TYPE)[0].getValue(), entitySet,transport.getValueMap(), properties);
        put.setEntity(EntityBuilder.create().setStream(response.getEntityAsStream()).build());
        try (CloseableHttpResponse httpResponse = client.execute(put)) {
            hasStatusOrFail(httpResponse, SC_OK, HttpStatus.SC_NO_CONTENT);
        }
    }  finally {
        if(response != null) response.close();
    }
  }
}
 
Example 2
Source File: ServiceTicketODataConsumer.java    From C4CODATAAPIDEVGUIDE with Apache License 2.0 5 votes vote down vote up
public ODataFeed readFeed(String serviceUri, String contentType,
		String entitySetName, SystemQueryOptions options)
		throws IllegalStateException, IOException, EntityProviderException,
		EdmException {
	Edm edm = readEdm();
	EdmEntityContainer entityContainer = edm.getDefaultEntityContainer();
	String absolutUri = createUri(serviceUri, entitySetName, null, options);

	InputStream content = executeGet(absolutUri, contentType);
	return EntityProvider.readFeed(contentType,
			entityContainer.getEntitySet(entitySetName), content,
			EntityProviderReadProperties.init().build());
}