Data Query
Encapsulates an OData query request. A query can be defined by setting query properties, or by calling query functions which provide a fluent interface. Execution of a query may result in some query properties being changed (e.g. the addition of {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#expandItems DataQuery.expandItems} or {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#selectItems DataQuery.selectItems} that are required for correct execution). Thus for thread safety, a query should be used only by a single thread at a time. Preferably a new query should be created before each query execution.
- See Also:
-
DataService.executeQuery.
- Example using proxy classes:
open fun dataQueryExample(): kotlin.Unit { val service = this.service; val query = DataQuery() .select(Customer.customerID, Customer.companyName, Customer.contactName) .filter(Customer.address.toLower().contains("king")) .orderBy(Customer.companyName); val customers = service.getCustomers(query); this.showCustomers(customers); }
- Example using dynamic API:
open fun dataQueryExample(): kotlin.Unit { val service = this.service; val customersEntitySet = service.getEntitySet("Customers"); val customerEntityType = customersEntitySet.entityType; val customerIDProperty = customerEntityType.getProperty("CustomerID"); val companyNameProperty = customerEntityType.getProperty("CompanyName"); val contactNameProperty = customerEntityType.getProperty("ContactName"); val addressProperty = customerEntityType.getProperty("Address"); val query = DataQuery() .select(customerIDProperty, companyNameProperty, contactNameProperty) .from(customersEntitySet).filter(addressProperty.toLower().contains("king")) .orderBy(companyNameProperty); val customers = service.executeQuery(query).getEntityList(); this.showCustomers(customers); }
Inheritors
Properties
Functions
Adds aggregate items (to {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#transformValues DataQuery.transformValues}) for transforming the result of a query sent to an entity set. This method is only for adding aggregate transformation items (in contrast to 'transform' method) for readability purposes.
Bind a resource as the binding parameter of a bound action/function.
If resource is a {@link com.sap.cloud.mobile.kotlin.odata.DataPath}, then sets {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#resourcePath DataQuery.resourcePath}.{@link com.sap.cloud.mobile.kotlin.odata.ResourcePath#dataPath ResourcePath.dataPath}.
If resource is an {@link com.sap.cloud.mobile.kotlin.odata.EntitySet}, then calls {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#from(com.sap.cloud.mobile.kotlin.odata.EntitySet) DataQuery.from} to set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#resourcePath DataQuery.resourcePath}.{@link com.sap.cloud.mobile.kotlin.odata.ResourcePath#entitySet ResourcePath.entitySet}.
If resource is an {@link com.sap.cloud.mobile.kotlin.odata.EntityValue}, then calls {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#load(com.sap.cloud.mobile.kotlin.odata.EntityValue, com.sap.cloud.mobile.kotlin.odata.PropertyPath?) DataQuery.load} to set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#resourcePath DataQuery.resourcePath}.{@link com.sap.cloud.mobile.kotlin.odata.ResourcePath#entitySet ResourcePath.entitySet} and {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#resourcePath DataQuery.resourcePath}.{@link com.sap.cloud.mobile.kotlin.odata.ResourcePath#entityKey ResourcePath.entityKey}.
Check if this query is properly configured from the client's perspective. Note: This does not guarantee that the server will be able to execute it.
- Throws:
-
{@link com.sap.cloud.mobile.kotlin.odata.DataQueryException} if the query is definitely not valid.
Return a copy of this data query which doesn't share mutable values with this query. The resulting query will not share mutable values with this query. The resulting query might share immutable values with this query. The resulting query might share mutable metadata with this query (but metadata is expected to be finalized before query construction).
Set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#countOnly DataQuery.countOnly} to true to request only the number of matching query results.
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.DataQuery#inlineCount() DataQuery.inlineCount}, Requesting the Number of Items in a Collection.
Alter this query to include all current entities (non-pending, or with pending create/update requests) as well as deleted entities (pending deletion). This is relevant in offline scenarios.
Alter this query to defer its execution. This is particular useful when using actions/functions with proxy classes. It allows the use of deferred proxy method calls together with request batches.
Add properties (to {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#expandItems DataQuery.expandItems}) for expanding from the target entity.
Return the names of all properties expanded by this query.
Return true if this query expands property from the target entity.
Add a property with a nested query to {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#expandItems DataQuery.expandItems}.
See the expandWithQueryExample2 below for an abbreviated syntax that implicitly creates the nested query.
Modify {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#queryFilter DataQuery.queryFilter} to be and'ed with test (or set to test if {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#queryFilter DataQuery.queryFilter} was null).
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.QueryFilter}, {@link com.sap.cloud.mobile.kotlin.odata.QueryFunction}, {@link com.sap.cloud.mobile.kotlin.odata.QueryOperator}, {@link com.sap.cloud.mobile.kotlin.odata.QueryValue}.
Return the names of all properties filtered by this query.
Return true if this query filters property from the target entity.
Set the {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#entitySet DataQuery.entitySet} property to identify this query's target entity set, but only if the {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#entitySet DataQuery.entitySet} property wasn't previously set. This function is intended for use by generated proxy classes.
For internal use only.
Adds a group transformation item to the DataQuery with the property paths given in the parameter list. Note: If this method is called then all the transformation and aggregation items added to the query will be applied to the group transformation in the query.
Alter this query to apply to all entities with pending changes.
Alter this query to apply to all entities with original state.
Set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#countInline DataQuery.countInline} to true to request an inline count in the server's response.
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.DataQuery#count() DataQuery.count}, System Query Option $count.
Set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#methodCall DataQuery.methodCall} to associate this query with an action/function invocation.
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.DataQuery#bind(com.sap.cloud.mobile.kotlin.odata.BindingPath) DataQuery.bind}, for setting the binding parameter for a bound action/function.
Set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#entitySet DataQuery.entitySet} and {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#entityKey DataQuery.entityKey} to configure this query to load an existing entity.
Equivalent to calling from(entity.entitySet).withKey(entity.entityKey).
Add to {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#sortItems DataQuery.sortItems} a value for result ordering.
Set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#pageSize DataQuery.pageSize} to specify the page-size for server-driven paging of results. Note: the server is not required to respect this setting. But if this setting is used, the client should expect to have to follow next-links.
Set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#resourcePath DataQuery.resourcePath} to identify this query's target resource.
Set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#searchExpression DataQuery.searchExpression} for free-text searching.
Add properties (to {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#selectItems DataQuery.selectItems}) for selecting from the target entity.
Add properties (to {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#selectItems DataQuery.selectItems}) for selecting from the target entity and set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#distinctItems DataQuery.distinctItems} to true.
Note that this isn't a standard OData query option, so servers might ignore it.
Return the names of all properties selected by this query. If {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#allSelected DataQuery.allSelected} or {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#keySelected DataQuery.keySelected} is set, then calling this function might result in additional items being added to {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#selectItems DataQuery.selectItems} so that the resulting set of properties is consistent with the other configured query options.
Return true if this query selects property from the target entity.
For internal use only.
Return the names of all properties used for sorting by this query.
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.DataQuery#orderBy(com.sap.cloud.mobile.kotlin.odata.QueryValue, com.sap.cloud.mobile.kotlin.odata.SortOrder) DataQuery.orderBy}, {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#thenBy(com.sap.cloud.mobile.kotlin.odata.QueryValue, com.sap.cloud.mobile.kotlin.odata.SortOrder) DataQuery.thenBy}.
Set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#sparseArray DataQuery.sparseArray} to true, so that query result entities will use sparse array storage of properties, to conserve memory.
This is only applicable to queries whose result entities will not be updated.
Add to {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#sortItems DataQuery.sortItems} a value for result ordering.
This function is an alias for {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#orderBy(com.sap.cloud.mobile.kotlin.odata.QueryValue, com.sap.cloud.mobile.kotlin.odata.SortOrder) DataQuery.orderBy}.
By convention to improve readability when multiple ordering values are required, the first ordering value is added using orderBy, and subsequent ordering values are added using thenBy.
Adds transform items (to {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#transformValues DataQuery.transformValues}) for transforming the result of a query sent to an entity set.
This function is an alias for {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#filter(com.sap.cloud.mobile.kotlin.odata.QueryFilter) DataQuery.filter}.
Set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#url DataQuery.url} from deltaLink and set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#trackChanges DataQuery.trackChanges} to true.
Also set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#deltaResponse DataQuery.deltaResponse} to true if deltaLink is non-null, otherwise false.
Set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#derivedType DataQuery.derivedType} to limit results to a derived complex/entity type.
Set {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#url DataQuery.url}. Note: It is not recommended for clients to explicitly set the URL, except by using a URL from {@link com.sap.cloud.mobile.kotlin.odata.EntityValueList#deltaLink EntityValueList.deltaLink} or {@link com.sap.cloud.mobile.kotlin.odata.EntityValueList#nextLink EntityValueList.nextLink}.