[OLINGO-603] Delete core dependecies in Tec Scenario
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/05935a0c Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/05935a0c Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/05935a0c Branch: refs/heads/master Commit: 05935a0c3d9141995cdf6547aefc0517360ee94d Parents: d4c2b89 Author: Christian Amend <[email protected]> Authored: Tue Apr 7 13:47:26 2015 +0200 Committer: Christian Amend <[email protected]> Committed: Tue Apr 7 14:15:17 2015 +0200 ---------------------------------------------------------------------- .../org/apache/olingo/fit/AbstractServices.java | 34 ++-- .../java/org/apache/olingo/fit/V4Services.java | 99 +++++---- .../core/serialization/ODataBinderImpl.java | 30 ++- .../apache/olingo/client/core/v4/JSONTest.java | 2 +- .../commons/api/data/AbstractODataObject.java | 68 +++++++ .../olingo/commons/api/data/Annotatable.java | 29 ++- .../olingo/commons/api/data/Annotation.java | 12 +- .../olingo/commons/api/data/ComplexValue.java | 9 +- .../olingo/commons/api/data/DeletedEntity.java | 22 +- .../apache/olingo/commons/api/data/Delta.java | 19 +- .../olingo/commons/api/data/DeltaLink.java | 30 ++- .../apache/olingo/commons/api/data/Entity.java | 138 ++++++++----- .../olingo/commons/api/data/EntitySet.java | 59 +++--- .../apache/olingo/commons/api/data/Link.java | 129 ++++++++---- .../apache/olingo/commons/api/data/Linked.java | 43 +++- .../olingo/commons/api/data/Parameter.java | 41 +++- .../olingo/commons/api/data/Property.java | 29 ++- .../olingo/commons/api/data/Valuable.java | 142 ++++++++++--- .../core/data/AbstractAnnotatedObject.java | 54 ----- .../commons/core/data/AbstractODataObject.java | 57 ------ .../commons/core/data/AbstractValuable.java | 166 --------------- .../commons/core/data/AnnotationImpl.java | 36 ---- .../commons/core/data/ComplexValueImpl.java | 88 -------- .../commons/core/data/DeletedEntityImpl.java | 48 ----- .../olingo/commons/core/data/DeltaImpl.java | 48 ----- .../olingo/commons/core/data/DeltaLinkImpl.java | 61 ------ .../olingo/commons/core/data/EntityImpl.java | 204 ------------------- .../olingo/commons/core/data/EntitySetImpl.java | 73 ------- .../olingo/commons/core/data/LinkImpl.java | 129 ------------ .../olingo/commons/core/data/ParameterImpl.java | 47 ----- .../olingo/commons/core/data/PropertyImpl.java | 54 ----- .../core/serialization/AtomDeserializer.java | 44 ++-- .../core/serialization/AtomSerializer.java | 21 +- .../serialization/JsonDeltaDeserializer.java | 13 +- .../core/serialization/JsonDeserializer.java | 26 +-- .../serialization/JsonEntityDeserializer.java | 13 +- .../JsonEntitySetDeserializer.java | 6 +- .../serialization/JsonPropertyDeserializer.java | 6 +- .../core/serialization/JsonSerializer.java | 24 +-- .../org/apache/olingo/server/api/OData.java | 14 ++ .../apache/olingo/server/core/ODataImpl.java | 8 + .../json/ODataJsonDeserializer.java | 66 +++--- .../json/ODataJsonSerializerTest.java | 10 +- lib/server-tecsvc/pom.xml | 1 + .../apache/olingo/server/tecsvc/Encoder.java | 132 ++++++++++++ .../olingo/server/tecsvc/data/DataCreator.java | 131 ++++++------ .../olingo/server/tecsvc/data/DataProvider.java | 23 +-- .../olingo/server/tecsvc/data/FunctionData.java | 24 +-- .../processor/TechnicalEntityProcessor.java | 8 +- .../TechnicalPrimitiveComplexProcessor.java | 14 +- .../tecsvc/processor/TechnicalProcessor.java | 5 + .../ExpandSystemQueryOptionHandler.java | 11 +- .../expression/operand/TypedOperand.java | 58 +++--- .../expression/operand/UntypedOperand.java | 70 +++---- .../expression/operand/VisitorOperand.java | 57 ++++-- .../expression/operation/BinaryOperator.java | 124 ++++++----- .../operation/MethodCallOperator.java | 91 ++++++--- .../expression/operation/UnaryOperator.java | 20 +- .../expression/primitive/EdmNull.java | 112 +++++++++- .../queryoptions/options/FilterHandler.java | 32 ++- .../options/ServerSidePagingHandler.java | 2 +- .../json/ODataJsonSerializerTest.java | 3 +- .../olingo/server/sample/data/DataProvider.java | 25 +-- 63 files changed, 1397 insertions(+), 1797 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java index de8c10e..a57f11b 100644 --- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java +++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java @@ -81,10 +81,6 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.serialization.ODataDeserializer; import org.apache.olingo.commons.api.serialization.ODataSerializer; -import org.apache.olingo.commons.core.data.EntityImpl; -import org.apache.olingo.commons.core.data.EntitySetImpl; -import org.apache.olingo.commons.core.data.LinkImpl; -import org.apache.olingo.commons.core.data.PropertyImpl; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.commons.core.serialization.AtomSerializer; import org.apache.olingo.commons.core.serialization.JsonDeserializer; @@ -231,14 +227,14 @@ public abstract class AbstractServices { @GET @Path("/StoredPIs(1000)") public Response getStoredPI(@Context final UriInfo uriInfo) { - final Entity entity = new EntityImpl(); + final Entity entity = new Entity(); entity.setType("Microsoft.Test.OData.Services.ODataWCFService.StoredPI"); - final Property id = new PropertyImpl(); + final Property id = new Property(); id.setType("Edm.Int32"); id.setName("StoredPIID"); id.setValue(ValueType.PRIMITIVE, 1000); entity.getProperties().add(id); - final Link edit = new LinkImpl(); + final Link edit = new Link(); edit.setHref(uriInfo.getRequestUri().toASCIIString()); edit.setRel("edit"); edit.setTitle("StoredPI"); @@ -622,7 +618,7 @@ public abstract class AbstractServices { final Entity entry; final String entityKey; if (xml.isMediaContent(entitySetName)) { - entry = new EntityImpl(); + entry = new Entity(); entry.setMediaContentType(ContentType.APPLICATION_OCTET_STREAM.toContentTypeString()); entry.setType(entitySet.getType()); @@ -632,7 +628,7 @@ public abstract class AbstractServices { final Pair<String, EdmPrimitiveTypeKind> id = Commons.getMediaContent().get(entitySetName); if (id != null) { - final Property prop = new PropertyImpl(); + final Property prop = new Property(); prop.setName(id.getKey()); prop.setType(id.getValue().toString()); prop.setValue(ValueType.PRIMITIVE, @@ -644,7 +640,7 @@ public abstract class AbstractServices { entry.getProperties().add(prop); } - final Link editLink = new LinkImpl(); + final Link editLink = new Link(); editLink.setHref(Commons.getEntityURI(entitySetName, entityKey)); editLink.setRel("edit"); editLink.setTitle(entitySetName); @@ -691,7 +687,7 @@ public abstract class AbstractServices { if ((this instanceof V4KeyAsSegment)) { location = uriInfo.getRequestUri().toASCIIString() + "/" + entityKey; - final Link editLink = new LinkImpl(); + final Link editLink = new Link(); editLink.setRel("edit"); editLink.setTitle(entitySetName); editLink.setHref(location); @@ -1207,7 +1203,7 @@ public abstract class AbstractServices { final Entity entry = container.getPayload(); if ((this instanceof V4KeyAsSegment)) { - final Link editLink = new LinkImpl(); + final Link editLink = new Link(); editLink.setRel("edit"); editLink.setTitle(entitySetName); editLink.setHref(Constants.get(ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "/" + entityId); @@ -1248,7 +1244,7 @@ public abstract class AbstractServices { for (Link link : entry.getNavigationLinks()) { if (links.contains(link.getTitle())) { // expand link - final Link rep = new LinkImpl(); + final Link rep = new Link(); rep.setHref(link.getHref()); rep.setRel(link.getRel()); rep.setTitle(link.getTitle()); @@ -1904,7 +1900,7 @@ public abstract class AbstractServices { for (Property property : entity.getProperties()) { if (navProperties.containsKey(property.getName())) { - Link alink = new LinkImpl(); + Link alink = new Link(); alink.setTitle(property.getName()); alink.getAnnotations().addAll(property.getAnnotations()); @@ -1915,9 +1911,9 @@ public abstract class AbstractServices { alink.setRel(Constants.get(ConstantKey.ATOM_LINK_REL) + property.getName()); if (property.isCollection()) { - EntitySet inline = new EntitySetImpl(); + EntitySet inline = new EntitySet(); for (Object value : property.asCollection()) { - Entity inlineEntity = new EntityImpl(); + Entity inlineEntity = new Entity(); inlineEntity.setType(navProperties.get(property.getName()).getType()); for (Property prop : ((ComplexValue) value).getValue()) { inlineEntity.getProperties().add(prop); @@ -1926,7 +1922,7 @@ public abstract class AbstractServices { } alink.setInlineEntitySet(inline); } else if (property.isComplex()) { - Entity inline = new EntityImpl(); + Entity inline = new Entity(); inline.setType(navProperties.get(property.getName()).getType()); for (Property prop : property.asComplex().getValue()) { inline.getProperties().add(prop); @@ -1946,7 +1942,7 @@ public abstract class AbstractServices { final EntityType entityType = metadata.getEntityOrComplexType(entitySet.getType()); for (Map.Entry<String, org.apache.olingo.fit.metadata.Property> property : entityType.getPropertyMap().entrySet()) { if (entry.getProperty(property.getKey()) == null && property.getValue().isNullable()) { - final PropertyImpl prop = new PropertyImpl(); + final Property prop = new Property(); prop.setName(property.getKey()); prop.setValue(ValueType.PRIMITIVE, null); entry.getProperties().add(prop); @@ -1962,7 +1958,7 @@ public abstract class AbstractServices { } if (!found) { - final LinkImpl link = new LinkImpl(); + final Link link = new Link(); link.setTitle(property.getKey()); link.setType(property.getValue().isEntitySet() ? Constants.get(ConstantKey.ATOM_LINK_FEED) http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/fit/src/main/java/org/apache/olingo/fit/V4Services.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java index fe9465e..6c1038d 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java @@ -18,6 +18,43 @@ */ package org.apache.olingo.fit; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.regex.Pattern; + +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMultipart; +import javax.ws.rs.BadRequestException; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; + import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -34,10 +71,6 @@ import org.apache.olingo.commons.api.data.ResWrap; import org.apache.olingo.commons.api.data.ValueType; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import org.apache.olingo.commons.api.format.ContentType; -import org.apache.olingo.commons.core.data.EntityImpl; -import org.apache.olingo.commons.core.data.EntitySetImpl; -import org.apache.olingo.commons.core.data.LinkImpl; -import org.apache.olingo.commons.core.data.PropertyImpl; import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo; import org.apache.olingo.fit.metadata.Metadata; import org.apache.olingo.fit.methods.PATCH; @@ -52,44 +85,6 @@ import org.apache.olingo.fit.utils.FSManager; import org.apache.olingo.fit.utils.LinkInfo; import org.springframework.stereotype.Service; -import javax.mail.internet.MimeBodyPart; -import javax.mail.internet.MimeMultipart; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.NotFoundException; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.core.UriInfo; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStreamWriter; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.regex.Pattern; - -import javax.ws.rs.BadRequestException; - @Service @Path("/V40/Static.svc") @InInterceptors(classes = { XHTTPMethodInterceptor.class, ResolvingReferencesInterceptor.class }) @@ -504,7 +499,7 @@ public class V4Services extends AbstractServices { acceptType = Accept.parse(accept); } - final Property property = new PropertyImpl(); + final Property property = new Property(); property.setType("Edm.Int32"); property.setValue(ValueType.PRIMITIVE, 2); final ResWrap<Property> container = new ResWrap<Property>( @@ -565,27 +560,27 @@ public class V4Services extends AbstractServices { acceptType = Accept.parse(accept); } - final EntityImpl entry = new EntityImpl(); + final Entity entry = new Entity(); entry.setType("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail"); - final Property productId = new PropertyImpl(); + final Property productId = new Property(); productId.setName("ProductID"); productId.setType("Edm.Int32"); productId.setValue(ValueType.PRIMITIVE, Integer.valueOf(entityId)); entry.getProperties().add(productId); - final Property productDetailId = new PropertyImpl(); + final Property productDetailId = new Property(); productDetailId.setName("ProductDetailID"); productDetailId.setType("Edm.Int32"); productDetailId.setValue(ValueType.PRIMITIVE, 2); entry.getProperties().add(productDetailId); - final Link link = new LinkImpl(); + final Link link = new Link(); link.setRel("edit"); link.setHref(URI.create( Constants.get(ConstantKey.DEFAULT_SERVICE_URL) + "ProductDetails(ProductID=6,ProductDetailID=1)").toASCIIString()); entry.setEditLink(link); - final EntitySetImpl feed = new EntitySetImpl(); + final EntitySet feed = new EntitySet(); feed.getEntities().add(entry); final ResWrap<EntitySet> container = new ResWrap<EntitySet>( @@ -736,7 +731,7 @@ public class V4Services extends AbstractServices { acceptType = Accept.parse(accept); } - final Property property = new PropertyImpl(); + final Property property = new Property(); property.setType("Edm.Double"); property.setValue(ValueType.PRIMITIVE, 41.79); @@ -1144,7 +1139,7 @@ public class V4Services extends AbstractServices { acceptType = Accept.parse(accept); } - final PropertyImpl property = new PropertyImpl(); + final Property property = new Property(); property.setType("Microsoft.Test.OData.Services.ODataWCFService.Color"); property.setValue(ValueType.ENUM, "Red"); final ResWrap<Property> container = new ResWrap<Property>( @@ -1236,7 +1231,7 @@ public class V4Services extends AbstractServices { acceptType = Accept.parse(accept); } - final PropertyImpl property = new PropertyImpl(); + final Property property = new Property(); property.setType("Collection(String)"); final List<String> value = Arrays.asList("Cheetos", "Mushrooms", "Apple", "Car", "Computer"); property.setValue(ValueType.COLLECTION_PRIMITIVE, value); @@ -1268,7 +1263,7 @@ public class V4Services extends AbstractServices { acceptType = Accept.parse(accept); } - final PropertyImpl property = new PropertyImpl(); + final Property property = new Property(); property.setType("Collection(Edm.String)"); property.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList("[email protected]", "[email protected]")); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java index 2ae47f1..54823e0 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java @@ -87,12 +87,6 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.geo.Geospatial; import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.serialization.ODataSerializerException; -import org.apache.olingo.commons.core.data.AnnotationImpl; -import org.apache.olingo.commons.core.data.ComplexValueImpl; -import org.apache.olingo.commons.core.data.EntityImpl; -import org.apache.olingo.commons.core.data.EntitySetImpl; -import org.apache.olingo.commons.core.data.LinkImpl; -import org.apache.olingo.commons.core.data.PropertyImpl; import org.apache.olingo.commons.core.domain.ODataAnnotationImpl; import org.apache.olingo.commons.core.domain.ODataDeletedEntityImpl; import org.apache.olingo.commons.core.domain.ODataDeltaLinkImpl; @@ -187,7 +181,7 @@ public class ODataBinderImpl implements ODataBinder { private void annotations(final ODataAnnotatable odataAnnotatable, final Annotatable annotatable) { for (ODataAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) { - final Annotation annotation = new AnnotationImpl(); + final Annotation annotation = new Annotation(); annotation.setTerm(odataAnnotation.getTerm()); annotation.setType(odataAnnotation.getValue().getTypeName()); @@ -199,7 +193,7 @@ public class ODataBinderImpl implements ODataBinder { @Override public EntitySet getEntitySet(final ODataEntitySet odataEntitySet) { - final EntitySet entitySet = new EntitySetImpl(); + final EntitySet entitySet = new EntitySet(); entitySet.setCount(odataEntitySet.getCount()); @@ -248,7 +242,7 @@ public class ODataBinderImpl implements ODataBinder { @Override public Entity getEntity(final ODataEntity odataEntity) { - final Entity entity = new EntityImpl(); + final Entity entity = new Entity(); entity.setType(odataEntity.getTypeName() == null ? null : odataEntity.getTypeName().toString()); @@ -257,7 +251,7 @@ public class ODataBinderImpl implements ODataBinder { // ------------------------------------------------------------- final URI odataEditLink = odataEntity.getEditLink(); if (odataEditLink != null) { - final LinkImpl editLink = new LinkImpl(); + final Link editLink = new Link(); editLink.setTitle(entity.getType()); editLink.setHref(odataEditLink.toASCIIString()); editLink.setRel(Constants.EDIT_LINK_REL); @@ -265,7 +259,7 @@ public class ODataBinderImpl implements ODataBinder { } if (odataEntity.isReadOnly()) { - final LinkImpl selfLink = new LinkImpl(); + final Link selfLink = new Link(); selfLink.setTitle(entity.getType()); selfLink.setHref(odataEntity.getLink().toASCIIString()); selfLink.setRel(Constants.SELF_LINK_REL); @@ -301,7 +295,7 @@ public class ODataBinderImpl implements ODataBinder { @Override public Link getLink(final ODataLink link) { - final Link linkResource = new LinkImpl(); + final Link linkResource = new Link(); linkResource.setRel(link.getRel()); linkResource.setTitle(link.getName()); linkResource.setHref(link.getLink() == null ? null : link.getLink().toASCIIString()); @@ -328,7 +322,7 @@ public class ODataBinderImpl implements ODataBinder { @Override public Property getProperty(final ODataProperty property) { - final Property propertyResource = new PropertyImpl(); + final Property propertyResource = new Property(); propertyResource.setName(property.getName()); updateValuable(propertyResource, property); annotations(property, propertyResource); @@ -350,7 +344,7 @@ public class ODataBinderImpl implements ODataBinder { for (final ODataProperty propertyValue : value.asComplex()) { complexProperties.add(getProperty(propertyValue)); } - final ComplexValue lcValueResource = new ComplexValueImpl(); + final ComplexValue lcValueResource = new ComplexValue(); lcValueResource.getValue().addAll(complexProperties); annotations(value.asComplex(), lcValueResource); links(value.asComplex(), lcValueResource); @@ -573,16 +567,16 @@ public class ODataBinderImpl implements ODataBinder { private ODataLink createLinkFromNavigationProperty(final Property property, final String propertyTypeName) { if (property.isCollection()) { - EntitySet inlineEntitySet = new EntitySetImpl(); + EntitySet inlineEntitySet = new EntitySet(); for (final Object inlined : property.asCollection()) { - Entity inlineEntity = new EntityImpl(); + Entity inlineEntity = new Entity(); inlineEntity.setType(propertyTypeName); inlineEntity.getProperties().addAll(((ComplexValue) inlined).getValue()); inlineEntitySet.getEntities().add(inlineEntity); } return createODataInlineEntitySet(inlineEntitySet, null, property.getName(), null); } else { - Entity inlineEntity = new EntityImpl(); + Entity inlineEntity = new Entity(); inlineEntity.setType(propertyTypeName); inlineEntity.getProperties().addAll(property.asComplex().getValue()); return createODataInlineEntity(inlineEntity, null, property.getName(), null); @@ -751,7 +745,7 @@ public class ODataBinderImpl implements ODataBinder { value = client.getObjectFactory().newCollectionValue(type == null ? null : "Collection(" + type.toString() + ")"); for (Object _value : valuable.asCollection()) { - final Property fake = new PropertyImpl(); + final Property fake = new Property(); fake.setValue(valuable.getValueType().getBaseType(), _value); value.asCollection().add(getODataValue(type, fake, contextURL, metadataETag)); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java index 19f39e6..0f6cb19 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java @@ -146,7 +146,7 @@ public class JSONTest extends AbstractTest { final StringWriter writer = new StringWriter(); getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntity( getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload()); - + assertSimilar(filename + "." + getSuffix(format), writer.toString()); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/AbstractODataObject.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/AbstractODataObject.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/AbstractODataObject.java new file mode 100644 index 0000000..2904bfd --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/AbstractODataObject.java @@ -0,0 +1,68 @@ +/* + * 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.data; + +import java.net.URI; +import java.text.ParseException; + +public abstract class AbstractODataObject extends Annotatable { + + private URI baseURI; + private URI id; + private String title; + + /** + * Gets base URI. + * + * @return base URI. + */ + public URI getBaseURI() { + return baseURI; + } + + public void setBaseURI(final String baseURI) { + this.baseURI = baseURI == null ? null : URI.create(baseURI); + } + + + /** + * Gest ID. + * + * @return ID. + */ + public URI getId() { + return id; + } + + public void setId(final URI id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setCommonProperty(final String key, final String value) throws ParseException { + if ("id".equals(key)) { + id = URI.create(value); + } else if ("title".equals(key)) { + title = value; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotatable.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotatable.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotatable.java index b2e3583..b43002f 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotatable.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotatable.java @@ -18,12 +18,37 @@ */ package org.apache.olingo.commons.api.data; +import java.util.ArrayList; import java.util.List; +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; + /** * An element with instance annotations. */ -public interface Annotatable { +public abstract class Annotatable { + + private final List<Annotation> annotations = new ArrayList<Annotation>(); + + public List<Annotation> getAnnotations() { + return annotations; + } + + @Override + public boolean equals(final Object obj) { + return EqualsBuilder.reflectionEquals(this, obj); + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } - List<Annotation> getAnnotations(); + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE); + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotation.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotation.java index f4e9d90..1b1741a 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotation.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotation.java @@ -21,9 +21,15 @@ package org.apache.olingo.commons.api.data; /** * Represents an instance annotation. */ -public interface Annotation extends Valuable { +public class Annotation extends Valuable { - String getTerm(); + private String term; - void setTerm(String term); + public String getTerm() { + return term; + } + + public void setTerm(final String term) { + this.term = term; + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java index ea5b528..d2611b3 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java @@ -18,9 +18,14 @@ */ package org.apache.olingo.commons.api.data; +import java.util.ArrayList; import java.util.List; -public interface ComplexValue extends Linked, Annotatable { +public class ComplexValue extends Linked { - List<Property> getValue(); + private final List<Property> value = new ArrayList<Property>(); + + public List<Property> getValue() { + return value; + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java index 77993c0..e51abfc 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java @@ -20,17 +20,31 @@ package org.apache.olingo.commons.api.data; import java.net.URI; -public interface DeletedEntity { +public class DeletedEntity { - enum Reason { + public enum Reason { deleted, changed } - URI getId(); + private URI id; + private Reason reason; - Reason getReason(); + public URI getId() { + return id; + } + + public void setId(final URI id) { + this.id = id; + } + 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/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java index 4309325..5fe36f7 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java @@ -18,14 +18,25 @@ */ package org.apache.olingo.commons.api.data; +import java.util.ArrayList; import java.util.List; -public interface Delta extends EntitySet { +public class Delta extends EntitySet { - List<DeletedEntity> getDeletedEntities(); + private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>(); + private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>(); + private final List<DeltaLink> deletedLinks = new ArrayList<DeltaLink>(); - List<DeltaLink> getAddedLinks(); + public List<DeletedEntity> getDeletedEntities() { + return deletedEntities; + } - List<DeltaLink> getDeletedLinks(); + public List<DeltaLink> getAddedLinks() { + return addedLinks; + } + + public List<DeltaLink> getDeletedLinks() { + return deletedLinks; + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java index 6c09fc8..335863e 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java @@ -20,17 +20,33 @@ package org.apache.olingo.commons.api.data; import java.net.URI; -public interface DeltaLink extends Annotatable { +public class DeltaLink extends Annotatable { - URI getSource(); + private URI source; + private String relationship; + private URI target; - void setSource(URI source); + public URI getSource() { + return source; + } - String getRelationship(); + public void setSource(final URI source) { + this.source = source; + } - void setRelationship(String relationship); + public String getRelationship() { + return relationship; + } - URI getTarget(); + public void setRelationship(final String relationship) { + this.relationship = relationship; + } - void setTarget(URI target); + public URI getTarget() { + return target; + } + + public void setTarget(final URI target) { + this.target = target; + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java index 4029cc3..acd3022 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java @@ -21,93 +21,110 @@ package org.apache.olingo.commons.api.data; import org.apache.olingo.commons.api.domain.ODataOperation; import java.net.URI; +import java.util.ArrayList; import java.util.List; -public interface Entity extends Linked, Annotatable { +public class Entity extends Linked { + + private String eTag; + private String type; + + private Link readLink; + private Link editLink; + + private final List<Link> mediaEditLinks = new ArrayList<Link>(); + private final List<ODataOperation> operations = new ArrayList<ODataOperation>(); + + private final List<Property> properties = new ArrayList<Property>(); + + private URI mediaContentSource; + private String mediaContentType; + private String mediaETag; /** * Gets ETag. * * @return ETag. */ - String getETag(); + public String getETag() { + return eTag; + } - /** - * Gets base URI. - * - * @return base URI. - */ - URI getBaseURI(); + public void setETag(final String eTag) { + this.eTag = eTag; + } /** * Gets entity type. * * @return entity type. */ - String getType(); + public String getType() { + return type; + } /** * Sets entity type. * * @param type entity type. */ - void setType(String type); - - /** - * Gets entity ID. - * - * @return entity ID. - */ - URI getId(); - - /** - * Sets entity ID. - * - * @param id entity ID. - */ - void setId(URI id); + public void setType(final String type) { + this.type = type; + } /** * Gets entity self link. * * @return self link. */ - Link getSelfLink(); + public Link getSelfLink() { + return readLink; + } /** * Sets entity self link. * * @param selfLink self link. */ - void setSelfLink(Link selfLink); + public void setSelfLink(final Link selfLink) { + this.readLink = selfLink; + } /** * Gets entity edit link. * * @return edit link. */ - Link getEditLink(); + public Link getEditLink() { + return editLink; + } /** * Sets entity edit link. * * @param editLink edit link. */ - void setEditLink(Link editLink); + public void setEditLink(final Link editLink) { + this.editLink = editLink; + } /** * Gets media entity links. * * @return links. */ - List<Link> getMediaEditLinks(); + public List<Link> getMediaEditLinks() { + return mediaEditLinks; + } /** * Gets operations. * * @return operations. */ - List<ODataOperation> getOperations(); + public List<ODataOperation> getOperations() { + return operations; + } /** * Add property to this Entity. @@ -115,14 +132,19 @@ public interface Entity extends Linked, Annotatable { * @param property property which is added * @return this Entity for fluid/flow adding */ - Entity addProperty(Property property); + public Entity addProperty(final Property property) { + properties.add(property); + return this; + } /** * Gets properties. * * @return properties. */ - List<Property> getProperties(); + public List<Property> getProperties() { + return properties; + } /** * Gets property with given name. @@ -130,54 +152,78 @@ public interface Entity extends Linked, Annotatable { * @param name property name * @return property with given name if found, null otherwise */ - Property getProperty(String name); + public Property getProperty(final String name) { + Property result = null; + + for (Property property : properties) { + if (name.equals(property.getName())) { + result = property; + } + } + + return result; + } /** * Gets media content type. * * @return media content type. */ - String getMediaContentType(); + public String getMediaContentType() { + return mediaContentType; + } /** - * Gets media content resource. + * Set media content type. * - * @return media content resource. + * @param mediaContentType media content type. */ - URI getMediaContentSource(); + public void setMediaContentType(final String mediaContentType) { + this.mediaContentType = mediaContentType; + } /** - * Set media content source. + * Gets media content resource. * - * @param mediaContentSource media content source. + * @return media content resource. */ - void setMediaContentSource(URI mediaContentSource); + public URI getMediaContentSource() { + return mediaContentSource; + } /** - * Set media content type. + * Set media content source. * - * @param mediaContentType media content type. + * @param mediaContentSource media content source. */ - void setMediaContentType(String mediaContentType); + public void setMediaContentSource(final URI mediaContentSource) { + this.mediaContentSource = mediaContentSource; + } /** * ETag of the binary stream represented by this media entity or named stream property. * * @return media ETag value */ - String getMediaETag(); + public String getMediaETag() { + return mediaETag; + } /** * Set media ETag. * * @param eTag media ETag value */ - void setMediaETag(String eTag); + public void setMediaETag(final String eTag) { + mediaETag = eTag; + } /** * Checks if the current entity is a media entity. * * @return 'TRUE' if is a media entity; 'FALSE' otherwise. */ - boolean isMediaEntity(); + public boolean isMediaEntity() { + return mediaContentSource != null; + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java index ad7e4fb..8f2cfb7 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java @@ -19,70 +19,79 @@ package org.apache.olingo.commons.api.data; import java.net.URI; +import java.util.ArrayList; import java.util.List; -public interface EntitySet extends Annotatable { +public class EntitySet extends AbstractODataObject { - /** - * Gets base URI. - * - * @return base URI. - */ - URI getBaseURI(); + private Integer count; + + private final List<Entity> entities = new ArrayList<Entity>(); + + private URI next; + + private URI deltaLink; /** * Sets number of entries. * * @param count number of entries */ - void setCount(Integer count); + public void setCount(final Integer count) { + this.count = count; + } /** * Gets number of entries - if it was required. * * @return number of entries into the entity set. */ - Integer getCount(); - - /** - * Gest ID. - * - * @return ID. - */ - URI getId(); + public Integer getCount() { + return count; + } /** * Gets entities. * * @return entries. */ - List<Entity> getEntities(); + public List<Entity> getEntities() { + return entities; + } /** - * Gets next link if exists. + * Sets next link. * - * @return next link if exists; null otherwise. + * @param next next link. */ - URI getNext(); + public void setNext(final URI next) { + this.next = next; + } /** - * Sets next link. + * Gets next link if exists. * - * @param next next link. + * @return next link if exists; null otherwise. */ - void setNext(URI next); + public URI getNext() { + return next; + } /** * Gets delta link if exists. * * @return delta link if exists; null otherwise. */ - URI getDeltaLink(); + public URI getDeltaLink() { + return deltaLink; + } /** * Sets delta link. * * @param deltaLink delta link. */ - void setDeltaLink(URI deltaLink); + public void setDeltaLink(final URI deltaLink) { + this.deltaLink = deltaLink; + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java index 88742f5..dff1069 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java @@ -18,130 +18,177 @@ */ package org.apache.olingo.commons.api.data; +import java.util.ArrayList; import java.util.List; -public interface Link extends Annotatable { +public class Link extends Annotatable { + + private String title; + private String rel; + private String href; + private String type; + private String mediaETag; + private Entity entity; + private EntitySet entitySet; + private String bindingLink; + private List<String> bindingLinks = new ArrayList<String>(); /** - * Gets rel info. + * Gets title. * - * @return rel info. + * @return title. */ - String getRel(); + public String getTitle() { + return title; + } /** - * Sets rel info. + * Sets title. * - * @param rel rel info. + * @param title title. */ - void setRel(String rel); + public void setTitle(final String title) { + this.title = title; + } /** - * Gets type. + * Gets rel info. * - * @return type. + * @return rel info. */ - String getType(); + public String getRel() { + return rel; + } /** - * Sets type. + * Sets rel info. * - * @param type type. + * @param rel rel info. */ - void setType(String type); + public void setRel(final String rel) { + this.rel = rel; + } /** - * Gets title. + * Gets href. * - * @return title. + * @return href. */ - String getTitle(); + public String getHref() { + return href; + } /** - * Sets title. + * Sets href. * - * @param title title. + * @param href href. */ - void setTitle(String title); + public void setHref(final String href) { + this.href = href; + } /** - * Gets href. + * Gets type. * - * @return href. + * @return type. */ - String getHref(); + public String getType() { + return type; + } /** - * Sets href. + * Sets type. * - * @param href href. + * @param type type. */ - void setHref(String href); + public void setType(final String type) { + this.type = type; + } /** * Gets Media ETag. * * @return media ETag */ - String getMediaETag(); + public String getMediaETag() { + return mediaETag; + } /** * Sets Media ETag. * - * @param etag media ETag + * @param mediaETag media ETag */ - void setMediaETag(String etag); + public void setMediaETag(final String mediaETag) { + this.mediaETag = mediaETag; + } /** * Gets in-line entity. * * @return in-line entity. */ - Entity getInlineEntity(); + public Entity getInlineEntity() { + return entity; + } /** * Sets in-line entity. * * @param entity entity. */ - void setInlineEntity(Entity entity); + public void setInlineEntity(final Entity entity) { + this.entity = entity; + } + /** * Gets in-line entity set. * * @return in-line entity set. */ - EntitySet getInlineEntitySet(); + public EntitySet getInlineEntitySet() { + return entitySet; + } /** * Sets in-line entity set. * * @param entitySet entity set. */ - void setInlineEntitySet(EntitySet entitySet); + public void setInlineEntitySet(final EntitySet entitySet) { + this.entitySet = entitySet; + } /** * If this is a "toOne" relationship this method delivers the binding link or <tt>null</tt> if not set. * @return String the binding link. */ - String getBindingLink(); + public String getBindingLink() { + return bindingLink; + } /** - * Sets the binding link. - * @param bindingLink + * If this is a "toMany" relationship this method delivers the binding links or <tt>emptyList</tt> if not set. + * @return a list of binding links. */ - void setBindingLink(String bindingLink); + public List<String> getBindingLinks() { + return bindingLinks; + } /** - * If this is a "toMany" relationship this method delivers the binding links or <tt>emptyList</tt> if not set. - * @return a list of binding links. + * Sets the binding link. + * @param bindingLink */ - List<String> getBindingLinks(); + public void setBindingLink(String bindingLink) { + this.bindingLink = bindingLink; + } /** * Sets the binding links. List MUST NOT be <tt>null</tt>. * @param bindingLinks */ - void setBindingLinks(List<String> bindingLinks); - + public void setBindingLinks(List<String> bindingLinks) { + this.bindingLinks = bindingLinks; + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java index 1c28507..c136d55 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java @@ -18,9 +18,26 @@ */ package org.apache.olingo.commons.api.data; +import java.util.ArrayList; import java.util.List; -public interface Linked { +public abstract class Linked extends AbstractODataObject { + + private final List<Link> associationLinks = new ArrayList<Link>(); + private final List<Link> navigationLinks = new ArrayList<Link>(); + private final List<Link> bindingLinks = new ArrayList<Link>(); + + protected Link getOneByTitle(final String name, final List<Link> links) { + Link result = null; + + for (Link link : links) { + if (name.equals(link.getTitle())) { + result = link; + } + } + + return result; + } /** * Gets association link with given name, if available, otherwise <tt>null</tt>. @@ -28,14 +45,18 @@ public interface Linked { * @param name candidate link name * @return association link with given name, if available, otherwise <tt>null</tt> */ - Link getAssociationLink(String name); + public Link getAssociationLink(final String name) { + return getOneByTitle(name, associationLinks); + } /** * Gets association links. * * @return association links. */ - List<Link> getAssociationLinks(); + public List<Link> getAssociationLinks() { + return associationLinks; + } /** * Gets navigation link with given name, if available, otherwise <tt>null</tt>. @@ -43,26 +64,34 @@ public interface Linked { * @param name candidate link name * @return navigation link with given name, if available, otherwise <tt>null</tt> */ - Link getNavigationLink(String name); + public Link getNavigationLink(final String name) { + return getOneByTitle(name, navigationLinks); + } /** * Gets navigation links. * * @return links. */ - List<Link> getNavigationLinks(); + public List<Link> getNavigationLinks() { + return navigationLinks; + } /** * Gets binding link with given name, if available, otherwise <tt>null</tt>. * @param name candidate link name * @return binding link with given name, if available, otherwise <tt>null</tt> */ - Link getNavigationBinding(String name); + public Link getNavigationBinding(String name) { + return getOneByTitle(name, bindingLinks); + } /** * Gets binding links. * * @return links. */ - List<Link> getNavigationBindings(); + public List<Link> getNavigationBindings() { + return bindingLinks; + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java index 87058ec..a5443c7 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java @@ -18,15 +18,46 @@ */ package org.apache.olingo.commons.api.data; -public interface Parameter extends Valuable { +public class Parameter extends Valuable { + + String name; /** * @return name of the parameter */ - String getName(); + public String getName() { + return name; + } - boolean isEntity(); - - Entity asEntity(); + /** + * @param name of the parameter + */ + public void setName(String name) { + this.name = name; + } + + /** + * Check if Valuable contains a ENTITY or COLLECTION_ENTITY ValueType + * + * @return true if ValueType is a ENTITY or COLLECTION_ENTITY, otherwise false + */ + public boolean isEntity() { + if (isCollection()) { + return getValueType().getBaseType() == ValueType.ENTITY; + } + return getValueType() == ValueType.ENTITY; + } + + /** + * Get the value in its entity representation or null if it is not based on an entity ValueType + * + * @return entity representation or null if it is not based on an entity ValueType + */ + public Entity asEntity() { + if (isCollection()) { + return null; + } + return isEntity() ? (Entity) getValue() : null; + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java index 28163dd..ef0adbd 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java @@ -18,9 +18,32 @@ */ package org.apache.olingo.commons.api.data; -public interface Property extends Valuable, Annotatable { +public class Property extends Valuable { - String getName(); + private String name; - void setName(String name); + public Property() {} + + public Property(final String type, final String name) { + this.name = name; + super.setType(type); + } + + public Property(String type, String name, ValueType valueType, Object value) { + this(type, name); + setValue(valueType, value); + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + @Override + public boolean isNull() { + return getValue() == null || "Edm.Null".equals(getType()); + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java index 78989b3..f982aab 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java @@ -18,96 +18,178 @@ */ package org.apache.olingo.commons.api.data; -import org.apache.olingo.commons.api.edm.geo.Geospatial; - import java.util.List; -public interface Valuable { +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.commons.api.edm.geo.Geospatial; + +public abstract class Valuable extends Annotatable { - String getType(); + private ValueType valueType = null; + private Object value = null; + private String type; - void setType(String type); + public boolean isNull() { + return value == null; + } - boolean isNull(); + public String getType() { + return type; + } + public void setType(final String type) { + this.type = type; + } + /** * Check if Valuable contains a PRIMITIVE or COLLECTION_PRIMITIVE ValueType * * @return true if ValueType is a PRIMITIVE or COLLECTION_PRIMITIVE, otherwise false */ - boolean isPrimitive(); + public boolean isPrimitive() { + if(isCollection()) { + return valueType.getBaseType() == ValueType.PRIMITIVE; + } + return valueType == ValueType.PRIMITIVE; + } /** * Check if Valuable contains a GEOSPATIAL or COLLECTION_GEOSPATIAL ValueType * * @return true if ValueType is a GEOSPATIAL or COLLECTION_GEOSPATIAL, otherwise false */ - boolean isGeospatial(); + public boolean isGeospatial() { + if(isCollection()) { + return valueType.getBaseType() == ValueType.GEOSPATIAL; + } + return valueType == ValueType.GEOSPATIAL; + } + /** * Check if Valuable contains a ENUM or COLLECTION_ENUM ValueType * * @return true if ValueType is a ENUM or COLLECTION_ENUM, otherwise false */ - boolean isEnum(); + public boolean isEnum() { + if(isCollection()) { + return valueType.getBaseType() == ValueType.ENUM; + } + return valueType == ValueType.ENUM; + } /** * Check if Valuable contains a COMPLEX or COLLECTION_COMPLEX ValueType * * @return true if ValueType is a COMPLEX or COLLECTION_COMPLEX, otherwise false */ - boolean isComplex(); + public boolean isComplex() { + if(isCollection()) { + return valueType.getBaseType() == ValueType.COMPLEX; + } + return valueType == ValueType.COMPLEX; + } /** * Check if Valuable contains a COLLECTION_* ValueType * * @return true if ValueType is a COLLECTION_*, otherwise false */ - boolean isCollection(); - - /** - * Get the value - * - * @return the value - */ - Object getValue(); + public boolean isCollection() { + return valueType != null && valueType != valueType.getBaseType(); + } /** * Get the value in its primitive representation or null if it is not based on a primitive ValueType * * @return primitive representation or null if it is not based on a primitive ValueType */ - Object asPrimitive(); + public Object asPrimitive() { + if(isCollection()) { + return null; + } + return isPrimitive() ? value : null; + } /** - * Get the value in its enum representation or null if it is not based on a enum ValueType + * Get the value in its geospatial representation or null if it is not based on a geospatial ValueType * - * @return enum representation or null if it is not based on a enum ValueType + * @return geospatial representation or null if it is not based on a geospatial ValueType */ - Object asEnum(); + public Geospatial asGeospatial() { + if(isCollection()) { + return null; + } + return isGeospatial() ? (Geospatial) value : null; + } /** - * Get the value in its geospatial representation or null if it is not based on a geospatial ValueType + * Get the value in its enum representation or null if it is not based on a enum ValueType * - * @return geospatial representation or null if it is not based on a geospatial ValueType + * @return enum representation or null if it is not based on a enum ValueType */ - Geospatial asGeospatial(); + public Object asEnum() { + if(isCollection()) { + return null; + } + return isEnum() ? value : null; + } /** * Get the value in its complex representation or null if it is not based on a complex ValueType * * @return primitive complex or null if it is not based on a complex ValueType */ - ComplexValue asComplex(); + public ComplexValue asComplex() { + if(isCollection()) { + return null; + } + return isComplex() ? (ComplexValue) value : null; + } /** * Get the value as collection or null if it is not a collection ValueType * * @return collection or null if it is not a collection ValueType */ - List<?> asCollection(); + public List<?> asCollection() { + return isCollection() ? (List<?>) value : null; + } - void setValue(ValueType valuetype, Object value); - - ValueType getValueType(); + /** + * Get the value + * + * @return the value + */ + public Object getValue() { + return value; + } + + public void setValue(final ValueType valueType, final Object value) { + this.valueType = valueType; + this.value = value; + } + + public ValueType getValueType() { + return valueType; + } + + + @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/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java deleted file mode 100644 index d8cdf05..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java +++ /dev/null @@ -1,54 +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.data; - -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.commons.api.data.Annotatable; -import org.apache.olingo.commons.api.data.Annotation; - -import java.util.ArrayList; -import java.util.List; - -public abstract class AbstractAnnotatedObject implements Annotatable { - - private final List<Annotation> annotations = new ArrayList<Annotation>(); - - @Override - public List<Annotation> getAnnotations() { - return annotations; - } - - @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/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java deleted file mode 100644 index 6a3c46f..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java +++ /dev/null @@ -1,57 +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.data; - -import java.net.URI; -import java.text.ParseException; - -public abstract class AbstractODataObject extends AbstractAnnotatedObject { - - private URI baseURI; - private URI id; - private String title; - - public URI getBaseURI() { - return baseURI; - } - - public void setBaseURI(final String baseURI) { - this.baseURI = baseURI == null ? null : URI.create(baseURI); - } - - public URI getId() { - return id; - } - - public void setId(final URI id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setCommonProperty(final String key, final String value) throws ParseException { - if ("id".equals(key)) { - id = URI.create(value); - } else if ("title".equals(key)) { - title = value; - } - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java deleted file mode 100644 index 3a06511..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java +++ /dev/null @@ -1,166 +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.data; - -import java.util.ArrayList; -import java.util.List; - -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.commons.api.data.Annotatable; -import org.apache.olingo.commons.api.data.Annotation; -import org.apache.olingo.commons.api.data.ComplexValue; -import org.apache.olingo.commons.api.data.Valuable; -import org.apache.olingo.commons.api.data.ValueType; -import org.apache.olingo.commons.api.edm.geo.Geospatial; - -public abstract class AbstractValuable implements Valuable, Annotatable { - - private ValueType valueType = null; - private Object value = null; - private final List<Annotation> annotations = new ArrayList<Annotation>(); - private String type; - - @Override - public boolean isNull() { - return value == null; - } - - @Override - public String getType() { - return type; - } - - @Override - public void setType(final String type) { - this.type = type; - } - - @Override - public boolean isPrimitive() { - if(isCollection()) { - return valueType.getBaseType() == ValueType.PRIMITIVE; - } - return valueType == ValueType.PRIMITIVE; - } - - @Override - public boolean isGeospatial() { - if(isCollection()) { - return valueType.getBaseType() == ValueType.GEOSPATIAL; - } - return valueType == ValueType.GEOSPATIAL; - } - - @Override - public boolean isEnum() { - if(isCollection()) { - return valueType.getBaseType() == ValueType.ENUM; - } - return valueType == ValueType.ENUM; - } - - @Override - public boolean isComplex() { - if(isCollection()) { - return valueType.getBaseType() == ValueType.COMPLEX; - } - return valueType == ValueType.COMPLEX; - } - - @Override - public boolean isCollection() { - return valueType != null && valueType != valueType.getBaseType(); - } - - @Override - public Object asPrimitive() { - if(isCollection()) { - return null; - } - return isPrimitive() ? value : null; - } - - @Override - public Geospatial asGeospatial() { - if(isCollection()) { - return null; - } - return isGeospatial() ? (Geospatial) value : null; - } - - @Override - public Object asEnum() { - if(isCollection()) { - return null; - } - return isEnum() ? value : null; - } - - @Override - public ComplexValue asComplex() { - if(isCollection()) { - return null; - } - return isComplex() ? (ComplexValue) value : null; - } - - @Override - public List<?> asCollection() { - return isCollection() ? (List<?>) value : null; - } - - @Override - public Object getValue() { - return value; - } - - @Override - public void setValue(final ValueType valueType, final Object value) { - this.valueType = valueType; - this.value = value; - } - - @Override - public ValueType getValueType() { - return valueType; - } - - @Override - public List<Annotation> getAnnotations() { - return annotations; - } - - @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/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java deleted file mode 100644 index 4e9953b..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java +++ /dev/null @@ -1,36 +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.data; - -import org.apache.olingo.commons.api.data.Annotation; - -public class AnnotationImpl extends AbstractValuable implements Annotation { - - private String term; - - @Override - public String getTerm() { - return term; - } - - @Override - public void setTerm(final String term) { - this.term = term; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java deleted file mode 100644 index c50f51a..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.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.core.data; - -import org.apache.olingo.commons.api.data.Annotation; -import org.apache.olingo.commons.api.data.Link; -import org.apache.olingo.commons.api.data.ComplexValue; -import org.apache.olingo.commons.api.data.Property; - -import java.util.ArrayList; -import java.util.List; - -public class ComplexValueImpl implements ComplexValue { - - private final List<Property> value = new ArrayList<Property>(); - private final List<Link> associationLinks = new ArrayList<Link>(); - private final List<Link> navigationLinks = new ArrayList<Link>(); - private final List<Link> bindingLinks = new ArrayList<Link>(); - private final List<Annotation> annotations = new ArrayList<Annotation>(); - - @Override - public List<Property> getValue() { - return value; - } - - private Link getOneByTitle(final String name, final List<Link> links) { - Link result = null; - - for (Link link : links) { - if (name.equals(link.getTitle())) { - result = link; - } - } - - return result; - } - - @Override - public Link getAssociationLink(final String name) { - return getOneByTitle(name, associationLinks); - } - - @Override - public List<Link> getAssociationLinks() { - return associationLinks; - } - - @Override - public Link getNavigationLink(final String name) { - return getOneByTitle(name, navigationLinks); - } - - @Override - public List<Link> getNavigationLinks() { - return navigationLinks; - } - - @Override - public List<Annotation> getAnnotations() { - return annotations; - } - - @Override - public Link getNavigationBinding(String name) { - return getOneByTitle(name, bindingLinks); - } - - @Override - public List<Link> getNavigationBindings() { - return bindingLinks; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java deleted file mode 100644 index 657e652..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java +++ /dev/null @@ -1,48 +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.data; - -import org.apache.olingo.commons.api.data.DeletedEntity; - -import java.net.URI; - -public class DeletedEntityImpl extends AbstractAnnotatedObject implements DeletedEntity { - - private URI id; - private Reason reason; - - @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/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaImpl.java deleted file mode 100644 index 3165bd4..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaImpl.java +++ /dev/null @@ -1,48 +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.data; - -import org.apache.olingo.commons.api.data.DeletedEntity; -import org.apache.olingo.commons.api.data.Delta; -import org.apache.olingo.commons.api.data.DeltaLink; - -import java.util.ArrayList; -import java.util.List; - -public class DeltaImpl extends EntitySetImpl implements Delta { - - private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>(); - private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>(); - private final List<DeltaLink> deletedLinks = new ArrayList<DeltaLink>(); - - @Override - public List<DeletedEntity> getDeletedEntities() { - return deletedEntities; - } - - @Override - public List<DeltaLink> getAddedLinks() { - return addedLinks; - } - - @Override - public List<DeltaLink> getDeletedLinks() { - return deletedLinks; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java deleted file mode 100644 index 91a1569..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java +++ /dev/null @@ -1,61 +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.data; - -import org.apache.olingo.commons.api.data.DeltaLink; - -import java.net.URI; - -public class DeltaLinkImpl extends AbstractAnnotatedObject implements DeltaLink { - - private URI source; - private String relationship; - private URI target; - - @Override - public URI getSource() { - return source; - } - - @Override - public void setSource(final URI source) { - this.source = source; - } - - @Override - public String getRelationship() { - return relationship; - } - - @Override - public void setRelationship(final String relationship) { - this.relationship = relationship; - } - - @Override - public URI getTarget() { - return target; - } - - @Override - public void setTarget(final URI target) { - this.target = target; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java deleted file mode 100755 index 38dd748..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java +++ /dev/null @@ -1,204 +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.data; - -import org.apache.olingo.commons.api.data.Entity; -import org.apache.olingo.commons.api.data.Link; -import org.apache.olingo.commons.api.data.Property; -import org.apache.olingo.commons.api.domain.ODataOperation; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -/** - * Class implementing an OData entity. - */ -public class EntityImpl extends AbstractODataObject implements Entity { - - private String eTag; - - private String type; - - private Link readLink; - private Link editLink; - - private final List<Link> associationLinks = new ArrayList<Link>(); - private final List<Link> navigationLinks = new ArrayList<Link>(); - private final List<Link> mediaEditLinks = new ArrayList<Link>(); - private final List<Link> bindingLinks = new ArrayList<Link>(); - - private final List<ODataOperation> operations = new ArrayList<ODataOperation>(); - - private final List<Property> properties = new ArrayList<Property>(); - - private URI mediaContentSource; - private String mediaContentType; - private String mediaETag; - - @Override - public String getETag() { - return eTag; - } - - public void setETag(final String eTag) { - this.eTag = eTag; - } - - @Override - public String getType() { - return type; - } - - @Override - public void setType(final String type) { - this.type = type; - } - - @Override - public Link getSelfLink() { - return readLink; - } - - @Override - public void setSelfLink(final Link readLink) { - this.readLink = readLink; - } - - @Override - public Link getEditLink() { - return editLink; - } - - @Override - public void setEditLink(final Link editLink) { - this.editLink = editLink; - } - - private Link getOneByTitle(final String name, final List<Link> links) { - Link result = null; - - for (Link link : links) { - if (name.equals(link.getTitle())) { - result = link; - } - } - - return result; - } - - @Override - public Link getAssociationLink(final String name) { - return getOneByTitle(name, associationLinks); - } - - @Override - public List<Link> getAssociationLinks() { - return associationLinks; - } - - @Override - public Link getNavigationLink(final String name) { - return getOneByTitle(name, navigationLinks); - } - - @Override - public List<Link> getNavigationLinks() { - return navigationLinks; - } - - @Override - public List<Link> getMediaEditLinks() { - return mediaEditLinks; - } - - @Override - public Link getNavigationBinding(String name) { - return getOneByTitle(name, bindingLinks); - } - - @Override - public List<Link> getNavigationBindings() { - return bindingLinks; - } - - @Override - public List<ODataOperation> getOperations() { - return operations; - } - - @Override - public Entity addProperty(final Property property) { - properties.add(property); - return this; - } - - @Override - public List<Property> getProperties() { - return properties; - } - - @Override - public Property getProperty(final String name) { - Property result = null; - - for (Property property : properties) { - if (name.equals(property.getName())) { - result = property; - } - } - - return result; - } - - @Override - public String getMediaContentType() { - return mediaContentType; - } - - @Override - public void setMediaContentType(final String mediaContentType) { - this.mediaContentType = mediaContentType; - } - - @Override - public URI getMediaContentSource() { - return mediaContentSource; - } - - @Override - public void setMediaContentSource(final URI mediaContentSource) { - this.mediaContentSource = mediaContentSource; - } - - @Override - public String getMediaETag() { - return mediaETag; - } - - @Override - public void setMediaETag(final String eTag) { - mediaETag = eTag; - } - - @Override - public boolean isMediaEntity() { - return mediaContentSource != null; - } -}
