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/ClientAnnotationPath.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotationPath.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotationPath.java deleted file mode 100644 index 7644c03..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotationPath.java +++ /dev/null @@ -1,27 +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 org.apache.olingo.commons.api.edm.provider.annotation.AnnotationPath; - -class ClientAnnotationPath extends AbstractClientElementOrAttributeExpression implements AnnotationPath { - - private static final long serialVersionUID = 5360735207353494466L; - -}
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/ClientAnnotations.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotations.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotations.java deleted file mode 100644 index d395706..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientAnnotations.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import org.apache.olingo.commons.api.edm.provider.CsdlAnnotations; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.IOException; - -@JsonDeserialize(using = ClientAnnotations.AnnotationsDeserializer.class) -class ClientAnnotations extends CsdlAnnotations { - - private static final long serialVersionUID = -5961207981571644200L; - - static class AnnotationsDeserializer extends AbstractClientEdmDeserializer<ClientAnnotations> { - - @Override - protected ClientAnnotations doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final ClientAnnotations annotations = new ClientAnnotations(); - - for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Target".equals(jp.getCurrentName())) { - annotations.setTarget(jp.nextTextValue()); - } else if ("Qualifier".equals(jp.getCurrentName())) { - annotations.setQualifier(jp.nextTextValue()); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - annotations.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); - } - } - } - - return annotations; - } - - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientApply.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientApply.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientApply.java deleted file mode 100644 index 9d89fc7..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientApply.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; -import 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.AnnotationExpression; -import org.apache.olingo.commons.api.edm.provider.annotation.Apply; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -@JsonDeserialize(using = ClientApply.ApplyDeserializer.class) -class ClientApply extends AbstractClientAnnotatableDynamicAnnotationExpression implements Apply { - - private static final long serialVersionUID = 4358398303405059879L; - - private String function; - - private final List<AnnotationExpression> parameters = new ArrayList<AnnotationExpression>(); - - @Override - public String getFunction() { - return function; - } - - public void setFunction(final String function) { - this.function = function; - } - - @Override - public List<AnnotationExpression> getParameters() { - return parameters; - } - - static class ApplyDeserializer extends AbstractClientEdmDeserializer<ClientApply> { - - @Override - protected ClientApply doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - final ClientApply apply = new ClientApply(); - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Function".equals(jp.getCurrentName())) { - apply.setFunction(jp.nextTextValue()); - } else if ("Annotation".equals(jp.getCurrentName())) { - apply.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); - } else if (isAnnotationConstExprConstruct(jp)) { - apply.getParameters().add(parseAnnotationConstExprConstruct(jp)); - } else { - apply.getParameters().add(jp.readValueAs(AbstractClientDynamicAnnotationExpression.class)); - } - } - } - - return apply; - } - } -} 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/ClientCast.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCast.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCast.java deleted file mode 100644 index 2160268..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCast.java +++ /dev/null @@ -1,137 +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.geo.SRID; -import org.apache.olingo.commons.api.edm.provider.annotation.Cast; -import org.apache.olingo.commons.api.edm.provider.annotation.DynamicAnnotationExpression; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.IOException; - -@JsonDeserialize(using = ClientCast.CastDeserializer.class) -class ClientCast extends AbstractClientAnnotatableDynamicAnnotationExpression implements Cast { - - private static final long serialVersionUID = 3312415984116005313L; - - 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 CastDeserializer extends AbstractClientEdmDeserializer<ClientCast> { - - @Override - protected ClientCast doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - final ClientCast cast = new ClientCast(); - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Type".equals(jp.getCurrentName())) { - cast.setType(jp.nextTextValue()); - } else if ("Annotation".equals(jp.getCurrentName())) { - cast.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); - } else if ("MaxLength".equals(jp.getCurrentName())) { - final String maxLenght = jp.nextTextValue(); - cast.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); - } else if ("Precision".equals(jp.getCurrentName())) { - cast.setPrecision(Integer.valueOf(jp.nextTextValue())); - } else if ("Scale".equals(jp.getCurrentName())) { - final String scale = jp.nextTextValue(); - cast.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); - } else if ("SRID".equals(jp.getCurrentName())) { - final String srid = jp.nextTextValue(); - if (srid != null) { - cast.setSrid(SRID.valueOf(srid)); - } - } else { - cast.setValue(jp.readValueAs(AbstractClientDynamicAnnotationExpression.class)); - } - } - } - return cast; - } - } -} 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/ClientCollection.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCollection.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCollection.java deleted file mode 100644 index 6dc43a9..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCollection.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.edm.xml; - -import java.io.IOException; -import 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.AnnotationExpression; -import org.apache.olingo.commons.api.edm.provider.annotation.Collection; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -@JsonDeserialize(using = ClientCollection.CollectionDeserializer.class) -class ClientCollection extends AbstractClientDynamicAnnotationExpression implements Collection { - - private static final long serialVersionUID = -724749123749715643L; - - private final List<AnnotationExpression> items = new ArrayList<AnnotationExpression>(); - - @Override - public List<AnnotationExpression> getItems() { - return items; - } - - static class CollectionDeserializer extends AbstractClientEdmDeserializer<ClientCollection> { - @Override - protected ClientCollection doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - final ClientCollection collection = new ClientCollection(); - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if (isAnnotationConstExprConstruct(jp)) { - collection.getItems().add(parseAnnotationConstExprConstruct(jp)); - } else { - collection.getItems().add(jp.readValueAs(AbstractClientDynamicAnnotationExpression.class)); - } - } - } - - return collection; - } - } -} 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/ClientComplexType.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientComplexType.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientComplexType.java deleted file mode 100644 index 1f6e6de..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientComplexType.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.CsdlComplexType; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.IOException; - -@JsonDeserialize(using = ClientComplexType.ComplexTypeDeserializer.class) -class ClientComplexType extends CsdlComplexType { - - private static final long serialVersionUID = 4076944306925840115L; - - static class ComplexTypeDeserializer extends AbstractClientEdmDeserializer<CsdlComplexType> { - - @Override - protected CsdlComplexType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException { - - final ClientComplexType complexType = new ClientComplexType(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - complexType.setName(jp.nextTextValue()); - } else if ("Abstract".equals(jp.getCurrentName())) { - complexType.setAbstract(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("BaseType".equals(jp.getCurrentName())) { - complexType.setBaseType(jp.nextTextValue()); - } else if ("OpenType".equals(jp.getCurrentName())) { - complexType.setOpenType(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("Property".equals(jp.getCurrentName())) { - jp.nextToken(); - complexType.getProperties().add(jp.readValueAs(ClientProperty.class)); - } else if ("NavigationProperty".equals(jp.getCurrentName())) { - jp.nextToken(); - complexType.getNavigationProperties().add(jp.readValueAs(ClientNavigationProperty.class)); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - complexType.getAnnotations().add(jp.readValueAs(ClientAnnotation.class)); - } - } - } - - return complexType; - } - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientConstantAnnotationExpression.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientConstantAnnotationExpression.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientConstantAnnotationExpression.java deleted file mode 100644 index 6ff3fd3..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientConstantAnnotationExpression.java +++ /dev/null @@ -1,52 +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 org.apache.olingo.commons.api.edm.provider.annotation.ConstantAnnotationExpression; - -class ClientConstantAnnotationExpression - extends AbstractClientAnnotationExpression implements ConstantAnnotationExpression { - - private static final long serialVersionUID = 5618680702707972904L; - - private Type type; - - private String value; - - @Override - public Type getType() { - return type; - } - - @Override - public void setType(final Type type) { - this.type = type; - } - - @Override - public String getValue() { - return value; - } - - @Override - public void setValue(final String value) { - this.value = value; - } - -} 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/ClientCsdlAction.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAction.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAction.java new file mode 100644 index 0000000..4514564 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAction.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.commons.api.edm.provider.CsdlAction; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlAction.ActionDeserializer.class) +class ClientCsdlAction extends CsdlAction { + + private static final long serialVersionUID = 5321541275349234088L; + + static class ActionDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlAction> { + + @Override + protected ClientCsdlAction doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlAction action = new ClientCsdlAction(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + action.setName(jp.nextTextValue()); + } else if ("IsBound".equals(jp.getCurrentName())) { + action.setBound(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("EntitySetPath".equals(jp.getCurrentName())) { + action.setEntitySetPath(jp.nextTextValue()); + } else if ("Parameter".equals(jp.getCurrentName())) { + jp.nextToken(); + action.getParameters().add(jp.readValueAs(ClientCsdlParameter.class)); + } else if ("ReturnType".equals(jp.getCurrentName())) { + action.setReturnType(parseReturnType(jp, "Action")); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + action.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } + } + } + + return action; + } + } +} \ 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/ClientCsdlActionImport.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlActionImport.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlActionImport.java new file mode 100644 index 0000000..ee6c69d --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlActionImport.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.apache.olingo.commons.api.edm.provider.CsdlActionImport; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlActionImport.ActionImportDeserializer.class) +class ClientCsdlActionImport extends CsdlActionImport { + + private static final long serialVersionUID = 2971468441177647068L; + + static class ActionImportDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlActionImport> { + + @Override + protected ClientCsdlActionImport doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlActionImport action = new ClientCsdlActionImport(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Action".equals(jp.getCurrentName())) { + action.setAction(jp.nextTextValue()); + } else if ("Name".equals(jp.getCurrentName())) { + action.setName(jp.nextTextValue()); + } else if ("EntitySet".equals(jp.getCurrentName())) { + action.setEntitySet(jp.nextTextValue()); + } + } + } + + return action; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/53b10f6b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAnnotation.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAnnotation.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAnnotation.java new file mode 100644 index 0000000..5413444 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAnnotation.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 java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientCsdlAnnotation.AnnotationDeserializer.class) +class ClientCsdlAnnotation extends CsdlAnnotation { + + private static final long serialVersionUID = 5464714417411058033L; + + static class AnnotationDeserializer extends AbstractClientCsdlEdmDeserializer<CsdlAnnotation> { + + @Override + protected CsdlAnnotation doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlAnnotation annotation = new ClientCsdlAnnotation(); + + for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Term".equals(jp.getCurrentName())) { + annotation.setTerm(jp.nextTextValue()); + } else if ("Qualifier".equals(jp.getCurrentName())) { + annotation.setQualifier(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + annotation.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else if (isAnnotationConstExprConstruct(jp)) { + // Constant Expressions + annotation.setExpression(parseAnnotationConstExprConstruct(jp)); + } else { + // Dynamic Expressions + annotation.setExpression(jp.readValueAs(AbstractClientCsdlDynamicAnnotationExpression.class)); + } + } + } + + return annotation; + } + } +} 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/ClientCsdlAnnotationPath.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAnnotationPath.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAnnotationPath.java new file mode 100644 index 0000000..195f24b --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAnnotationPath.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.AnnotationPath; + +class ClientCsdlAnnotationPath extends AbstractClientCsdlElementOrAttributeExpression implements AnnotationPath { + + private static final long serialVersionUID = 5360735207353494466L; + +} 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/ClientCsdlAnnotations.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAnnotations.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAnnotations.java new file mode 100644 index 0000000..c710a42 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlAnnotations.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.CsdlAnnotations; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlAnnotations.AnnotationsDeserializer.class) +class ClientCsdlAnnotations extends CsdlAnnotations { + + private static final long serialVersionUID = -5961207981571644200L; + + static class AnnotationsDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlAnnotations> { + + @Override + protected ClientCsdlAnnotations doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlAnnotations annotations = new ClientCsdlAnnotations(); + + for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Target".equals(jp.getCurrentName())) { + annotations.setTarget(jp.nextTextValue()); + } else if ("Qualifier".equals(jp.getCurrentName())) { + annotations.setQualifier(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + annotations.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } + } + } + + return annotations; + } + + } + +} 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/ClientCsdlApply.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlApply.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlApply.java new file mode 100644 index 0000000..2d80c98 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlApply.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 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.AnnotationExpression; +import org.apache.olingo.commons.api.edm.provider.annotation.Apply; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientCsdlApply.ApplyDeserializer.class) +class ClientCsdlApply extends AbstractClientCsdlAnnotatableDynamicAnnotationExpression implements Apply { + + private static final long serialVersionUID = 4358398303405059879L; + + private String function; + + private final List<AnnotationExpression> parameters = new ArrayList<AnnotationExpression>(); + + @Override + public String getFunction() { + return function; + } + + public void setFunction(final String function) { + this.function = function; + } + + @Override + public List<AnnotationExpression> getParameters() { + return parameters; + } + + static class ApplyDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlApply> { + + @Override + protected ClientCsdlApply doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlApply apply = new ClientCsdlApply(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Function".equals(jp.getCurrentName())) { + apply.setFunction(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + apply.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else if (isAnnotationConstExprConstruct(jp)) { + apply.getParameters().add(parseAnnotationConstExprConstruct(jp)); + } else { + apply.getParameters().add(jp.readValueAs(AbstractClientCsdlDynamicAnnotationExpression.class)); + } + } + } + + return apply; + } + } +} 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/ClientCsdlCast.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlCast.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlCast.java new file mode 100644 index 0000000..384f6fa --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlCast.java @@ -0,0 +1,137 @@ +/* + * 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.Cast; +import org.apache.olingo.commons.api.edm.provider.annotation.DynamicAnnotationExpression; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlCast.CastDeserializer.class) +class ClientCsdlCast extends AbstractClientCsdlAnnotatableDynamicAnnotationExpression implements Cast { + + private static final long serialVersionUID = 3312415984116005313L; + + 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 CastDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlCast> { + + @Override + protected ClientCsdlCast doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlCast cast = new ClientCsdlCast(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Type".equals(jp.getCurrentName())) { + cast.setType(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + cast.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else if ("MaxLength".equals(jp.getCurrentName())) { + final String maxLenght = jp.nextTextValue(); + cast.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + } else if ("Precision".equals(jp.getCurrentName())) { + cast.setPrecision(Integer.valueOf(jp.nextTextValue())); + } else if ("Scale".equals(jp.getCurrentName())) { + final String scale = jp.nextTextValue(); + cast.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + } else if ("SRID".equals(jp.getCurrentName())) { + final String srid = jp.nextTextValue(); + if (srid != null) { + cast.setSrid(SRID.valueOf(srid)); + } + } else { + cast.setValue(jp.readValueAs(AbstractClientCsdlDynamicAnnotationExpression.class)); + } + } + } + return cast; + } + } +} 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/ClientCsdlCollection.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlCollection.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlCollection.java new file mode 100644 index 0000000..cc9832b --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlCollection.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 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.AnnotationExpression; +import org.apache.olingo.commons.api.edm.provider.annotation.Collection; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientCsdlCollection.CollectionDeserializer.class) +class ClientCsdlCollection extends AbstractClientCsdlDynamicAnnotationExpression implements Collection { + + private static final long serialVersionUID = -724749123749715643L; + + private final List<AnnotationExpression> items = new ArrayList<AnnotationExpression>(); + + @Override + public List<AnnotationExpression> getItems() { + return items; + } + + static class CollectionDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlCollection> { + @Override + protected ClientCsdlCollection doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlCollection collection = new ClientCsdlCollection(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if (isAnnotationConstExprConstruct(jp)) { + collection.getItems().add(parseAnnotationConstExprConstruct(jp)); + } else { + collection.getItems().add(jp.readValueAs(AbstractClientCsdlDynamicAnnotationExpression.class)); + } + } + } + + return collection; + } + } +} 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/ClientCsdlComplexType.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlComplexType.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlComplexType.java new file mode 100644 index 0000000..0b59e99 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlComplexType.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or >ied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.commons.api.edm.provider.CsdlComplexType; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlComplexType.ComplexTypeDeserializer.class) +class ClientCsdlComplexType extends CsdlComplexType { + + private static final long serialVersionUID = 4076944306925840115L; + + static class ComplexTypeDeserializer extends AbstractClientCsdlEdmDeserializer<CsdlComplexType> { + + @Override + protected CsdlComplexType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlComplexType complexType = new ClientCsdlComplexType(); + + 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(ClientCsdlProperty.class)); + } else if ("NavigationProperty".equals(jp.getCurrentName())) { + jp.nextToken(); + complexType.getNavigationProperties().add(jp.readValueAs(ClientCsdlNavigationProperty.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + complexType.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } + } + } + + return complexType; + } + } + +} 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/ClientCsdlConstantAnnotationExpression.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlConstantAnnotationExpression.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlConstantAnnotationExpression.java new file mode 100644 index 0000000..26e067f --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlConstantAnnotationExpression.java @@ -0,0 +1,52 @@ +/* + * 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.ConstantAnnotationExpression; + +class ClientCsdlConstantAnnotationExpression + extends AbstractClientCsdlAnnotationExpression implements ConstantAnnotationExpression { + + private static final long serialVersionUID = 5618680702707972904L; + + private Type type; + + private String value; + + @Override + public Type getType() { + return type; + } + + @Override + public void setType(final Type type) { + this.type = type; + } + + @Override + public String getValue() { + return value; + } + + @Override + public void setValue(final String value) { + this.value = value; + } + +} 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/ClientCsdlDataServices.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlDataServices.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlDataServices.java new file mode 100644 index 0000000..072ad0f --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlDataServices.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.olingo.client.api.edm.xml.DataServices; +import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmItem; +import org.apache.olingo.commons.api.edm.provider.CsdlSchema; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientCsdlDataServices.DataServicesDeserializer.class) +class ClientCsdlDataServices extends CsdlAbstractEdmItem implements DataServices { + + private static final long serialVersionUID = 4200317286476885204L; + + private final List<CsdlSchema> schemas = new ArrayList<CsdlSchema>(); + + 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<CsdlSchema> getSchemas() { + return schemas; + } + + static class DataServicesDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlDataServices> { + + @Override + protected ClientCsdlDataServices doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlDataServices dataServices = new ClientCsdlDataServices(); + + 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(ClientCsdlSchema.class)); + } + } + } + + return dataServices; + } + } +} 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/ClientCsdlEdmx.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEdmx.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEdmx.java new file mode 100644 index 0000000..ba0d26d --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEdmx.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.olingo.client.api.edm.xml.DataServices; +import org.apache.olingo.client.api.edm.xml.Edmx; +import org.apache.olingo.client.api.edm.xml.Reference; +import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmItem; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientCsdlEdmx.EdmxDeserializer.class) +public class ClientCsdlEdmx extends CsdlAbstractEdmItem 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 AbstractClientCsdlEdmDeserializer<ClientCsdlEdmx> { + + @Override + protected ClientCsdlEdmx doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlEdmx edmx = new ClientCsdlEdmx(); + + 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(ClientCsdlDataServices.class)); + } else if ("Reference".equals(jp.getCurrentName())) { + jp.nextToken(); + edmx.getReferences().add(jp.readValueAs(ClientCsdlReference.class)); + } + } + } + + return edmx; + } + } +} 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/ClientCsdlEntityContainer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntityContainer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntityContainer.java new file mode 100644 index 0000000..de83325 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntityContainer.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlEntityContainer.EntityContainerDeserializer.class) +class ClientCsdlEntityContainer extends CsdlEntityContainer { + + private static final long serialVersionUID = 5631432527646955795L; + + static class EntityContainerDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlEntityContainer> { + + @Override + protected ClientCsdlEntityContainer doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlEntityContainer entityContainer = new ClientCsdlEntityContainer(); + + 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(ClientCsdlEntitySet.class)); + } else if ("Singleton".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getSingletons().add(jp.readValueAs(ClientCsdlSingleton.class)); + } else if ("ActionImport".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getActionImports().add(jp.readValueAs(ClientCsdlActionImport.class)); + } else if ("FunctionImport".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getFunctionImports().add(jp.readValueAs(ClientCsdlFunctionImport.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + entityContainer.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } + } + } + + return entityContainer; + } + } +} 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/ClientCsdlEntityKey.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntityKey.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntityKey.java new file mode 100644 index 0000000..7be9a90 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntityKey.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmItem; +import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ClientCsdlEntityKey.EntityKeyDeserializer.class) +class ClientCsdlEntityKey extends CsdlAbstractEdmItem { + + private static final long serialVersionUID = 520227585458843347L; + + private final List<CsdlPropertyRef> propertyRefs = new ArrayList<CsdlPropertyRef>(); + + public List<CsdlPropertyRef> getPropertyRefs() { + return propertyRefs; + } + + static class EntityKeyDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlEntityKey> { + @Override + protected ClientCsdlEntityKey doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlEntityKey entityKey = new ClientCsdlEntityKey(); + + 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(ClientCsdlPropertyRef.class)); + } + } + + return entityKey; + } + } +} 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/ClientCsdlEntitySet.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntitySet.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntitySet.java new file mode 100644 index 0000000..6973a27 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntitySet.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlEntitySet.EntitySetDeserializer.class) +class ClientCsdlEntitySet extends CsdlEntitySet { + + private static final long serialVersionUID = -5553885465204370676L; + + static class EntitySetDeserializer extends AbstractClientCsdlEdmDeserializer<CsdlEntitySet> { + @Override + protected CsdlEntitySet doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlEntitySet entitySet = new ClientCsdlEntitySet(); + + 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(ClientCsdlNavigationPropertyBinding.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + entitySet.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } + } + } + + return entitySet; + } + } +} 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/ClientCsdlEntityType.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntityType.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntityType.java new file mode 100644 index 0000000..f08bcbe --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEntityType.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.commons.api.edm.provider.CsdlEntityType; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlEntityType.EntityTypeDeserializer.class) +class ClientCsdlEntityType extends CsdlEntityType { + + private static final long serialVersionUID = -3986417775876689669L; + + static class EntityTypeDeserializer extends AbstractClientCsdlEdmDeserializer<CsdlEntityType> { + @Override + protected CsdlEntityType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlEntityType entityType = new ClientCsdlEntityType(); + + 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(); + ClientCsdlEntityKey keyImpl = jp.readValueAs(ClientCsdlEntityKey.class); + entityType.setKey(keyImpl.getPropertyRefs()); + } else if ("Property".equals(jp.getCurrentName())) { + jp.nextToken(); + entityType.getProperties().add(jp.readValueAs(ClientCsdlProperty.class)); + } else if ("NavigationProperty".equals(jp.getCurrentName())) { + jp.nextToken(); + entityType.getNavigationProperties().add(jp.readValueAs(ClientCsdlNavigationProperty.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + entityType.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } + } + } + + return entityType; + } + } +} 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/ClientCsdlEnumMember.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEnumMember.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEnumMember.java new file mode 100644 index 0000000..057a678 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEnumMember.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.apache.olingo.commons.api.edm.provider.CsdlEnumMember; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlEnumMember.EnumMemberDeserializer.class) +class ClientCsdlEnumMember extends CsdlEnumMember { + + private static final long serialVersionUID = -6138606817225829791L; + + static class EnumMemberDeserializer extends AbstractClientCsdlEdmDeserializer<CsdlEnumMember> { + @Override + protected CsdlEnumMember doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final CsdlEnumMember member = new CsdlEnumMember(); + + 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(ClientCsdlAnnotation.class)); + } + } + } + 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/ClientCsdlEnumType.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEnumType.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEnumType.java new file mode 100644 index 0000000..a49f3ff --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlEnumType.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlEnumType.EnumTypeDeserializer.class) +class ClientCsdlEnumType extends CsdlEnumType { + + private static final long serialVersionUID = 9191189755592743333L; + + static class EnumTypeDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlEnumType> { + @Override + protected ClientCsdlEnumType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlEnumType enumType = new ClientCsdlEnumType(); + + 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(ClientCsdlEnumMember.class)); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + enumType.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } + } + } + + return enumType; + } + } +} 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/ClientCsdlFunction.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlFunction.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlFunction.java new file mode 100644 index 0000000..97fd637 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ClientCsdlFunction.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.commons.api.edm.provider.CsdlFunction; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import java.io.IOException; + +@JsonDeserialize(using = ClientCsdlFunction.FunctionDeserializer.class) +class ClientCsdlFunction extends CsdlFunction { + + private static final long serialVersionUID = -5494898295282843362L; + + static class FunctionDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlFunction> { + @Override + protected ClientCsdlFunction doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + + final ClientCsdlFunction functionImpl = new ClientCsdlFunction(); + + 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(ClientCsdlParameter.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(ClientCsdlAnnotation.class)); + } + } + } + + return functionImpl; + } + } +}
