You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/11/17 10:53:53 UTC
[1/4] olingo-odata4 git commit: [OLINGO-821] Support alias for enum
values in URI
Repository: olingo-odata4
Updated Branches:
refs/heads/OLINGO-568_SearchParser_Draft 9ff30e729 -> c0adc020b
[OLINGO-821] Support alias for enum values in URI
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/c7838a67
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/c7838a67
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/c7838a67
Branch: refs/heads/OLINGO-568_SearchParser_Draft
Commit: c7838a678d96a92f6c77aae617b0e840ebbbb9a5
Parents: 639362c
Author: Christian Amend <ch...@sap.com>
Authored: Mon Nov 9 15:46:12 2015 +0100
Committer: Christian Amend <ch...@sap.com>
Committed: Mon Nov 9 15:46:12 2015 +0100
----------------------------------------------------------------------
.../commons/core/edm/EdmEnumTypeImpl.java | 36 ++++++++++++++------
.../server/core/edm/provider/EdmEnumTest.java | 30 +++++++++++-----
.../core/uri/antlr/TestFullResourcePath.java | 8 +++++
3 files changed, 56 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c7838a67/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java
index 98a0962..1f7f070 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.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
@@ -43,7 +43,7 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
private final EdmPrimitiveType underlyingType;
private final CsdlEnumType enumType;
- private final String uriPrefix;
+ private final FullQualifiedName enumName;
private final String uriSuffix;
private List<String> memberNames;
private Map<String, EdmMember> membersMap;
@@ -67,7 +67,7 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
}
this.enumType = enumType;
- uriPrefix = enumName.getFullQualifiedNameAsString() + '\'';
+ this.enumName = enumName;
uriSuffix = "'";
}
@@ -228,19 +228,35 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
@Override
public String toUriLiteral(final String literal) {
- return literal == null ? null : uriPrefix + literal + uriSuffix;
+ return literal == null ? null : enumName.getFullQualifiedNameAsString() + "'" + literal + uriSuffix;
}
@Override
public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException {
if (literal == null) {
return null;
- } else if (literal.length() >= uriPrefix.length() + uriSuffix.length()
- && literal.startsWith(uriPrefix) && literal.endsWith(uriSuffix)) {
- return literal.substring(uriPrefix.length(), literal.length() - uriSuffix.length());
- } else {
- throw new EdmPrimitiveTypeException("The literal '" + literal + "' has illegal content.");
}
+
+ if (literal.endsWith(uriSuffix)) {
+ String[] splitLiteral = literal.split("'");
+ if (splitLiteral.length != 2) {
+ throw new EdmPrimitiveTypeException("The literal '" + literal
+ + "' must be of format FullQuallifiedTypeName'literal'");
+ }
+ // First part must be the FullQualifiedName
+ FullQualifiedName typeFqn = null;
+ try {
+ typeFqn = new FullQualifiedName(splitLiteral[0]);
+ } catch (IllegalArgumentException e) {
+ throw new EdmPrimitiveTypeException("The literal '" + literal + "' has illegal content.", e);
+ }
+ // Get itself. This will also resolve a possible alias
+ EdmEnumType prospect = edm.getEnumType(typeFqn);
+ if (prospect != null && enumName.equals(prospect.getFullQualifiedName())) {
+ return splitLiteral[1];
+ }
+ }
+ throw new EdmPrimitiveTypeException("The literal '" + literal + "' has illegal content.");
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c7838a67/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
index b027c64..dbcda3a 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
@@ -26,10 +26,13 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.List;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
@@ -53,15 +56,18 @@ public class EdmEnumTest {
private final EdmEnumType int32FlagType;
public EdmEnumTest() {
+ Edm edm = mock(Edm.class);
final List<CsdlEnumMember> memberList = Arrays.asList(
new CsdlEnumMember().setName("first").setValue("1"),
new CsdlEnumMember().setName("second").setValue("64"));
final FullQualifiedName enumName = new FullQualifiedName("namespace", "name");
- instance = new EdmEnumTypeImpl(null, enumName,
+ instance = new EdmEnumTypeImpl(edm, enumName,
new CsdlEnumType().setName("name").setMembers(memberList).setFlags(true)
.setUnderlyingType(EdmPrimitiveTypeKind.SByte.getFullQualifiedName()));
+ when(edm.getEnumType(new FullQualifiedName("namespace.name"))).thenReturn(instance);
+ when(edm.getEnumType(new FullQualifiedName("alias.name"))).thenReturn(instance);
otherInstance = new EdmEnumTypeImpl(null, enumName,
new CsdlEnumType().setName("name").setMembers(memberList).setFlags(true)
@@ -170,11 +176,15 @@ public class EdmEnumTest {
public void fromUriLiteral() throws Exception {
assertNull(instance.fromUriLiteral(null));
assertEquals("first", instance.fromUriLiteral("namespace.name'first'"));
-
- expectErrorInFromUriLiteral(instance, "");
- expectErrorInFromUriLiteral(instance, "name'first'");
- expectErrorInFromUriLiteral(instance, "namespace.name'first");
- expectErrorInFromUriLiteral(instance, "namespace.namespace'first");
+ assertEquals("first", instance.fromUriLiteral("alias.name'first'"));
+
+ expectErrorInFromUriLiteral(instance, "", null);
+ expectErrorInFromUriLiteral(instance, "name'first'", null);
+ expectErrorInFromUriLiteral(instance, "namespace.name'first", null);
+ expectErrorInFromUriLiteral(instance, "namespace.namespace'first", null);
+ expectErrorInFromUriLiteral(instance, "namespace.namespace'fi'rst", null);
+ expectErrorInFromUriLiteral(instance, "namespace.namespace'first'", null);
+ expectErrorInFromUriLiteral(instance, "namespace.name'fir'st'", "must be of format");
}
@Test
@@ -279,13 +289,17 @@ public class EdmEnumTest {
expectContentErrorInValueToString(int16EnumType, Integer.MAX_VALUE);
}
- protected void expectErrorInFromUriLiteral(final EdmPrimitiveType instance, final String value) {
+ protected void expectErrorInFromUriLiteral(final EdmPrimitiveType instance, final String value, final String error) {
try {
instance.fromUriLiteral(value);
fail("Expected exception not thrown");
} catch (final EdmPrimitiveTypeException e) {
assertNotNull(e.getLocalizedMessage());
- assertThat(e.getLocalizedMessage(), containsString("' has illegal content."));
+ if(error == null){
+ assertThat(e.getLocalizedMessage(), containsString("' has illegal content."));
+ }else{
+ assertThat(e.getLocalizedMessage(), containsString(error));
+ }
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c7838a67/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index 69458ab..58ccf16 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -88,6 +88,14 @@ public class TestFullResourcePath {
.isEntitySet("ESMixEnumDefCollComp")
.goUpUriValidator()
.goFilter().is("<<PropertyEnumString> has <olingo.odata.test1.ENString<String1>>>");
+
+ testUri
+ .run("ESMixEnumDefCollComp(PropertyEnumString=Namespace1_Alias.ENString'String1',PropertyDefString='abc')")
+ .goPath()
+ .at(0)
+ .isEntitySet("ESMixEnumDefCollComp")
+ .isKeyPredicate(0, "PropertyEnumString", "Namespace1_Alias.ENString'String1'")
+ .isKeyPredicate(1, "PropertyDefString", "'abc'");
}
@Test
[4/4] olingo-odata4 git commit: [OLINGO-568] Merge branch 'master'
into OLINGO-568_SearchParser_Draft
Posted by mi...@apache.org.
[OLINGO-568] Merge branch 'master' into OLINGO-568_SearchParser_Draft
arser_Draft
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/c0adc020
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/c0adc020
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/c0adc020
Branch: refs/heads/OLINGO-568_SearchParser_Draft
Commit: c0adc020b22ed728aaed1659fc8485e4c214141f
Parents: 9ff30e7 6614aea
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Nov 17 10:50:06 2015 +0100
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Nov 17 10:50:06 2015 +0100
----------------------------------------------------------------------
.../commons/core/edm/EdmEnumTypeImpl.java | 47 ++++++--
.../server/core/edm/provider/EdmEnumTest.java | 16 ++-
.../core/uri/parser/UriParseTreeVisitor.java | 18 ++-
.../TechnicalPrimitiveComplexProcessor.java | 8 +-
.../expression/ExpressionVisitorImpl.java | 9 +-
.../expression/operand/UntypedOperand.java | 19 +---
.../queryoptions/options/FilterHandler.java | 2 +-
.../queryoptions/options/OrderByHandler.java | 4 +-
.../core/uri/antlr/TestFullResourcePath.java | 113 +++++++++++++++----
9 files changed, 170 insertions(+), 66 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c0adc020/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
[3/4] olingo-odata4 git commit: [OLINGO-821] small fix for UriParser
handling of Enum/TypeDefinition
Posted by mi...@apache.org.
[OLINGO-821] small fix for UriParser handling of Enum/TypeDefinition
Signed-off-by: Christian Amend <ch...@sap.com>
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/6614aea6
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/6614aea6
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/6614aea6
Branch: refs/heads/OLINGO-568_SearchParser_Draft
Commit: 6614aea6bae1cacfaa71712f8335c253cef7dd0c
Parents: 0c100df
Author: Klaus Straubinger <kl...@sap.com>
Authored: Tue Nov 10 16:10:44 2015 +0100
Committer: Christian Amend <ch...@sap.com>
Committed: Tue Nov 10 16:16:53 2015 +0100
----------------------------------------------------------------------
.../server/core/edm/provider/EdmEnumTest.java | 28 +++--
.../core/uri/parser/UriParseTreeVisitor.java | 18 +++-
.../TechnicalPrimitiveComplexProcessor.java | 8 +-
.../core/uri/antlr/TestFullResourcePath.java | 105 +++++++++++++++----
4 files changed, 117 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6614aea6/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
index 04be8ae..af2d12f 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
@@ -68,7 +68,7 @@ public class EdmEnumTest {
.setUnderlyingType(EdmPrimitiveTypeKind.SByte.getFullQualifiedName()));
when(edm.getEnumType(new FullQualifiedName("namespace.name"))).thenReturn(instance);
when(edm.getEnumType(new FullQualifiedName("alias.name"))).thenReturn(instance);
-
+
otherInstance = new EdmEnumTypeImpl(null, enumName,
new CsdlEnumType().setName("name").setMembers(memberList).setFlags(true)
.setUnderlyingType(EdmPrimitiveTypeKind.SByte.getFullQualifiedName()));
@@ -178,15 +178,15 @@ public class EdmEnumTest {
assertEquals("first", instance.fromUriLiteral("namespace.name'first'"));
assertEquals("first", instance.fromUriLiteral("alias.name'first'"));
- expectErrorInFromUriLiteral(instance, "", null);
- expectErrorInFromUriLiteral(instance, "'", null);
- expectErrorInFromUriLiteral(instance, "''", null);
- expectErrorInFromUriLiteral(instance, "name'first'", null);
- expectErrorInFromUriLiteral(instance, "namespace.name'", null);
- expectErrorInFromUriLiteral(instance, "namespace.name'first", null);
- expectErrorInFromUriLiteral(instance, "namespace.namespace'first", null);
- expectErrorInFromUriLiteral(instance, "namespace.namespace'fi'rst", null);
- expectErrorInFromUriLiteral(instance, "namespace.namespace'first'", null);
+ expectErrorInFromUriLiteral(instance, "");
+ expectErrorInFromUriLiteral(instance, "'");
+ expectErrorInFromUriLiteral(instance, "''");
+ expectErrorInFromUriLiteral(instance, "name'first'");
+ expectErrorInFromUriLiteral(instance, "namespace.name'");
+ expectErrorInFromUriLiteral(instance, "namespace.name'first");
+ expectErrorInFromUriLiteral(instance, "namespace.namespace'first");
+ expectErrorInFromUriLiteral(instance, "namespace.namespace'fi'rst");
+ expectErrorInFromUriLiteral(instance, "namespace.namespace'first'");
}
@Test
@@ -291,17 +291,13 @@ public class EdmEnumTest {
expectContentErrorInValueToString(int16EnumType, Integer.MAX_VALUE);
}
- protected void expectErrorInFromUriLiteral(final EdmPrimitiveType instance, final String value, final String error) {
+ protected void expectErrorInFromUriLiteral(final EdmPrimitiveType instance, final String value) {
try {
instance.fromUriLiteral(value);
fail("Expected exception not thrown");
} catch (final EdmPrimitiveTypeException e) {
assertNotNull(e.getLocalizedMessage());
- if(error == null){
- assertThat(e.getLocalizedMessage(), containsString("' has illegal content."));
- }else{
- assertThat(e.getLocalizedMessage(), containsString(error));
- }
+ assertThat(e.getLocalizedMessage(), containsString("' has illegal content."));
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6614aea6/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
index eaf1075..c155355 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
@@ -483,7 +483,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
if (property instanceof EdmProperty) {
- if (((EdmProperty) property).isPrimitive()) {
+ if (((EdmProperty) property).isPrimitive()
+ || property.getType().getKind() == EdmTypeKind.ENUM
+ || property.getType().getKind() == EdmTypeKind.DEFINITION) {
// create simple property
UriResourcePrimitivePropertyImpl simpleResource = new UriResourcePrimitivePropertyImpl()
.setProperty((EdmProperty) property);
@@ -1046,6 +1048,11 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
return type;
}
+ type = edm.getTypeDefinition(fullName);
+ if (type != null) {
+ return type;
+ }
+
type = edm.getEnumType(fullName);
if (type != null) {
return type;
@@ -1994,8 +2001,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public Object visitDecimalLiteral(final DecimalLiteralContext ctx) {
final EdmType type = EdmPrimitiveTypeFactory.getInstance(
- ctx.getText().contains("e") || ctx.getText().contains("E") ? EdmPrimitiveTypeKind.Double
- : EdmPrimitiveTypeKind.Decimal);
+ ctx.getText().contains("e") || ctx.getText().contains("E") ?
+ EdmPrimitiveTypeKind.Double :
+ EdmPrimitiveTypeKind.Decimal);
return new LiteralImpl().setText(ctx.getText()).setType(type);
}
@@ -2216,7 +2224,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// contextSelectItem.addSegment(newSegment);
if (element instanceof EdmProperty) {
EdmProperty property = (EdmProperty) element;
- if (property.isPrimitive()) {
+ if (property.isPrimitive()
+ || property.getType().getKind() == EdmTypeKind.ENUM
+ || property.getType().getKind() == EdmTypeKind.DEFINITION) {
UriResourcePrimitivePropertyImpl simple = new UriResourcePrimitivePropertyImpl();
simple.setProperty(property);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6614aea6/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
index 5928c30..87fbf00 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
@@ -460,8 +460,12 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
if (entitySet != null && !path.isEmpty()) {
builder = builder.navOrPropertyPath(buildPropertyPath(path));
}
- builder = builder.selectList(type.getKind() == EdmTypeKind.PRIMITIVE ? null :
- helper.buildContextURLSelectList((EdmStructuredType) type, expand, select));
+ builder = builder.selectList(
+ type.getKind() == EdmTypeKind.PRIMITIVE
+ || type.getKind() == EdmTypeKind.ENUM
+ || type.getKind() == EdmTypeKind.DEFINITION ?
+ null :
+ helper.buildContextURLSelectList((EdmStructuredType) type, expand, select));
return builder.build();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6614aea6/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index 58ccf16..fc48b9d 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -54,6 +54,7 @@ import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
import org.apache.olingo.server.tecsvc.provider.EntityTypeProvider;
import org.apache.olingo.server.tecsvc.provider.EnumTypeProvider;
import org.apache.olingo.server.tecsvc.provider.PropertyProvider;
+import org.apache.olingo.server.tecsvc.provider.TypeDefinitionProvider;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
@@ -1424,6 +1425,26 @@ public class TestFullResourcePath {
.isComplex("PropertyComp")
.n()
.isComplex("PropertyComp");
+
+ testUri.run("ESMixEnumDefCollComp(PropertyEnumString=olingo.odata.test1.ENString'String1',"
+ + "PropertyDefString='key1')/PropertyEnumString")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESMixEnumDefCollComp")
+ .isKeyPredicate(0, "PropertyEnumString", "olingo.odata.test1.ENString'String1'")
+ .isKeyPredicate(1, "PropertyDefString", "'key1'")
+ .n()
+ .isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false);
+
+ testUri.run("ESMixEnumDefCollComp(PropertyEnumString=olingo.odata.test1.ENString'String1',"
+ + "PropertyDefString='key1')/PropertyDefString")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESMixEnumDefCollComp")
+ .isKeyPredicate(0, "PropertyEnumString", "olingo.odata.test1.ENString'String1'")
+ .isKeyPredicate(1, "PropertyDefString", "'key1'")
+ .n()
+ .isPrimitiveProperty("PropertyDefString", TypeDefinitionProvider.nameTDString, false);
}
@Test
@@ -1458,6 +1479,26 @@ public class TestFullResourcePath {
.isType(ComplexTypeProvider.nameCTPrimComp, true)
.n()
.isCount();
+
+ testUri.run("ESMixEnumDefCollComp(PropertyEnumString=olingo.odata.test1.ENString'String1',"
+ + "PropertyDefString='key1')/CollPropertyEnumString")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESMixEnumDefCollComp")
+ .isKeyPredicate(0, "PropertyEnumString", "olingo.odata.test1.ENString'String1'")
+ .isKeyPredicate(1, "PropertyDefString", "'key1'")
+ .n()
+ .isPrimitiveProperty("CollPropertyEnumString", EnumTypeProvider.nameENString, true);
+
+ testUri.run("ESMixEnumDefCollComp(PropertyEnumString=olingo.odata.test1.ENString'String1',"
+ + "PropertyDefString='key1')/CollPropertyDefString")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESMixEnumDefCollComp")
+ .isKeyPredicate(0, "PropertyEnumString", "olingo.odata.test1.ENString'String1'")
+ .isKeyPredicate(1, "PropertyDefString", "'key1'")
+ .n()
+ .isPrimitiveProperty("CollPropertyDefString", TypeDefinitionProvider.nameTDString, true);
}
@Test
@@ -2717,6 +2758,17 @@ public class TestFullResourcePath {
.goUpExpandValidator()
.isSelectText("PropertyCompNav/PropertyInt16");
+ testUri.run("ESMixEnumDefCollComp",
+ "$select=PropertyEnumString,PropertyDefString,CollPropertyEnumString,CollPropertyDefString")
+ .isKind(UriInfoKind.resource)
+ .goSelectItemPath(0).isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
+ .goUpUriValidator()
+ .goSelectItemPath(1).isPrimitiveProperty("PropertyDefString", TypeDefinitionProvider.nameTDString, false)
+ .goUpUriValidator()
+ .goSelectItemPath(2).isPrimitiveProperty("CollPropertyEnumString", EnumTypeProvider.nameENString, true)
+ .goUpUriValidator()
+ .goSelectItemPath(3).isPrimitiveProperty("CollPropertyDefString", TypeDefinitionProvider.nameTDString, true);
+
testUri.runEx("ESKeyNav", "$expand=undefined")
.isExSemantic(MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE);
testUri.runEx("ESTwoKeyNav", "$expand=PropertyCompNav/undefined")
@@ -3599,7 +3651,6 @@ public class TestFullResourcePath {
.root().right()
.isType(PropertyProvider.nameDecimal);
- //
testFilter.runOnETAllPrim("PropertyDecimal ge PropertyDecimal")
.is("<<PropertyDecimal> ge <PropertyDecimal>>")
.isBinary(BinaryOperatorKind.GE)
@@ -4397,8 +4448,6 @@ public class TestFullResourcePath {
.goUpFilterValidator().root()
.goParameter(1).isTypedLiteral(ComplexTypeProvider.nameCTTwoPrim);
- // testFilter.runOnETKeyNav(" Xcast(PropertyCompTwoPrim,olingo.odata.test1.CTAllPrim)");
-
testFilter.runOnETKeyNav("cast(NavPropertyETKeyNavOne,olingo.odata.test1.ETKeyPrimNav)")
.is("<cast(<NavPropertyETKeyNavOne>,<olingo.odata.test1.ETKeyPrimNav>)>")
.isMethod(MethodKind.CAST, 2)
@@ -4657,7 +4706,7 @@ public class TestFullResourcePath {
.goUpFilterValidator()
.root().goParameter(1).isTypedLiteral(PropertyProvider.nameTimeOfDay);
- testFilter.runOnETTwoKeyNav(" isof(PropertyComp/PropertyComp/PropertyDuration,Edm.Duration)")
+ testFilter.runOnETTwoKeyNav("isof(PropertyComp/PropertyComp/PropertyDuration,Edm.Duration)")
.is("<isof(<PropertyComp/PropertyComp/PropertyDuration>,<Edm.Duration>)>")
.root()
.isMethod(MethodKind.ISOF, 2)
@@ -4689,6 +4738,20 @@ public class TestFullResourcePath {
.n().isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false)
.goUpFilterValidator()
.root().goParameter(1).isTypedLiteral(PropertyProvider.nameGuid);
+
+ testFilter.runOnETMixEnumDefCollComp("isof(PropertyEnumString,Namespace1_Alias.ENString)")
+ .isMethod(MethodKind.ISOF, 2)
+ .goParameter(0).goPath()
+ .first().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
+ .goUpFilterValidator()
+ .root().goParameter(1).isTypedLiteral(EnumTypeProvider.nameENString);
+
+ testFilter.runOnETMixEnumDefCollComp("isof(PropertyDefString,Namespace1_Alias.TDString)")
+ .isMethod(MethodKind.ISOF, 2)
+ .goParameter(0).goPath()
+ .first().isPrimitiveProperty("PropertyDefString", TypeDefinitionProvider.nameTDString, false)
+ .goUpFilterValidator()
+ .root().goParameter(1).isTypedLiteral(TypeDefinitionProvider.nameTDString);
}
@Test
@@ -4697,7 +4760,7 @@ public class TestFullResourcePath {
testFilter.runOnETMixEnumDefCollComp("PropertyEnumString has olingo.odata.test1.ENString'String1'")
.is("<<PropertyEnumString> has <olingo.odata.test1.ENString<String1>>>")
.isBinary(BinaryOperatorKind.HAS)
- .root().left().goPath().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString)
+ .root().left().goPath().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
.goUpFilterValidator()
.root().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String1"));
@@ -4707,8 +4770,7 @@ public class TestFullResourcePath {
.isBinary(BinaryOperatorKind.HAS)
.root().left().goPath()
.first().isComplex("PropertyCompMixedEnumDef")
- .n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString)
- .isType(EnumTypeProvider.nameENString)
+ .n().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
.goUpFilterValidator()
.root().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String2"));
@@ -4722,7 +4784,7 @@ public class TestFullResourcePath {
.isBinary(BinaryOperatorKind.HAS)
.root().left().left().goPath()
.first().isComplex("PropertyCompMixedEnumDef")
- .n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString)
+ .n().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
.goUpFilterValidator()
.root().left().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String2"));
@@ -4730,8 +4792,7 @@ public class TestFullResourcePath {
.is("<<PropertyEnumString> has <olingo.odata.test1.ENString<String3>>>")
.isBinary(BinaryOperatorKind.HAS)
.root().left().goPath()
- .first().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString)
- .isType(EnumTypeProvider.nameENString)
+ .first().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
.goUpFilterValidator()
.root().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String3"));
@@ -4739,8 +4800,7 @@ public class TestFullResourcePath {
.is("<<PropertyEnumString> has <olingo.odata.test1.ENString<String,String3>>>")
.isBinary(BinaryOperatorKind.HAS)
.root().left().goPath()
- .first().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString)
- .isType(EnumTypeProvider.nameENString)
+ .first().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
.goUpFilterValidator()
.root().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String", "String3"));
@@ -4749,7 +4809,8 @@ public class TestFullResourcePath {
.root()
.isBinary(BinaryOperatorKind.HAS)
.root().left().goPath()
- .first().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString).goUpFilterValidator()
+ .first().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
+ .goUpFilterValidator()
.root().right().isNull();
testFilter.runOnETTwoKeyNav("endswith(PropertyComp/PropertyComp/PropertyString,'dorf')")
@@ -4964,14 +5025,14 @@ public class TestFullResourcePath {
testFilter.runOnETMixEnumDefCollComp("PropertyEnumString eq olingo.odata.test1.ENString'String1'")
.is("<<PropertyEnumString> eq <olingo.odata.test1.ENString<String1>>>")
.isBinary(BinaryOperatorKind.EQ)
- .root().left().goPath().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString)
+ .root().left().goPath().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
.goUpFilterValidator()
.root().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String1"));
testFilter.runOnETMixEnumDefCollComp("PropertyEnumString eq olingo.odata.test1.ENString'String2'")
.is("<<PropertyEnumString> eq <olingo.odata.test1.ENString<String2>>>")
.isBinary(BinaryOperatorKind.EQ)
- .root().left().goPath().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString)
+ .root().left().goPath().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
.goUpFilterValidator()
.root().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String2"));
@@ -4981,7 +5042,8 @@ public class TestFullResourcePath {
.isBinary(BinaryOperatorKind.EQ)
.root().left().goPath()
.first().isComplex("PropertyCompMixedEnumDef")
- .n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString).goUpFilterValidator()
+ .n().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
+ .goUpFilterValidator()
.root().right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String3"));
testFilter
@@ -4993,10 +5055,11 @@ public class TestFullResourcePath {
.isBinary(BinaryOperatorKind.EQ)
.root().left().goPath()
.first().isComplex("PropertyCompMixedEnumDef")
- .n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString).goUpFilterValidator()
+ .n().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
+ .goUpFilterValidator()
.root().right().goPath()
.first().isComplex("PropertyCompMixedEnumDef")
- .n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString).goUpFilterValidator();
+ .n().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false);
testFilter.runUriEx("ESMixEnumDefCollComp", "$filter=PropertyEnumString has ENString'String1'")
.isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
@@ -5337,12 +5400,14 @@ public class TestFullResourcePath {
testFilter.runOrderByOnETMixEnumDefCollComp("PropertyEnumString eq olingo.odata.test1.ENString'String1'")
.isSortOrder(0, false)
- .goOrder(0).left().goPath().isComplex("PropertyEnumString").goUpFilterValidator()
+ .goOrder(0).left().goPath().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
+ .goUpFilterValidator()
.goOrder(0).right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String1"));
testFilter.runOrderByOnETMixEnumDefCollComp("PropertyEnumString eq olingo.odata.test1.ENString'String1' desc")
.isSortOrder(0, true)
- .goOrder(0).left().goPath().isComplex("PropertyEnumString").goUpFilterValidator()
+ .goOrder(0).left().goPath().isPrimitiveProperty("PropertyEnumString", EnumTypeProvider.nameENString, false)
+ .goUpFilterValidator()
.goOrder(0).right().isEnum(EnumTypeProvider.nameENString, Arrays.asList("String1"));
testFilter.runOrderByOnETTwoKeyNavEx("PropertyInt16 1")
[2/4] olingo-odata4 git commit: [OLINGO-821] Optimize alias handling
in enum types
Posted by mi...@apache.org.
[OLINGO-821] Optimize alias handling in enum types
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/0c100df4
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/0c100df4
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/0c100df4
Branch: refs/heads/OLINGO-568_SearchParser_Draft
Commit: 0c100df480fc396ae9b4e53ace0e79f186686545
Parents: c7838a6
Author: Christian Amend <ch...@sap.com>
Authored: Tue Nov 10 10:52:33 2015 +0100
Committer: Christian Amend <ch...@sap.com>
Committed: Tue Nov 10 10:52:33 2015 +0100
----------------------------------------------------------------------
.../commons/core/edm/EdmEnumTypeImpl.java | 53 ++++++++++++--------
.../server/core/edm/provider/EdmEnumTest.java | 4 +-
.../expression/ExpressionVisitorImpl.java | 9 ++--
.../expression/operand/UntypedOperand.java | 19 +------
.../queryoptions/options/FilterHandler.java | 2 +-
.../queryoptions/options/OrderByHandler.java | 4 +-
6 files changed, 41 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0c100df4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java
index 1f7f070..ea28c16 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java
@@ -44,7 +44,6 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
private final EdmPrimitiveType underlyingType;
private final CsdlEnumType enumType;
private final FullQualifiedName enumName;
- private final String uriSuffix;
private List<String> memberNames;
private Map<String, EdmMember> membersMap;
@@ -68,7 +67,6 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
this.enumType = enumType;
this.enumName = enumName;
- uriSuffix = "'";
}
@Override
@@ -228,32 +226,43 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
@Override
public String toUriLiteral(final String literal) {
- return literal == null ? null : enumName.getFullQualifiedNameAsString() + "'" + literal + uriSuffix;
+ return literal == null ? null : enumName.getFullQualifiedNameAsString() + "'" + literal + "'";
}
@Override
public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException {
if (literal == null) {
return null;
- }
-
- if (literal.endsWith(uriSuffix)) {
- String[] splitLiteral = literal.split("'");
- if (splitLiteral.length != 2) {
- throw new EdmPrimitiveTypeException("The literal '" + literal
- + "' must be of format FullQuallifiedTypeName'literal'");
- }
- // First part must be the FullQualifiedName
- FullQualifiedName typeFqn = null;
- try {
- typeFqn = new FullQualifiedName(splitLiteral[0]);
- } catch (IllegalArgumentException e) {
- throw new EdmPrimitiveTypeException("The literal '" + literal + "' has illegal content.", e);
- }
- // Get itself. This will also resolve a possible alias
- EdmEnumType prospect = edm.getEnumType(typeFqn);
- if (prospect != null && enumName.equals(prospect.getFullQualifiedName())) {
- return splitLiteral[1];
+ } else {
+ String uriPrefix = enumName.getFullQualifiedNameAsString() + "'";
+ String uriSuffix = "'";
+ if (literal.length() >= uriPrefix.length() + uriSuffix.length()
+ && literal.startsWith(uriPrefix) && literal.endsWith(uriSuffix)) {
+ // This is the positive case where the literal is prefixed with the full qualified name of the enum type
+ return literal.substring(uriPrefix.length(), literal.length() - uriSuffix.length());
+ } else {
+ // This case will be called if the prefix might be an alias
+ if (literal.endsWith(uriSuffix)) {
+ int indexSingleQuote = literal.indexOf('\'');
+ String fqn = literal.substring(0, indexSingleQuote);
+ FullQualifiedName typeFqn = null;
+ try {
+ typeFqn = new FullQualifiedName(fqn);
+ } catch (IllegalArgumentException e) {
+ throw new EdmPrimitiveTypeException("The literal '" + literal + "' has illegal content.", e);
+ }
+ /*
+ * Get itself. This will also resolve a possible alias. If we had an easier way to query the edm for an alias
+ * we could use this here. But since there is no such method we try to get the enum type based on a possible
+ * alias qualified name. This way the edm will resolve the alias for us. Also in a positive case the type is
+ * already cached so the EdmProvider should not be called.
+ */
+ EdmEnumType prospect = edm.getEnumType(typeFqn);
+ if (prospect != null && enumName.equals(prospect.getFullQualifiedName())
+ && literal.length() >= fqn.length() + 2) {
+ return literal.substring(fqn.length() + 1, literal.length() - 1);
+ }
+ }
}
}
throw new EdmPrimitiveTypeException("The literal '" + literal + "' has illegal content.");
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0c100df4/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
index dbcda3a..04be8ae 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
@@ -179,12 +179,14 @@ public class EdmEnumTest {
assertEquals("first", instance.fromUriLiteral("alias.name'first'"));
expectErrorInFromUriLiteral(instance, "", null);
+ expectErrorInFromUriLiteral(instance, "'", null);
+ expectErrorInFromUriLiteral(instance, "''", null);
expectErrorInFromUriLiteral(instance, "name'first'", null);
+ expectErrorInFromUriLiteral(instance, "namespace.name'", null);
expectErrorInFromUriLiteral(instance, "namespace.name'first", null);
expectErrorInFromUriLiteral(instance, "namespace.namespace'first", null);
expectErrorInFromUriLiteral(instance, "namespace.namespace'fi'rst", null);
expectErrorInFromUriLiteral(instance, "namespace.namespace'first'", null);
- expectErrorInFromUriLiteral(instance, "namespace.name'fir'st'", "must be of format");
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0c100df4/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
index b362456..95343fd 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
@@ -23,7 +23,6 @@ import java.util.Locale;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmProperty;
@@ -51,12 +50,10 @@ public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand>
private final Entity entity;
private final UriInfoResource uriInfo;
- private final Edm edm;
- public ExpressionVisitorImpl(final Entity entity, final UriInfoResource uriInfo, final Edm edm) {
+ public ExpressionVisitorImpl(final Entity entity, final UriInfoResource uriInfo) {
this.entity = entity;
this.uriInfo = uriInfo;
- this.edm = edm;
}
@Override
@@ -174,7 +171,7 @@ public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand>
@Override
public VisitorOperand visitLiteral(final Literal literal) throws ExpressionVisitException, ODataApplicationException {
- return new UntypedOperand(literal.getText(), edm);
+ return new UntypedOperand(literal.getText());
}
@Override
@@ -209,7 +206,7 @@ public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand>
@Override
public VisitorOperand visitAlias(final String aliasName) throws ExpressionVisitException, ODataApplicationException {
- return new UntypedOperand(uriInfo.getValueForAlias(aliasName), edm);
+ return new UntypedOperand(uriInfo.getValueForAlias(aliasName));
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0c100df4/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/UntypedOperand.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/UntypedOperand.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/UntypedOperand.java
index 755d8d1..dba114b 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/UntypedOperand.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/UntypedOperand.java
@@ -20,21 +20,15 @@ package org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operan
import java.util.Locale;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.server.api.ODataApplicationException;
public class UntypedOperand extends VisitorOperand {
- private final Edm edm;
-
- public UntypedOperand(final String literal, final Edm edm) {
+ public UntypedOperand(final String literal) {
super(literal);
- this.edm = edm;
}
@Override
@@ -132,17 +126,6 @@ public class UntypedOperand extends VisitorOperand {
return new TypedOperand(newValue, primDouble);
}
- // Enum
- final EdmSchema schema = edm.getSchema(edm.getEntityContainer().getNamespace());
- final String enumValue = schema.getAlias() != null && literal.startsWith(schema.getAlias()) ?
- literal.replace(schema.getAlias(), schema.getNamespace()) :
- literal;
- for (final EdmEnumType enumType : schema.getEnumTypes()) {
- if ((newValue = tryCast(enumValue, enumType)) != null) {
- return new TypedOperand(newValue, enumType);
- }
- }
-
throw new ODataApplicationException("Could not determine type for literal " + literal,
HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0c100df4/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
index b2bd405..1a19016 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
@@ -53,7 +53,7 @@ public class FilterHandler {
while (iter.hasNext()) {
final VisitorOperand operand = filterOption.getExpression()
- .accept(new ExpressionVisitorImpl(iter.next(), uriInfo, edm));
+ .accept(new ExpressionVisitorImpl(iter.next(), uriInfo));
final TypedOperand typedOperand = operand.asTypedOperand();
if (typedOperand.is(primBoolean)) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0c100df4/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
index ad1d2d5..ddcf0af 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
@@ -70,9 +70,9 @@ public class OrderByHandler {
try {
final OrderByItem item = orderByOption.getOrders().get(i);
final TypedOperand op1 =
- item.getExpression().accept(new ExpressionVisitorImpl(e1, uriInfo, edm)).asTypedOperand();
+ item.getExpression().accept(new ExpressionVisitorImpl(e1, uriInfo)).asTypedOperand();
final TypedOperand op2 =
- item.getExpression().accept(new ExpressionVisitorImpl(e2, uriInfo, edm)).asTypedOperand();
+ item.getExpression().accept(new ExpressionVisitorImpl(e2, uriInfo)).asTypedOperand();
if (op1.isNull() || op2.isNull()) {
if (op1.isNull() && op2.isNull()) {