http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlFunctionImport.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlFunctionImport.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlFunctionImport.java new file mode 100644 index 0000000..6b6a044 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlFunctionImport.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.CsdlFunctionImport; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlFunctionImport.FunctionImportDeserializer.class) +class ClientCsdlFunctionImport extends CsdlFunctionImport { + + private static final long serialVersionUID = -1686801084142932402L; + + static class FunctionImportDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlFunctionImport> { + @Override + protected ClientCsdlFunctionImport doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlFunctionImport functImpImpl = new ClientCsdlFunctionImport(); + + 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(ClientCsdlAnnotation.class)); + } + } + } + + return functImpImpl; + } + } +}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIf.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIf.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIf.java new file mode 100644 index 0000000..1289637 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIf.java @@ -0,0 +1,61 @@ +/* + * 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 org.apache.olingo.commons.api.edm.provider.annotation.AnnotationExpression; +import org.apache.olingo.commons.api.edm.provider.annotation.If; + +class ClientCsdlIf extends AbstractClientCsdlAnnotatableDynamicAnnotationExpression implements If { + + private static final long serialVersionUID = -8571383625077590656L; + + private AnnotationExpression guard; + + private AnnotationExpression _then; + + private AnnotationExpression _else; + + @Override + public AnnotationExpression getGuard() { + return guard; + } + + public void setGuard(final AnnotationExpression guard) { + this.guard = guard; + } + + @Override + public AnnotationExpression getThen() { + return _then; + } + + public void setThen(final AnnotationExpression _then) { + this._then = _then; + } + + @Override + public AnnotationExpression getElse() { + return _else; + } + + public void setElse(final AnnotationExpression _else) { + this._else = _else; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlInclude.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlInclude.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlInclude.java new file mode 100644 index 0000000..541f037 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlInclude.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.CsdlAbstractEdmItem; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlInclude.IncludeDeserializer.class) +class ClientCsdlInclude extends CsdlAbstractEdmItem 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 AbstractClientCsdlEdmDeserializer<Include> { + @Override + protected Include doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlInclude include = new ClientCsdlInclude(); + + 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/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIncludeAnnotations.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIncludeAnnotations.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIncludeAnnotations.java new file mode 100644 index 0000000..87150ea --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIncludeAnnotations.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.CsdlAbstractEdmItem; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlIncludeAnnotations.IncludeAnnotationsDeserializer.class) +class ClientCsdlIncludeAnnotations extends CsdlAbstractEdmItem 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 AbstractClientCsdlEdmDeserializer<IncludeAnnotations> { + @Override + protected IncludeAnnotations doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlIncludeAnnotations member = new ClientCsdlIncludeAnnotations(); + + 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; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIsOf.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIsOf.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIsOf.java new file mode 100644 index 0000000..58b34e0 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlIsOf.java @@ -0,0 +1,136 @@ +/* + * 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.geo.SRID; +import org.apache.olingo.commons.api.edm.provider.annotation.DynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.provider.annotation.IsOf; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlIsOf.IsOfDeserializer.class) +class ClientCsdlIsOf extends AbstractClientCsdlAnnotatableDynamicAnnotationExpression implements IsOf { + + private static final long serialVersionUID = -893355856129761174L; + + private String type; + + private Integer maxLength; + + private Integer precision; + + private Integer scale; + + private SRID srid; + + private DynamicAnnotationExpression value; + + @Override + public String getType() { + return type; + } + + public void setType(final String type) { + this.type = type; + } + + @Override + public Integer getMaxLength() { + return maxLength; + } + + public void setMaxLength(final Integer maxLength) { + this.maxLength = maxLength; + } + + @Override + public Integer getPrecision() { + return precision; + } + + public void setPrecision(final Integer precision) { + this.precision = precision; + } + + @Override + public Integer getScale() { + return scale; + } + + public void setScale(final Integer scale) { + this.scale = scale; + } + + @Override + public SRID getSrid() { + return srid; + } + + public void setSrid(final SRID srid) { + this.srid = srid; + } + + @Override + public DynamicAnnotationExpression getValue() { + return value; + } + + public void setValue(final DynamicAnnotationExpression value) { + this.value = value; + } + + static class IsOfDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlIsOf> { + @Override + protected ClientCsdlIsOf doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlIsOf isof = new ClientCsdlIsOf(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Type".equals(jp.getCurrentName())) { + isof.setType(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + isof.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else if ("MaxLength".equals(jp.getCurrentName())) { + final String maxLenght = jp.nextTextValue(); + isof.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + } else if ("Precision".equals(jp.getCurrentName())) { + isof.setPrecision(Integer.valueOf(jp.nextTextValue())); + } else if ("Scale".equals(jp.getCurrentName())) { + final String scale = jp.nextTextValue(); + isof.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + } else if ("SRID".equals(jp.getCurrentName())) { + final String srid = jp.nextTextValue(); + if (srid != null) { + isof.setSrid(SRID.valueOf(srid)); + } + } else { + isof.setValue(jp.readValueAs(AbstractClientCsdlDynamicAnnotationExpression.class)); + } + } + } + return isof; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlLabeledElement.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlLabeledElement.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlLabeledElement.java new file mode 100644 index 0000000..db1a734 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlLabeledElement.java @@ -0,0 +1,79 @@ +/* + * 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.annotation.DynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.provider.annotation.LabeledElement; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlLabeledElement.LabeledElementDeserializer.class) +class ClientCsdlLabeledElement + extends AbstractClientCsdlAnnotatableDynamicAnnotationExpression implements LabeledElement { + + private static final long serialVersionUID = 4909387630253341824L; + + private String name; + + private DynamicAnnotationExpression value; + + @Override + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + @Override + public DynamicAnnotationExpression getValue() { + return value; + } + + public void setValue(final DynamicAnnotationExpression value) { + this.value = value; + } + + static class LabeledElementDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlLabeledElement> { + @Override + protected ClientCsdlLabeledElement doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlLabeledElement element = new ClientCsdlLabeledElement(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + element.setName(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + element.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else { + element.setValue(jp.readValueAs(AbstractClientCsdlDynamicAnnotationExpression.class)); + } + } + } + return element; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlLabeledElementReference.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlLabeledElementReference.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlLabeledElementReference.java new file mode 100644 index 0000000..b3f1e5a --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlLabeledElementReference.java @@ -0,0 +1,28 @@ +/* + * 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 org.apache.olingo.commons.api.edm.provider.annotation.LabeledElementReference; + +class ClientCsdlLabeledElementReference + extends AbstractClientCsdlElementOrAttributeExpression implements LabeledElementReference { + + private static final long serialVersionUID = 7560525604021670529L; + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationProperty.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationProperty.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationProperty.java new file mode 100644 index 0000000..2fca830 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationProperty.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.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.CsdlNavigationProperty; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlNavigationProperty.NavigationPropertyDeserializer.class) +class ClientCsdlNavigationProperty extends CsdlNavigationProperty { + + private static final long serialVersionUID = 6240231735592427582L; + + static class NavigationPropertyDeserializer extends AbstractClientCsdlEdmDeserializer<CsdlNavigationProperty> { + + @Override + protected CsdlNavigationProperty doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final CsdlNavigationProperty property = new ClientCsdlNavigationProperty(); + + 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 ("Partner".equals(jp.getCurrentName())) { + property.setPartner(jp.nextTextValue()); + } else if ("ContainsTarget".equals(jp.getCurrentName())) { + property.setContainsTarget(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("ReferentialConstraint".equals(jp.getCurrentName())) { + jp.nextToken(); + property.getReferentialConstraints().add(jp.readValueAs(ClientCsdlReferentialConstraint.class)); + } else if ("OnDelete".equals(jp.getCurrentName())) { + jp.nextToken(); + property.setOnDelete(jp.readValueAs(ClientCsdlOnDelete.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + property.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } + } + } + return property; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationPropertyBinding.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationPropertyBinding.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationPropertyBinding.java new file mode 100644 index 0000000..d9da5b0 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationPropertyBinding.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 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.CsdlNavigationPropertyBinding; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlNavigationPropertyBinding.NavigationPropertyBindingDeserializer.class) +class ClientCsdlNavigationPropertyBinding extends CsdlNavigationPropertyBinding { + + private static final long serialVersionUID = -7056978592235483660L; + + @Override + public CsdlNavigationPropertyBinding setPath(final String path) { + super.setPath(path); + return this; + } + + @Override + public CsdlNavigationPropertyBinding setTarget(final String target) { + super.setTarget(target); + return this; + } + + static class NavigationPropertyBindingDeserializer extends + AbstractClientCsdlEdmDeserializer<CsdlNavigationPropertyBinding> { + @Override + protected CsdlNavigationPropertyBinding doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlNavigationPropertyBinding member = new ClientCsdlNavigationPropertyBinding(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Path".equals(jp.getCurrentName())) { + member.setPath(jp.nextTextValue()); + } else if ("Target".equals(jp.getCurrentName())) { + member.setTarget(jp.nextTextValue()); + } + } + } + return member; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationPropertyPath.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationPropertyPath.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationPropertyPath.java new file mode 100644 index 0000000..039af20 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNavigationPropertyPath.java @@ -0,0 +1,28 @@ +/* + * 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 org.apache.olingo.commons.api.edm.provider.annotation.NavigationPropertyPath; + +class ClientCsdlNavigationPropertyPath extends AbstractClientCsdlElementOrAttributeExpression + implements NavigationPropertyPath { + + private static final long serialVersionUID = 879840502446301312L; + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNot.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNot.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNot.java new file mode 100644 index 0000000..b417341 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNot.java @@ -0,0 +1,39 @@ +/* + * 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 org.apache.olingo.commons.api.edm.provider.annotation.DynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.provider.annotation.Not; + +class ClientCsdlNot extends AbstractClientCsdlDynamicAnnotationExpression implements Not { + + private static final long serialVersionUID = -437788415922966812L; + + private DynamicAnnotationExpression expression; + + @Override + public DynamicAnnotationExpression getExpression() { + return expression; + } + + public void setExpression(final DynamicAnnotationExpression expression) { + this.expression = expression; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNull.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNull.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNull.java new file mode 100644 index 0000000..5181c0f --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlNull.java @@ -0,0 +1,51 @@ +/* + * 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.annotation.Null; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlNull.NullDeserializer.class) +class ClientCsdlNull extends AbstractClientCsdlAnnotatableDynamicAnnotationExpression implements Null { + + private static final long serialVersionUID = -3148516847180393142L; + + static class NullDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlNull> { + @Override + protected ClientCsdlNull doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlNull _null = new ClientCsdlNull(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Annotation".equals(jp.getCurrentName())) { + _null.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } + } + } + return _null; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlOnDelete.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlOnDelete.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlOnDelete.java new file mode 100644 index 0000000..6fa992f --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlOnDelete.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.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.CsdlOnDelete; +import org.apache.olingo.commons.api.edm.provider.CsdlOnDeleteAction; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlOnDelete.OnDeleteDeserializer.class) +class ClientCsdlOnDelete extends CsdlOnDelete { + + private static final long serialVersionUID = -7130889202653716784L; + + static class OnDeleteDeserializer extends AbstractClientCsdlEdmDeserializer<CsdlOnDelete> { + @Override + protected CsdlOnDelete doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final CsdlOnDelete ondelete = new ClientCsdlOnDelete(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Action".equals(jp.getCurrentName())) { + CsdlOnDeleteAction action = CsdlOnDeleteAction.valueOf(jp.nextTextValue()); + ondelete.setAction(action); + } + } + } + return ondelete; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlParameter.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlParameter.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlParameter.java new file mode 100644 index 0000000..4df4377 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlParameter.java @@ -0,0 +1,84 @@ +/* + * 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.geo.SRID; +import org.apache.olingo.commons.api.edm.provider.CsdlParameter; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlParameter.ParameterDeserializer.class) +class ClientCsdlParameter extends CsdlParameter { + + private static final long serialVersionUID = 7119478691341167904L; + + static class ParameterDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlParameter> { + @Override + protected ClientCsdlParameter doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlParameter parameter = new ClientCsdlParameter(); + + 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(ClientCsdlAnnotation.class)); + } + } + } + + return parameter; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPath.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPath.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPath.java new file mode 100644 index 0000000..ed4d2bc --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPath.java @@ -0,0 +1,27 @@ +/* + * 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 org.apache.olingo.commons.api.edm.provider.annotation.Path; + +class ClientCsdlPath extends AbstractClientCsdlElementOrAttributeExpression implements Path { + + private static final long serialVersionUID = 6020168217561402545L; + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlProperty.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlProperty.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlProperty.java new file mode 100644 index 0000000..647f386 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlProperty.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 org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.api.edm.provider.CsdlProperty; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlProperty.PropertyDeserializer.class) +class ClientCsdlProperty extends CsdlProperty { + + private static final long serialVersionUID = -4521766603286651372L; + + static class PropertyDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlProperty> { + @Override + protected ClientCsdlProperty doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlProperty property = new ClientCsdlProperty(); + + 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(ClientCsdlAnnotation.class)); + } + } + } + + return property; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyPath.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyPath.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyPath.java new file mode 100644 index 0000000..45b66dc --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyPath.java @@ -0,0 +1,27 @@ +/* + * 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 org.apache.olingo.commons.api.edm.provider.annotation.PropertyPath; + +class ClientCsdlPropertyPath extends AbstractClientCsdlElementOrAttributeExpression implements PropertyPath { + + private static final long serialVersionUID = -9133862135834738470L; + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyRef.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyRef.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyRef.java new file mode 100644 index 0000000..6e32473 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyRef.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.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.CsdlPropertyRef; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlPropertyRef.PropertyRefDeserializer.class) +class ClientCsdlPropertyRef extends CsdlPropertyRef { + + private static final long serialVersionUID = 1504095609268590326L; + + static class PropertyRefDeserializer extends AbstractClientCsdlEdmDeserializer<CsdlPropertyRef> { + @Override + protected CsdlPropertyRef doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final CsdlPropertyRef propertyRef = new ClientCsdlPropertyRef(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + propertyRef.setName(jp.nextTextValue()); + } else if ("Alias".equals(jp.getCurrentName())) { + propertyRef.setAlias(jp.nextTextValue()); + } + } + } + return propertyRef; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyValue.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyValue.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyValue.java new file mode 100644 index 0000000..d1cec62 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlPropertyValue.java @@ -0,0 +1,81 @@ +/* + * 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.annotation.AnnotationExpression; +import org.apache.olingo.commons.api.edm.provider.annotation.PropertyValue; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlPropertyValue.PropertyValueDeserializer.class) +class ClientCsdlPropertyValue extends AbstractClientCsdlAnnotatableDynamicAnnotationExpression + implements PropertyValue { + + private static final long serialVersionUID = -8437649215282645228L; + + private String property; + + private AnnotationExpression value; + + @Override + public String getProperty() { + return property; + } + + public void setProperty(final String property) { + this.property = property; + } + + @Override + public AnnotationExpression getValue() { + return value; + } + + public void setValue(final AnnotationExpression value) { + this.value = value; + } + + static class PropertyValueDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlPropertyValue> { + @Override + protected ClientCsdlPropertyValue doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlPropertyValue propValue = new ClientCsdlPropertyValue(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Property".equals(jp.getCurrentName())) { + propValue.setProperty(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + propValue.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else if (isAnnotationConstExprConstruct(jp)) { + propValue.setValue(parseAnnotationConstExprConstruct(jp)); + } else { + propValue.setValue(jp.readValueAs(AbstractClientCsdlDynamicAnnotationExpression.class)); + } + } + } + return propValue; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlRecord.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlRecord.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlRecord.java new file mode 100644 index 0000000..f1176c9 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlRecord.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 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.annotation.PropertyValue; +import org.apache.olingo.commons.api.edm.provider.annotation.Record; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientCsdlRecord.RecordDeserializer.class) +class ClientCsdlRecord extends AbstractClientCsdlAnnotatableDynamicAnnotationExpression implements Record { + + private static final long serialVersionUID = 4275271751615410709L; + + private String type; + + private final List<PropertyValue> propertyValues = new ArrayList<PropertyValue>(); + + @Override + public String getType() { + return type; + } + + public void setType(final String type) { + this.type = type; + } + + @Override + public List<PropertyValue> getPropertyValues() { + return propertyValues; + } + + static class RecordDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlRecord> { + @Override + protected ClientCsdlRecord doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlRecord record = new ClientCsdlRecord(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Type".equals(jp.getCurrentName())) { + record.setType(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + record.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else { + record.getPropertyValues().add(jp.readValueAs(ClientCsdlPropertyValue.class)); + } + } + } + return record; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReference.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReference.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReference.java new file mode 100644 index 0000000..b0b71e7 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReference.java @@ -0,0 +1,98 @@ +/* + * 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 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; +import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmItem; +import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientCsdlReference.ReferenceDeserializer.class) +class ClientCsdlReference extends CsdlAbstractEdmItem implements Reference { + + private static final long serialVersionUID = 7720274712545267654L; + + private URI uri; + private final List<Include> includes = new ArrayList<Include>(); + private final List<IncludeAnnotations> includeAnnotations = new ArrayList<IncludeAnnotations>(); + private final List<CsdlAnnotation> annotations = new ArrayList<CsdlAnnotation>(); + + @Override + public List<CsdlAnnotation> getAnnotations() { + return annotations; + } + + @Override + public URI getUri() { + return uri; + } + + public void setUri(final URI uri) { + this.uri = uri; + } + + @Override + public List<Include> getIncludes() { + return includes; + } + + @Override + public List<IncludeAnnotations> getIncludeAnnotations() { + return includeAnnotations; + } + + static class ReferenceDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlReference> { + @Override + protected ClientCsdlReference doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlReference reference = new ClientCsdlReference(); + + 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( ClientCsdlInclude.class)); + } else if ("IncludeAnnotations".equals(jp.getCurrentName())) { + jp.nextToken(); + reference.getIncludeAnnotations().add(jp.readValueAs( ClientCsdlIncludeAnnotations.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + reference.getAnnotations().add(jp.readValueAs( ClientCsdlAnnotation.class)); + } + } + } + + return reference; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReferentialConstraint.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReferentialConstraint.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReferentialConstraint.java new file mode 100644 index 0000000..1327766 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReferentialConstraint.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.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.CsdlReferentialConstraint; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlReferentialConstraint.ReferentialConstraintDeserializer.class) +class ClientCsdlReferentialConstraint extends CsdlReferentialConstraint { + + private static final long serialVersionUID = -5822115908069878139L; + + static class ReferentialConstraintDeserializer extends AbstractClientCsdlEdmDeserializer<CsdlReferentialConstraint> { + @Override + protected CsdlReferentialConstraint doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final CsdlReferentialConstraint refConst = new ClientCsdlReferentialConstraint(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Property".equals(jp.getCurrentName())) { + refConst.setProperty(jp.nextTextValue()); + } else if ("ReferencedProperty".equals(jp.getCurrentName())) { + refConst.setReferencedProperty(jp.nextTextValue()); + } + } + } + return refConst; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReturnType.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReturnType.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReturnType.java new file mode 100644 index 0000000..302bd9f --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlReturnType.java @@ -0,0 +1,78 @@ +/* + * 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.geo.SRID; +import org.apache.olingo.commons.api.edm.provider.CsdlReturnType; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlReturnType.ReturnTypeDeserializer.class) +class ClientCsdlReturnType extends CsdlReturnType { + + private static final long serialVersionUID = 6261092793901735110L; + + static class ReturnTypeDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlReturnType> { + @Override + protected ClientCsdlReturnType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlReturnType returnType = new ClientCsdlReturnType(); + + 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; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlSchema.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlSchema.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlSchema.java new file mode 100644 index 0000000..bc141c5 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlSchema.java @@ -0,0 +1,86 @@ +/* + * 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.CsdlSchema; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlSchema.SchemaDeserializer.class) +class ClientCsdlSchema extends CsdlSchema { + + private static final long serialVersionUID = 1911087363912024939L; + + static class SchemaDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlSchema> { + @Override + protected ClientCsdlSchema doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlSchema schema = new ClientCsdlSchema(); + + 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(ClientCsdlComplexType.class)); + } else if ("EntityType".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getEntityTypes().add(jp.readValueAs(ClientCsdlEntityType.class)); + } else if ("EnumType".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getEnumTypes().add(jp.readValueAs(ClientCsdlEnumType.class)); + } else if ("EntityContainer".equals(jp.getCurrentName())) { + jp.nextToken(); + ClientCsdlEntityContainer entityContainer = jp.readValueAs(ClientCsdlEntityContainer.class); + schema.setEntityContainer(entityContainer); + } else if ("Action".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getActions().add(jp.readValueAs(ClientCsdlAction.class)); + } else if ("Function".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getFunctions().add(jp.readValueAs(ClientCsdlFunction.class)); + } else if ("TypeDefinition".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getTypeDefinitions().add(jp.readValueAs(ClientCsdlTypeDefinition.class)); + } + } else if ("Annotations".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getAnnotationGroups().add(jp.readValueAs(ClientCsdlAnnotations.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else if ("Term".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getTerms().add(jp.readValueAs(ClientCsdlTerm.class)); + } + } + + return schema; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlSingleton.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlSingleton.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlSingleton.java new file mode 100644 index 0000000..7a2d097 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlSingleton.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.CsdlSingleton; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlSingleton.SingletonDeserializer.class) +class ClientCsdlSingleton extends CsdlSingleton { + + private static final long serialVersionUID = 1656749615107151921L; + + static class SingletonDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlSingleton> { + @Override + protected ClientCsdlSingleton doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlSingleton singleton = new ClientCsdlSingleton(); + + 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(ClientCsdlNavigationPropertyBinding.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + singleton.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } + } + } + + return singleton; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTerm.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTerm.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTerm.java new file mode 100644 index 0000000..b2cef22 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTerm.java @@ -0,0 +1,83 @@ +/* + * 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.commons.lang3.StringUtils; +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.api.edm.provider.CsdlTerm; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; +import java.util.Arrays; + +@JsonDeserialize(using = ClientCsdlTerm.TermDeserializer.class) +class ClientCsdlTerm extends CsdlTerm { + + private static final long serialVersionUID = -8350072064720586186L; + + static class TermDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlTerm> { + @Override + protected ClientCsdlTerm doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlTerm term = new ClientCsdlTerm(); + + 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(ClientCsdlAnnotation.class)); + } + } + } + + return term; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTwoParamsOpDynamicAnnotationExpression.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTwoParamsOpDynamicAnnotationExpression.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTwoParamsOpDynamicAnnotationExpression.java new file mode 100644 index 0000000..b4d3732 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlTwoParamsOpDynamicAnnotationExpression.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 org.apache.olingo.commons.api.edm.provider.annotation.DynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.provider.annotation.TwoParamsOpDynamicAnnotationExpression; + +class ClientCsdlTwoParamsOpDynamicAnnotationExpression + extends AbstractClientCsdlDynamicAnnotationExpression implements TwoParamsOpDynamicAnnotationExpression { + + private static final long serialVersionUID = 6241842185452451946L; + + private Type type; + + private DynamicAnnotationExpression left; + + private DynamicAnnotationExpression right; + + @Override + public Type getType() { + return type; + } + + public void setType(final Type type) { + this.type = type; + } + + @Override + public DynamicAnnotationExpression getLeftExpression() { + return left; + } + + public void setLeftExpression(final DynamicAnnotationExpression left) { + this.left = left; + } + + @Override + public DynamicAnnotationExpression getRightExpression() { + return right; + } + + public void setRightExpression(final DynamicAnnotationExpression right) { + this.right = right; + } + +}
