org.plasma.query.collector
Class SelectionCollector

java.lang.Object
  extended by org.plasma.query.collector.SelectionCollector
All Implemented Interfaces:
Selection

public class SelectionCollector
extends Object
implements Selection

Traverses a given Select) clause collecting the specified property names, as well as any path-reference or key properties required for graph structure, into a simple list of logical property name strings mapped to the respective {@link Type} definition.

See Also:
Select, Type

Field Summary
protected  boolean onlyDeclaredProperties
          Whether to collect only declared properties for a type, otherwise indicates to collect all properties for a given type and all its base types
protected  boolean onlySingularProperties
          Whether to collect only singular reference properties and follow paths composed of only singular properties.
protected  Type rootType
           
 
Constructor Summary
SelectionCollector(Select select, Type rootType)
           
SelectionCollector(Select select, Type rootType, boolean onlySingularProperties)
           
SelectionCollector(Select select, Where where, OrderBy orderBy, Type rootType)
           
SelectionCollector(Select select, Where where, OrderBy orderBy, Type rootType, boolean onlySingularProperties)
           
SelectionCollector(Select select, Where where, Type rootType)
           
SelectionCollector(Select select, Where where, Type rootType, boolean onlySingularProperties)
           
SelectionCollector(Where where, Type rootType)
           
SelectionCollector(Where where, Type rootType, boolean onlySingularProperties)
           
 
Method Summary
protected  void addInheritedProperty(Type type, Integer level, Property property, Map<Type,Map<Integer,Set<Property>>> map)
           
protected  void addInheritedProperty(Type type, Property property, Map<Type,Set<Property>> map)
           
protected  void addInheritedProperty(Type type, Property edge, Property property, Map<Type,Map<Property,Set<Property>>> map)
           
protected  void addPredicate(Property property, Integer level, Where predicate, Map<Property,Map<Integer,Where>> map)
           
protected  void addPredicate(Property property, Property edge, Where predicate, Map<Property,Map<Property,Where>> map)
           
protected  void addProperty(Type type, Integer level, Property property, Map<Type,Map<Integer,Set<Property>>> map)
           
protected  void addProperty(Type type, Property property, Map<Type,Set<Property>> map)
           
protected  void addProperty(Type type, Property edge, Property property, Map<Type,Map<Property,Set<Property>>> map)
           
 List<Type> addProperty(Type rootType, String path)
          Adds the given given property to the selection for the given graph root type and returns any types collected during traversal of the property path.
 String dumpInheritedProperties()
           
 String dumpProperties()
           
protected  Property[] findProperties(Type type, AbstractProperty abstractProperty)
          A convenience method returning an array of names for the given property whether a wildcard property or not.
protected  String[] findPropertyNames(Type type, AbstractProperty abstractProperty)
          A convenience method returning an array of names for the given property whether a wildcard property or not.
 List<Function> getFunctions(Property property)
          Returns the functions for the given property or empty list if the given property has no functions.
 List<Function> getFunctions(Property property, int level)
          Returns the functions for the given property for the given traversal level or graph depth, or empty list if the given property has no functions.
 Set<Property> getInheritedProperties(Type type)
          Returns the unique set of inherited data and reference properties collected for the given type, and any base types of the given type, irrespective of the (query) graph level.
 Set<Property> getInheritedProperties(Type type, int level)
          Returns the unique set of inherited data and reference properties collected for the given type, and any base types of the given type, for the given (query) graph level.
 Set<Property> getInheritedProperties(Type type, Property sourceProperty)
          Returns the unique set of inherited data and reference properties collected for the given Type for the given (query) graph edge source property.
 Set<Property> getInheritedProperties(Type type, Property sourceProperty, int level)
          Returns the unique set of inherited data and reference properties collected for the given Type for the given (query) graph edge source property at the given traversal level or graph depth.
 List<Type> getInheritedTypes()
          Returns all selected types and as well as types which specialize or inherit from the selected types.
 Where getPredicate(Property property)
          Returns the predicate for the given property or null if the given property has no predicates.
 Where getPredicate(Property property, int level)
          Returns the predicate , if exists, collected for the given property for the given traversal level or graph depth.
 Where getPredicate(Property property, Property sourceProperty)
          Returns the predicate, if exists, collected for the given property and for the given (query) graph edge source property.
 Map<Property,Where> getPredicateMap()
          Deprecated. 
 Set<Property> getProperties(Type type)
          Returns the unique set of data and reference properties collected for the given type irrespective of the (query) graph level, or source graph edge type.
 Set<Property> getProperties(Type type, int level)
          Returns the unique set of data and reference properties collected for the given Type for the given (query) graph level.
 Set<Property> getProperties(Type type, Property sourceProperty)
          Returns the unique set of data and reference properties collected for the given Type for the given (query) graph edge source property.
 Set<Property> getProperties(Type type, Property sourceProperty, int level)
          Returns the unique set of data and reference properties collected for the given Type for the given (query) graph edge source property at the given traversal level or graph depth.
 Set<Property> getSingularProperties(Type type)
          Returns the unique set of singular data and reference properties collected for the given type irrespective of the (query) graph level, or source graph edge type.
 List<Type> getTypes()
          Returns all selected types.
 boolean hasInheritedProperty(Type type, Property property)
          Returns true if the given type is found in the inherited type selection and if the given property is found in the property selection for the given type.
 boolean hasInheritedType(Type type)
          Returns true if the given type is found in the inherited type selection.
 boolean hasPredicates()
          (non-Javadoc)
 boolean hasProperty(Type type, Property property)
          Returns true if the given type is found in the type selection and if the given property is found in the property selection for the given type.
 boolean hasType(Type type)
          Returns true if the given type is found in the type selection.
 boolean isOnlyDeclaredProperties()
          Returns whether to collect only declared properties for a type.
 boolean isOnlySingularProperties()
          Returns whether to collect only singular properties and follow paths composed of only singular properties.
protected  boolean isSingularPath(Path path, Type currType, AbstractPathElement currPathElement, int curPathElementIndex, AbstractProperty abstractProperty)
          Recursively traverses the given path checking every path element and determines if the entire path is composed of singular properties.
protected  boolean isSingularPath(Path path, Type rootType, AbstractProperty abstractProperty)
          Recursively traverses the given path checking every path element and determines if the entire path is composed of singular properties.
protected  void mapFunctions(Property prop, Integer level, List<Function> functions, Map<Property,Map<Integer,List<Function>>> map)
           
protected  void mapFunctions(Property prop, List<Function> functions, Map<Property,List<Function>> map)
           
protected  void mapInheritedProperties(Type type, Integer level, Property[] props, Map<Type,Map<Integer,Set<Property>>> map)
           
protected  void mapInheritedProperties(Type type, Property[] props, Map<Type,Set<Property>> map)
           
protected  void mapInheritedProperties(Type type, Property edge, Property[] props, Map<Type,Map<Property,Set<Property>>> map)
           
protected  void mapInheritedProperty(Type type, Property property, Map<Type,List<String>> map)
           
protected  void mapInheritedPropertyNames(Type type, String[] names, Map<Type,List<String>> map)
           
protected  void mapProperties(Type type, Integer level, Property[] props, Map<Type,Map<Integer,Set<Property>>> map)
           
protected  void mapProperties(Type type, Property[] props, Map<Type,Set<Property>> map)
           
protected  void mapProperties(Type type, Property edge, Property[] props, Map<Type,Map<Property,Set<Property>>> map)
           
protected  void mapProperty(Type type, Property property, Map<Type,List<String>> map)
           
protected  void mapPropertyNames(Type type, String[] names, Map<Type,List<String>> map)
           
 void setOnlyDeclaredProperties(boolean onlyDeclaredProperties)
          Sets whether to collect only declared properties for a type.
 void setOnlySingularProperties(boolean onlySingularProperties)
          Sets whether to collect only singular properties and follow paths composed of only singular properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootType

protected Type rootType

onlySingularProperties

protected boolean onlySingularProperties
Whether to collect only singular reference properties and follow paths composed of only singular properties.


onlyDeclaredProperties

protected boolean onlyDeclaredProperties
Whether to collect only declared properties for a type, otherwise indicates to collect all properties for a given type and all its base types

Constructor Detail

SelectionCollector

public SelectionCollector(Select select,
                          Type rootType)

SelectionCollector

public SelectionCollector(Select select,
                          Type rootType,
                          boolean onlySingularProperties)

SelectionCollector

public SelectionCollector(Select select,
                          Where where,
                          Type rootType)

SelectionCollector

public SelectionCollector(Select select,
                          Where where,
                          Type rootType,
                          boolean onlySingularProperties)

SelectionCollector

public SelectionCollector(Select select,
                          Where where,
                          OrderBy orderBy,
                          Type rootType)

SelectionCollector

public SelectionCollector(Select select,
                          Where where,
                          OrderBy orderBy,
                          Type rootType,
                          boolean onlySingularProperties)

SelectionCollector

public SelectionCollector(Where where,
                          Type rootType)

SelectionCollector

public SelectionCollector(Where where,
                          Type rootType,
                          boolean onlySingularProperties)
Method Detail

getPredicateMap

@Deprecated
public Map<Property,Where> getPredicateMap()
Deprecated. 


hasPredicates

public boolean hasPredicates()
(non-Javadoc)

Specified by:
hasPredicates in interface Selection
Returns:
true if the selection has path predicates.

getPredicate

public Where getPredicate(Property property)
Description copied from interface: Selection
Returns the predicate for the given property or null if the given property has no predicates.

Specified by:
getPredicate in interface Selection
Parameters:
property - the property
Returns:
the predicate for the given property or null if the given property has no predicates.

getSingularProperties

public Set<Property> getSingularProperties(Type type)
Description copied from interface: Selection
Returns the unique set of singular data and reference properties collected for the given type irrespective of the (query) graph level, or source graph edge type.

Specified by:
getSingularProperties in interface Selection
Parameters:
type - the type
Returns:
the unique set of singular data and reference properties collected for the given type irrespective of the (query) graph level, or source graph edge type.

getProperties

public Set<Property> getProperties(Type type)
Description copied from interface: Selection
Returns the unique set of data and reference properties collected for the given type irrespective of the (query) graph level, or source graph edge type.

Specified by:
getProperties in interface Selection
Parameters:
type - the type
Returns:
the unique set of data and reference properties collected for the given type irrespective of the (query) graph level, or source graph edge type.

getInheritedProperties

public Set<Property> getInheritedProperties(Type type)
Description copied from interface: Selection
Returns the unique set of inherited data and reference properties collected for the given type, and any base types of the given type, irrespective of the (query) graph level. of the given type

Specified by:
getInheritedProperties in interface Selection
Parameters:
type - the type
Returns:
the unique set of inherited data and reference properties collected for the given type, and any base types of the given type, irrespective of the (query) graph level

getInheritedProperties

public Set<Property> getInheritedProperties(Type type,
                                            Property sourceProperty)
Description copied from interface: Selection
Returns the unique set of inherited data and reference properties collected for the given Type for the given (query) graph edge source property.

Specified by:
getInheritedProperties in interface Selection
Parameters:
type - the type (query) graph edge source property
sourceProperty - the
Returns:
the unique set of inherited data and reference properties collected for the given Type for the given (query) graph edge source property.

getInheritedProperties

public Set<Property> getInheritedProperties(Type type,
                                            int level)
Description copied from interface: Selection
Returns the unique set of inherited data and reference properties collected for the given type, and any base types of the given type, for the given (query) graph level.

Specified by:
getInheritedProperties in interface Selection
Parameters:
type - the type
level - the specific graph level where the properties were specified in the selection
Returns:
the unique set of inherited data and reference properties collected for the given type, and any base types of the given type, irrespective of the (query) graph level

getInheritedProperties

public Set<Property> getInheritedProperties(Type type,
                                            Property sourceProperty,
                                            int level)
Description copied from interface: Selection
Returns the unique set of inherited data and reference properties collected for the given Type for the given (query) graph edge source property at the given traversal level or graph depth.

Specified by:
getInheritedProperties in interface Selection
Parameters:
type - the type (query) graph edge source property
sourceProperty - the
level - the traversal level or graph depth
Returns:
the unique set of inherited data and reference properties collected for the given Type for the given (query) graph edge source property.

getTypes

public List<Type> getTypes()
Description copied from interface: Selection
Returns all selected types.

Specified by:
getTypes in interface Selection
Returns:
all selected types.

hasType

public boolean hasType(Type type)
Description copied from interface: Selection
Returns true if the given type is found in the type selection.

Specified by:
hasType in interface Selection
Parameters:
type - the type
Returns:
true if the given type is found in the type selection.

getInheritedTypes

public List<Type> getInheritedTypes()
Description copied from interface: Selection
Returns all selected types and as well as types which specialize or inherit from the selected types.

Specified by:
getInheritedTypes in interface Selection
Returns:
all selected types and as well as types which specialize or inherit from the selected types.

hasInheritedType

public boolean hasInheritedType(Type type)
Description copied from interface: Selection
Returns true if the given type is found in the inherited type selection.

Specified by:
hasInheritedType in interface Selection
Parameters:
type - the type
Returns:
true if the given type is found in the inherited type selection.

hasProperty

public boolean hasProperty(Type type,
                           Property property)
Description copied from interface: Selection
Returns true if the given type is found in the type selection and if the given property is found in the property selection for the given type.

Specified by:
hasProperty in interface Selection
Parameters:
type - the type
property - the property
Returns:
true if the given type is found in the type selection and if the given property is found in the property selection for the given type.

addProperty

public List<Type> addProperty(Type rootType,
                              String path)
Description copied from interface: Selection
Adds the given given property to the selection for the given graph root type and returns any types collected during traversal of the property path.

Specified by:
addProperty in interface Selection
Parameters:
rootType - the graph root type
path - the SDO XPath specifying a path from the given root type to a target or endpoint property
Returns:
any types collected during traversal of the property path.

hasInheritedProperty

public boolean hasInheritedProperty(Type type,
                                    Property property)
Description copied from interface: Selection
Returns true if the given type is found in the inherited type selection and if the given property is found in the property selection for the given type.

Specified by:
hasInheritedProperty in interface Selection
Parameters:
type - the type
property - the property
Returns:
true if the given type is found in the inherited type selection and if the given property is found in the property selection for the given type.

getProperties

public Set<Property> getProperties(Type type,
                                   int level)
Description copied from interface: Selection
Returns the unique set of data and reference properties collected for the given Type for the given (query) graph level.

Specified by:
getProperties in interface Selection
Parameters:
type - the type
level - the specific graph level where the properties were specified in the selection
Returns:
the unique set of data and reference properties collected for the given type for the given (query) graph level.

getProperties

public Set<Property> getProperties(Type type,
                                   Property sourceProperty)
Description copied from interface: Selection
Returns the unique set of data and reference properties collected for the given Type for the given (query) graph edge source property.

Specified by:
getProperties in interface Selection
Parameters:
type - the type (query) graph edge source property
sourceProperty - the (query) graph edge source property
Returns:
the unique set of data and reference properties collected for the given Type for the given (query) graph edge source property.

getProperties

public Set<Property> getProperties(Type type,
                                   Property sourceProperty,
                                   int level)
Description copied from interface: Selection
Returns the unique set of data and reference properties collected for the given Type for the given (query) graph edge source property at the given traversal level or graph depth.

Specified by:
getProperties in interface Selection
Parameters:
type - the type (query) graph edge source property
sourceProperty - the (query) graph edge source property
level - the traversal level or graph depth
Returns:
the unique set of data and reference properties collected for the given Type for the given (query) graph edge source property.

getPredicate

public Where getPredicate(Property property,
                          Property sourceProperty)
Description copied from interface: Selection
Returns the predicate, if exists, collected for the given property and for the given (query) graph edge source property.

Specified by:
getPredicate in interface Selection
Parameters:
property - the source property
sourceProperty - the (query) graph edge source property
Returns:
the predicate, if exists

getPredicate

public Where getPredicate(Property property,
                          int level)
Description copied from interface: Selection
Returns the predicate , if exists, collected for the given property for the given traversal level or graph depth.

Specified by:
getPredicate in interface Selection
level - the traversal level or graph depth
Returns:
the predicate, if exists

getFunctions

public List<Function> getFunctions(Property property)
Description copied from interface: Selection
Returns the functions for the given property or empty list if the given property has no functions.

Specified by:
getFunctions in interface Selection
Parameters:
property - the property
Returns:
the predicate for the given property or empty list if the given property has no functions.

getFunctions

public List<Function> getFunctions(Property property,
                                   int level)
Description copied from interface: Selection
Returns the functions for the given property for the given traversal level or graph depth, or empty list if the given property has no functions.

Specified by:
getFunctions in interface Selection
Parameters:
property - the property
level - the traversal level or graph depth
Returns:
the predicate for the given property for the given traversal level or graph depth, or empty list if the given property has no functions.

dumpProperties

public String dumpProperties()

dumpInheritedProperties

public String dumpInheritedProperties()

isOnlySingularProperties

public boolean isOnlySingularProperties()
Returns whether to collect only singular properties and follow paths composed of only singular properties.


setOnlySingularProperties

public void setOnlySingularProperties(boolean onlySingularProperties)
Sets whether to collect only singular properties and follow paths composed of only singular properties.


isOnlyDeclaredProperties

public boolean isOnlyDeclaredProperties()
Returns whether to collect only declared properties for a type.


setOnlyDeclaredProperties

public void setOnlyDeclaredProperties(boolean onlyDeclaredProperties)
Sets whether to collect only declared properties for a type.


mapProperty

protected void mapProperty(Type type,
                           Property property,
                           Map<Type,List<String>> map)

addProperty

protected void addProperty(Type type,
                           Property property,
                           Map<Type,Set<Property>> map)

addProperty

protected void addProperty(Type type,
                           Integer level,
                           Property property,
                           Map<Type,Map<Integer,Set<Property>>> map)

addPredicate

protected void addPredicate(Property property,
                            Integer level,
                            Where predicate,
                            Map<Property,Map<Integer,Where>> map)

addProperty

protected void addProperty(Type type,
                           Property edge,
                           Property property,
                           Map<Type,Map<Property,Set<Property>>> map)

addPredicate

protected void addPredicate(Property property,
                            Property edge,
                            Where predicate,
                            Map<Property,Map<Property,Where>> map)

mapInheritedProperty

protected void mapInheritedProperty(Type type,
                                    Property property,
                                    Map<Type,List<String>> map)

addInheritedProperty

protected void addInheritedProperty(Type type,
                                    Property property,
                                    Map<Type,Set<Property>> map)

addInheritedProperty

protected void addInheritedProperty(Type type,
                                    Integer level,
                                    Property property,
                                    Map<Type,Map<Integer,Set<Property>>> map)

addInheritedProperty

protected void addInheritedProperty(Type type,
                                    Property edge,
                                    Property property,
                                    Map<Type,Map<Property,Set<Property>>> map)

mapPropertyNames

protected void mapPropertyNames(Type type,
                                String[] names,
                                Map<Type,List<String>> map)

mapProperties

protected void mapProperties(Type type,
                             Property[] props,
                             Map<Type,Set<Property>> map)

mapFunctions

protected void mapFunctions(Property prop,
                            List<Function> functions,
                            Map<Property,List<Function>> map)

mapProperties

protected void mapProperties(Type type,
                             Integer level,
                             Property[] props,
                             Map<Type,Map<Integer,Set<Property>>> map)

mapFunctions

protected void mapFunctions(Property prop,
                            Integer level,
                            List<Function> functions,
                            Map<Property,Map<Integer,List<Function>>> map)

mapProperties

protected void mapProperties(Type type,
                             Property edge,
                             Property[] props,
                             Map<Type,Map<Property,Set<Property>>> map)

mapInheritedPropertyNames

protected void mapInheritedPropertyNames(Type type,
                                         String[] names,
                                         Map<Type,List<String>> map)

mapInheritedProperties

protected void mapInheritedProperties(Type type,
                                      Property[] props,
                                      Map<Type,Set<Property>> map)

mapInheritedProperties

protected void mapInheritedProperties(Type type,
                                      Integer level,
                                      Property[] props,
                                      Map<Type,Map<Integer,Set<Property>>> map)

mapInheritedProperties

protected void mapInheritedProperties(Type type,
                                      Property edge,
                                      Property[] props,
                                      Map<Type,Map<Property,Set<Property>>> map)

findPropertyNames

protected String[] findPropertyNames(Type type,
                                     AbstractProperty abstractProperty)
A convenience method returning an array of names for the given property whether a wildcard property or not. For wildcard properties determines the type of wildcard and returns the appropriate property set.

Parameters:
type - the type
abstractProperty - the property
Returns:
the property names as an array

findProperties

protected Property[] findProperties(Type type,
                                    AbstractProperty abstractProperty)
A convenience method returning an array of names for the given property whether a wildcard property or not. For wildcard properties determines the type of wildcard and returns the appropriate property set.

Parameters:
type - the type
abstractProperty - the property
Returns:
the property names as an array

isSingularPath

protected boolean isSingularPath(Path path,
                                 Type rootType,
                                 AbstractProperty abstractProperty)
Recursively traverses the given path checking every path element and determines if the entire path is composed of singular properties.

Parameters:
path - the path
rootType - the root type
abstractProperty -
Returns:
whether the given path is composed entirely of singular \ properties

isSingularPath

protected boolean isSingularPath(Path path,
                                 Type currType,
                                 AbstractPathElement currPathElement,
                                 int curPathElementIndex,
                                 AbstractProperty abstractProperty)
Recursively traverses the given path checking every path element and determines if the entire path is composed of singular properties.

Parameters:
path - the path
currType - the current type
currPathElement - the current path element
curPathElementIndex - the current path element index
abstractProperty - the property
Returns:
whether the given path is composed entirely of singular \ properties


Copyright © 2014. All rights reserved.