com.sun.mdm.index.query
Class MultiQueryParser

java.lang.Object
  extended bycom.sun.mdm.index.query.QueryParser
      extended bycom.sun.mdm.index.query.MultiQueryParser

class MultiQueryParser
extends QueryParser

This Parser parses a QueryObject and produces SQLDescriptors[] containing SQL statements. Each SQL statement correspond to a path from a root to a leaf, specified in selectfields in QueryObject. Example if we have an object graph like: System Person Address Phone Alias Here System is the root object and has one child Person. Person has children: Address, Phone, ALias. So the three SQL statements would consists of select fields: {System.attributes, Person.attributes, Address.attributes}, {System.keyfield, Person.keyfield, Phone.attributes}, {System.keyfield, Person.keyfield, Alias.attributes} Say if QueryObject has conditions: Address.city = ‘Monrovia’ and Phone.phoneType = ‘Business’. Select fields are Person.firstName, Phone.phoneNumber, Address.city, Alias.lastName. Primary keys are: System (euid), Person (personid), Address (addressid), Phone (phoneid), Alias (aliasid). So this would generate the three SQL statements as: SQL1: Select system.euid, person.personid, person.firstname, address.addressid, address.city From system, person, address Where system.euid = person.euid And person.personid = address.personid And address.city = ‘Monrovia’ And personid in ( Select personid from person, phone where person.personid = phone.personid and phone.phoneType = ‘Business’ ) Order by system.euid, person.personid SQL2: Select system.euid, person.personid, phone.phoneid, phone.phonenumber From system, person, phone Where system.euid = person.euid And person.personid = address.personid And phone.phoneType = ‘Business’ And personid in ( Select person.personid from person, address where person.personid = address.personid and address.city = ‘Monrovia’) Order by system.euid, person.personid SQL3: Select system.euid, person.personid, phone.phoneid, alias.lastName From system, person, alias Where system.euid = person.euid And person.personid = alias.personid And personid in ( Select person.personid from person, address where person.personid = address.personid and address.city = ‘Monrovia’) And personid in ( Select person.personid from person, phone where person.personid = phone.personid and phone.phoneType = ‘Business’ ) Order by system.euid, person.personid


Constructor Summary
(package private) MultiQueryParser(QueryObject qo)
          Creates a new instance of QueryParser
 
Method Summary
(package private)  void checkForInvalidObjects(java.util.HashSet objects, QPath[] qpaths)
           
(package private)  ConditionMap[] createConditionMap(java.util.HashSet objects, QPath[] qpaths, Condition[] conditions)
           
(package private)  QPath[] createQPath(java.lang.String root, java.util.HashSet objectsHS)
          This is the actual method that creates the QPath[] each of which is a path from root to a different leaf.
(package private)  void createsubQPath(QPath[] selectQpaths, QPath[] cqpaths, ConditionMap[] conditionMap)
           
(package private)  java.util.HashSet findObjects(QualifiedField[] selectFields)
           
(package private)  java.util.HashSet findObjects(QualifiedField[] selectFields, Condition[] conditions)
           
(package private)  QueryObject getQueryObject()
           
(package private)  java.lang.String getRoot()
           
(package private)  java.lang.String getRoot(QualifiedField[] selectFields, Condition[] conditions)
           
(package private)  java.lang.String[] getRootId()
          Returns full qualified path for root object primary key
 SQLDescWithBindParameters[] parse()
          parses the QueryObject.
(package private)  QualifiedField[] qualify(java.lang.String[] selectFields)
           
(package private)  void setQueryObject(QueryObject qo)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiQueryParser

MultiQueryParser(QueryObject qo)
Creates a new instance of QueryParser

Parameters:
qo - QueryObject to parse
Method Detail

checkForInvalidObjects

void checkForInvalidObjects(java.util.HashSet objects,
                            QPath[] qpaths)
                      throws QMException
Throws:
QMException

createConditionMap

ConditionMap[] createConditionMap(java.util.HashSet objects,
                                  QPath[] qpaths,
                                  Condition[] conditions)

createQPath

QPath[] createQPath(java.lang.String root,
                    java.util.HashSet objectsHS)
This is the actual method that creates the QPath[] each of which is a path from root to a different leaf. So if objectsHS contain objects which belong to object graph: System Person Address Phone Alias, then QPaths would be { System, Person, Address }, { System, Person, Phone }, { System, Person, Alias } This method uses a variation of Breadth First Search algorithm to create SQL paths.

Parameters:
root - root of the tree that contains objects
objectsHS - HashSet contains the objects.

createsubQPath

void createsubQPath(QPath[] selectQpaths,
                    QPath[] cqpaths,
                    ConditionMap[] conditionMap)

findObjects

java.util.HashSet findObjects(QualifiedField[] selectFields)

findObjects

java.util.HashSet findObjects(QualifiedField[] selectFields,
                              Condition[] conditions)

getQueryObject

QueryObject getQueryObject()

getRoot

java.lang.String getRoot()

getRoot

java.lang.String getRoot(QualifiedField[] selectFields,
                         Condition[] conditions)

getRootId

java.lang.String[] getRootId()
                       throws QMException
Returns full qualified path for root object primary key

Returns:
Throws:
QMException

parse

public SQLDescWithBindParameters[] parse()
                                  throws QMException
parses the QueryObject. This is the main interface method for parsing.

Specified by:
parse in class QueryParser
Returns:
SQLDescriptor[] Each SQLDescriptor has a different SQL statement
Throws:
QMException - if there is any exception

qualify

QualifiedField[] qualify(java.lang.String[] selectFields)
                   throws QMException
Throws:
QMException

setQueryObject

void setQueryObject(QueryObject qo)


Sun Microsystems, Inc.