http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntity.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntity.java deleted file mode 100644 index 363b522..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntity.java +++ /dev/null @@ -1,202 +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.commons.api.domain; - -import org.apache.olingo.commons.api.edm.FullQualifiedName; - -import java.net.URI; -import java.util.List; - -/** - * OData entity. - */ -public interface ODataEntity extends ODataLinked, ODataAnnotatable, ODataInvokeResult { - - /** - * @return the type name of this entity. - */ - FullQualifiedName getTypeName(); - - /** - * @return self link. - */ - URI getLink(); - - /** - * Returns OData entity edit link. - * - * @return entity edit link. - */ - URI getEditLink(); - - /** - * Sets OData entity edit link. - * - * @param editLink edit link. - */ - void setEditLink(URI editLink); - - /** - * Gets ETag. - * - * @return ETag. - */ - String getETag(); - - /** - * Sets ETag. - * - * @param eTag ETag. - */ - void setETag(String eTag); - - /** - * Searches for operation with given title. - * - * @param title operation to look for - * @return operation if found with given title, <tt>null</tt> otherwise - */ - ODataOperation getOperation(String title); - - /** - * Gets operations. - * - * @return operations. - */ - List<ODataOperation> getOperations(); - - /** - * Searches for property with given name. - * - * @param name property to look for - * @return property if found with given name, <tt>null</tt> otherwise - */ - ODataProperty getProperty(String name); - - /** - * Returns OData entity properties. - * - * @return OData entity properties. - */ - List<ODataProperty> getProperties(); - - /** - * To request entity references in place of the actual entities, the client issues a GET request with /$ref appended - * to the resource path. - * <br /> - * If the resource path does not identify an entity or a collection of entities, the service returns 404 Not Found. - * <br /> - * If the resource path terminates on a collection, the response MUST be the format-specific representation of a - * collection of entity references pointing to the related entities. If no entities are related, the response is the - * format-specific representation of an empty collection. - * <br /> - * If the resource path terminates on a single entity, the response MUST be the format-specific representation of an - * entity reference pointing to the related single entity. If the resource path terminates on a single entity and no - * such entity exists, the service returns 404 Not Found. - * - * @return entity reference. - */ - URI getId(); - - /** - * Set id for this OData entity. - * - * @param id the if for this entity - */ - void setId(URI id); - - /** - * Gets media-edit link with given name, if available, otherwise <tt>null</tt>. - * - * @param name candidate link name - * @return media-edit link with given name, if available, otherwise <tt>null</tt> - */ - ODataLink getMediaEditLink(final String name); - - /** - * Returns entity media edit links. - * - * @return OData entity links. - */ - List<ODataLink> getMediaEditLinks(); - - /** - * TRUE if read-only entity. - * - * @return TRUE if read-only; FALSE otherwise. - */ - boolean isReadOnly(); - - /** - * Checks if the current entity is a media entity. - * - * @return 'TRUE' if media entity; 'FALSE' otherwise. - */ - boolean isMediaEntity(); - - /** - * Sets media entity flag. - * - * @param isMediaEntity media entity flag value. - */ - void setMediaEntity(boolean isMediaEntity); - - /** - * Gets media content type. - * - * @return media content type. - */ - String getMediaContentType(); - - /** - * Sets media content type. - * - * @param mediaContentType media content type. - */ - void setMediaContentType(String mediaContentType); - - /** - * Gets media content source. - * - * @return media content source. - */ - URI getMediaContentSource(); - - /** - * Sets media content source. - * - * @param mediaContentSource media content source. - */ - void setMediaContentSource(URI mediaContentSource); - - /** - * ETag of the binary stream represented by this media entity or named stream property. - * - * @return media ETag value - */ - String getMediaETag(); - - /** - * Set media ETag. - * - * @param eTag media ETag value - */ - void setMediaETag(String eTag); - -}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntitySet.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntitySet.java deleted file mode 100644 index 4175f8f..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntitySet.java +++ /dev/null @@ -1,71 +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.commons.api.domain; - -import java.net.URI; -import java.util.List; - -/** - * OData entity collection. If pagination was used to get this instance, forward page navigation URI will be available. - */ -public interface ODataEntitySet extends ODataInvokeResult, ODataAnnotatable { - - /** - * Gets next page link. - * - * @return next page link; null value if single page or last page reached. - */ - URI getNext(); - - /** - * Gets contained entities. - * - * @return entity set's entities. - */ - List<ODataEntity> getEntities(); - - /** - * Gets in-line count. - * - * @return in-line count value. - */ - Integer getCount(); - - /** - * Sets in-line count. - * - * @param count in-line count value. - */ - void setCount(final int count); - - - /** - * Gets delta link if exists. - * - * @return delta link if exists; null otherwise. - */ - URI getDeltaLink(); - - /** - * Sets delta link. - * - * @param deltaLink delta link. - */ - void setDeltaLink(URI deltaLink); -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEnumValue.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEnumValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEnumValue.java deleted file mode 100644 index ef5852d..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEnumValue.java +++ /dev/null @@ -1,27 +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.commons.api.domain; - -public interface ODataEnumValue extends ODataValue { - - String getValue(); - - @Override - String toString(); -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java deleted file mode 100644 index a910f08..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java +++ /dev/null @@ -1,132 +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.commons.api.domain; - -import java.util.List; -import java.util.Map; - -/** - * OData error. - */ -public class ODataError { - - private String code; - private String message; - private String target; - private List<ODataErrorDetail> details; - private Map<String, String> innerError; - - /** - * The value for the code name/value pair is a language-independent string. Its value is a service-defined error code. - * This code serves as a sub-status for the HTTP error code specified in the response. MAY be null. - * @return the error code as a string - */ - public String getCode() { - return code; - } - - /** - * The value for the code name/value pair is a language-independent string. Its value is a service-defined error code. - * This code serves as a sub-status for the HTTP error code specified in the response. MAY be null. - * @param code - * @return this for method chaining - */ - public ODataError setCode(String code) { - this.code = code; - return this; - } - - /** - * The value for the message name/value pair MUST be a human-readable, language-dependent representation of the error. - * MUST not be null - * @return the message string - */ - public String getMessage() { - return message; - } - - /** - * The value for the message name/value pair MUST be a human-readable, language-dependent representation of the error. - * MUST not be null - * @param message - * @return this for method chaining - */ - public ODataError setMessage(String message) { - this.message = message; - return this; - } - - /** - * The value for the target name/value pair is the target of the particular error (for example, the name of the - * property in error). MAY be null. - * @return the target string - */ - public String getTarget() { - return target; - } - - /** - * The value for the target name/value pair is the target of the particular error (for example, the name of the - * property in error). MAY be null. - * @param target - * @return this for method chaining - */ - public ODataError setTarget(String target) { - this.target = target; - return this; - } - - /** - * Gets error details. - * - * @return ODataErrorDetail list. - */ - public List<ODataErrorDetail> getDetails() { - return details; - } - - /** - * Sets error details. - * - * @return this for method chaining. - */ - public ODataError setDetails(List<ODataErrorDetail> details) { - this.details = details; - return this; - } - - /** - * Gets server defined key-value pairs for debug environment only. - * - * @return a pair representing server defined object. MAY be null. - */ - public Map<String, String> getInnerError() { - return innerError; - } - - /** - * Sets server defined key-value pairs for debug environment only. - * - * @return this for method chaining. - */ - public ODataError setInnerError(Map<String, String> innerError) { - this.innerError = innerError; - return this; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java deleted file mode 100644 index 573525d..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java +++ /dev/null @@ -1,73 +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.commons.api.domain; - -/** - * OData detailsï¼ for example <tt>{ "error": {..., "details":[ - * {"code": "301","target": "$search" ,"message": "$search query option not supported"} - * ],...}}</tt>. - */ -public class ODataErrorDetail { - - private String code; - private String message; - private String target; - - /** - * Gets error code. - * - * @return error code. - */ - public String getCode() { - return code; - } - - public ODataErrorDetail setCode(final String code) { - this.code = code; - return this; - } - - /** - * Gets error message. - * - * @return error message. - */ - public String getMessage() { - return message; - } - - public ODataErrorDetail setMessage(final String message) { - this.message = message; - return this; - } - - /** - * Gets error target. - * - * @return error message. - */ - public String getTarget() { - return target; - } - - public ODataErrorDetail setTarget(final String target) { - this.target = target; - return this; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java deleted file mode 100644 index 6ba0ad6..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java +++ /dev/null @@ -1,68 +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.commons.api.domain; - -import java.net.URI; - -/** - * OData in-line entity. - */ -public class ODataInlineEntity extends ODataLink { - - private final ODataEntity entity; - - /** - * Constructor. - * - * @param uri edit link. - * @param type type. - * @param title title. - * @param entity entity. - */ - public ODataInlineEntity(final URI uri, final ODataLinkType type, final String title, final ODataEntity entity) { - - super(uri, type, title); - this.entity = entity; - } - - /** - * Constructor. - * - * @param baseURI base URI. - * @param href href. - * @param type type. - * @param title title. - * @param entity entity. - */ - public ODataInlineEntity(final URI baseURI, final String href, final ODataLinkType type, final String title, - final ODataEntity entity) { - - super(baseURI, href, type, title); - this.entity = entity; - } - - /** - * Gets wrapped entity. - * - * @return wrapped entity. - */ - public ODataEntity getEntity() { - return entity; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java deleted file mode 100644 index c1cf322..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java +++ /dev/null @@ -1,69 +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.commons.api.domain; - -import java.net.URI; - -/** - * OData in-line entity set. - */ -public class ODataInlineEntitySet extends ODataLink { - - private ODataEntitySet entitySet; - - /** - * Constructor. - * - * @param uri edit link. - * @param type type. - * @param title title. - * @param entitySet entity set. - */ - public ODataInlineEntitySet(final URI uri, final ODataLinkType type, - final String title, final ODataEntitySet entitySet) { - - super(uri, type, title); - this.entitySet = entitySet; - } - - /** - * Constructor. - * - * @param baseURI base URI. - * @param href href. - * @param type type. - * @param title title. - * @param entitySet entity set. - */ - public ODataInlineEntitySet(final URI baseURI, final String href, - final ODataLinkType type, final String title, final ODataEntitySet entitySet) { - - super(baseURI, href, type, title); - this.entitySet = entitySet; - } - - /** - * Gets wrapped entity set. - * - * @return wrapped entity set. - */ - public ODataEntitySet getEntitySet() { - return entitySet; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInvokeResult.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInvokeResult.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInvokeResult.java deleted file mode 100644 index bfd0909..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInvokeResult.java +++ /dev/null @@ -1,30 +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.commons.api.domain; - -/** - * Marker interface for any OData domain object that can be returned by an operation invocation. - * - * @see ODataEntitySet - * @see ODataEntity - * @see ODataProperty - */ -public interface ODataInvokeResult { -//No additional methods needed for now. -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataItem.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataItem.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataItem.java deleted file mode 100644 index 589b249..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataItem.java +++ /dev/null @@ -1,96 +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.commons.api.domain; - -import java.net.URI; - -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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Abstract representation of OData entities and links. - */ -public abstract class ODataItem { - - /** - * Logger. - */ - protected static final Logger LOG = LoggerFactory.getLogger(ODataItem.class); - - /** - * OData entity name/type. - */ - private final String name; - - /** - * OData item self link. - */ - protected URI link; - - /** - * Constructor. - * - * @param name ODataItem name (it's entity type for {@link ODataEntity}). - */ - public ODataItem(final String name) { - this.name = name; - } - - /** - * @return ODataItem name (it's entity type for {@link ODataEntity}). - */ - public String getName() { - return name; - } - - /** - * @return ODataItem link (it's edit link for {@link ODataEntity}). - */ - public URI getLink() { - return link; - } - - /** - * Sets ODataItem link (it's edit link for {@link ODataEntity}). - * - * @param link link. - */ - public void setLink(final URI link) { - this.link = link; - } - - @Override - public boolean equals(final Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - - @Override - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); - } - - @Override - public String toString() { - return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java deleted file mode 100644 index 8593679..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java +++ /dev/null @@ -1,187 +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.commons.api.domain; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import org.apache.olingo.commons.api.Constants; - -/** - * OData link. - */ -public class ODataLink extends ODataItem implements ODataAnnotatable { - - public static class Builder { - - protected URI uri; - - protected ODataLinkType type; - - protected String title; - - public Builder setURI(final URI uri) { - this.uri = uri; - return this; - } - - public Builder setURI(final URI baseURI, final String href) { - uri = getURI(baseURI, href); - return this; - } - - public Builder setType(final ODataLinkType type) { - this.type = type; - return this; - } - - public Builder setTitle(final String title) { - this.title = title; - return this; - } - - public ODataLink build() { - return new ODataLink(uri, type, title); - } - } - - /** - * Build URI starting from the given base and href. - * <br/> - * If href is absolute or base is null then base will be ignored. - * - * @param base URI prefix. - * @param href URI suffix. - * @return built URI. - */ - private static URI getURI(final URI base, final String href) { - if (href == null) { - throw new IllegalArgumentException("Null link provided"); - } - - URI uri = URI.create(href); - - if (!uri.isAbsolute() && base != null) { - uri = URI.create(base.toASCIIString() + "/" + href); - } - - return uri.normalize(); - } - - /** - * Link type. - */ - protected final ODataLinkType type; - - /** - * Link rel. - */ - protected final String rel; - - /** - * ETag for media edit links. - */ - protected String mediaETag; - - private final List<ODataAnnotation> annotations = new ArrayList<ODataAnnotation>(); - - /** - * Constructor. - * - * @param uri URI. - * @param type type. - * @param title title. - */ - public ODataLink(final URI uri, final ODataLinkType type, final String title) { - super(title); - - link = uri; - this.type = type; - - switch (this.type) { - case ASSOCIATION: - rel = Constants.NS_ASSOCIATION_LINK_REL + title; - break; - - case ENTITY_NAVIGATION: - case ENTITY_SET_NAVIGATION: - rel = Constants.NS_NAVIGATION_LINK_REL + title; - break; - - case MEDIA_EDIT: - default: - rel = Constants.NS_MEDIA_EDIT_LINK_REL + title; - break; - } - } - - /** - * Constructor. - * - * @param version OData service version. - * @param baseURI base URI. - * @param href href. - * @param type type. - * @param title title. - */ - protected ODataLink(final URI baseURI, final String href, final ODataLinkType type, final String title) { - - this(getURI(baseURI, href), type, title); - } - - /** - * Gets link type. - * - * @return link type; - */ - public ODataLinkType getType() { - return type; - } - - public ODataInlineEntity asInlineEntity() { - return (this instanceof ODataInlineEntity) ? (ODataInlineEntity) this : null; - } - - public ODataInlineEntitySet asInlineEntitySet() { - return (this instanceof ODataInlineEntitySet) ? (ODataInlineEntitySet) this : null; - } - - /** - * Gets link rel. - * - * @return link rel - */ - public String getRel() { - return rel; - } - - /** - * Gets Media ETag. - * - * @return media ETag - */ - public String getMediaETag() { - return mediaETag; - } - - public List<ODataAnnotation> getAnnotations() { - return annotations; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java deleted file mode 100644 index 5ae427c..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java +++ /dev/null @@ -1,105 +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.commons.api.domain; - -import org.apache.commons.lang3.StringUtils; -import org.apache.olingo.commons.api.Constants; -import org.apache.olingo.commons.api.format.ContentType; - -/** - * OData link types. - */ -public enum ODataLinkType { - - /** - * Entity navigation link. - */ - ENTITY_NAVIGATION(ContentType.APPLICATION_ATOM_XML_ENTRY), - /** - * Entity set navigation link. - */ - ENTITY_SET_NAVIGATION(ContentType.APPLICATION_ATOM_XML_FEED), - /** - * Association link. - */ - ASSOCIATION(ContentType.APPLICATION_XML), - /** - * Media-edit link. - */ - MEDIA_EDIT("*/*"), - - /** - * Entity binding link. - */ - ENTITY_BINDING(ContentType.APPLICATION_XML), - - /** - * Entity collection binding link. - */ - ENTITY_COLLECTION_BINDING(ContentType.APPLICATION_XML); - - private String type; - - private ODataLinkType(final String type) { - this.type = type; - } - - private ODataLinkType(final ContentType contentType) { - this(contentType.toContentTypeString()); - } - - private ODataLinkType setType(final String type) { - this.type = type; - return this; - } - - /** - * Gets - * <code>LinkType</code> instance from the given rel and type. - * - * @param rel rel. - * @param type type. - * @return <code>ODataLinkType</code> object. - */ - public static ODataLinkType fromString(final String rel, final String type) { - if (StringUtils.isNotBlank(rel) && rel.startsWith(Constants.NS_MEDIA_EDIT_LINK_REL)) { - - return MEDIA_EDIT.setType(StringUtils.isBlank(type) ? "*/*" : type); - } - - if (ODataLinkType.ENTITY_NAVIGATION.type.equals(type)) { - return ENTITY_NAVIGATION; - } - - if (ODataLinkType.ENTITY_SET_NAVIGATION.type.equals(type)) { - return ENTITY_SET_NAVIGATION; - } - - if (ODataLinkType.ASSOCIATION.type.equals(type)) { - return ASSOCIATION; - } - - throw new IllegalArgumentException("Invalid link type: " + type); - } - - @Override - public String toString() { - return type; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java deleted file mode 100644 index fd9d965..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinked.java +++ /dev/null @@ -1,70 +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.commons.api.domain; - -import java.util.List; - -public interface ODataLinked { - - /** - * Puts the given link into one of available lists, based on its type. - * - * @param link to be added - * @return <tt>true</tt> if the given link was added in one of available lists - */ - boolean addLink(ODataLink link); - - /** - * Removes the given link from any list (association, navigation, edit-media). - * - * @param link to be removed - * @return <tt>true</tt> if the given link was contained in one of available lists - */ - boolean removeLink(ODataLink link); - - /** - * Gets association link with given name, if available, otherwise <tt>null</tt>. - * - * @param name candidate link name - * @return association link with given name, if available, otherwise <tt>null</tt> - */ - ODataLink getAssociationLink(String name); - - /** - * Returns all entity association links. - * - * @return OData entity links. - */ - List<ODataLink> getAssociationLinks(); - - /** - * Gets navigation link with given name, if available, otherwise <tt>null</tt>. - * - * @param name candidate link name - * @return navigation link with given name, if available, otherwise <tt>null</tt> - */ - ODataLink getNavigationLink(String name); - - /** - * Returns all entity navigation links (including inline entities / entity sets). - * - * @return OData entity links. - */ - List<ODataLink> getNavigationLinks(); -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java deleted file mode 100644 index 3dee5e3..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java +++ /dev/null @@ -1,168 +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.commons.api.domain; - -import org.apache.olingo.commons.api.edm.FullQualifiedName; - -import java.net.URI; - -/** - * Entry point for generating OData domain objects. - */ -public interface ODataObjectFactory { - - /** - * Instantiates a new entity set. - * - * @return entity set. - */ - ODataEntitySet newEntitySet(); - - /** - * Instantiates a new entity set. - * - * @param next next link. - * @return entity set. - */ - ODataEntitySet newEntitySet(URI next); - - /** - * Instantiates a new entity. - * - * @param typeName OData entity type name. - * @return entity. - */ - ODataEntity newEntity(FullQualifiedName typeName); - - /** - * Instantiates a new entity. - * - * @param typeName OData entity type name. - * @param link self link. - * @return entity. - */ - ODataEntity newEntity(FullQualifiedName typeName, URI link); - - /** - * Instantiates a new entity set (for deep insert). - * - * @param name name. - * @param entitySet entity set. - * @return in-line entity set. - */ - ODataInlineEntitySet newDeepInsertEntitySet(String name, ODataEntitySet entitySet); - - /** - * Instantiates a new entity (for deep insert). - * - * @param name name. - * @param entity entity. - * @return in-line entity. - */ - ODataInlineEntity newDeepInsertEntity(String name, ODataEntity entity); - - /** - * Instantiates a new entity set navigation link. - * - * @param name name. - * @param link link. - * @return entity set navigation link. - */ - ODataLink newEntitySetNavigationLink(String name, URI link); - - /** - * Instantiates a new singleton entity. - * - * @param typeName OData singleton entity type name. - * @return new singleton entity. - */ - ODataSingleton newSingleton(FullQualifiedName typeName); - - /** - * Instantiates a new entity navigation link. - * - * @param name name. - * @param link link. - * @return entity navigation link. - */ - ODataLink newEntityNavigationLink(String name, URI link); - - ODataLink newAssociationLink(String name, URI link); - - ODataLink newMediaEditLink(String name, URI link); - - ODataPrimitiveValue.Builder newPrimitiveValueBuilder(); - - ODataEnumValue newEnumValue(String typeName, String value); - - ODataComplexValue newComplexValue(String typeName); - - ODataCollectionValue<ODataValue> newCollectionValue(String typeName); - - /** - * Instantiates a new primitive property. - * - * @param name name. - * @param value primitive value. - * @return primitive property. - */ - ODataProperty newPrimitiveProperty(String name, ODataPrimitiveValue value); - - /** - * Instantiates a new complex property. - * - * @param name name. - * @param value value. - * @return complex property. - */ - ODataProperty newComplexProperty(String name, ODataComplexValue value); - - /** - * Instantiates a new collection property. - * - * @param name name. - * @param value value. - * @return collection property. - */ - ODataProperty newCollectionProperty(String name, ODataCollectionValue<? extends ODataValue> value); - - /** - * Instantiates a new enum property. - * - * @param name name. - * @param value value. - * @return new enum property. - */ - ODataProperty newEnumProperty(String name, ODataEnumValue value); - - /** - * Instantiates a new delta property. - * - * @return new delta property. - */ - ODataDelta newDelta(); - - /** - * Instantiates a new delta property. - * - * @param next next link for delta property - * @return new delta property. - */ - ODataDelta newDelta(URI next); -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataOperation.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataOperation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataOperation.java deleted file mode 100644 index 421a405..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataOperation.java +++ /dev/null @@ -1,85 +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.commons.api.domain; - -import java.net.URI; - -public class ODataOperation { - - private String metadataAnchor; - - private String title; - - private URI target; - - /** - * Gets metadata anchor. - * - * @return metadata anchor. - */ - public String getMetadataAnchor() { - return metadataAnchor; - } - - /** - * Sets metadata anchor. - * - * @param metadataAnchor metadata anchor. - */ - public void setMetadataAnchor(final String metadataAnchor) { - this.metadataAnchor = metadataAnchor; - } - - /** - * Gets title. - * - * @return title. - */ - public String getTitle() { - return title; - } - - /** - * Sets title. - * - * @param title title. - */ - public void setTitle(final String title) { - this.title = title; - } - - /** - * Gets target. - * - * @return target. - */ - public URI getTarget() { - return target; - } - - /** - * Sets target. - * - * @param target target. - */ - public void setTarget(final URI target) { - this.target = target; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java deleted file mode 100644 index 46c4416..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java +++ /dev/null @@ -1,88 +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.commons.api.domain; - -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.EdmType; - -import java.util.UUID; - -public interface ODataPrimitiveValue extends ODataValue { - - interface Builder { - - Builder setType(EdmType type); - - Builder setType(EdmPrimitiveTypeKind type); - - Builder setValue(Object value); - - ODataPrimitiveValue build(); - - ODataPrimitiveValue buildBoolean(Boolean value); - - ODataPrimitiveValue buildInt16(Short value); - - ODataPrimitiveValue buildInt32(Integer value); - - ODataPrimitiveValue buildInt64(Long value); - - ODataPrimitiveValue buildSingle(Float value); - - ODataPrimitiveValue buildDouble(Double value); - - ODataPrimitiveValue buildString(String value); - - ODataPrimitiveValue buildGuid(UUID value); - - ODataPrimitiveValue buildBinary(byte[] value); - } - - EdmPrimitiveTypeKind getTypeKind(); - - EdmPrimitiveType getType(); - - /** - * Returns the current value as generic Object. - * - * @return an uncasted instance of this value - */ - Object toValue(); - - /** - * Returns the current value casted to the given type. - * - * @param <T> cast type - * @param reference class reference - * @return the current value as typed java instance - * @throws EdmPrimitiveTypeException if the object is not assignable to the type T. - */ - <T> T toCastValue(Class<T> reference) throws EdmPrimitiveTypeException; - - /** - * Serialize the current value as String. - * - * @return a String representation of this value - */ - @Override - String toString(); - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java deleted file mode 100644 index 9007626..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java +++ /dev/null @@ -1,32 +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.commons.api.domain; - -/** - * OData entity property. - */ -public interface ODataProperty extends ODataInvokeResult, ODataAnnotatable, ODataValuable { - - /** - * Returns property name. - * - * @return property name. - */ - String getName(); -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java deleted file mode 100644 index e7b5b85..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java +++ /dev/null @@ -1,44 +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.commons.api.domain; - -public enum ODataPropertyType { - - /** - * Primitive (including geospatial). - */ - PRIMITIVE, - /** - * Enum. - */ - ENUM, - /** - * Collection. - */ - COLLECTION, - /** - * Complex. - */ - COMPLEX, - /** - * Empty type (possibly, no type information could be retrieved). - */ - EMPTY - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataServiceDocument.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataServiceDocument.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataServiceDocument.java deleted file mode 100644 index 8bbff32..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataServiceDocument.java +++ /dev/null @@ -1,163 +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.commons.api.domain; - -import java.net.URI; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -public class ODataServiceDocument { - - private final Map<String, URI> entitySets = new HashMap<String, URI>(); - - private final Map<String, URI> functionImports = new HashMap<String, URI>(); - - private final Map<String, URI> singletons = new HashMap<String, URI>(); - - private final Map<String, URI> relatedServiceDocuments = new HashMap<String, URI>(); - - public Map<String, URI> getEntitySets() { - return entitySets; - } - - /** - * Gets entity set names. - * - * @return entity set names. - */ - public Collection<String> getEntitySetNames() { - return entitySets.keySet(); - } - - /** - * Gets entity set URIs. - * - * @return entity set URIs. - */ - public Collection<URI> getEntitySetURIs() { - return entitySets.values(); - } - - /** - * Gets URI about the given entity set. - * - * @param name name. - * @return URI. - */ - public URI getEntitySetURI(final String name) { - return entitySets.get(name); - } - - public Map<String, URI> getFunctionImports() { - return functionImports; - } - - /** - * Gets function import names. - * - * @return function import names. - */ - public Collection<String> getFunctionImportNames() { - return functionImports.keySet(); - } - - /** - * Gets function import URIs. - * - * @return function import URIs. - */ - public Collection<URI> getFunctionImportURIs() { - return functionImports.values(); - } - - /** - * Gets URI of the given function import. - * - * @param name name. - * @return URI. - */ - public URI getFunctionImportURI(final String name) { - return functionImports.get(name); - } - - public Map<String, URI> getSingletons() { - return singletons; - } - - /** - * Gets singleton names. - * - * @return singleton names. - */ - public Collection<String> getSingletonNames() { - return singletons.keySet(); - } - - /** - * Gets singleton URIs. - * - * @return singleton URIs. - */ - public Collection<URI> getSingletonURIs() { - return singletons.values(); - } - - /** - * Gets URI of the given singleton. - * - * @param name name. - * @return URI. - */ - public URI getSingletonURI(final String name) { - return singletons.get(name); - } - - public Map<String, URI> getRelatedServiceDocuments() { - return relatedServiceDocuments; - } - - /** - * Gets related service documents names. - * - * @return related service documents names. - */ - public Collection<String> getRelatedServiceDocumentsNames() { - return relatedServiceDocuments.keySet(); - } - - /** - * Gets related service documents URIs. - * - * @return related service documents URIs. - */ - public Collection<URI> getRelatedServiceDocumentsURIs() { - return relatedServiceDocuments.values(); - } - - /** - * Gets URI of the given related service documents. - * - * @param name name. - * @return URI. - */ - public URI getRelatedServiceDocumentURI(final String name) { - return relatedServiceDocuments.get(name); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataSingleton.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataSingleton.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataSingleton.java deleted file mode 100644 index d328f41..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataSingleton.java +++ /dev/null @@ -1,23 +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.commons.api.domain; - -public interface ODataSingleton extends ODataEntity { -//No additional methods needed for now. -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValuable.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValuable.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValuable.java deleted file mode 100644 index 7e0c60c..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValuable.java +++ /dev/null @@ -1,94 +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.commons.api.domain; - - -public interface ODataValuable { - - /** - * Returns annotation value. - * - * @return annotation value. - */ - ODataValue getValue(); - - /** - * Checks if has null value. - * - * @return 'TRUE' if has null value; 'FALSE' otherwise. - */ - boolean hasNullValue(); - - /** - * Checks if has primitive value. - * - * @return 'TRUE' if has primitive value; 'FALSE' otherwise. - */ - boolean hasPrimitiveValue(); - - /** - * Gets primitive value. - * - * @return primitive value if exists; null otherwise. - */ - ODataPrimitiveValue getPrimitiveValue(); - - /** - * Checks if has collection value. - * - * @return 'TRUE' if has collection value; 'FALSE' otherwise. - */ - boolean hasCollectionValue(); - - /** - * Gets collection value. - * - * @return collection value if exists; null otherwise. - */ - ODataCollectionValue<ODataValue> getCollectionValue(); - - /** - * Checks if has complex value. - * - * @return 'TRUE' if has complex value; 'FALSE' otherwise. - */ - boolean hasComplexValue(); - - /** - * Gets complex value. - * - * @return complex value if exists; null otherwise. - */ - ODataComplexValue getComplexValue(); - - /** - * Checks if has enum value. - * - * @return 'TRUE' if has enum value; 'FALSE' otherwise. - */ - boolean hasEnumValue(); - - /** - * Gets enum value. - * - * @return enum value if exists; null otherwise. - */ - ODataEnumValue getEnumValue(); - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java deleted file mode 100644 index 57069e8..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java +++ /dev/null @@ -1,91 +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.commons.api.domain; - - -/** - * Abstract representation of an OData entity property value. - */ -public interface ODataValue { - - /** - * Gets value type name. - * - * @return value type name. - */ - String getTypeName(); - - /** - * Check is is a primitive value. - * - * @return 'TRUE' if primitive; 'FALSE' otherwise. - */ - boolean isPrimitive(); - - /** - * Casts to primitive value. - * - * @return primitive value. - */ - ODataPrimitiveValue asPrimitive(); - - /** - * Check is is a collection value. - * - * @return 'TRUE' if collection; 'FALSE' otherwise. - */ - boolean isCollection(); - - /** - * Casts to collection value. - * - * @param <OV> The actual ODataValue interface. - * @return collection value. - */ - <OV extends ODataValue> ODataCollectionValue<OV> asCollection(); - - /** - * Casts to complex value. - * - * @return complex value. - */ - ODataComplexValue asComplex(); - - /** - * Check is is a linked complex value. - * - * @return 'TRUE' if linked complex; 'FALSE' otherwise. - */ - boolean isComplex(); - - /** - * Check is is an enum value. - * - * @return 'TRUE' if enum; 'FALSE' otherwise. - */ - boolean isEnum(); - - /** - * Casts to enum value. - * - * @return enum value. - */ - ODataEnumValue asEnum(); - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java index 21c1854..cc47fe6 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java @@ -18,10 +18,10 @@ */ package org.apache.olingo.commons.api.edm.annotation; -import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.domain.ClientValue; public interface EdmConstantAnnotationExpression extends EdmAnnotationExpression { - ODataValue getValue(); + ClientValue getValue(); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java index 8e313b1..38ad911 100755 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java @@ -22,7 +22,7 @@ import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.data.Property; import org.apache.olingo.commons.api.data.ResWrap; -import org.apache.olingo.commons.api.domain.ODataError; +import org.apache.olingo.commons.api.domain.ClientError; import java.io.InputStream; @@ -61,5 +61,5 @@ public interface ODataDeserializer { * @param input stream to be parsed and de-serialized. * @return parsed ODataError object represented by the given InputStream */ - ODataError toError(InputStream input) throws ODataDeserializerException; + ClientError toError(InputStream input) throws ODataDeserializerException; } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractClientEntitySet.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractClientEntitySet.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractClientEntitySet.java new file mode 100644 index 0000000..d11b799 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractClientEntitySet.java @@ -0,0 +1,71 @@ +/* + * 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.commons.core.domain; + +import org.apache.olingo.commons.api.domain.AbstractClientPayload; +import org.apache.olingo.commons.api.domain.ClientEntitySet; + +import java.net.URI; + +public abstract class AbstractClientEntitySet extends AbstractClientPayload implements ClientEntitySet { + + /** + * Link to the next page. + */ + private URI next; + + /** + * Number of ODataEntities contained in this entity set. + * <br/> + * If <tt>$inlinecount</tt> was requested, this value comes from there. + */ + private Integer count; + + /** + * Constructor. + */ + public AbstractClientEntitySet() { + super(null); + } + + /** + * Constructor. + * + * @param next next link. + */ + public AbstractClientEntitySet(final URI next) { + super(null); + this.next = next; + } + + @Override + public URI getNext() { + return next; + } + + @Override + public Integer getCount() { + return count; + } + + @Override + public void setCount(final int count) { + this.count = count; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java deleted file mode 100644 index f8535b0..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java +++ /dev/null @@ -1,71 +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.commons.core.domain; - -import org.apache.olingo.commons.api.domain.AbstractODataPayload; -import org.apache.olingo.commons.api.domain.ODataEntitySet; - -import java.net.URI; - -public abstract class AbstractODataEntitySet extends AbstractODataPayload implements ODataEntitySet { - - /** - * Link to the next page. - */ - private URI next; - - /** - * Number of ODataEntities contained in this entity set. - * <br/> - * If <tt>$inlinecount</tt> was requested, this value comes from there. - */ - private Integer count; - - /** - * Constructor. - */ - public AbstractODataEntitySet() { - super(null); - } - - /** - * Constructor. - * - * @param next next link. - */ - public AbstractODataEntitySet(final URI next) { - super(null); - this.next = next; - } - - @Override - public URI getNext() { - return next; - } - - @Override - public Integer getCount() { - return count; - } - - @Override - public void setCount(final int count) { - this.count = count; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientAnnotationImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientAnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientAnnotationImpl.java new file mode 100644 index 0000000..b5fae89 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientAnnotationImpl.java @@ -0,0 +1,102 @@ +/* + * 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.commons.core.domain; + +import org.apache.olingo.commons.api.domain.ClientAnnotation; +import org.apache.olingo.commons.api.domain.ClientCollectionValue; +import org.apache.olingo.commons.api.domain.ClientComplexValue; +import org.apache.olingo.commons.api.domain.ClientEnumValue; +import org.apache.olingo.commons.api.domain.ClientPrimitiveValue; +import org.apache.olingo.commons.api.domain.ClientValuable; +import org.apache.olingo.commons.api.domain.ClientValue; + +public class ClientAnnotationImpl implements ClientAnnotation { + + private final String term; + + private final ClientValuable valuable; + + public ClientAnnotationImpl(final String term, final ClientValue value) { + this.term = term; + valuable = new ClientValuableImpl(value); + } + + @Override + public String getTerm() { + return term; + } + + @Override + public ClientValue getValue() { + return valuable.getValue(); + } + + @Override + public boolean hasNullValue() { + return valuable.hasNullValue(); + } + + @Override + public boolean hasPrimitiveValue() { + return valuable.hasPrimitiveValue(); + } + + @Override + public ClientPrimitiveValue getPrimitiveValue() { + return valuable.getPrimitiveValue(); + } + + @Override + public boolean hasCollectionValue() { + return valuable.hasCollectionValue(); + } + + @Override + public ClientCollectionValue<ClientValue> getCollectionValue() { + return valuable.getCollectionValue(); + } + + @Override + public boolean hasComplexValue() { + return valuable.hasComplexValue(); + } + + @Override + public ClientComplexValue getComplexValue() { + return valuable.getComplexValue(); + } + + @Override + public boolean hasEnumValue() { + return valuable.hasEnumValue(); + } + + @Override + public ClientEnumValue getEnumValue() { + return valuable.getEnumValue(); + } + + @Override + public String toString() { + return "ODataPropertyImpl{" + + "term=" + term + + ",valuable=" + valuable + + '}'; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientCollectionValueImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientCollectionValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientCollectionValueImpl.java new file mode 100644 index 0000000..e7b53ff --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientCollectionValueImpl.java @@ -0,0 +1,124 @@ +/* + * 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.commons.core.domain; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.apache.olingo.commons.api.domain.AbstractClientValue; +import org.apache.olingo.commons.api.domain.ClientCollectionValue; +import org.apache.olingo.commons.api.domain.ClientEnumValue; +import org.apache.olingo.commons.api.domain.ClientValue; + +public class ClientCollectionValueImpl<OV extends ClientValue> extends AbstractClientValue + implements ClientCollectionValue<OV>, ClientValue { + + /** + * Constructor. + * + * @param typeName type name. + */ + public ClientCollectionValueImpl(final String typeName) { + super(typeName == null || typeName.startsWith("Collection(") ? typeName : "Collection(" + typeName + ")"); + } + + @Override + public boolean isEnum() { + return false; + } + + @Override + public ClientEnumValue asEnum() { + return null; + } + + @Override + public boolean isComplex() { + return false; + } + + @Override + public Collection<Object> asJavaCollection() { + final List<Object> result = new ArrayList<Object>(); + for (ClientValue value : values) { + if (value.isPrimitive()) { + result.add(value.asPrimitive().toValue()); + } else if (value.isComplex()) { + result.add(value.asComplex().asJavaMap()); + } else if (value.isCollection()) { + result.add(value.asCollection().asJavaCollection()); + } else if (value.isEnum()) { + result.add(value.asEnum().toString()); + } + } + + return result; + } + + /** + * Values. + */ + protected final List<OV> values = new ArrayList<OV>(); + + /** + * Adds a value to the collection. + * + * @param value value to be added. + */ + @Override + @SuppressWarnings("unchecked") + public ClientCollectionValue<OV> add(final ClientValue value) { + values.add((OV) value); + return this; + } + + /** + * Value iterator. + * + * @return value iterator. + */ + @Override + public Iterator<OV> iterator() { + return values.iterator(); + } + + /** + * Gets collection size. + * + * @return collection size. + */ + @Override + public int size() { + return values.size(); + } + + /** + * Checks if collection is empty. + * + * @return 'TRUE' if empty; 'FALSE' otherwise. + */ + @Override + public boolean isEmpty() { + return values.isEmpty(); + } + + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientComplexValueImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientComplexValueImpl.java new file mode 100644 index 0000000..3881c3a --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientComplexValueImpl.java @@ -0,0 +1,204 @@ +/* + * 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.commons.core.domain; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.olingo.commons.api.domain.AbstractClientValue; +import org.apache.olingo.commons.api.domain.ClientAnnotation; +import org.apache.olingo.commons.api.domain.ClientComplexValue; +import org.apache.olingo.commons.api.domain.ClientEnumValue; +import org.apache.olingo.commons.api.domain.ClientLink; +import org.apache.olingo.commons.api.domain.ClientProperty; + +public class ClientComplexValueImpl extends AbstractClientValue implements ClientComplexValue { + + /** + * Navigation links (might contain in-line entities or entity sets). + */ + private final List<ClientLink> navigationLinks = new ArrayList<ClientLink>(); + + /** + * Association links. + */ + private final List<ClientLink> associationLinks = new ArrayList<ClientLink>(); + + private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>(); + + /** + * Complex type fields. + */ + private final Map<String, ClientProperty> fields = new LinkedHashMap<String, ClientProperty>(); + + /** + * Constructor. + * + * @param typeName type name. + */ + public ClientComplexValueImpl(final String typeName) { + super(typeName); + } + + @Override + public boolean isEnum() { + return false; + } + + @Override + public ClientEnumValue asEnum() { + return null; + } + + @Override + public boolean isComplex() { + return true; + } + + @Override + public boolean addLink(final ClientLink link) { + boolean result = false; + + switch (link.getType()) { + case ASSOCIATION: + result = associationLinks.contains(link) ? false : associationLinks.add(link); + break; + + case ENTITY_NAVIGATION: + case ENTITY_SET_NAVIGATION: + result = navigationLinks.contains(link) ? false : navigationLinks.add(link); + break; + + case MEDIA_EDIT: + throw new IllegalArgumentException("Complex values cannot have media links!"); + + default: + } + + return result; + } + + @Override + public boolean removeLink(final ClientLink link) { + return associationLinks.remove(link) || navigationLinks.remove(link); + } + + private ClientLink getLink(final List<ClientLink> links, final String name) { + ClientLink result = null; + for (ClientLink link : links) { + if (name.equals(link.getName())) { + result = link; + break; + } + } + + return result; + } + + @Override + public ClientLink getNavigationLink(final String name) { + return getLink(navigationLinks, name); + } + + @Override + public List<ClientLink> getNavigationLinks() { + return navigationLinks; + } + + @Override + public ClientLink getAssociationLink(final String name) { + return getLink(associationLinks, name); + } + + @Override + public List<ClientLink> getAssociationLinks() { + return associationLinks; + } + + @Override + public Map<String, Object> asJavaMap() { + final Map<String, Object> result = new LinkedHashMap<String, Object>(); + for (Map.Entry<String, ClientProperty> entry : fields.entrySet()) { + Object value = null; + if (entry.getValue().hasPrimitiveValue()) { + value = entry.getValue().getPrimitiveValue().toValue(); + } else if (entry.getValue().hasComplexValue()) { + value = entry.getValue().getComplexValue().asJavaMap(); + } else if (entry.getValue().hasCollectionValue()) { + value = entry.getValue().getCollectionValue().asJavaCollection(); + } else if (entry.getValue().hasEnumValue()) { + value = entry.getValue().getEnumValue().toString(); + } + + result.put(entry.getKey(), value); + } + + return result; + } + + @Override + public List<ClientAnnotation> getAnnotations() { + return annotations; + } + + /** + * Adds field to the complex type. + * + * @param field field to be added. + */ + @Override + public ClientComplexValue add(final ClientProperty field) { + fields.put(field.getName(), field); + return this; + } + + /** + * Gets field. + * + * @param name name of the field to be retrieved. + * @return requested field. + */ + @Override + public ClientProperty get(final String name) { + return fields.get(name); + } + + /** + * Complex property fields iterator. + * + * @return fields iterator. + */ + @Override + public Iterator<ClientProperty> iterator() { + return fields.values().iterator(); + } + + /** + * Gets number of fields. + * + * @return number of fields. + */ + @Override + public int size() { + return fields.size(); + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeletedEntityImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeletedEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeletedEntityImpl.java new file mode 100644 index 0000000..9df7a18 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeletedEntityImpl.java @@ -0,0 +1,54 @@ +/* + * 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.commons.core.domain; + +import org.apache.olingo.commons.api.domain.ClientDeletedEntity; +import org.apache.olingo.commons.api.domain.ClientItem; + +import java.net.URI; + +public class ClientDeletedEntityImpl extends ClientItem implements ClientDeletedEntity { + + private URI id; + + private Reason reason; + + public ClientDeletedEntityImpl() { + super(null); + } + + @Override + public URI getId() { + return id; + } + + public void setId(final URI id) { + this.id = id; + } + + @Override + public Reason getReason() { + return reason; + } + + public void setReason(final Reason reason) { + this.reason = reason; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaImpl.java new file mode 100644 index 0000000..1c1e521 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaImpl.java @@ -0,0 +1,60 @@ +/* + * 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.commons.core.domain; + +import org.apache.olingo.commons.api.domain.ClientDeletedEntity; +import org.apache.olingo.commons.api.domain.ClientDelta; +import org.apache.olingo.commons.api.domain.ClientDeltaLink; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +public class ClientDeltaImpl extends ClientEntitySetImpl implements ClientDelta { + + private final List<ClientDeletedEntity> deletedEntities = new ArrayList<ClientDeletedEntity>(); + + private final List<ClientDeltaLink> addedLinks = new ArrayList<ClientDeltaLink>(); + + private final List<ClientDeltaLink> deletedLinks = new ArrayList<ClientDeltaLink>(); + + public ClientDeltaImpl() { + super(); + } + + public ClientDeltaImpl(final URI next) { + super(next); + } + + @Override + public List<ClientDeletedEntity> getDeletedEntities() { + return deletedEntities; + } + + @Override + public List<ClientDeltaLink> getAddedLinks() { + return addedLinks; + } + + @Override + public List<ClientDeltaLink> getDeletedLinks() { + return deletedLinks; + } + +}
