Cool documentation

com.sap.tc.col.client.generic.api
Interface IQuery


public interface IQuery

interface of a Query at runtime, a Query allows searching for Aspects for given search parameters and given input Keys.

An example using a Query could be:

   IQuery query = serviceModule.createQuery("QUERY_NAME");
   IStructure inputParameter = query.getInputParameter();
   // setting input parameter
   inputParameter.setAttributeValue("NAME1", "R*");
   ..
   query.execute();
   // now the result
   IAspect aspect = query.getResult();
   ..
 
Additionally Query implements ICMIQuery and ICMIModelClassExecutable.

This is necessary to use a Query from Web Dynpro. Web Dynpro framework only knows this interfaces and uses the implicit relations inputParameter and result for setting parameters and getting the result of the Query.

A Query is the root of a cache. That means that all Aspects which were reached by navigation from this Query result, are internally hold in a cache until this cache is invalidated implicitly or explicitly with method invalidate().

Implicitly could be a new execute() of this Query or changing services (insert, update, delete) for an Aspect in the cache.


Field Summary
static java.lang.String BT
          constant string value for operator BETWEEN in select options structure
static java.lang.String EQ
          constant string value for operator EQUAL (=) in select options structure
static java.lang.String GE
          constant string value for operator GREATER OR EQUAL (>=) in select options structure
static java.lang.String GT
          constant string value for operator GREATER (>) in select options structure
static java.lang.String INPUT_PARAMETER
          constant string for implicit inputParamter relation role
static java.lang.String LE
          constant string value for operator LESS EQUAL (<=) in select options structure
static java.lang.String LT
          constant string value for operator LESS (<) in select options structure
static java.lang.String NE
          constant string value for operator NOT EQUAL (!=) in select options structure
static java.lang.String RESULT
          constant string for implicit result relation role
static java.lang.String SELECT_OPTIONS
          constant string for implicit select options relation role
 
Method Summary
 IStructure createSelectOption(java.lang.String fieldName)
          creates a select option for this Query and the given fieldName.
 IStructure createSelectOption(java.lang.String fieldName, java.lang.String operator, java.lang.String from, java.lang.String to)
          creates a select option for this Query and the given fieldName.
 void execute()
          Executes this Query by calling corresponding ServiceManager service.
 IQueryDescriptor getDescriptor()
          returns meta data of this Query
 IKeyList getInputKeyList()
          returns the input KeyList, which you can use as input of this Query to define a subset of the result.
 IStructure getInputParameterStructure()
          returns the search parameter structure of this Query or throws an UnsupportedOperationException, if this Query has no input parameter.
 IAspect getResultAspect()
          returns the result of this Query
 IStructureList getSelectOptions()
          returns a list of all currently set select options for this Query.
 void invalidate()
          invalidates this Query and all Aspects, which were created by navigation from Query result.
 void setSortingCriteria(SortingCriteria sorting)
          set SortingCriteria for this Query.
 

Field Detail

INPUT_PARAMETER

public static final java.lang.String INPUT_PARAMETER
constant string for implicit inputParamter relation role

SELECT_OPTIONS

public static final java.lang.String SELECT_OPTIONS
constant string for implicit select options relation role

RESULT

public static final java.lang.String RESULT
constant string for implicit result relation role

EQ

public static final java.lang.String EQ
constant string value for operator EQUAL (=) in select options structure

NE

public static final java.lang.String NE
constant string value for operator NOT EQUAL (!=) in select options structure

GT

public static final java.lang.String GT
constant string value for operator GREATER (>) in select options structure

GE

public static final java.lang.String GE
constant string value for operator GREATER OR EQUAL (>=) in select options structure

LT

public static final java.lang.String LT
constant string value for operator LESS (<) in select options structure

LE

public static final java.lang.String LE
constant string value for operator LESS EQUAL (<=) in select options structure

BT

public static final java.lang.String BT
constant string value for operator BETWEEN in select options structure
Method Detail

execute

public void execute()
Executes this Query by calling corresponding ServiceManager service.

Before this is done, eventually existing result and cache are invalidated.

Note that this execute is propagated to the backend only when the message queue is flushed.


getDescriptor

public IQueryDescriptor getDescriptor()
returns meta data of this Query
Returns:
IQueryDescriptor meta data of this Query

getResultAspect

public IAspect getResultAspect()
returns the result of this Query
Returns:
IAspect the result of this Query

getInputParameterStructure

public IStructure getInputParameterStructure()
returns the search parameter structure of this Query or throws an UnsupportedOperationException, if this Query has no input parameter.
Returns:
IStructure the search parameter of this Query
Throws:
throws - an UnsupportedOperationException, if this Query has no input parameter.

getInputKeyList

public IKeyList getInputKeyList()
returns the input KeyList, which you can use as input of this Query to define a subset of the result. incomplete Keys in this KeyList are ignored.
Returns:
IKeyList the input KeyKist, which you can use as input of this Query to define a subset of the result.

setSortingCriteria

public void setSortingCriteria(SortingCriteria sorting)
set SortingCriteria for this Query.
Parameters:
sorting - the sorting criteria for this Query

getSelectOptions

public IStructureList getSelectOptions()
returns a list of all currently set select options for this Query. A Structure(select option item) in this list contains the following fields: "FIELDNAME" ,"OPTION", "LOW", "HIGH" To add a select option to this list, the user must use the method createSelectOption(), removing of entries is done with list methods like remove() and clear().
 Example:
    ...
    // create select options for a Query
    IStructure nameOption = query.createSelectOption("NAME");
    nameOption.setAttributeValue("OPTION",IQuery.BT);
    nameOption.setAttributeValue("LOW","M*");
    nameOption.setAttributeValue("HIGH","OTTO");
    ...
    query.execute();
    ...
    // remove select option
    query.getSelectOptions().remove(nameOption);
    quere.getInputParameterStructure().setAttributeValue("NAME","A*");
    query.execute();
    ...
Returns:
IStructureList a list with all select options for this Query

createSelectOption

public IStructure createSelectOption(java.lang.String fieldName)
creates a select option for this Query and the given fieldName. the method checks, if there is no value set for corresponding field in inputParameter structure
Parameters:
fieldName - the name of the field, where the select options are set.
Throws:
java.lang.IllegalArgumentException - if fieldName is no fieldName from inputStructure or a value is set for inputStructure

createSelectOption

public IStructure createSelectOption(java.lang.String fieldName,
                                     java.lang.String operator,
                                     java.lang.String from,
                                     java.lang.String to)
creates a select option for this Query and the given fieldName. The given attributes are set to the corresponding Structure fields. If no "to" value is neeeded for operator, "to" must be set to null. the method checks, whether there is no value set for corresponding field in inputParameter structure
Parameters:
fieldName - the name of the field, where the select options are set.
operator - the operator, possible values are EQ, NE, GT, GE, LE, LT, BT
from - the value or from value, if it is a range, for the select option
to - the to value, if it is a range, or null, if not for the select option
Throws:
java.lang.IllegalArgumentException - if fieldName is no fieldName from inputStructure or a value is set for inputStructure

invalidate

public void invalidate()
invalidates this Query and all Aspects, which were created by navigation from Query result.

invalidating the query doesn't mean, that the Query object itself isn't valid, but the result of the query with its Aspect tree is no more valid. You can set the input parameters and input keys a new, and then execute this Query again.


Cool documentation

Copyright © 2002 SAP AG. Automatically generated Thu Mar 3 2005, 21:55