Class ExecuteQueryCommand
- java.lang.Object
-
- com.sodius.mdw.metamodel.integrity.io.command.ExecutableCommandWrapper
-
- com.sodius.mdw.metamodel.integrity.io.command.ExecuteQueryCommand
-
- All Implemented Interfaces:
ExecutableCommand
public class ExecuteQueryCommand extends ExecutableCommandWrapper implements ExecutableCommand
Executes a dynamic query, i.e. a query whose textual definition is given as an argument of the constructor, to get the
Items
matching the query criteria.Note:
- The query definition format is described in the Integrity
im issues
command reference manual. - The query definition must be surrounded by parenthesis.
Usage:
ExecuteQueryCommand command = new ExecuteQueryCommand(myDatabase, "(field[Type]=\"Requirement\")"); command.execute(); MDWList<Item> result = command.getItems(); // get the Items which match the Query criteria
-
-
Constructor Summary
Constructors Constructor Description ExecuteQueryCommand(Database database, String queryDefinition)
Instantiates a command to execute a dynamic query.ExecuteQueryCommand(Database database, String queryDefinition, Collection<Field> fields)
Instantiates a command to execute a dynamic query and to read the field values of the matching items.ExecuteQueryCommand(Query query, Collection<Field> fields)
Instantiates a command to execute a registered query and to read the field values of the matching items.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MDWList<Item>
getItems()
Returns the unmodifiable list of Items matching the query criteria.-
Methods inherited from class com.sodius.mdw.metamodel.integrity.io.command.ExecutableCommandWrapper
execute
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.sodius.mdw.metamodel.integrity.io.command.ExecutableCommand
execute
-
-
-
-
Constructor Detail
-
ExecuteQueryCommand
public ExecuteQueryCommand(Database database, String queryDefinition)
Instantiates a command to execute a dynamic query.This command executes the query and identifies the items matching the query criteria. It does not read any field values of items. Field values are retrieved on-demand individually for each item. To get better performance, clients are recommended to use the constructor that allows to specify the collection of fields of interest.
- Parameters:
database
- the database on which the query must execute.queryDefinition
- the definition of the query to execute.- See Also:
ExecuteQueryCommand(Database, String, Collection)
-
ExecuteQueryCommand
public ExecuteQueryCommand(Database database, String queryDefinition, Collection<Field> fields)
Instantiates a command to execute a dynamic query and to read the field values of the matching items.This constructor enables to execute only one command to:
- Execute a query to get a list of items matching the criteria.
- Read the field values of those items.
Reading the field values in the same command as the query execution provides much better performance. It is to be noted that only the fields specified in the constructor are read, meaning additional fields cannot be retrieved later on.
- Parameters:
database
- the database on which the query must execute.queryDefinition
- the definition of the query to execute.fields
- the collections of fields to read for items matching the query criteria.- Since:
- 1.8.0
-
ExecuteQueryCommand
public ExecuteQueryCommand(Query query, Collection<Field> fields)
Instantiates a command to execute a registered query and to read the field values of the matching items.This constructor enables to execute only one command to:
- Execute a query to get a list of items matching the criteria.
- Read the field values of those items.
Reading the field values in the same command as the query execution provides much better performance. It is to be noted that only the fields specified in the constructor are read, meaning additional fields cannot be retrieved later on.
- Parameters:
query
- a query registered in the database.fields
- the collections of fields to read for items matching the query criteria.- Since:
- 1.8.0
-
-