[OLINGO-63] Uri Parser: add special handling for leading type filter in member, expand, select

This commit is contained in:
Sven Kobler 2014-02-20 12:26:16 +01:00
parent 30ca8f01a3
commit 32467b8d62
61 changed files with 486 additions and 315 deletions

View File

@ -25,7 +25,7 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.ExpandOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.FilterOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.FormatOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.IdOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.InlineCountOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.CountOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.OrderByOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.SearchOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.SelectOption;
@ -45,7 +45,7 @@ public interface UriInfoResource {
IdOption getIdOption();
InlineCountOption getInlineCountOption();
CountOption getInlineCountOption();
OrderByOption getOrderByOption();

View File

@ -1,29 +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.odata4.server.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface UriResourceStartingTypeFilter extends UriResourcePartTyped {
EdmType getTypeFilterOnCollection();
EdmType getTypeFilterOnEntry();
}

View File

@ -18,7 +18,7 @@
******************************************************************************/
package org.apache.olingo.odata4.server.api.uri.queryoption;
public interface InlineCountOption extends SystemQueryOption {
public interface CountOption extends SystemQueryOption {
boolean getValue();

View File

@ -18,6 +18,7 @@
******************************************************************************/
package org.apache.olingo.odata4.server.api.uri.queryoption;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.server.api.uri.UriInfoResource;
public interface ExpandItem {
@ -34,16 +35,19 @@ public interface ExpandItem {
TopOption getTopOption();
InlineCountOption getInlineCountOption();
CountOption getInlineCountOption();
SelectOption getSelectOption();
ExpandOption getExpandOption();
UriInfoResource getResourceInfo();
UriInfoResource getResourcePath();
boolean isStar();
boolean isRef();
EdmType getStartTypeFilter();
}

View File

@ -18,6 +18,7 @@
******************************************************************************/
package org.apache.olingo.odata4.server.api.uri.queryoption;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
import org.apache.olingo.odata4.server.api.uri.UriInfoResource;
@ -29,6 +30,8 @@ public interface SelectItem {
FullQualifiedName getAllOperationsInSchemaNameSpace();
UriInfoResource getResourceInfo();
UriInfoResource getResourcePath();
EdmType getStartTypeFilter();
}

View File

@ -23,10 +23,14 @@ import org.apache.olingo.odata4.server.api.uri.UriInfoResource;
public interface Member extends Expression {
public UriInfoResource getPath();
public UriInfoResource getResourcePath();
public EdmType getType();
public EdmType getStartTypeFilter();
public boolean isCollection();
}

View File

@ -347,7 +347,7 @@ odataIdentifier : ODATAIDENTIFIER;
primitiveLiteral : nullrule
| booleanNonCase
| DECIMAL //includes double and single literals
| NANINFINITY
| naninfinity
| INT //includes int16/int32 and int64 literals
| BINARY
| DATE
@ -373,6 +373,7 @@ primitiveLiteral : nullrule
| geometryPolygon
;
naninfinity : NANINFINITY;
nullrule : NULLVALUE;
booleanNonCase : BOOLEAN | TRUE | FALSE;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import java.util.ArrayList;
import java.util.Collections;
@ -38,7 +38,7 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.ExpandOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.FilterOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.FormatOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.IdOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.InlineCountOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.CountOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.OrderByOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.SearchOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.SelectOption;
@ -181,7 +181,7 @@ public class UriInfoImpl implements UriInfo {
}
@Override
public InlineCountOption getInlineCountOption() {
public CountOption getInlineCountOption() {
return inlineCountOption;
}
@ -288,4 +288,9 @@ public class UriInfoImpl implements UriInfo {
this.fragment = fragment;
return this;
}
public void removeResourcePart(int index) {
this.pathParts.remove(index);
}
}

View File

@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.server.api.uri.UriParameter;
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmAction;
import org.apache.olingo.odata4.commons.api.edm.EdmActionImport;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.server.api.uri.UriResourceCount;
import org.apache.olingo.odata4.server.api.uri.UriResourceKind;

View File

@ -17,7 +17,7 @@
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmEntitySet;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import java.util.ArrayList;
import java.util.List;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.server.api.uri.UriResource;
import org.apache.olingo.odata4.server.api.uri.UriResourceKind;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.server.api.uri.UriResourceIt;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmType;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmType;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.server.api.uri.UriResourceKind;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmType;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmType;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.server.api.uri.UriResourceKind;
import org.apache.olingo.odata4.server.api.uri.UriResourceRef;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.server.api.uri.UriResourceKind;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;

View File

@ -1,29 +1,29 @@
/*******************************************************************************
* 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.
* 2 * Licensed to the Apache Software Foundation (ASF) under one
* 3 * or more contributor license agreements. See the NOTICE file
* 4 * distributed with this work for additional information
* 5 * regarding copyright ownership. The ASF licenses this file
* 6 * to you under the Apache License, Version 2.0 (the
* 7 * "License"); you may not use this file except in compliance
* 8 * with the License. You may obtain a copy of the License at
* 9 *
* 10 * http://www.apache.org/licenses/LICENSE-2.0
* 11 *
* 12 * Unless required by applicable law or agreed to in writing,
* 13 * software distributed under the License is distributed on an
* 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* 15 * KIND, either express or implied. See the License for the
* 16 * specific language governing permissions and limitations
* 17 * under the License.
* 18
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.server.api.uri.UriResourceKind;
import org.apache.olingo.odata4.server.api.uri.UriResourceStartingTypeFilter;
public class UriResourceStartingTypeFilterImpl extends UriResourceWithKeysImpl
implements UriResourceStartingTypeFilter {
public class UriResourceStartingTypeFilterImpl extends UriResourceWithKeysImpl {
private EdmType type;
private boolean isCollection;
@ -65,4 +65,4 @@ public class UriResourceStartingTypeFilterImpl extends UriResourceWithKeysImpl
return type.getNamespace() + "." + type.getName();
}
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType;
import org.apache.olingo.odata4.commons.api.edm.EdmType;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import org.apache.olingo.odata4.server.api.uri.UriResourceKind;
import org.apache.olingo.odata4.server.api.uri.UriResourceValue;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.apiimpl;
package org.apache.olingo.odata4.server.core.uri;
import java.util.ArrayList;
import java.util.List;

View File

@ -34,8 +34,8 @@ import org.apache.olingo.odata4.server.api.uri.UriInfo;
import org.apache.olingo.odata4.server.api.uri.UriInfoKind;
import org.apache.olingo.odata4.server.api.uri.UriResource;
import org.apache.olingo.odata4.server.api.uri.UriResourcePartTyped;
import org.apache.olingo.odata4.server.core.uri.UriParserException;
import org.apache.olingo.odata4.server.core.uri.UriParserSyntaxException;
import org.apache.olingo.odata4.server.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceImpl;
import org.apache.olingo.odata4.server.core.uri.antlr.UriLexer;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.AllEOFContext;
@ -48,8 +48,6 @@ import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.MetadataEO
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.OrderByEOFContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.PathSegmentEOFContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.SelectEOFContext;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.CountOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.CustomQueryOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;

View File

@ -22,7 +22,7 @@ import java.util.List;
public class RawUri {
public String uri;
public String sheme;
public String scheme;
public String authority;
public String path;
public String queryOptionString;

View File

@ -21,11 +21,11 @@ package org.apache.olingo.odata4.server.core.uri.parser;
import java.util.Stack;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.server.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.ExpandPathContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.ExpandPathExtensionContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.SelectItemContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.SelectSegmentContext;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.parser.UriParseTreeVisitor.TypeInformation;
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandItemImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.SelectItemImpl;

View File

@ -27,7 +27,6 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.olingo.odata4.server.core.uri.UriParserSyntaxException;
import org.apache.olingo.odata4.server.core.uri.parser.RawUri.QueryOption;
public class UriDecoder {
@ -39,7 +38,7 @@ public class UriDecoder {
Matcher m = uriPattern.matcher(uri);
if (m.matches()) {
rawUri.sheme = m.group(2);
rawUri.scheme = m.group(2);
rawUri.authority = m.group(4);
rawUri.path = m.group(5);
rawUri.queryOptionString = m.group(7);

View File

@ -49,8 +49,27 @@ import org.apache.olingo.odata4.server.api.uri.UriResource;
import org.apache.olingo.odata4.server.api.uri.UriResourcePartTyped;
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind;
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind;
import org.apache.olingo.odata4.server.core.uri.UriParserException;
import org.apache.olingo.odata4.server.core.uri.UriParserSemanticException;
import org.apache.olingo.odata4.server.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.UriParameterImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceActionImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceComplexPropertyImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceCountImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceEntitySetImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceFunctionImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceItImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceLambdaAllImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceLambdaAnyImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceLambdaVarImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceNavigationPropertyImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourcePrimitivePropertyImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceRefImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceRootImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceSingletonImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceStartingTypeFilterImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceTypedImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceValueImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceWithKeysImpl;
import org.apache.olingo.odata4.server.core.uri.antlr.UriLexer;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserBaseVisitor;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.AliasAndValueContext;
@ -109,8 +128,10 @@ import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.MonthMetho
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.NameValueOptListContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.NameValuePairContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.NamespaceContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.NaninfinityContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.NowMethodCallExprContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.NullruleContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.Number_in_jsonContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.OdataIdentifierContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.OrderByContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.OrderByEOFContext;
@ -141,27 +162,6 @@ import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.Totalsecon
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.TrimMethodCallExprContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.UnaryContext;
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.YearMethodCallExprContext;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriParameterImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceActionImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceComplexPropertyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceCountImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceEntitySetImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceFunctionImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceItImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceLambdaAllImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceLambdaAnyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceLambdaVarImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceNavigationPropertyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourcePrimitivePropertyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceRefImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceRootImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceSingletonImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceStartingTypeFilterImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceTypedImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceValueImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceWithKeysImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.AliasQueryOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.CountOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandItemImpl;
@ -461,7 +461,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (lastResourcePart == null) {
// this may be the case if a member expression within a filter starts with a typeCast
UriResourceStartingTypeFilterImpl uriResource = new UriResourceStartingTypeFilterImpl()
.setType(source.type)
.setType(filterEntityType)
.setCollection(source.isCollection);
if (source.isCollection) {
uriResource.setCollectionTypeFilter(filterEntityType);
@ -527,7 +527,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (lastResourcePart == null) {
// this may be the case if a member expression within a filter starts with a typeCast
UriResourceStartingTypeFilterImpl uriResource = new UriResourceStartingTypeFilterImpl()
.setType(source.type)
.setType(filterComplexType)
.setCollection(source.isCollection);
if (source.isCollection) {
@ -702,8 +702,43 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
uriInfoImplpath.addResourcePart((UriResourceImpl) super.visitAltAll(ctx));
return new MemberImpl()
.setPath(uriInfoImplpath);
EdmType startType = removeUriResourceStartingTypeFilterImpl(uriInfoImplpath);
MemberImpl ret = new MemberImpl();
ret.setResourcePath(uriInfoImplpath);
if (startType != null) {
ret.setTypeFilter(startType);
}
return ret;
}
private EdmType removeUriResourceStartingTypeFilterImpl(UriInfoImpl uriInfoImplpath) {
List<UriResource> segments = uriInfoImplpath.getUriResourceParts();
if (segments.size() == 0) {
return null;
}
UriResource segment = segments.get(0);
if (segment instanceof UriResourceStartingTypeFilterImpl) {
UriResourceStartingTypeFilterImpl startingTypeFilter = (UriResourceStartingTypeFilterImpl) segment;
EdmType type = null;
if (startingTypeFilter.getTypeFilterOnEntry()!= null) {
type =startingTypeFilter.getTypeFilterOnEntry();
} else if (startingTypeFilter.getTypeFilterOnCollection()!= null) {
type =startingTypeFilter.getTypeFilterOnCollection();
} else {
type =startingTypeFilter.getType();
}
uriInfoImplpath.removeResourcePart(0);
return type;
}
return null;
}
@Override
@ -723,8 +758,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
uriInfoImplpath.addResourcePart((UriResourceImpl) super.visitAltAny(ctx));
return new MemberImpl()
.setPath(uriInfoImplpath);
EdmType startType = removeUriResourceStartingTypeFilterImpl(uriInfoImplpath);
MemberImpl ret = new MemberImpl();
ret.setResourcePath(uriInfoImplpath);
if (startType != null) {
ret.setTypeFilter(startType);
}
return ret;
}
@Override
@ -1127,7 +1168,12 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// contextUriInfo.addPathInfo(pathInfoIT);
super.visitExpandPath(ctx);
expandItem.setResourceInfo(context.contextUriInfo);
EdmType startType = this.removeUriResourceStartingTypeFilterImpl(context.contextUriInfo);
expandItem.setResourcePath(context.contextUriInfo);
if ( startType != null) {
expandItem.setTypeFilter(startType);
}
// reset context
context.contextUriInfo = uriInfoResourceBU;
@ -1148,14 +1194,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
targetType = getTypeInformation(lastSegment).type;
isColl = lastSegment.isCollection();
} else {
if (context.contextExpandItemPath.getResourceInfo() == null) {
if (context.contextExpandItemPath.getResourcePath() == null) {
// use the type of the last resource path segement
UriResourceTypedImpl lastSegment = (UriResourceTypedImpl) context.contextUriInfo.getLastResourcePart();
targetType = getTypeInformation(lastSegment).type;
isColl = lastSegment.isCollection();
} else {
// use the type of the last ''expand'' path segement
UriInfoImpl info = (UriInfoImpl) context.contextExpandItemPath.getResourceInfo();
UriInfoImpl info = (UriInfoImpl) context.contextExpandItemPath.getResourcePath();
targetType = getTypeInformation((UriResourceImpl) info.getLastResourcePart()).type;
isColl = ((UriResourcePartTyped) info.getLastResourcePart()).isCollection();
}
@ -1164,14 +1210,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
context.contextTypes.push(new TypeInformation(targetType, isColl));
if (ctx.vC != null) {
UriInfoImpl resourcePath = (UriInfoImpl) context.contextExpandItemPath.getResourceInfo();
UriInfoImpl resourcePath = (UriInfoImpl) context.contextExpandItemPath.getResourcePath();
resourcePath.addResourcePart(new UriResourceCountImpl());
for (ExpandCountOptionContext s : ctx.vlEOC) {
list.add((SystemQueryOptionImpl) s.accept(this));
}
} else if (ctx.vR != null) {
UriInfoImpl resourcePath = (UriInfoImpl) context.contextExpandItemPath.getResourceInfo();
UriInfoImpl resourcePath = (UriInfoImpl) context.contextExpandItemPath.getResourcePath();
resourcePath.addResourcePart(new UriResourceRefImpl());
for (ExpandRefOptionContext s : ctx.vlEOR) {
@ -1367,8 +1413,15 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
uriInfoImplpath.addResourcePart((UriResourceImpl) ctx.vANY.accept(this));
}
return new MemberImpl()
.setPath(uriInfoImplpath);
EdmType startType = removeUriResourceStartingTypeFilterImpl(uriInfoImplpath);
MemberImpl ret = new MemberImpl();
ret.setResourcePath(uriInfoImplpath);
if (startType != null) {
ret.setTypeFilter(startType);
}
return ret;
}
@Override
@ -1558,6 +1611,11 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
return uriParameter;
}
@Override
public Object visitNaninfinity(NaninfinityContext ctx) {
return new LiteralImpl().setType(EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance()).setText(ctx.getText());
}
@Override
public ExpressionImpl visitNowMethodCallExpr(final NowMethodCallExprContext ctx) {
return new MethodCallImpl()
@ -1663,7 +1721,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (child1 instanceof EnumLitContext ||
child1 instanceof BooleanNonCaseContext ||
child1 instanceof NullruleContext) {
child1 instanceof NullruleContext ||
child1 instanceof NaninfinityContext) {
return child1.accept(this);
}
return new LiteralImpl().setText(ctx.getText());
@ -1727,7 +1786,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
return new MemberImpl()
.setPath(uriInfoImplpath);
.setResourcePath(uriInfoImplpath);
}
@ -1799,15 +1858,16 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (ctx.vNS == null) {
EdmType prevType = null;
if (context.contextSelectItem.getResourceInfo() == null) {
if (context.contextSelectItem.getResourcePath() == null) {
prevType = context.contextTypes.peek().type;
} else {
UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourceInfo();
UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourcePath();
UriResource last = uriInfo.getLastResourcePart();
if (!(last instanceof UriResourceTypedImpl)) {
throw wrap(new UriParserSemanticException("prev segement typed"));
prevType = getTypeInformation( last).type;
if (prevType == null) {
throw wrap(new UriParserSemanticException("prev segement not typed"));
}
prevType = getTypeInformation((UriResourceTypedImpl) last).type;
}
if (!(prevType instanceof EdmStructuralType)) {
@ -1830,17 +1890,23 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriResourcePrimitivePropertyImpl simple = new UriResourcePrimitivePropertyImpl();
simple.setProperty(property);
UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourceInfo();
UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourcePath();
if (uriInfo == null) {
uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource);
uriInfo.addResourcePart(simple);
context.contextSelectItem.setResourceInfo(uriInfo);
EdmType startType = this.removeUriResourceStartingTypeFilterImpl(uriInfo);
if (startType != null) {
context.contextSelectItem.setTypeFilter(startType);
}
context.contextSelectItem.setResourcePath(uriInfo);
} else {
uriInfo.addResourcePart(simple);
}
return this;
} else {
UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourceInfo();
UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourcePath();
UriResourceComplexPropertyImpl complex = new UriResourceComplexPropertyImpl();
complex.setProperty(property);
@ -1848,7 +1914,13 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (uriInfo == null) {
uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource);
uriInfo.addResourcePart(complex);
context.contextSelectItem.setResourceInfo(uriInfo);
EdmType startType = this.removeUriResourceStartingTypeFilterImpl(uriInfo);
if (startType != null) {
context.contextSelectItem.setTypeFilter(startType);
}
context.contextSelectItem.setResourcePath(uriInfo);
} else {
uriInfo.addResourcePart(complex);
}
@ -1864,7 +1936,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
FullQualifiedName fullName = new FullQualifiedName(namespace, odi);
// contextSelectItem.addQualifiedThing(fullName);
if (context.contextSelectItem.getResourceInfo() == null) {
if (context.contextSelectItem.getResourcePath() == null) {
EdmType prevType = context.contextTypes.peek().type;
// check for complex type cast
@ -1877,7 +1949,13 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriInfoImpl uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource);
uriInfo.addResourcePart(resourcePart);
context.contextSelectItem.setResourceInfo(uriInfo);
EdmType startType = this.removeUriResourceStartingTypeFilterImpl(uriInfo);
if (startType != null) {
context.contextSelectItem.setTypeFilter(startType);
}
context.contextSelectItem.setResourcePath(uriInfo);
return this;
}
}
@ -1890,7 +1968,13 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriInfoImpl uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource);
uriInfo.addResourcePart(resourcePart);
context.contextSelectItem.setResourceInfo(uriInfo);
EdmType startType = this.removeUriResourceStartingTypeFilterImpl(uriInfo);
if (startType != null) {
context.contextSelectItem.setTypeFilter(startType);
}
context.contextSelectItem.setResourcePath(uriInfo);
return this;
}
}
@ -1899,7 +1983,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
} else {
UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourceInfo();
UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourcePath();
UriResource last = uriInfo.getLastResourcePart();
if (!(last instanceof UriResourceTypedImpl)) {
throw wrap(new UriParserSemanticException("prev segement typed"));
@ -1937,10 +2021,10 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
EdmType prevType = null;
if (context.contextSelectItem.getResourceInfo() == null) {
if (context.contextSelectItem.getResourcePath() == null) {
prevType = context.contextTypes.peek().type;
} else {
UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourceInfo();
UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourcePath();
UriResource last = uriInfo.getLastResourcePart();
if (!(last instanceof UriResourceTypedImpl)) {
throw wrap(new UriParserSemanticException("prev segement typed"));
@ -1958,7 +2042,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriResourceActionImpl uriAction = new UriResourceActionImpl();
uriAction.setAction(action);
UriInfoImpl resourcePath = (UriInfoImpl) context.contextSelectItem.getResourceInfo();
UriInfoImpl resourcePath = (UriInfoImpl) context.contextSelectItem.getResourcePath();
resourcePath.addResourcePart(uriAction);
}
@ -1970,7 +2054,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriResourceFunctionImpl uriFunction = new UriResourceFunctionImpl();
uriFunction.setFunction(function);
UriInfoImpl resourcePath = (UriInfoImpl) context.contextSelectItem.getResourceInfo();
UriInfoImpl resourcePath = (UriInfoImpl) context.contextSelectItem.getResourcePath();
resourcePath.addResourcePart(uriFunction);
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri;
package org.apache.olingo.odata4.server.core.uri.parser;
//TODO Check name of this exception when implementing proper error handling
public class UriParserException extends Exception {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri;
package org.apache.olingo.odata4.server.core.uri.parser;
//TODO Check name of this exception when implementing proper error handling
public class UriParserSemanticException extends UriParserException {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri;
package org.apache.olingo.odata4.server.core.uri.parser;
public class UriParserSyntaxException extends UriParserException {

View File

@ -18,10 +18,10 @@
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.queryoption;
import org.apache.olingo.odata4.server.api.uri.queryoption.InlineCountOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.CountOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions;
public class CountOptionImpl extends SystemQueryOptionImpl implements InlineCountOption {
public class CountOptionImpl extends SystemQueryOptionImpl implements CountOption {
private boolean count;

View File

@ -21,11 +21,12 @@ package org.apache.olingo.odata4.server.core.uri.queryoption;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.server.api.uri.UriInfoResource;
import org.apache.olingo.odata4.server.api.uri.queryoption.ExpandItem;
import org.apache.olingo.odata4.server.api.uri.queryoption.ExpandOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.FilterOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.InlineCountOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.CountOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.LevelsExpandOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.OrderByOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.SearchOption;
@ -33,6 +34,7 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.SelectOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.SkipOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions;
import org.apache.olingo.odata4.server.api.uri.queryoption.TopOption;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.MemberImpl;
public class ExpandItemImpl implements ExpandItem {
private LevelsExpandOption levelsExpandOption;
@ -41,7 +43,7 @@ public class ExpandItemImpl implements ExpandItem {
private OrderByOption orderByOption;
private SkipOption skipOption;
private TopOption topOption;
private InlineCountOption inlineCountOption;
private CountOption inlineCountOption;
private SelectOption selectOption;
private ExpandOption expandOption;
@ -50,6 +52,7 @@ public class ExpandItemImpl implements ExpandItem {
private boolean isStar;
private boolean isRef;
private EdmType startTypeFilter;
public ExpandItemImpl setSystemQueryOption(final SystemQueryOptionImpl sysItem) {
@ -114,7 +117,7 @@ public class ExpandItemImpl implements ExpandItem {
}
@Override
public InlineCountOption getInlineCountOption() {
public CountOption getInlineCountOption() {
return inlineCountOption;
}
@ -129,13 +132,13 @@ public class ExpandItemImpl implements ExpandItem {
return expandOption;
}
public ExpandItemImpl setResourceInfo(final UriInfoResource resourceInfo) {
public ExpandItemImpl setResourcePath(final UriInfoResource resourceInfo) {
this.resourceInfo = resourceInfo;
return this;
}
@Override
public UriInfoResource getResourceInfo() {
public UriInfoResource getResourcePath() {
return resourceInfo;
}
@ -160,4 +163,15 @@ public class ExpandItemImpl implements ExpandItem {
return this;
}
@Override
public EdmType getStartTypeFilter() {
return this.startTypeFilter;
}
public ExpandItemImpl setTypeFilter(EdmType startTypeFilter) {
this.startTypeFilter = startTypeFilter;
return this;
}
}

View File

@ -18,6 +18,7 @@
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.queryoption;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
import org.apache.olingo.odata4.server.api.uri.UriInfoResource;
import org.apache.olingo.odata4.server.api.uri.queryoption.SelectItem;
@ -29,13 +30,15 @@ public class SelectItemImpl implements SelectItem {
private boolean isStar;
private FullQualifiedName addOperationsInSchemaNameSpace;
private EdmType startTypeFilter;
@Override
public UriInfoResource getResourceInfo() {
public UriInfoResource getResourcePath() {
return path;
}
public SelectItemImpl setResourceInfo(final UriInfoResource path) {
public SelectItemImpl setResourcePath(final UriInfoResource path) {
this.path = path;
return this;
}
@ -67,5 +70,15 @@ public class SelectItemImpl implements SelectItem {
public void addAllOperationsInSchema(final FullQualifiedName addOperationsInSchemaNameSpace) {
this.addOperationsInSchemaNameSpace = addOperationsInSchemaNameSpace;
}
@Override
public EdmType getStartTypeFilter() {
return this.startTypeFilter;
}
public SelectItemImpl setTypeFilter(EdmType startTypeFilter) {
this.startTypeFilter = startTypeFilter;
return this;
}
}

View File

@ -25,21 +25,22 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Member;
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceTypedImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceWithKeysImpl;
import org.apache.olingo.odata4.server.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceTypedImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceWithKeysImpl;
public class MemberImpl extends ExpressionImpl implements Member, VisitableExression {
private UriInfoResource path;
private EdmType startTypeFilter;
@Override
public UriInfoResource getPath() {
public UriInfoResource getResourcePath() {
return path;
}
public Member setPath(final UriInfoResource pathSegments) {
public Member setResourcePath(final UriInfoResource pathSegments) {
path = pathSegments;
return this;
}
@ -84,5 +85,15 @@ public class MemberImpl extends ExpressionImpl implements Member, VisitableExres
}
return false;
}
@Override
public EdmType getStartTypeFilter() {
return this.startTypeFilter;
}
public MemberImpl setTypeFilter(EdmType startTypeFilter) {
this.startTypeFilter = startTypeFilter;
return this;
}
}

View File

@ -26,6 +26,7 @@ import java.util.List;
import org.apache.olingo.odata4.server.core.uri.parser.RawUri;
import org.apache.olingo.odata4.server.core.uri.parser.UriDecoder;
import org.apache.olingo.odata4.server.core.uri.parser.UriParserSyntaxException;
import org.junit.Test;
public class RawUriTest {

View File

@ -38,9 +38,6 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.CustomQueryOption;
import org.apache.olingo.odata4.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.odata4.server.core.testutil.EdmTechProvider;
import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceActionImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceEntitySetImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.CountOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.CustomQueryOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;

View File

@ -42,25 +42,6 @@ import org.apache.olingo.odata4.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.odata4.server.core.edm.provider.EdmSingletonImpl;
import org.apache.olingo.odata4.server.core.testutil.EdmTechProvider;
import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriParameterImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceActionImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceComplexPropertyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceCountImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceEntitySetImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceFunctionImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceItImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceLambdaAllImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceLambdaAnyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceLambdaVarImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceNavigationPropertyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourcePrimitivePropertyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceRefImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceRootImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceSingletonImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceStartingTypeFilterImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceTypedImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceValueImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceWithKeysImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ExpressionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.LiteralImpl;
import org.junit.Test;
@ -495,6 +476,7 @@ public class UriParameterImplTest {
assertEquals(true, impl.isCollection());
}
/*
@Test
public void testUriResourceStartingTypeFilterImpl() {
UriResourceStartingTypeFilterImpl impl = new UriResourceStartingTypeFilterImpl();
@ -516,5 +498,5 @@ public class UriParameterImplTest {
impl.setKeyPredicates(keyPredicates);
assertEquals(false, impl.isCollection());
}
}*/
}

View File

@ -18,12 +18,17 @@
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.antlr;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
import org.apache.olingo.odata4.commons.api.edm.Edm;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
import org.apache.olingo.odata4.server.api.uri.UriInfoKind;
import org.apache.olingo.odata4.server.api.uri.UriResourceKind;
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind;
@ -32,10 +37,11 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCall
import org.apache.olingo.odata4.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.odata4.server.core.testutil.EdmTechProvider;
import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.odata4.server.core.testutil.FilterValidator;
import org.apache.olingo.odata4.server.core.testutil.ResourceValidator;
import org.apache.olingo.odata4.server.core.testutil.UriValidator;
import org.apache.olingo.odata4.server.core.uri.UriParserException;
import org.apache.olingo.odata4.server.core.uri.parser.UriParserException;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.MemberImpl;
import org.apache.olingo.odata4.server.core.uri.testutil.FilterValidator;
import org.apache.olingo.odata4.server.core.uri.testutil.ResourceValidator;
import org.apache.olingo.odata4.server.core.uri.testutil.UriValidator;
import org.junit.Test;
public class TestFullResourcePath {
@ -53,7 +59,7 @@ public class TestFullResourcePath {
@Test
public void test() throws UriParserException {
// testUri.log("ESAllPrim?$orderby=PropertyDouble eq 3.5E+38");
}
@Test
@ -2344,10 +2350,11 @@ public class TestFullResourcePath {
+ "$expand=com.sap.odata.test1.ETBaseTwoKeyNav/NavPropertyETKeyNavMany")
.isKind(UriInfoKind.resource).goPath().first()
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
.isType(EdmTechProvider.nameETTwoKeyNav)
.isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
.n()
// .isType(EdmTechProvider.nameETTwoKeyNav)
// .isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
// .n()
.isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true);
testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='Hugo')?"
@ -2356,10 +2363,11 @@ public class TestFullResourcePath {
.isKeyPredicate(0, "PropertyInt16", "1")
.isKeyPredicate(1, "PropertyString", "'Hugo'")
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
.isType(EdmTechProvider.nameETTwoKeyNav)
.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
.n()
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
//.n()
.isNavProperty("NavPropertyETKeyNavMany", EdmTechProvider.nameETKeyNav, true);
testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?"
@ -2368,10 +2376,11 @@ public class TestFullResourcePath {
.isKeyPredicate(0, "PropertyInt16", "1")
.isKeyPredicate(1, "PropertyString", "'2'")
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
.isType(EdmTechProvider.nameETTwoKeyNav)
.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
.n()
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
//.n()
.isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true);
testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?$expand=com.sap.odata.test1.ETBaseTwoKeyNav"
@ -2380,20 +2389,22 @@ public class TestFullResourcePath {
.isKeyPredicate(0, "PropertyInt16", "1")
.isKeyPredicate(1, "PropertyString", "'2'")
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
.isType(EdmTechProvider.nameETTwoKeyNav)
.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
.n()
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
//.n()
.isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
.isTypeFilterOnCollection(EdmTechProvider.nameETTwoBaseTwoKeyNav);
testUri.run("ESTwoKeyNav?$expand=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplexNav/NavPropertyETTwoKeyNavOne")
.isKind(UriInfoKind.resource).goPath().first()
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
.isType(EdmTechProvider.nameETTwoKeyNav)
.isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
.n()
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
//.n()
.isComplex("PropertyComplexNav")
.isType(EdmTechProvider.nameCTBasePrimCompNav)
.n()
@ -2403,10 +2414,11 @@ public class TestFullResourcePath {
+ "/com.sap.odata.test1.CTTwoBasePrimCompNav/NavPropertyETTwoKeyNavOne")
.isKind(UriInfoKind.resource).goPath().first()
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
.isType(EdmTechProvider.nameETTwoKeyNav)
.isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
.n()
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
//.n()
.isComplex("PropertyComplexNav")
.isType(EdmTechProvider.nameCTBasePrimCompNav)
.n()
@ -2434,11 +2446,12 @@ public class TestFullResourcePath {
.isKeyPredicate(0, "PropertyInt16", "1")
.isKeyPredicate(1, "PropertyString", "'2'")
.goExpand().first()
.isExpandStartType(EdmTechProvider.nameETBaseTwoKeyNav)
.goPath().first()
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
.n().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
//.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
//.isType(EdmTechProvider.nameETTwoKeyNav)
//.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
//.n().isNavProperty("NavPropertyETTwoKeyNavMany", EdmTechProvider.nameETTwoKeyNav, true)
.isType(EdmTechProvider.nameETTwoKeyNav)
.isTypeFilterOnCollection(EdmTechProvider.nameETTwoBaseTwoKeyNav)
.goUpExpandValidator()
@ -2462,6 +2475,17 @@ public class TestFullResourcePath {
.goPath().first()
.isNavProperty("NavPropertyETKeyNavOne", EdmTechProvider.nameETKeyNav, false)
.isType(EdmTechProvider.nameETKeyNav);
testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?$select=com.sap.odata.test1.ETBaseTwoKeyNav"
+ "/PropertyInt16")
.isKind(UriInfoKind.resource).goPath()
.first()
.isKeyPredicate(0, "PropertyInt16", "1")
.isKeyPredicate(1, "PropertyString", "'2'")
.isSelectStartType(0, EdmTechProvider.nameETBaseTwoKeyNav)
.goSelectItem(0)
.first()
.isPrimitiveProperty("PropertyInt16", EdmTechProvider.nameInt16, false);
testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($select=PropertyInt16)")
.isKind(UriInfoKind.resource)
@ -2835,25 +2859,27 @@ public class TestFullResourcePath {
.root().right();
testFilter.runOnETTwoKeyNav("com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate eq 2013-11-12")
.is("<<com.sap.odata.test1.ETTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate> eq <2013-11-12>>")
.is("<<PropertyDate> eq <2013-11-12>>")
.root().left()
.isType(EdmTechProvider.nameDate)
.isMember().goPath()
.first().isUriPathInfoKind(UriResourceKind.startingTypeFilter)
.isType(EdmTechProvider.nameETTwoKeyNav).isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
.n().isPrimitiveProperty("PropertyDate", EdmTechProvider.nameDate, false)
.isMember().isMemberStartType(EdmTechProvider.nameETBaseTwoKeyNav).goPath()
// .first().isUriPathInfoKind(UriResourceKind.startingTypeFilter)
// .isType(EdmTechProvider.nameETTwoKeyNav).isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
// .n().isPrimitiveProperty("PropertyDate", EdmTechProvider.nameDate, false)
.first().isPrimitiveProperty("PropertyDate", EdmTechProvider.nameDate, false)
.goUpFilterValidator()
.root().right()
.isLiteral("2013-11-12");
testFilter.runOnCTTwoPrim("com.sap.odata.test1.CTBase/AdditionalPropString eq 'SomeString'")
.is("<<com.sap.odata.test1.CTTwoPrim/com.sap.odata.test1.CTBase/AdditionalPropString> eq <'SomeString'>>")
.is("<<AdditionalPropString> eq <'SomeString'>>")
.root().left()
.isType(EdmTechProvider.nameString)
.isMember().goPath()
.first().isUriPathInfoKind(UriResourceKind.startingTypeFilter)
.isType(EdmTechProvider.nameCTTwoPrim).isTypeFilterOnEntry(EdmTechProvider.nameCTBase)
.n().isPrimitiveProperty("AdditionalPropString", EdmTechProvider.nameString, false)
.isMember().isMemberStartType(EdmTechProvider.nameCTBase).goPath()
// .first().isUriPathInfoKind(UriResourceKind.startingTypeFilter)
// .isType(EdmTechProvider.nameCTTwoPrim).isTypeFilterOnEntry(EdmTechProvider.nameCTBase)
// .n().isPrimitiveProperty("AdditionalPropString", EdmTechProvider.nameString, false)
.first().isPrimitiveProperty("AdditionalPropString", EdmTechProvider.nameString, false)
.goUpFilterValidator()
.root().right()
.isLiteral("'SomeString'");
@ -2874,7 +2900,7 @@ public class TestFullResourcePath {
.root().right()
.isLiteral("'SomeString'");
// testFilter.runOnETTwoKeyNavEx("invalid").isExSemantic(0);
testFilter.runOnETTwoKeyNavEx("invalid").isExSemantic(0);
testFilter.runOnETTwoKeyNavEx("PropertyComplex/invalid").isExSemantic(0);
testFilter.runOnETTwoKeyNavEx("concat('a','b')/invalid").isExSyntax(0);
testFilter.runOnETTwoKeyNavEx("PropertyComplex/concat('a','b')").isExSyntax(0);
@ -3269,7 +3295,7 @@ public class TestFullResourcePath {
.root().right()
.isType(EdmTechProvider.nameDecimal);
// DODO not synced
//
testFilter.runOnETAllPrim("PropertyDecimal ge PropertyDecimal")
.is("<<PropertyDecimal> ge <PropertyDecimal>>")
.isBinary(BinaryOperatorKind.GE)
@ -3291,6 +3317,13 @@ public class TestFullResourcePath {
.isType(EdmTechProvider.nameDecimal)
.root().right()
.isType(EdmTechProvider.nameDecimal);
testFilter.runOnETAllPrim("PropertyDecimal sub NaN")
.right().isLiteral("NaN").isType(EdmTechProvider.nameDecimal);
testFilter.runOnETAllPrim("PropertyDecimal sub -INF")
.right().isLiteral("-INF").isType(EdmTechProvider.nameDecimal);
testFilter.runOnETAllPrim("PropertyDecimal sub INF")
.right().isLiteral("INF").isType(EdmTechProvider.nameDecimal);
}
@Test

View File

@ -19,7 +19,7 @@
package org.apache.olingo.odata4.server.core.uri.antlr;
import org.antlr.v4.runtime.Lexer;
import org.apache.olingo.odata4.server.core.testutil.TokenValidator;
import org.apache.olingo.odata4.server.core.uri.testutil.TokenValidator;
import org.junit.Test;
public class TestLexer {

View File

@ -18,7 +18,7 @@
******************************************************************************/
package org.apache.olingo.odata4.server.core.uri.antlr;
import org.apache.olingo.odata4.server.core.testutil.ParserValidator;
import org.apache.olingo.odata4.server.core.uri.testutil.ParserValidator;
import org.junit.Test;
/**

View File

@ -30,10 +30,10 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCall
import org.apache.olingo.odata4.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.odata4.server.core.testutil.EdmTechProvider;
import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.odata4.server.core.testutil.FilterValidator;
import org.apache.olingo.odata4.server.core.testutil.ResourceValidator;
import org.apache.olingo.odata4.server.core.testutil.UriValidator;
import org.apache.olingo.odata4.server.core.uri.UriParserException;
import org.apache.olingo.odata4.server.core.uri.parser.UriParserException;
import org.apache.olingo.odata4.server.core.uri.testutil.FilterValidator;
import org.apache.olingo.odata4.server.core.uri.testutil.ResourceValidator;
import org.apache.olingo.odata4.server.core.uri.testutil.UriValidator;
import org.junit.Test;
public class TestUriParserImpl {
@ -1005,40 +1005,44 @@ public class TestUriParserImpl {
// on EntityType entry
testUri.run("ESTwoKeyNav(ParameterInt16=1,PropertyString='ABC')?"
+ "$filter=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate")
.goFilter().root().isMember().goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
.isType(EdmTechProvider.nameETTwoKeyNav, false)
.isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
.at(1).isType(EdmTechProvider.nameDate);
.goFilter().root().isMember()
.isMemberStartType(EdmTechProvider.nameETBaseTwoKeyNav).goPath()
// .at(0)
// .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
// .isType(EdmTechProvider.nameETTwoKeyNav, false)
// .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav)
.at(0).isType(EdmTechProvider.nameDate);
// on EntityType collection
testUri.run("ESTwoKeyNav?$filter=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate")
.goFilter().root().isMember().goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
.isType(EdmTechProvider.nameETTwoKeyNav, true)
.isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
.at(1).isType(EdmTechProvider.nameDate);
.goFilter().root().isMember()
.isMemberStartType(EdmTechProvider.nameETBaseTwoKeyNav).goPath()
// .at(0)
// .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
// .isType(EdmTechProvider.nameETTwoKeyNav, true)
// .isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav)
.at(0).isType(EdmTechProvider.nameDate);
testUri.run("FICRTCTTwoPrimParam(ParameterInt16=1,ParameterString='2')?"
+ "$filter=com.sap.odata.test1.CTBase/AdditionalPropString")
.goFilter().root().isMember().goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
.isType(EdmTechProvider.nameCTTwoPrim, false)
.isTypeFilterOnEntry(EdmTechProvider.nameCTBase)
.at(1).isType(EdmTechProvider.nameString);
.goFilter().root().isMember()
.isMemberStartType(EdmTechProvider.nameCTBase).goPath()
//.at(0)
//.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
//.isType(EdmTechProvider.nameCTTwoPrim, false)
//.isTypeFilterOnEntry(EdmTechProvider.nameCTBase)
.at(0).isType(EdmTechProvider.nameString);
// on Complex collection
testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')?"
+ "$filter=com.sap.odata.test1.CTBase/AdditionalPropString")
.goFilter().root().isMember().goPath()
.at(0)
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
.isType(EdmTechProvider.nameCTTwoPrim, true)
.isTypeFilterOnCollection(EdmTechProvider.nameCTBase)
.at(1).isType(EdmTechProvider.nameString);
.goFilter().root().isMember()
.isMemberStartType(EdmTechProvider.nameCTBase).goPath()
//.at(0)
//.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
//.isType(EdmTechProvider.nameCTTwoPrim, true)
//.isTypeFilterOnCollection(EdmTechProvider.nameCTBase)
.at(0).isType(EdmTechProvider.nameString);
}
@ -1116,16 +1120,10 @@ public class TestUriParserImpl {
.isComplexProperty("PropertyComplex", EdmTechProvider.nameCTAllPrim, false);
testUri.run("ESTwoKeyNav?$select=com.sap.odata.test1.ETBaseTwoKeyNav")
.goSelectItemPath(0)
.first()
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
.isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav);
.isSelectStartType(0,EdmTechProvider.nameETBaseTwoKeyNav);
testUri.run("ESTwoKeyNav/PropertyComplexNav?$select=com.sap.odata.test1.CTTwoBasePrimCompNav")
.goSelectItemPath(0)
.first()
.isUriPathInfoKind(UriResourceKind.startingTypeFilter)
.isTypeFilterOnCollection(EdmTechProvider.nameCTTwoBasePrimCompNav);
.isSelectStartType(0,EdmTechProvider.nameCTTwoBasePrimCompNav);
testUri.run("ESTwoKeyNav?$select=PropertyComplexNav/com.sap.odata.test1.CTTwoBasePrimCompNav")
.goSelectItemPath(0)

View File

@ -29,7 +29,7 @@ import org.apache.olingo.odata4.server.api.uri.UriInfoResource;
import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions;
import org.apache.olingo.odata4.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.AliasImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ExpressionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.LiteralImpl;
@ -109,8 +109,8 @@ public class QueryOptionTest {
option = new ExpandItemImpl();
UriInfoResource resource = new UriInfoImpl().asUriInfoResource();
option.setResourceInfo(resource);
assertEquals(resource, option.getResourceInfo());
option.setResourcePath(resource);
assertEquals(resource, option.getResourcePath());
}

View File

@ -38,10 +38,10 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.expression.UnaryOpera
import org.apache.olingo.odata4.server.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.odata4.server.core.testutil.EdmTechProvider;
import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider;
import org.apache.olingo.odata4.server.core.testutil.FilterTreeToText;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceActionImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceFunctionImpl;
import org.apache.olingo.odata4.server.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceActionImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceFunctionImpl;
import org.apache.olingo.odata4.server.core.uri.testutil.FilterTreeToText;
import org.junit.Test;
public class ExpressionTest {
@ -135,11 +135,11 @@ public class ExpressionTest {
EdmAction action = edm.getAction(EdmTechProvider.nameUARTPrimParam, null, null);
UriInfoResource uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
new UriResourceActionImpl().setAction(action)).asUriInfoResource();
expression.setPath(uriInfo);
expression.setResourcePath(uriInfo);
assertEquals(action.getReturnType().getType(), expression.getType());
// check accept and path
assertEquals(uriInfo, expression.getPath());
assertEquals(uriInfo, expression.getResourcePath());
assertEquals("<UARTPrimParam>", expression.accept(new FilterTreeToText()));
// UriResourceImplTyped check collection = false case
@ -147,21 +147,21 @@ public class ExpressionTest {
// UriResourceImplTyped check collection = true case
action = edm.getAction(EdmTechProvider.nameUARTPrimCollParam, null, null);
expression.setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
new UriResourceActionImpl().setAction(action))
.asUriInfoResource());
assertEquals(true, expression.isCollection());
// UriResourceImplTyped with filter
action = edm.getAction(EdmTechProvider.nameUARTPrimParam, null, null);
expression.setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
new UriResourceActionImpl().setAction(action).setTypeFilter(entityType))
.asUriInfoResource());
assertEquals(entityType, expression.getType());
// UriResourceImplKeyPred
EdmFunction function = edm.getFunction(EdmTechProvider.nameUFCRTETKeyNav, null, null, null);
expression.setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
new UriResourceFunctionImpl().setFunction(function))
.asUriInfoResource());
assertEquals(function.getReturnType().getType(), expression.getType());
@ -170,7 +170,7 @@ public class ExpressionTest {
EdmEntityType entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null,
Arrays.asList(("ParameterInt16")));
expression.setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
new UriResourceFunctionImpl().setFunction(function).setEntryTypeFilter(entityBaseType))
.asUriInfoResource());
assertEquals(entityBaseType, expression.getType());
@ -179,7 +179,7 @@ public class ExpressionTest {
entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null,
Arrays.asList(("ParameterInt16")));
expression.setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
new UriResourceFunctionImpl().setFunction(function).setCollectionTypeFilter(entityBaseType))
.asUriInfoResource());
assertEquals(entityBaseType, expression.getType());
@ -188,7 +188,7 @@ public class ExpressionTest {
entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null,
Arrays.asList(("ParameterInt16")));
expression.setPath(new UriInfoImpl().setKind(UriInfoKind.all));
expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.all));
assertEquals(null, expression.getType());
// no typed collection else case

View File

@ -17,24 +17,26 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
import org.apache.olingo.odata4.commons.api.edm.Edm;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
import org.apache.olingo.odata4.server.api.uri.UriInfoKind;
import org.apache.olingo.odata4.server.api.uri.queryoption.ExpandItem;
import org.apache.olingo.odata4.server.api.uri.queryoption.SelectItem;
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.QueryOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.SelectOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.MemberImpl;
public class ExpandValidator implements Validator {
private Edm edm;
@ -73,7 +75,7 @@ public class ExpandValidator implements Validator {
}
public ResourceValidator goPath() {
UriInfoImpl uriInfo = (UriInfoImpl) expandItem.getResourceInfo();
UriInfoImpl uriInfo = (UriInfoImpl) expandItem.getResourcePath();
if (uriInfo.getKind() != UriInfoKind.resource) {
fail("goPath() can only be used on UriInfoKind.resource");
@ -99,7 +101,7 @@ public class ExpandValidator implements Validator {
SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
UriInfoImpl uriInfo = (UriInfoImpl) item.getResourceInfo();
UriInfoImpl uriInfo = (UriInfoImpl) item.getResourcePath();
return new ResourceValidator()
.setUpValidator(this)
@ -218,4 +220,14 @@ public class ExpandValidator implements Validator {
return this;
}
public ExpandValidator isExpandStartType(final FullQualifiedName fullName) {
EdmType actualType = expandItem.getStartTypeFilter();
FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
assertEquals(fullName, actualName);
return this;
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
import java.util.List;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@ -34,11 +34,11 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Member;
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind;
import org.apache.olingo.odata4.server.core.uri.UriParserException;
import org.apache.olingo.odata4.server.core.uri.UriParserSemanticException;
import org.apache.olingo.odata4.server.core.uri.UriParserSyntaxException;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.parser.Parser;
import org.apache.olingo.odata4.server.core.uri.parser.UriParserException;
import org.apache.olingo.odata4.server.core.uri.parser.UriParserSemanticException;
import org.apache.olingo.odata4.server.core.uri.parser.UriParserSyntaxException;
import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.BinaryImpl;
@ -272,7 +272,7 @@ public class FilterValidator implements Validator {
return new ResourceValidator()
.setEdm(edm)
.setUriInfoImplPath((UriInfoImpl) member.getPath())
.setUriInfoImplPath((UriInfoImpl) member.getResourcePath())
.setUpValidator(this);
}
@ -332,6 +332,9 @@ public class FilterValidator implements Validator {
} else if (curExpression instanceof TypeLiteralImpl) {
TypeLiteralImpl typeLiteral = (TypeLiteralImpl) curExpression;
actualType = typeLiteral.getType();
} else if (curExpression instanceof LiteralImpl) {
LiteralImpl typeLiteral = (LiteralImpl) curExpression;
actualType = typeLiteral.getType();
}
if (actualType == null) {
@ -441,6 +444,19 @@ public class FilterValidator implements Validator {
return this;
}
public FilterValidator isMemberStartType(final FullQualifiedName fullName) {
if (!(curExpression instanceof MemberImpl)) {
fail("Current expression not a member");
}
MemberImpl member = (MemberImpl) curExpression;
EdmType actualType = member.getStartTypeFilter();
FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
assertEquals(fullName, actualName);
return this;
}
public FilterValidator isEnum(final FullQualifiedName nameenstring, final List<String> enumValues) {
if (!(curExpression instanceof EnumerationImpl)) {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
import java.util.Arrays;
import java.util.List;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
import static org.junit.Assert.assertEquals;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
import org.antlr.v4.runtime.DefaultErrorStrategy;
import org.antlr.v4.runtime.DiagnosticErrorListener;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -37,23 +37,24 @@ import org.apache.olingo.odata4.server.api.uri.UriResourcePartTyped;
import org.apache.olingo.odata4.server.api.uri.queryoption.CustomQueryOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.SelectItem;
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
import org.apache.olingo.odata4.server.core.uri.UriParserException;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceActionImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceComplexPropertyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceEntitySetImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceFunctionImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceLambdaAllImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceLambdaAnyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceNavigationPropertyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourcePrimitivePropertyImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceSingletonImpl;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceWithKeysImpl;
import org.apache.olingo.odata4.server.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceActionImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceComplexPropertyImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceEntitySetImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceFunctionImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceLambdaAllImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceLambdaAnyImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceNavigationPropertyImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourcePrimitivePropertyImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceSingletonImpl;
import org.apache.olingo.odata4.server.core.uri.UriResourceWithKeysImpl;
import org.apache.olingo.odata4.server.core.uri.parser.UriParserException;
import org.apache.olingo.odata4.server.core.uri.queryoption.CustomQueryOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.SelectOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ExpressionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.MemberImpl;
public class ResourceValidator implements Validator {
private Edm edm;
@ -148,7 +149,7 @@ public class ResourceValidator implements Validator {
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourceInfo();
UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourcePath();
return new ResourceValidator()
.setUpValidator(this)
@ -568,4 +569,15 @@ public class ResourceValidator implements Validator {
return this;
}
public ResourceValidator isSelectStartType(final int index, FullQualifiedName fullName) {
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
EdmType actualType = item.getStartTypeFilter();
FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
assertEquals(fullName, actualName);
return this;
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
import java.util.BitSet;
import java.util.Collections;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
import static org.junit.Assert.assertEquals;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.Token;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@ -25,15 +25,16 @@ import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.Edm;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
import org.apache.olingo.odata4.server.api.uri.UriInfoKind;
import org.apache.olingo.odata4.server.api.uri.queryoption.CustomQueryOption;
import org.apache.olingo.odata4.server.api.uri.queryoption.SelectItem;
import org.apache.olingo.odata4.server.core.uri.UriParserException;
import org.apache.olingo.odata4.server.core.uri.UriParserSemanticException;
import org.apache.olingo.odata4.server.core.uri.UriParserSyntaxException;
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.server.core.uri.parser.Parser;
import org.apache.olingo.odata4.server.core.uri.parser.UriParserException;
import org.apache.olingo.odata4.server.core.uri.parser.UriParserSemanticException;
import org.apache.olingo.odata4.server.core.uri.parser.UriParserSyntaxException;
import org.apache.olingo.odata4.server.core.uri.queryoption.CustomQueryOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;
import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl;
@ -129,7 +130,7 @@ public class UriValidator implements Validator {
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourceInfo();
UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourcePath();
return new ResourceValidator()
.setUpValidator(this)
@ -137,6 +138,18 @@ public class UriValidator implements Validator {
.setUriInfoImplPath(uriInfo1);
}
public UriValidator isSelectStartType(int index, final FullQualifiedName fullName) {
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
EdmType actualType = item.getStartTypeFilter();
FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
assertEquals(fullName, actualName);
return this;
}
// Validation
public UriValidator isKind(final UriInfoKind kind) {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.server.core.testutil;
package org.apache.olingo.odata4.server.core.uri.testutil;
public interface Validator {