uk.ac.bbk.dcs.automed.qproc.reformulate
Class NewGAVQueryReformulationProvider

java.lang.Object
  extended by uk.ac.bbk.dcs.automed.qproc.reformulate.NewGAVQueryReformulationProvider

public class NewGAVQueryReformulationProvider
extends java.lang.Object

The query reformulator accepts an IQL query on the source schema and rewrites it in terms of constructs of the target schemata.

To do this, on construction, the query reformulator traverses the pathways from the source schema to the target schemata and builds a view definition over target schema constructs for each source schema construct.


Field Summary
private  QueryProcessorConfiguration _qpc
           
protected  java.util.logging.Logger logger
           
protected  Schema sourceSchema
           
protected  Schema[] targetSchemata
           
protected  java.util.Map viewmap
          Viewmap contains the constructs of the source schema in the LHS and the IQL view of each construct of the LHS in the RHS.
private static java.util.Map viewmap_cache
           
 
Constructor Summary
protected NewGAVQueryReformulationProvider()
           
  NewGAVQueryReformulationProvider(Schema sourceSchema, Schema[] targetSchemata, QueryProcessorConfiguration qpc)
           
 
Method Summary
private  void branch(Cell n, Schema fromSchema, java.lang.Object[] tos)
          Updates the view definitions (viewmap).
protected  void buildViews()
          Traverses BAV pathways and builds GAV views.
private  void changeSchemaRef(Cell n, Schema fromSchema, Schema to)
          Updates the view definition hashmap when the 'from' schema has only one 'to' schema.
private  void checkFinalConstructs()
           
 void finalize()
           
static void main(java.lang.String[] args)
           
private static void o(java.lang.Object s)
           
private  void populateViewMapLHS(Schema sourceSchema)
          Populates the LHS of the viewmap with schemes from source schema
private  void processTransformation(Schema fromSchema, Schema toSchema)
           
 void reformulate(ASG g, QueryProcessorConfiguration qpc)
          Reformulates the query represented by the ASG g according to the view defintions it has stored.
private  void replace(SchemeInfo si, Cell q, Cell root)
           
private  void replaceNullSchemaRefs(Cell r, java.lang.String sName)
           
private  void showViewMap()
           
private  void unifyViewDefinitions()
          Performs variable unification on each view definition in the viewmap.
private  void updateSchemeInfo(Cell c)
           
private  void updateSchemeInfoInViewMap()
          Method goes through all view definitions and updates SchemeInfo objects with Model, ConstructType and Type information (if present in the repository).
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected java.util.logging.Logger logger

sourceSchema

protected Schema sourceSchema

targetSchemata

protected Schema[] targetSchemata

viewmap

protected java.util.Map viewmap
Viewmap contains the constructs of the source schema in the LHS and the IQL view of each construct of the LHS in the RHS.


_qpc

private QueryProcessorConfiguration _qpc

viewmap_cache

private static java.util.Map viewmap_cache
Constructor Detail

NewGAVQueryReformulationProvider

protected NewGAVQueryReformulationProvider()

NewGAVQueryReformulationProvider

public NewGAVQueryReformulationProvider(Schema sourceSchema,
                                        Schema[] targetSchemata,
                                        QueryProcessorConfiguration qpc)
                                 throws QueryReformulationException
Parameters:
sourceschema - the source schema
targetschemata - the target schemata
qpc - the input configuration
Throws:
QueryReformulationException - if there was a problem building the view definitions of the source schema constructs over target schema constructs
Method Detail

buildViews

protected void buildViews()
                   throws QueryReformulationException
Traverses BAV pathways and builds GAV views.

Throws:
QueryReformulationException
IntegrityException
NotFoundException

showViewMap

private void showViewMap()

populateViewMapLHS

private void populateViewMapLHS(Schema sourceSchema)
Populates the LHS of the viewmap with schemes from source schema

Parameters:
sourceSchema - the source schema

unifyViewDefinitions

private void unifyViewDefinitions()
                           throws QueryReformulationException
Performs variable unification on each view definition in the viewmap.

Throws:
QueryReformulationException
QueryReformulationException

updateSchemeInfoInViewMap

private void updateSchemeInfoInViewMap()
                                throws NotFoundException
Method goes through all view definitions and updates SchemeInfo objects with Model, ConstructType and Type information (if present in the repository).

Throws:
NotFoundException

updateSchemeInfo

private void updateSchemeInfo(Cell c)
                       throws NotFoundException
Throws:
NotFoundException

processTransformation

private void processTransformation(Schema fromSchema,
                                   Schema toSchema)
                            throws NotFoundException,
                                   QueryReformulationException
Throws:
NotFoundException
QueryReformulationException

replaceNullSchemaRefs

private void replaceNullSchemaRefs(Cell r,
                                   java.lang.String sName)

replace

private void replace(SchemeInfo si,
                     Cell q,
                     Cell root)

changeSchemaRef

private void changeSchemaRef(Cell n,
                             Schema fromSchema,
                             Schema to)
                      throws NotFoundException
Updates the view definition hashmap when the 'from' schema has only one 'to' schema. The only thing it updates is the schema reference of SchemeInfo objects found in the view definitions.

Parameters:
n - the view to be updated
fromSchema - the 'from' schema
to - the 'to' schema
Throws:
NotFoundException

branch

private void branch(Cell n,
                    Schema fromSchema,
                    java.lang.Object[] tos)
             throws NotFoundException,
                    QueryReformulationException
Updates the view definitions (viewmap). Building viewmap occurs by a breadth-first traversal, so at each depth, and for each pathway, if a 'from' schema has more than one 'to' schemas, the viewmap is updated using this method.

Parameters:
n - the view definition to be updated
fromSchema - the schema where the branching occurs
tos - the schemas resulting from the branching
Throws:
NotFoundException
QueryReformulationException

reformulate

public void reformulate(ASG g,
                        QueryProcessorConfiguration qpc)
                 throws QueryReformulationException
Reformulates the query represented by the ASG g according to the view defintions it has stored.

Throws:
QueryReformulationException

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

checkFinalConstructs

private void checkFinalConstructs()

o

private static void o(java.lang.Object s)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception