[OLINGO-63] Uri Parser: Add support for II

This commit is contained in:
Sven Kobler 2013-12-18 11:23:48 +01:00
parent 4954467155
commit 7955eadf02
157 changed files with 9798 additions and 3116 deletions

View File

@ -179,6 +179,7 @@ public class EdmProviderImpl extends EdmImpl {
for (Function function : functions) {
if (function.isBound() == false) {
List<Parameter> parameters = function.getParameters();
// TODO add check for parameters == null;
if (parameterNames.size() == parameters.size()) {
List<String> functionParameterNames = new ArrayList<String>();
for (Parameter parameter : parameters) {

View File

@ -19,6 +19,23 @@
package org.apache.olingo.odata4.producer.api.uri;
public interface UriInfo {
public interface UriInfo extends
UriInfoService, UriInfoAll, UriInfoBatch, UriInfoCrossjoin,
UriInfoEntityId, UriInfoMetadata, UriInfoResource {
public UriInfoService asUriInfoService();
public UriInfoAll asUriInfoAll();
public UriInfoBatch asUriInfoBatch();
public UriInfoCrossjoin asUriInfoCrossjoin();
public UriInfoEntityId asUriInfoEntityId();
public UriInfoMetadata asUriInfoMetadata();
public UriInfoResource asUriInfoResource();
public UriInfoKind getKind();
}

View File

@ -19,6 +19,6 @@
package org.apache.olingo.odata4.producer.api.uri;
public enum UriPathInfoKind {
entitySet, navEntitySet, singleton, action, function, it;
public interface UriInfoAll {
}

View File

@ -19,6 +19,6 @@
package org.apache.olingo.odata4.producer.api.uri;
public interface UriInfoBatch {
public interface UriInfoBatch {
}

View File

@ -1,4 +1,5 @@
/*******************************************************************************
*
* 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
@ -16,15 +17,12 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
import java.util.List;
public interface UriPathInfo {
public UriPathInfoKind getKind();
public interface UriInfoCrossjoin {
public EdmEntityContainer getEntityContainer();
List<String> getEntitySetNames();
public boolean isCollection();
}

View File

@ -0,0 +1,48 @@
/*******************************************************************************
* 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.producer.api.uri;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.FormatOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.IdOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption;
/**
* Indicates a URL access to an single Entity
*/
public interface UriInfoEntityId {
public List<CustomQueryOption> getCustomQueryOptions();
public EdmEntityType getEntityTypeCast();
public ExpandOption getExpandOption();
public FormatOption getFormatOption();
public IdOption getIdOption();
public SelectOption getSelectOption();
}

View File

@ -20,6 +20,5 @@
package org.apache.olingo.odata4.producer.api.uri;
public enum UriInfoKind {
batch,entity, metadata, all, crossjoin, path;
all, batch, crossjoin, entityId, metadata, resource, service;
}

View File

@ -0,0 +1,28 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.producer.api.uri.queryoption.FormatOption;
public interface UriInfoMetadata {
public String getContext();
public FormatOption getFormatOption();
}

View File

@ -0,0 +1,64 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
import java.util.List;
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.FilterOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.FormatOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.IdOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.InlineCountOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipTokenOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption;
public interface UriInfoResource {
List<CustomQueryOption> getCustomQueryOptions();
ExpandOption getExpandOption();
FilterOption getFilterOption();
FormatOption getFormatOption();
IdOption getIdOption();
InlineCountOption getInlineCountOption();
OrderByOption getOrderByOption();
SearchOption getSearchOption();
SelectOption getSelectOption();
SkipOption getSkipOption();
SkipTokenOption getSkipTokenOption();
TopOption getTopOption();
List<UriResourcePart> getUriResourceParts();
}

View File

@ -0,0 +1,23 @@
/*******************************************************************************
* 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.producer.api.uri;
public interface UriInfoService {
}

View File

@ -0,0 +1,30 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
public interface UriParameter {
public String getAlias();
public String getText();
public Expression getExression();
public String getName();
}

View File

@ -0,0 +1,35 @@
/*******************************************************************************
* 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.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmAction;
import org.apache.olingo.odata4.commons.api.edm.EdmActionImport;
public interface UriResourceAction extends UriResourcePartTyped {
EdmAction getAction();
/**
* Convenience method which return the {@link EdmActionImport} which was used in
* the resource path to define the {@link EdmAction}.
* @return
*/
EdmActionImport getActionImport();
}

View File

@ -0,0 +1,26 @@
/*******************************************************************************
* 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.producer.api.uri;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
public interface UriResourceAll extends UriResourcePartTyped {
public String getLamdaVariable();
public Expression getExpression();
}

View File

@ -0,0 +1,26 @@
/*******************************************************************************
* 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.producer.api.uri;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
public interface UriResourceAny extends UriResourcePartTyped {
public String getLamdaVariable();
public Expression getExpression();
}

View File

@ -0,0 +1,28 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
public interface UriResourceComplexProperty extends UriResourceProperty {
EdmComplexType getComplexType();
EdmComplexType getComplexTypeFilter();
}

View File

@ -0,0 +1,24 @@
/*******************************************************************************
* 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.producer.api.uri;
public interface UriResourceCount extends UriResourcePart {
}

View File

@ -16,28 +16,25 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
package org.apache.olingo.odata4.producer.api.uri;
import java.util.ArrayList;
import java.util.List;
public class UriParameterlist {
import org.apache.olingo.odata4.commons.api.edm.EdmEntitySet;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
private List<String> names = new ArrayList<String>();
private List<String> values = new ArrayList<String>();
private List<String> aliases = new ArrayList<String>();
public interface UriResourceEntitySet extends UriResourcePartTyped {
public UriParameterlist add(String name, String value, String alias) {
names.add(name);
values.add(value);
aliases.add(alias);
return this;
EdmEntitySet getEntitySet();
}
EdmEntityType getEntityType();
public List<String> getNames() {
List<UriParameter> getKeyPredicates();
return names;
}
EdmType getTypeFilterOnCollection();
EdmType getTypeFilterOnEntry();
}

View File

@ -0,0 +1,47 @@
/*******************************************************************************
* 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.producer.api.uri;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface UriResourceFunction extends UriResourcePartTyped {
EdmFunction getFunction();
/**
* Convenience method which return the {@link EdmFunctionImport} which was used in
* the resource path to define the {@link EdmFunction}.
* @return
*/
EdmFunctionImport getFunctionImport();
List<UriParameter> getKeyPredicates();
List<UriParameter> getParameters();
EdmType getTypeFilterOnCollection();
EdmType getTypeFilterOnEntry();
}

View File

@ -0,0 +1,32 @@
/*******************************************************************************
* 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.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
/**
* Class indicating the $it reference. $it may be used within filter to
* refer to the last EDM object reference in the resource path.
*/
public interface UriResourceIt extends UriResourcePartTyped {
EdmType getTypeFilterOnCollection();
EdmType getTypeFilterOnEntry();
boolean isExplicitIt();
}

View File

@ -0,0 +1,26 @@
/*******************************************************************************
*
* 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.producer.api.uri;
public enum UriResourceKind {
action, entitySet, function, it, singleton, navigationProperty,
simpleProperty, complexProperty, value, count, ref, root, lamdaAll, lamdaAny
}

View File

@ -0,0 +1,33 @@
/*******************************************************************************
* 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.producer.api.uri;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface UriResourceNavigation extends UriResourcePartTyped {
List<UriParameter> getKeyPredicates();
EdmNavigationProperty getNavigationProperty();
EdmType getTypeFilterOnCollection();
EdmType getTypeFilterOnEntry();
}

View File

@ -0,0 +1,24 @@
/*******************************************************************************
* 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.producer.api.uri;
public interface UriResourcePart {
UriResourceKind getKind();
}

View File

@ -0,0 +1,28 @@
/*******************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface UriResourcePartTyped extends UriResourcePart {
EdmType getType();
boolean isCollection();
}

View File

@ -0,0 +1,25 @@
/*******************************************************************************
* 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.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
public interface UriResourceProperty extends UriResourcePartTyped {
EdmProperty getProperty();
}

View File

@ -0,0 +1,24 @@
/*******************************************************************************
* 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.producer.api.uri;
public interface UriResourceRef extends UriResourcePart {
}

View File

@ -0,0 +1,27 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
/**
* Class indicating the $root reference. $root may be used within filter to
* refer to the current OData service
*/
public interface UriResourceRoot extends UriResourcePart {
}

View File

@ -0,0 +1,24 @@
/*******************************************************************************
* 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.producer.api.uri;
public interface UriResourceSimpleProperty extends UriResourceProperty{
}

View File

@ -0,0 +1,28 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface UriResourceSingleton extends UriResourcePartTyped {
EdmType getEntityType();
EdmSingleton getSingleton();
}

View File

@ -0,0 +1,24 @@
/*******************************************************************************
* 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.producer.api.uri;
public interface UriResourceValue extends UriResourcePart {
}

View File

@ -1,83 +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.producer.api.uri;
public enum UriType {
TYPE_ENTITY_SET,
TYPE_ENTITY_SET_COUNT,
TYPE_MEDIA_REFERENCE,
TYPE_REFERENCE_COLLECTION,
/*
* Singleton
*/
TYPE_ENTITY,
TYPE_MEDIA_STREAM,
TYPE_REFERENCE,
/*
* Property Path
*/
TYPE_PROPERTY_PRIMITIVE,
TYPE_PROPERTY_PRIMITIVE_COLLECTION,
TYPE_PROPERTY_PRIMITIVE_VALUE,
TYPE_PROPERTY_COMPLEX,
/*
* Crossjoin
*/
TYPE_CROSSJOIN,
/*
* $all
*/
TYPE_SERVICE_ALL,
/*
* ActionImport
*/
TYPE_AI_ENTITY,
/*
* FunctionImport
*/
TYPE_FI_ENTITY,
TYPE_FI_ENTITY_SET,
TYPE_FI_ENTITY_SET_COUNT,
TYPE_FI_PROPERTY_PRIMITIVE,
TYPE_FI_PROPERTY_PRIMITIVE_COLL,
TYPE_FI_PROPERTY_PRIMITIVE_COLL_COUNT,
TYPE_FI_PROPERTY_COMPLEX,
TYPE_FI_PROPERTY_COMPLEX_COLL,
TYPE_FI_PROPERTY_COMPLEX_COLL_COUNT,
/*
* BoundFunction
*/
TYPE_BF_ENTITY,
TYPE_BF_ENTITY_SET,
TYPE_BF_PROP_PRIM,
TYPE_BF_PROP_COMP,
TYPE_BF_PROP_COMP_COLL,
TYPE_BF_PROP_PRIM_COLL,
/*
* BoundAction
*/
TYPE_BA_ENTITY_SET,
TYPE_BA_ENTITY,
TYPE_BA_PROP_PRIM,
TYPE_BA_PROP_PRIM_COLL,
TYPE_BA_PROP_COMP;
}

View File

@ -0,0 +1,76 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.optiontree;
import java.util.List;
import org.apache.olingo.odata4.producer.api.uri.UriResourceProperty;
import org.apache.olingo.odata4.producer.api.uri.queryoption.FilterOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.InlineCountOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption;
/**
* Contains the merged $expand and $select options
*/
public interface OptionNode {
/**
* Contains the list of non navigation properties which should serialized at this expand level.
*/
List<UriResourceProperty> getPropertyChainList();
List<OptionProperty> getExpandetNavigationProperties();
/**
* Contains the filter which should be applied to this expand level.
*/
FilterOption getFilter();
/**
* Contains the search information which should be applied to this expand level.
*/
SearchOption getSearch();
/**
* Contains the orderBy information which should be applied to this expand level.
*/
OrderByOption getOrderBy();
/**
* Contains the information about how many output entities should be skipped at this
* expand level.
*/
SkipOption getSkip();
/**
* Contains the information about how many output items should be serialized at this
* expand level.
*/
TopOption getTop();
/**
* Contains the information whether the number of output items should be serialized
* at this expand level
*/
InlineCountOption getInlineCount();
}

View File

@ -0,0 +1,27 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.optiontree;
import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
public interface OptionProperty {
EdmNavigationProperty getNavigationProperty();
OptionNode getOptionNode();
}

View File

@ -0,0 +1,26 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
public interface AliasQueryOption extends QueryOption {
public Expression getAliasValue();
}

View File

@ -0,0 +1,23 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption;
public interface CustomQueryOption extends QueryOption {
}

View File

@ -0,0 +1,28 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public class ExceptionVisitExpand extends Exception {
/**
*
*/
private static final long serialVersionUID = 822365726050299076L;
}

View File

@ -0,0 +1,47 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption;
import java.util.List;
import org.apache.olingo.odata4.producer.api.uri.UriResourceProperty;
public interface ExpandItem {
boolean isStar();
List<UriResourceProperty> getPropertyChainList();
LevelExpandOption getLevel();
FilterOption getFilter();
SearchOption getSearch();
OrderByOption getOrderBy();
SkipOption getSkip();
TopOption getTop();
InlineCountOption getInlineCount();
SelectOption getSelect();
ExpandOption getExpand();
}

View File

@ -0,0 +1,25 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption;
import java.util.List;
public interface ExpandOption extends SystemQueryOption {
List<ExpandItem> getExpandItems();
}

View File

@ -0,0 +1,36 @@
/*******************************************************************************
*
* 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.producer.api.uri.queryoption;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.EdmElement;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface ExpandVisitor<T> {
T visitExpandSegment(EdmElement property, EdmType initialType, EdmType finalType);
T visitExpandItem(List<T> expandSegments, boolean isStar, boolean isRef, EdmType finalType);
T visitExpand(List<T> expandItems);
}

View File

@ -0,0 +1,25 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
public interface FilterOption extends SystemQueryOption {
Expression getExpression();
}

View File

@ -0,0 +1,24 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption;
public interface FormatOption extends SystemQueryOption {
// TODO select best representation for format
Object getFormat();
}

View File

@ -0,0 +1,23 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption;
public interface IdOption extends SystemQueryOption {
String getIdValue();
}

View File

@ -0,0 +1,23 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption;
public interface InlineCountOption extends SystemQueryOption {
boolean getInlineCountValue();
}

View File

@ -0,0 +1,27 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public interface LevelExpandOption {
boolean isMax();
String getLevel();
}

View File

@ -1,4 +1,5 @@
/*******************************************************************************
*
* 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
@ -16,21 +17,18 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.queryoption;
package org.apache.olingo.odata4.producer.api.uri.queryoption;
import org.apache.olingo.odata4.producer.core.uri.expression.Expression;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
public class Filter extends SystemQueryOption {
public interface OrderByItem {
/**
* Returns the sort order of the orderBy item
* @return if false (default) the sort order is ascending, if true the sort order is descending
*/
boolean isDescending();
Expression expression;
Expression getExpression();
public Filter(Expression expression) {
this.expression = expression;
}
public Expression getTree() {
return expression;
}
}

View File

@ -0,0 +1,27 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
import java.util.List;
public interface OrderByOption extends SystemQueryOption {
List<OrderByItem> getOrders();
}

View File

@ -16,8 +16,11 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.queryoption;
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public class QueryOption {
public interface QueryOption {
public String getName();
public String getText();
}

View File

@ -16,12 +16,11 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
package org.apache.olingo.odata4.producer.api.uri.queryoption;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
import org.apache.olingo.odata4.producer.api.uri.queryoption.search.SearchExpression;
public class UriInfoImplCrossjoin extends UriInfoImpl {
public UriInfoImplCrossjoin() {
this.setKind(UriInfoKind.crossjoin);
}
public interface SearchOption extends SystemQueryOption {
SearchExpression getSearchExpression();
}

View File

@ -16,38 +16,28 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
package org.apache.olingo.odata4.producer.api.uri.queryoption;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.EdmAction;
import org.apache.olingo.odata4.producer.api.uri.UriPathInfoKind;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
import org.apache.olingo.odata4.producer.api.uri.UriResourceProperty;
/**
* Covers Functionimports and BoundFunction in URI
*/
public class UriPathInfoIT extends UriPathInfoImpl {
public interface SelectItem {
private boolean explicitIT;
boolean isStar();
boolean isAllOperationsInSchema();
public UriPathInfoIT() {
this.setKind(UriPathInfoKind.it);
this.setCollection(false);
}
@Override
public String toString() {
if (explicitIT) {
return "$it" + super.toString();
}
return super.toString();
}
String getNameSpace();
public UriPathInfoIT setIsExplicitIT(boolean explicitIT) {
this.explicitIT =explicitIT;
return this;
}
EdmEntityType getEntityTypeCast();
EdmAction getAction();
EdmFunction getFunction();
List<UriResourceProperty> getPropertyChainList();
}

View File

@ -0,0 +1,27 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
import java.util.List;
public interface SelectOption extends SystemQueryOption {
List<SelectItem> getSelectItems();
}

View File

@ -0,0 +1,25 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption;
public interface SkipOption extends SystemQueryOption {
String getSkipValue();
}

View File

@ -0,0 +1,26 @@
/*******************************************************************************
*
* 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.producer.api.uri.queryoption;
public interface SkipTokenOption extends SystemQueryOption{
String getSkipTokenValue();
}

View File

@ -0,0 +1,20 @@
/*******************************************************************************
*
* 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.producer.api.uri.queryoption;

View File

@ -16,8 +16,10 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.queryoption;
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public class SystemQueryOption extends QueryOption {
public interface SystemQueryOption extends QueryOption {
SystemQueryOptionEnum getKind();
}

View File

@ -16,11 +16,12 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public enum SystemQueryParameter {
public enum SystemQueryOptionEnum {
FILTER("$filter"),
FORMAT("$format"),
EXPAND("$expand"),
ID("$id"),
INLINECOUNT("$inlinecount"),
ORDERBY("$orderby"),
@ -28,11 +29,12 @@ public enum SystemQueryParameter {
SELECT("$select"),
SKIP("$skip"),
SKIPTOKEN("$skiptoken"),
TOP("$top");
TOP("$top"),
LEVEL("$level");
String syntax;
private SystemQueryParameter(final String syntax) {
private SystemQueryOptionEnum(final String syntax) {
this.syntax = syntax;
}

View File

@ -0,0 +1,23 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption;
public interface TopOption extends SystemQueryOption{
String getTopValue();
}

View File

@ -0,0 +1,48 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption;
/* TODO update documentation*/
public interface VisitableExpand {
/**
* Method {@link #accept(ExpressionVisitor)} is called when traversing the expression tree. This method is invoked on
* each
* expression used as node in an expression tree. The implementations should
* behave as follows:
* <li>Call accept on all sub nodes and store the returned Objects
* <li>Call the appropriate method on the {@link ExpressionVisitor} instance and provide the stored objects to that
* instance
* <li>Return the object which should be passed to the processing algorithm of the parent expression node
* <br>
* <br>
* @param visitor
* Object ( implementing {@link ExpressionVisitor}) whose methods are called during traversing a expression node of
* the expression tree.
* @return
* Object which should be passed to the processing algorithm of the parent expression node
* @throws ExceptionVisitExpression
* Exception occurred the OData library while traversing the tree
* @throws ODataApplicationException
* Exception thrown by the application who implemented the visitor
*/
<T> T accept(ExpandVisitor<T> visitor) throws ExceptionVisitExpand;
}

View File

@ -0,0 +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.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public interface BinaryExpression {
public SupportedBinaryOperators getOperator();
public Expression getLeftOperand();
public Expression getRightOperand();
}

View File

@ -16,10 +16,8 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.expression;
public abstract class Expression implements Visitable{
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public interface Expression {
}

View File

@ -0,0 +1,25 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption.expression;
public interface LambdaRef {
public String getVariableText();
}

View File

@ -0,0 +1,25 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption.expression;
public interface Literal {
public String getText();
}

View File

@ -0,0 +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.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
public interface Member {
public boolean isIT();
public UriInfoResource getPath();
}

View File

@ -0,0 +1,31 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption.expression;
import java.util.List;
public interface MethodCall {
public SupportedMethodCalls getMethod();
public List<Expression> getParameters();
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.expression;
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public enum SupportedBinaryOperators {
//multiplicative

View File

@ -0,0 +1,55 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public enum SupportedMethodCalls {
CONTAINS("contains"),STARTSWITH("startswith"),ENDSWITH("endswith"),LENGTH("length"),
INDEXOF("indexof"),SUBSTRING("substring"),TOLOWER("tolower"),TOUPPER("toupper"),TRIM("trim"),
CONCAT("concat"),
YEAR("year"),MONTH("month"),DAY("day"),HOUR("hour"),MINUTE("minute"),SECOND("second"),
FRACTIONALSECOND("fractionalsecond"),TOTALSECONDS("totalseconds"),DATE("date"),TIME("time"),
TOTALOFFSETMINUTES("totaloffsetminutes"),MINDATETIME("mindatetime"),MAXDATETIME("maxdatetime"),NOW("now"),
ROUND("round"),FLOOR("floor"),
CEILING("ceiling"),DISTANCE("distance"),GEOLENGTH("geolength"),INTERSECTS("intersects"), CAST("cast"), ISOF("isof");
private String syntax;
private SupportedMethodCalls(final String syntax) {
this.syntax = syntax;
}
@Override
public String toString() {
return syntax;
}
public static SupportedMethodCalls get(String operator) {
for (SupportedMethodCalls op : SupportedMethodCalls.values()) {
if (op.toString().equals(operator+'(')) {
return op;
}
}
return null;
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.expression;
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public enum SupportedUnaryOperators {
MINUS("-"), NOT("not");

View File

@ -0,0 +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.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface TypeLiteral {
public EdmType getType();
}

View File

@ -0,0 +1,27 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public interface UnaryOperator {
public abstract Expression getOperand();
public abstract SupportedUnaryOperators getOperator();
}

View File

@ -0,0 +1,28 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption.search;
public interface SearchBinary extends SearchExpression {
SupportedSearchBinaryOperators getOperator();
SearchExpression getLeftOperand();
SearchExpression getRightOperand();
}

View File

@ -0,0 +1,23 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption.search;
public interface SearchExpression {
}

View File

@ -0,0 +1,23 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption.search;
public interface SearchTerm extends SearchExpression {
String getSearchTerm();
}

View File

@ -0,0 +1,23 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption.search;
public interface SearchUnary {
SearchExpression getOperand();
}

View File

@ -16,28 +16,20 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.expression;
package org.apache.olingo.odata4.producer.api.uri.queryoption.search;
public enum SupportedMethodCalls {
MUL("mul"), DIV("div"), MOD("mod"),
ADD("add"), SUB("sub"), GT("gt"), GE("ge"), LT("lt"), LE("le"),
ISOF("isof"),
EQ("eq"), NE("ne"),
public enum SupportedSearchBinaryOperators {
// and/or
AND("and"), OR("or");
private String syntax;
private SupportedMethodCalls(final String syntax) {
private SupportedSearchBinaryOperators(final String syntax) {
this.syntax = syntax;
}
@Override
public String toString() {
return syntax;
}
public static SupportedMethodCalls get(String operator) {
for (SupportedMethodCalls op : SupportedMethodCalls.values()) {
public static SupportedSearchBinaryOperators get(String operator) {
for (SupportedSearchBinaryOperators op : SupportedSearchBinaryOperators.values()) {
if (op.toString().equals(operator)) {
return op;
}
@ -45,4 +37,8 @@ public enum SupportedMethodCalls {
return null;
}
@Override
public String toString() {
return syntax;
}
}

View File

@ -0,0 +1,43 @@
/*******************************************************************************
* 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.producer.api.uri.queryoption.search;
public enum SupportedSearchUnaryOperators {
NOT("not");
private String syntax;
private SupportedSearchUnaryOperators(final String syntax) {
this.syntax = syntax;
}
@Override
public String toString() {
return syntax;
}
public static SupportedSearchUnaryOperators get(String operator) {
for (SupportedSearchUnaryOperators op : SupportedSearchUnaryOperators.values()) {
if (op.toString().equals(operator)) {
return op;
}
}
return null;
}
}

View File

@ -62,7 +62,7 @@ POINT : '.';
AT : '@';
EQ : '=' ;
STAR : '*';
SEMI : ';';
SEMI : ';' | '%3b';
FRAGMENT : '#';
COLON : ':';
@ -112,10 +112,14 @@ REF : '$ref';
COUNT : '$count';
//inlined query parameters ( e.g. $skip)
SKIP_INLINE : '$skip';
FILTER_INLINE : '$filter';
ORDERBY_INLINE: '$orderby';
TOP_I : '$top' -> type(TOP);
SKIP_I : '$skip' -> type(SKIP);
FILTER_I : '$filter' -> type(FILTER);
ORDERBY_I: '$orderby' -> type(ORDERBY);
SELECT_I: '$select' -> type(SELECT);
EXPAND_I: '$expand' -> type(EXPAND);
LEVELS_I: '$levels' -> type(LEVELS);
MAX: 'max';
ROOT : '$root/';
@ -158,10 +162,14 @@ DESC : 'desc';
MUL : 'mul';
DIV : 'div';
MOD : 'mod';
HAS : 'has';
ADD : 'add';
SUB : 'sub';
ANY_LAMDA : 'any';
ALL_LAMDA : 'all';
GT : 'gt';
GE : 'ge';
LT : 'lt';
@ -179,7 +187,8 @@ NOT : 'not';
MINUS :'-';
NANINFINITY : 'NaN' | '-INF' | 'INF';
IMPLICIT_VARIABLE_EXPR : '$it';
IT : '$it';
ITSLASH : '$it/';
LEVELS : '$levels';
CONTAINS_WORD : 'contains(';
@ -229,10 +238,6 @@ LINK : '$link';
DELETED_LINK : '$deletedLink';
DELTA : '$delta';
LEVELSMAX : '$levels=max';
//ODI
ODATAIDENTIFIER : ODI_LEADINGCHARACTER (ODI_CHARACTER)*;
@ -262,26 +267,26 @@ SEARCH : '$search' -> pushMode(MODE_SYSTEM_Q
EQ_q : '=' -> type(EQ);
AMP_q : '&' -> type(AMP);
CUSTOMNAME : ~[&=@$] ~[&=]*;
CUSTOMVALUE : ~[&=]+;
AT_Q : '@' -> pushMode(DEFAULT_MODE);
CUSTOMNAME : ~[&=@$] ~[&=]* -> pushMode(MODE_SYSTEM_QUERY_REST);
//;==============================================================================
mode MODE_SYSTEM_QUERY_PCHAR;
//;==============================================================================
AMP_sqp : '&' -> popMode,popMode;
AMP_sqp : '&' -> type(AMP), popMode;
//fragment EQ_sqp : '=';
fragment ALPHA_sqp : 'a'..'z'|'A'..'Z';
fragment A_TO_F_sqp : 'a'..'f'|'A'..'F';
fragment DIGIT_sqp : '0'..'9';
fragment HEXDIG_sqp : DIGIT_sqp | A_TO_F_sqp;
fragment PCT_ENCODED_sqp : '%' HEXDIG_sqp HEXDIG_sqp;
fragment SUB_DELIMS_sqp : '$' | '&' | '\'' | EQ_sqp | OTHER_DELIMS_sqp;
fragment SUB_DELIMS_sqp : '$' | /*'&' |*/ '\'' | EQ_sqp | OTHER_DELIMS_sqp;
fragment OTHER_DELIMS_sqp : '!' | '(' | ')' | '*' | '+' | ',' | ';';
fragment UNRESERVED_sqp : ALPHA_sqp | DIGIT_sqp | '-' |'.' | '_' | '~';
fragment PCHAR : UNRESERVED_sqp | PCT_ENCODED_sqp | SUB_DELIMS_sqp | ':' | '@';
fragment PCHARSTART : UNRESERVED_sqp | PCT_ENCODED_sqp | '$' | '&' | '\'' | OTHER_DELIMS_sqp | ':' | '@';
fragment PCHARSTART : UNRESERVED_sqp | PCT_ENCODED_sqp | '$' | /*'&' |*/ '\'' | OTHER_DELIMS_sqp | ':' | '@';
ATOM : [Aa][Tt][Oo][Mm];
@ -290,6 +295,7 @@ XML : [Xx][Mm][Ll];
PCHARS : PCHARSTART PCHAR*;
SLASH_sqp : '/' -> type(SLASH);
EQ_sqp : '=' -> type(EQ);

View File

@ -68,9 +68,6 @@ options {
}
//;------------------------------------------------------------------------------
//; 0. URI
//;------------------------------------------------------------------------------
@ -88,10 +85,10 @@ odataRelativeUriEOF : odataRelativeUri? EOF;
//QM and FRAGMENT enable next lexer mode
//TODO add the new "ENTITYCAST"
odataRelativeUri : BATCH # altBatch
| ENTITY QM eo=entityOptions # altEntity
| ENTITY SLASH ns=namespace? odi=odataIdentifier QM eo=entityOptions # altEntityCast
| METADATA ( QM format )? ( FRAGMENT contextFragment )? # altMetadata
| resourcePath ( QM queryOptions )? # altResourcePath
| ENTITY QM vEO=entityOptions # altEntity
| ENTITY SLASH vNS=namespace vODI=odataIdentifier QM vEO=entityOptionsCast # altEntityCast
| METADATA ( QM vF=format )? ( FRAGMENT vCF=contextFragment )? # altMetadata
| vRP=resourcePath ( QM vQO=queryOptions )? # altResourcePath
;
//;------------------------------------------------------------------------------
@ -100,20 +97,20 @@ odataRelativeUri : BATCH
resourcePath : vAll=ALL
| vCJ=crossjoin
| vPSs=pathSegments
| vlPS=pathSegments
;
crossjoin : CROSSJOIN OPEN odi+=odataIdentifier ( COMMA odi+=odataIdentifier )* CLOSE;
crossjoin : CROSSJOIN OPEN WSP? vlODI+=odataIdentifier WSP? ( COMMA WSP? vlODI+=odataIdentifier WSP?)* CLOSE;
pathSegments : vlPS+=pathSegment (SLASH vlPS+=pathSegment)* vCS=constSegment?;
pathSegment : vNS=namespace? vODI=odataIdentifier vlVPO+=nameValueOptList*;
pathSegment : vNS=namespace? vODI=odataIdentifier vlNVO+=nameValueOptList*;
nameValueOptList : OPEN (vVO=valueOnly | vNVL=nameValueList)? CLOSE;
valueOnly : vV=primitiveLiteral ;
nameValueList : WSP* vNVP+=nameValuePair WSP* ( COMMA WSP* vNVP+=nameValuePair WSP*)* ;
nameValuePair : vODI=odataIdentifier EQ (AT vALI=odataIdentifier | vVAL=primitiveLiteral /*TODO | val2=enumX*/);
valueOnly : vV=commonExpr ;
nameValueList : WSP* vlNVP+=nameValuePair WSP* ( COMMA WSP* vlNVP+=nameValuePair WSP*)* ;
nameValuePair : vODI=odataIdentifier EQ (AT vALI=odataIdentifier | vCOM=commonExpr /*TODO | val2=enumX*/);
constSegment : SLASH (v=value | c=count | r=ref );
constSegment : SLASH (vV=value | vC=count | vR=ref );
count : COUNT;
ref : REF;
@ -122,24 +119,32 @@ value : VALUE;
//; 2. Query Options
//;------------------------------------------------------------------------------
queryOptions : qo+=queryOption ( AMP qo+=queryOption )*;
queryOptions : vlQO+=queryOption ( AMP vlQO+=queryOption )*;
queryOption : systemQueryOption
| AT aliasAndValue
| AT_Q aliasAndValue
| customQueryOption
;
entityOptions : (eob+=entityOption AMP )* ID EQ REST ( AMP eoa+=entityOption )*;
entityOption : ( expand | format | select )
entityOptions : (vlEOb+=entityOption AMP )* vlEOm=id ( AMP vlEOa+=entityOption )*;
entityOption : format
| customQueryOption
;
entityOptionsCast : (vlEOb+=entityOptionCast AMP )* vlEOm=id ( AMP vlEOa+=entityOptionCast )*;
entityOptionCast : expand
| format
| select
| filter
| customQueryOption
;
systemQueryOption : expand
| filter
| format
| id
| inlinecount
| orderby
| orderBy
| search
| select
| skip
@ -149,44 +154,41 @@ systemQueryOption : expand
id : ID EQ REST;
skiptoken : SKIPTOKEN EQ REST;
expand : EXPAND EQ expandItemList;
expand : EXPAND EQ vlEI+=expandItem ( COMMA vlEI+=expandItem )*;
expandItemList : expandItem ( COMMA expandItem )*;
expandItem : vS=STAR ( SLASH vR=ref | OPEN LEVELS EQ ( vL=INT | vM=MAX) CLOSE )?
| vEP=expandPath vEPE=expandPathExtension?;
expandItem : STAR ( SLASH ref | OPEN (LEVELS EQ INT | LEVELSMAX) CLOSE )?
| expandPath expandPathExtension?;
expandPath : expandPathSegment ( SLASH expandPathSegment )*;
expandPathSegment : vNS=namespace? vODI=odataIdentifier;
expandPath : ( namespace? odataIdentifier ) ( SLASH namespace? odataIdentifier )*;
expandPathExtension : SLASH ref ( OPEN expandRefOption ( SEMI expandRefOption )* CLOSE )?
| SLASH count ( OPEN expandCountOption ( SEMI expandCountOption )* CLOSE )?
| OPEN expandOption ( SEMI expandOption )* CLOSE
expandPathExtension : OPEN vlEO+=expandOption ( SEMI vlEO+=expandOption )* CLOSE
| SLASH vR=ref ( OPEN vlEOR+=expandRefOption ( SEMI vlEOR+=expandRefOption )* CLOSE )?
| SLASH vC=count ( OPEN vlEOC+=expandCountOption ( SEMI vlEOC+=expandCountOption )* CLOSE )?
;
expandCountOption : filterInline
| searchInline
expandCountOption : filter
| search
;
expandRefOption : expandCountOption
| orderbyInline
| skipInline
| orderBy
| skip
| top
| inlinecount
;
expandOption : expandRefOption
| select
| expand
| LEVELS;
| levels;
levels : LEVELS EQ ( INT | MAX );
filter : FILTER EQ commonExpr;
filterInline : FILTER_INLINE EQ commonExpr;
orderby : ORDERBY EQ orderbyItem ( COMMA orderbyItem )*;
orderbyInline : ORDERBY_INLINE EQ orderbyItem ( COMMA orderbyItem )*;
orderbyItem : commonExpr ( WSP ( ASC | DESC ) )?;
orderBy : ORDERBY EQ orderByItem ( COMMA orderByItem )*;
orderByItem : commonExpr ( WSP ( ASC | DESC ) )?;
//this is completly done in lexer grammer to avoid ambiguities with odataIdentifier and STRING
skip : SKIP EQ INT;
skipInline : SKIP_INLINE EQ INT;
top : TOP EQ INT;
format : FORMAT EQ ( ATOM | JSON | XML | PCHARS ( SLASH PCHARS)?);
@ -209,13 +211,12 @@ searchExpr : (NOT WSP) searchExpr
searchPhrase : SEARCHPHRASE;
searchWord : SEARCHWORD;
select : SELECT EQ selectItem ( COMMA selectItem )*;
selectItem : namespace? STAR
| (namespace? odataIdentifier nameValueOptList? ) ( SLASH namespace? odataIdentifier nameValueOptList? )*
;
select : SELECT EQ vlSI+=selectItem ( COMMA vlSI+=selectItem )*;
selectItem : vlSS+=selectSegment ( SLASH vlSS+=selectSegment ) *;
selectSegment : vNS=namespace? ( vODI=odataIdentifier | vS=STAR );
aliasAndValue : odataIdentifier EQ parameterValue;
parameterValue : //arrayOrObject
aliasAndValue : vODI=ODATAIDENTIFIER EQ vV=parameterValue;
parameterValue : //TODO json not supported arrayOrObject
commonExpr
;
@ -224,21 +225,18 @@ parameterValue : //arrayOrObject
customQueryOption : customName ( EQ customValue)?
;
customName : CUSTOMNAME;
customValue : CUSTOMVALUE;
customValue : REST;
//;------------------------------------------------------------------------------
//; 3. Context URL Fragments
//;------------------------------------------------------------------------------
//ps+=pathSegment (SLASH ps+=pathSegment)*
//PRIMITIVETYPENAME
//TODO add ps+=pathSegment (SLASH ps+=pathSegment)*
contextFragment : REF
/*| PRIMITIVETYPENAME*/
| COLLECTION_REF
| COLLECTION_ENTITY_TYPE
| COLLECTION_COMPLEX_TYPE
| COLLECTION ( /*PRIMITIVETYPENAME |*/ namespace? odataIdentifier ) CLOSE
| namespace? odataIdentifier
( SLASH ( DELETED_ENTITY | LINK | DELETED_LINK )
| nameValueOptList? ( SLASH namespace? odataIdentifier)* ( propertyList )? ( SLASH DELTA) ? (SLASH ENTITY) ?
@ -267,15 +265,19 @@ test_expr : INT
| test_expr ( WSP '!' WSP | WSP '*' WSP ) test_expr;
commonExpr : OPEN commonExpr CLOSE #altPharenthesis
| vE1=commonExpr (WSP HAS WSP) vE2=commonExpr #altHas
| methodCallExpr #altMethod
| ( unary WSP ) commonExpr #altUnary
| anyExpr #altAny
| allExpr #altAll
| memberExpr #altMember
| commonExpr (WSP MUL WSP | WSP DIV WSP | WSP MOD WSP ) commonExpr #altMult
| commonExpr (WSP ADD WSP | WSP SUB WSP) commonExpr #altAdd
| commonExpr (WSP GT WSP | WSP GE WSP | WSP LT WSP | WSP LE WSP | WSP ISOF WSP) commonExpr #altComparism
| commonExpr (WSP EQ_ALPHA WSP | WSP NE WSP) commonExpr #altEquality
| commonExpr (WSP AND WSP) commonExpr #altAnd
| commonExpr (WSP OR WSP) commonExpr #altOr
| vE1=commonExpr (WSP vO=MUL WSP | WSP vO=DIV WSP | WSP vO=MOD WSP ) vE2=commonExpr #altMult
| vE1=commonExpr (WSP vO=ADD WSP | WSP vO=SUB WSP) vE2=commonExpr #altAdd
| vE1=commonExpr (WSP vO=GT WSP | WSP vO=GE WSP | WSP vO=LT WSP
| WSP vO=LE WSP | WSP vO=ISOF WSP) vE2=commonExpr #altComparism
| vE1=commonExpr (WSP vO=EQ_ALPHA WSP | WSP vO=NE WSP) vE2=commonExpr #altEquality
| vE1=commonExpr (WSP AND WSP) vE2=commonExpr #altAnd
| vE1=commonExpr (WSP OR WSP) vE2=commonExpr #altOr
| rootExpr #altRoot //; $...
| AT odataIdentifier #altAlias // @...
| primitiveLiteral #altLiteral // ...
@ -283,13 +285,13 @@ commonExpr : OPEN commonExpr CLOSE
unary : (MINUS| NOT) ;
rootExpr : ROOT pathSegments;
rootExpr : ROOT vPs=pathSegments;
memberExpr : '$it'
| '$it/'? ps=pathSegments;
memberExpr : vIt=IT ( SLASH (vANY=anyExpr | vALL=allExpr))?
| vIts=ITSLASH? vPs=pathSegments ( SLASH (vANY=anyExpr | vALL=allExpr))?;
anyExpr : 'any' OPEN WSP /* [ lambdaVariableExpr BWS COLON BWS lambdaPredicateExpr ] WS* */ CLOSE;
allExpr : 'all' OPEN WSP /* lambdaVariableExpr BWS COLON BWS lambdaPredicateExpr WS* */ CLOSE;
anyExpr : ANY_LAMDA OPEN WSP? ( vLV=odataIdentifier WSP? COLON WSP? vLE=commonExpr WSP? )? CLOSE;
allExpr : ALL_LAMDA OPEN WSP? vLV=odataIdentifier WSP? COLON WSP? vLE=commonExpr WSP? CLOSE;
methodCallExpr : indexOfMethodCallExpr
| toLowerMethodCallExpr
@ -327,43 +329,43 @@ methodCallExpr : indexOfMethodCallExpr
;
containsMethodCallExpr : CONTAINS_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
startsWithMethodCallExpr : STARTSWITH_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
endsWithMethodCallExpr : ENDSWITH_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
lengthMethodCallExpr : LENGTH_WORD WSP? commonExpr WSP? CLOSE;
indexOfMethodCallExpr : INDEXOF_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
substringMethodCallExpr : SUBSTRING_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? ( COMMA WSP? commonExpr WSP? )? CLOSE;
toLowerMethodCallExpr : TOLOWER_WORD WSP? commonExpr WSP? CLOSE;
toUpperMethodCallExpr : TOUPPER_WORD WSP? commonExpr WSP? CLOSE;
trimMethodCallExpr : TRIM_WORD WSP? commonExpr WSP? CLOSE;
concatMethodCallExpr : CONCAT_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
containsMethodCallExpr : CONTAINS_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE;
startsWithMethodCallExpr : STARTSWITH_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE;
endsWithMethodCallExpr : ENDSWITH_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE;
lengthMethodCallExpr : LENGTH_WORD WSP? vE1=commonExpr WSP? CLOSE;
indexOfMethodCallExpr : INDEXOF_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE;
substringMethodCallExpr : SUBSTRING_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? ( COMMA WSP? vE3=commonExpr WSP? )? CLOSE;
toLowerMethodCallExpr : TOLOWER_WORD WSP? vE1=commonExpr WSP? CLOSE;
toUpperMethodCallExpr : TOUPPER_WORD WSP? vE1=commonExpr WSP? CLOSE;
trimMethodCallExpr : TRIM_WORD WSP? vE1=commonExpr WSP? CLOSE;
concatMethodCallExpr : CONCAT_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE;
yearMethodCallExpr : YEAR_WORD WSP? commonExpr WSP? CLOSE;
monthMethodCallExpr : MONTH_WORD WSP? commonExpr WSP? CLOSE;
dayMethodCallExpr : DAY_WORD WSP? commonExpr WSP? CLOSE;
hourMethodCallExpr : HOUR_WORD WSP? commonExpr WSP? CLOSE;
minuteMethodCallExpr : MINUTE_WORD WSP? commonExpr WSP? CLOSE;
secondMethodCallExpr : SECOND_WORD WSP? commonExpr WSP? CLOSE;
fractionalsecondsMethodCallExpr : FRACTIONALSECONDS_WORD WSP? commonExpr WSP? CLOSE;
totalsecondsMethodCallExpr : TOTALSECONDS_WORD WSP? commonExpr WSP? CLOSE;
dateMethodCallExpr : DATE_WORD WSP? commonExpr WSP? CLOSE;
timeMethodCallExpr : TIME_WORD WSP? commonExpr WSP? CLOSE;
totalOffsetMinutesMethodCallExpr : TOTALOFFSETMINUTES_WORD WSP? commonExpr WSP? CLOSE;
yearMethodCallExpr : YEAR_WORD WSP? vE1=commonExpr WSP? CLOSE;
monthMethodCallExpr : MONTH_WORD WSP? vE1=commonExpr WSP? CLOSE;
dayMethodCallExpr : DAY_WORD WSP? vE1=commonExpr WSP? CLOSE;
hourMethodCallExpr : HOUR_WORD WSP? vE1=commonExpr WSP? CLOSE;
minuteMethodCallExpr : MINUTE_WORD WSP? vE1=commonExpr WSP? CLOSE;
secondMethodCallExpr : SECOND_WORD WSP? vE1=commonExpr WSP? CLOSE;
fractionalsecondsMethodCallExpr : FRACTIONALSECONDS_WORD WSP? vE1=commonExpr WSP? CLOSE;
totalsecondsMethodCallExpr : TOTALSECONDS_WORD WSP? vE1=commonExpr WSP? CLOSE;
dateMethodCallExpr : DATE_WORD WSP? vE1=commonExpr WSP? CLOSE;
timeMethodCallExpr : TIME_WORD WSP? vE1=commonExpr WSP? CLOSE;
totalOffsetMinutesMethodCallExpr : TOTALOFFSETMINUTES_WORD WSP? vE1=commonExpr WSP? CLOSE;
minDateTimeMethodCallExpr : MINDATETIME_WORD WSP? CLOSE;
maxDateTimeMethodCallExpr : MAXDATETIME_WORD WSP? CLOSE;
nowMethodCallExpr : NOW_WORD WSP? CLOSE;
roundMethodCallExpr : ROUND_WORD WSP? commonExpr WSP? CLOSE;
floorMethodCallExpr : FLOOR_WORD WSP? commonExpr WSP? CLOSE;
ceilingMethodCallExpr : CEILING_WORD WSP? commonExpr WSP? CLOSE;
roundMethodCallExpr : ROUND_WORD WSP? vE1=commonExpr WSP? CLOSE;
floorMethodCallExpr : FLOOR_WORD WSP? vE1=commonExpr WSP? CLOSE;
ceilingMethodCallExpr : CEILING_WORD WSP? vE1=commonExpr WSP? CLOSE;
distanceMethodCallExpr : GEO_DISTANCE_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
geoLengthMethodCallExpr : GEO_LENGTH_WORD WSP? commonExpr WSP? CLOSE;
intersectsMethodCallExpr : GEO_INTERSECTS_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
distanceMethodCallExpr : GEO_DISTANCE_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE;
geoLengthMethodCallExpr : GEO_LENGTH_WORD WSP? vE1=commonExpr WSP? CLOSE;
intersectsMethodCallExpr : GEO_INTERSECTS_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE;
isofExpr : ISOF_WORD WSP? ( commonExpr WSP? COMMA WSP? )? qualifiedtypename WSP? CLOSE;
castExpr : CAST_WORD WSP? ( commonExpr WSP? COMMA WSP? )? qualifiedtypename WSP? CLOSE;
isofExpr : ISOF_WORD WSP? ( vE1=commonExpr WSP? COMMA WSP? )? vNS=namespace vODI=odataIdentifier WSP? CLOSE;
castExpr : CAST_WORD WSP? ( vE1=commonExpr WSP? COMMA WSP? )? vNS=namespace vODI=odataIdentifier WSP? CLOSE;
//;------------------------------------------------------------------------------
//; 5. JSON format for function parameters
@ -428,6 +430,7 @@ primitiveLiteral : nullrule
| GUID
| string
| TIMEOFDAY
| enumX
| geographyCollection
| geographyLineString
| geographyMultilineString
@ -442,7 +445,6 @@ primitiveLiteral : nullrule
| geometryMultipolygon
| geometryPoint
| geometryPolygon
| enumX
;
@ -451,7 +453,7 @@ booleanNonCase : BOOLEAN | TRUE | FALSE;
string : STRING;
enumX : namespace odataIdentifier STRING /*SQUOTE enumValue SQUOTE*/;
enumX : namespace odataIdentifier STRING;
enumValue : singleEnumValue *( COMMA singleEnumValue );
singleEnumValue : odataIdentifier / INT;

View File

@ -0,0 +1,145 @@
/*******************************************************************************
* 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.producer.core.uri;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.List;
import org.antlr.v4.runtime.ANTLRErrorListener;
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;
import org.antlr.v4.runtime.atn.ATNConfigSet;
import org.antlr.v4.runtime.dfa.DFA;
class ErrorCollector implements ANTLRErrorListener {
private List<Exception> exceptions = new ArrayList<Exception>();
//private ParserValidator tokenValidator;
@Override
public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
final int charPositionInLine,
final String msg, final RecognitionException e) {
// Collect the exception
// TODO needs to be improved
exceptions.add(e);
System.out.println("syntaxError");
trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
//fail("syntaxError");
}
@Override
public void reportAmbiguity(final Parser recognizer, final DFA dfa, final int startIndex, final int stopIndex,
final boolean exact,
final BitSet ambigAlts, final ATNConfigSet configs) {
/*
if (tokenValidator.logLevel > 0) {
System.out.println("reportAmbiguity: ");
System.out.println(" ambigAlts: " + ambigAlts);
System.out.println(" configs: " + configs);
System.out.println(" input: " + recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex)));
}*/
/*
if (!tokenValidator.allowAmbiguity) {
printStack(recognizer);
fail("reportAmbiguity");
}*/
}
@Override
public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex,
final int stopIndex,
final BitSet conflictingAlts, final ATNConfigSet configs) {
/*
// The grammar should be written in order to avoid attempting a full context parse because its negative
// impact on the performance, so trace and stop here
if (tokenValidator.logLevel > 0) {
System.out.println("allowed AttemptingFullContext");
}
if (!tokenValidator.allowFullContext) {
printStack(recognizer);
fail("reportAttemptingFullContext");
}*/
}
@Override
public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex,
final int stopIndex, final int prediction,
final ATNConfigSet configs) {
/*
if (tokenValidator.logLevel > 0) {
System.out.println("allowed ContextSensitivity");
}
if (!tokenValidator.allowContextSensitifity) {
printStack(recognizer);
fail("reportContextSensitivity");
}*/
}
/*
* private void printStack(final Parser recognizer) {
* List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
* Collections.reverse(stack);
*
* System.out.println(" Rule stack: " + stack);
* }
*/
private void printStack(final Recognizer<?, ?> recognizer) {
List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
Collections.reverse(stack);
System.out.println(" rule stack: " + stack);
}
public void trace(final Recognizer<?, ?> recognizer, final Object offendingSymbol,
final int line, final int charPositionInLine, final String msg, final RecognitionException e) {
System.err.println("-");
// TODO check also http://stackoverflow.com/questions/14747952/ll-exact-ambig-detection-interpetation
printStack(recognizer);
if (e != null && e.getOffendingToken() != null) {
// String lexerTokenName = TestSuiteLexer.tokenNames[e.getOffendingToken().getType()];
String lexerTokenName = "";
try {
//TODO check how the Lexer is accessed in the new package structure
//lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
} catch (ArrayIndexOutOfBoundsException es) {
lexerTokenName = "token error";
}
System.err.println(" line " + line + ":" + charPositionInLine + " at " +
offendingSymbol + "/" + lexerTokenName + ": " + msg);
} else {
System.err.println(" line " + line + ":" + charPositionInLine + " at " + offendingSymbol + ": " + msg);
}
}
}

View File

@ -1,55 +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.producer.core.uri;
import java.util.Collections;
import java.util.List;
import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriLexer;
public class ErrorHandler<T> extends BaseErrorListener {
@Override
public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol,
final int line, final int charPositionInLine, final String msg, final RecognitionException e) {
System.err.println("-");
// check also http://stackoverflow.com/questions/14747952/ll-exact-ambig-detection-interpetation
List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
Collections.reverse(stack);
System.err.println("rule stack: " + stack);
if (e != null && e.getOffendingToken() != null) {
// String lexerTokenName =TestSuiteLexer.tokenNames[e.getOffendingToken().getType()];
String lexerTokenName = "";
try {
// lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
} catch (ArrayIndexOutOfBoundsException es) {
lexerTokenName = "token error";
}
System.err.println("line " + line + ":" + charPositionInLine + " at " +
offendingSymbol + "/" + lexerTokenName + ": " + msg);
} else {
System.err.println("line " + line + ":" + charPositionInLine + " at " + offendingSymbol + ": " + msg);
}
}
}

View File

@ -18,11 +18,8 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandSegment;
public class ExpandSegmentCount extends ExpandSegment {
public class UriInfoImplAll extends UriInfoImpl {
public UriInfoImplAll() {
this.setKind(UriInfoKind.all);
}
}

View File

@ -18,10 +18,8 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandSegment;
public class ExpandSegmentIt extends ExpandSegment {
public class UriInfoImplBatch extends UriInfoImpl {
public UriInfoImplBatch() {
this.setKind(UriInfoKind.batch);
}
}

View File

@ -18,11 +18,8 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandSegment;
public class UriInfoImplEntity extends UriInfoImpl {
public UriInfoImplEntity() {
this.setKind(UriInfoKind.entity);
}
public class ExpandSegmentRef extends ExpandSegment {
}

View File

@ -29,7 +29,26 @@ import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext;
public class ParserAdapter {
static public OdataRelativeUriEOFContext parseInput(final String input) throws UriParserException {
public static UriInfoImpl parseUri(final String input, UriParseTreeVisitor uriParseTreeVisitor)
throws UriParserException {
try {
UriInfoImpl uriInput = (UriInfoImpl) parseInput(input).accept(uriParseTreeVisitor);
return uriInput;
} catch (ParseCancellationException e) {
// unpack UriParserException
Throwable cause = e.getCause();
if (cause instanceof UriParserException) {
throw (UriParserException) cause;
}
}
return null;
}
static private OdataRelativeUriEOFContext parseInput(final String input) throws UriParserSyntaxException {
UriParserParser parser = null;
UriLexer lexer = null;
OdataRelativeUriEOFContext ret = null;
@ -42,6 +61,10 @@ public class ParserAdapter {
// create parser
lexer = new UriLexer(new ANTLRInputStream(input));
parser = new UriParserParser(new CommonTokenStream(lexer));
// TODO create better error collector
parser.addErrorListener(new ErrorCollector());
// bail out of parser at first syntax error. --> proceeds in catch block with step 2
parser.setErrorHandler(new BailErrorStrategy());
@ -69,12 +92,12 @@ public class ParserAdapter {
ret = parser.odataRelativeUriEOF();
} catch (Exception weakException) {
throw new UriParserException("Error in Parser", weakException);
throw new UriParserSyntaxException("Error in syntax", weakException);
// exceptionOnStage = 2;
}
} catch (Exception hardException) {
throw new UriParserException("Error in Parser", hardException);
throw new UriParserSyntaxException("Error in syntax", hardException);
}
return ret;

View File

@ -18,38 +18,276 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import java.util.Arrays;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.olingo.odata4.commons.api.edm.Edm;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.producer.api.uri.UriInfo;
import org.apache.olingo.odata4.producer.api.uri.UriInfoAll;
import org.apache.olingo.odata4.producer.api.uri.UriInfoBatch;
import org.apache.olingo.odata4.producer.api.uri.UriInfoCrossjoin;
import org.apache.olingo.odata4.producer.api.uri.UriInfoEntityId;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
import org.apache.olingo.odata4.producer.api.uri.UriInfoMetadata;
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
import org.apache.olingo.odata4.producer.api.uri.UriInfoService;
import org.apache.olingo.odata4.producer.api.uri.UriResourcePart;
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.FilterOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.FormatOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.IdOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.InlineCountOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipTokenOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum;
import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption;
import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.FormatOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.IdOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.InlineCountImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.OrderByImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.QueryOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.SearchOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.SelectOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.SkipOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.SkipTokenOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.SystemQueryOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.TopOptionImpl;
public class UriInfoImpl {
public class UriInfoImpl implements UriInfo {
private UriInfoKind kind;
private Map<String, List<Object>> queryParameter = new HashMap<String, List<Object>>();
private List<String> entitySetNames = new ArrayList<String>(); // for $entity
private EdmEntityType entityTypeCast; // for $entity
public UriInfoImpl setKind(final UriInfoKind kind) {
// Query options
private List<CustomQueryOptionImpl> customQueryOptions;
private ExpandOptionImpl expandOption;
private FilterOptionImpl filterOption;
private FormatOptionImpl formatOption;
private IdOption idOption;
private InlineCountImpl inlineCountOption;
private OrderByImpl orderByOption;
private SearchOptionImpl searchOption;
private SelectOptionImpl selectOption;
private SkipOptionImpl skipOption;
private SkipTokenOptionImpl skipTokenOption;
private TopOptionImpl topOption;
private UriResourcePart lastPathPart;
private List<UriResourcePart> pathParts = new ArrayList<UriResourcePart>();
public UriInfoImpl(Edm edm) {
// this.edm = edm;
}
@Override
public UriInfoAll asUriInfoAll() {
return this;
}
@Override
public UriInfoBatch asUriInfoBatch() {
return this;
}
@Override
public UriInfoCrossjoin asUriInfoCrossjoin() {
return this;
}
@Override
public UriInfoEntityId asUriInfoEntityId() {
return this;
}
@Override
public UriInfoMetadata asUriInfoMetadata() {
return this;
}
@Override
public UriInfoResource asUriInfoResource() {
return this;
}
@Override
public List<String> getEntitySetNames() {
return Collections.unmodifiableList(entitySetNames);
}
public void addEntitySetName(String entitySet) {
entitySetNames.add(entitySet);
}
@Override
public List<UriResourcePart> getUriResourceParts() {
List<UriResourcePart> returnList = new ArrayList<UriResourcePart>();
for (UriResourcePart part : pathParts) {
returnList.add(part);
}
return Collections.unmodifiableList(returnList);
}
public void addPathInfo(UriResourcePartImpl uriPathInfo) {
pathParts.add(uriPathInfo);
lastPathPart = uriPathInfo;
}
@Override
public String getContext() {
return null;
}
@Override
public List<CustomQueryOption> getCustomQueryOptions() {
List<CustomQueryOption> retList = new ArrayList<CustomQueryOption>();
for (CustomQueryOptionImpl item : customQueryOptions) {
retList.add(item);
}
return retList;
}
@Override
public EdmEntityType getEntityTypeCast() {
return entityTypeCast;
}
@Override
public ExpandOption getExpandOption() {
return expandOption;
}
@Override
public FilterOption getFilterOption() {
return filterOption;
}
@Override
public FormatOption getFormatOption() {
return formatOption;
}
@Override
public IdOption getIdOption() {
return idOption;
}
@Override
public InlineCountOption getInlineCountOption() {
return inlineCountOption;
}
@Override
public UriInfoKind getKind() {
return kind;
}
public UriResourcePart getLastUriPathInfo() {
return lastPathPart;
}
@Override
public OrderByOption getOrderByOption() {
return orderByOption;
}
@Override
public SearchOption getSearchOption() {
return searchOption;
}
@Override
public SelectOption getSelectOption() {
return selectOption;
}
@Override
public SkipOption getSkipOption() {
return skipOption;
}
@Override
public SkipTokenOption getSkipTokenOption() {
return skipTokenOption;
}
@Override
public TopOption getTopOption() {
return topOption;
}
public UriInfoImpl setEntityTypeCast(EdmEntityType type) {
entityTypeCast = type;
return this;
}
public UriInfoImpl setFormat(FormatOptionImpl formatOption) {
this.formatOption = formatOption;
return this;
}
protected UriInfoImpl setKind(final UriInfoKind kind) {
this.kind = kind;
return this;
}
public Object getKind() {
return kind;
}
public UriInfoImpl setQueryOptions(List<QueryOptionImpl> list) {
public List<Object> getQueryParameters(String name) {
return queryParameter.get(name);
}
for (QueryOptionImpl item : list) {
if (item instanceof SystemQueryOptionImpl) {
SystemQueryOptionImpl sysItem = (SystemQueryOptionImpl) item;
public void addQueryParameter(String name, Object object) {
List<Object> entry = queryParameter.get(name);
if (entry != null) {
entry.add(object);
} else {
queryParameter.put(name, Arrays.asList(object));
if (sysItem.getKind() == SystemQueryOptionEnum.EXPAND) {
expandOption = (ExpandOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.FILTER) {
filterOption = (FilterOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.FORMAT) {
formatOption = (FormatOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.ID) {
idOption = (IdOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.INLINECOUNT) {
inlineCountOption = (InlineCountImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.ORDERBY) {
orderByOption = (OrderByImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.SEARCH) {
searchOption = (SearchOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.SELECT) {
selectOption = (SelectOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.SKIP) {
skipOption = (SkipOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.SKIPTOKEN) {
skipTokenOption = (SkipTokenOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.TOP) {
topOption = (TopOptionImpl) sysItem;
}
} else if (item instanceof CustomQueryOptionImpl) {
customQueryOptions.add((CustomQueryOptionImpl) item);
}
}
return this;
}
@Override
public UriInfoService asUriInfoService() {
return this;
}
public void clearPathInfo() {
pathParts.clear();
}
}

View File

@ -1,27 +0,0 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
public class UriInfoImplMetadata extends UriInfoImpl {
public UriInfoImplMetadata() {
this.setKind(UriInfoKind.metadata);
}
}

View File

@ -1,81 +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.producer.core.uri;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
import org.apache.olingo.odata4.producer.core.uri.expression.Expression;
import org.apache.olingo.odata4.producer.core.uri.queryoption.Filter;
public class UriInfoImplPath extends UriInfoImpl {
private List<UriPathInfoImpl> pathInfos = new ArrayList<UriPathInfoImpl>();
//TODO add other systemQueryParamters
private Filter spFilter;
public UriInfoImplPath() {
this.setKind(UriInfoKind.path);
}
public UriInfoImpl addPathInfo(UriPathInfoImpl pathInfo) {
pathInfos.add(pathInfo);
return this;
}
public UriPathInfoImpl getLastUriPathInfo() {
if (pathInfos.size() > 0) {
return pathInfos.get(pathInfos.size() - 1);
}
return null;
}
public UriPathInfoImpl getUriPathInfo(int index) {
return pathInfos.get(index);
}
public void setSystemParameter(SystemQueryParameter filter, Expression expression) {
spFilter = new Filter(expression);
addQueryParameter(filter.toString(), expression);
}
public Filter getFilter() {
return this.spFilter;
}
@Override
public String toString() {
String ret = "";
int i = 0;
while (i < pathInfos.size()) {
if ( i > 0 ) {
ret += "/";
}
ret += pathInfos.get(i).toString();
i++;
}
return ret;
}
}

View File

@ -0,0 +1,71 @@
/*******************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.api.uri.UriParameter;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
public class UriParameterImpl implements UriParameter {
private String name;
private String text;
private String alias;
private Expression expression;
@Override
public String getName() {
return name;
}
public UriParameterImpl setName(String name) {
this.name = name;
return this;
}
@Override
public String getAlias() {
return alias;
}
public UriParameterImpl setAlias(String alias) {
this.alias = alias;
return this;
}
@Override
public String getText() {
return text;
}
public UriParameterImpl setText(String text) {
this.text = text;
return this;
}
@Override
public Expression getExression() {
return expression;
}
public UriParameterImpl setExpression(Expression expression) {
this.expression = expression;
return this;
}
}

View File

@ -20,14 +20,19 @@ package org.apache.olingo.odata4.producer.core.uri;
//TODO Check name of this exception when implementing proper error handling
public class UriParserException extends Exception {
public UriParserException(String message, Throwable cause) {
super(message, cause);
}
/**
*
*/
private static final long serialVersionUID = -1813203179082217112L;
public UriParserException(String message, Throwable cause) {
super(message, cause);
}
public UriParserException(String message) {
super(message, null);
}
}

View File

@ -1,580 +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.producer.core.uri;
import java.util.List;
import org.antlr.v4.runtime.tree.ParseTree;
import org.apache.olingo.odata4.commons.api.edm.Edm;
import org.apache.olingo.odata4.commons.api.edm.EdmAction;
import org.apache.olingo.odata4.commons.api.edm.EdmActionImport;
import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
import org.apache.olingo.odata4.commons.api.edm.EdmElement;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.odata4.commons.api.edm.EdmEntitySet;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;
import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltAddContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltAliasContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltAndContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltBatchContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltComparismContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltEntityCastContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltEntityContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltEqualityContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltLiteralContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltMemberContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltMetadataContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltMethodContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltMultContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltOrContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltPharenthesisContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltResourcePathContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltRootContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltUnaryContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.CustomQueryOptionContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ExpandContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FilterContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FormatContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IdContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.InlinecountContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.MemberExprContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.NameValueListContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.NameValueOptListContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.NameValuePairContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OdataRelativeUriContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OrderbyContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.PathSegmentContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.PathSegmentsContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.QueryOptionContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.QueryOptionsContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ResourcePathContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SearchContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SelectContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SkipContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SkiptokenContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SystemQueryOptionContext;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.TopContext;
import org.apache.olingo.odata4.producer.core.uri.expression.Alias;
import org.apache.olingo.odata4.producer.core.uri.expression.Binary;
import org.apache.olingo.odata4.producer.core.uri.expression.Expression;
import org.apache.olingo.odata4.producer.core.uri.expression.Literal;
import org.apache.olingo.odata4.producer.core.uri.expression.Member;
import org.apache.olingo.odata4.producer.core.uri.expression.MethodCall;
import org.apache.olingo.odata4.producer.core.uri.expression.SupportedBinaryOperators;
import org.apache.olingo.odata4.producer.core.uri.expression.SupportedMethodCalls;
import org.apache.olingo.odata4.producer.core.uri.expression.SupportedUnaryOperators;
import org.apache.olingo.odata4.producer.core.uri.expression.UnaryOperator;
public class UriParserImpl {
private Edm edm = null;
private EdmEntityContainer edmEntityContainer = null;
private UriPathInfoImpl lastUriPathInfo;
public UriParserImpl(Edm edm) {
this.edm = edm;
this.edmEntityContainer = edm.getEntityContainer(null);
}
public UriInfoImpl ParseUri(String uri) throws UriParserException {
OdataRelativeUriEOFContext root = ParserAdapter.parseInput(uri);
return readODataRelativeUriEOF(root);
}
private UriInfoImpl readODataRelativeUriEOF(OdataRelativeUriEOFContext node) {
OdataRelativeUriContext first = (OdataRelativeUriContext) node.getChild(0);
UriInfoImpl uriInfo = readODataRelativeUri(first);
return uriInfo;
}
private UriInfoImpl readODataRelativeUri(OdataRelativeUriContext node) {
if (node instanceof AltBatchContext) {
return new UriInfoImplBatch();
} else if (node instanceof AltEntityContext) {
// TODO read the entity options
return new UriInfoImplEntity();
} else if (node instanceof AltEntityCastContext) {
// TODO read the entity options and the cast ns.odi
return new UriInfoImplEntity();
} else if (node instanceof AltMetadataContext) {
// TODO read the metadata queryparameter and fragment
return new UriInfoImplMetadata();
} else if (node instanceof AltResourcePathContext) {
return readAltResourcePath((AltResourcePathContext) node);
}
return null;
}
private UriInfoImpl readAltResourcePath(AltResourcePathContext node) {
ResourcePathContext rpc = (ResourcePathContext) node.getChild(0);
QueryOptionsContext qoc = (QueryOptionsContext) node.getChild(2); // is null if there are no options
if (rpc.vPSs != null) {
UriInfoImplPath uriInfo = readPathSegments(rpc.vPSs, null);
if (qoc != null) {
readQueryParameter(uriInfo, qoc);
}
return uriInfo;
} else if (rpc.vCJ != null) {
return new UriInfoImplCrossjoin();
} else if (rpc.vAll != null) {
return new UriInfoImplAll();
}
return null;
}
private void readQueryParameter(UriInfoImplPath uriInfoImplPath, QueryOptionsContext qoc) {
for (QueryOptionContext queryOption : qoc.qo) {
readQueryOption(uriInfoImplPath, queryOption);
}
}
private void readQueryOption(UriInfoImplPath uriInfoImplPath, QueryOptionContext queryOption) {
ParseTree firstChild = queryOption.getChild(0);
if (firstChild instanceof SystemQueryOptionContext) {
readSystemQueryOption(uriInfoImplPath, firstChild);
} else if (firstChild instanceof CustomQueryOptionContext) {
// TODO read custom request option
} else if (firstChild.getText().equals("@")) {
// TODO read alias and value
}
}
private void readSystemQueryOption(UriInfoImplPath uriInfoImplPath, ParseTree systemQueryOption) {
ParseTree firstChild = systemQueryOption.getChild(0);
if (firstChild instanceof ExpandContext) {
// TODO implement
} else if (firstChild instanceof FilterContext) {
Expression expression = readFilterOption(firstChild);
uriInfoImplPath.setSystemParameter(SystemQueryParameter.FILTER, expression);
return;
} else if (firstChild instanceof FormatContext) {
// TODO implement
} else if (firstChild instanceof IdContext) {
// TODO implement
} else if (firstChild instanceof InlinecountContext) {
// TODO implement
} else if (firstChild instanceof OrderbyContext) {
// TODO implement
} else if (firstChild instanceof SearchContext) {
// TODO implement
} else if (firstChild instanceof SelectContext) {
// TODO implement
} else if (firstChild instanceof SkipContext) {
// TODO implement
} else if (firstChild instanceof SkiptokenContext) {
// TODO implement
} else if (firstChild instanceof TopContext) {
// TODO implement
}
}
private Expression readFilterOption(ParseTree filter) {
return readCommonExpression(filter.getChild(2));
}
private Expression readCommonExpression(ParseTree expressionContext) {
// Expression ret = null;
if (expressionContext instanceof AltPharenthesisContext) {
return readCommonExpression(expressionContext.getChild(1));
} else if (expressionContext instanceof AltMethodContext) {
return readMethod(expressionContext);
} else if (expressionContext instanceof AltUnaryContext) {
UnaryOperator unary = new UnaryOperator();
unary.setOperator(SupportedUnaryOperators.get(expressionContext.getChild(0).getText()));
unary.setOperand(readCommonExpression(expressionContext.getChild(1)));
return unary;
} else if (expressionContext instanceof AltMemberContext) {
return readMember(expressionContext);
} else if (expressionContext instanceof AltMultContext) {
return readBinary(expressionContext);
} else if (expressionContext instanceof AltAddContext) {
return readBinary(expressionContext);
} else if (expressionContext instanceof AltComparismContext) {
return readBinary(expressionContext);
} else if (expressionContext instanceof AltEqualityContext) {
return readBinary(expressionContext);
} else if (expressionContext instanceof AltAndContext) {
return readBinary(expressionContext);
} else if (expressionContext instanceof AltOrContext) {
return readBinary(expressionContext);
} else if (expressionContext instanceof AltRootContext) {
// TODO
} else if (expressionContext instanceof AltAliasContext) {
Alias alias = new Alias();
alias.setReference(expressionContext.getChild(1).getText());
// TODO collect all aliases and verify them afterwards
return alias;
} else if (expressionContext instanceof AltLiteralContext) {
Literal literal = new Literal();
literal.setText(expressionContext.getText());
return literal;
}
return null;
}
private Expression readMember(ParseTree expressionContext) {
MemberExprContext context = (MemberExprContext) expressionContext.getChild(0);
Member member = new Member();
UriPathInfoIT pathInfoIT = new UriPathInfoIT();
if (context.ps!= null) {
if (context.getChild(0).getText().startsWith("$it/")) {
member.setIT(true); // TODO check if this is required
pathInfoIT.setIsExplicitIT(true);
}
UriParserImpl parser = new UriParserImpl(this.edm);
UriInfoImplPath path = parser.readPathSegments(context.ps,
new UriPathInfoIT().setType(lastUriPathInfo.getType()));
member.setPath(path);
} else {
member.setIT(true);
}
return member;
}
private Expression readMethod(ParseTree expressionContext) {
MethodCall expression = new MethodCall();
expression.setMethod(SupportedMethodCalls.get(expressionContext.getChild(0).getText()));
int i = 1;
while (i < expressionContext.getChildCount()) {
expression.addParameter(readCommonExpression(expressionContext.getChild(i)));
i++;
}
return expression;
}
private Expression readBinary(ParseTree expressionContext) {
Binary expression = new Binary();
expression.setLeftOperand(readCommonExpression(expressionContext.getChild(0)));
expression.setOperator(SupportedBinaryOperators.get(expressionContext.getChild(2).getText()));
expression.setRightOperand(readCommonExpression(expressionContext.getChild(4)));
return expression;
}
private UriInfoImplPath readPathSegments(PathSegmentsContext pathSegments, UriPathInfoImpl usePrevPathInfo) {
UriPathInfoImpl prevPathInfo = usePrevPathInfo;
UriInfoImplPath infoImpl = new UriInfoImplPath();
int iSegment = 0;
if (prevPathInfo == null) {
PathSegmentContext firstChild = (PathSegmentContext) pathSegments.vlPS.get(iSegment);
UriPathInfoImpl firstPathInfo = readFirstPathSegment(infoImpl, firstChild);
iSegment++;
prevPathInfo = firstPathInfo;
} else {
infoImpl.addPathInfo(prevPathInfo);
}
while (iSegment < pathSegments.vlPS.size()) {
PathSegmentContext nextChild = (PathSegmentContext) pathSegments.vlPS.get(iSegment);
prevPathInfo = readNextPathSegment(infoImpl, nextChild, prevPathInfo);
iSegment++;
}
lastUriPathInfo = prevPathInfo;
return infoImpl;
}
private UriPathInfoImpl readNextPathSegment(UriInfoImplPath infoImpl, PathSegmentContext pathSegment,
UriPathInfoImpl prevPathInfo) {
UriPathInfoImpl pathInfo = null;
String odi = pathSegment.vODI.getText(); // not optional
// check for properties
if (pathSegment.vNS == null) {
EdmType prevType = prevPathInfo.getType();
if (prevType instanceof EdmStructuralType) {
EdmStructuralType prevStructType = (EdmStructuralType) prevType;
EdmElement element = prevStructType.getProperty(odi);
if (element == null) {
// TODO exception property not found
}
if (element instanceof EdmProperty) {
prevPathInfo.addProperty((EdmProperty) element);
return prevPathInfo;
} else if (element instanceof EdmNavigationProperty) {
prevPathInfo.addNavigationProperty((EdmNavigationProperty) element);
UriPathInfoNavEntitySet pathInfoNav = new UriPathInfoNavEntitySet();
pathInfoNav.addSourceNavigationProperty((EdmNavigationProperty) element);
infoImpl.addPathInfo(pathInfoNav);
return pathInfoNav;
} else {
}
}
} else {
// check for namespace
String namespace = pathSegment.vNS.getText();
namespace = namespace.substring(0, namespace.length() - 1);
FullQualifiedName fullName = new FullQualifiedName(namespace, odi);
// check for typecasts
if (prevPathInfo.getType() instanceof EdmEntityType) {
EdmEntityType et = edm.getEntityType(fullName);
if (et != null) {
prevPathInfo.addTypeFilter(et);
if (pathSegment.vlVPO.size() != 0) {
UriKeyPredicateList keyPred = readKeyPredicateList(
pathSegment.vlVPO.get(0), (EdmEntityType) prevPathInfo.getType());
prevPathInfo.setKeyPredicates(keyPred);
}
return prevPathInfo;
}
} else if (prevPathInfo.getType() instanceof EdmComplexType) {
EdmComplexType ct = edm.getComplexType(fullName);
if (ct != null) {
prevPathInfo.addTypeFilter(ct);
return prevPathInfo;
}
}
// check for bound action
if (pathSegment.vlVPO == null) {
EdmAction action = edm.getAction(fullName, prevPathInfo.getFullType(), false);
pathInfo = new UriPathInfoActionImpl().setAction(action);
infoImpl.addPathInfo(pathInfo);
return pathInfo;
} else {
// check for bound functions
UriParameterlist parameterList = readParameterList(pathSegment.vlVPO.get(0));
EdmFunction function = edm.getFunction(fullName, prevPathInfo.getFullType(), false, parameterList.getNames());
if (function != null) {
UriPathInfoFunctionImpl pathInfoFunction = new UriPathInfoFunctionImpl();
pathInfoFunction.setFunction(function);
pathInfoFunction.setParameters(parameterList);
if (pathSegment.vlVPO.size() > 1) {
UriKeyPredicateList keyPred = readKeyPredicateList(
pathSegment.vlVPO.get(1), (EdmEntityType) prevPathInfo.getType());
pathInfoFunction.setKeyPredicates(keyPred);
}
infoImpl.addPathInfo(pathInfo);
return pathInfo;
}
}
// Exception unknown typeFilter/action or function
}
return null;
}
private UriPathInfoImpl readFirstPathSegment(UriInfoImplPath infoImpl, PathSegmentContext pathSegment) {
UriPathInfoImpl pathInfo = null;
// assert pathSegment.vNS = null;
String odi = pathSegment.vODI.getText(); // not optional
// EntitySet
EdmEntitySet edmES = edmEntityContainer.getEntitySet(odi);
if (edmES != null) {
pathInfo = readEntitySet(pathSegment, edmES);
}
// Singleton
EdmSingleton edmSI = edmEntityContainer.getSingleton(odi);
if (edmSI != null) {
pathInfo = readSingleton(pathSegment, edmSI);
}
// FunctionImport
EdmFunctionImport edmFI = edmEntityContainer.getFunctionImport(odi);
if (edmFI != null) {
pathInfo = readFunctionImport(pathSegment, edmFI);
}
// ActionImport
EdmActionImport edmAI = edmEntityContainer.getActionImport(odi);
if (edmAI != null) {
pathInfo = readActionImport(pathSegment, edmAI);
}
infoImpl.addPathInfo(pathInfo);
return pathInfo;
}
private UriPathInfoImpl readActionImport(PathSegmentContext pathSegment, EdmActionImport edmFI) {
UriPathInfoActionImpl uriPathInfo = new UriPathInfoActionImpl();
EdmAction action = edmFI.getAction();
uriPathInfo.setAction(action);
int num = pathSegment.vlVPO.size();
if (num == 2) {
// TODO exception action parameters not allowed
} else if (num == 1) {
if (uriPathInfo.isCollection() == true) {
if (uriPathInfo.getType() instanceof EdmEntityType) {
uriPathInfo.setKeyPredicates(
readKeyPredicateList(pathSegment.vlVPO.get(0), (EdmEntityType) uriPathInfo.getType()));
} else {
// TODO exception action keypreticates not allowed
}
} else {
// TODO exception action parameters not allowed
}
}
return uriPathInfo;
}
private UriPathInfoImpl readFunctionImport(PathSegmentContext pathSegment, EdmFunctionImport edmFI) {
UriPathInfoFunctionImpl uriPathInfo = new UriPathInfoFunctionImpl();
if (pathSegment.vlVPO == null) {
// TODO exception function parameters missing
}
UriParameterlist parameterList = readParameterList(pathSegment.vlVPO.get(0));
EdmFunction function = edmFI.getFunction(parameterList.getNames());
uriPathInfo.setFunction(function);
uriPathInfo.setParameters(parameterList);
if (pathSegment.vlVPO.size() > 1) {
if (!(uriPathInfo.getType() instanceof EdmEntityType)) {
// TODO exception illegally used keypredicates on function impored returning not an entityset
}
uriPathInfo.setKeyPredicates(
readKeyPredicateList(pathSegment.vlVPO.get(1), (EdmEntityType) uriPathInfo.getType()));
}
return null;
}
private UriPathInfoImpl readSingleton(PathSegmentContext pathSegment, EdmSingleton edmSI) {
UriPathInfoSingletonImpl uriPathInfo = new UriPathInfoSingletonImpl();
uriPathInfo.setSingleton(edmSI);
return uriPathInfo;
}
private UriPathInfoImpl readEntitySet(PathSegmentContext pathSegment, EdmEntitySet edmES) {
UriPathInfoEntitySetImpl uriPathInfo = new UriPathInfoEntitySetImpl();
uriPathInfo.setEntitSet(edmES);
// KeyPredicates
if (pathSegment.vlVPO != null) {
if (pathSegment.vlVPO.size() == 1) {
uriPathInfo.setKeyPredicates(readKeyPredicateList(pathSegment.vlVPO.get(0), edmES.getEntityType()));
} else if (pathSegment.vlVPO.size() > 1) {
// TODO exception ( to much key predicates)
}
}
return uriPathInfo;
}
private UriKeyPredicateList readKeyPredicateList(NameValueOptListContext parameterList, EdmEntityType entityType) {
if (parameterList.vVO != null) {
String value = parameterList.vVO.vV.getText();
List<String> kp = entityType.getKeyPredicateNames();
if (kp.size() != 1) {
// TODO exception "for using a value only keyPredicate there must be exact ONE defined keyProperty
}
String keyName = kp.get(0); // there yhoul
return new UriKeyPredicateList().add(keyName, value);
}
NameValueListContext vNVL = parameterList.vNVL;
if (vNVL == null) {
// TODO throw exception empty keypredicates not allowed
}
UriKeyPredicateList uriPrameterList1 = new UriKeyPredicateList();
for (NameValuePairContext nvl : vNVL.vNVP) {
String name = nvl.vODI.getText();
String value = nvl.vVAL.getText();
uriPrameterList1.add(name, value);
}
return uriPrameterList1;
}
private UriParameterlist readParameterList(NameValueOptListContext parameterList) {
if (parameterList.vVO != null) {
// TODO throw error "Value Only" not allowed for function/action parameters, only in keypredicates
return null;
}
NameValueListContext vNVL = parameterList.vNVL;
UriParameterlist uriPrameterList1 = new UriParameterlist();
for (NameValuePairContext nvl : vNVL.vNVP) {
String name = nvl.vODI.getText();
if (nvl.vVAL != null) {
String value = nvl.vVAL.getText();
uriPrameterList1.add(name, value, null);
} else {
String alias = nvl.vALI.getText();
uriPrameterList1.add(name, null, alias);
}
}
return uriPrameterList1;
}
}

View File

@ -0,0 +1,39 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
//TODO Check name of this exception when implementing proper error handling
public class UriParserSemanticException extends UriParserException {
/**
*
*/
private static final long serialVersionUID = -1813203179082217112L;
public UriParserSemanticException(String message, Throwable cause) {
super(message, cause);
}
public UriParserSemanticException(String message) {
super(message, null);
}
}

View File

@ -0,0 +1,36 @@
/*******************************************************************************
* 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.producer.core.uri;
public class UriParserSyntaxException extends UriParserException {
/**
*
*/
private static final long serialVersionUID = -975557346686301719L;
public UriParserSyntaxException(String message, Throwable cause) {
super(message, cause);
}
public UriParserSyntaxException(String message) {
super(message, null);
}
}

View File

@ -1,202 +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.producer.core.uri;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.EdmElement;
import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
import org.apache.olingo.odata4.producer.api.uri.UriPathInfoKind;
import org.apache.olingo.odata4.producer.core.uri.expression.Expression;
public abstract class UriPathInfoImpl {
private EdmType initialType = null;
private EdmType finalType = null;
private UriPathInfoKind kind;
private EdmType collectionTypeFilter = null;
private UriKeyPredicateList keyPredicates = null;
private EdmType singleTypeFilter = null;
private class PathListItem {
private EdmElement property; // ia EdmProperty or EdmNavigationProperty
private EdmType initialType;
private EdmType finalType;
private boolean isCollection;
}
private List<PathListItem> pathList = null;
private boolean isCollection;
public UriPathInfoImpl setType(EdmType edmType) {
this.initialType = edmType;
this.finalType = edmType;
return this;
}
public EdmType getType() {
return finalType;
}
public EdmType getInitialType() {
return initialType;
}
public EdmType getCollectionTypeFilter() {
return collectionTypeFilter;
}
public EdmType getSingleTypeFilter() {
return singleTypeFilter;
}
public FullQualifiedName getFullType() {
return new FullQualifiedName(finalType.getNamespace(), finalType.getName());
}
public UriPathInfoImpl setKind(UriPathInfoKind kind) {
this.kind = kind;
return this;
}
public UriPathInfoKind getKind() {
return kind;
}
public UriPathInfoImpl setKeyPredicates(UriKeyPredicateList keyPredicates) {
if (this.isCollection() != true) {
// throw exception
}
this.keyPredicates = keyPredicates;
this.setCollection(false);
return this;
}
public UriKeyPredicateList getKeyPredicates() {
return this.keyPredicates;
}
public UriPathInfoImpl addTypeFilter(EdmStructuralType targetType) {
// TODO if there is a navigation path the type filter musst be applied to the last
if (pathList == null) {
if (keyPredicates == null) {
if (collectionTypeFilter != null) {
// TODO exception Type filters are not directy chainable
}
if (targetType.compatibleTo((EdmStructuralType) finalType)) {
collectionTypeFilter = targetType;
finalType = targetType;
} else {
// TODO throw exception
}
} else {
if (singleTypeFilter != null) {
// TODO exception Type filters are not directy chainable
}
if (targetType.compatibleTo((EdmStructuralType) finalType)) {
singleTypeFilter = targetType;
finalType = targetType;
} else {
// TODO throw exception
}
}
} else {
PathListItem last = pathList.get(pathList.size() - 1);
if (targetType.compatibleTo(last.finalType)) {
last.finalType = targetType;
}
}
return this;
}
public UriPathInfoImpl addProperty(EdmProperty property) {
if (pathList == null) {
pathList = new ArrayList<PathListItem>();
}
PathListItem newItem = new PathListItem();
newItem.property = property;
newItem.initialType = property.getType();
newItem.finalType = property.getType();
newItem.isCollection = property.isCollection();
pathList.add(newItem);
this.finalType = newItem.finalType;
this.isCollection = newItem.isCollection;
return this;
}
public UriPathInfoImpl addNavigationProperty(EdmNavigationProperty property) {
if (pathList == null) {
pathList = new ArrayList<PathListItem>();
}
PathListItem newItem = new PathListItem();
newItem.property = property;
newItem.initialType = property.getType();
newItem.finalType = property.getType();
newItem.isCollection = property.isCollection();
pathList.add(newItem);
this.finalType = newItem.finalType;
this.isCollection = newItem.isCollection;
return this;
}
public int getPropertyCount() {
return pathList.size();
}
public EdmElement getProperty(int index) {
return pathList.get(index).property;
}
public UriPathInfoImpl setCollection(boolean isCollection) {
this.isCollection = isCollection;
return this;
}
public boolean isCollection() {
return isCollection;
}
@Override
public String toString() {
String ret = "";
int i = 0;
while (i < pathList.size()) {
if (i > 0) {
ret += "/";
}
ret += pathList.get(i).property.getName();
i++;
}
return ret;
}
}

View File

@ -0,0 +1,75 @@
/*******************************************************************************
* 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.producer.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmAction;
import org.apache.olingo.odata4.commons.api.edm.EdmActionImport;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceAction;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
public class UriResourceActionImpl extends UriResourceImplTyped implements UriResourceAction {
protected EdmAction action;
protected EdmActionImport actionImport;
public UriResourceActionImpl() {
super(UriResourceKind.action);
}
@Override
public EdmAction getAction() {
return action;
}
public UriResourceActionImpl setAction(EdmAction action) {
this.action = action;
return this;
}
@Override
public EdmActionImport getActionImport() {
return actionImport;
}
public UriResourceActionImpl setActionImport(EdmActionImport actionImport) {
this.actionImport = actionImport;
this.setAction(actionImport.getAction());
return this;
}
@Override
public String toString() {
return action.getName() + super.toString();
}
@Override
public boolean isCollection() {
if ( action != null) {
return action.getReturnType().isCollection();
}
return false;
}
@Override
public EdmType getType() {
return action.getReturnType().getType();
}
}

View File

@ -0,0 +1,67 @@
/*******************************************************************************
* 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.producer.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceAll;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
public class UriResourceAllImpl extends UriResourceImplTyped implements UriResourceAll {
protected EdmProperty property;
private String lamdaVariable;
private ExpressionImpl expression;
public UriResourceAllImpl() {
super(UriResourceKind.lamdaAll);
}
@Override
public EdmType getType() {
return EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance();
}
@Override
public boolean isCollection() {
return false;
}
@Override
public String getLamdaVariable() {
return lamdaVariable;
}
public UriResourceAllImpl setLamdaVariable(String lamdaVariable) {
this.lamdaVariable = lamdaVariable;
return this;
};
@Override
public Expression getExpression() {
return expression;
}
public UriResourceAllImpl setExpression(ExpressionImpl expression) {
this.expression = expression;
return this;
};
}

View File

@ -0,0 +1,67 @@
/*******************************************************************************
* 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.producer.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceAny;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
public class UriResourceAnyImpl extends UriResourceImplTyped implements UriResourceAny {
protected EdmProperty property;
private String lamdaVariable;
private ExpressionImpl expression;
public UriResourceAnyImpl() {
super(UriResourceKind.lamdaAny);
}
@Override
public EdmType getType() {
return EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance();
}
@Override
public boolean isCollection() {
return false;
}
@Override
public String getLamdaVariable() {
return lamdaVariable;
}
public UriResourceAnyImpl setLamdaVariable(String lamdaVariable) {
this.lamdaVariable = lamdaVariable;
return this;
};
@Override
public Expression getExpression() {
return expression;
}
public UriResourceAnyImpl setExpression(ExpressionImpl expression) {
this.expression = expression;
return this;
};
}

View File

@ -0,0 +1,65 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceComplexProperty;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
public class UriResourceComplexPropertyImpl extends UriResourceImplTyped implements UriResourceComplexProperty {
protected EdmProperty property;
public UriResourceComplexPropertyImpl() {
super(UriResourceKind.complexProperty);
}
@Override
public EdmProperty getProperty() {
return property;
}
public UriResourceComplexPropertyImpl setProperty(EdmProperty property) {
this.property = property;
return this;
}
@Override
public EdmComplexType getComplexType() {
return (EdmComplexType) this.getType();
}
@Override
public EdmComplexType getComplexTypeFilter() {
return (EdmComplexType) typeFilter;
}
@Override
public EdmType getType() {
return property.getType();
}
@Override
public boolean isCollection() {
return property.isCollection();
}
}

View File

@ -0,0 +1,30 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.api.uri.UriResourceCount;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
public class UriResourceCountImpl extends UriResourcePartImpl implements UriResourceCount {
public UriResourceCountImpl() {
super(UriResourceKind.count);
}
}

View File

@ -0,0 +1,74 @@
/*******************************************************************************
* 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.producer.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmEntitySet;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceEntitySet;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
public class UriResourceEntitySetImpl extends UriResourceImplKeyPred implements UriResourceEntitySet {
protected EdmEntitySet edmEntitySet = null;
public UriResourceEntitySetImpl() {
super(UriResourceKind.entitySet);
}
@Override
public EdmEntitySet getEntitySet() {
return edmEntitySet;
}
public UriResourceEntitySetImpl setEntitSet(EdmEntitySet edmES) {
this.edmEntitySet = edmES;
return this;
}
@Override
public String toString() {
return edmEntitySet.getName() + super.toString();
}
@Override
public EdmEntityType getEntityType() {
return edmEntitySet.getEntityType();
}
@Override
public EdmType getType() {
/*if (singleTypeFilter != null) {
return singleTypeFilter;
} else if (collectionTypeFilter != null) {
return collectionTypeFilter;
}*/
return edmEntitySet.getEntityType();
}
@Override
public boolean isCollection() {
if (keyPredicates == null) {
return true;
}
return false;
}
}

View File

@ -0,0 +1,110 @@
/*******************************************************************************
* 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.producer.core.uri;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
import org.apache.olingo.odata4.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriParameter;
import org.apache.olingo.odata4.producer.api.uri.UriResourceFunction;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
/**
* Covers Function imports and BoundFunction in URI
*/
public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements UriResourceFunction {
protected List<UriParameterImpl> parameters;
protected EdmFunction function;
protected EdmFunctionImport functionImport;
public UriResourceFunctionImpl() {
super(UriResourceKind.function);
}
@Override
public List<UriParameter> getParameters() {
List<UriParameter> retList = new ArrayList<UriParameter>();
for (UriParameterImpl item : parameters) {
retList.add(item);
}
return retList;
}
public UriResourceFunctionImpl setParameters(List<UriParameterImpl> parameters) {
this.parameters = parameters;
return this;
}
@Override
public EdmFunction getFunction() {
return function;
}
public UriResourceFunctionImpl setFunction(EdmFunction function) {
this.function = function;
return this;
}
@Override
public EdmFunctionImport getFunctionImport() {
return functionImport;
}
public UriResourceFunctionImpl setFunctionImport(EdmFunctionImport edmFI, List<UriParameterImpl> parameters) {
this.functionImport = edmFI;
this.parameters = parameters;
List<String> names = new ArrayList<String>();
for (UriParameterImpl item : parameters) {
names.add(item.getName());
}
setFunction(edmFI.getFunction(names));
return this;
}
@Override
public String toString() {
return function.getName() + super.toString();
}
@Override
public EdmType getType() {
return function.getReturnType().getType();
}
@Override
public boolean isCollection() {
if (keyPredicates != null ) {
return false;
}
return function.getReturnType().isCollection();
}
}

View File

@ -0,0 +1,75 @@
/*******************************************************************************
* 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.producer.core.uri;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriParameter;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
public abstract class UriResourceImplKeyPred extends UriResourceImplTyped {
protected EdmType collectionTypeFilter = null;
protected List<UriParameterImpl> keyPredicates = null;
protected EdmType singleTypeFilter = null;
public UriResourceImplKeyPred(UriResourceKind kind) {
super(kind);
}
public EdmType getComplexTypeFilter() {
if (singleTypeFilter != null) {
return singleTypeFilter;
}
return collectionTypeFilter;
}
public EdmType getTypeFilterOnCollection() {
return collectionTypeFilter;
}
public EdmType getTypeFilterOnEntry() {
return singleTypeFilter;
}
public List<UriParameter> getKeyPredicates() {
List<UriParameter> retList = new ArrayList<UriParameter>();
for (UriParameterImpl item : keyPredicates) {
retList.add(item);
}
return retList;
}
public UriResourceImplKeyPred setKeyPredicates(List<UriParameterImpl> list) {
keyPredicates = list;
return this;
}
public void setSingleTypeFilter(EdmType singleTypeFilter) {
this.singleTypeFilter = singleTypeFilter;
}
public void setCollectionTypeFilter(EdmType collectionTypeFilter) {
this.collectionTypeFilter = collectionTypeFilter;
}
}

View File

@ -18,26 +18,26 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.odata4.producer.api.uri.UriPathInfoKind;
import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourcePartTyped;
public class UriPathInfoNavEntitySet extends UriPathInfoImpl {
public abstract class UriResourceImplTyped extends UriResourcePartImpl implements UriResourcePartTyped {
private EdmNavigationProperty sourceNavigationProperty;
public UriPathInfoNavEntitySet() {
this.setKind(UriPathInfoKind.navEntitySet);
protected EdmType typeFilter = null;
public UriResourceImplTyped(UriResourceKind kind) {
super(kind);
}
public UriPathInfoNavEntitySet addSourceNavigationProperty(EdmNavigationProperty sourceNavigationProperty) {
this.sourceNavigationProperty = sourceNavigationProperty;
this.setType(sourceNavigationProperty.getType());
return this;
public EdmType getComplexTypeFilter() {//TODO rename to TypeFilter
return typeFilter;
}
@Override
public String toString() {
return sourceNavigationProperty.getName()+super.toString();
public UriResourceImplTyped setTypeFilter(EdmStructuralType typeFilter) {
this.typeFilter = typeFilter;
return this;
}
}

Some files were not shown because too many files have changed in this diff Show More