2.17.2: 2011-06-17

net.sf.basedb.info
Class QueryOptions

java.lang.Object
  extended by net.sf.basedb.info.QueryOptions
All Implemented Interfaces:
Transferable

public class QueryOptions
extends Object
implements Transferable

This class holds information to configure itemqueries in webservices with. It is which items to include in the query and which restriction to put on the query.

The includes in this class correspond directly to the includes in Include. The include options will be set to TRUE if nothing else is specified.

Version:
2.5
Author:
Martin

Field Summary
private  boolean includeInProject
          Include items from the active project.
private  boolean includeMine
          Include items that belongs to the logged in user.
private  boolean includeNotRemoved
           
private  boolean includeOthers
          Include items that belong to other users.
private  boolean includeShared
          Include items, shared to the logged in user.
private  QueryParameter[] parameters
           
private  String prefix
          The prefix that represent a root alias in a query.
private  String restriction
          A restriction to set on the query.
 
Constructor Summary
QueryOptions()
          An empty constructor.
QueryOptions(Boolean includeMine, Boolean includeShared, Boolean includeInProject, Boolean includeOthers, String restriction, String prefix)
          Constructor where the parameters is set from start.
 
Method Summary
 boolean getIncludeInProject()
          Gets if items in the project that is currently active should be included.
 boolean getIncludeMine()
          Gets if items of logged in user should be included
 boolean getIncludeNotRemoved()
          Include not removed items
 boolean getIncludeOthers()
          Gets if other users' item should be included in the query
 boolean getIncludeShared()
          Gets if items shared to the logged in user should be included or not
 QueryParameter[] getParameters()
          Get the parameters used in this query.
 String getRestriction()
          Gets the restriction for this QueryOptions
 String getRestrictionPrefix()
          Gets the prefix used with the restriction/expression in this object.
 void setIncludeInProject(boolean includeInProject)
          Sets if items in currently active project should be included.
 void setIncludeMine(boolean includeMine)
          Sets if the logged in user's items should be included or not.
 void setIncludeNotRemoved(boolean include)
          Sets if not removed items should be included
 void setIncludeOthers(boolean includeOthers)
          Sets if other users' items should be included.
 void setIncludeShared(boolean includeShared)
          Sets if items shared to logged in user should be included.
 void setParameters(QueryParameter[] parameters)
          Set the parmeters to use in this query.
 void setRestriction(String restriction)
          Sets restriction for these query options.
 void setRestrictionPrefix(String prefix)
          Sets the prefix to use in restrictions or expression
 void setRestrictionWithPrefix(String restriction, String prefix)
          Sets both the restriction and the prefix with it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

includeMine

private boolean includeMine
Include items that belongs to the logged in user. Included by default.


includeShared

private boolean includeShared
Include items, shared to the logged in user. Included by default.


includeInProject

private boolean includeInProject
Include items from the active project. Included by default.


includeOthers

private boolean includeOthers
Include items that belong to other users. Included by default.


includeNotRemoved

private boolean includeNotRemoved

parameters

private QueryParameter[] parameters

restriction

private String restriction
A restriction to set on the query.


prefix

private String prefix
The prefix that represent a root alias in a query. This string can be used in {restriction and will be replaced when the restriction is inserted into a HQL query.

Constructor Detail

QueryOptions

public QueryOptions()
An empty constructor.


QueryOptions

public QueryOptions(Boolean includeMine,
                    Boolean includeShared,
                    Boolean includeInProject,
                    Boolean includeOthers,
                    String restriction,
                    String prefix)
Constructor where the parameters is set from start.

Parameters:
includeMine - TRUE if logged in user's items should be included.
includeShared - TRUE if items shared to logged in user should be included.
includeInProject - TRUE if items in the active project should be included.
includeOthers - TRUE if other users' items should be included.
restriction - A Restriction as a string.
prefix - Prefix used in the restriction.
Method Detail

setIncludeMine

public void setIncludeMine(boolean includeMine)
Sets if the logged in user's items should be included or not.

Parameters:
includeMine - TRUE to include logged in user's items, otherwise FALSE

getIncludeMine

public boolean getIncludeMine()
Gets if items of logged in user should be included

Returns:
TRUE to include, otherwise FALSE

setIncludeShared

public void setIncludeShared(boolean includeShared)
Sets if items shared to logged in user should be included.

Parameters:
includeShared - TRUE to include shared items, otherwise FALSE.

getIncludeShared

public boolean getIncludeShared()
Gets if items shared to the logged in user should be included or not

Returns:
TRUE if shared items should be included, FALSE otherwise.

setIncludeInProject

public void setIncludeInProject(boolean includeInProject)
Sets if items in currently active project should be included.

Parameters:
includeInProject - TRUE to include, FALSE otherwise.

getIncludeInProject

public boolean getIncludeInProject()
Gets if items in the project that is currently active should be included.

Returns:
TRUE to include the items, FALSE otherwise.

setIncludeOthers

public void setIncludeOthers(boolean includeOthers)
Sets if other users' items should be included.

Parameters:
includeOthers - TRUE if the item should be included, FALSE otherwise.

getIncludeOthers

public boolean getIncludeOthers()
Gets if other users' item should be included in the query

Returns:
TRUE if the items should be included, FALSE otherwise.

setIncludeNotRemoved

public void setIncludeNotRemoved(boolean include)
Sets if not removed items should be included

Parameters:
include - TRUE(default) to include.

getIncludeNotRemoved

public boolean getIncludeNotRemoved()
Include not removed items

Returns:
TRUE to include, FALSE otherwise.

setRestriction

public void setRestriction(String restriction)
Sets restriction for these query options.

The string must be in right format so it can be inserted directly into a hql query. The restriction string can contain a prefix, but it has to be set separatly setRestrictionPrefix(String).

Example how this property can be used together with the prefix:
$name='item1'
When this string is used in a query, ie that select users, it will look like this: usr.name='item1'.

Parameters:
restriction - A restriction as a string to use with HQL queries.

getRestriction

public String getRestriction()
Gets the restriction for this QueryOptions

Returns:
A String with restriction

setRestrictionPrefix

public void setRestrictionPrefix(String prefix)
Sets the prefix to use in restrictions or expression

Parameters:
prefix - A prefix where the root-alias should be put.

getRestrictionPrefix

public String getRestrictionPrefix()
Gets the prefix used with the restriction/expression in this object.

Returns:
A String that should be replaced with the root alias when put in a query.

setRestrictionWithPrefix

public void setRestrictionWithPrefix(String restriction,
                                     String prefix)
Sets both the restriction and the prefix with it.

Parameters:
restriction - A string with a valid hql restriction.
prefix - A string that is used where root-alias should be put in the restriction/expression.

getParameters

public QueryParameter[] getParameters()
Get the parameters used in this query.

Returns:
An array of query parameters, may be null or empty if no parameters are used

setParameters

public void setParameters(QueryParameter[] parameters)
Set the parmeters to use in this query.

Parameters:
parameters - An array of query parameters, may be null or empty if not parameters are used

2.17.2: 2011-06-17