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/ClientNavigationProperty.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientNavigationProperty.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientNavigationProperty.java new file mode 100644 index 0000000..cea0c83 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientNavigationProperty.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.NavigationProperty; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientNavigationProperty.NavigationPropertyDeserializer.class) +public class ClientNavigationProperty extends NavigationProperty { + + private static final long serialVersionUID = 6240231735592427582L; + + static class NavigationPropertyDeserializer extends AbstractClientEdmDeserializer<NavigationProperty> { + + @Override + protected NavigationProperty doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final NavigationProperty property = new ClientNavigationProperty(); + + 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(ClientReferentialConstraint.class)); + } else if ("OnDelete".equals(jp.getCurrentName())) { + jp.nextToken(); + property.setOnDelete(jp.readValueAs(ClientOnDelete.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + property.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } + } + } + return property; + } + } +} \ 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/ClientNavigationPropertyBinding.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientNavigationPropertyBinding.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientNavigationPropertyBinding.java new file mode 100644 index 0000000..dae72f3 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientNavigationPropertyBinding.java @@ -0,0 +1,66 @@ +/* + * 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.NavigationPropertyBinding; + +import java.io.IOException; + +@JsonDeserialize(using = ClientNavigationPropertyBinding.NavigationPropertyBindingDeserializer.class) +public class ClientNavigationPropertyBinding extends NavigationPropertyBinding { + + private static final long serialVersionUID = -7056978592235483660L; + + @Override + public NavigationPropertyBinding setPath(final String path) { + super.setPath(path); + return this; + } + + @Override + public NavigationPropertyBinding setTarget(final String target) { + super.setTarget(target); + return this; + } + + static class NavigationPropertyBindingDeserializer extends AbstractClientEdmDeserializer<NavigationPropertyBinding> { + @Override + protected NavigationPropertyBinding doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientNavigationPropertyBinding member = new ClientNavigationPropertyBinding(); + + 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/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientOnDelete.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientOnDelete.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientOnDelete.java new file mode 100644 index 0000000..398fd58 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientOnDelete.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.OnDelete; +import org.apache.olingo.commons.api.edm.provider.OnDeleteAction; + +import java.io.IOException; + +@JsonDeserialize(using = ClientOnDelete.OnDeleteDeserializer.class) +public class ClientOnDelete extends OnDelete { + + private static final long serialVersionUID = -7130889202653716784L; + + static class OnDeleteDeserializer extends AbstractClientEdmDeserializer<OnDelete> { + @Override + protected OnDelete doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final OnDelete ondelete = new ClientOnDelete(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Action".equals(jp.getCurrentName())) { + OnDeleteAction action = OnDeleteAction.valueOf(jp.nextTextValue()); + ondelete.setAction(action); + } + } + } + return ondelete; + } + } +} 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/ClientParameter.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientParameter.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientParameter.java new file mode 100644 index 0000000..34f95cf --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientParameter.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.Parameter; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientParameter.ParameterDeserializer.class) +public class ClientParameter extends Parameter { + + private static final long serialVersionUID = 7119478691341167904L; + + static class ParameterDeserializer extends AbstractClientEdmDeserializer<ClientParameter> { + @Override + protected ClientParameter doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientParameter parameter = new ClientParameter(); + + 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(ClientAnnotation.class)); + } + } + } + + return parameter; + } + } +} 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/ClientProperty.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientProperty.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientProperty.java new file mode 100644 index 0000000..920c383 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientProperty.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.Property; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientProperty.PropertyDeserializer.class) +public class ClientProperty extends Property { + + private static final long serialVersionUID = -4521766603286651372L; + + static class PropertyDeserializer extends AbstractClientEdmDeserializer<ClientProperty> { + @Override + protected ClientProperty doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientProperty property = new ClientProperty(); + + 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(ClientAnnotation.class)); + } + } + } + + return property; + } + } +} 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/ClientPropertyRef.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientPropertyRef.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientPropertyRef.java new file mode 100644 index 0000000..82dc0b0 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientPropertyRef.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.PropertyRef; + +import java.io.IOException; + +@JsonDeserialize(using = ClientPropertyRef.PropertyRefDeserializer.class) +public class ClientPropertyRef extends PropertyRef { + + private static final long serialVersionUID = 1504095609268590326L; + + static class PropertyRefDeserializer extends AbstractClientEdmDeserializer<PropertyRef> { + @Override + protected PropertyRef doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final PropertyRef propertyRef = new ClientPropertyRef(); + + 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/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientReference.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientReference.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientReference.java new file mode 100644 index 0000000..a989ba3 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientReference.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.AbstractEdmItem; +import org.apache.olingo.commons.api.edm.provider.Annotation; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientReference.ReferenceDeserializer.class) +public class ClientReference extends AbstractEdmItem 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<Annotation> annotations = new ArrayList<Annotation>(); + + @Override + public List<Annotation> 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 AbstractClientEdmDeserializer<ClientReference> { + @Override + protected ClientReference doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientReference reference = new ClientReference(); + + 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( ClientInclude.class)); + } else if ("IncludeAnnotations".equals(jp.getCurrentName())) { + jp.nextToken(); + reference.getIncludeAnnotations().add(jp.readValueAs( ClientIncludeAnnotations.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + reference.getAnnotations().add(jp.readValueAs( ClientAnnotation.class)); + } + } + } + + return reference; + } + } +} 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/ClientReferentialConstraint.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientReferentialConstraint.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientReferentialConstraint.java new file mode 100644 index 0000000..9524e74 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientReferentialConstraint.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.ReferentialConstraint; + +import java.io.IOException; + +@JsonDeserialize(using = ClientReferentialConstraint.ReferentialConstraintDeserializer.class) +public class ClientReferentialConstraint extends ReferentialConstraint { + + private static final long serialVersionUID = -5822115908069878139L; + + static class ReferentialConstraintDeserializer extends AbstractClientEdmDeserializer<ReferentialConstraint> { + @Override + protected ReferentialConstraint doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ReferentialConstraint refConst = new ClientReferentialConstraint(); + + 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/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientReturnType.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientReturnType.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientReturnType.java new file mode 100644 index 0000000..587a189 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientReturnType.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.ReturnType; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientReturnType.ReturnTypeDeserializer.class) +public class ClientReturnType extends ReturnType { + + private static final long serialVersionUID = 6261092793901735110L; + + static class ReturnTypeDeserializer extends AbstractClientEdmDeserializer<ClientReturnType> { + @Override + protected ClientReturnType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientReturnType returnType = new ClientReturnType(); + + 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/754e23ab/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientSchema.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientSchema.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientSchema.java new file mode 100644 index 0000000..46e76cd --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientSchema.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.Schema; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientSchema.SchemaDeserializer.class) +public class ClientSchema extends Schema { + + private static final long serialVersionUID = 1911087363912024939L; + + static class SchemaDeserializer extends AbstractClientEdmDeserializer<ClientSchema> { + @Override + protected ClientSchema doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientSchema schema = new ClientSchema(); + + 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(ClientComplexType.class)); + } else if ("EntityType".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getEntityTypes().add(jp.readValueAs(ClientEntityType.class)); + } else if ("EnumType".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getEnumTypes().add(jp.readValueAs(ClientEnumType.class)); + } else if ("EntityContainer".equals(jp.getCurrentName())) { + jp.nextToken(); + ClientEntityContainer entityContainer = jp.readValueAs(ClientEntityContainer.class); + schema.setEntityContainer(entityContainer); + } else if ("Action".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getActions().add(jp.readValueAs(ClientAction.class)); + } else if ("Function".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getFunctions().add(jp.readValueAs(ClientFunction.class)); + } else if ("TypeDefinition".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getTypeDefinitions().add(jp.readValueAs(ClientTypeDefinition.class)); + } + } else if ("Annotations".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getAnnotationGroups().add(jp.readValueAs(ClientAnnotations.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } else if ("Term".equals(jp.getCurrentName())) { + jp.nextToken(); + schema.getTerms().add(jp.readValueAs(ClientTerm.class)); + } + } + + return schema; + } + } +} 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/ClientSingleton.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientSingleton.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientSingleton.java new file mode 100644 index 0000000..efe25ea --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientSingleton.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.Singleton; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientSingleton.SingletonDeserializer.class) +public class ClientSingleton extends Singleton { + + private static final long serialVersionUID = 1656749615107151921L; + + static class SingletonDeserializer extends AbstractClientEdmDeserializer<ClientSingleton> { + @Override + protected ClientSingleton doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientSingleton singleton = new ClientSingleton(); + + 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(ClientNavigationPropertyBinding.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + singleton.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } + } + } + + return singleton; + } + } +} 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/ClientTerm.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientTerm.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientTerm.java new file mode 100644 index 0000000..b343ee9 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientTerm.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.Term; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; +import java.util.Arrays; + +@JsonDeserialize(using = ClientTerm.TermDeserializer.class) +public class ClientTerm extends Term { + + private static final long serialVersionUID = -8350072064720586186L; + + static class TermDeserializer extends AbstractClientEdmDeserializer<ClientTerm> { + @Override + protected ClientTerm doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientTerm term = new ClientTerm(); + + 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(ClientAnnotation.class)); + } + } + } + + return term; + } + } +} 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/ClientTypeDefinition.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientTypeDefinition.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientTypeDefinition.java new file mode 100644 index 0000000..87e2bb8 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientTypeDefinition.java @@ -0,0 +1,74 @@ +/* + * 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.TypeDefinition; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientTypeDefinition.TypeDefinitionDeserializer.class) +public class ClientTypeDefinition extends TypeDefinition { + + private static final long serialVersionUID = -902407149079419602L; + + static class TypeDefinitionDeserializer extends AbstractClientEdmDeserializer<ClientTypeDefinition> { + @Override + protected ClientTypeDefinition doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientTypeDefinition typeDefinition = new ClientTypeDefinition(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + typeDefinition.setName(jp.nextTextValue()); + } else if ("UnderlyingType".equals(jp.getCurrentName())) { + typeDefinition.setUnderlyingType(jp.nextTextValue()); + } else if ("MaxLength".equals(jp.getCurrentName())) { + typeDefinition.setMaxLength(jp.nextIntValue(0)); + } else if ("Unicode".equals(jp.getCurrentName())) { + typeDefinition.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("Precision".equals(jp.getCurrentName())) { + typeDefinition.setPrecision(jp.nextIntValue(0)); + } else if ("Scale".equals(jp.getCurrentName())) { + final String scale = jp.nextTextValue(); + typeDefinition.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + } else if ("SRID".equals(jp.getCurrentName())) { + final String srid = jp.nextTextValue(); + if (srid != null) { + typeDefinition.setSrid(SRID.valueOf(srid)); + } + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + typeDefinition.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); + } + } + } + + return typeDefinition; + } + } +} 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/ClientXMLMetadata.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientXMLMetadata.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientXMLMetadata.java new file mode 100644 index 0000000..680e622 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientXMLMetadata.java @@ -0,0 +1,75 @@ +/* + * 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.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.apache.olingo.client.api.edm.xml.Edmx; +import org.apache.olingo.client.api.edm.xml.Reference; +import org.apache.olingo.client.api.edm.xml.XMLMetadata; +import org.apache.olingo.commons.api.edm.provider.AbstractEdmItem; +import org.apache.olingo.commons.api.edm.provider.Schema; + +/** + * Entry point for access information about EDM metadata. + */ +public class ClientXMLMetadata extends AbstractEdmItem implements XMLMetadata { + + private static final long serialVersionUID = 6025723060298454901L; + protected final Edmx edmx; + + public ClientXMLMetadata(final Edmx edmx) { + this.edmx = edmx; + } + + @Override + public List<Schema> getSchemas() { + return this.edmx.getDataServices().getSchemas(); + } + + @Override + public Schema getSchema(final int index) { + return getSchemas().get(index); + } + + @Override + public Schema getSchema(final String key) { + return getSchemaByNsOrAlias().get(key); + } + + @Override + public Map<String, Schema> getSchemaByNsOrAlias() { + final Map<String, Schema> schemaByNsOrAlias = new HashMap<String, Schema>(); + for (Schema schema : getSchemas()) { + schemaByNsOrAlias.put(schema.getNamespace(), schema); + if (StringUtils.isNotBlank(schema.getAlias())) { + schemaByNsOrAlias.put(schema.getAlias(), schema); + } + } + return schemaByNsOrAlias; + } + + @Override + public List<Reference> getReferences() { + return this.edmx.getReferences(); + } +} 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/ComplexTypeImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeImpl.java deleted file mode 100644 index af0b1d6..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeImpl.java +++ /dev/null @@ -1,72 +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 >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 = ComplexTypeImpl.ComplexTypeDeserializer.class) -public class ComplexTypeImpl extends ComplexType { - - private static final long serialVersionUID = 4076944306925840115L; - - static class ComplexTypeDeserializer extends AbstractEdmDeserializer<ComplexType> { - - @Override - protected ComplexType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final ComplexTypeImpl complexType = new ComplexTypeImpl(); - - 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(PropertyImpl.class)); - } else if ("NavigationProperty".equals(jp.getCurrentName())) { - jp.nextToken(); - complexType.getNavigationProperties().add(jp.readValueAs(NavigationPropertyImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - complexType.getAnnotations().add(jp.readValueAs(AnnotationImpl.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/DataServicesImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesImpl.java deleted file mode 100644 index e446e29..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; -import java.util.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 = DataServicesImpl.DataServicesDeserializer.class) -public class DataServicesImpl 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 AbstractEdmDeserializer<DataServicesImpl> { - - @Override - protected DataServicesImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final DataServicesImpl dataServices = new DataServicesImpl(); - - 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(SchemaImpl.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/EdmxImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxImpl.java deleted file mode 100644 index 6eb7365..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; -import java.util.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 = EdmxImpl.EdmxDeserializer.class) -public class EdmxImpl 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 AbstractEdmDeserializer<EdmxImpl> { - - @Override - protected EdmxImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final EdmxImpl edmx = new EdmxImpl(); - - 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(DataServicesImpl.class)); - } else if ("Reference".equals(jp.getCurrentName())) { - jp.nextToken(); - edmx.getReferences().add(jp.readValueAs(ReferenceImpl.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/EntityContainerImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityContainerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityContainerImpl.java deleted file mode 100644 index 4d0abe6..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityContainerImpl.java +++ /dev/null @@ -1,72 +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.EntityContainer; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.IOException; - -@JsonDeserialize(using = EntityContainerImpl.EntityContainerDeserializer.class) -public class EntityContainerImpl extends EntityContainer { - - private static final long serialVersionUID = 5631432527646955795L; - - static class EntityContainerDeserializer extends AbstractEdmDeserializer<EntityContainerImpl> { - - @Override - protected EntityContainerImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final EntityContainerImpl entityContainer = new EntityContainerImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - entityContainer.setName(jp.nextTextValue()); - } else if ("Extends".equals(jp.getCurrentName())) { - entityContainer.setExtendsContainer(jp.nextTextValue()); - } else if ("EntitySet".equals(jp.getCurrentName())) { - jp.nextToken(); - entityContainer.getEntitySets().add(jp.readValueAs(EntitySetImpl.class)); - } else if ("Singleton".equals(jp.getCurrentName())) { - jp.nextToken(); - entityContainer.getSingletons().add(jp.readValueAs(SingletonImpl.class)); - } else if ("ActionImport".equals(jp.getCurrentName())) { - jp.nextToken(); - entityContainer.getActionImports().add(jp.readValueAs(ActionImportImpl.class)); - } else if ("FunctionImport".equals(jp.getCurrentName())) { - jp.nextToken(); - entityContainer.getFunctionImports().add(jp.readValueAs(FunctionImportImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - entityContainer.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return entityContainer; - } - } -} 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/EntityKeyImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityKeyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityKeyImpl.java deleted file mode 100644 index 0dc07d0..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityKeyImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; -import 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 = EntityKeyImpl.EntityKeyDeserializer.class) -public class EntityKeyImpl 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 AbstractEdmDeserializer<EntityKeyImpl> { - @Override - protected EntityKeyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final EntityKeyImpl entityKey = new EntityKeyImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - - if (token == JsonToken.FIELD_NAME && "PropertyRef".equals(jp.getCurrentName())) { - jp.nextToken(); - entityKey.getPropertyRefs().add(jp.readValueAs(PropertyRefImpl.class)); - } - } - - return entityKey; - } - } -} 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/EntitySetImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntitySetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntitySetImpl.java deleted file mode 100644 index 0368225..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntitySetImpl.java +++ /dev/null @@ -1,65 +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.EntitySet; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.IOException; - -@JsonDeserialize(using = EntitySetImpl.EntitySetDeserializer.class) -public class EntitySetImpl extends EntitySet { - - private static final long serialVersionUID = -5553885465204370676L; - - static class EntitySetDeserializer extends AbstractEdmDeserializer<EntitySet> { - @Override - protected EntitySet doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final EntitySetImpl entitySet = new EntitySetImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - entitySet.setName(jp.nextTextValue()); - } else if ("EntityType".equals(jp.getCurrentName())) { - entitySet.setType(jp.nextTextValue()); - } else if ("IncludeInServiceDocument".equals(jp.getCurrentName())) { - entitySet.setIncludeInServiceDocument(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("NavigationPropertyBinding".equals(jp.getCurrentName())) { - jp.nextToken(); - entitySet.getNavigationPropertyBindings().add(jp.readValueAs(NavigationPropertyBindingImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - entitySet.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return entitySet; - } - } -} 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/EntityTypeImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java deleted file mode 100644 index f54ff27..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java +++ /dev/null @@ -1,76 +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.EntityType; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.IOException; - -@JsonDeserialize(using = EntityTypeImpl.EntityTypeDeserializer.class) -public class EntityTypeImpl extends EntityType { - - private static final long serialVersionUID = -3986417775876689669L; - - static class EntityTypeDeserializer extends AbstractEdmDeserializer<EntityType> { - @Override - protected EntityType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final EntityTypeImpl entityType = new EntityTypeImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - entityType.setName(jp.nextTextValue()); - } else if ("Abstract".equals(jp.getCurrentName())) { - entityType.setAbstract(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("BaseType".equals(jp.getCurrentName())) { - entityType.setBaseType(jp.nextTextValue()); - } else if ("OpenType".equals(jp.getCurrentName())) { - entityType.setOpenType(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("HasStream".equals(jp.getCurrentName())) { - entityType.setHasStream(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("Key".equals(jp.getCurrentName())) { - jp.nextToken(); - EntityKeyImpl keyImpl = jp.readValueAs(EntityKeyImpl.class); - entityType.setKey(keyImpl.getPropertyRefs()); - } else if ("Property".equals(jp.getCurrentName())) { - jp.nextToken(); - entityType.getProperties().add(jp.readValueAs(PropertyImpl.class)); - } else if ("NavigationProperty".equals(jp.getCurrentName())) { - jp.nextToken(); - entityType.getNavigationProperties().add(jp.readValueAs(NavigationPropertyImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - entityType.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return entityType; - } - } -} 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/EnumMemberImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumMemberImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumMemberImpl.java deleted file mode 100644 index 74588a1..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumMemberImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import 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 = EnumMemberImpl.EnumMemberDeserializer.class) -public class EnumMemberImpl extends EnumMember { - - private static final long serialVersionUID = -6138606817225829791L; - - static class EnumMemberDeserializer extends AbstractEdmDeserializer<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(AnnotationImpl.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/EnumTypeImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumTypeImpl.java deleted file mode 100644 index bd05df6..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumTypeImpl.java +++ /dev/null @@ -1,65 +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.EnumType; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.IOException; - -@JsonDeserialize(using = EnumTypeImpl.EnumTypeDeserializer.class) -public class EnumTypeImpl extends EnumType { - - private static final long serialVersionUID = 9191189755592743333L; - - static class EnumTypeDeserializer extends AbstractEdmDeserializer<EnumTypeImpl> { - @Override - protected EnumTypeImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final EnumTypeImpl enumType = new EnumTypeImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - enumType.setName(jp.nextTextValue()); - } else if ("UnderlyingType".equals(jp.getCurrentName())) { - enumType.setUnderlyingType(jp.nextTextValue()); - } else if ("IsFlags".equals(jp.getCurrentName())) { - enumType.setFlags(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("Member".equals(jp.getCurrentName())) { - jp.nextToken(); - enumType.getMembers().add(jp.readValueAs(EnumMemberImpl.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - enumType.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return enumType; - } - } -} 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/FunctionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImpl.java deleted file mode 100644 index d1e1d2c..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/FunctionImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.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 = FunctionImpl.FunctionDeserializer.class) -public class FunctionImpl extends Function { - - private static final long serialVersionUID = -5494898295282843362L; - - static class FunctionDeserializer extends AbstractEdmDeserializer<FunctionImpl> { - @Override - protected FunctionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final FunctionImpl functionImpl = new FunctionImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - functionImpl.setName(jp.nextTextValue()); - } else if ("IsBound".equals(jp.getCurrentName())) { - functionImpl.setBound(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("IsComposable".equals(jp.getCurrentName())) { - functionImpl.setComposable(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("EntitySetPath".equals(jp.getCurrentName())) { - functionImpl.setEntitySetPath(jp.nextTextValue()); - } else if ("Parameter".equals(jp.getCurrentName())) { - jp.nextToken(); - functionImpl.getParameters().add(jp.readValueAs(ParameterImpl.class)); - } else if ("ReturnType".equals(jp.getCurrentName())) { - functionImpl.setReturnType(parseReturnType(jp, "Function")); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - functionImpl.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return functionImpl; - } - } -}
