http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java deleted file mode 100644 index ce78d84..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncRequestWrapperImpl.java +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.communication.request.v4; - -import java.io.IOException; -import java.net.URI; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.commons.lang3.ArrayUtils; -import org.apache.http.Header; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.impl.client.DecompressingHttpClient; -import org.apache.http.util.EntityUtils; -import org.apache.olingo.client.api.communication.ODataClientErrorException; -import org.apache.olingo.client.api.communication.header.HeaderName; -import org.apache.olingo.client.api.communication.header.ODataPreferences; -import org.apache.olingo.client.api.communication.request.ODataRequest; -import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest; -import org.apache.olingo.client.api.communication.request.v4.AsyncRequestWrapper; -import org.apache.olingo.client.api.communication.response.ODataDeleteResponse; -import org.apache.olingo.client.api.communication.response.ODataResponse; -import org.apache.olingo.client.api.communication.response.v4.AsyncResponseWrapper; -import org.apache.olingo.client.api.http.HttpClientException; -import org.apache.olingo.client.api.v4.ODataClient; -import org.apache.olingo.client.core.communication.request.AbstractODataRequest; -import org.apache.olingo.client.core.communication.request.AbstractRequest; -import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; -import org.apache.olingo.commons.api.http.HttpMethod; - -public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRequest - implements AsyncRequestWrapper<R> { - - protected static final int MAX_RETRY = 5; - - protected final ODataClient odataClient; - - /** - * Request to be wrapped. - */ - protected final ODataRequest odataRequest; - - /** - * HTTP client. - */ - protected final HttpClient httpClient; - - /** - * HTTP request. - */ - protected final HttpUriRequest request; - - /** - * Target URI. - */ - protected final URI uri; - - protected AsyncRequestWrapperImpl(final ODataClient odataClient, final ODataRequest odataRequest) { - this.odataRequest = odataRequest; - this.odataRequest.setAccept(this.odataRequest.getAccept()); - this.odataRequest.setContentType(this.odataRequest.getContentType()); - - extendHeader(HeaderName.prefer.toString(), new ODataPreferences(ODataServiceVersion.V40).respondAsync()); - - this.odataClient = odataClient; - final HttpMethod method = odataRequest.getMethod(); - - // target uri - this.uri = odataRequest.getURI(); - - HttpClient _httpClient = odataClient.getConfiguration().getHttpClientFactory().create(method, this.uri); - if (odataClient.getConfiguration().isGzipCompression()) { - _httpClient = new DecompressingHttpClient(_httpClient); - } - this.httpClient = _httpClient; - - this.request = odataClient.getConfiguration().getHttpUriRequestFactory().create(method, this.uri); - } - - @Override - public final AsyncRequestWrapper<R> wait(final int waitInSeconds) { - extendHeader(HeaderName.prefer.toString(), new ODataPreferences(ODataServiceVersion.V40).wait(waitInSeconds)); - return this; - } - - @Override - public final AsyncRequestWrapper<R> callback(URI url) { - extendHeader(HeaderName.prefer.toString(), - new ODataPreferences(ODataServiceVersion.V40).callback(url.toASCIIString())); - return this; - } - - protected final void extendHeader(final String headerName, final String headerValue) { - final StringBuilder extended = new StringBuilder(); - if (this.odataRequest.getHeaderNames().contains(headerName)) { - extended.append(this.odataRequest.getHeader(headerName)).append(", "); - } - - this.odataRequest.addCustomHeader(headerName, extended.append(headerValue).toString()); - } - - @Override - public AsyncResponseWrapper<R> execute() { - return new AsyncResponseWrapperImpl(doExecute()); - } - - protected HttpResponse doExecute() { - // Add all available headers - for (String key : odataRequest.getHeaderNames()) { - final String value = odataRequest.getHeader(key); - this.request.addHeader(key, value); - LOG.debug("HTTP header being sent {}: {}", key, value); - } - - return executeHttpRequest(httpClient, this.request); - } - - public class AsyncResponseWrapperImpl implements AsyncResponseWrapper<R> { - - protected URI location = null; - - protected R response = null; - - protected int retryAfter = 5; - - protected boolean preferenceApplied = false; - - public AsyncResponseWrapperImpl() { - } - - /** - * Constructor. - * - * @param res HTTP response. - */ - @SuppressWarnings("unchecked") - public AsyncResponseWrapperImpl(final HttpResponse res) { - if (res.getStatusLine().getStatusCode() == 202) { - retrieveMonitorDetails(res); - } else { - response = (R) ((AbstractODataRequest) odataRequest).getResponseTemplate().initFromHttpResponse(res); - } - } - - @Override - public boolean isPreferenceApplied() { - return preferenceApplied; - } - - @Override - public boolean isDone() { - if (response == null) { - // check to the monitor URL - final HttpResponse res = checkMonitor(location); - - if (res.getStatusLine().getStatusCode() == 202) { - retrieveMonitorDetails(res); - } else { - response = instantiateResponse(res); - } - } - - return response != null; - } - - @Override - public R getODataResponse() { - HttpResponse res = null; - for (int i = 0; response == null && i < MAX_RETRY; i++) { - res = checkMonitor(location); - - if (res.getStatusLine().getStatusCode() == 202) { - - final Header[] headers = res.getHeaders(HeaderName.retryAfter.toString()); - if (ArrayUtils.isNotEmpty(headers)) { - this.retryAfter = Integer.parseInt(headers[0].getValue()); - } - - try { - // wait for retry-after - Thread.sleep(retryAfter * 1000); - } catch (InterruptedException ignore) { - // ignore - } - - } else { - location = null; - return instantiateResponse(res); - } - } - - if (response == null) { - throw new ODataClientErrorException(res == null ? null : res.getStatusLine()); - } - - return response; - } - - /** - * {@inheritDoc} - */ - @Override - public ODataDeleteResponse delete() { - final ODataDeleteRequest deleteRequest = odataClient.getCUDRequestFactory().getDeleteRequest(location); - return deleteRequest.execute(); - } - - /** - * {@inheritDoc} - */ - @Override - public AsyncResponseWrapper<ODataDeleteResponse> asyncDelete() { - return odataClient.getAsyncRequestFactory().<ODataDeleteResponse>getAsyncRequestWrapper( - odataClient.getCUDRequestFactory().getDeleteRequest(location)).execute(); - } - - /** - * {@inheritDoc} - */ - @Override - public AsyncResponseWrapper<R> forceNextMonitorCheck(final URI uri) { - this.location = uri; - this.response = null; - return this; - } - - @SuppressWarnings("unchecked") - private R instantiateResponse(final HttpResponse res) { - R odataResponse; - try { - odataResponse = (R) ((AbstractODataRequest) odataRequest).getResponseTemplate(). - initFromEnclosedPart(res.getEntity().getContent()); - - } catch (Exception e) { - LOG.error("Error instantiating odata response", e); - odataResponse = null; - } - - return odataResponse; - } - - private void retrieveMonitorDetails(final HttpResponse res) { - Header[] headers = res.getHeaders(HeaderName.location.toString()); - if (ArrayUtils.isNotEmpty(headers)) { - this.location = URI.create(headers[0].getValue()); - } else { - throw new AsyncRequestException( - "Invalid async request response. Monitor URL '" + headers[0].getValue() + "'"); - } - - headers = res.getHeaders(HeaderName.retryAfter.toString()); - if (ArrayUtils.isNotEmpty(headers)) { - this.retryAfter = Integer.parseInt(headers[0].getValue()); - } - - headers = res.getHeaders(HeaderName.preferenceApplied.toString()); - if (ArrayUtils.isNotEmpty(headers)) { - for (Header header : headers) { - if (header.getValue().equalsIgnoreCase(new ODataPreferences(ODataServiceVersion.V40).respondAsync())) { - preferenceApplied = true; - } - } - } - try { - EntityUtils.consume(res.getEntity()); - } catch (IOException ex) { - Logger.getLogger(AsyncRequestWrapperImpl.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - protected final HttpResponse checkMonitor(final URI location) { - if (location == null) { - throw new AsyncRequestException("Invalid async request response. Missing monitor URL"); - } - - final HttpUriRequest monitor = odataClient.getConfiguration().getHttpUriRequestFactory(). - create(HttpMethod.GET, location); - - return executeHttpRequest(httpClient, monitor); - } - - protected final HttpResponse executeHttpRequest(final HttpClient client, final HttpUriRequest req) { - final HttpResponse response; - try { - response = client.execute(req); - } catch (IOException e) { - throw new HttpClientException(e); - } catch (RuntimeException e) { - req.abort(); - throw new HttpClientException(e); - } - - checkResponse(odataClient, response, odataRequest.getAccept()); - - return response; - } -}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AsyncResponseImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AsyncResponseImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AsyncResponseImpl.java new file mode 100644 index 0000000..6f012c8 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AsyncResponseImpl.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.communication.response; + +import java.util.Collection; +import java.util.Map; + +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.olingo.client.api.CommonODataClient; +import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator; +import org.apache.olingo.client.api.communication.response.AsyncResponse; +import org.apache.olingo.client.core.communication.request.batch.ODataBatchController; + +/** + * Abstract representation of an OData response. + */ +public class AsyncResponseImpl extends AbstractODataResponse implements AsyncResponse { + + public AsyncResponseImpl(final CommonODataClient<?> odataClient, final HttpClient httpClient, + final HttpResponse res) { + + super(odataClient, httpClient, res); + } + + /** + * Constructor to be used inside a batch item. + */ + public AsyncResponseImpl( + final Map.Entry<Integer, String> responseLine, + final Map<String, Collection<String>> headers, + final ODataBatchLineIterator batchLineIterator, + final String boundary) { + + super(null, null, null); + + if (hasBeenInitialized) { + throw new IllegalStateException("Request already initialized"); + } + + this.hasBeenInitialized = true; + + this.batchInfo = new ODataBatchController(batchLineIterator, boundary); + + this.statusCode = responseLine.getKey(); + this.statusMessage = responseLine.getValue(); + this.headers.putAll(headers); + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/v4/AsyncResponseImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/v4/AsyncResponseImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/v4/AsyncResponseImpl.java deleted file mode 100644 index cdbfa8a..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/v4/AsyncResponseImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.communication.response.v4; - -import java.util.Collection; -import java.util.Map; - -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.olingo.client.api.CommonODataClient; -import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator; -import org.apache.olingo.client.api.communication.response.v4.AsyncResponse; -import org.apache.olingo.client.core.communication.request.batch.ODataBatchController; -import org.apache.olingo.client.core.communication.response.AbstractODataResponse; - -/** - * Abstract representation of an OData response. - */ -public class AsyncResponseImpl extends AbstractODataResponse implements AsyncResponse { - - public AsyncResponseImpl(final CommonODataClient<?> odataClient, final HttpClient httpClient, - final HttpResponse res) { - - super(odataClient, httpClient, res); - } - - /** - * Constructor to be used inside a batch item. - */ - public AsyncResponseImpl( - final Map.Entry<Integer, String> responseLine, - final Map<String, Collection<String>> headers, - final ODataBatchLineIterator batchLineIterator, - final String boundary) { - - super(null, null, null); - - if (hasBeenInitialized) { - throw new IllegalStateException("Request already initialized"); - } - - this.hasBeenInitialized = true; - - this.batchInfo = new ODataBatchController(batchLineIterator, boundary); - - this.statusCode = responseLine.getKey(); - this.statusMessage = responseLine.getValue(); - this.headers.putAll(headers); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java index 8340ec6..63cfa42 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImpl.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.core.edm; -import org.apache.olingo.client.api.edm.xml.v4.Action; +import org.apache.olingo.client.api.edm.xml.Action; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; import org.apache.olingo.commons.api.edm.FullQualifiedName; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java index 3478f48..d826486 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java @@ -20,7 +20,7 @@ package org.apache.olingo.client.core.edm; import java.util.List; -import org.apache.olingo.client.api.edm.xml.v4.ActionImport; +import org.apache.olingo.client.api.edm.xml.ActionImport; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; import org.apache.olingo.commons.api.edm.EdmActionImport; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java index e7b334d..f6d0a25 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java @@ -21,8 +21,8 @@ package org.apache.olingo.client.core.edm; import java.util.ArrayList; import java.util.List; -import org.apache.olingo.client.api.edm.xml.v4.Annotatable; -import org.apache.olingo.client.api.edm.xml.v4.Annotation; +import org.apache.olingo.client.api.edm.xml.Annotatable; +import org.apache.olingo.client.api.edm.xml.Annotation; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmTerm; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java index 81b89a9..de46fae 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java @@ -21,15 +21,15 @@ package org.apache.olingo.client.core.edm; import java.util.ArrayList; import java.util.List; -import org.apache.olingo.client.api.edm.xml.v4.Annotatable; -import org.apache.olingo.client.api.edm.xml.v4.Annotation; -import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationExpression; -import org.apache.olingo.client.api.edm.xml.v4.annotation.DynamicAnnotationExpression; -import org.apache.olingo.client.api.edm.xml.v4.annotation.PropertyValue; -import org.apache.olingo.client.core.edm.v4.annotation.EdmCastImpl; -import org.apache.olingo.client.core.edm.v4.annotation.EdmConstantAnnotationExpressionImpl; -import org.apache.olingo.client.core.edm.v4.annotation.EdmIsOfImpl; -import org.apache.olingo.client.core.edm.v4.annotation.EdmRecordImpl; +import org.apache.olingo.client.api.edm.xml.Annotatable; +import org.apache.olingo.client.api.edm.xml.Annotation; +import org.apache.olingo.client.api.edm.xml.annotation.AnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.DynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.PropertyValue; +import org.apache.olingo.client.core.edm.annotation.EdmCastImpl; +import org.apache.olingo.client.core.edm.annotation.EdmConstantAnnotationExpressionImpl; +import org.apache.olingo.client.core.edm.annotation.EdmIsOfImpl; +import org.apache.olingo.client.core.edm.annotation.EdmRecordImpl; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotatable; import org.apache.olingo.commons.api.edm.EdmAnnotation; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java index 5589033..ebd953d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringUtils; -import org.apache.olingo.client.api.edm.xml.v4.Annotation; -import org.apache.olingo.client.api.edm.xml.v4.Annotations; +import org.apache.olingo.client.api.edm.xml.Annotation; +import org.apache.olingo.client.api.edm.xml.Annotations; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmAnnotations; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java index ed26215..21b7e9b 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java @@ -21,8 +21,8 @@ package org.apache.olingo.client.core.edm; import java.util.ArrayList; import java.util.List; -import org.apache.olingo.client.api.edm.xml.v4.BindingTarget; -import org.apache.olingo.client.api.edm.xml.v4.NavigationPropertyBinding; +import org.apache.olingo.client.api.edm.xml.BindingTarget; +import org.apache.olingo.client.api.edm.xml.NavigationPropertyBinding; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java index 89468a7..6b9c9b9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java @@ -32,19 +32,19 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import org.apache.olingo.client.api.edm.xml.Action; +import org.apache.olingo.client.api.edm.xml.Annotatable; +import org.apache.olingo.client.api.edm.xml.Annotation; +import org.apache.olingo.client.api.edm.xml.Annotations; import org.apache.olingo.client.api.edm.xml.CommonParameter; import org.apache.olingo.client.api.edm.xml.ComplexType; import org.apache.olingo.client.api.edm.xml.EntityContainer; import org.apache.olingo.client.api.edm.xml.EntityType; import org.apache.olingo.client.api.edm.xml.EnumType; +import org.apache.olingo.client.api.edm.xml.Function; import org.apache.olingo.client.api.edm.xml.Schema; -import org.apache.olingo.client.api.edm.xml.v4.Action; -import org.apache.olingo.client.api.edm.xml.v4.Annotatable; -import org.apache.olingo.client.api.edm.xml.v4.Annotation; -import org.apache.olingo.client.api.edm.xml.v4.Annotations; -import org.apache.olingo.client.api.edm.xml.v4.Function; -import org.apache.olingo.client.api.edm.xml.v4.Term; -import org.apache.olingo.client.api.edm.xml.v4.TypeDefinition; +import org.apache.olingo.client.api.edm.xml.Term; +import org.apache.olingo.client.api.edm.xml.TypeDefinition; import org.apache.olingo.commons.api.edm.EdmAction; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmAnnotations; @@ -140,8 +140,8 @@ public class EdmClientImpl extends AbstractEdm { EdmTypeDefinition result = null; final Schema schema = xmlSchemaByNamespace.get(typeDefinitionName.getNamespace()); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { - final TypeDefinition xmlTypeDefinition = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema). + if (schema instanceof Schema) { + final TypeDefinition xmlTypeDefinition = ((Schema) schema). getTypeDefinition(typeDefinitionName.getName()); if (xmlTypeDefinition != null) { result = new EdmTypeDefinitionImpl(version, this, typeDefinitionName, xmlTypeDefinition); @@ -186,8 +186,8 @@ public class EdmClientImpl extends AbstractEdm { EdmAction result = null; final Schema schema = xmlSchemaByNamespace.get(actionName.getNamespace()); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { - final List<Action> actions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema). + if (schema instanceof Schema) { + final List<Action> actions = ((Schema) schema). getActions(actionName.getName()); boolean found = false; for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) { @@ -206,8 +206,8 @@ public class EdmClientImpl extends AbstractEdm { final List<EdmFunction> result = new ArrayList<EdmFunction>(); final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace()); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { - final List<Function> functions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema). + if (schema instanceof Schema) { + final List<Function> functions = ((Schema) schema). getFunctions(functionName.getName()); for (final Iterator<Function> itor = functions.iterator(); itor.hasNext();) { final Function function = itor.next(); @@ -224,8 +224,8 @@ public class EdmClientImpl extends AbstractEdm { EdmFunction result = null; final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace()); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { - final List<Function> functions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema). + if (schema instanceof Schema) { + final List<Function> functions = ((Schema) schema). getFunctions(functionName.getName()); boolean found = false; for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) { @@ -252,9 +252,9 @@ public class EdmClientImpl extends AbstractEdm { EdmAction result = null; final Schema schema = xmlSchemaByNamespace.get(actionName.getNamespace()); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + if (schema instanceof Schema) { final List<Action> actions = - ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getActions(actionName.getName()); + ((Schema) schema).getActions(actionName.getName()); boolean found = false; for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) { final Action action = itor.next(); @@ -282,8 +282,8 @@ public class EdmClientImpl extends AbstractEdm { EdmFunction result = null; final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace()); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { - final List<Function> functions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema). + if (schema instanceof Schema) { + final List<Function> functions = ((Schema) schema). getFunctions(functionName.getName()); boolean found = false; for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) { @@ -315,8 +315,8 @@ public class EdmClientImpl extends AbstractEdm { EdmTerm result = null; final Schema schema = xmlSchemaByNamespace.get(termName.getNamespace()); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { - final Term term = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getTerm(termName.getName()); + if (schema instanceof Schema) { + final Term term = ((Schema) schema).getTerm(termName.getName()); if (term != null) { result = new EdmTermImpl(this, schema.getNamespace(), term); } @@ -330,9 +330,9 @@ public class EdmClientImpl extends AbstractEdm { EdmAnnotationsImpl result = null; final Schema schema = xmlSchemaByNamespace.get(targetName.getNamespace()); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + if (schema instanceof Schema) { final Annotations annotationGroup = - ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getAnnotationGroup(targetName.getName()); + ((Schema) schema).getAnnotationGroup(targetName.getName()); if (annotationGroup != null) { result = new EdmAnnotationsImpl(this, schemas.get(schema.getNamespace()), annotationGroup); } @@ -346,9 +346,9 @@ public class EdmClientImpl extends AbstractEdm { List<EdmAnnotation> result = null; final Schema schema = xmlSchemaByNamespace.get(annotatedName.getNamespace()); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + if (schema instanceof Schema) { final Annotatable annotatable = - ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getAnnotatables().get(annotatedName.getName()); + ((Schema) schema).getAnnotatables().get(annotatedName.getName()); if (annotatable != null && annotatable.getAnnotations() != null) { result = new ArrayList<EdmAnnotation>(); for (Annotation annotation : annotatable.getAnnotations()) { http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java index 6f70e36..e734200 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java @@ -44,8 +44,8 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType { final List<? extends Schema> xmlSchemas, final ComplexType complexType) { FullQualifiedName baseTypeName = null; - if (complexType instanceof org.apache.olingo.client.api.edm.xml.v4.ComplexType) { - final String baseType = ((org.apache.olingo.client.api.edm.xml.v4.ComplexType) complexType).getBaseType(); + if (complexType instanceof org.apache.olingo.client.api.edm.xml.ComplexType) { + final String baseType = ((org.apache.olingo.client.api.edm.xml.ComplexType) complexType).getBaseType(); baseTypeName = baseType == null ? null : new EdmTypeInfo.Builder().setTypeExpression(baseType).build().getFullQualifiedName(); } @@ -60,9 +60,9 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType { super(edm, fqn, baseTypeName); this.typeHelper = new EdmStructuredTypeHelperImpl(edm, getFullQualifiedName(), xmlSchemas, complexType); - if (complexType instanceof org.apache.olingo.client.api.edm.xml.v4.ComplexType) { + if (complexType instanceof org.apache.olingo.client.api.edm.xml.ComplexType) { this.annotationHelper = new EdmAnnotationHelperImpl(edm, - (org.apache.olingo.client.api.edm.xml.v4.ComplexType) complexType); + (org.apache.olingo.client.api.edm.xml.ComplexType) complexType); } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java index defaf0f..b6cdc36 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java @@ -21,12 +21,12 @@ package org.apache.olingo.client.core.edm; import java.util.Collections; import java.util.List; +import org.apache.olingo.client.api.edm.xml.ActionImport; import org.apache.olingo.client.api.edm.xml.CommonFunctionImport; import org.apache.olingo.client.api.edm.xml.EntityContainer; import org.apache.olingo.client.api.edm.xml.EntitySet; import org.apache.olingo.client.api.edm.xml.Schema; -import org.apache.olingo.client.api.edm.xml.v4.ActionImport; -import org.apache.olingo.client.api.edm.xml.v4.Singleton; +import org.apache.olingo.client.api.edm.xml.Singleton; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmActionImport; import org.apache.olingo.commons.api.edm.EdmAnnotation; @@ -55,22 +55,22 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { this.xmlEntityContainer = xmlEntityContainer; this.xmlSchemas = xmlSchemas; - if (xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer) { + if (xmlEntityContainer instanceof EntityContainer) { this.helper = new EdmAnnotationHelperImpl(edm, - (org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer); + (EntityContainer) xmlEntityContainer); } } @Override public boolean isDefault() { - return xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer + return xmlEntityContainer instanceof EntityContainer ? true : xmlEntityContainer.isDefaultEntityContainer(); } @Override protected EdmSingleton createSingleton(final String singletonName) { - final Singleton singleton = ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer). + final Singleton singleton = ((EntityContainer) xmlEntityContainer). getSingleton(singletonName); return singleton == null ? null @@ -88,9 +88,9 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { if (entitySet != null) { final FullQualifiedName entityType = new EdmTypeInfo.Builder().setTypeExpression(entitySet.getEntityType()). setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName(); - if (entitySet instanceof org.apache.olingo.client.api.edm.xml.v4.EntitySet) { + if (entitySet instanceof EntitySet) { result = new EdmEntitySetImpl(edm, this, entitySetName, entityType, - (org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet); + (EntitySet) entitySet); } } @@ -101,8 +101,8 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { protected EdmActionImport createActionImport(final String actionImportName) { EdmActionImport result = null; - if (xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer) { - final ActionImport actionImport = ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer). + if (xmlEntityContainer instanceof EntityContainer) { + final ActionImport actionImport = ((EntityContainer) xmlEntityContainer). getActionImport(actionImportName); if (actionImport != null) { result = new EdmActionImportImpl(edm, this, actionImportName, actionImport); @@ -117,9 +117,9 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { final CommonFunctionImport functionImport = xmlEntityContainer.getFunctionImport(functionImportName); if (functionImport != null) { - if (functionImport instanceof org.apache.olingo.client.api.edm.xml.v4.FunctionImport) { + if (functionImport instanceof org.apache.olingo.client.api.edm.xml.FunctionImport) { result = new EdmFunctionImportImpl(edm, this, functionImportName, - (org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport); + (org.apache.olingo.client.api.edm.xml.FunctionImport) functionImport); } } @@ -134,9 +134,9 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { EdmEntitySet edmSet; final FullQualifiedName entityType = new EdmTypeInfo.Builder().setTypeExpression(entitySet.getEntityType()). setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName(); - if (entitySet instanceof org.apache.olingo.client.api.edm.xml.v4.EntitySet) { + if (entitySet instanceof EntitySet) { edmSet = new EdmEntitySetImpl(edm, this, entitySet.getName(), entityType, - (org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet); + (EntitySet) entitySet); entitySets.put(edmSet.getName(), edmSet); } } @@ -149,9 +149,9 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { final List<? extends CommonFunctionImport> localFunctionImports = xmlEntityContainer.getFunctionImports(); for (CommonFunctionImport functionImport : localFunctionImports) { EdmFunctionImport edmFunctionImport; - if (functionImport instanceof org.apache.olingo.client.api.edm.xml.v4.FunctionImport) { + if (functionImport instanceof org.apache.olingo.client.api.edm.xml.FunctionImport) { edmFunctionImport = new EdmFunctionImportImpl(edm, this, functionImport.getName(), - (org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport); + (org.apache.olingo.client.api.edm.xml.FunctionImport) functionImport); functionImports.put(edmFunctionImport.getName(), edmFunctionImport); } } @@ -160,7 +160,7 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { @Override protected void loadAllSingletons() { final List<Singleton> localSingletons = - ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).getSingletons(); + ((EntityContainer) xmlEntityContainer).getSingletons(); if (localSingletons != null) { for (Singleton singleton : localSingletons) { singletons.put(singleton.getName(), new EdmSingletonImpl(edm, this, singleton.getName(), @@ -173,9 +173,9 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { @Override protected void loadAllActionImports() { - if (xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer) { + if (xmlEntityContainer instanceof EntityContainer) { final List<ActionImport> localActionImports = - ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer).getActionImports(); + ((EntityContainer) xmlEntityContainer).getActionImports(); if (actionImports != null) { for (ActionImport actionImport : localActionImports) { actionImports.put(actionImport.getName(), http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java index 2c80ad1..d4aa183 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.core.edm; -import org.apache.olingo.client.api.edm.xml.v4.EntitySet; +import org.apache.olingo.client.api.edm.xml.EntitySet; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntitySet; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java index 27730b3..746047b 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java @@ -80,9 +80,9 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType { super(edm, fqn, baseTypeName, entityType.isHasStream()); this.typeHelper = new EdmStructuredTypeHelperImpl(edm, getFullQualifiedName(), xmlSchemas, entityType); - if (entityType instanceof org.apache.olingo.client.api.edm.xml.v4.EntityType) { + if (entityType instanceof EntityType) { this.annotationHelper = new EdmAnnotationHelperImpl(edm, - (org.apache.olingo.client.api.edm.xml.v4.EntityType) entityType); + (EntityType) entityType); } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImpl.java index d2831fc..1e7f9f6 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImpl.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.core.edm; -import org.apache.olingo.client.api.edm.xml.v4.Function; +import org.apache.olingo.client.api.edm.xml.Function; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.FullQualifiedName; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java index ade9bba..170c046 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java @@ -20,7 +20,7 @@ package org.apache.olingo.client.core.edm; import java.util.List; -import org.apache.olingo.client.api.edm.xml.v4.FunctionImport; +import org.apache.olingo.client.api.edm.xml.FunctionImport; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java index a06fcc9..bf19703 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.List; import org.apache.olingo.client.api.edm.xml.Member; -import org.apache.olingo.client.core.edm.xml.v4.MemberImpl; +import org.apache.olingo.client.core.edm.xml.MemberImpl; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmTerm; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java index 6aa3476..c3aec23 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java @@ -21,8 +21,8 @@ package org.apache.olingo.client.core.edm; import java.util.ArrayList; import java.util.List; -import org.apache.olingo.client.api.edm.xml.v4.NavigationProperty; -import org.apache.olingo.client.api.edm.xml.v4.ReferentialConstraint; +import org.apache.olingo.client.api.edm.xml.NavigationProperty; +import org.apache.olingo.client.api.edm.xml.ReferentialConstraint; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmReferentialConstraint; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java index b09ce3f..498fece 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringUtils; +import org.apache.olingo.client.api.edm.xml.Action; import org.apache.olingo.client.api.edm.xml.CommonParameter; -import org.apache.olingo.client.api.edm.xml.v4.Action; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmParameter; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java index 8b2830a..c71d1e5 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.List; import org.apache.olingo.client.api.edm.xml.CommonParameter; -import org.apache.olingo.client.api.edm.xml.v4.Parameter; +import org.apache.olingo.client.api.edm.xml.Parameter; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmMapping; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java index 7faba4f..36e2348 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.List; import org.apache.olingo.client.api.edm.xml.CommonProperty; -import org.apache.olingo.client.api.edm.xml.v4.Property; +import org.apache.olingo.client.api.edm.xml.Property; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmMapping; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java index 1564593..c9a80e9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java @@ -20,7 +20,7 @@ package org.apache.olingo.client.core.edm; import java.util.List; -import org.apache.olingo.client.api.edm.xml.v4.ReferentialConstraint; +import org.apache.olingo.client.api.edm.xml.ReferentialConstraint; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmTerm; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java index 4d7c9f4..071cbfa 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.core.edm; -import org.apache.olingo.client.api.edm.xml.v4.ReturnType; +import org.apache.olingo.client.api.edm.xml.ReturnType; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.AbstractEdmReturnType; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java index eb6c31b..b1cbd1c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java @@ -23,17 +23,17 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.olingo.client.api.edm.xml.Action; +import org.apache.olingo.client.api.edm.xml.Annotation; +import org.apache.olingo.client.api.edm.xml.Annotations; import org.apache.olingo.client.api.edm.xml.ComplexType; import org.apache.olingo.client.api.edm.xml.EntityContainer; import org.apache.olingo.client.api.edm.xml.EntityType; import org.apache.olingo.client.api.edm.xml.EnumType; +import org.apache.olingo.client.api.edm.xml.Function; import org.apache.olingo.client.api.edm.xml.Schema; -import org.apache.olingo.client.api.edm.xml.v4.Action; -import org.apache.olingo.client.api.edm.xml.v4.Annotation; -import org.apache.olingo.client.api.edm.xml.v4.Annotations; -import org.apache.olingo.client.api.edm.xml.v4.Function; -import org.apache.olingo.client.api.edm.xml.v4.Term; -import org.apache.olingo.client.api.edm.xml.v4.TypeDefinition; +import org.apache.olingo.client.api.edm.xml.Term; +import org.apache.olingo.client.api.edm.xml.TypeDefinition; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; import org.apache.olingo.commons.api.edm.EdmAnnotation; @@ -79,7 +79,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema { if (entityContainers == null) { entityContainerByName = new HashMap<FullQualifiedName, EdmEntityContainer>(); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + if (schema instanceof Schema) { entityContainers = super.getEntityContainers(); if (getEntityContainer() != null) { entityContainerByName.put(getEntityContainer().getFullQualifiedName(), getEntityContainer()); @@ -127,9 +127,9 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List<EdmTypeDefinition> createTypeDefinitions() { final List<EdmTypeDefinition> typeDefinitions = new ArrayList<EdmTypeDefinition>(); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + if (schema instanceof Schema) { final List<TypeDefinition> providerTypeDefinitions = - ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getTypeDefinitions(); + ((Schema) schema).getTypeDefinitions(); if (providerTypeDefinitions != null) { for (TypeDefinition def : providerTypeDefinitions) { typeDefinitions.add( @@ -182,8 +182,8 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List<EdmAction> createActions() { final List<EdmAction> actions = new ArrayList<EdmAction>(); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { - final List<Action> providerActions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getActions(); + if (schema instanceof Schema) { + final List<Action> providerActions = ((Schema) schema).getActions(); if (providerActions != null) { for (Action action : providerActions) { actions.add(EdmActionImpl.getInstance(edm, new FullQualifiedName(namespace, action.getName()), action)); @@ -196,8 +196,8 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List<EdmFunction> createFunctions() { final List<EdmFunction> functions = new ArrayList<EdmFunction>(); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { - final List<Function> providerFunctions = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getFunctions(); + if (schema instanceof Schema) { + final List<Function> providerFunctions = ((Schema) schema).getFunctions(); if (providerFunctions != null) { for (Function function : providerFunctions) { functions.add( @@ -212,8 +212,8 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List<EdmTerm> createTerms() { final List<EdmTerm> terms = new ArrayList<EdmTerm>(); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { - final List<Term> providerTerms = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getTerms(); + if (schema instanceof Schema) { + final List<Term> providerTerms = ((Schema) schema).getTerms(); if (providerTerms != null) { for (Term term : providerTerms) { terms.add(new EdmTermImpl(edm, getNamespace(), term)); @@ -226,9 +226,9 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List<EdmAnnotations> createAnnotationGroups() { final List<EdmAnnotations> annotationGroups = new ArrayList<EdmAnnotations>(); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + if (schema instanceof Schema) { final List<Annotations> providerAnnotations = - ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getAnnotationGroups(); + ((Schema) schema).getAnnotationGroups(); if (providerAnnotations != null) { for (Annotations annotationGroup : providerAnnotations) { annotationGroups.add(new EdmAnnotationsImpl(edm, this, annotationGroup)); @@ -241,9 +241,9 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List<EdmAnnotation> createAnnotations() { final List<EdmAnnotation> annotations = new ArrayList<EdmAnnotation>(); - if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + if (schema instanceof Schema) { final List<Annotation> providerAnnotations = - ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getAnnotations(); + ((Schema) schema).getAnnotations(); if (providerAnnotations != null) { for (Annotation annotation : providerAnnotations) { annotations.add(new EdmAnnotationImpl(edm, annotation)); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java index 403c28f..4735569 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.core.edm; -import org.apache.olingo.client.api.edm.xml.v4.Singleton; +import org.apache.olingo.client.api.edm.xml.Singleton; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmSingleton; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java index 5315bfb..9a5e0c8 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java @@ -72,10 +72,10 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper { if (navigationProperties == null) { navigationProperties = new LinkedHashMap<String, EdmNavigationProperty>(); for (CommonNavigationProperty navigationProperty : complexType.getNavigationProperties()) { - if (navigationProperty instanceof org.apache.olingo.client.api.edm.xml.v4.NavigationProperty) { + if (navigationProperty instanceof org.apache.olingo.client.api.edm.xml.NavigationProperty) { navigationProperties.put(navigationProperty.getName(), new EdmNavigationPropertyImpl( edm, structuredTypeName, - (org.apache.olingo.client.api.edm.xml.v4.NavigationProperty) navigationProperty)); + (org.apache.olingo.client.api.edm.xml.NavigationProperty) navigationProperty)); } } } @@ -84,8 +84,8 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper { @Override public boolean isOpenType() { - return complexType instanceof org.apache.olingo.client.api.edm.xml.v4.ComplexType - ? ((org.apache.olingo.client.api.edm.xml.v4.ComplexType) complexType).isOpenType() + return complexType instanceof org.apache.olingo.client.api.edm.xml.ComplexType + ? ((org.apache.olingo.client.api.edm.xml.ComplexType) complexType).isOpenType() : complexType instanceof EntityType ? ((EntityType) complexType).isOpenType() : false; @@ -93,8 +93,8 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper { @Override public boolean isAbstract() { - return complexType instanceof org.apache.olingo.client.api.edm.xml.v4.ComplexType - ? ((org.apache.olingo.client.api.edm.xml.v4.ComplexType) complexType).isAbstractEntityType() + return complexType instanceof org.apache.olingo.client.api.edm.xml.ComplexType + ? ((org.apache.olingo.client.api.edm.xml.ComplexType) complexType).isAbstractEntityType() : complexType instanceof EntityType ? ((EntityType) complexType).isAbstractEntityType() : false; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java index daa2647..4d85e51 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.ClassUtils; -import org.apache.olingo.client.api.edm.xml.v4.Term; +import org.apache.olingo.client.api.edm.xml.Term; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmException; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java index e314f58..62f514d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java @@ -20,7 +20,7 @@ package org.apache.olingo.client.core.edm; import java.util.List; -import org.apache.olingo.client.api.edm.xml.v4.TypeDefinition; +import org.apache.olingo.client.api.edm.xml.TypeDefinition; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmException; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmCastImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmCastImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmCastImpl.java new file mode 100644 index 0000000..68a9d66 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmCastImpl.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.Cast; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmType; +import org.apache.olingo.commons.api.edm.annotation.EdmCast; +import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.annotation.AbstractEdmAnnotatableDynamicAnnotationExpression; + +public class EdmCastImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmCast { + + private final Edm edm; + + private final Cast cast; + + private final EdmDynamicAnnotationExpression value; + + private EdmType type; + + public EdmCastImpl(final Edm edm, final Cast cast, final EdmDynamicAnnotationExpression value) { + this.edm = edm; + this.cast = cast; + this.value = value; + } + + @Override + public Integer getMaxLength() { + return cast.getMaxLength(); + } + + @Override + public Integer getPrecision() { + return cast.getPrecision(); + } + + @Override + public Integer getScale() { + return cast.getScale(); + } + + @Override + public SRID getSrid() { + return cast.getSrid(); + } + + @Override + public EdmType getType() { + if (type == null) { + final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(cast.getType()).build(); + type = typeInfo.getType(); + } + return type; + } + + @Override + public EdmDynamicAnnotationExpression getValue() { + return value; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java new file mode 100644 index 0000000..50d0fc9 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.annotation; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.apache.olingo.client.api.edm.xml.annotation.ConstantAnnotationExpression; +import org.apache.olingo.commons.api.Constants; +import org.apache.olingo.commons.api.domain.v4.ODataEnumValue; +import org.apache.olingo.commons.api.domain.v4.ODataValue; +import org.apache.olingo.commons.api.edm.EdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.annotation.EdmConstantAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; +import org.apache.olingo.commons.core.domain.v4.ODataCollectionValueImpl; +import org.apache.olingo.commons.core.domain.v4.ODataEnumValueImpl; +import org.apache.olingo.commons.core.domain.v4.ODataPrimitiveValueImpl; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; + +public class EdmConstantAnnotationExpressionImpl implements EdmConstantAnnotationExpression { + + private final ODataValue value; + + public EdmConstantAnnotationExpressionImpl(final ConstantAnnotationExpression constExprConstruct) { + if (constExprConstruct.getType() == ConstantAnnotationExpression.Type.EnumMember) { + final List<ODataEnumValue> enumValues = new ArrayList<ODataEnumValue>(); + String enumTypeName = null; + for (String split : StringUtils.split(constExprConstruct.getValue(), ' ')) { + final String[] enumSplit = StringUtils.split(split, '/'); + enumTypeName = enumSplit[0]; + enumValues.add(new ODataEnumValueImpl(enumSplit[0], enumSplit[1])); + } + if (enumValues.size() == 1) { + value = enumValues.get(0); + } else { + final ODataCollectionValueImpl collValue = new ODataCollectionValueImpl(enumTypeName); + for (ODataValue enumValue : enumValues) { + collValue.add(enumValue); + } + value = collValue; + } + } else { + EdmPrimitiveTypeKind kind; + switch (constExprConstruct.getType()) { + case Binary: + kind = EdmPrimitiveTypeKind.Binary; + break; + case Bool: + kind = EdmPrimitiveTypeKind.Boolean; + break; + case Date: + kind = EdmPrimitiveTypeKind.Date; + break; + case DateTimeOffset: + kind = EdmPrimitiveTypeKind.DateTimeOffset; + break; + case Decimal: + kind = EdmPrimitiveTypeKind.Decimal; + break; + case Duration: + kind = EdmPrimitiveTypeKind.Duration; + break; + case Float: + kind = EdmPrimitiveTypeKind.Single; + break; + case Guid: + kind = EdmPrimitiveTypeKind.Guid; + break; + case Int: + kind = EdmPrimitiveTypeKind.Int32; + break; + case TimeOfDay: + kind = EdmPrimitiveTypeKind.TimeOfDay; + break; + case String: + default: + kind = EdmPrimitiveTypeKind.String; + } + final ODataPrimitiveValueImpl.BuilderImpl primitiveValueBuilder = + new ODataPrimitiveValueImpl.BuilderImpl(ODataServiceVersion.V40); + primitiveValueBuilder.setType(kind); + try { + final EdmPrimitiveType primitiveType = EdmPrimitiveTypeFactory.getInstance(kind); + primitiveValueBuilder.setValue( + primitiveType.valueOfString(constExprConstruct.getValue(), + null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, + primitiveType.getDefaultType())); + } catch (final EdmPrimitiveTypeException e) { + throw new IllegalArgumentException(e); + } + + value = primitiveValueBuilder.build(); + } + } + + @Override + public boolean isConstant() { + return true; + } + + @Override + public EdmConstantAnnotationExpression asConstant() { + return this; + } + + @Override + public boolean isDynamic() { + return false; + } + + @Override + public EdmDynamicAnnotationExpression asDynamic() { + return null; + } + + @Override + public ODataValue getValue() { + return value; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmIsOfImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmIsOfImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmIsOfImpl.java new file mode 100644 index 0000000..8ff4757 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmIsOfImpl.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.IsOf; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmType; +import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmIsOf; +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.annotation.AbstractEdmAnnotatableDynamicAnnotationExpression; + +public class EdmIsOfImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmIsOf { + + private final Edm edm; + + private final IsOf isOf; + + private final EdmDynamicAnnotationExpression value; + + private EdmType type; + + public EdmIsOfImpl(final Edm edm, final IsOf isOf, final EdmDynamicAnnotationExpression value) { + this.edm = edm; + this.isOf = isOf; + this.value = value; + } + + @Override + public Integer getMaxLength() { + return isOf.getMaxLength(); + } + + @Override + public Integer getPrecision() { + return isOf.getPrecision(); + } + + @Override + public Integer getScale() { + return isOf.getScale(); + } + + @Override + public SRID getSrid() { + return isOf.getSrid(); + } + + @Override + public EdmType getType() { + if (type == null) { + final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(isOf.getType()).build(); + type = typeInfo.getType(); + } + return type; + } + + @Override + public EdmDynamicAnnotationExpression getValue() { + return value; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmRecordImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmRecordImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmRecordImpl.java new file mode 100644 index 0000000..c5ea7e0 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/annotation/EdmRecordImpl.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.annotation; + +import java.util.List; + +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmStructuredType; +import org.apache.olingo.commons.api.edm.annotation.EdmPropertyValue; +import org.apache.olingo.commons.api.edm.annotation.EdmRecord; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.annotation.AbstractEdmAnnotatableDynamicAnnotationExpression; + +public class EdmRecordImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmRecord { + + private final List<EdmPropertyValue> propertyValues; + + private EdmStructuredType type; + + public EdmRecordImpl(final Edm edm, final String type, final List<EdmPropertyValue> propertyValues) { + this.propertyValues = propertyValues; + + if (type != null) { + final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(type).build(); + this.type = typeInfo.getEntityType() == null ? typeInfo.getComplexType() : typeInfo.getEntityType(); + } + } + + @Override + public List<EdmPropertyValue> getPropertyValues() { + return propertyValues; + } + + @Override + public EdmStructuredType getType() { + return type; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmCastImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmCastImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmCastImpl.java deleted file mode 100644 index 0c05155..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmCastImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.v4.annotation; - -import org.apache.olingo.client.api.edm.xml.v4.annotation.Cast; -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.commons.api.edm.annotation.EdmCast; -import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression; -import org.apache.olingo.commons.api.edm.geo.SRID; -import org.apache.olingo.commons.core.edm.EdmTypeInfo; -import org.apache.olingo.commons.core.edm.annotation.AbstractEdmAnnotatableDynamicAnnotationExpression; - -public class EdmCastImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmCast { - - private final Edm edm; - - private final Cast cast; - - private final EdmDynamicAnnotationExpression value; - - private EdmType type; - - public EdmCastImpl(final Edm edm, final Cast cast, final EdmDynamicAnnotationExpression value) { - this.edm = edm; - this.cast = cast; - this.value = value; - } - - @Override - public Integer getMaxLength() { - return cast.getMaxLength(); - } - - @Override - public Integer getPrecision() { - return cast.getPrecision(); - } - - @Override - public Integer getScale() { - return cast.getScale(); - } - - @Override - public SRID getSrid() { - return cast.getSrid(); - } - - @Override - public EdmType getType() { - if (type == null) { - final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(cast.getType()).build(); - type = typeInfo.getType(); - } - return type; - } - - @Override - public EdmDynamicAnnotationExpression getValue() { - return value; - } - -}
