http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ApplyDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ApplyDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ApplyDeserializer.java new file mode 100644 index 0000000..8f8ac86 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ApplyDeserializer.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.annotation; + +import java.io.IOException; + +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.AnnotationImpl; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; + +public class ApplyDeserializer extends AbstractEdmDeserializer<ApplyImpl> { + + @Override + protected ApplyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + final ApplyImpl apply = new ApplyImpl(); + + 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(AnnotationImpl.class)); + } else if (isAnnotationConstExprConstruct(jp)) { + apply.getParameters().add(parseAnnotationConstExprConstruct(jp)); + } else { + apply.getParameters().add(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); + } + } + } + + return apply; + } + +}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ApplyImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ApplyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ApplyImpl.java new file mode 100644 index 0000000..60ed4ae --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ApplyImpl.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.annotation; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.olingo.client.api.edm.xml.annotation.AnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.Apply; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ApplyDeserializer.class) +public class ApplyImpl extends AbstractAnnotatableDynamicAnnotationExpression 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; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CastDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CastDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CastDeserializer.java new file mode 100644 index 0000000..87e4c84 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CastDeserializer.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.annotation; + +import java.io.IOException; + +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.AnnotationImpl; +import org.apache.olingo.commons.api.edm.geo.SRID; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; + +public class CastDeserializer extends AbstractEdmDeserializer<CastImpl> { + + @Override + protected CastImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + final CastImpl cast = new CastImpl(); + + 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(AnnotationImpl.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(AbstractDynamicAnnotationExpression.class)); + } + } + } + + return cast; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CastImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CastImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CastImpl.java new file mode 100644 index 0000000..48fd310 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CastImpl.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.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.Cast; +import org.apache.olingo.client.api.edm.xml.annotation.DynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.geo.SRID; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = CastDeserializer.class) +public class CastImpl extends AbstractAnnotatableDynamicAnnotationExpression 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; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CollectionDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CollectionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CollectionDeserializer.java new file mode 100644 index 0000000..330c7e0 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CollectionDeserializer.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.annotation; + +import java.io.IOException; + +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; + +public class CollectionDeserializer extends AbstractEdmDeserializer<CollectionImpl> { + + @Override + protected CollectionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + final CollectionImpl collection = new CollectionImpl(); + + 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(AbstractDynamicAnnotationExpression.class)); + } + } + } + + return collection; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CollectionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CollectionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CollectionImpl.java new file mode 100644 index 0000000..0dfe18e --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/CollectionImpl.java @@ -0,0 +1,41 @@ +/* + * 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.annotation; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.olingo.client.api.edm.xml.annotation.AnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.Collection; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = CollectionDeserializer.class) +public class CollectionImpl extends AbstractDynamicAnnotationExpression implements Collection { + + private static final long serialVersionUID = -724749123749715643L; + + private final List<AnnotationExpression> items = new ArrayList<AnnotationExpression>(); + + @Override + public List<AnnotationExpression> getItems() { + return items; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ConstantAnnotationExpressionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ConstantAnnotationExpressionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ConstantAnnotationExpressionImpl.java new file mode 100644 index 0000000..7530e48 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ConstantAnnotationExpressionImpl.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.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.ConstantAnnotationExpression; + +public class ConstantAnnotationExpressionImpl + extends AbstractAnnotationExpression 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/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/DynamicAnnotationExpressionDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/DynamicAnnotationExpressionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/DynamicAnnotationExpressionDeserializer.java new file mode 100644 index 0000000..7328487 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/DynamicAnnotationExpressionDeserializer.java @@ -0,0 +1,175 @@ +/* + * 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.annotation; + +import java.io.IOException; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.ClassUtils; +import org.apache.olingo.client.api.edm.xml.annotation.AnnotationPath; +import org.apache.olingo.client.api.edm.xml.annotation.Apply; +import org.apache.olingo.client.api.edm.xml.annotation.Cast; +import org.apache.olingo.client.api.edm.xml.annotation.Collection; +import org.apache.olingo.client.api.edm.xml.annotation.If; +import org.apache.olingo.client.api.edm.xml.annotation.IsOf; +import org.apache.olingo.client.api.edm.xml.annotation.LabeledElement; +import org.apache.olingo.client.api.edm.xml.annotation.NavigationPropertyPath; +import org.apache.olingo.client.api.edm.xml.annotation.Null; +import org.apache.olingo.client.api.edm.xml.annotation.Path; +import org.apache.olingo.client.api.edm.xml.annotation.PropertyPath; +import org.apache.olingo.client.api.edm.xml.annotation.Record; +import org.apache.olingo.client.api.edm.xml.annotation.TwoParamsOpDynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.UrlRef; +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; + +import com.fasterxml.jackson.core.JsonLocation; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; + +public class DynamicAnnotationExpressionDeserializer + extends AbstractEdmDeserializer<AbstractDynamicAnnotationExpression> { + + private static final String[] EL_OR_ATTR = { + AnnotationPath.class.getSimpleName(), NavigationPropertyPath.class.getSimpleName(), + Path.class.getSimpleName(), PropertyPath.class.getSimpleName() + }; + + private static final String APPLY = Apply.class.getSimpleName(); + + private static final String CAST = Cast.class.getSimpleName(); + + private static final String COLLECTION = Collection.class.getSimpleName(); + + private static final String IF = If.class.getSimpleName(); + + private static final String IS_OF = IsOf.class.getSimpleName(); + + private static final String LABELED_ELEMENT = LabeledElement.class.getSimpleName(); + + private static final String NULL = Null.class.getSimpleName(); + + private static final String RECORD = Record.class.getSimpleName(); + + private static final String URL_REF = UrlRef.class.getSimpleName(); + + private AbstractElementOrAttributeExpression getElementOrAttributeExpressio(final String simpleClassName) + throws JsonParseException { + + try { + @SuppressWarnings("unchecked") + Class<? extends AbstractElementOrAttributeExpression> elOrAttrClass = + (Class<? extends AbstractElementOrAttributeExpression>) ClassUtils.getClass( + getClass().getPackage().getName() + "." + simpleClassName + "Impl"); + return elOrAttrClass.newInstance(); + } catch (Exception e) { + throw new JsonParseException("Could not instantiate " + simpleClassName, JsonLocation.NA, e); + } + } + + private AbstractAnnotationExpression parseConstOrEnumExpression(final JsonParser jp) throws IOException { + AbstractAnnotationExpression result; + if (isAnnotationConstExprConstruct(jp)) { + result = parseAnnotationConstExprConstruct(jp); + } else { + result = jp.readValueAs(AbstractDynamicAnnotationExpression.class); + } + jp.nextToken(); + + return result; + } + + @Override + protected AbstractDynamicAnnotationExpression doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + AbstractDynamicAnnotationExpression expression = null; + + if ("Not".equals(jp.getCurrentName())) { + final NotImpl not = new NotImpl(); + + jp.nextToken(); + for (; jp.getCurrentToken() != JsonToken.FIELD_NAME; jp.nextToken()) { + } + not.setExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT || !jp.getCurrentName().equals("Not"); jp.nextToken()) { + } + + expression = not; + } else if (TwoParamsOpDynamicAnnotationExpression.Type.fromString(jp.getCurrentName()) != null) { + final TwoParamsOpDynamicAnnotationExpressionImpl dynExprDoubleParamOp = + new TwoParamsOpDynamicAnnotationExpressionImpl(); + dynExprDoubleParamOp.setType(TwoParamsOpDynamicAnnotationExpression.Type.fromString(jp.getCurrentName())); + + jp.nextToken(); + for (; jp.getCurrentToken() != JsonToken.FIELD_NAME; jp.nextToken()) { + } + dynExprDoubleParamOp.setLeftExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); + dynExprDoubleParamOp.setRightExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT + || !jp.getCurrentName().equals(dynExprDoubleParamOp.getType().name()); jp.nextToken()) { + } + + expression = dynExprDoubleParamOp; + } else if (ArrayUtils.contains(EL_OR_ATTR, jp.getCurrentName())) { + final AbstractElementOrAttributeExpression elOrAttr = getElementOrAttributeExpressio(jp.getCurrentName()); + elOrAttr.setValue(jp.nextTextValue()); + + expression = elOrAttr; + } else if (APPLY.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(ApplyImpl.class); + } else if (CAST.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(CastImpl.class); + } else if (COLLECTION.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(CollectionImpl.class); + } else if (IF.equals(jp.getCurrentName())) { + jp.nextToken(); + jp.nextToken(); + + final IfImpl _if = new IfImpl(); + _if.setGuard(parseConstOrEnumExpression(jp)); + _if.setThen(parseConstOrEnumExpression(jp)); + _if.setElse(parseConstOrEnumExpression(jp)); + + expression = _if; + } else if (IS_OF.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(IsOfImpl.class); + } else if (LABELED_ELEMENT.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(LabeledElementImpl.class); + } else if (NULL.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(NullImpl.class); + } else if (RECORD.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(RecordImpl.class); + } else if (URL_REF.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(UrlRefImpl.class); + } + + return expression; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IfImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IfImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IfImpl.java new file mode 100644 index 0000000..dd62bd4 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IfImpl.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.AnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.If; + +public class IfImpl extends AbstractAnnotatableDynamicAnnotationExpression implements If { + + private static final long serialVersionUID = -8571383625077590656L; + + private AnnotationExpression guard; + + private AnnotationExpression _then; + + private AnnotationExpression _else; + + @Override + public AnnotationExpression getGuard() { + return guard; + } + + public void setGuard(final AnnotationExpression guard) { + this.guard = guard; + } + + @Override + public AnnotationExpression getThen() { + return _then; + } + + public void setThen(final AnnotationExpression _then) { + this._then = _then; + } + + @Override + public AnnotationExpression getElse() { + return _else; + } + + public void setElse(final AnnotationExpression _else) { + this._else = _else; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IsOfDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IsOfDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IsOfDeserializer.java new file mode 100644 index 0000000..0b1ce80 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IsOfDeserializer.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.annotation; + +import java.io.IOException; + +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.AnnotationImpl; +import org.apache.olingo.commons.api.edm.geo.SRID; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; + +public class IsOfDeserializer extends AbstractEdmDeserializer<IsOfImpl> { + + @Override + protected IsOfImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + final IsOfImpl isof = new IsOfImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Type".equals(jp.getCurrentName())) { + isof.setType(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + isof.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } else if ("MaxLength".equals(jp.getCurrentName())) { + final String maxLenght = jp.nextTextValue(); + isof.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + } else if ("Precision".equals(jp.getCurrentName())) { + isof.setPrecision(Integer.valueOf(jp.nextTextValue())); + } else if ("Scale".equals(jp.getCurrentName())) { + final String scale = jp.nextTextValue(); + isof.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + } else if ("SRID".equals(jp.getCurrentName())) { + final String srid = jp.nextTextValue(); + if (srid != null) { + isof.setSrid(SRID.valueOf(srid)); + } + } else { + isof.setValue(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); + } + } + } + + return isof; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IsOfImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IsOfImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IsOfImpl.java new file mode 100644 index 0000000..1c41c77 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/IsOfImpl.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.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.DynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.IsOf; +import org.apache.olingo.commons.api.edm.geo.SRID; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = IsOfDeserializer.class) +public class IsOfImpl extends AbstractAnnotatableDynamicAnnotationExpression implements IsOf { + + private static final long serialVersionUID = -893355856129761174L; + + private String type; + + private Integer maxLength; + + private Integer precision; + + private Integer scale; + + private SRID srid; + + private DynamicAnnotationExpression value; + + @Override + public String getType() { + return type; + } + + public void setType(final String type) { + this.type = type; + } + + @Override + public Integer getMaxLength() { + return maxLength; + } + + public void setMaxLength(final Integer maxLength) { + this.maxLength = maxLength; + } + + @Override + public Integer getPrecision() { + return precision; + } + + public void setPrecision(final Integer precision) { + this.precision = precision; + } + + @Override + public Integer getScale() { + return scale; + } + + public void setScale(final Integer scale) { + this.scale = scale; + } + + @Override + public SRID getSrid() { + return srid; + } + + public void setSrid(final SRID srid) { + this.srid = srid; + } + + @Override + public DynamicAnnotationExpression getValue() { + return value; + } + + public void setValue(final DynamicAnnotationExpression value) { + this.value = value; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementDeserializer.java new file mode 100644 index 0000000..5c68abd --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementDeserializer.java @@ -0,0 +1,55 @@ +/* + * 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.annotation; + +import java.io.IOException; + +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.AnnotationImpl; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; + +public class LabeledElementDeserializer extends AbstractEdmDeserializer<LabeledElementImpl> { + + @Override + protected LabeledElementImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + final LabeledElementImpl element = new LabeledElementImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + element.setName(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + element.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } else { + element.setValue(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); + } + } + } + + return element; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementImpl.java new file mode 100644 index 0000000..9b5a6d2 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementImpl.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.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.DynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.LabeledElement; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = LabeledElementDeserializer.class) +public class LabeledElementImpl + extends AbstractAnnotatableDynamicAnnotationExpression implements LabeledElement { + + private static final long serialVersionUID = 4909387630253341824L; + + private String name; + + private DynamicAnnotationExpression value; + + @Override + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + @Override + public DynamicAnnotationExpression getValue() { + return value; + } + + public void setValue(final DynamicAnnotationExpression value) { + this.value = value; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementReferenceImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementReferenceImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementReferenceImpl.java new file mode 100644 index 0000000..0da0ce5 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/LabeledElementReferenceImpl.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.LabeledElementReference; + +public class LabeledElementReferenceImpl + extends AbstractElementOrAttributeExpression implements LabeledElementReference { + + private static final long serialVersionUID = 7560525604021670529L; + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NavigationPropertyPathImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NavigationPropertyPathImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NavigationPropertyPathImpl.java new file mode 100644 index 0000000..c93cd09 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NavigationPropertyPathImpl.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.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.NavigationPropertyPath; + +public class NavigationPropertyPathImpl extends AbstractElementOrAttributeExpression implements NavigationPropertyPath { + + private static final long serialVersionUID = 879840502446301312L; + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NotImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NotImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NotImpl.java new file mode 100644 index 0000000..7013e30 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NotImpl.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.DynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.Not; + +public class NotImpl extends AbstractDynamicAnnotationExpression implements Not { + + private static final long serialVersionUID = -437788415922966812L; + + private DynamicAnnotationExpression expression; + + @Override + public DynamicAnnotationExpression getExpression() { + return expression; + } + + public void setExpression(final DynamicAnnotationExpression expression) { + this.expression = expression; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NullDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NullDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NullDeserializer.java new file mode 100644 index 0000000..0364a8b --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NullDeserializer.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml.annotation; + +import java.io.IOException; + +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.AnnotationImpl; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; + +public class NullDeserializer extends AbstractEdmDeserializer<NullImpl> { + + @Override + protected NullImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + final NullImpl _null = new NullImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Annotation".equals(jp.getCurrentName())) { + _null.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return _null; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NullImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NullImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NullImpl.java new file mode 100644 index 0000000..f779b5f --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/NullImpl.java @@ -0,0 +1,30 @@ +/* + * 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.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.Null; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = NullDeserializer.class) +public class NullImpl extends AbstractAnnotatableDynamicAnnotationExpression implements Null { + + private static final long serialVersionUID = -3148516847180393142L; + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PathImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PathImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PathImpl.java new file mode 100644 index 0000000..73e9571 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PathImpl.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.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.Path; + +public class PathImpl extends AbstractElementOrAttributeExpression implements Path { + + private static final long serialVersionUID = 6020168217561402545L; + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyPathImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyPathImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyPathImpl.java new file mode 100644 index 0000000..f8d1916 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyPathImpl.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.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.PropertyPath; + +public class PropertyPathImpl extends AbstractElementOrAttributeExpression implements PropertyPath { + + private static final long serialVersionUID = -9133862135834738470L; + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyValueDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyValueDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyValueDeserializer.java new file mode 100644 index 0000000..6c3d151 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyValueDeserializer.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.annotation; + +import java.io.IOException; + +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.AnnotationImpl; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; + +public class PropertyValueDeserializer extends AbstractEdmDeserializer<PropertyValueImpl> { + + @Override + protected PropertyValueImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + final PropertyValueImpl propValue = new PropertyValueImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Property".equals(jp.getCurrentName())) { + propValue.setProperty(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + propValue.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } else if (isAnnotationConstExprConstruct(jp)) { + propValue.setValue(parseAnnotationConstExprConstruct(jp)); + } else { + propValue.setValue(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); + } + } + } + + return propValue; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyValueImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyValueImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyValueImpl.java new file mode 100644 index 0000000..61cf85d --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/PropertyValueImpl.java @@ -0,0 +1,53 @@ +/* + * 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.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.AnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.PropertyValue; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = PropertyValueDeserializer.class) +public class PropertyValueImpl extends AbstractAnnotatableDynamicAnnotationExpression implements PropertyValue { + + private static final long serialVersionUID = -8437649215282645228L; + + private String property; + + private AnnotationExpression value; + + @Override + public String getProperty() { + return property; + } + + public void setProperty(final String property) { + this.property = property; + } + + @Override + public AnnotationExpression getValue() { + return value; + } + + public void setValue(final AnnotationExpression value) { + this.value = value; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/RecordDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/RecordDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/RecordDeserializer.java new file mode 100644 index 0000000..d680248 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/RecordDeserializer.java @@ -0,0 +1,55 @@ +/* + * 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.annotation; + +import java.io.IOException; + +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.AnnotationImpl; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; + +public class RecordDeserializer extends AbstractEdmDeserializer<RecordImpl> { + + @Override + protected RecordImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + final RecordImpl record = new RecordImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Type".equals(jp.getCurrentName())) { + record.setType(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + record.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } else { + record.getPropertyValues().add(jp.readValueAs(PropertyValueImpl.class)); + } + } + } + + return record; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/RecordImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/RecordImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/RecordImpl.java new file mode 100644 index 0000000..46f322b --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/RecordImpl.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.annotation; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.olingo.client.api.edm.xml.annotation.PropertyValue; +import org.apache.olingo.client.api.edm.xml.annotation.Record; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = RecordDeserializer.class) +public class RecordImpl extends AbstractAnnotatableDynamicAnnotationExpression implements Record { + + private static final long serialVersionUID = 4275271751615410709L; + + private String type; + + private final List<PropertyValue> propertyValues = new ArrayList<PropertyValue>(); + + @Override + public String getType() { + return type; + } + + public void setType(final String type) { + this.type = type; + } + + @Override + public List<PropertyValue> getPropertyValues() { + return propertyValues; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/TwoParamsOpDynamicAnnotationExpressionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/TwoParamsOpDynamicAnnotationExpressionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/TwoParamsOpDynamicAnnotationExpressionImpl.java new file mode 100644 index 0000000..5b1f7fa --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/TwoParamsOpDynamicAnnotationExpressionImpl.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.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.DynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.TwoParamsOpDynamicAnnotationExpression; + +public class TwoParamsOpDynamicAnnotationExpressionImpl + extends AbstractDynamicAnnotationExpression implements TwoParamsOpDynamicAnnotationExpression { + + private static final long serialVersionUID = 6241842185452451946L; + + private Type type; + + private DynamicAnnotationExpression left; + + private DynamicAnnotationExpression right; + + @Override + public Type getType() { + return type; + } + + public void setType(final Type type) { + this.type = type; + } + + @Override + public DynamicAnnotationExpression getLeftExpression() { + return left; + } + + public void setLeftExpression(final DynamicAnnotationExpression left) { + this.left = left; + } + + @Override + public DynamicAnnotationExpression getRightExpression() { + return right; + } + + public void setRightExpression(final DynamicAnnotationExpression right) { + this.right = right; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/UrlRefDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/UrlRefDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/UrlRefDeserializer.java new file mode 100644 index 0000000..1ca1241 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/UrlRefDeserializer.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.annotation; + +import java.io.IOException; + +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; + +public class UrlRefDeserializer extends AbstractEdmDeserializer<UrlRefImpl> { + + @Override + protected UrlRefImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + final UrlRefImpl urlref = new UrlRefImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if (isAnnotationConstExprConstruct(jp)) { + urlref.setValue(parseAnnotationConstExprConstruct(jp)); + } else { + urlref.setValue(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); + } + } + } + + return urlref; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/UrlRefImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/UrlRefImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/UrlRefImpl.java new file mode 100644 index 0000000..3e7eeba --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/UrlRefImpl.java @@ -0,0 +1,42 @@ +/* + * 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.annotation; + +import org.apache.olingo.client.api.edm.xml.annotation.AnnotationExpression; +import org.apache.olingo.client.api.edm.xml.annotation.UrlRef; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = UrlRefDeserializer.class) +public class UrlRefImpl extends AbstractDynamicAnnotationExpression implements UrlRef { + + private static final long serialVersionUID = -7693224811739000440L; + + private AnnotationExpression value; + + @Override + public AnnotationExpression getValue() { + return value; + } + + public void setValue(final AnnotationExpression value) { + this.value = value; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AbstractAnnotatable.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AbstractAnnotatable.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AbstractAnnotatable.java deleted file mode 100644 index 257ed39..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AbstractAnnotatable.java +++ /dev/null @@ -1,39 +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.v4; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.olingo.client.api.edm.xml.v4.Annotatable; -import org.apache.olingo.client.api.edm.xml.v4.Annotation; -import org.apache.olingo.client.core.edm.xml.AbstractEdmItem; - -public abstract class AbstractAnnotatable extends AbstractEdmItem implements Annotatable { - - private static final long serialVersionUID = 3739284381932173905L; - - private final List<Annotation> annotations = new ArrayList<Annotation>(); - - @Override - public List<Annotation> getAnnotations() { - return annotations; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionDeserializer.java deleted file mode 100644 index ed2793c..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionDeserializer.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.v4; - -import java.io.IOException; - -import org.apache.commons.lang3.BooleanUtils; -import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class ActionDeserializer extends AbstractEdmDeserializer<ActionImpl> { - - @Override - protected ActionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final ActionImpl action = new ActionImpl(); - - for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Name".equals(jp.getCurrentName())) { - action.setName(jp.nextTextValue()); - } else if ("IsBound".equals(jp.getCurrentName())) { - action.setBound(BooleanUtils.toBoolean(jp.nextTextValue())); - } else if ("EntitySetPath".equals(jp.getCurrentName())) { - action.setEntitySetPath(jp.nextTextValue()); - } else if ("Parameter".equals(jp.getCurrentName())) { - jp.nextToken(); - action.getParameters().add(jp.readValueAs(ParameterImpl.class)); - } else if ("ReturnType".equals(jp.getCurrentName())) { - action.setReturnType(parseReturnType(jp, "Action")); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - action.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } - } - } - - return action; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImpl.java deleted file mode 100644 index 4ab6159..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImpl.java +++ /dev/null @@ -1,91 +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.v4; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.olingo.client.api.edm.xml.v4.Action; -import org.apache.olingo.client.api.edm.xml.v4.Parameter; -import org.apache.olingo.client.api.edm.xml.v4.ReturnType; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -@JsonDeserialize(using = ActionDeserializer.class) -public class ActionImpl extends AbstractAnnotatable implements Action { - - private static final long serialVersionUID = 5321541275349234088L; - - private String name; - - private boolean bound = false; - - private String entitySetPath; - - private final List<Parameter> parameters = new ArrayList<Parameter>(); - - private ReturnType returnType; - - @Override - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - @Override - public boolean isBound() { - return bound; - } - - public void setBound(final boolean bound) { - this.bound = bound; - } - - @Override - public String getEntitySetPath() { - return entitySetPath; - } - - public void setEntitySetPath(final String entitySetPath) { - this.entitySetPath = entitySetPath; - } - - @Override - public Parameter getParameter(final String name) { - return getOneByName(name, getParameters()); - } - - @Override - public List<Parameter> getParameters() { - return parameters; - } - - @Override - public ReturnType getReturnType() { - return returnType; - } - - public void setReturnType(final ReturnType returnType) { - this.returnType = returnType; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImportImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImportImpl.java deleted file mode 100644 index 87644b3..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImportImpl.java +++ /dev/null @@ -1,66 +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.v4; - -import org.apache.olingo.client.api.edm.xml.v4.ActionImport; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ActionImportImpl extends AbstractAnnotatable implements ActionImport { - - private static final long serialVersionUID = 2971468441177647068L; - - @JsonProperty(value = "Name", required = true) - private String name; - - @JsonProperty(value = "Action", required = true) - private String action; - - @JsonProperty(value = "EntitySet") - private String entitySet; - - @Override - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - @Override - public String getAction() { - return action; - } - - public void setAction(final String action) { - this.action = action; - } - - @Override - public String getEntitySet() { - return entitySet; - } - - @Override - public void setEntitySet(final String entitySet) { - this.entitySet = entitySet; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AnnotationDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AnnotationDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AnnotationDeserializer.java deleted file mode 100644 index fa93dab..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AnnotationDeserializer.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.v4; - -import java.io.IOException; - -import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; -import org.apache.olingo.client.core.edm.xml.v4.annotation.AbstractDynamicAnnotationExpression; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; - -public class AnnotationDeserializer extends AbstractEdmDeserializer<AnnotationImpl> { - - @Override - protected AnnotationImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - final AnnotationImpl annotation = new AnnotationImpl(); - - for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { - final JsonToken token = jp.getCurrentToken(); - if (token == JsonToken.FIELD_NAME) { - if ("Term".equals(jp.getCurrentName())) { - annotation.setTerm(jp.nextTextValue()); - } else if ("Qualifier".equals(jp.getCurrentName())) { - annotation.setQualifier(jp.nextTextValue()); - } else if ("Annotation".equals(jp.getCurrentName())) { - jp.nextToken(); - annotation.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); - } else if (isAnnotationConstExprConstruct(jp)) { - // Constant Expressions - annotation.setAnnotationExpression(parseAnnotationConstExprConstruct(jp)); - } else { - // Dynamic Expressions - annotation.setAnnotationExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); - } - } - } - - return annotation; - } - -}
