livespace.services.entities.info_repository
Class QueryEntity

java.lang.Object
  extended by dsto.dfc.databeans.AbstractDataObject
      extended by dsto.dfc.databeans.SimpleDataObject
          extended by dsto.dfc.databeans.FancyDataObject
              extended by livespace.services.Entity
                  extended by livespace.services.entities.info_repository.QueryEntity
All Implemented Interfaces:
IDataObject, IDataObjectChildListener, Cloneable

public class QueryEntity
extends Entity

Represents an information repository query used to query the repository for information repository entities based on certain search criteria. The search criteria are specified upon creation of this class (via the factory method) and used to form query statements that are later passed on the JCR's QueryManager to handle the search.

Author:
Vivian Nguyen

Field Summary
 String[] comparator
           
 boolean deepSearch
           
static String ENTITY_TYPE
           
 Object funcArg
           
 String jcrFunction
           
 boolean order
           
 String orderDirection
           
 String orderProperty
           
 String parentFolder
           
 boolean processed
           
 String[] propertyName
           
 Object[] propValue
           
 String queryLang
           
 String queryStmt
           
 String requiredNodeType
           
 String[] result
           
 
Fields inherited from class livespace.services.Entity
container, id, lastTouched, name, unconfirmedUpdates
 
Fields inherited from class dsto.dfc.databeans.AbstractDataObject
listeners
 
Fields inherited from interface dsto.dfc.databeans.IDataObject
OVERRIDE, PERSISTENT, PERSISTENT_OVERRIDE, TRANSIENT, TRANSIENT_OVERRIDE
 
Constructor Summary
protected QueryEntity()
           
 
Method Summary
static QueryEntity createQueryEntity(Object parentFolder, boolean deepSearch, String requiredNodeType, String jcrFunction, Object funcArg, String[] propName, String[] comparator, Object[] propValue)
          Create a QueryEntity from the specified arguments.
static QueryEntity createQueryEntity(String queryStmt, String queryLang)
          Create a QueryEntity with the specified query statement for the specified query language.
 String getType()
          The type of the object (eg "room", "light", "volume", etc).
 void orderBy(String orderProp, String orderDir)
          Order the result of this query by the specified property in the specified order (InfoRepositoryQueryOperators.ASCENDING or InfoRepositoryQueryOperators.DESCENDING)
 
Methods inherited from class livespace.services.Entity
create, createId, getElvin, getType, getTypeInfo, mutex, sameEntity, shallowClone, waitForProperty, waitForProperty, waitForProperty, waitForProperty
 
Methods inherited from class dsto.dfc.databeans.FancyDataObject
childPropertyChanged, getValue, isTransient, propertyIterator, setValue
 
Methods inherited from class dsto.dfc.databeans.SimpleDataObject
getFieldNames, setValue
 
Methods inherited from class dsto.dfc.databeans.AbstractDataObject
addFirstPropertyListener, addPropertyListener, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, getBeanValue, getBooleanValue, getBooleanValue, getCharValue, getCharValue, getDoubleValue, getDoubleValue, getFloatValue, getFloatValue, getIntValue, getIntValue, getLongValue, getLongValue, getObjectValue, getPropertyListeners, getShortValue, getStringValue, registerValue, removePropertyListener, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, toString, unregisterValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ENTITY_TYPE

public static final String ENTITY_TYPE
See Also:
Constant Field Values

parentFolder

public String parentFolder

deepSearch

public boolean deepSearch

propertyName

public String[] propertyName

jcrFunction

public String jcrFunction

funcArg

public Object funcArg

requiredNodeType

public String requiredNodeType

propValue

public Object[] propValue

comparator

public String[] comparator

processed

public boolean processed

order

public boolean order

result

public String[] result

orderProperty

public String orderProperty

orderDirection

public String orderDirection

queryStmt

public String queryStmt

queryLang

public String queryLang
Constructor Detail

QueryEntity

protected QueryEntity()
Method Detail

createQueryEntity

public static QueryEntity createQueryEntity(Object parentFolder,
                                            boolean deepSearch,
                                            String requiredNodeType,
                                            String jcrFunction,
                                            Object funcArg,
                                            String[] propName,
                                            String[] comparator,
                                            Object[] propValue)
Create a QueryEntity from the specified arguments. Search can be done using JCR's built-in functions such as 'contains' or 'similar'. In such case, the funcArg must contain value to search against. Search can also be done against properties. For example, search for all files larger than 10Kb and of mime-type text/plain. In this case, comparators and propValues must be in the same order as propNames. Comparators and propValues can be null, if so, the search will result in all nodes of the required type that have the specified property/ies. Search can be done for multiple criteria, such as more than one properties or property-value sets in conjunction with jcrFunctions.

Parameters:
parentFolder - folder to search in. It can be an InfoRepositoryEntity or path to the parent folder or null (search everywhere)
deepSearch - true or false if multi-level search is required
requiredNodeType - required node type, e.g. InfoRepositoryConstants.FILE_NODE_TYPE or InfoRepositoryConstants.FOLDER_NODE_TYPE or InfoRepositoryConstants.SESSION_NODE_TYPE or null (any node type)
jcrFunction - functions that are supported by JCR, e.g. InfoRepositoryQueryOperators.JCR_FUNCTION_CONTAINS or InfoRepositoryQueryOperators.JCR_FUNCTION_SIMILAR
funcArg - arguments for the jcrFunction
propName - properties to search against, e.g. size, date created, mimetype, etc (see InfoRepositoryConstants)
comparator - (must be in the same order as propertyName[] indicate how to limit the result based on values of specified properties, e.g. InfoRepositoryQueryOperators.GREATER_THAN or InfoRepositoryQueryOperators.LESS_THAN or InfoRepositoryQueryOperators.EQUALS InfoRepositoryQueryOperators.GREATER_THAN_OR_EQUALS InfoRepositoryQueryOperators.LESS_THAN_OR_EQUALS InfoRepositoryQueryOperators.NOT_EQUAL = "!=";
propValue - values for the properties to search against (must be in the same order as propertyNames[]
Returns:
QueryEntity
Throws:
IllegalArgumentException - if parentFolder is not String or InfoRepositoryEntity or null

createQueryEntity

public static QueryEntity createQueryEntity(String queryStmt,
                                            String queryLang)
Create a QueryEntity with the specified query statement for the specified query language. The language must be either InfoRepositoryQueryOperators.XPATH or InfoRepositoryQueryOperators.SQL

Parameters:
queryStmt - final query statement
queryLang - InfoRepositoryQueryOperators.XPATH or InfoRepositoryQueryOperators.SQL
Returns:
QueryEntity

orderBy

public void orderBy(String orderProp,
                    String orderDir)
Order the result of this query by the specified property in the specified order (InfoRepositoryQueryOperators.ASCENDING or InfoRepositoryQueryOperators.DESCENDING)

Parameters:
orderProp -
orderDir -

getType

public String getType()
Description copied from class: Entity
The type of the object (eg "room", "light", "volume", etc). This must be unique to the entity class.

NOTE: it is also a good practice to provide a static field that defines the entity type on the class: eg

 public static final String ENTITY_TYPE = "room";
 

Specified by:
getType in class Entity


Copyright © 2008 Commonwealth of Australia