http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlCollection.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlCollection.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlCollection.java new file mode 100644 index 0000000..e76dddd --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlCollection.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.AbstractClientCsdlEdmDeserializer; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlCollection; + +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; + +@JsonDeserialize(using = ClientCsdlCollection.CollectionDeserializer.class) +class ClientCsdlCollection extends CsdlCollection { + + private static final long serialVersionUID = -724749123749715643L; + + 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(ClientCsdlDynamicExpression.class)); + } + } + } + + return collection; + } + } +}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java new file mode 100644 index 0000000..d332649 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlDynamicExpression.java @@ -0,0 +1,162 @@ +/* + * 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.AbstractClientCsdlEdmDeserializer; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlDynamicExpression; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlExpression; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlIf; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression; +//CHECKSTYLE:OFF +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression.LogicalOrComparisonExpressionType; +//CHECKSTYLE:ON +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlNavigationPropertyPath; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlPath; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlPropertyPath; + +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; + +@JsonDeserialize(using = ClientCsdlDynamicExpression.DynamicExpressionDeserializer.class) +public abstract class ClientCsdlDynamicExpression extends CsdlDynamicExpression { + + private static final long serialVersionUID = 1093411847477874348L; + + static class DynamicExpressionDeserializer + extends AbstractClientCsdlEdmDeserializer<CsdlDynamicExpression> { + + // TODO: Search for constants + private static final String APPLY = "Apply"; + private static final String CAST = "Cast"; + private static final String COLLECTION = "Collection"; + private static final String IF = "If"; + private static final String IS_OF = "IsOf"; + private static final String LABELED_ELEMENT = "LabeledElement"; + private static final String NULL = "Null"; + private static final String RECORD = "Record"; + private static final String URL_REF = "UrlRef"; + + private static final String ANNOTATION_PATH = "AnnotationPath"; + private static final String NAVIGATION_PROPERTY_PATH = "NavigationPropertyPath"; + private static final String PATH = "Path"; + private static final String PROPERTY_PATH = "PropertyPath"; + + private CsdlExpression parseConstOrEnumExpression(final JsonParser jp) throws IOException { + CsdlExpression result; + if (isAnnotationConstExprConstruct(jp)) { + result = parseAnnotationConstExprConstruct(jp); + } else { + result = jp.readValueAs(ClientCsdlDynamicExpression.class); + } + jp.nextToken(); + + return result; + } + + @Override + protected CsdlDynamicExpression doDeserialize(final JsonParser jp, + final DeserializationContext ctxt) throws IOException { + + CsdlDynamicExpression expression = null; + + if ("Not".equals(jp.getCurrentName())) { + final CsdlLogicalOrComparisonExpression not = + new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.Not); + jp.nextToken(); + // Search for field name + while (jp.getCurrentToken() != JsonToken.FIELD_NAME) { + jp.nextToken(); + } + not.setLeft(jp.readValueAs(ClientCsdlDynamicExpression.class)); + // Search for end object + while (jp.getCurrentToken() != JsonToken.END_OBJECT || !jp.getCurrentName().equals("Not")) { + jp.nextToken(); + } + + expression = not; + } else if (LogicalOrComparisonExpressionType.fromString(jp.getCurrentName()) != null) { + final CsdlLogicalOrComparisonExpression logicalOrComparissonExp = + new CsdlLogicalOrComparisonExpression(LogicalOrComparisonExpressionType.fromString(jp.getCurrentName())); + jp.nextToken(); + // Search for field name + while (jp.getCurrentToken() != JsonToken.FIELD_NAME) { + jp.nextToken(); + } + // TODO: Read as expression + logicalOrComparissonExp.setLeft(jp.readValueAs(ClientCsdlDynamicExpression.class)); + logicalOrComparissonExp.setRight(jp.readValueAs(ClientCsdlDynamicExpression.class)); + // Search for expression + while (jp.getCurrentToken() != JsonToken.END_OBJECT || !jp.getCurrentName().equals(logicalOrComparissonExp + .getType().name())) { + jp.nextToken(); + } + + expression = logicalOrComparissonExp; + } else if (PATH.equals(jp.getCurrentName())) { + expression = new CsdlPath().setValue(jp.nextTextValue()); + } else if (NAVIGATION_PROPERTY_PATH.equals(jp.getCurrentName())) { + expression = new CsdlNavigationPropertyPath().setValue(jp.nextTextValue()); + } else if (PROPERTY_PATH.equals(jp.getCurrentName())) { + expression = new CsdlPropertyPath().setValue(jp.nextTextValue()); + } else if (ANNOTATION_PATH.equals(jp.getCurrentName())) { + expression = new CsdlPath().setValue(jp.nextTextValue()); + } else if (APPLY.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(ClientCsdlApply.class); + } else if (CAST.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(ClientCsdlCast.class); + } else if (COLLECTION.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(ClientCsdlCollection.class); + } else if (IF.equals(jp.getCurrentName())) { + jp.nextToken(); + jp.nextToken(); + + final CsdlIf ifImpl = new CsdlIf(); + ifImpl.setGuard(parseConstOrEnumExpression(jp)); + ifImpl.setThen(parseConstOrEnumExpression(jp)); + ifImpl.setElse(parseConstOrEnumExpression(jp)); + + expression = ifImpl; + } else if (IS_OF.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(ClientCsdlIsOf.class); + } else if (LABELED_ELEMENT.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(ClientCsdlLabeledElement.class); + } else if (NULL.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(ClientCsdlNull.class); + } else if (RECORD.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(ClientCsdlRecord.class); + } else if (URL_REF.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(ClientCsdlUrlRef.class); + } + + return expression; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlIsOf.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlIsOf.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlIsOf.java new file mode 100644 index 0000000..31ec91a --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlIsOf.java @@ -0,0 +1,71 @@ +/* + * 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.AbstractClientCsdlEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.ClientCsdlAnnotation; +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlIsOf; + +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; + +@JsonDeserialize(using = ClientCsdlIsOf.IsOfDeserializer.class) +class ClientCsdlIsOf extends CsdlIsOf{ + + private static final long serialVersionUID = -893355856129761174L; + + static class IsOfDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlIsOf> { + @Override + protected ClientCsdlIsOf doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlIsOf isof = new ClientCsdlIsOf(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Type".equals(jp.getCurrentName())) { + isof.setType(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + isof.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else if ("MaxLength".equals(jp.getCurrentName())) { + final String maxLenght = jp.nextTextValue(); + isof.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); + } else if ("Precision".equals(jp.getCurrentName())) { + isof.setPrecision(Integer.valueOf(jp.nextTextValue())); + } else if ("Scale".equals(jp.getCurrentName())) { + final String scale = jp.nextTextValue(); + isof.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); + } else if ("SRID".equals(jp.getCurrentName())) { + final String srid = jp.nextTextValue(); + if (srid != null) { + isof.setSrid(SRID.valueOf(srid)); + } + } else { + isof.setValue(jp.readValueAs(ClientCsdlDynamicExpression.class)); + } + } + } + return isof; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlLabeledElement.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlLabeledElement.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlLabeledElement.java new file mode 100644 index 0000000..fdef249 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlLabeledElement.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.AbstractClientCsdlEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.ClientCsdlAnnotation; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLabeledElement; + +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; + +@JsonDeserialize(using = ClientCsdlLabeledElement.LabeledElementDeserializer.class) +class ClientCsdlLabeledElement extends CsdlLabeledElement { + + private static final long serialVersionUID = 4909387630253341824L; + + static class LabeledElementDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlLabeledElement> { + @Override + protected ClientCsdlLabeledElement doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlLabeledElement element = new ClientCsdlLabeledElement(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + element.setName(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + element.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else { + element.setValue(jp.readValueAs(ClientCsdlDynamicExpression.class)); + } + } + } + return element; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlNull.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlNull.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlNull.java new file mode 100644 index 0000000..d8ebb0c --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlNull.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 java.io.IOException; + +import org.apache.olingo.client.core.edm.xml.AbstractClientCsdlEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.ClientCsdlAnnotation; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlNull; + +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; + +@JsonDeserialize(using = ClientCsdlNull.NullDeserializer.class) +class ClientCsdlNull extends CsdlNull { + + private static final long serialVersionUID = -3148516847180393142L; + + static class NullDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlNull> { + @Override + protected ClientCsdlNull doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlNull _null = new ClientCsdlNull(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Annotation".equals(jp.getCurrentName())) { + _null.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } + } + } + return _null; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlPropertyValue.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlPropertyValue.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlPropertyValue.java new file mode 100644 index 0000000..078f66c --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlPropertyValue.java @@ -0,0 +1,59 @@ +/* + * 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.AbstractClientCsdlEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.ClientCsdlAnnotation; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlPropertyValue; + +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; + +@JsonDeserialize(using = ClientCsdlPropertyValue.PropertyValueDeserializer.class) +class ClientCsdlPropertyValue extends CsdlPropertyValue { + + private static final long serialVersionUID = -8437649215282645228L; + + static class PropertyValueDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlPropertyValue> { + @Override + protected ClientCsdlPropertyValue doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlPropertyValue propValue = new ClientCsdlPropertyValue(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Property".equals(jp.getCurrentName())) { + propValue.setProperty(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + propValue.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else if (isAnnotationConstExprConstruct(jp)) { + propValue.setValue(parseAnnotationConstExprConstruct(jp)); + } else { + propValue.setValue(jp.readValueAs(ClientCsdlDynamicExpression.class)); + } + } + } + return propValue; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlRecord.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlRecord.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlRecord.java new file mode 100644 index 0000000..10d2f50 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlRecord.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.AbstractClientCsdlEdmDeserializer; +import org.apache.olingo.client.core.edm.xml.ClientCsdlAnnotation; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlRecord; + +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; + +@JsonDeserialize(using = ClientCsdlRecord.RecordDeserializer.class) +class ClientCsdlRecord extends CsdlRecord { + + private static final long serialVersionUID = 4275271751615410709L; + + static class RecordDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlRecord> { + @Override + protected ClientCsdlRecord doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlRecord record = new ClientCsdlRecord(); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Type".equals(jp.getCurrentName())) { + record.setType(jp.nextTextValue()); + } else if ("Annotation".equals(jp.getCurrentName())) { + record.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class)); + } else { + record.getPropertyValues().add(jp.readValueAs(ClientCsdlPropertyValue.class)); + } + } + } + return record; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlUrlRef.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlUrlRef.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlUrlRef.java new file mode 100644 index 0000000..2a4ebc8 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/annotation/ClientCsdlUrlRef.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 java.io.IOException; + +import org.apache.olingo.client.core.edm.xml.AbstractClientCsdlEdmDeserializer; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlUrlRef; + +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; + +@JsonDeserialize(using = ClientCsdlUrlRef.UrlRefDeserializer.class) +class ClientCsdlUrlRef extends CsdlUrlRef { + + private static final long serialVersionUID = -7693224811739000440L; + + static class UrlRefDeserializer extends AbstractClientCsdlEdmDeserializer<ClientCsdlUrlRef> { + @Override + protected ClientCsdlUrlRef doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException { + final ClientCsdlUrlRef urlref = new ClientCsdlUrlRef(); + 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(ClientCsdlDynamicExpression.class)); + } + } + } + return urlref; + } + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java index 740ba7f..99aa7bd 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java @@ -56,12 +56,14 @@ import org.apache.olingo.commons.api.edm.provider.CsdlFunctionImport; import org.apache.olingo.commons.api.edm.provider.CsdlSchema; import org.apache.olingo.commons.api.edm.provider.CsdlSingleton; import org.apache.olingo.commons.api.edm.provider.CsdlTerm; -import org.apache.olingo.commons.api.edm.provider.annotation.Apply; -import org.apache.olingo.commons.api.edm.provider.annotation.Collection; -import org.apache.olingo.commons.api.edm.provider.annotation.ConstantAnnotationExpression; -import org.apache.olingo.commons.api.edm.provider.annotation.Path; -import org.apache.olingo.commons.api.edm.provider.annotation.TwoParamsOpDynamicAnnotationExpression; -import org.apache.olingo.commons.api.edm.provider.annotation.UrlRef; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlApply; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlCollection; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; +//CHECKSTYLE:OFF +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression.LogicalOrComparisonExpressionType; +//CHECKSTYLE:ON +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlPath; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlUrlRef; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal; import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32; @@ -146,7 +148,7 @@ public class MetadataTest extends AbstractTest { final CsdlAnnotations annots = metadata.getSchema(0).getAnnotationGroup("ODataDemo.DemoService/Suppliers", null); assertNotNull(annots); assertFalse(annots.getAnnotations().isEmpty()); - assertEquals(ConstantAnnotationExpression.Type.String, + assertEquals(CsdlConstantExpression.ConstantExpressionType.String, annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getExpression().asConstant().getType()); assertEquals("http://www.odata.org/", annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getExpression().asConstant().getValue()); @@ -290,19 +292,19 @@ public class MetadataTest extends AbstractTest { assertTrue(displayName.getExpression().isDynamic()); assertTrue(displayName.getExpression().asDynamic().isApply()); - final Apply apply = displayName.getExpression().asDynamic().asApply(); + final CsdlApply apply = displayName.getExpression().asDynamic().asApply(); assertEquals(Constants.CANONICAL_FUNCTION_CONCAT, apply.getFunction()); assertEquals(3, apply.getParameters().size()); - Path path = (Path) apply.getParameters().get(0); + CsdlPath path = (CsdlPath) apply.getParameters().get(0); assertEquals("Name", path.getValue()); - ConstantAnnotationExpression expression = - (ConstantAnnotationExpression) apply.getParameters().get(1); + CsdlConstantExpression expression = + (CsdlConstantExpression) apply.getParameters().get(1); assertEquals(" in ", expression.getValue()); - assertEquals(ConstantAnnotationExpression.Type.String, expression.getType()); + assertEquals(CsdlConstantExpression.ConstantExpressionType.String, expression.getType()); - Path thirdArg = (Path) apply.getParameters().get(2); + CsdlPath thirdArg = (CsdlPath) apply.getParameters().get(2); assertEquals("Address/CountryName", thirdArg.getValue()); // Check Tags @@ -312,9 +314,10 @@ public class MetadataTest extends AbstractTest { assertTrue(tags.getExpression().isDynamic()); assertTrue(tags.getExpression().asDynamic().isCollection()); - final Collection collection = tags.getExpression().asDynamic().asCollection(); + final CsdlCollection collection = tags.getExpression().asDynamic().asCollection(); assertEquals(1, collection.getItems().size()); - assertEquals(ConstantAnnotationExpression.Type.String, collection.getItems().get(0).asConstant().getType()); + assertEquals(CsdlConstantExpression.ConstantExpressionType.String, collection.getItems().get(0).asConstant() + .getType()); assertEquals("MasterData", collection.getItems().get(0).asConstant().getValue()); } @@ -355,16 +358,16 @@ public class MetadataTest extends AbstractTest { annotation = group.getAnnotation("And"); assertTrue(annotation.getExpression().isDynamic()); - assertTrue(annotation.getExpression().asDynamic().isTwoParamsOp()); - assertEquals(TwoParamsOpDynamicAnnotationExpression.Type.And, - annotation.getExpression().asDynamic().asTwoParamsOp().getType()); - assertTrue(annotation.getExpression().asDynamic().asTwoParamsOp().getLeftExpression().isPath()); + assertTrue(annotation.getExpression().asDynamic().isLogicalOrComparison()); + assertEquals(LogicalOrComparisonExpressionType.And, + annotation.getExpression().asDynamic().asLogicalOrComparison().getType()); + assertTrue(annotation.getExpression().asDynamic().asLogicalOrComparison().getLeft().asDynamic().isPath()); annotation = group.getAnnotation("Vocab.Supplier"); assertNotNull(annotation); assertTrue(annotation.getExpression().isDynamic()); assertTrue(annotation.getExpression().asDynamic().isUrlRef()); - final UrlRef urlRef = annotation.getExpression().asDynamic().asUrlRef(); + final CsdlUrlRef urlRef = annotation.getExpression().asDynamic().asUrlRef(); assertTrue(urlRef.getValue().isDynamic()); assertTrue(urlRef.getValue().asDynamic().isApply()); @@ -383,7 +386,7 @@ public class MetadataTest extends AbstractTest { edmAnnotation = edmGroup.getAnnotations().get(1); assertTrue(edmAnnotation.getExpression().isDynamic()); assertTrue(edmAnnotation.getExpression().asDynamic().isAnd()); - assertTrue(edmAnnotation.getExpression().asDynamic().asAnd().getLeftExpression().isPath()); + assertTrue(edmAnnotation.getExpression().asDynamic().asAnd().getLeftExpression().asDynamic().isPath()); edmAnnotation = edmGroup.getAnnotations().get(edmGroup.getAnnotations().size() - 2); assertNotNull(edmAnnotation); @@ -398,7 +401,7 @@ public class MetadataTest extends AbstractTest { public void metadataWithCapabilities() throws Exception { InputStream input = getClass().getResourceAsStream("Metadata-With-Capabilities.xml"); final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML). - toMetadata(input); + toMetadata(input); CsdlSchema schema = metadata.getSchema("Capabilities"); assertNotNull(schema); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNot.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNot.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNot.java index 5e4441d..7c302f4 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNot.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNot.java @@ -24,8 +24,8 @@ package org.apache.olingo.commons.api.edm.annotation; public interface EdmNot extends EdmDynamicAnnotationExpression { /** - * Returns a boolean value - * @return either true or false + * Returns an expression which should be inverted + * @return the expression which must be inverted */ - EdmDynamicAnnotationExpression getExpression(); + EdmAnnotationExpression getExpression(); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmTwoParamsOpDynamicAnnotationExpression.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmTwoParamsOpDynamicAnnotationExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmTwoParamsOpDynamicAnnotationExpression.java index 60fecb5..5fc5edf 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmTwoParamsOpDynamicAnnotationExpression.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmTwoParamsOpDynamicAnnotationExpression.java @@ -27,11 +27,11 @@ public interface EdmTwoParamsOpDynamicAnnotationExpression extends EdmDynamicAnn * Returns the first expression (left child) * @return Child expression */ - EdmDynamicAnnotationExpression getLeftExpression(); + EdmAnnotationExpression getLeftExpression(); /** * Returns the second expression (right child) * @return Child expression */ - EdmDynamicAnnotationExpression getRightExpression(); + EdmAnnotationExpression getRightExpression(); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlAnnotation.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlAnnotation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlAnnotation.java index a1f838e..e5d1ddb 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlAnnotation.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlAnnotation.java @@ -6,9 +6,9 @@ * 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 @@ -21,7 +21,7 @@ package org.apache.olingo.commons.api.edm.provider; import java.util.ArrayList; import java.util.List; -import org.apache.olingo.commons.api.edm.provider.annotation.AnnotationExpression; +import org.apache.olingo.commons.api.edm.provider.annotation.CsdlExpression; /** * Represents a CSDL annotation @@ -36,13 +36,13 @@ public class CsdlAnnotation extends CsdlAbstractEdmItem implements CsdlAnnotatab private List<CsdlAnnotation> annotations = new ArrayList<CsdlAnnotation>(); - private AnnotationExpression annotationExpression; + private CsdlExpression annotationExpression; /** * Returns the annotated expression * @return expression annotated expression */ - public AnnotationExpression getExpression() { + public CsdlExpression getExpression() { return annotationExpression; } @@ -50,7 +50,7 @@ public class CsdlAnnotation extends CsdlAbstractEdmItem implements CsdlAnnotatab * Sets the annotated expression * @param annotationExpression annotated expression */ - public CsdlAnnotation setExpression(final AnnotationExpression annotationExpression) { + public CsdlAnnotation setExpression(final CsdlExpression annotationExpression) { this.annotationExpression = annotationExpression; return this; } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlExpression.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlExpression.java deleted file mode 100644 index f555343..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlExpression.java +++ /dev/null @@ -1,26 +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.commons.api.edm.provider; - -/** - * The type Csdl expression. - */ -public class CsdlExpression { - // TODO: Expression implementation -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AbstractCsdlAnnotationExpression.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AbstractCsdlAnnotationExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AbstractCsdlAnnotationExpression.java deleted file mode 100644 index 0c0f1d5..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AbstractCsdlAnnotationExpression.java +++ /dev/null @@ -1,49 +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.commons.api.edm.provider.annotation; - -import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmItem; -import org.apache.olingo.commons.api.edm.provider.annotation.AnnotationExpression; -import org.apache.olingo.commons.api.edm.provider.annotation.ConstantAnnotationExpression; -import org.apache.olingo.commons.api.edm.provider.annotation.DynamicAnnotationExpression; - -public abstract class AbstractCsdlAnnotationExpression extends CsdlAbstractEdmItem implements AnnotationExpression { - - private static final long serialVersionUID = -4238652997159205377L; - - @Override - public boolean isConstant() { - return this instanceof ConstantAnnotationExpression; - } - - @Override - public ConstantAnnotationExpression asConstant() { - return isConstant() ? (ConstantAnnotationExpression) this : null; - } - - @Override - public boolean isDynamic() { - return this instanceof DynamicAnnotationExpression; - } - - @Override - public DynamicAnnotationExpression asDynamic() { - return isDynamic() ? (DynamicAnnotationExpression) this : null; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AnnotationExpression.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AnnotationExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AnnotationExpression.java deleted file mode 100644 index e9a5d69..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AnnotationExpression.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.commons.api.edm.provider.annotation; - -import java.io.Serializable; - -/** - * Super type of all annotation expressions - * A expression is either constant or dynamic - */ -public interface AnnotationExpression extends Serializable { - - /** - * Return true if the expression is constant - * @return true if the expression is constant - */ - boolean isConstant(); - - /** - * Casts the expression to {@link org.apache.olingo.commons.api.edm.annotation.EdmConstantAnnotationExpression} - * @return Constant Expression - */ - ConstantAnnotationExpression asConstant(); - - /** - * Return true if the expression is dynamic - * @return true if the expression is dynamic - */ - boolean isDynamic(); - - /** - * Cast the expression to {@link org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression} - * @return Dynamic Expression - */ - DynamicAnnotationExpression asDynamic(); -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AnnotationPath.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AnnotationPath.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AnnotationPath.java deleted file mode 100644 index 03cd8de..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/AnnotationPath.java +++ /dev/null @@ -1,31 +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.commons.api.edm.provider.annotation; - -/** - * Represents an annotation path - */ -public interface AnnotationPath extends DynamicAnnotationExpression { - - /** - * Value of the path - * @return value of the path - */ - String getValue(); -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Apply.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Apply.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Apply.java deleted file mode 100644 index 69fbf2d..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Apply.java +++ /dev/null @@ -1,49 +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.commons.api.edm.provider.annotation; - -import java.util.List; - -import org.apache.olingo.commons.api.edm.provider.CsdlAnnotatable; - -/** - * Represents an Edm:Apply expression - */ -public interface Apply extends DynamicAnnotationExpression, CsdlAnnotatable { - - /** - * A QualifiedName specifying the name of the client-side function to apply. - * <br/> - * OData defines three canonical functions. Services MAY support additional functions that MUST be qualified with a - * namespace or alias other than odata. Function names qualified with odata are reserved for this specification and - * its future versions. - * - * @return function full qualified name - * @see org.apache.olingo.commons.api.Constants#CANONICAL_FUNCTION_CONCAT - * @see org.apache.olingo.commons.api.Constants#CANONICAL_FUNCTION_FILLURITEMPLATE - * @see org.apache.olingo.commons.api.Constants#CANONICAL_FUNCTION_URIENCODE - */ - String getFunction(); - - /** - * Returns the expressions applied to the parameters of the function - * @return List of expression - */ - List<AnnotationExpression> getParameters(); -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Cast.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Cast.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Cast.java deleted file mode 100644 index c7f0092..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Cast.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.api.edm.provider.annotation; - -import org.apache.olingo.commons.api.edm.geo.SRID; -import org.apache.olingo.commons.api.edm.provider.CsdlAnnotatable; - -/** - * Represents an edm:Cast expression. - * Casts the value obtained from its single child expression to the specified type - */ -public interface Cast extends DynamicAnnotationExpression, CsdlAnnotatable { - /** - * Returns the facet attribute MaxLength - * @return Returns the facet attribute MaxLength - */ - Integer getMaxLength(); - - /** - * Returns the facet attribute Precision - * @return Returns the facet attribute Precision - */ - Integer getPrecision(); - - /** - * Returns the facet attribute Scale - * @return Returns the facet attribute Scale - */ - Integer getScale(); - - /** - * Returns the facet attribute SRID - * @return Returns the facet attribute SRID - */ - SRID getSrid(); - - /** - * Value cast to - * @return value cast to - */ - String getType(); - - /** - * Cast value of the expression - * @return Cast value - */ - DynamicAnnotationExpression getValue(); - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Collection.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Collection.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Collection.java deleted file mode 100644 index 30eadac..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/Collection.java +++ /dev/null @@ -1,36 +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.commons.api.edm.provider.annotation; - -import java.util.List; - -/** - * The edm:Collection expression enables a value to be obtained from zero or more child expressions. - * The value calculated by the collection expression is the collection of the values calculated - * by each of the child expressions. - */ -public interface Collection extends DynamicAnnotationExpression { - - /** - * Returns a list of child expression - * @return List of child expression - */ - List<AnnotationExpression> getItems(); - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/ConstantAnnotationExpression.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/ConstantAnnotationExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/ConstantAnnotationExpression.java deleted file mode 100644 index 65d818c..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/ConstantAnnotationExpression.java +++ /dev/null @@ -1,118 +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.commons.api.edm.provider.annotation; - -/** - * Represents a constant expression - */ -public interface ConstantAnnotationExpression extends AnnotationExpression { - - /** - * Type of the constant expression - */ - public enum Type { - /** - * Type Edm.binary - */ - Binary, - /** - * Type Edm.Bool - */ - Bool, - /** - * Type Edm.Date - */ - Date, - /** - * Type Edm.DateTimeOffset - */ - DateTimeOffset, - /** - * Type Edm.Decimal - */ - Decimal, - /** - * Type Edm.Duration - */ - Duration, - /** - * Type Edm.EnumMeber - */ - EnumMember, - /** - * Type Edm.Float - */ - Float, - /** - * Type Edm.GUID - */ - Guid, - /** - * Type Integer - */ - Int, - /** - * Type Edm.String - */ - String, - /** - * Type Edm.TimeOfDay - */ - TimeOfDay; - - /** - * Creates a new type by a given string e.g. "TimeOfDay" - * @param value Type as string - * @return Type type - */ - public static Type fromString(final String value) { - Type result = null; - try { - result = valueOf(value); - } catch (IllegalArgumentException e) { - // ignore - } - return result; - } - } - - /** - * Returns the type of the constant exprssion - * @return type of the constant expresion - */ - Type getType(); - - /** - * Sets the type of the constant expression - * @param type type of the constant expression - */ - void setType(Type type); - - /** - * Value of the constant expression - * @return value of the constant expression as String - */ - String getValue(); - - /** - * Sets the value of the constant expression - * @param value value of the constant expression - */ - void setValue(String value); -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlAnnotationPath.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlAnnotationPath.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlAnnotationPath.java new file mode 100644 index 0000000..ed9b31f --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlAnnotationPath.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.commons.api.edm.provider.annotation; + +/** + * Represents an annotation path + */ +public class CsdlAnnotationPath extends CsdlDynamicExpression { + private static final long serialVersionUID = 1588336268773032932L; + + private String value; + + public CsdlAnnotationPath setValue(final String value) { + this.value = value; + return this; + } + + /** + * Value of the path + * @return value of the path + */ + public String getValue() { + return value; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlApply.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlApply.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlApply.java new file mode 100644 index 0000000..2c637a5 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlApply.java @@ -0,0 +1,77 @@ +/* + * 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.commons.api.edm.provider.annotation; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.olingo.commons.api.edm.provider.CsdlAnnotatable; +import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; + +public class CsdlApply extends CsdlDynamicExpression implements CsdlAnnotatable{ + private static final long serialVersionUID = 3555689860643577136L; + + private String function; + private List<CsdlExpression> parameters = new ArrayList<CsdlExpression>(); + private List<CsdlAnnotation> annotations = new ArrayList<CsdlAnnotation>(); + + @Override + public List<CsdlAnnotation> getAnnotations() { + return annotations; + } + + public CsdlApply setAnnotations(List<CsdlAnnotation> annotations) { + this.annotations = annotations; + return this; + } + + /** + * A QualifiedName specifying the name of the client-side function to apply. + * <br/> + * OData defines three canonical functions. Services MAY support additional functions that MUST be qualified with a + * namespace or alias other than odata. Function names qualified with odata are reserved for this specification and + * its future versions. + * + * @return function full qualified name + * @see org.apache.olingo.commons.api.Constants#CANONICAL_FUNCTION_CONCAT + * @see org.apache.olingo.commons.api.Constants#CANONICAL_FUNCTION_FILLURITEMPLATE + * @see org.apache.olingo.commons.api.Constants#CANONICAL_FUNCTION_URIENCODE + */ + public String getFunction() { + return function; + } + + public CsdlApply setFunction(final String function) { + this.function = function; + return this; + } + + /** + * Returns the expressions applied to the parameters of the function + * @return List of expression + */ + public List<CsdlExpression> getParameters() { + return parameters; + } + + public CsdlApply setParameters(List<CsdlExpression> parameters) { + this.parameters = parameters; + return this; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlCast.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlCast.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlCast.java new file mode 100644 index 0000000..a2dc7e7 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlCast.java @@ -0,0 +1,124 @@ +/* + * 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.commons.api.edm.provider.annotation; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.api.edm.provider.CsdlAnnotatable; +import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; + +/** + * Represents an edm:Cast expression. + * Casts the value obtained from its single child expression to the specified type + */ +public class CsdlCast extends CsdlDynamicExpression implements CsdlAnnotatable{ + private static final long serialVersionUID = 7664148202663405946L; + + private String type; + private Integer maxLength; + private Integer precision; + private Integer scale; + private SRID srid; + private CsdlDynamicExpression value; + private List<CsdlAnnotation> annotations = new ArrayList<CsdlAnnotation>(); + + @Override + public List<CsdlAnnotation> getAnnotations() { + return annotations; + } + + public CsdlCast setAnnotations(List<CsdlAnnotation> annotations) { + this.annotations = annotations; + return this; + } + + /** + * Value cast to + * @return value cast to + */ + public String getType() { + return type; + } + + public void setType(final String type) { + this.type = type; + } + + /** + * Returns the facet attribute MaxLength + * @return Returns the facet attribute MaxLength + */ + public Integer getMaxLength() { + return maxLength; + } + + public void setMaxLength(final Integer maxLength) { + this.maxLength = maxLength; + } + + /** + * Returns the facet attribute Precision + * @return Returns the facet attribute Precision + */ + public Integer getPrecision() { + return precision; + } + + public void setPrecision(final Integer precision) { + this.precision = precision; + } + + /** + * Returns the facet attribute Scale + * @return Returns the facet attribute Scale + */ + public Integer getScale() { + return scale; + } + + public void setScale(final Integer scale) { + this.scale = scale; + } + + /** + * Returns the facet attribute SRID + * @return Returns the facet attribute SRID + */ + public SRID getSrid() { + return srid; + } + + public void setSrid(final SRID srid) { + this.srid = srid; + } + + /** + * Cast value of the expression + * @return Cast value + */ + public CsdlDynamicExpression getValue() { + return value; + } + + public void setValue(final CsdlDynamicExpression value) { + this.value = value; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlCollection.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlCollection.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlCollection.java new file mode 100644 index 0000000..d1dd9c0 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlCollection.java @@ -0,0 +1,50 @@ +/* + * 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.commons.api.edm.provider.annotation; + +import java.util.ArrayList; +import java.util.List; + +/** + * The edm:Collection expression enables a value to be obtained from zero or more child expressions. + * The value calculated by the collection expression is the collection of the values calculated + * by each of the child expressions. + */ +public class CsdlCollection extends CsdlDynamicExpression { + private static final long serialVersionUID = 3792880963089015493L; + + private List<CsdlExpression> items = new ArrayList<CsdlExpression>(); + + /** + * Returns a list of child expression + * @return List of child expression + */ + public List<CsdlExpression> getItems() { + return items; + } + + /** + * Returns a list of child expression + * @return List of child expression + */ + public CsdlCollection setItems(List<CsdlExpression> items) { + this.items = items; + return this; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlConstantAnnotationExpression.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlConstantAnnotationExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlConstantAnnotationExpression.java deleted file mode 100644 index 1f70276..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlConstantAnnotationExpression.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.api.edm.provider.annotation; - -public class CsdlConstantAnnotationExpression - extends AbstractCsdlAnnotationExpression implements ConstantAnnotationExpression { - - private static final long serialVersionUID = 5618680702707972904L; - - private Type type; - - private String value; - - public CsdlConstantAnnotationExpression() { - } - - public CsdlConstantAnnotationExpression(Type type, String value) { - this.type = type; - this.value = 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/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlConstantExpression.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlConstantExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlConstantExpression.java new file mode 100644 index 0000000..8e8d5cd --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlConstantExpression.java @@ -0,0 +1,142 @@ +/* + * 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.commons.api.edm.provider.annotation; + + +public class CsdlConstantExpression extends CsdlExpression { + + private static final long serialVersionUID = 5618680702707972904L; + + private ConstantExpressionType type; + private String value; + + /** + * Type of the constant expression + */ + public enum ConstantExpressionType { + /** + * Type Edm.binary + */ + Binary, + /** + * Type Edm.Bool + */ + Bool, + /** + * Type Edm.Date + */ + Date, + /** + * Type Edm.DateTimeOffset + */ + DateTimeOffset, + /** + * Type Edm.Decimal + */ + Decimal, + /** + * Type Edm.Duration + */ + Duration, + /** + * Type Edm.EnumMeber + */ + EnumMember, + /** + * Type Edm.Float + */ + Float, + /** + * Type Edm.GUID + */ + Guid, + /** + * Type Integer + */ + Int, + /** + * Type Edm.String + */ + String, + /** + * Type Edm.TimeOfDay + */ + TimeOfDay; + + /** + * Creates a new type by a given string e.g. "TimeOfDay". + * Will NOT throw an IlligalArgumentException for invalid types. If needed use the valueOf method. + * @param value Type as string + * @return Type type + */ + public static ConstantExpressionType fromString(final String value) { + ConstantExpressionType result = null; + try { + result = valueOf(value); + } catch (IllegalArgumentException e) { + // ignore + } + return result; + } + } + + public CsdlConstantExpression() {} + + public CsdlConstantExpression(ConstantExpressionType type, String value) { + this.type = type; + this.value = value; + } + + /** + * Returns the type of the constant expression + * @return type of the constant expression + */ + public ConstantExpressionType getType() { + return type; + } + + /** + * Sets the type of the constant expression + * @param type type of the constant expression + * @return this for method chaining + */ + public CsdlConstantExpression setType(final ConstantExpressionType type) { + this.type = type; + return this; + } + + /** + * Value of the constant expression + * @return value of the constant expression as String + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the constant expression + * @param value value of the constant expression + * @return this for method chaining + */ + public CsdlConstantExpression setValue(final String value) { + this.value = value; + return this; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/67ccbf9d/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlDynamicExpression.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlDynamicExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlDynamicExpression.java new file mode 100644 index 0000000..3ee1468 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/annotation/CsdlDynamicExpression.java @@ -0,0 +1,282 @@ +/* + * 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.commons.api.edm.provider.annotation; + +import java.util.Collection; + +public abstract class CsdlDynamicExpression extends CsdlExpression { + + private static final long serialVersionUID = 179628476369962030L; + + /** + * Returns true if the expression is a logical expression + * @return true if the expression is a logical expression + */ + public boolean isLogicalOrComparison() { + return this instanceof CsdlLogicalOrComparisonExpression; + } + + /** + * Casts the expression to a {@link CsdlLogicalOrComparisonExpression} expression + * @return CsdlLogicalExpression expression + */ + public CsdlLogicalOrComparisonExpression asLogicalOrComparison() { + return isLogicalOrComparison() ? (CsdlLogicalOrComparisonExpression) this : null; + } + + /** + * Returns true if the expression is a edm:AnnotationPath expression + * @return true if the expression is a edm:AnnotationPath expression + */ + public boolean isAnnotationPath() { + return this instanceof CsdlAnnotationPath; + } + + /** + * Casts the expression to a {@link CsdlAnnotationPath} expression + * @return AnnotationPath expression + */ + public CsdlAnnotationPath asAnnotationPath() { + return isAnnotationPath() ? (CsdlAnnotationPath) this : null; + } + + /** + * Returns true if the expression is a edm:Apply expression + * @return true if the expression is a edm:Apply expression + */ + public boolean isApply() { + return this instanceof CsdlApply; + } + + /** + * Casts the expression to a {@link CsdlApply} expression + * @return Apply expression + */ + public CsdlApply asApply() { + return isApply() ? (CsdlApply) this : null; + } + + /** + * Returns true if the expression is a edm:Cast expression + * @return true if the expression is a edm:Cast expression + */ + public boolean isCast() { + return this instanceof CsdlCast; + } + + /** + * Casts the expression to a {@link CsdlCast} expression + * @return Cast expression + */ + public CsdlCast asCast() { + return isCast() ? (CsdlCast) this : null; + } + + /** + * Returns true if the expression is a edm:Collection expression + * @return true if the expression is a edm:Collection expression + */ + public boolean isCollection() { + return this instanceof CsdlCollection; + } + + /** + * Casts the expression to a {@link Collection} expression + * @return Collection expression + */ + public CsdlCollection asCollection() { + return isCollection() ? (CsdlCollection) this : null; + } + + /** + * Returns true if the expression is a edm:If expression + * @return true if the expression is a edm:If expression + */ + public boolean isIf() { + return this instanceof CsdlIf; + } + + /** + * Casts the expression to a {@link CsdlIf} expression + * @return If expression + */ + public CsdlIf asIf() { + return isIf() ? (CsdlIf) this : null; + } + + /** + * Returns true if the expression is a edm:IsOf expression + * @return true if the expression is a edm:IsOf expression + */ + public boolean isIsOf() { + return this instanceof CsdlIsOf; + } + + /** + * Casts the expression to a {@link CsdlIsOf} expression + * @return IsOf expression + */ + public CsdlIsOf asIsOf() { + return isIsOf() ? (CsdlIsOf) this : null; + } + + /** + * Returns true if the expression is a edm:LabeledElement expression + * @return true if the expression is a edm:LabeledElement expression + */ + public boolean isLabeledElement() { + return this instanceof CsdlLabeledElement; + } + + /** + * Casts the expression to a {@link CsdlLabeledElement} expression + * @return LabeledElement expression + */ + public CsdlLabeledElement asLabeledElement() { + return isLabeledElement() ? (CsdlLabeledElement) this : null; + } + + /** + * Returns true if the expression is a edm:LabeledElementReference expression + * @return true if the expression is a edm:LabeledElementReference expression + */ + public boolean isLabeledElementReference() { + return this instanceof CsdlLabeledElementReference; + } + + /** + * Casts the expression to a {@link CsdlLabeledElementReference} expression + * @return LabeledElementReference expression + */ + public CsdlLabeledElementReference asLabeledElementReference() { + return isLabeledElementReference() ? (CsdlLabeledElementReference) this : null; + } + + /** + * Returns true if the expression is a edm:Null expression + * @return true if the expression is a edm:Null expression + */ + public boolean isNull() { + return this instanceof CsdlNull; + } + + /** + * Casts the expression to a {@link CsdlNull} expression + * @return Null expression + */ + public CsdlNull asNull() { + return isNull() ? (CsdlNull) this : null; + } + + /** + * Returns true if the expression is a edm:NavigationPropertyPath expression + * @return true if the expression is a edm:NavigationPropertyPath expression + */ + public boolean isNavigationPropertyPath() { + return this instanceof CsdlNavigationPropertyPath; + } + + /** + * Casts the expression to a {@link CsdlNavigationPropertyPath} expression + * @return NavigationPropertyPath expression + */ + public CsdlNavigationPropertyPath asNavigationPropertyPath() { + return isNavigationPropertyPath() ? (CsdlNavigationPropertyPath) this : null; + } + + /** + * Returns true if the expression is a edm:Path expression + * @return true if the expression is a edm:Path expression + */ + public boolean isPath() { + return this instanceof CsdlPath; + } + + /** + * Casts the expression to a {@link CsdlPath} expression + * @return Path expression + */ + public CsdlPath asPath() { + return isPath() ? (CsdlPath) this : null; + } + + /** + * Returns true if the expression is a edm:PropertyPath expression + * @return true if the expression is a edm:PropertyPath expression + */ + public boolean isPropertyPath() { + return this instanceof CsdlPropertyPath; + } + + /** + * Casts the expression to a {@link CsdlPropertyPath} expression + * @return PropertyPath expression + */ + public CsdlPropertyPath asPropertyPath() { + return isPropertyPath() ? (CsdlPropertyPath) this : null; + } + + /** + * Returns true if the expression is a edm:PropertyValue expression + * @return true if the expression is a edm:PropertyValue expression + */ + public boolean isPropertyValue() { + return this instanceof CsdlPropertyValue; + } + + /** + * Casts the expression to a {@link CsdlPropertyValue} expression + * @return PropertyValue expression + */ + public CsdlPropertyValue asPropertyValue() { + return isPropertyValue() ? (CsdlPropertyValue) this : null; + } + + /** + * Returns true if the expression is a edm:Record expression + * @return true if the expression is a edm:Record expression + */ + public boolean isRecord() { + return this instanceof CsdlRecord; + } + + /** + * Casts the expression to a {@link CsdlRecord} expression + * @return Record expression + */ + public CsdlRecord asRecord() { + return isRecord() ? (CsdlRecord) this : null; + } + + /** + * Returns true if the expression is a edm:UrlRef expression + * @return true if the expression is a edm:UrlRef expression + */ + public boolean isUrlRef() { + return this instanceof CsdlUrlRef; + } + + /** + * Casts the expression to a {@link CsdlUrlRef} expression + * @return UrlRef expression + */ + public CsdlUrlRef asUrlRef() { + return isUrlRef() ? (CsdlUrlRef) this : null; + } +}
