[OLINGO-564] Renamed client edm classes
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/754e23ab Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/754e23ab Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/754e23ab Branch: refs/heads/OLINGO-564 Commit: 754e23abee9918bf6eca6bcbf97e4d1007b0b910 Parents: cceceaf Author: Michael Bolz <[email protected]> Authored: Thu Apr 23 15:57:22 2015 +0200 Committer: Michael Bolz <[email protected]> Committed: Thu Apr 23 15:57:22 2015 +0200 ---------------------------------------------------------------------- .../retrieve/XMLMetadataRequestImpl.java | 10 +- .../edm/xml/AbstractClientEdmDeserializer.java | 62 ++++ .../core/edm/xml/AbstractEdmDeserializer.java | 61 ---- .../olingo/client/core/edm/xml/ActionImpl.java | 68 ---- .../client/core/edm/xml/ActionImportImpl.java | 58 --- .../client/core/edm/xml/AnnotationImpl.java | 67 ---- .../client/core/edm/xml/AnnotationsImpl.java | 62 ---- .../client/core/edm/xml/ClientAction.java | 68 ++++ .../client/core/edm/xml/ClientActionImport.java | 58 +++ .../client/core/edm/xml/ClientAnnotation.java | 67 ++++ .../client/core/edm/xml/ClientAnnotations.java | 62 ++++ .../client/core/edm/xml/ClientComplexType.java | 72 ++++ .../client/core/edm/xml/ClientDataServices.java | 93 +++++ .../olingo/client/core/edm/xml/ClientEdmx.java | 95 +++++ .../core/edm/xml/ClientEntityContainer.java | 72 ++++ .../client/core/edm/xml/ClientEntityKey.java | 63 ++++ .../client/core/edm/xml/ClientEntitySet.java | 65 ++++ .../client/core/edm/xml/ClientEntityType.java | 76 ++++ .../client/core/edm/xml/ClientEnumMember.java | 57 +++ .../client/core/edm/xml/ClientEnumType.java | 65 ++++ .../client/core/edm/xml/ClientFunction.java | 69 ++++ .../core/edm/xml/ClientFunctionImport.java | 64 ++++ .../client/core/edm/xml/ClientInclude.java | 76 ++++ .../core/edm/xml/ClientIncludeAnnotations.java | 88 +++++ .../core/edm/xml/ClientNavigationProperty.java | 80 +++++ .../xml/ClientNavigationPropertyBinding.java | 66 ++++ .../client/core/edm/xml/ClientOnDelete.java | 54 +++ .../client/core/edm/xml/ClientParameter.java | 84 +++++ .../client/core/edm/xml/ClientProperty.java | 88 +++++ .../client/core/edm/xml/ClientPropertyRef.java | 54 +++ .../client/core/edm/xml/ClientReference.java | 98 +++++ .../edm/xml/ClientReferentialConstraint.java | 54 +++ .../client/core/edm/xml/ClientReturnType.java | 78 ++++ .../client/core/edm/xml/ClientSchema.java | 86 +++++ .../client/core/edm/xml/ClientSingleton.java | 62 ++++ .../olingo/client/core/edm/xml/ClientTerm.java | 83 +++++ .../core/edm/xml/ClientTypeDefinition.java | 74 ++++ .../client/core/edm/xml/ClientXMLMetadata.java | 75 ++++ .../client/core/edm/xml/ComplexTypeImpl.java | 72 ---- .../client/core/edm/xml/DataServicesImpl.java | 93 ----- .../olingo/client/core/edm/xml/EdmxImpl.java | 95 ----- .../core/edm/xml/EntityContainerImpl.java | 72 ---- .../client/core/edm/xml/EntityKeyImpl.java | 63 ---- .../client/core/edm/xml/EntitySetImpl.java | 65 ---- .../client/core/edm/xml/EntityTypeImpl.java | 76 ---- .../client/core/edm/xml/EnumMemberImpl.java | 57 --- .../client/core/edm/xml/EnumTypeImpl.java | 65 ---- .../client/core/edm/xml/FunctionImpl.java | 69 ---- .../client/core/edm/xml/FunctionImportImpl.java | 64 ---- .../core/edm/xml/IncludeAnnotationsImpl.java | 88 ----- .../olingo/client/core/edm/xml/IncludeImpl.java | 76 ---- .../edm/xml/NavigationPropertyBindingImpl.java | 66 ---- .../core/edm/xml/NavigationPropertyImpl.java | 80 ----- .../client/core/edm/xml/OnDeleteImpl.java | 54 --- .../client/core/edm/xml/ParameterImpl.java | 84 ----- .../client/core/edm/xml/PropertyImpl.java | 88 ----- .../client/core/edm/xml/PropertyRefImpl.java | 54 --- .../client/core/edm/xml/ReferenceImpl.java | 98 ----- .../core/edm/xml/ReferentialConstraintImpl.java | 54 --- .../client/core/edm/xml/ReturnTypeImpl.java | 78 ---- .../olingo/client/core/edm/xml/SchemaImpl.java | 86 ----- .../client/core/edm/xml/SingletonImpl.java | 62 ---- .../olingo/client/core/edm/xml/TermImpl.java | 83 ----- .../client/core/edm/xml/TypeDefinitionImpl.java | 74 ---- .../client/core/edm/xml/XMLMetadataImpl.java | 75 ---- ...tAnnotatableDynamicAnnotationExpression.java | 38 -- .../AbstractAnnotationExpression.java | 49 --- ...tAnnotatableDynamicAnnotationExpression.java | 38 ++ .../AbstractClientAnnotationExpression.java | 49 +++ ...stractClientDynamicAnnotationExpression.java | 357 +++++++++++++++++++ ...tractClientElementOrAttributeExpression.java | 37 ++ .../AbstractDynamicAnnotationExpression.java | 356 ------------------ .../AbstractElementOrAttributeExpression.java | 37 -- .../edm/xml/annotation/AnnotationPathImpl.java | 27 -- .../core/edm/xml/annotation/ApplyImpl.java | 82 ----- .../core/edm/xml/annotation/CastImpl.java | 139 -------- .../xml/annotation/ClientAnnotationPath.java | 27 ++ .../core/edm/xml/annotation/ClientApply.java | 82 +++++ .../core/edm/xml/annotation/ClientCast.java | 139 ++++++++ .../edm/xml/annotation/ClientCollection.java | 65 ++++ .../ClientConstantAnnotationExpression.java | 52 +++ .../core/edm/xml/annotation/ClientIf.java | 61 ++++ .../core/edm/xml/annotation/ClientIsOf.java | 138 +++++++ .../xml/annotation/ClientLabeledElement.java | 81 +++++ .../ClientLabeledElementReference.java | 28 ++ .../ClientNavigationPropertyPath.java | 28 ++ .../core/edm/xml/annotation/ClientNot.java | 39 ++ .../core/edm/xml/annotation/ClientNull.java | 53 +++ .../core/edm/xml/annotation/ClientPath.java | 27 ++ .../edm/xml/annotation/ClientPropertyPath.java | 27 ++ .../edm/xml/annotation/ClientPropertyValue.java | 82 +++++ .../core/edm/xml/annotation/ClientRecord.java | 78 ++++ ...tTwoParamsOpDynamicAnnotationExpression.java | 62 ++++ .../core/edm/xml/annotation/ClientUrlRef.java | 66 ++++ .../core/edm/xml/annotation/CollectionImpl.java | 65 ---- .../ConstantAnnotationExpressionImpl.java | 52 --- .../client/core/edm/xml/annotation/IfImpl.java | 61 ---- .../core/edm/xml/annotation/IsOfImpl.java | 138 ------- .../edm/xml/annotation/LabeledElementImpl.java | 81 ----- .../annotation/LabeledElementReferenceImpl.java | 28 -- .../annotation/NavigationPropertyPathImpl.java | 27 -- .../client/core/edm/xml/annotation/NotImpl.java | 39 -- .../core/edm/xml/annotation/NullImpl.java | 53 --- .../core/edm/xml/annotation/PathImpl.java | 27 -- .../edm/xml/annotation/PropertyPathImpl.java | 27 -- .../edm/xml/annotation/PropertyValueImpl.java | 82 ----- .../core/edm/xml/annotation/RecordImpl.java | 78 ---- ...ParamsOpDynamicAnnotationExpressionImpl.java | 62 ---- .../core/edm/xml/annotation/UrlRefImpl.java | 66 ---- .../ClientODataDeserializerImpl.java | 6 +- .../olingo/client/core/uri/URIEscapeTest.java | 4 +- .../client/core/uri/v4/FilterFactoryTest.java | 4 +- .../olingo/client/core/v4/MetadataTest.java | 10 +- 113 files changed, 3941 insertions(+), 3938 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java index 20d1da1..510c9e6 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java @@ -31,8 +31,8 @@ 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; import org.apache.olingo.client.api.edm.xml.XMLMetadata; -import org.apache.olingo.client.core.edm.xml.AnnotationsImpl; -import org.apache.olingo.client.core.edm.xml.SchemaImpl; +import org.apache.olingo.client.core.edm.xml.ClientAnnotations; +import org.apache.olingo.client.core.edm.xml.ClientSchema; import org.apache.olingo.commons.api.edm.provider.Annotation; import org.apache.olingo.commons.api.edm.provider.Annotations; import org.apache.olingo.commons.api.edm.provider.Schema; @@ -68,7 +68,7 @@ public class XMLMetadataRequestImpl if (includedSchema != null) { response.getBody().getSchemas().add(includedSchema); if (StringUtils.isNotBlank(include.getAlias())) { - ((SchemaImpl) includedSchema).setAlias(include.getAlias()); + ((ClientSchema) includedSchema).setAlias(include.getAlias()); } } } @@ -77,7 +77,7 @@ public class XMLMetadataRequestImpl for (IncludeAnnotations include : reference.getIncludeAnnotations()) { for (Schema schema : includeMetadata.getSchemas()) { // create empty schema that will be fed with edm:Annotations that match the criteria in IncludeAnnotations - final SchemaImpl forInclusion = new SchemaImpl(); + final ClientSchema forInclusion = new ClientSchema(); forInclusion.setNamespace(schema.getNamespace()); forInclusion.setAlias(schema.getAlias()); @@ -91,7 +91,7 @@ public class XMLMetadataRequestImpl && (StringUtils.isBlank(include.getQualifier()) || include.getQualifier().equals(annotationGroup.getQualifier()))) { - final AnnotationsImpl toBeIncluded = new AnnotationsImpl(); + final ClientAnnotations toBeIncluded = new ClientAnnotations(); toBeIncluded.setTarget(annotationGroup.getTarget()); toBeIncluded.setQualifier(annotationGroup.getQualifier()); // only import annotations with terms matching the given TermNamespace http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractClientEdmDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractClientEdmDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractClientEdmDeserializer.java new file mode 100644 index 0000000..e02c054 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractClientEdmDeserializer.java @@ -0,0 +1,62 @@ +/* + * 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.olingo.client.core.edm.xml.annotation.ClientConstantAnnotationExpression; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser; + +public abstract class AbstractClientEdmDeserializer<T> extends JsonDeserializer<T> { + + protected boolean isAnnotationConstExprConstruct(final JsonParser jp) throws IOException { + return ClientConstantAnnotationExpression.Type.fromString(jp.getCurrentName()) != null; + } + + protected ClientConstantAnnotationExpression parseAnnotationConstExprConstruct(final JsonParser jp) + throws IOException { + final ClientConstantAnnotationExpression constExpr = new ClientConstantAnnotationExpression(); + constExpr.setType(ClientConstantAnnotationExpression.Type.fromString(jp.getCurrentName())); + constExpr.setValue(jp.nextTextValue()); + return constExpr; + } + + protected ClientReturnType parseReturnType(final JsonParser jp, final String elementName) throws IOException { + final ClientReturnType returnType; + if (elementName.equals(((FromXmlParser) jp).getStaxReader().getLocalName())) { + returnType = new ClientReturnType(); + returnType.setType(jp.nextTextValue()); + } else { + jp.nextToken(); + returnType = jp.readValueAs(ClientReturnType.class); + } + return returnType; + } + + protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt) throws IOException; + + @Override + public T deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { + return doDeserialize(jp, ctxt); + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java ---------------------------------------------------------------------- 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 deleted file mode 100644 index 6453431..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.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.olingo.client.core.edm.xml.annotation.ConstantAnnotationExpressionImpl; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser; - -public abstract class AbstractEdmDeserializer<T> extends JsonDeserializer<T> { - - protected boolean isAnnotationConstExprConstruct(final JsonParser jp) throws IOException { - return ConstantAnnotationExpressionImpl.Type.fromString(jp.getCurrentName()) != null; - } - - protected ConstantAnnotationExpressionImpl parseAnnotationConstExprConstruct(final JsonParser jp) throws IOException { - final ConstantAnnotationExpressionImpl constExpr = new ConstantAnnotationExpressionImpl(); - constExpr.setType(ConstantAnnotationExpressionImpl.Type.fromString(jp.getCurrentName())); - constExpr.setValue(jp.nextTextValue()); - return constExpr; - } - - protected ReturnTypeImpl parseReturnType(final JsonParser jp, final String elementName) throws IOException { - final ReturnTypeImpl returnType; - if (elementName.equals(((FromXmlParser) jp).getStaxReader().getLocalName())) { - returnType = new ReturnTypeImpl(); - returnType.setType(jp.nextTextValue()); - } else { - jp.nextToken(); - returnType = jp.readValueAs(ReturnTypeImpl.class); - } - return returnType; - } - - protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt) throws IOException; - - @Override - public T deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { - return doDeserialize(jp, ctxt); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImpl.java deleted file mode 100644 index 3aaedba..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.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.Action; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.IOException; - -@JsonDeserialize(using = ActionImpl.ActionDeserializer.class) -public class ActionImpl extends Action { - - private static final long serialVersionUID = 5321541275349234088L; - - static class ActionDeserializer extends AbstractEdmDeserializer<ActionImpl> { - - @Override - protected ActionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final ActionImpl action = new ActionImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - action.setName(jp.nextTextValue()); - } else if ("IsBound".equals(jp.getCurrentName())) { - action.setBound(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("EntitySetPath".equals(jp.getCurrentName())) { - action.setEntitySetPath(jp.nextTextValue()); - } else if ("Parameter".equals(jp.getCurrentName())) { - jp.nextToken(); - action.getParameters().add(jp.readValueAs(ParameterImpl.class)); - } else if ("ReturnType".equals(jp.getCurrentName())) { - action.setReturnType(parseReturnType(jp, "Action")); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - action.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return action; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImportImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImportImpl.java deleted file mode 100644 index 7b834a0..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImportImpl.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 com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.apache.olingo.commons.api.edm.provider.ActionImport; - -import java.io.IOException; - -@JsonDeserialize(using = ActionImportImpl.ActionImportDeserializer.class) -public class ActionImportImpl extends ActionImport { - - private static final long serialVersionUID = 2971468441177647068L; - - static class ActionImportDeserializer extends AbstractEdmDeserializer<ActionImportImpl> { - - @Override - protected ActionImportImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final ActionImportImpl action = new ActionImportImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Action".equals(jp.getCurrentName())) { - action.setAction(jp.nextTextValue()); - } else if ("Name".equals(jp.getCurrentName())) { - action.setName(jp.nextTextValue()); - } else if ("EntitySet".equals(jp.getCurrentName())) { - action.setEntitySet(jp.nextTextValue()); - } - } - } - - return action; - } - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java deleted file mode 100644 index 95939ec..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java +++ /dev/null @@ -1,67 +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.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import org.apache.olingo.client.core.edm.xml.annotation.AbstractDynamicAnnotationExpression; -import org.apache.olingo.commons.api.edm.provider.Annotation; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -@JsonDeserialize(using = AnnotationImpl.AnnotationDeserializer.class) -public class AnnotationImpl extends Annotation { - - private static final long serialVersionUID = 5464714417411058033L; - - static class AnnotationDeserializer extends AbstractEdmDeserializer<Annotation> { - - @Override - protected Annotation doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final AnnotationImpl annotation = new AnnotationImpl(); - - for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Term".equals(jp.getCurrentName())) { - annotation.setTerm(jp.nextTextValue()); - } else if ("Qualifier".equals(jp.getCurrentName())) { - annotation.setQualifier(jp.nextTextValue()); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - annotation.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } else if (isAnnotationConstExprConstruct(jp)) { - // Constant Expressions - annotation.setExpression(parseAnnotationConstExprConstruct(jp)); - } else { - // Dynamic Expressions - annotation.setExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); - } - } - } - - return annotation; - } - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsImpl.java deleted file mode 100644 index 21aff68..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsImpl.java +++ /dev/null @@ -1,62 +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 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.Annotations; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.IOException; - -@JsonDeserialize(using = AnnotationsImpl.AnnotationsDeserializer.class) -public class AnnotationsImpl extends Annotations { - - private static final long serialVersionUID = -5961207981571644200L; - - static class AnnotationsDeserializer extends AbstractEdmDeserializer<AnnotationsImpl> { - - @Override - protected AnnotationsImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final AnnotationsImpl annotations = new AnnotationsImpl(); - - for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Target".equals(jp.getCurrentName())) { - annotations.setTarget(jp.nextTextValue()); - } else if ("Qualifier".equals(jp.getCurrentName())) { - annotations.setQualifier(jp.nextTextValue()); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - annotations.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return annotations; - } - - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAction.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAction.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAction.java new file mode 100644 index 0000000..57bdad6 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAction.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.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.Action; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientAction.ActionDeserializer.class) +public class ClientAction extends Action { + + private static final long serialVersionUID = 5321541275349234088L; + + static class ActionDeserializer extends AbstractClientEdmDeserializer<ClientAction> { + + @Override + protected ClientAction doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientAction action = new ClientAction(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + action.setName(jp.nextTextValue()); + } else if ("IsBound".equals(jp.getCurrentName())) { + action.setBound(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("EntitySetPath".equals(jp.getCurrentName())) { + action.setEntitySetPath(jp.nextTextValue()); + } else if ("Parameter".equals(jp.getCurrentName())) { + jp.nextToken(); + action.getParameters().add(jp.readValueAs(ClientParameter.class)); + } else if ("ReturnType".equals(jp.getCurrentName())) { + action.setReturnType(parseReturnType(jp, "Action")); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + action.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } + } + } + + return action; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientActionImport.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientActionImport.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientActionImport.java new file mode 100644 index 0000000..8c251f3 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientActionImport.java @@ -0,0 +1,58 @@ +/* + * 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 com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.apache.olingo.commons.api.edm.provider.ActionImport; + +import java.io.IOException; + +@JsonDeserialize(using = ClientActionImport.ActionImportDeserializer.class) +public class ClientActionImport extends ActionImport { + + private static final long serialVersionUID = 2971468441177647068L; + + static class ActionImportDeserializer extends AbstractClientEdmDeserializer<ClientActionImport> { + + @Override + protected ClientActionImport doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientActionImport action = new ClientActionImport(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Action".equals(jp.getCurrentName())) { + action.setAction(jp.nextTextValue()); + } else if ("Name".equals(jp.getCurrentName())) { + action.setName(jp.nextTextValue()); + } else if ("EntitySet".equals(jp.getCurrentName())) { + action.setEntitySet(jp.nextTextValue()); + } + } + } + + return action; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotation.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotation.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotation.java new file mode 100644 index 0000000..85b866d --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotation.java @@ -0,0 +1,67 @@ +/* + * 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.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.olingo.client.core.edm.xml.annotation.AbstractClientDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.provider.Annotation; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientAnnotation.AnnotationDeserializer.class) +public class ClientAnnotation extends Annotation { + + private static final long serialVersionUID = 5464714417411058033L; + + static class AnnotationDeserializer extends AbstractClientEdmDeserializer<Annotation> { + + @Override + protected Annotation doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientAnnotation annotation = new ClientAnnotation(); + + for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Term".equals(jp.getCurrentName())) { + annotation.setTerm(jp.nextTextValue()); + } else if ("Qualifier".equals(jp.getCurrentName())) { + annotation.setQualifier(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + annotation.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } else if (isAnnotationConstExprConstruct(jp)) { + // Constant Expressions + annotation.setExpression(parseAnnotationConstExprConstruct(jp)); + } else { + // Dynamic Expressions + annotation.setExpression(jp.readValueAs(AbstractClientDynamicAnnotationExpression.class)); + } + } + } + + return annotation; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotations.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotations.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotations.java new file mode 100644 index 0000000..55d9cbd --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotations.java @@ -0,0 +1,62 @@ +/* + * 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 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.Annotations; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientAnnotations.AnnotationsDeserializer.class) +public class ClientAnnotations extends Annotations { + + private static final long serialVersionUID = -5961207981571644200L; + + static class AnnotationsDeserializer extends AbstractClientEdmDeserializer<ClientAnnotations> { + + @Override + protected ClientAnnotations doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientAnnotations annotations = new ClientAnnotations(); + + for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Target".equals(jp.getCurrentName())) { + annotations.setTarget(jp.nextTextValue()); + } else if ("Qualifier".equals(jp.getCurrentName())) { + annotations.setQualifier(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + annotations.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } + } + } + + return annotations; + } + + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientComplexType.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientComplexType.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientComplexType.java new file mode 100644 index 0000000..ebc0452 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientComplexType.java @@ -0,0 +1,72 @@ +/* + * 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 >ied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +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.ComplexType; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientComplexType.ComplexTypeDeserializer.class) +public class ClientComplexType extends ComplexType { + + private static final long serialVersionUID = 4076944306925840115L; + + static class ComplexTypeDeserializer extends AbstractClientEdmDeserializer<ComplexType> { + + @Override + protected ComplexType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientComplexType complexType = new ClientComplexType(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + complexType.setName(jp.nextTextValue()); + } else if ("Abstract".equals(jp.getCurrentName())) { + complexType.setAbstract(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("BaseType".equals(jp.getCurrentName())) { + complexType.setBaseType(jp.nextTextValue()); + } else if ("OpenType".equals(jp.getCurrentName())) { + complexType.setOpenType(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("Property".equals(jp.getCurrentName())) { + jp.nextToken(); + complexType.getProperties().add(jp.readValueAs(ClientProperty.class)); + } else if ("NavigationProperty".equals(jp.getCurrentName())) { + jp.nextToken(); + complexType.getNavigationProperties().add(jp.readValueAs(ClientNavigationProperty.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + complexType.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } + } + } + + return complexType; + } + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientDataServices.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientDataServices.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientDataServices.java new file mode 100644 index 0000000..f68c457 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientDataServices.java @@ -0,0 +1,93 @@ +/* + * 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.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.DataServices; +import org.apache.olingo.commons.api.edm.provider.AbstractEdmItem; +import org.apache.olingo.commons.api.edm.provider.Schema; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientDataServices.DataServicesDeserializer.class) +public class ClientDataServices extends AbstractEdmItem implements DataServices { + + private static final long serialVersionUID = 4200317286476885204L; + + private final List<Schema> schemas = new ArrayList<Schema>(); + + private String dataServiceVersion; + + private String maxDataServiceVersion; + + @Override + public String getDataServiceVersion() { + return dataServiceVersion; + } + + public void setDataServiceVersion(final String version) { + this.dataServiceVersion = version; + } + + @Override + public String getMaxDataServiceVersion() { + return maxDataServiceVersion; + } + + public void setMaxDataServiceVersion(final String version) { + this.maxDataServiceVersion = version; + } + + @Override + public List<Schema> getSchemas() { + return schemas; + } + + static class DataServicesDeserializer extends AbstractClientEdmDeserializer<ClientDataServices> { + + @Override + protected ClientDataServices doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientDataServices dataServices = new ClientDataServices(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("DataServiceVersion".equals(jp.getCurrentName())) { + dataServices.setDataServiceVersion(jp.nextTextValue()); + } else if ("MaxDataServiceVersion".equals(jp.getCurrentName())) { + dataServices.setMaxDataServiceVersion(jp.nextTextValue()); + } else if ("Schema".equals(jp.getCurrentName())) { + jp.nextToken(); + dataServices.getSchemas().add(jp.readValueAs(ClientSchema.class)); + } + } + } + + return dataServices; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEdmx.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEdmx.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEdmx.java new file mode 100644 index 0000000..29a399c --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEdmx.java @@ -0,0 +1,95 @@ +/* + * 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.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.DataServices; +import org.apache.olingo.client.api.edm.xml.Edmx; +import org.apache.olingo.client.api.edm.xml.Reference; +import org.apache.olingo.commons.api.edm.provider.AbstractEdmItem; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientEdmx.EdmxDeserializer.class) +public class ClientEdmx extends AbstractEdmItem implements Edmx { + + private static final long serialVersionUID = -6293476719276092572L; + + private final List<Reference> references = new ArrayList<Reference>(); + + private String version; + + private DataServices dataServices; + + @Override + public String getVersion() { + return version; + } + + public void setVersion(final String version) { + this.version = version; + } + + @Override + public DataServices getDataServices() { + return dataServices; + } + + public void setDataServices(final DataServices dataServices) { + this.dataServices = dataServices; + } + + @Override + public List<Reference> getReferences() { + return references; + } + + static class EdmxDeserializer extends AbstractClientEdmDeserializer<ClientEdmx> { + + @Override + protected ClientEdmx doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientEdmx edmx = new ClientEdmx(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Version".equals(jp.getCurrentName())) { + edmx.setVersion(jp.nextTextValue()); + } else if ("DataServices".equals(jp.getCurrentName())) { + jp.nextToken(); + edmx.setDataServices(jp.readValueAs(ClientDataServices.class)); + } else if ("Reference".equals(jp.getCurrentName())) { + jp.nextToken(); + edmx.getReferences().add(jp.readValueAs(ClientReference.class)); + } + } + } + + return edmx; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityContainer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityContainer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityContainer.java new file mode 100644 index 0000000..d91f8d3 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityContainer.java @@ -0,0 +1,72 @@ +/* + * 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 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; + +import java.io.IOException; + +@JsonDeserialize(using = ClientEntityContainer.EntityContainerDeserializer.class) +public class ClientEntityContainer extends EntityContainer { + + private static final long serialVersionUID = 5631432527646955795L; + + static class EntityContainerDeserializer extends AbstractClientEdmDeserializer<ClientEntityContainer> { + + @Override + protected ClientEntityContainer doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientEntityContainer entityContainer = new ClientEntityContainer(); + + 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(ClientEntitySet.class)); + } else if ("Singleton".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getSingletons().add(jp.readValueAs(ClientSingleton.class)); + } else if ("ActionImport".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getActionImports().add(jp.readValueAs(ClientActionImport.class)); + } else if ("FunctionImport".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getFunctionImports().add(jp.readValueAs(ClientFunctionImport.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } + } + } + + return entityContainer; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityKey.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityKey.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityKey.java new file mode 100644 index 0000000..f238699 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityKey.java @@ -0,0 +1,63 @@ +/* + * 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.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 = ClientEntityKey.EntityKeyDeserializer.class) +public class ClientEntityKey extends AbstractEdmItem { + + private static final long serialVersionUID = 520227585458843347L; + + private final List<PropertyRef> propertyRefs = new ArrayList<PropertyRef>(); + + public List<PropertyRef> getPropertyRefs() { + return propertyRefs; + } + + static class EntityKeyDeserializer extends AbstractClientEdmDeserializer<ClientEntityKey> { + @Override + protected ClientEntityKey doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientEntityKey entityKey = new ClientEntityKey(); + + 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(ClientPropertyRef.class)); + } + } + + return entityKey; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntitySet.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntitySet.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntitySet.java new file mode 100644 index 0000000..655f80d --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntitySet.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.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; + +import java.io.IOException; + +@JsonDeserialize(using = ClientEntitySet.EntitySetDeserializer.class) +public class ClientEntitySet extends EntitySet { + + private static final long serialVersionUID = -5553885465204370676L; + + static class EntitySetDeserializer extends AbstractClientEdmDeserializer<EntitySet> { + @Override + protected EntitySet doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientEntitySet entitySet = new ClientEntitySet(); + + 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(ClientNavigationPropertyBinding.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + entitySet.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } + } + } + + return entitySet; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityType.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityType.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityType.java new file mode 100644 index 0000000..9089bc9 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEntityType.java @@ -0,0 +1,76 @@ +/* + * 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 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; + +import java.io.IOException; + +@JsonDeserialize(using = ClientEntityType.EntityTypeDeserializer.class) +public class ClientEntityType extends EntityType { + + private static final long serialVersionUID = -3986417775876689669L; + + static class EntityTypeDeserializer extends AbstractClientEdmDeserializer<EntityType> { + @Override + protected EntityType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientEntityType entityType = new ClientEntityType(); + + 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(); + ClientEntityKey keyImpl = jp.readValueAs(ClientEntityKey.class); + entityType.setKey(keyImpl.getPropertyRefs()); + } else if ("Property".equals(jp.getCurrentName())) { + jp.nextToken(); + entityType.getProperties().add(jp.readValueAs(ClientProperty.class)); + } else if ("NavigationProperty".equals(jp.getCurrentName())) { + jp.nextToken(); + entityType.getNavigationProperties().add(jp.readValueAs(ClientNavigationProperty.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + entityType.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } + } + } + + return entityType; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEnumMember.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEnumMember.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEnumMember.java new file mode 100644 index 0000000..af6f64d --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEnumMember.java @@ -0,0 +1,57 @@ +/* + * 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 com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.apache.olingo.commons.api.edm.provider.EnumMember; + +import java.io.IOException; + +@JsonDeserialize(using = ClientEnumMember.EnumMemberDeserializer.class) +public class ClientEnumMember extends EnumMember { + + private static final long serialVersionUID = -6138606817225829791L; + + static class EnumMemberDeserializer extends AbstractClientEdmDeserializer<EnumMember> { + @Override + protected EnumMember doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final EnumMember member = new EnumMember(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + member.setName(jp.nextTextValue()); + } else if ("Value".equals(jp.getCurrentName())) { + member.setValue(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + member.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } + } + } + return member; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEnumType.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEnumType.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEnumType.java new file mode 100644 index 0000000..284b5c9 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientEnumType.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.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; + +import java.io.IOException; + +@JsonDeserialize(using = ClientEnumType.EnumTypeDeserializer.class) +public class ClientEnumType extends EnumType { + + private static final long serialVersionUID = 9191189755592743333L; + + static class EnumTypeDeserializer extends AbstractClientEdmDeserializer<ClientEnumType> { + @Override + protected ClientEnumType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientEnumType enumType = new ClientEnumType(); + + 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(ClientEnumMember.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + enumType.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } + } + } + + return enumType; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientFunction.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientFunction.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientFunction.java new file mode 100644 index 0000000..c9260f1 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientFunction.java @@ -0,0 +1,69 @@ +/* + * 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 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; + +import java.io.IOException; + +@JsonDeserialize(using = ClientFunction.FunctionDeserializer.class) +public class ClientFunction extends Function { + + private static final long serialVersionUID = -5494898295282843362L; + + static class FunctionDeserializer extends AbstractClientEdmDeserializer<ClientFunction> { + @Override + protected ClientFunction doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientFunction functionImpl = new ClientFunction(); + + 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(ClientParameter.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(ClientAnnotation.class)); + } + } + } + + return functionImpl; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientFunctionImport.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientFunctionImport.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientFunctionImport.java new file mode 100644 index 0000000..3a7230f --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientFunctionImport.java @@ -0,0 +1,64 @@ +/* + * 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 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; + +import java.io.IOException; + +@JsonDeserialize(using = ClientFunctionImport.FunctionImportDeserializer.class) +public class ClientFunctionImport extends FunctionImport { + + private static final long serialVersionUID = -1686801084142932402L; + + static class FunctionImportDeserializer extends AbstractClientEdmDeserializer<ClientFunctionImport> { + @Override + protected ClientFunctionImport doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientFunctionImport functImpImpl = new ClientFunctionImport(); + + 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(ClientAnnotation.class)); + } + } + } + + return functImpImpl; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientInclude.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientInclude.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientInclude.java new file mode 100644 index 0000000..01984e0 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientInclude.java @@ -0,0 +1,76 @@ +/* + * 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 com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.apache.olingo.client.api.edm.xml.Include; +import org.apache.olingo.commons.api.edm.provider.AbstractEdmItem; + +import java.io.IOException; + +@JsonDeserialize(using = ClientInclude.IncludeDeserializer.class) +public class ClientInclude extends AbstractEdmItem implements Include { + + private static final long serialVersionUID = -5450008299655584221L; + + private String namespace; + private String alias; + + @Override + public String getNamespace() { + return namespace; + } + + public void setNamespace(final String namespace) { + this.namespace = namespace; + } + + @Override + public String getAlias() { + return alias; + } + + public void setAlias(final String alias) { + this.alias = alias; + } + + static class IncludeDeserializer extends AbstractClientEdmDeserializer<Include> { + @Override + protected Include doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientInclude include = new ClientInclude(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Namespace".equals(jp.getCurrentName())) { + include.setNamespace(jp.nextTextValue()); + } else if ("Alias".equals(jp.getCurrentName())) { + include.setAlias(jp.nextTextValue()); + } + } + } + return include; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientIncludeAnnotations.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientIncludeAnnotations.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientIncludeAnnotations.java new file mode 100644 index 0000000..4cf80c0 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientIncludeAnnotations.java @@ -0,0 +1,88 @@ +/* + * 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 com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.apache.olingo.client.api.edm.xml.IncludeAnnotations; +import org.apache.olingo.commons.api.edm.provider.AbstractEdmItem; + +import java.io.IOException; + +@JsonDeserialize(using = ClientIncludeAnnotations.IncludeAnnotationsDeserializer.class) +public class ClientIncludeAnnotations extends AbstractEdmItem implements IncludeAnnotations { + + private static final long serialVersionUID = -8157841387011422396L; + + private String termNamespace; + private String qualifier; + private String targetNamespace; + + @Override + public String getTermNamespace() { + return termNamespace; + } + + public void setTermNamespace(final String termNamespace) { + this.termNamespace = termNamespace; + } + + @Override + public String getQualifier() { + return qualifier; + } + + public void setQualifier(final String qualifier) { + this.qualifier = qualifier; + } + + @Override + public String getTargetNamespace() { + return targetNamespace; + } + + public void setTargetNamespace(final String targetNamespace) { + this.targetNamespace = targetNamespace; + } + + static class IncludeAnnotationsDeserializer extends AbstractClientEdmDeserializer<IncludeAnnotations> { + @Override + protected IncludeAnnotations doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientIncludeAnnotations member = new ClientIncludeAnnotations(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("TermNamespace".equals(jp.getCurrentName())) { + member.setTermNamespace(jp.nextTextValue()); + } else if ("Qualifier".equals(jp.getCurrentName())) { + member.setQualifier(jp.nextTextValue()); + } else if ("TargetNamespace".equals(jp.getCurrentName())) { + member.setTargetNamespace(jp.nextTextValue()); + } + } + } + return member; + } + } +}
