public class QueryImpl extends Object implements Query, ResourceInstance
Constructor and Description |
---|
QueryImpl(Map<Resource.Type,String> keyValueMap,
ResourceDefinition resourceDefinition,
ClusterController clusterController)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addLocalProperty(String property)
Add a local (not sub-resource) property to the query.
|
void |
addProperty(String propertyId,
TemporalInfo temporalInfo)
Add a property to the query.
|
protected Map<String,QueryImpl> |
ensureSubResources()
Get the map of sub-resources.
|
boolean |
equals(Object o) |
Result |
execute()
Execute the query.
|
protected Map<Resource,Set<Map<String,Object>>> |
getJoinedResourceProperties(Set<String> propertyIds,
Resource parentResource,
String category)
Get a map of property sets keyed by the resources associated with this
query.
|
Map<Resource.Type,String> |
getKeyValueMap()
Obtain the primary and foreign key properties for the resource.
|
Predicate |
getPredicate()
Return the predicate used to identify the associated resource.
|
Set<String> |
getProperties()
Obtain the properties of the query.
|
Query |
getQuery()
Return the query associated with the resource.
|
Map<String,String> |
getRequestInfoProps()
Get this Query's requestInfoProperties from the original request.
|
ResourceDefinition |
getResourceDefinition()
Return the resource definition for this resource type.
|
Map<String,ResourceInstance> |
getSubResources()
Return all sub-resource instances.
|
int |
hashCode() |
boolean |
isCollectionResource()
Determine if resource is a collection resource.
|
void |
setKeyValueMap(Map<Resource.Type,String> keyValueMap)
Set the values of the parent foreign keys.
|
void |
setPageRequest(PageRequest pageRequest)
Set the page request information for this query.
|
void |
setRenderer(Renderer renderer)
Set the corresponding renderer.
|
void |
setRequestInfoProps(Map<String,String> requestInfoProperties)
Set this Query's requestInfoProperties from the original request.
|
void |
setSortRequest(SortRequest sortRequest)
Set the order request information on the query
|
void |
setUserPredicate(Predicate predicate)
Set the user provided predicated on this query.
|
public QueryImpl(Map<Resource.Type,String> keyValueMap, ResourceDefinition resourceDefinition, ClusterController clusterController)
keyValueMap
- the map of key valuesresourceDefinition
- the resource definitionclusterController
- the cluster controllerpublic void addProperty(String propertyId, TemporalInfo temporalInfo)
Query
addProperty
in interface Query
propertyId
- the property idtemporalInfo
- temporal information for the propertypublic void addLocalProperty(String property)
Query
addLocalProperty
in interface Query
property
- the property id which contains the group, property name
and whether the property is temporalpublic Result execute() throws UnsupportedPropertyException, SystemException, NoSuchResourceException, NoSuchParentResourceException
Query
execute
in interface Query
UnsupportedPropertyException
- if the query or query predicate contains invalid non-existent propertiesSystemException
- an internal error occurredNoSuchResourceException
- the query didn't match any resourcesNoSuchParentResourceException
- a specified parent resource doesn't existpublic Predicate getPredicate()
Query
getPredicate
in interface Query
public Set<String> getProperties()
Query
getProperties
in interface Query
public void setUserPredicate(Predicate predicate)
Query
setUserPredicate
in interface Query
predicate
- the user provided predicatepublic void setPageRequest(PageRequest pageRequest)
Query
setPageRequest
in interface Query
pageRequest
- the page request informationpublic void setSortRequest(SortRequest sortRequest)
Query
setSortRequest
in interface Query
sortRequest
- the ordering infopublic void setRenderer(Renderer renderer)
Query
setRenderer
in interface Query
renderer
- renderer for the querypublic void setRequestInfoProps(Map<String,String> requestInfoProperties)
Query
setRequestInfoProps
in interface Query
requestInfoProperties
- a map a request info propertiespublic Map<String,String> getRequestInfoProps()
Query
getRequestInfoProps
in interface Query
public void setKeyValueMap(Map<Resource.Type,String> keyValueMap)
ResourceInstance
setKeyValueMap
in interface ResourceInstance
keyValueMap
- map of all parent foreign keys. Map from resource type to id value.public Map<Resource.Type,String> getKeyValueMap()
ResourceInstance
getKeyValueMap
in interface ResourceInstance
public Query getQuery()
ResourceInstance
getQuery
in interface ResourceInstance
public ResourceDefinition getResourceDefinition()
ResourceInstance
getResourceDefinition
in interface ResourceInstance
public boolean isCollectionResource()
ResourceInstance
isCollectionResource
in interface ResourceInstance
public Map<String,ResourceInstance> getSubResources()
ResourceInstance
getSubResources
in interface ResourceInstance
protected Map<String,QueryImpl> ensureSubResources()
protected Map<Resource,Set<Map<String,Object>>> getJoinedResourceProperties(Set<String> propertyIds, Resource parentResource, String category) throws SystemException, UnsupportedPropertyException, NoSuchParentResourceException, NoSuchResourceException
a_resources │ └──AResource1 ─────────────AResource1 ─────────────AResource3 │ │ │ ├── b_resources ├── b_resources ├── BResources │ ├── BResource1 │ ├── BResource3 │ └── BResource5 │ │ p1:1 │ │ p1:3 │ p1:5 │ │ p2:5 │ │ p2:5 │ p2:5 │ │ │ │ │ │ └── BResource2 │ └── BResource4 └── c_resources │ p1:2 │ p1:4 └── CResource4 │ p2:0 │ p2:0 p3:4 │ │ └── c_resources └── c_resources ├── CResource1 └── CResource3 │ p3:1 p3:3 │ └── CResource2 p3:2 Given the following query ... api/v1/a_resources?b_resources/p1>3&b_resources/p2=5&c_resources/p3=1 The caller should pass the following property ids ... b_resources/p1 b_resources/p2 c_resources/p3 getJoinedResourceProperties should produce the following map of property sets by making recursive calls on the sub-resources of each of this query's resources, joining the resulting property sets, and adding them to the map keyed by the resource ... { AResource1=[{b_resources/p1=1, b_resources/p2=5, c_resources/p3=1}, {b_resources/p1=2, b_resources/p2=0, c_resources/p3=1}, {b_resources/p1=1, b_resources/p2=5, c_resources/p3=2}, {b_resources/p1=2, b_resources/p2=0, c_resources/p3=2}], AResource2=[{b_resources/p1=3, b_resources/p2=5, c_resources/p3=3}, {b_resources/p1=4, b_resources/p2=0, c_resources/p3=3}], AResource3=[{b_resources/p1=5, b_resources/p2=5, c_resources/p3=4}], }
propertyIds
- the requested propertiesparentResource
- the parent resource; may be nullcategory
- the sub-resource category; may be nullSystemException
UnsupportedPropertyException
NoSuchParentResourceException
NoSuchResourceException
Copyright © 2022 Apache Software Foundation. All rights reserved.