Project: stp

com.ibm.rational.stp.client.samples
Class QueryUtilities

Object
  extended by com.ibm.rational.stp.client.samples.QueryUtilities
Direct Known Subclasses:
QueryCommand

public abstract class QueryUtilities
extends Object

A CmdBaseQuery


Nested Class Summary
private static class QueryUtilities.FilterSym<T>
          The representation for a symbol in a filtering expression
private static class QueryUtilities.Kind
           
private static class QueryUtilities.Tokenizer
          Tokenizes a stream containing a filtering expression from the command line
 
Field Summary
private static EnumSet<QueryUtilities.Kind> END_MASK
          Kind mask for the end of a FilterLeaf expression
private static javax.wvcm.PropertyRequestItem.PropertyRequest FIELD_DEFINITION_PROPERTIES
          CqFieldDefinition properties we will be needing
private static HashMap<com.ibm.rational.wvcm.stp.StpLocation,CqRecordType> g_recordTypeMap
          A Map from user-friendly location to fully-populated record type proxy.
protected static javax.wvcm.PropertyRequestItem.PropertyRequest RECORD_TYPE_WITH_FIELDS
          Properties needed from a record type of a database
private static javax.wvcm.PropertyRequestItem.PropertyRequest RECORD_TYPE_WITHOUT_FIELDS
          Properties needed from a record type of a database (without its field definitions)
private static EnumSet<QueryUtilities.Kind> SEPARATOR_MASK
          Kind mask for a target separator token
private static QueryUtilities.FilterSym[] symbol
          Pre-defined Filter token definitions
private static EnumSet<QueryUtilities.Kind> TARGET_MASK
          Kind mask for target specification token
 
Constructor Summary
QueryUtilities()
           
 
Method Summary
private static CqFieldDefinition[] buildFieldPath(CqQuery query, String path)
          Constructs a CqFieldDefinition[] from a field path specification consisting of dotted segments: field1.field2. ... .fieldN
private static CqQuery.Filter.Operation checkOp(CqQuery.Filter.Operation oldOp, CqQuery.Filter.Operation newOp)
          Verifies that the operation in the input is consistent with the previous operations used.
private static CqFieldDefinition findField(String name, javax.wvcm.ResourceList fields)
          Locates that CqFieldDefinition that corresponds to a given field name.
private static CqRecordType getReferencedRecordType(CqFieldDefinition def)
          Returns a fully-populated proxy for the record type of the records referenced by a given field definition.
protected static CqQuery.DisplayField parseDisplayField(CqQuery query, String fieldSpec)
          Parses a specification for a query display field and constructs a DisplayField object to represent it.
protected static CqQuery.FilterLeaf parseDynamicFilter(CqQuery query, int n, String param)
          Parses the specification for the parameter value that matches a dynamic filter.
protected static CqQuery.Filter parseFilter(CqQuery query, Iterator filterItems)
          Parses a filtering expression, builds a Filter structure for it, and defines that as the value of the query's FILTERING property.
protected static CqQuery.FilterLeaf parseFilterLeaf(CqQuery query, String image)
          Parses a single filter leaf specification and construct the corresponding FilterLeaf structure for it.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TARGET_MASK

private static final EnumSet<QueryUtilities.Kind> TARGET_MASK
Kind mask for target specification token


SEPARATOR_MASK

private static final EnumSet<QueryUtilities.Kind> SEPARATOR_MASK
Kind mask for a target separator token


END_MASK

private static final EnumSet<QueryUtilities.Kind> END_MASK
Kind mask for the end of a FilterLeaf expression


symbol

private static QueryUtilities.FilterSym[] symbol
Pre-defined Filter token definitions


g_recordTypeMap

private static HashMap<com.ibm.rational.wvcm.stp.StpLocation,CqRecordType> g_recordTypeMap
A Map from user-friendly location to fully-populated record type proxy. Used to avoid unnecessary trips to the server to get this static information


RECORD_TYPE_WITHOUT_FIELDS

private static final javax.wvcm.PropertyRequestItem.PropertyRequest RECORD_TYPE_WITHOUT_FIELDS
Properties needed from a record type of a database (without its field definitions)


FIELD_DEFINITION_PROPERTIES

private static final javax.wvcm.PropertyRequestItem.PropertyRequest FIELD_DEFINITION_PROPERTIES
CqFieldDefinition properties we will be needing


RECORD_TYPE_WITH_FIELDS

protected static final javax.wvcm.PropertyRequestItem.PropertyRequest RECORD_TYPE_WITH_FIELDS
Properties needed from a record type of a database

Constructor Detail

QueryUtilities

public QueryUtilities()
Method Detail

findField

private static CqFieldDefinition findField(String name,
                                           javax.wvcm.ResourceList fields)
                                    throws javax.wvcm.WvcmException
Locates that CqFieldDefinition that corresponds to a given field name. Errors or warnings are generated if the given name doesn't match a defined field exactly.

Parameters:
name - The field name to be matched. Must not be null.
fields - The list of FieldDefinitions against which the name is to be compared.
Returns:
The CqFieldDefinition that matches the given name; null returned if no match is found.
Throws:
javax.wvcm.WvcmException - Thrown if the supplied FieldDefinitions do not define the DISPLAY_NAME property.

buildFieldPath

private static CqFieldDefinition[] buildFieldPath(CqQuery query,
                                                  String path)
                                           throws javax.wvcm.WvcmException
Constructs a CqFieldDefinition[] from a field path specification consisting of dotted segments: field1.field2. ... .fieldN

Parameters:
query - A CqQuery proxy for the query in which the field path will be used. Must define PRIMARY_RECORD_TYPE.nest(FIELD_DEFINITIONS.nest(FIELD_DEFINITION_PROPERTIES))
path - A dot-separated list of field names describing the path from a field of the primary resource type, through references, to the targeted field.
Returns:
A CqFieldDefinition[] containing a valid CqFieldDefinition proxy for each segment of the path.
Throws:
javax.wvcm.WvcmException - If the information needed to analyze the path is unavailable or unobtainable.

getReferencedRecordType

private static CqRecordType getReferencedRecordType(CqFieldDefinition def)
                                             throws javax.wvcm.WvcmException
Returns a fully-populated proxy for the record type of the records referenced by a given field definition.

Parameters:
def - The CqFieldDefinition whose referenced record type is desired. must not be null.
Returns:
A fully-populated CqRecordType proxy for the record type of the records referenced by the values of the given field definition; null if the field value doesn't reference a record (or record list). The results are cached to avoid unnecessary interactions with the serve.
Throws:
javax.wvcm.WvcmException

checkOp

private static CqQuery.Filter.Operation checkOp(CqQuery.Filter.Operation oldOp,
                                                CqQuery.Filter.Operation newOp)
Verifies that the operation in the input is consistent with the previous operations used.

Parameters:
oldOp - The previous Operation used; may be null if this is first use of an Operation.
newOp - The current Operation in the input.
Returns:
The newOp.
Throws:
RuntimeException - if the newOp is not compatible with the oldOp.

parseFilterLeaf

protected static CqQuery.FilterLeaf parseFilterLeaf(CqQuery query,
                                                    String image)
                                             throws javax.wvcm.WvcmException
Parses a single filter leaf specification and construct the corresponding FilterLeaf structure for it. The specification is in the form field-path[op]target-list Example specifications are...
     owner[eq][user]
     date[between]10/26/94[and]10/24/95
     submit_date[outside]8-feb-02[and]10-mar-02
     owner.name[unlike]Fred
     State[is]Submitted[or]Closed
     Severity[isnt]High[or]Low
     Description[null]
     Priority[set]
 

Parameters:
query - The Query proxy for the query that will be using the filter
image - String containing the filter leaf expression.
Returns:
A Query.FilterLeaf structure for the filter leaf expression
Throws:
javax.wvcm.WvcmException - If the necessary information is not available or attainable from the server.

parseDynamicFilter

protected static CqQuery.FilterLeaf parseDynamicFilter(CqQuery query,
                                                       int n,
                                                       String param)
                                                throws javax.wvcm.WvcmException
Parses the specification for the parameter value that matches a dynamic filter.

Parameters:
query - The query for which the parameter is being specified
n - The index of the dynamic filter in the query's dynamic filter list.
param - The parameter value specification, which is a filter leaf specification without the field path and optionally without the operator, these being defaulted from the dynamic filter. Must not be null, but may be "" to indicate no value is to be supplied for the dynamic filter
Returns:
A FilterLeaf object representing the parameter operation and values to be used for the n-th dynamic filter of the query as specified by the parameter string.
Throws:
javax.wvcm.WvcmException

parseFilter

protected static CqQuery.Filter parseFilter(CqQuery query,
                                            Iterator filterItems)
                                     throws javax.wvcm.WvcmException
Parses a filtering expression, builds a Filter structure for it, and defines that as the value of the query's FILTERING property. The filtering expression must conform to the following grammar for a filter
 filter ::= filterLeaf
 filter ::= [(] filter [)]
 filter ::= filter ([or] filter)+
 filter ::= filter ([and] filter)+
 
Examples

Parameters:
query - The CqQuery proxy in which the FILTERING property is to be defined. This proxy must define the PRIMARY_RESOURCE property using a CqRecordType proxy that defines the FIELD_DEFINITIONS property.
filterItems - An Iterator over String objects producing the terms of the filtering expression in order left to right, where a term is one of the elements, filterLeaf, [(], [)], [and], or [or] in the above grammar
Returns:
A Filter object representing the specified filtering expression
Throws:
javax.wvcm.WvcmException

parseDisplayField

protected static CqQuery.DisplayField parseDisplayField(CqQuery query,
                                                        String fieldSpec)
                                                 throws javax.wvcm.WvcmException
Parses a specification for a query display field and constructs a DisplayField object to represent it. The specification takes the general form:

[sort-key-position]field-path{label}

Both [sort-key-position] and the {label} are optional. The first position in the sort key is index 1. The index may be preceded by D to indicate a descending sort. Enclose the entire specification in square brackets ([])to make the field not visible.

Parameters:
query - A CqQuery proxy for the query for which the DisplayField is to be constructed. Must define the properties required by buildFieldPath.
fieldSpec - A String containing the specification for one display field of a query.
Returns:
A DisplayField object implementing the String specification.
Throws:
javax.wvcm.WvcmException - If the necessary information is not available or obtainable from the server.

Generated Fri 16-Aug-2013 10:37 PM

Copyright © IBM 2013. All rights reserved.