You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by ro...@apache.org on 2014/12/22 17:54:13 UTC

[07/50] incubator-usergrid git commit: adding collections resource

adding collections resource


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/a4be0857
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/a4be0857
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/a4be0857

Branch: refs/heads/two-dot-o
Commit: a4be08576a1a0ad3a2a146a2cdd1e841845ce9d4
Parents: 90b5167
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 15 16:24:07 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 15 16:24:07 2014 -0700

----------------------------------------------------------------------
 .../endpoints/ApplicationResource.java          |  19 +--
 .../resource2point0/endpoints/Collection.java   | 124 -------------------
 .../endpoints/CollectionResource.java           |  89 +++++++++++++
 .../endpoints/EntityResource.java               |  61 +++++++++
 .../endpoints/NamedResource.java                |  27 ++++
 .../rest/test/resource2point0/model/Entity.java |  20 ++-
 .../resource2point0/model/EntityResponse.java   |  12 +-
 .../resource2point0/model/QueryParameters.java  |  73 +++++++++++
 8 files changed, 275 insertions(+), 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a4be0857/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationResource.java
index edd2cd8..a724a48 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ApplicationResource.java
@@ -17,6 +17,7 @@
 package org.apache.usergrid.rest.test.resource2point0.endpoints;
 
 
+import org.apache.usergrid.rest.test.resource.app.Collection;
 import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource2point0.model.Application;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
@@ -70,13 +71,15 @@ public class ApplicationResource extends NamedResource {
     }
 
 
+    public CollectionResource collection(final String name){ return new CollectionResource(name,context,this);}
+
     /**
      * Currently hardcoded to users, this is because we expect to create and chain different cases of collections.
      * The pattern should look like: orgs.apps.users , orgs.apps.groups and so on...
      * @return
      */
-    public Collection users(){
-        return new Collection("users", context , this);
+    public CollectionResource users(){
+        return new CollectionResource("users", context , this);
     }
 
     /**
@@ -84,8 +87,8 @@ public class ApplicationResource extends NamedResource {
      * The pattern should look like: orgs.apps.users , orgs.apps.groups and so on...
      * @return
      */
-    public Collection roles(){
-        return new Collection("roles", context , this);
+    public CollectionResource roles(){
+        return new CollectionResource("roles", context , this);
     }
 
     /**
@@ -93,8 +96,8 @@ public class ApplicationResource extends NamedResource {
      * The pattern should look like: orgs.apps.users , orgs.apps.groups and so on...
      * @return
      */
-    public Collection permissions(){
-        return new Collection("permissions", context , this);
+    public CollectionResource permissions(){
+        return new CollectionResource("permissions", context , this);
     }
 
     /**
@@ -102,8 +105,8 @@ public class ApplicationResource extends NamedResource {
      * The pattern should look like: orgs.apps.users , orgs.apps.groups and so on...
      * @return
      */
-    public Collection notifications(){
-        return new Collection("notifications", context , this);
+    public CollectionResource notifications(){
+        return new CollectionResource("notifications", context , this);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a4be0857/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/Collection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/Collection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/Collection.java
deleted file mode 100644
index 3a0c020..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/Collection.java
+++ /dev/null
@@ -1,124 +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.usergrid.rest.test.resource2point0.endpoints;
-
-
-import java.util.UUID;
-
-import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
-import org.apache.usergrid.rest.test.resource2point0.model.Entity;
-import org.apache.usergrid.rest.test.resource2point0.model.EntityResponse;
-import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
-
-import com.google.common.base.Optional;
-
-
-/**
- * Holds POST,PUT,GET,DELETE methods for Collections. Models the rest endpoints for the different ways
- * to get an entity out of UG.
- */
-public  class Collection extends NamedResource {
-
-
-    public Collection( final String name, final ClientContext context,  final UrlResource parent ) {
-        super( name, context, parent );
-    }
-
-    /**
-     * Get a list of entities
-     * @return
-     */
-    public ApiResponse get(final Optional<String> cursor){
-       return get(cursor,true);
-    }
-    /**
-     * Get a list of entities
-     * @return
-     */
-    public ApiResponse get(final Optional<String> cursor, final boolean useToken){
-      return  getResource(useToken).get( ApiResponse.class );
-    }
-
-
-    /**
-     * Get the response as an entity response
-     * @return
-     */
-    public EntityResponse getEntityResponse(){
-        return EntityResponse.fromCollection( this );
-    }
-
-
-    /**
-     * Post the entity to the users collection
-     * @param user
-     * @return
-     */
-    public Entity post(final Entity user){
-        return null;
-    }
-
-
-    /**
-     * Get the entity by uuid
-     * @param uuid
-     * @return
-     */
-    public Entity get(final UUID uuid){
-        return get(uuid.toString());
-    }
-
-
-    /**
-     * Get the entity by name
-     * @param name
-     * @return
-     */
-    public Entity get(final String name){
-        return null;
-    }
-
-
-    /**
-     * Updte the entity
-     * @param toUpdate
-     * @return
-     */
-    public Entity put(final Entity toUpdate){
-        return null;
-    }
-
-
-    /**
-     * Delete the entity
-     * @param uuid
-     * @return
-     */
-    public Entity delete(final UUID uuid){
-        return delete(uuid.toString());
-    }
-
-
-    /**
-     * Delete the entity by name
-     * @param name
-     * @return
-     */
-    public Entity delete(final String name){
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a4be0857/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionResource.java
new file mode 100644
index 0000000..7b51a95
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionResource.java
@@ -0,0 +1,89 @@
+/*
+ * 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.usergrid.rest.test.resource2point0.endpoints;
+
+
+import java.util.UUID;
+
+import com.sun.jersey.api.client.WebResource;
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.rest.test.resource2point0.model.EntityResponse;
+import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
+import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+
+import com.google.common.base.Optional;
+
+import javax.ws.rs.core.MediaType;
+
+
+/**
+ * Holds POST,PUT,GET,DELETE methods for Collections. Models the rest endpoints for the different ways
+ * to get an entity out of UG.
+ */
+public  class CollectionResource extends NamedResource {
+
+
+    public CollectionResource(final String name, final ClientContext context, final UrlResource parent) {
+        super( name, context, parent );
+    }
+
+    public EntityResource getEntityResource(final String identifier){
+        return new EntityResource( identifier, context, this );
+    }
+
+    /**
+     * Get a list of entities
+     * @return
+     */
+    public ApiResponse get( final QueryParameters parameters){
+       return get(parameters,true);
+    }
+    /**
+     * Get a list of entities
+     * @return
+     */
+    public ApiResponse get(final QueryParameters parameters, final boolean useToken){
+        WebResource resource  = getResource(useToken);
+        addParametersToResource(getResource(), parameters);
+        return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
+                .get(ApiResponse.class);
+    }
+
+    /**
+     * Post the entity to the users collection
+     * @param entity
+     * @return
+     */
+    public ApiResponse post(final Entity entity){
+        return getResource(true).post(ApiResponse.class,entity);
+    }
+
+    /**
+     * Put the entity to the users collection
+     * @param entity
+     * @return
+     */
+    public ApiResponse put(final Entity entity){
+        return getResource(true).post(ApiResponse.class,entity);
+    }
+
+
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a4be0857/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/EntityResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/EntityResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/EntityResource.java
new file mode 100644
index 0000000..e5a4e34
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/EntityResource.java
@@ -0,0 +1,61 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  *  contributor license agreements.  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.  For additional information regarding
+ *  * copyright in this work, please see the NOTICE file in the top level
+ *  * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.rest.test.resource2point0.endpoints;
+
+import com.sun.jersey.api.client.WebResource;
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
+import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+
+import javax.ws.rs.core.MediaType;
+
+/**
+ * Classy class class.
+ */
+public class EntityResource extends NamedResource {
+    public EntityResource(String name, ClientContext context, UrlResource parent) {
+        super(name, context, parent);
+    }
+
+    public ApiResponse get(){
+        return get(new QueryParameters());
+    }
+
+    public ApiResponse get(final QueryParameters parameters){
+        WebResource resource  =getResource(true);
+        addParametersToResource(resource,parameters);
+        return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
+                .get(ApiResponse.class);
+    }
+
+    public ApiResponse post(final Entity entity){
+        WebResource resource  =getResource(true);
+        return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
+                .post(ApiResponse.class,entity);
+    }
+
+    public ApiResponse put(final Entity entity){
+        WebResource resource  =getResource(true);
+        return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
+                .put(ApiResponse.class,entity);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a4be0857/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
index 1f49832..4ff7014 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
@@ -17,10 +17,13 @@
 package org.apache.usergrid.rest.test.resource2point0.endpoints;
 
 
+import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 
 import com.sun.jersey.api.client.WebResource;
 
+import java.util.UUID;
+
 
 /**
  * Base class that is extended by named endpoints.
@@ -68,4 +71,28 @@ public class NamedResource implements UrlResource {
         this.useToken = useToken;
         return useToken;
     }
+
+    protected WebResource addParametersToResource(final WebResource resource, final QueryParameters parameters){
+        if(parameters == null){
+            return resource;
+        }
+        if ( parameters.getQuery() != null ) {
+            resource.queryParam( "ql", parameters.getQuery() );
+        }
+
+        if ( parameters.getCursor() != null ) {
+           resource.queryParam( "cursor", parameters.getCursor() );
+        }
+
+        if ( parameters.getStart() != null ) {
+            resource.queryParam("start", parameters.getStart().toString());
+        }
+
+        if ( parameters.getLimit() != null ) {
+             resource.queryParam("limit", parameters.getLimit().toString());
+        }
+        return resource;
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a4be0857/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index 9e923c3..23d7f38 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@ -27,22 +27,15 @@ import java.util.*;
 
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.usergrid.persistence.EntityFactory;
-import org.apache.usergrid.persistence.Schema;
 import org.apache.usergrid.persistence.annotations.EntityProperty;
-import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.Collection;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionResource;
 
 import com.fasterxml.jackson.annotation.JsonAnyGetter;
 import com.fasterxml.jackson.annotation.JsonAnySetter;
 import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 
 import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_TYPE;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_URI;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_UUID;
 
 
 /**
@@ -56,14 +49,15 @@ public class Entity implements Serializable, Map<String,Object> {
 
     protected Map<String, Object> dynamic_properties = new TreeMap<String, Object>( String.CASE_INSENSITIVE_ORDER );
 
-    private Collection targetResource;
+    private CollectionResource targetResource;
 
     /**
      * Performs deep copy on entity passed in and save over what we currently have
      */
     public void save(){
-        Entity response = targetResource.put(this);
-        this.dynamic_properties.putAll(response.getDynamicProperties());
+        List<Entity> response = targetResource.put(this).getEntities();
+        Entity entity = response.get(0);
+        this.dynamic_properties.putAll(entity.getDynamicProperties());
     }
 
 
@@ -248,8 +242,8 @@ public class Entity implements Serializable, Map<String,Object> {
         return "Entity(" + getProperties() + ")";
     }
 
-    public Collection getTargetResource(){return targetResource;}
-    public void setTargetResource(Collection targetResource){this.targetResource = targetResource;}
+    public CollectionResource getTargetResource(){return targetResource;}
+    public void setTargetResource(CollectionResource targetResource){this.targetResource = targetResource;}
 
     @JsonAnySetter
     public void setDynamicProperty( String key, Object value ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a4be0857/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/EntityResponse.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/EntityResponse.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/EntityResponse.java
index 91903ad..f701608 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/EntityResponse.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/EntityResponse.java
@@ -26,9 +26,11 @@ package org.apache.usergrid.rest.test.resource2point0.model;
 
         import java.util.Iterator;
 
-        import org.apache.usergrid.rest.test.resource2point0.endpoints.Collection;
+        import org.apache.usergrid.rest.test.resource.app.Collection;
+        import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionResource;
 
         import com.google.common.base.Optional;
+        import org.apache.usergrid.rest.test.resource2point0.endpoints.NamedResource;
 
 
 /**
@@ -52,7 +54,7 @@ package org.apache.usergrid.rest.test.resource2point0.model;
  */
 public class EntityResponse implements Iterable<Entity>, Iterator<Entity> {
 
-    private final Collection sourceEndpoint;
+    private final CollectionResource sourceEndpoint;
 
     private String cursor;
 
@@ -63,7 +65,7 @@ public class EntityResponse implements Iterable<Entity>, Iterator<Entity> {
      * Use the factory method instead
      * @param sourceCollection
      */
-    private EntityResponse( final Collection sourceCollection ){
+    private EntityResponse( final CollectionResource sourceCollection ){
         this.sourceEndpoint = sourceCollection;
         loadPage();
     }
@@ -108,7 +110,7 @@ public class EntityResponse implements Iterable<Entity>, Iterator<Entity> {
     }
 
     private void loadPage(){
-        final ApiResponse response = sourceEndpoint.get( Optional.of(cursor));
+        final ApiResponse response = sourceEndpoint.get( new QueryParameters().setCursor( cursor));
 
         cursor = response.getCursor();
     }
@@ -125,7 +127,7 @@ public class EntityResponse implements Iterable<Entity>, Iterator<Entity> {
      * @param collection
      * @return The iterator
      */
-    public static EntityResponse fromCollection(final Collection collection){
+    public static EntityResponse fromCollection(final CollectionResource collection){
         return new EntityResponse(collection);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a4be0857/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/QueryParameters.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/QueryParameters.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/QueryParameters.java
new file mode 100644
index 0000000..f2a8e12
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/QueryParameters.java
@@ -0,0 +1,73 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  *  contributor license agreements.  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.  For additional information regarding
+ *  * copyright in this work, please see the NOTICE file in the top level
+ *  * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.rest.test.resource2point0.model;
+
+import java.util.UUID;
+
+/**
+ * Classy class class.
+ */
+public class QueryParameters {
+    private String query;
+    private String cursor;
+    private UUID start;
+    private Integer limit;
+
+    public QueryParameters() {
+    }
+
+    public UUID getStart() {
+        return start;
+    }
+
+    public QueryParameters setStart(UUID start) {
+        this.start = start;
+        return this;
+    }
+
+    public String getCursor() {
+        return cursor;
+    }
+
+    public QueryParameters setCursor(String cursor) {
+        this.cursor = cursor;
+        return this;
+    }
+
+    public String getQuery() {
+        return query;
+    }
+
+    public QueryParameters setQuery(String query) {
+        this.query = query;
+        return this;
+    }
+
+    public Integer getLimit() {
+        return limit;
+    }
+
+    public QueryParameters setLimit(int limit) {
+        this.limit = new Integer(limit);
+        return this;
+    }
+
+}