diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java index d45d749f0..645343108 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java @@ -23,15 +23,12 @@ import java.io.IOException; import org.apache.olingo.client.core.edm.xml.annotation.ConstantAnnotationExpressionImpl; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser; public abstract class AbstractEdmDeserializer extends JsonDeserializer { - //protected ODataServiceVersion version; - protected boolean isAnnotationConstExprConstruct(final JsonParser jp) throws IOException { return ConstantAnnotationExpressionImpl.Type.fromString(jp.getCurrentName()) != null; } @@ -44,7 +41,7 @@ public abstract class AbstractEdmDeserializer extends JsonDeserializer { } protected ReturnTypeImpl parseReturnType(final JsonParser jp, final String elementName) throws IOException { - ReturnTypeImpl returnType; + final ReturnTypeImpl returnType; if (elementName.equals(((FromXmlParser) jp).getStaxReader().getLocalName())) { returnType = new ReturnTypeImpl(); returnType.setType(jp.nextTextValue()); @@ -55,15 +52,10 @@ public abstract class AbstractEdmDeserializer extends JsonDeserializer { return returnType; } - protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException; + protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt) throws IOException; @Override - public T deserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - //version = (ODataServiceVersion) ctxt.findInjectableValue(ODataServiceVersion.class.getName(), null, null); + public T deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { return doDeserialize(jp, ctxt); } - } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityContainerDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityContainerDeserializer.java deleted file mode 100644 index c778f4394..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityContainerDeserializer.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class EntityContainerDeserializer extends AbstractEdmDeserializer { - - @Override - protected EntityContainerImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final EntityContainerImpl entityContainer = new EntityContainerImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - entityContainer.setName(jp.nextTextValue()); - } else if ("Extends".equals(jp.getCurrentName())) { - entityContainer.setExtendsContainer(jp.nextTextValue()); - } else if ("EntitySet".equals(jp.getCurrentName())) { - jp.nextToken(); - entityContainer.getEntitySets().add(jp.readValueAs(EntitySetImpl.class)); - } else if ("Singleton".equals(jp.getCurrentName())) { - jp.nextToken(); - entityContainer.getSingletons().add(jp.readValueAs(SingletonImpl.class)); - } else if ("ActionImport".equals(jp.getCurrentName())) { - jp.nextToken(); - entityContainer.getActionImports().add(jp.readValueAs(ActionImportImpl.class)); - } else if ("FunctionImport".equals(jp.getCurrentName())) { - jp.nextToken(); - entityContainer.getFunctionImports().add(jp.readValueAs(FunctionImportImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - entityContainer.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return entityContainer; - } -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityContainerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityContainerImpl.java index c44e64054..4d0abe6ba 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityContainerImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityContainerImpl.java @@ -18,12 +18,55 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; import org.apache.olingo.commons.api.edm.provider.EntityContainer; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = EntityContainerDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = EntityContainerImpl.EntityContainerDeserializer.class) public class EntityContainerImpl extends EntityContainer { private static final long serialVersionUID = 5631432527646955795L; + + static class EntityContainerDeserializer extends AbstractEdmDeserializer { + + @Override + protected EntityContainerImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final EntityContainerImpl entityContainer = new EntityContainerImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + entityContainer.setName(jp.nextTextValue()); + } else if ("Extends".equals(jp.getCurrentName())) { + entityContainer.setExtendsContainer(jp.nextTextValue()); + } else if ("EntitySet".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getEntitySets().add(jp.readValueAs(EntitySetImpl.class)); + } else if ("Singleton".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getSingletons().add(jp.readValueAs(SingletonImpl.class)); + } else if ("ActionImport".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getActionImports().add(jp.readValueAs(ActionImportImpl.class)); + } else if ("FunctionImport".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getFunctionImports().add(jp.readValueAs(FunctionImportImpl.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return entityContainer; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityKeyDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityKeyDeserializer.java deleted file mode 100644 index 561c3ec9a..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityKeyDeserializer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class EntityKeyDeserializer extends AbstractEdmDeserializer { - - @Override - protected EntityKeyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final EntityKeyImpl entityKey = new EntityKeyImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - - if (token == JsonToken.FIELD_NAME && "PropertyRef".equals(jp.getCurrentName())) { - jp.nextToken(); - entityKey.getPropertyRefs().add(jp.readValueAs(PropertyRefImpl.class)); - } - } - - return entityKey; - } -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityKeyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityKeyImpl.java index 17fd381a4..0dc07d0ac 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityKeyImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityKeyImpl.java @@ -18,15 +18,19 @@ */ package org.apache.olingo.client.core.edm.xml; +import java.io.IOException; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; import org.apache.olingo.commons.api.edm.provider.AbstractEdmItem; import org.apache.olingo.commons.api.edm.provider.PropertyRef; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = EntityKeyDeserializer.class) +@JsonDeserialize(using = EntityKeyImpl.EntityKeyDeserializer.class) public class EntityKeyImpl extends AbstractEdmItem { private static final long serialVersionUID = 520227585458843347L; @@ -36,4 +40,24 @@ public class EntityKeyImpl extends AbstractEdmItem { public List getPropertyRefs() { return propertyRefs; } + + static class EntityKeyDeserializer extends AbstractEdmDeserializer { + @Override + protected EntityKeyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final EntityKeyImpl entityKey = new EntityKeyImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + + if (token == JsonToken.FIELD_NAME && "PropertyRef".equals(jp.getCurrentName())) { + jp.nextToken(); + entityKey.getPropertyRefs().add(jp.readValueAs(PropertyRefImpl.class)); + } + } + + return entityKey; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntitySetDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntitySetDeserializer.java deleted file mode 100644 index 53cec31e7..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntitySetDeserializer.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.client.core.edm.xml; - -import java.io.IOException; - -import org.apache.commons.lang3.BooleanUtils; -import org.apache.olingo.commons.api.edm.provider.EntitySet; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class EntitySetDeserializer extends AbstractEdmDeserializer { - - @Override - protected EntitySet doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final EntitySetImpl entitySet = new EntitySetImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - entitySet.setName(jp.nextTextValue()); - } else if ("EntityType".equals(jp.getCurrentName())) { - entitySet.setType(jp.nextTextValue()); - } else if ("IncludeInServiceDocument".equals(jp.getCurrentName())) { - entitySet.setIncludeInServiceDocument(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("NavigationPropertyBinding".equals(jp.getCurrentName())) { - jp.nextToken(); - entitySet.getNavigationPropertyBindings().add(jp.readValueAs(NavigationPropertyBindingImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - entitySet.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return entitySet; - } - -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntitySetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntitySetImpl.java index d27b5a5e2..036822582 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntitySetImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntitySetImpl.java @@ -18,13 +18,48 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; import org.apache.olingo.commons.api.edm.provider.EntitySet; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = EntitySetDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = EntitySetImpl.EntitySetDeserializer.class) public class EntitySetImpl extends EntitySet { private static final long serialVersionUID = -5553885465204370676L; + static class EntitySetDeserializer extends AbstractEdmDeserializer { + @Override + protected EntitySet doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final EntitySetImpl entitySet = new EntitySetImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + entitySet.setName(jp.nextTextValue()); + } else if ("EntityType".equals(jp.getCurrentName())) { + entitySet.setType(jp.nextTextValue()); + } else if ("IncludeInServiceDocument".equals(jp.getCurrentName())) { + entitySet.setIncludeInServiceDocument(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("NavigationPropertyBinding".equals(jp.getCurrentName())) { + jp.nextToken(); + entitySet.getNavigationPropertyBindings().add(jp.readValueAs(NavigationPropertyBindingImpl.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + entitySet.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return entitySet; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeDeserializer.java deleted file mode 100644 index df30d0747..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeDeserializer.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.client.core.edm.xml; - -import java.io.IOException; - -import org.apache.commons.lang3.BooleanUtils; -import org.apache.olingo.commons.api.edm.provider.EntityType; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class EntityTypeDeserializer extends AbstractEdmDeserializer { - - @Override - protected EntityType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final EntityTypeImpl entityType = new EntityTypeImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - entityType.setName(jp.nextTextValue()); - } else if ("Abstract".equals(jp.getCurrentName())) { - entityType.setAbstract(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("BaseType".equals(jp.getCurrentName())) { - entityType.setBaseType(jp.nextTextValue()); - } else if ("OpenType".equals(jp.getCurrentName())) { - entityType.setOpenType(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("HasStream".equals(jp.getCurrentName())) { - entityType.setHasStream(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("Key".equals(jp.getCurrentName())) { - jp.nextToken(); - EntityKeyImpl keyImpl = jp.readValueAs(EntityKeyImpl.class); - entityType.setKey(keyImpl.getPropertyRefs()); - } else if ("Property".equals(jp.getCurrentName())) { - jp.nextToken(); - entityType.getProperties().add(jp.readValueAs(PropertyImpl.class)); - } else if ("NavigationProperty".equals(jp.getCurrentName())) { - jp.nextToken(); - entityType.getNavigationProperties().add(jp.readValueAs(NavigationPropertyImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - entityType.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return entityType; - } -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java index 548e11296..f54ff273f 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java @@ -18,12 +18,59 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; import org.apache.olingo.commons.api.edm.provider.EntityType; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = EntityTypeDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = EntityTypeImpl.EntityTypeDeserializer.class) public class EntityTypeImpl extends EntityType { private static final long serialVersionUID = -3986417775876689669L; + + static class EntityTypeDeserializer extends AbstractEdmDeserializer { + @Override + protected EntityType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final EntityTypeImpl entityType = new EntityTypeImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + entityType.setName(jp.nextTextValue()); + } else if ("Abstract".equals(jp.getCurrentName())) { + entityType.setAbstract(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("BaseType".equals(jp.getCurrentName())) { + entityType.setBaseType(jp.nextTextValue()); + } else if ("OpenType".equals(jp.getCurrentName())) { + entityType.setOpenType(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("HasStream".equals(jp.getCurrentName())) { + entityType.setHasStream(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("Key".equals(jp.getCurrentName())) { + jp.nextToken(); + EntityKeyImpl keyImpl = jp.readValueAs(EntityKeyImpl.class); + entityType.setKey(keyImpl.getPropertyRefs()); + } else if ("Property".equals(jp.getCurrentName())) { + jp.nextToken(); + entityType.getProperties().add(jp.readValueAs(PropertyImpl.class)); + } else if ("NavigationProperty".equals(jp.getCurrentName())) { + jp.nextToken(); + entityType.getNavigationProperties().add(jp.readValueAs(NavigationPropertyImpl.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + entityType.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return entityType; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumTypeDeserializer.java deleted file mode 100644 index 0f6033a08..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumTypeDeserializer.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; - -import org.apache.commons.lang3.BooleanUtils; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class EnumTypeDeserializer extends AbstractEdmDeserializer { - - @Override - protected EnumTypeImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final EnumTypeImpl enumType = new EnumTypeImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - enumType.setName(jp.nextTextValue()); - } else if ("UnderlyingType".equals(jp.getCurrentName())) { - enumType.setUnderlyingType(jp.nextTextValue()); - } else if ("IsFlags".equals(jp.getCurrentName())) { - enumType.setFlags(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("Member".equals(jp.getCurrentName())) { - jp.nextToken(); - enumType.getMembers().add(jp.readValueAs(EnumMemberImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - enumType.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return enumType; - } -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumTypeImpl.java index 5b01a3f7b..bd05df667 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumTypeImpl.java @@ -18,13 +18,48 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; import org.apache.olingo.commons.api.edm.provider.EnumType; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = EnumTypeDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = EnumTypeImpl.EnumTypeDeserializer.class) public class EnumTypeImpl extends EnumType { private static final long serialVersionUID = 9191189755592743333L; + static class EnumTypeDeserializer extends AbstractEdmDeserializer { + @Override + protected EnumTypeImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final EnumTypeImpl enumType = new EnumTypeImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + enumType.setName(jp.nextTextValue()); + } else if ("UnderlyingType".equals(jp.getCurrentName())) { + enumType.setUnderlyingType(jp.nextTextValue()); + } else if ("IsFlags".equals(jp.getCurrentName())) { + enumType.setFlags(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("Member".equals(jp.getCurrentName())) { + jp.nextToken(); + enumType.getMembers().add(jp.readValueAs(EnumMemberImpl.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + enumType.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return enumType; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionDeserializer.java deleted file mode 100644 index 9d753fba2..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionDeserializer.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; - -import org.apache.commons.lang3.BooleanUtils; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class FunctionDeserializer extends AbstractEdmDeserializer { - - @Override - protected FunctionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final FunctionImpl functionImpl = new FunctionImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - functionImpl.setName(jp.nextTextValue()); - } else if ("IsBound".equals(jp.getCurrentName())) { - functionImpl.setBound(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("IsComposable".equals(jp.getCurrentName())) { - functionImpl.setComposable(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("EntitySetPath".equals(jp.getCurrentName())) { - functionImpl.setEntitySetPath(jp.nextTextValue()); - } else if ("Parameter".equals(jp.getCurrentName())) { - jp.nextToken(); - functionImpl.getParameters().add(jp.readValueAs(ParameterImpl.class)); - } else if ("ReturnType".equals(jp.getCurrentName())) { - functionImpl.setReturnType(parseReturnType(jp, "Function")); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - functionImpl.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return functionImpl; - } -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImpl.java index b795cb69c..d1e1d2cc3 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImpl.java @@ -18,13 +18,52 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; import org.apache.olingo.commons.api.edm.provider.Function; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = FunctionDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = FunctionImpl.FunctionDeserializer.class) public class FunctionImpl extends Function { private static final long serialVersionUID = -5494898295282843362L; + static class FunctionDeserializer extends AbstractEdmDeserializer { + @Override + protected FunctionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final FunctionImpl functionImpl = new FunctionImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + functionImpl.setName(jp.nextTextValue()); + } else if ("IsBound".equals(jp.getCurrentName())) { + functionImpl.setBound(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("IsComposable".equals(jp.getCurrentName())) { + functionImpl.setComposable(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("EntitySetPath".equals(jp.getCurrentName())) { + functionImpl.setEntitySetPath(jp.nextTextValue()); + } else if ("Parameter".equals(jp.getCurrentName())) { + jp.nextToken(); + functionImpl.getParameters().add(jp.readValueAs(ParameterImpl.class)); + } else if ("ReturnType".equals(jp.getCurrentName())) { + functionImpl.setReturnType(parseReturnType(jp, "Function")); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + functionImpl.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return functionImpl; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImportDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImportDeserializer.java deleted file mode 100644 index c6af64128..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImportDeserializer.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; - -import org.apache.commons.lang3.BooleanUtils; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class FunctionImportDeserializer extends AbstractEdmDeserializer { - - @Override - protected FunctionImportImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final FunctionImportImpl functImpImpl = new FunctionImportImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - functImpImpl.setName(jp.nextTextValue()); - } else if ("Function".equals(jp.getCurrentName())) { - functImpImpl.setFunction(jp.nextTextValue()); - } else if ("EntitySet".equals(jp.getCurrentName())) { - functImpImpl.setEntitySet(jp.nextTextValue()); - } else if ("IncludeInServiceDocument".equals(jp.getCurrentName())) { - functImpImpl.setIncludeInServiceDocument(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - functImpImpl.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return functImpImpl; - } -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImportImpl.java index 460c94ccf..35916982e 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImportImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImportImpl.java @@ -18,12 +18,47 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; import org.apache.olingo.commons.api.edm.provider.FunctionImport; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = FunctionImportDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = FunctionImportImpl.FunctionImportDeserializer.class) public class FunctionImportImpl extends FunctionImport { private static final long serialVersionUID = -1686801084142932402L; + + static class FunctionImportDeserializer extends AbstractEdmDeserializer { + @Override + protected FunctionImportImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final FunctionImportImpl functImpImpl = new FunctionImportImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + functImpImpl.setName(jp.nextTextValue()); + } else if ("Function".equals(jp.getCurrentName())) { + functImpImpl.setFunction(jp.nextTextValue()); + } else if ("EntitySet".equals(jp.getCurrentName())) { + functImpImpl.setEntitySet(jp.nextTextValue()); + } else if ("IncludeInServiceDocument".equals(jp.getCurrentName())) { + functImpImpl.setIncludeInServiceDocument(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + functImpImpl.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return functImpImpl; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ParameterDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ParameterDeserializer.java deleted file mode 100644 index 7ca059e23..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ParameterDeserializer.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; - -import org.apache.commons.lang3.BooleanUtils; -import org.apache.olingo.commons.api.edm.geo.SRID; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class ParameterDeserializer extends AbstractEdmDeserializer { - - @Override - protected ParameterImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final ParameterImpl parameter = new ParameterImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - parameter.setName(jp.nextTextValue()); - } else if ("Type".equals(jp.getCurrentName())) { - String metadataTypeName = jp.nextTextValue(); - if (metadataTypeName.startsWith("Collection(")) { - parameter.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1, - metadataTypeName.length() - 1)); - parameter.setCollection(true); - } else { - parameter.setType(metadataTypeName); - parameter.setCollection(false); - } - } else if ("Nullable".equals(jp.getCurrentName())) { - parameter.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("MaxLength".equals(jp.getCurrentName())) { - final String maxLenght = jp.nextTextValue(); - parameter.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); - } else if ("Precision".equals(jp.getCurrentName())) { - parameter.setPrecision(Integer.valueOf(jp.nextTextValue())); - } else if ("Scale".equals(jp.getCurrentName())) { - final String scale = jp.nextTextValue(); - parameter.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); - } else if ("SRID".equals(jp.getCurrentName())) { - final String srid = jp.nextTextValue(); - if (srid != null) { - parameter.setSrid(SRID.valueOf(srid)); - } - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - parameter.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return parameter; - } - -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ParameterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ParameterImpl.java index e7f74dbc2..fb0b5f61d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ParameterImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ParameterImpl.java @@ -18,12 +18,67 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.api.edm.provider.Parameter; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = ParameterDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = ParameterImpl.ParameterDeserializer.class) public class ParameterImpl extends Parameter { private static final long serialVersionUID = 7119478691341167904L; + + static class ParameterDeserializer extends AbstractEdmDeserializer { + @Override + protected ParameterImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ParameterImpl parameter = new ParameterImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + parameter.setName(jp.nextTextValue()); + } else if ("Type".equals(jp.getCurrentName())) { + String metadataTypeName = jp.nextTextValue(); + if (metadataTypeName.startsWith("Collection(")) { + parameter.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1, + metadataTypeName.length() - 1)); + parameter.setCollection(true); + } else { + parameter.setType(metadataTypeName); + parameter.setCollection(false); + } + } else if ("Nullable".equals(jp.getCurrentName())) { + parameter.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("MaxLength".equals(jp.getCurrentName())) { + final String maxLenght = jp.nextTextValue(); + parameter.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + } else if ("Precision".equals(jp.getCurrentName())) { + parameter.setPrecision(Integer.valueOf(jp.nextTextValue())); + } else if ("Scale".equals(jp.getCurrentName())) { + final String scale = jp.nextTextValue(); + parameter.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + } else if ("SRID".equals(jp.getCurrentName())) { + final String srid = jp.nextTextValue(); + if (srid != null) { + parameter.setSrid(SRID.valueOf(srid)); + } + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + parameter.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return parameter; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyDeserializer.java deleted file mode 100644 index 09bada5fa..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyDeserializer.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; - -import org.apache.commons.lang3.BooleanUtils; -import org.apache.olingo.commons.api.edm.geo.SRID; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class PropertyDeserializer extends AbstractEdmDeserializer { - - @Override - protected PropertyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final PropertyImpl property = new org.apache.olingo.client.core.edm.xml.PropertyImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - property.setName(jp.nextTextValue()); - } else if ("Type".equals(jp.getCurrentName())) { - String metadataTypeName = jp.nextTextValue(); - if (metadataTypeName.startsWith("Collection(")) { - property.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1, - metadataTypeName.length() - 1)); - property.setCollection(true); - } else { - property.setType(metadataTypeName); - property.setCollection(false); - } - } else if ("Nullable".equals(jp.getCurrentName())) { - property.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("DefaultValue".equals(jp.getCurrentName())) { - property.setDefaultValue(jp.nextTextValue()); - } else if ("MaxLength".equals(jp.getCurrentName())) { - final String maxLenght = jp.nextTextValue(); - property.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); - } else if ("Precision".equals(jp.getCurrentName())) { - property.setPrecision(Integer.valueOf(jp.nextTextValue())); - } else if ("Scale".equals(jp.getCurrentName())) { - final String scale = jp.nextTextValue(); - property.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); - } else if ("Unicode".equals(jp.getCurrentName())) { - property.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("SRID".equals(jp.getCurrentName())) { - final String srid = jp.nextTextValue(); - if (srid != null) { - property.setSrid(SRID.valueOf(srid)); - } - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - property.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return property; - } - -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyImpl.java index c7312cd07..1cc18e9d1 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyImpl.java @@ -18,13 +18,71 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.api.edm.provider.Property; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = PropertyDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = PropertyImpl.PropertyDeserializer.class) public class PropertyImpl extends Property { private static final long serialVersionUID = -4521766603286651372L; + static class PropertyDeserializer extends AbstractEdmDeserializer { + @Override + protected PropertyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final PropertyImpl property = new org.apache.olingo.client.core.edm.xml.PropertyImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + property.setName(jp.nextTextValue()); + } else if ("Type".equals(jp.getCurrentName())) { + String metadataTypeName = jp.nextTextValue(); + if (metadataTypeName.startsWith("Collection(")) { + property.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1, + metadataTypeName.length() - 1)); + property.setCollection(true); + } else { + property.setType(metadataTypeName); + property.setCollection(false); + } + } else if ("Nullable".equals(jp.getCurrentName())) { + property.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("DefaultValue".equals(jp.getCurrentName())) { + property.setDefaultValue(jp.nextTextValue()); + } else if ("MaxLength".equals(jp.getCurrentName())) { + final String maxLenght = jp.nextTextValue(); + property.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + } else if ("Precision".equals(jp.getCurrentName())) { + property.setPrecision(Integer.valueOf(jp.nextTextValue())); + } else if ("Scale".equals(jp.getCurrentName())) { + final String scale = jp.nextTextValue(); + property.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + } else if ("Unicode".equals(jp.getCurrentName())) { + property.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("SRID".equals(jp.getCurrentName())) { + final String srid = jp.nextTextValue(); + if (srid != null) { + property.setSrid(SRID.valueOf(srid)); + } + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + property.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return property; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferenceDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferenceDeserializer.java deleted file mode 100644 index 92f1e5317..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferenceDeserializer.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; -import java.net.URI; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class ReferenceDeserializer extends AbstractEdmDeserializer { - - @Override - protected ReferenceImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final ReferenceImpl reference = new ReferenceImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Uri".equals(jp.getCurrentName())) { - reference.setUri(URI.create(jp.nextTextValue())); - } else if ("Include".equals(jp.getCurrentName())) { - jp.nextToken(); - reference.getIncludes().add(jp.readValueAs( IncludeImpl.class)); - } else if ("IncludeAnnotations".equals(jp.getCurrentName())) { - jp.nextToken(); - reference.getIncludeAnnotations().add(jp.readValueAs( IncludeAnnotationsImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - reference.getAnnotations().add(jp.readValueAs( AnnotationImpl.class)); - } - } - } - - return reference; - } - -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferenceImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferenceImpl.java index 8a90c6112..e4383d333 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferenceImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferenceImpl.java @@ -18,10 +18,14 @@ */ package org.apache.olingo.client.core.edm.xml; +import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; import org.apache.olingo.client.api.edm.xml.Include; import org.apache.olingo.client.api.edm.xml.IncludeAnnotations; import org.apache.olingo.client.api.edm.xml.Reference; @@ -30,17 +34,14 @@ import org.apache.olingo.commons.api.edm.provider.Annotation; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = ReferenceDeserializer.class) +@JsonDeserialize(using = ReferenceImpl.ReferenceDeserializer.class) public class ReferenceImpl extends AbstractEdmItem implements Reference { private static final long serialVersionUID = 7720274712545267654L; private URI uri; - private final List includes = new ArrayList(); - private final List includeAnnotations = new ArrayList(); - private final List annotations = new ArrayList(); @Override @@ -67,4 +68,31 @@ public class ReferenceImpl extends AbstractEdmItem implements Reference { return includeAnnotations; } + static class ReferenceDeserializer extends AbstractEdmDeserializer { + @Override + protected ReferenceImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ReferenceImpl reference = new ReferenceImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Uri".equals(jp.getCurrentName())) { + reference.setUri(URI.create(jp.nextTextValue())); + } else if ("Include".equals(jp.getCurrentName())) { + jp.nextToken(); + reference.getIncludes().add(jp.readValueAs( IncludeImpl.class)); + } else if ("IncludeAnnotations".equals(jp.getCurrentName())) { + jp.nextToken(); + reference.getIncludeAnnotations().add(jp.readValueAs( IncludeAnnotationsImpl.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + reference.getAnnotations().add(jp.readValueAs( AnnotationImpl.class)); + } + } + } + + return reference; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReturnTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReturnTypeDeserializer.java deleted file mode 100644 index 314b7b16f..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReturnTypeDeserializer.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; - -import org.apache.commons.lang3.BooleanUtils; -import org.apache.olingo.commons.api.edm.geo.SRID; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class ReturnTypeDeserializer extends AbstractEdmDeserializer { - - @Override - protected ReturnTypeImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final ReturnTypeImpl returnType = new ReturnTypeImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Type".equals(jp.getCurrentName())) { - String metadataTypeName = jp.nextTextValue(); - if (metadataTypeName.startsWith("Collection(")) { - returnType.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1, - metadataTypeName.length() - 1)); - returnType.setCollection(true); - } else { - returnType.setType(metadataTypeName); - returnType.setCollection(false); - } - } else if ("Nullable".equals(jp.getCurrentName())) { - returnType.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("MaxLength".equals(jp.getCurrentName())) { - final String maxLenght = jp.nextTextValue(); - returnType.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); - } else if ("Precision".equals(jp.getCurrentName())) { - returnType.setPrecision(Integer.valueOf(jp.nextTextValue())); - } else if ("Scale".equals(jp.getCurrentName())) { - final String scale = jp.nextTextValue(); - returnType.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); - } else if ("SRID".equals(jp.getCurrentName())) { - final String srid = jp.nextTextValue(); - if (srid != null) { - returnType.setSrid(SRID.valueOf(srid)); - } - } - } - } - - return returnType; - } - -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReturnTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReturnTypeImpl.java index 69cd715ef..8caeca89d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReturnTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReturnTypeImpl.java @@ -18,12 +18,61 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.api.edm.provider.ReturnType; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = ReturnTypeDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = ReturnTypeImpl.ReturnTypeDeserializer.class) public class ReturnTypeImpl extends ReturnType { private static final long serialVersionUID = 6261092793901735110L; + + static class ReturnTypeDeserializer extends AbstractEdmDeserializer { + @Override + protected ReturnTypeImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ReturnTypeImpl returnType = new ReturnTypeImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Type".equals(jp.getCurrentName())) { + String metadataTypeName = jp.nextTextValue(); + if (metadataTypeName.startsWith("Collection(")) { + returnType.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1, + metadataTypeName.length() - 1)); + returnType.setCollection(true); + } else { + returnType.setType(metadataTypeName); + returnType.setCollection(false); + } + } else if ("Nullable".equals(jp.getCurrentName())) { + returnType.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("MaxLength".equals(jp.getCurrentName())) { + final String maxLenght = jp.nextTextValue(); + returnType.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + } else if ("Precision".equals(jp.getCurrentName())) { + returnType.setPrecision(Integer.valueOf(jp.nextTextValue())); + } else if ("Scale".equals(jp.getCurrentName())) { + final String scale = jp.nextTextValue(); + returnType.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + } else if ("SRID".equals(jp.getCurrentName())) { + final String srid = jp.nextTextValue(); + if (srid != null) { + returnType.setSrid(SRID.valueOf(srid)); + } + } + } + } + + return returnType; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SchemaDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SchemaDeserializer.java deleted file mode 100644 index ea7718a4e..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SchemaDeserializer.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class SchemaDeserializer extends AbstractEdmDeserializer { - - @Override - protected SchemaImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final SchemaImpl schema = new SchemaImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Namespace".equals(jp.getCurrentName())) { - schema.setNamespace(jp.nextTextValue()); - } else if ("Alias".equals(jp.getCurrentName())) { - schema.setAlias(jp.nextTextValue()); - } else if ("ComplexType".equals(jp.getCurrentName())) { - jp.nextToken(); - schema.getComplexTypes().add(jp.readValueAs(ComplexTypeImpl.class)); - } else if ("EntityType".equals(jp.getCurrentName())) { - jp.nextToken(); - schema.getEntityTypes().add(jp.readValueAs(EntityTypeImpl.class)); - } else if ("EnumType".equals(jp.getCurrentName())) { - jp.nextToken(); - schema.getEnumTypes().add(jp.readValueAs(EnumTypeImpl.class)); - } else if ("EntityContainer".equals(jp.getCurrentName())) { - jp.nextToken(); - EntityContainerImpl entityContainer = jp.readValueAs(EntityContainerImpl.class); - schema.setEntityContainer(entityContainer); - } else if ("Action".equals(jp.getCurrentName())) { - jp.nextToken(); - schema.getActions().add(jp.readValueAs(ActionImpl.class)); - } else if ("Function".equals(jp.getCurrentName())) { - jp.nextToken(); - schema.getFunctions().add(jp.readValueAs(FunctionImpl.class)); - } else if ("TypeDefinition".equals(jp.getCurrentName())) { - jp.nextToken(); - schema.getTypeDefinitions().add(jp.readValueAs(TypeDefinitionImpl.class)); - } - } else if ("Annotations".equals(jp.getCurrentName())) { - jp.nextToken(); - schema.getAnnotationGroups().add(jp.readValueAs(AnnotationsImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - schema.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } else if ("Term".equals(jp.getCurrentName())) { - jp.nextToken(); - schema.getTerms().add(jp.readValueAs(TermImpl.class)); - } - } - - return schema; - } -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SchemaImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SchemaImpl.java index f1b4f93ff..da8df2eac 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SchemaImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SchemaImpl.java @@ -18,13 +18,69 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; import org.apache.olingo.commons.api.edm.provider.Schema; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = SchemaDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = SchemaImpl.SchemaDeserializer.class) public class SchemaImpl extends Schema { private static final long serialVersionUID = 1911087363912024939L; + static class SchemaDeserializer extends AbstractEdmDeserializer { + @Override + protected SchemaImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final SchemaImpl schema = new SchemaImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Namespace".equals(jp.getCurrentName())) { + schema.setNamespace(jp.nextTextValue()); + } else if ("Alias".equals(jp.getCurrentName())) { + schema.setAlias(jp.nextTextValue()); + } else if ("ComplexType".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getComplexTypes().add(jp.readValueAs(ComplexTypeImpl.class)); + } else if ("EntityType".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getEntityTypes().add(jp.readValueAs(EntityTypeImpl.class)); + } else if ("EnumType".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getEnumTypes().add(jp.readValueAs(EnumTypeImpl.class)); + } else if ("EntityContainer".equals(jp.getCurrentName())) { + jp.nextToken(); + EntityContainerImpl entityContainer = jp.readValueAs(EntityContainerImpl.class); + schema.setEntityContainer(entityContainer); + } else if ("Action".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getActions().add(jp.readValueAs(ActionImpl.class)); + } else if ("Function".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getFunctions().add(jp.readValueAs(FunctionImpl.class)); + } else if ("TypeDefinition".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getTypeDefinitions().add(jp.readValueAs(TypeDefinitionImpl.class)); + } + } else if ("Annotations".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getAnnotationGroups().add(jp.readValueAs(AnnotationsImpl.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } else if ("Term".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getTerms().add(jp.readValueAs(TermImpl.class)); + } + } + + return schema; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SingletonDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SingletonDeserializer.java deleted file mode 100644 index 5446e8ae4..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SingletonDeserializer.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.client.core.edm.xml; - -import java.io.IOException; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class SingletonDeserializer extends AbstractEdmDeserializer { - - @Override - protected SingletonImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final SingletonImpl singleton = new SingletonImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - singleton.setName(jp.nextTextValue()); - } else if ("Type".equals(jp.getCurrentName())) { - singleton.setType(jp.nextTextValue()); - } else if ("NavigationPropertyBinding".equals(jp.getCurrentName())) { - jp.nextToken(); - singleton.getNavigationPropertyBindings().add( - jp.readValueAs(NavigationPropertyBindingImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - singleton.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return singleton; - } - -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SingletonImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SingletonImpl.java index 1d4c79fe6..c0066baf8 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SingletonImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/SingletonImpl.java @@ -18,13 +18,45 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; import org.apache.olingo.commons.api.edm.provider.Singleton; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = SingletonDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = SingletonImpl.SingletonDeserializer.class) public class SingletonImpl extends Singleton { private static final long serialVersionUID = 1656749615107151921L; + static class SingletonDeserializer extends AbstractEdmDeserializer { + @Override + protected SingletonImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final SingletonImpl singleton = new SingletonImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + singleton.setName(jp.nextTextValue()); + } else if ("Type".equals(jp.getCurrentName())) { + singleton.setType(jp.nextTextValue()); + } else if ("NavigationPropertyBinding".equals(jp.getCurrentName())) { + jp.nextToken(); + singleton.getNavigationPropertyBindings().add( + jp.readValueAs(NavigationPropertyBindingImpl.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + singleton.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return singleton; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermDeserializer.java deleted file mode 100644 index 084c62f5e..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermDeserializer.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; -import java.util.Arrays; - -import org.apache.commons.lang3.BooleanUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.olingo.commons.api.edm.geo.SRID; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class TermDeserializer extends AbstractEdmDeserializer { - - @Override - protected TermImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final TermImpl term = new TermImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - term.setName(jp.nextTextValue()); - } else if ("Type".equals(jp.getCurrentName())) { - term.setType(jp.nextTextValue()); - } else if ("BaseTerm".equals(jp.getCurrentName())) { - term.setBaseTerm(jp.nextTextValue()); - } else if ("DefaultValue".equals(jp.getCurrentName())) { - term.setDefaultValue(jp.nextTextValue()); - } else if ("Nullable".equals(jp.getCurrentName())) { - term.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("MaxLength".equals(jp.getCurrentName())) { - final String maxLenght = jp.nextTextValue(); - term.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); - } else if ("Precision".equals(jp.getCurrentName())) { - term.setPrecision(Integer.valueOf(jp.nextTextValue())); - } else if ("Scale".equals(jp.getCurrentName())) { - final String scale = jp.nextTextValue(); - term.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); - } else if ("SRID".equals(jp.getCurrentName())) { - final String srid = jp.nextTextValue(); - if (srid != null) { - term.setSrid(SRID.valueOf(srid)); - } - } else if ("AppliesTo".equals(jp.getCurrentName())) { - term.getAppliesTo().addAll(Arrays.asList(StringUtils.split(jp.nextTextValue()))); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - term.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return term; - } - -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermImpl.java index fe1839e51..8dbdd9b58 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermImpl.java @@ -18,13 +18,66 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.api.edm.provider.Term; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = TermDeserializer.class) +import java.io.IOException; +import java.util.Arrays; + +@JsonDeserialize(using = TermImpl.TermDeserializer.class) public class TermImpl extends Term { private static final long serialVersionUID = -8350072064720586186L; + static class TermDeserializer extends AbstractEdmDeserializer { + @Override + protected TermImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final TermImpl term = new TermImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + term.setName(jp.nextTextValue()); + } else if ("Type".equals(jp.getCurrentName())) { + term.setType(jp.nextTextValue()); + } else if ("BaseTerm".equals(jp.getCurrentName())) { + term.setBaseTerm(jp.nextTextValue()); + } else if ("DefaultValue".equals(jp.getCurrentName())) { + term.setDefaultValue(jp.nextTextValue()); + } else if ("Nullable".equals(jp.getCurrentName())) { + term.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("MaxLength".equals(jp.getCurrentName())) { + final String maxLenght = jp.nextTextValue(); + term.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + } else if ("Precision".equals(jp.getCurrentName())) { + term.setPrecision(Integer.valueOf(jp.nextTextValue())); + } else if ("Scale".equals(jp.getCurrentName())) { + final String scale = jp.nextTextValue(); + term.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + } else if ("SRID".equals(jp.getCurrentName())) { + final String srid = jp.nextTextValue(); + if (srid != null) { + term.setSrid(SRID.valueOf(srid)); + } + } else if ("AppliesTo".equals(jp.getCurrentName())) { + term.getAppliesTo().addAll(Arrays.asList(StringUtils.split(jp.nextTextValue()))); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + term.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return term; + } + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TypeDefinitionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TypeDefinitionDeserializer.java deleted file mode 100644 index 551a3c7a0..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TypeDefinitionDeserializer.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.client.core.edm.xml; - -import java.io.IOException; - -import org.apache.commons.lang3.BooleanUtils; -import org.apache.olingo.commons.api.edm.geo.SRID; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class TypeDefinitionDeserializer extends AbstractEdmDeserializer { - - @Override - protected TypeDefinitionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final TypeDefinitionImpl typeDefinition = new TypeDefinitionImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - typeDefinition.setName(jp.nextTextValue()); - } else if ("UnderlyingType".equals(jp.getCurrentName())) { - typeDefinition.setUnderlyingType(jp.nextTextValue()); - } else if ("MaxLength".equals(jp.getCurrentName())) { - typeDefinition.setMaxLength(jp.nextIntValue(0)); - } else if ("Unicode".equals(jp.getCurrentName())) { - typeDefinition.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("Precision".equals(jp.getCurrentName())) { - typeDefinition.setPrecision(jp.nextIntValue(0)); - } else if ("Scale".equals(jp.getCurrentName())) { - final String scale = jp.nextTextValue(); - typeDefinition.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); - } else if ("SRID".equals(jp.getCurrentName())) { - final String srid = jp.nextTextValue(); - if (srid != null) { - typeDefinition.setSrid(SRID.valueOf(srid)); - } - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - typeDefinition.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return typeDefinition; - } - -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TypeDefinitionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TypeDefinitionImpl.java index 346a6a8bd..81013ce42 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TypeDefinitionImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TypeDefinitionImpl.java @@ -18,13 +18,57 @@ */ package org.apache.olingo.client.core.edm.xml; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.api.edm.provider.TypeDefinition; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonDeserialize(using = TypeDefinitionDeserializer.class) +import java.io.IOException; + +@JsonDeserialize(using = TypeDefinitionImpl.TypeDefinitionDeserializer.class) public class TypeDefinitionImpl extends TypeDefinition { private static final long serialVersionUID = -902407149079419602L; + static class TypeDefinitionDeserializer extends AbstractEdmDeserializer { + @Override + protected TypeDefinitionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final TypeDefinitionImpl typeDefinition = new TypeDefinitionImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + typeDefinition.setName(jp.nextTextValue()); + } else if ("UnderlyingType".equals(jp.getCurrentName())) { + typeDefinition.setUnderlyingType(jp.nextTextValue()); + } else if ("MaxLength".equals(jp.getCurrentName())) { + typeDefinition.setMaxLength(jp.nextIntValue(0)); + } else if ("Unicode".equals(jp.getCurrentName())) { + typeDefinition.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("Precision".equals(jp.getCurrentName())) { + typeDefinition.setPrecision(jp.nextIntValue(0)); + } else if ("Scale".equals(jp.getCurrentName())) { + final String scale = jp.nextTextValue(); + typeDefinition.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + } else if ("SRID".equals(jp.getCurrentName())) { + final String srid = jp.nextTextValue(); + if (srid != null) { + typeDefinition.setSrid(SRID.valueOf(srid)); + } + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + typeDefinition.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return typeDefinition; + } + } } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java index e360516bb..0b2db0da7 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java @@ -23,11 +23,27 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.util.List; +import com.fasterxml.aalto.stax.InputFactoryImpl; +import com.fasterxml.aalto.stax.OutputFactoryImpl; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.InjectableValues; +import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; +import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; +import com.fasterxml.jackson.dataformat.xml.XmlFactory; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; import org.apache.olingo.client.api.ODataClient; import org.apache.olingo.client.api.edm.xml.XMLMetadata; import org.apache.olingo.client.core.AbstractTest; +import org.apache.olingo.client.core.edm.xml.EdmxImpl; +import org.apache.olingo.client.core.edm.xml.XMLMetadataImpl; import org.apache.olingo.client.core.edm.xml.annotation.ConstantAnnotationExpressionImpl; import org.apache.olingo.client.core.edm.xml.annotation.PathImpl; import org.apache.olingo.commons.api.Constants; @@ -44,7 +60,9 @@ import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.edm.EdmSchema; +import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.annotation.EdmUrlRef; @@ -58,15 +76,18 @@ import org.apache.olingo.commons.api.edm.provider.Function; import org.apache.olingo.commons.api.edm.provider.FunctionImport; import org.apache.olingo.commons.api.edm.provider.Schema; import org.apache.olingo.commons.api.edm.provider.Singleton; +import org.apache.olingo.commons.api.edm.provider.Term; import org.apache.olingo.commons.api.edm.provider.annotation.Apply; import org.apache.olingo.commons.api.edm.provider.annotation.Collection; import org.apache.olingo.commons.api.edm.provider.annotation.ConstantAnnotationExpression; import org.apache.olingo.commons.api.edm.provider.annotation.TwoParamsOpDynamicAnnotationExpression; import org.apache.olingo.commons.api.edm.provider.annotation.UrlRef; import org.apache.olingo.commons.api.format.ODataFormat; +import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean; import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal; import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; +import org.junit.Ignore; import org.junit.Test; public class MetadataTest extends AbstractTest { @@ -396,4 +417,19 @@ public class MetadataTest extends AbstractTest { assertTrue(edmUrlRef.getValue().isDynamic()); assertTrue(edmUrlRef.getValue().asDynamic().isApply()); } + + @Test + public void metadataWithCapabilities() throws Exception { + InputStream input = getClass().getResourceAsStream("Metadata-With-Capabilities.xml"); + final XMLMetadata metadata = getClient().getDeserializer(ODataFormat.XML). + toMetadata(input); + + Schema schema = metadata.getSchema("Capabilities"); + assertNotNull(schema); + assertEquals(23, schema.getTerms().size()); + + final Term deleteRestrictions = schema.getTerm("DeleteRestrictions"); + assertNotNull(deleteRestrictions); + assertEquals("Capabilities.DeleteRestrictionsType", deleteRestrictions.getType()); + } } diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Metadata-With-Capabilities.xml b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Metadata-With-Capabilities.xml new file mode 100644 index 000000000..64999ad87 --- /dev/null +++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/Metadata-With-Capabilities.xml @@ -0,0 +1,323 @@ + + + + + + + + The Capabilities vocabulary aims to provide a way for service authors to describe + certain capabilities of an OData Service. + + + + + There are some capabilities which are strongly recommended for services to support even + though they are optional. Support for $top and $skip is a good example as + supporting these query options helps with performance of a service and are essential. Such + capabilities are assumed to be default capabilities of an OData service even in + the case that a capabilities annotation doesn’t exist. Capabilities annotations are + mainly expected to be used to explicitly specify that a service doesn’t support such + capabilities. Capabilities annotations can as well be used to declaratively + specify the support of such capabilities. + + On the other hand, there are some capabilities that a service may choose to support or + not support and in varying degrees. $filter and $orderby are such good examples. + This vocabulary aims to define terms to specify support or no support for such + capabilities. + + A service is assumed to support by default the following capabilities even though an + annotation doesn’t exist: + - Countability ($count, $inlinecount) + - Client pageability ($top, $skip) + - Expandability ($expand) + - Indexability by key + - Batch support ($batch) + - Navigability of navigation properties + + A service is expected to support the following capabilities. If not supported, the + service is expected to call out the restrictions using annotations: + - Filterability ($filter) + - Sortability ($orderby) + - Queryability of top level entity sets + - Query functions + + A client cannot assume that a service supports certain capabilities. A client can try, but + it needs to be prepared to handle an error in case the following capabilities are not + supported: + - Insertability + - Updatability + - Deletability + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file