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)
QueryaddProperty in interface QuerypropertyId - the property idtemporalInfo - temporal information for the propertypublic void addLocalProperty(String property)
QueryaddLocalProperty in interface Queryproperty - the property id which contains the group, property name
and whether the property is temporalpublic Result execute() throws UnsupportedPropertyException, SystemException, NoSuchResourceException, NoSuchParentResourceException
Queryexecute in interface QueryUnsupportedPropertyException - 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()
QuerygetPredicate in interface Querypublic Set<String> getProperties()
QuerygetProperties in interface Querypublic void setUserPredicate(Predicate predicate)
QuerysetUserPredicate in interface Querypredicate - the user provided predicatepublic void setPageRequest(PageRequest pageRequest)
QuerysetPageRequest in interface QuerypageRequest - the page request informationpublic void setSortRequest(SortRequest sortRequest)
QuerysetSortRequest in interface QuerysortRequest - the ordering infopublic void setRenderer(Renderer renderer)
QuerysetRenderer in interface Queryrenderer - renderer for the querypublic void setRequestInfoProps(Map<String,String> requestInfoProperties)
QuerysetRequestInfoProps in interface QueryrequestInfoProperties - a map a request info propertiespublic Map<String,String> getRequestInfoProps()
QuerygetRequestInfoProps in interface Querypublic void setKeyValueMap(Map<Resource.Type,String> keyValueMap)
ResourceInstancesetKeyValueMap in interface ResourceInstancekeyValueMap - map of all parent foreign keys. Map from resource type to id value.public Map<Resource.Type,String> getKeyValueMap()
ResourceInstancegetKeyValueMap in interface ResourceInstancepublic Query getQuery()
ResourceInstancegetQuery in interface ResourceInstancepublic ResourceDefinition getResourceDefinition()
ResourceInstancegetResourceDefinition in interface ResourceInstancepublic boolean isCollectionResource()
ResourceInstanceisCollectionResource in interface ResourceInstancepublic Map<String,ResourceInstance> getSubResources()
ResourceInstancegetSubResources in interface ResourceInstanceprotected 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 nullSystemExceptionUnsupportedPropertyExceptionNoSuchParentResourceExceptionNoSuchResourceExceptionCopyright © 2022 Apache Software Foundation. All rights reserved.