This is an automated email from the ASF dual-hosted git repository.

ramyav pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/olingo-odata4.git


The following commit(s) were added to refs/heads/master by this push:
     new 3aa902b  [ODATA-1157]Support orderby, top and skip transformation in  
requests
3aa902b is described below

commit 3aa902b1b493a04f221a1e06c61d5b5d496786a9
Author: ramya vasanth <ramya.vasa...@sap.com>
AuthorDate: Fri Oct 9 12:05:51 2020 +0530

    [ODATA-1157]Support orderby, top and skip transformation in  requests
---
 .../server/api/uri/queryoption/ApplyItem.java      |   5 +-
 .../{ApplyItem.java => apply/OrderBy.java}         |  77 ++++++--------
 .../{ApplyItem.java => apply/Skip.java}            |  78 ++++++--------
 .../queryoption/{ApplyItem.java => apply/Top.java} |  79 ++++++--------
 .../olingo/server/core/uri/parser/ApplyParser.java |  30 ++++++
 .../server/core/uri/parser/UriTokenizer.java       |  12 +++
 .../core/uri/queryoption/apply/OrderByImpl.java}   |  87 ++++++++--------
 .../core/uri/queryoption/apply/SkipImpl.java}      |  87 ++++++++--------
 .../core/uri/queryoption/apply/TopImpl.java}       |  87 ++++++++--------
 .../server/core/uri/parser/ApplyParserTest.java    | 114 +++++++++++++++++++++
 10 files changed, 385 insertions(+), 271 deletions(-)

diff --git 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
 
b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
index 34588e2..156aefc 100644
--- 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
+++ 
b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
@@ -34,7 +34,10 @@ public interface ApplyItem {
     FILTER,
     GROUP_BY,
     IDENTITY,
-    SEARCH
+    SEARCH,
+    ORDERBY,
+    TOP,
+    SKIP
   }
 
   /**
diff --git 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
 
b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/OrderBy.java
similarity index 63%
copy from 
lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
copy to 
lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/OrderBy.java
index 34588e2..62d9dc8 100644
--- 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
+++ 
b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/OrderBy.java
@@ -1,45 +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.server.api.uri.queryoption;
-
-/**
- * Represents a single transformation from the system query option $apply.
- */
-public interface ApplyItem {
-
-  /** The kind of the transformation. */
-  public enum Kind {
-    AGGREGATE,
-    BOTTOM_TOP,
-    COMPUTE,
-    CONCAT,
-    CUSTOM_FUNCTION,
-    EXPAND,
-    FILTER,
-    GROUP_BY,
-    IDENTITY,
-    SEARCH
-  }
-
-  /**
-   * Gets the kind of the transformation.
-   * @return transformation kind
-   */
-  Kind getKind();
-}
+/*
+ * 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.server.api.uri.queryoption.apply;
+
+import org.apache.olingo.server.api.uri.queryoption.ApplyItem;
+import org.apache.olingo.server.api.uri.queryoption.OrderByOption;
+/**
+ * Represents the orderby transformation.
+ */
+public interface OrderBy extends ApplyItem {
+       /**
+          * Gets the order by option.
+          * @return a {@link OrderByOption} (but never <code>null</code>)
+          */
+         OrderByOption getOrderByOption();
+}
diff --git 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
 
b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/Skip.java
similarity index 63%
copy from 
lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
copy to 
lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/Skip.java
index 34588e2..cda0ad5 100644
--- 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
+++ 
b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/Skip.java
@@ -1,45 +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.server.api.uri.queryoption;
-
-/**
- * Represents a single transformation from the system query option $apply.
- */
-public interface ApplyItem {
-
-  /** The kind of the transformation. */
-  public enum Kind {
-    AGGREGATE,
-    BOTTOM_TOP,
-    COMPUTE,
-    CONCAT,
-    CUSTOM_FUNCTION,
-    EXPAND,
-    FILTER,
-    GROUP_BY,
-    IDENTITY,
-    SEARCH
-  }
-
-  /**
-   * Gets the kind of the transformation.
-   * @return transformation kind
-   */
-  Kind getKind();
-}
+/*
+ * 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.server.api.uri.queryoption.apply;
+
+import org.apache.olingo.server.api.uri.queryoption.ApplyItem;
+import org.apache.olingo.server.api.uri.queryoption.SkipOption;
+
+/**
+ * Represents the skip transformation.
+ */
+public interface Skip extends ApplyItem {
+       /**
+          * Gets the skip option.
+          * @return a {@link SkipOption} (but never <code>null</code>)
+          */
+         SkipOption getSkipOption();
+}
diff --git 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
 
b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/Top.java
similarity index 63%
copy from 
lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
copy to 
lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/Top.java
index 34588e2..8be2c32 100644
--- 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
+++ 
b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/Top.java
@@ -1,45 +1,34 @@
-/*
- * 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.server.api.uri.queryoption;
-
-/**
- * Represents a single transformation from the system query option $apply.
- */
-public interface ApplyItem {
-
-  /** The kind of the transformation. */
-  public enum Kind {
-    AGGREGATE,
-    BOTTOM_TOP,
-    COMPUTE,
-    CONCAT,
-    CUSTOM_FUNCTION,
-    EXPAND,
-    FILTER,
-    GROUP_BY,
-    IDENTITY,
-    SEARCH
-  }
-
-  /**
-   * Gets the kind of the transformation.
-   * @return transformation kind
-   */
-  Kind getKind();
-}
+/*
+ * 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.server.api.uri.queryoption.apply;
+
+import org.apache.olingo.server.api.uri.queryoption.ApplyItem;
+import org.apache.olingo.server.api.uri.queryoption.TopOption;
+
+/**
+ * Represents the top transformation.
+ */
+
+public interface Top extends ApplyItem {
+       /**
+          * Gets the top option.
+          * @return a {@link TopOption} (but never <code>null</code>)
+          */
+         TopOption getTopOption();
+}
diff --git 
a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ApplyParser.java
 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ApplyParser.java
index ab1a491..4592014 100644
--- 
a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ApplyParser.java
+++ 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ApplyParser.java
@@ -46,7 +46,9 @@ import org.apache.olingo.server.api.uri.queryoption.ApplyItem;
 import org.apache.olingo.server.api.uri.queryoption.ApplyOption;
 import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
 import org.apache.olingo.server.api.uri.queryoption.FilterOption;
+import org.apache.olingo.server.api.uri.queryoption.OrderByOption;
 import org.apache.olingo.server.api.uri.queryoption.SearchOption;
+import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
 import org.apache.olingo.server.api.uri.queryoption.apply.Aggregate;
 import org.apache.olingo.server.api.uri.queryoption.apply.AggregateExpression;
 import 
org.apache.olingo.server.api.uri.queryoption.apply.AggregateExpression.StandardMethod;
@@ -67,6 +69,8 @@ import 
org.apache.olingo.server.core.uri.parser.UriTokenizer.TokenKind;
 import org.apache.olingo.server.core.uri.queryoption.ApplyOptionImpl;
 import org.apache.olingo.server.core.uri.queryoption.ExpandItemImpl;
 import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.SkipOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.TopOptionImpl;
 import 
org.apache.olingo.server.core.uri.queryoption.apply.AggregateExpressionImpl;
 import org.apache.olingo.server.core.uri.queryoption.apply.AggregateImpl;
 import org.apache.olingo.server.core.uri.queryoption.apply.BottomTopImpl;
@@ -81,7 +85,10 @@ import 
org.apache.olingo.server.core.uri.queryoption.apply.FilterImpl;
 import org.apache.olingo.server.core.uri.queryoption.apply.GroupByImpl;
 import org.apache.olingo.server.core.uri.queryoption.apply.GroupByItemImpl;
 import org.apache.olingo.server.core.uri.queryoption.apply.IdentityImpl;
+import org.apache.olingo.server.core.uri.queryoption.apply.OrderByImpl;
 import org.apache.olingo.server.core.uri.queryoption.apply.SearchImpl;
+import org.apache.olingo.server.core.uri.queryoption.apply.SkipImpl;
+import org.apache.olingo.server.core.uri.queryoption.apply.TopImpl;
 import org.apache.olingo.server.core.uri.queryoption.expression.MemberImpl;
 import org.apache.olingo.server.core.uri.validator.UriValidationException;
 
@@ -172,6 +179,29 @@ public class ApplyParser {
       ParserHelper.requireNext(tokenizer, TokenKind.CLOSE);
       return new SearchImpl().setSearchOption(searchOption);
 
+    } else if (tokenizer.next(TokenKind.OrderByTrafo)) {
+       final OrderByOption orderByOption = new OrderByParser(edm, odata)
+                       .parse(tokenizer, referencedType, 
crossjoinEntitySetNames, aliases);
+       ParserHelper.requireNext(tokenizer, TokenKind.CLOSE);
+       return new OrderByImpl().setOrderByOption(orderByOption);
+    } else if (tokenizer.next(TokenKind.TopTrafo)) {
+       ParserHelper.requireNext(tokenizer, TokenKind.IntegerValue);
+       final int value = 
ParserHelper.parseNonNegativeInteger(SystemQueryOptionKind.TOP.toString(),
+                tokenizer.getText(), true);
+        TopOptionImpl topOption = new TopOptionImpl();
+        topOption.setText(tokenizer.getText());
+        topOption.setValue(value);
+        ParserHelper.requireNext(tokenizer, TokenKind.CLOSE);
+        return new TopImpl().setTopOption(topOption);
+    } else if (tokenizer.next(TokenKind.SkipTrafo)) {
+       ParserHelper.requireNext(tokenizer, TokenKind.IntegerValue);
+       final int value = 
ParserHelper.parseNonNegativeInteger(SystemQueryOptionKind.SKIP.toString(),
+                tokenizer.getText(), true);
+        SkipOptionImpl skipOption = new SkipOptionImpl();
+        skipOption.setText(tokenizer.getText());
+        skipOption.setValue(value);
+        ParserHelper.requireNext(tokenizer, TokenKind.CLOSE);
+        return new SkipImpl().setSkipOption(skipOption);
     } else if (tokenizer.next(TokenKind.QualifiedName)) {
       return parseCustomFunction(new FullQualifiedName(tokenizer.getText()), 
referencedType);
 
diff --git 
a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriTokenizer.java
 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriTokenizer.java
index 5b05111..10a7b8a 100644
--- 
a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriTokenizer.java
+++ 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriTokenizer.java
@@ -187,6 +187,9 @@ public class UriTokenizer {
     TopCountTrafo, // for the aggregation extension
     TopPercentTrafo, // for the aggregation extension
     TopSumTrafo, // for the aggregation extension
+    TopTrafo, // for the aggregation extension
+    SkipTrafo, // for the aggregation extension
+    OrderByTrafo, // for the aggregation extension
 
     RollUpSpec, // for the aggregation extension
 
@@ -689,6 +692,15 @@ public class UriTokenizer {
     case TopSumTrafo:
       found = nextMethod("topsum");
       break;
+    case OrderByTrafo:
+       found = nextMethod("orderby");
+       break;
+    case TopTrafo:
+       found = nextMethod("top");
+       break;
+    case SkipTrafo:
+       found = nextMethod("skip");
+       break;
 
     // Roll-up specification for the aggregation extension
     case RollUpSpec:
diff --git 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/OrderByImpl.java
similarity index 56%
copy from 
lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
copy to 
lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/OrderByImpl.java
index 34588e2..ac72ec2 100644
--- 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
+++ 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/OrderByImpl.java
@@ -1,45 +1,42 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.api.uri.queryoption;
-
-/**
- * Represents a single transformation from the system query option $apply.
- */
-public interface ApplyItem {
-
-  /** The kind of the transformation. */
-  public enum Kind {
-    AGGREGATE,
-    BOTTOM_TOP,
-    COMPUTE,
-    CONCAT,
-    CUSTOM_FUNCTION,
-    EXPAND,
-    FILTER,
-    GROUP_BY,
-    IDENTITY,
-    SEARCH
-  }
-
-  /**
-   * Gets the kind of the transformation.
-   * @return transformation kind
-   */
-  Kind getKind();
-}
+/*
+ * 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.server.core.uri.queryoption.apply;
+
+import org.apache.olingo.server.api.uri.queryoption.OrderByOption;
+import org.apache.olingo.server.api.uri.queryoption.apply.OrderBy;
+
+public class OrderByImpl implements OrderBy {
+
+       private OrderByOption orderByOption = null;
+       
+       @Override
+       public Kind getKind() {
+               return Kind.ORDERBY;
+       }
+
+       @Override
+       public OrderByOption getOrderByOption() {
+               return orderByOption;
+       }
+
+       public OrderByImpl setOrderByOption(final OrderByOption orderByOption) {
+           this.orderByOption = orderByOption;
+           return this;
+         }
+}
diff --git 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/SkipImpl.java
similarity index 58%
copy from 
lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
copy to 
lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/SkipImpl.java
index 34588e2..070e7a7 100644
--- 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
+++ 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/SkipImpl.java
@@ -1,45 +1,42 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.api.uri.queryoption;
-
-/**
- * Represents a single transformation from the system query option $apply.
- */
-public interface ApplyItem {
-
-  /** The kind of the transformation. */
-  public enum Kind {
-    AGGREGATE,
-    BOTTOM_TOP,
-    COMPUTE,
-    CONCAT,
-    CUSTOM_FUNCTION,
-    EXPAND,
-    FILTER,
-    GROUP_BY,
-    IDENTITY,
-    SEARCH
-  }
-
-  /**
-   * Gets the kind of the transformation.
-   * @return transformation kind
-   */
-  Kind getKind();
-}
+/*
+ * 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.server.core.uri.queryoption.apply;
+
+import org.apache.olingo.server.api.uri.queryoption.SkipOption;
+import org.apache.olingo.server.api.uri.queryoption.apply.Skip;
+
+public class SkipImpl implements Skip {
+
+       private SkipOption skipOption = null;
+       
+       @Override
+       public Kind getKind() {
+               return Kind.SKIP;
+       }
+
+       @Override
+       public SkipOption getSkipOption() {
+               return skipOption;
+       }
+
+       public SkipImpl setSkipOption(final SkipOption skipOption) {
+           this.skipOption = skipOption;
+           return this;
+         }
+}
diff --git 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/TopImpl.java
similarity index 59%
copy from 
lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
copy to 
lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/TopImpl.java
index 34588e2..c299c16 100644
--- 
a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ApplyItem.java
+++ 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/TopImpl.java
@@ -1,45 +1,42 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.api.uri.queryoption;
-
-/**
- * Represents a single transformation from the system query option $apply.
- */
-public interface ApplyItem {
-
-  /** The kind of the transformation. */
-  public enum Kind {
-    AGGREGATE,
-    BOTTOM_TOP,
-    COMPUTE,
-    CONCAT,
-    CUSTOM_FUNCTION,
-    EXPAND,
-    FILTER,
-    GROUP_BY,
-    IDENTITY,
-    SEARCH
-  }
-
-  /**
-   * Gets the kind of the transformation.
-   * @return transformation kind
-   */
-  Kind getKind();
-}
+/*
+ * 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.server.core.uri.queryoption.apply;
+
+import org.apache.olingo.server.api.uri.queryoption.TopOption;
+import org.apache.olingo.server.api.uri.queryoption.apply.Top;
+
+public class TopImpl implements Top {
+
+       private TopOption topOption = null;
+       
+       @Override
+       public Kind getKind() {
+               return Kind.TOP;
+       }
+
+       @Override
+       public TopOption getTopOption() {
+               return topOption;
+       }
+
+       public TopImpl setTopOption(final TopOption topOption) {
+           this.topOption = topOption;
+           return this;
+         }
+}
diff --git 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ApplyParserTest.java
 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ApplyParserTest.java
index c22df73..8e31808 100644
--- 
a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ApplyParserTest.java
+++ 
b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ApplyParserTest.java
@@ -23,7 +23,9 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.List;
 
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@@ -36,6 +38,7 @@ import org.apache.olingo.server.api.uri.UriResource;
 import org.apache.olingo.server.api.uri.UriResourceKind;
 import org.apache.olingo.server.api.uri.queryoption.ApplyItem;
 import org.apache.olingo.server.api.uri.queryoption.ApplyOption;
+import org.apache.olingo.server.api.uri.queryoption.OrderByItem;
 import org.apache.olingo.server.api.uri.queryoption.apply.Aggregate;
 import org.apache.olingo.server.api.uri.queryoption.apply.AggregateExpression;
 import 
org.apache.olingo.server.api.uri.queryoption.apply.AggregateExpression.StandardMethod;
@@ -50,12 +53,16 @@ import 
org.apache.olingo.server.api.uri.queryoption.apply.Filter;
 import org.apache.olingo.server.api.uri.queryoption.apply.GroupBy;
 import org.apache.olingo.server.api.uri.queryoption.apply.GroupByItem;
 import org.apache.olingo.server.api.uri.queryoption.apply.Identity;
+import org.apache.olingo.server.api.uri.queryoption.apply.OrderBy;
 import org.apache.olingo.server.api.uri.queryoption.apply.Search;
+import org.apache.olingo.server.api.uri.queryoption.apply.Skip;
+import org.apache.olingo.server.api.uri.queryoption.apply.Top;
 import 
org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
 import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
 import org.apache.olingo.server.core.uri.UriInfoImpl;
 import org.apache.olingo.server.core.uri.parser.search.SearchParserException;
 import org.apache.olingo.server.core.uri.testutil.ExpandValidator;
+import org.apache.olingo.server.core.uri.testutil.FilterTreeToText;
 import org.apache.olingo.server.core.uri.testutil.FilterValidator;
 import org.apache.olingo.server.core.uri.testutil.ResourceValidator;
 import org.apache.olingo.server.core.uri.testutil.TestUriValidator;
@@ -207,6 +214,30 @@ public class ApplyParserTest {
         
.goConcat(1).goBottomTop().isMethod(Method.BOTTOM_COUNT).goNumber().isLiteral("2");
 
     parseEx("ESTwoKeyNav", 
"concat(identity)").isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+    
+    parse("ESTwoKeyNav", "concat("
+               + "groupby((PropertyString),aggregate(PropertyInt16 with sum as 
s)),"
+               + 
"groupby((PropertyString,PropertyInt16),aggregate(PropertyInt16 with sum as 
s1))"
+               + "/orderby(PropertyString,PropertyInt16)"
+               + "/skip(3)"
+               + "/top(10))")
+    .is(Concat.class)
+    .goConcat(0).goGroupBy(0).goUp().goUp()
+    .goConcat(1).goGroupBy(0).goUp().goUp()
+    
.goConcat(1).at(1).goOrderBy().goValue("<false<PropertyString>,false<PropertyInt16>>").goUp().goUp()
+    .goConcat(1).at(2).goSkip().goValue(3).goUp().goUp()
+    .goConcat(1).at(3).goTop().goValue(10).goUp().goUp();
+    
+    parse("ESTwoKeyNav", 
"groupby((PropertyString,PropertyInt16),aggregate(PropertyInt16 with sum as 
s1))"
+               + "/orderby(PropertyString 
asc,PropertyInt16,NavPropertyETTwoKeyNavOne/PropertyString desc)"
+               + "/skip(3)"
+               + "/top(10)/concat(identity,aggregate(PropertyInt16 with max as 
s2))")
+    .at(0).goGroupBy(0).goUp()
+    .at(1).goOrderBy().goValue("<false<PropertyString>,false<PropertyInt16>"
+               + ",true<NavPropertyETTwoKeyNavOne/PropertyString>>").goUp()
+    .at(2).goSkip().goValue(3).goUp()
+    .at(3).goTop().goValue(10).goUp()
+    .at(4).is(Concat.class);
   }
 
   @Test
@@ -554,6 +585,21 @@ public class ApplyParserTest {
       is(BottomTop.class);
       return new BottomTopValidator((BottomTop) applyItem, this);
     }
+    
+    public OrderByValidator goOrderBy() {
+        is(OrderBy.class);
+        return new OrderByValidator((OrderBy) applyItem, this);
+      }
+    
+    public TopValidator goTop() {
+        is(Top.class);
+        return new TopValidator((Top) applyItem, this);
+      }
+    
+    public SkipValidator goSkip() {
+        is(Skip.class);
+        return new SkipValidator((Skip) applyItem, this);
+      }
 
     public ApplyValidator isCustomFunction(final FullQualifiedName function) {
       is(CustomFunction.class);
@@ -688,6 +734,74 @@ public class ApplyParserTest {
       return previous;
     }
   }
+  
+  private final class TopValidator implements TestValidator {
+
+           private final Top item;
+           private final ApplyValidator previous;
+
+           private TopValidator(final Top item, final ApplyValidator previous) 
{
+             this.item = item;
+             this.previous = previous;
+           }
+
+           public TopValidator goValue(int value) {
+             assertNotNull(item.getTopOption().getValue());
+             assertEquals(value, item.getTopOption().getValue());
+             return this;
+           }
+
+           public ApplyValidator goUp() {
+             return previous;
+           }
+         }
+  
+  private final class SkipValidator implements TestValidator {
+
+           private final Skip item;
+           private final ApplyValidator previous;
+
+           private SkipValidator(final Skip item, final ApplyValidator 
previous) {
+             this.item = item;
+             this.previous = previous;
+           }
+
+           public SkipValidator goValue(int value) {
+             assertNotNull(item.getSkipOption().getValue());
+             assertEquals(value, item.getSkipOption().getValue());
+             return this;
+           }
+
+           public ApplyValidator goUp() {
+             return previous;
+           }
+         }
+  
+  private final class OrderByValidator implements TestValidator {
+
+           private final OrderBy item;
+           private final ApplyValidator previous;
+
+           private OrderByValidator(final OrderBy item, final ApplyValidator 
previous) {
+             this.item = item;
+             this.previous = previous;
+           }
+
+           public OrderByValidator goValue(String expectedOrderBy) throws 
Exception {
+             List<OrderByItem> orderByItems = 
item.getOrderByOption().getOrders();
+             List<String> orderBy = new ArrayList<>();
+             for (OrderByItem orderByItem : orderByItems) {
+                 orderBy.add(String.valueOf(orderByItem.isDescending()) + 
+             FilterTreeToText.Serialize(orderByItem.getExpression()));
+             }
+             assertEquals(expectedOrderBy, "<" + String.join(",", orderBy) + 
">");
+             return this;
+           }
+
+           public ApplyValidator goUp() {
+             return previous;
+           }
+         }
 
   private final class ComputeValidator implements TestValidator {
 

Reply via email to