DSRG.VKB
Class View_Definition

java.lang.Object
  |
  +--DSRG.VKB.View_Definition

public class View_Definition
extends java.lang.Object
implements java.io.Serializable, VSA_View_Definition, java.lang.Cloneable

Represents the View definition.

It has a small parser in it, so, it can generate from a string of ESQL. It contains three lists: select, from and where.

ViewDefinition Overall Function

See Also:
Serialized Form

Field Summary
private static boolean DEBUG
           
static int DONTCARE
          VE is DONTCARE
static int EQUIVALENT
          VE is EQUIVALENT
(package private)  java.util.Vector from
          Vector of FROM clause.
static int FROM
          FROM clause constant
static int JOIN
          JOIN list constant
(package private)  java.lang.String name
          Name of this ViewDefinition.
static int PROJECT
          PROJECT list constant
(package private)  java.util.Vector select
          it will keep the order of the select clause.
static int SELECT
          SELECT here has two meaning.
static int SUBSET
          VE is SUBSET.
static int SUPERSET
          VE is SUPERSET
(package private)  java.util.Vector versions
          A Vector of Versions of this View-Definition.
(package private)  int VExtent
          VE parameter of this View Definition
(package private)  Condition_index where
          Vector of Condition clause.
static int WHERE
          WHERE clause constant
 
Constructor Summary
View_Definition()
          Default construction.
View_Definition(java.lang.String ESQL, MKB mkb)
          Parse E-SQL/SQL String and create the View definition object.
 
Method Summary
 void addJCs(java.util.Vector jcs)
          Add a Vector of JCs to the View Definition.
 void addRelFrom(Relation r)
          Add Relation to from clause of the View Definition.
 java.util.Vector attrSelect(Relation r, boolean di, boolean re)
          Get Attributes in Select Clause.
 java.util.Vector attrWhere(Relation r, boolean di, boolean re)
          Get Attributes in Where Clause.
 void clean()
          Clean the View Definition: 1.
 java.lang.Object clone()
          Clone the view definition.
 boolean contains(Attribute attr)
          Descide whether VD contains some Attribute.
 boolean contains(Relation rel)
          Descide whether VD contains some Relation
 boolean contains(java.lang.String IS_name)
          Descide whether VD contains some IS
 void dropAttrSelect(Relation r, boolean di, boolean re)
          Drop Attributes from Select clause of this view definition.
 void dropAttrSelect(java.util.Vector attrs)
          Drop attribute-components from Select clause for specific vector of attributes
 void dropComponents(java.util.Vector s)
          Drop a vector of components from one view definition.
 void dropCondWhere(Relation r, boolean di, boolean re)
          Drop Conditions from Where clause of this view definition.
 boolean evolvable(Attribute attr)
          Similar to evolvable for del_relation.
 boolean evolvable(Relation rel)
          Check if this view is evolvable or not for a specific relation.
 Relation_Component from_get(Relation rel)
          Get a Relation Component for specific Relation.
(package private)  Attribute_Component get(java.util.Vector sec, Attribute attr)
          Get an Attribute Component from a vector of attribute_components clause for specific Attribute.
 Attribute_Component getAttrComponent(Attribute attr)
          Get an Attribute_Component from select clause for specific attribute
 java.util.Vector getAttributes(Relation rel)
          Get all attributes of one Relation of this View.
 java.util.Vector getClause(int type)
          Get clause from this view definition.
 java.util.Vector getComponents(Relation rel)
          Get all components of one Relation
 java.util.Vector getCondComponents(Attribute a)
          Get Condition_Component for specific Attribute.
 java.util.Vector getDispensableComponent()
          Get Dispensable components of one view defintion.
 java.lang.String getESQL()
          Get E-SQL of this view definition.
 java.util.Vector getISs()
          Return vector of ISs of this VD.
 java.lang.String getName()
          Return view name.
 java.util.Vector getPSJList(int type)
          Get PSJ List of this View Definition.
(package private)  Relation_Component getRelComponent(Relation r)
          Get Relation_Component for specific Relation.
 java.lang.String getSQL()
          Get SQL of this view definition without the IS information.
 java.util.Vector getVersions()
          return the vector of all versions of this view after view synchronization.
 int getVExtent()
           
 void makeStrongest()
           
 boolean replaceAttrSelect(Attribute attr, Attribute reattr)
          replace Attributes in Select Clause.
 boolean replaceAttrSelect(Relation r, Replacement rep, boolean di, boolean re)
          replace Attributes in Select clause.
 void replaceAttrWhere(Attribute attr, Attribute reattr)
          Replace attribute in the Where clause.
 boolean replaceCondWhere(Relation r, Replacement rep, boolean di, boolean re)
          replace Attributes in the condition in the Where clause.
 void replaceRelFrom(Relation r, Relation s)
          Replace relation at From clause.
 void setFrom(java.util.Vector clause)
          Set From clause
 void setName(java.lang.String str)
          Set View Definition's Name
 void setSelect(java.util.Vector clause)
          Set Select Clause
 void setVersions(java.util.Vector vs)
          Set a list of versions of rewritings of this View_Definition by VSA.
 void setVExtent(int ext)
          Set VE parameter of this View Definition
 void setWhere(Condition_index clause)
          Set Where clause
 java.lang.String toString()
          Debug Function show the View_Definition
(package private)  java.lang.String VExtentoStr(int ext)
          Return string representation of VExtent parameter
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG

versions

java.util.Vector versions
A Vector of Versions of this View-Definition. To be used for selecting a version out of some suggestions after a view synchronization.

SELECT

public static final int SELECT
SELECT here has two meaning. If it used in getClause() function, it means the select clause of view definition. If it used in getPSJList() function, it means the local_conditions in the where clause of view definition.

FROM

public static final int FROM
FROM clause constant

WHERE

public static final int WHERE
WHERE clause constant

PROJECT

public static final int PROJECT
PROJECT list constant

JOIN

public static final int JOIN
JOIN list constant

SUBSET

public static final int SUBSET
VE is SUBSET.

SUPERSET

public static final int SUPERSET
VE is SUPERSET

EQUIVALENT

public static final int EQUIVALENT
VE is EQUIVALENT

DONTCARE

public static final int DONTCARE
VE is DONTCARE

name

java.lang.String name
Name of this ViewDefinition.

VExtent

int VExtent
VE parameter of this View Definition

select

java.util.Vector select
it will keep the order of the select clause. It stores a vector of Attribute_Component

from

java.util.Vector from
Vector of FROM clause. The elements are objects of class Relation_Component.

where

Condition_index where
Vector of Condition clause. It's a list of conditions. Each elememt is an object of Condition_Component.
Constructor Detail

View_Definition

public View_Definition()
Default construction.

View_Definition

public View_Definition(java.lang.String ESQL,
                       MKB mkb)
Parse E-SQL/SQL String and create the View definition object.
Parameters:
ESQL - E-SQL/SQL of this view definition.
Method Detail

setVersions

public void setVersions(java.util.Vector vs)
Set a list of versions of rewritings of this View_Definition by VSA.
Parameters:
A - Vector of Version.

getVersions

public java.util.Vector getVersions()
return the vector of all versions of this view after view synchronization. This vector is updated from the outside, it's never changed from within this class.

clean

public void clean()
Clean the View Definition: 1. Clean the from clause to remove the useless relations that only appeared in Where clause. 2. It also clean the duplicate relations. 3. Clean the Where Clause JC conditions.

dropAttrSelect

public void dropAttrSelect(Relation r,
                           boolean di,
                           boolean re)
Drop Attributes from Select clause of this view definition.
Specified by:
dropAttrSelect in interface VSA_View_Definition
Parameters:
r - the attribute's relation
di - ESQL dispensable parameter
re - ESQL replaceable parameter

dropCondWhere

public void dropCondWhere(Relation r,
                          boolean di,
                          boolean re)
Drop Conditions from Where clause of this view definition.
Specified by:
dropCondWhere in interface VSA_View_Definition
Parameters:
r - the attribute's relation
di - ESQL dispensable parameter
re - ESQL replaceable parameter

replaceAttrSelect

public boolean replaceAttrSelect(Attribute attr,
                                 Attribute reattr)
replace Attributes in Select Clause.
Parameters:
attr - The Attribute to be replaced
reattr - The Substitute Attribute
Returns:
If replace successful (view evolvable) return true. That means for (f, t), all attributes can be replaced; otherwise, fail.

replaceAttrSelect

public boolean replaceAttrSelect(Relation r,
                                 Replacement rep,
                                 boolean di,
                                 boolean re)
replace Attributes in Select clause.
Specified by:
replaceAttrSelect in interface VSA_View_Definition
Parameters:
r - the attribute's relation.
rep - Replace ment of this relation with hashtable of substitute attributes.
di - ESQL dispensable parameter
re - ESQL replaceable parameter
Returns:
If replace successfull (view evolvable) return true. That means for (f,t), all attributes should be replaced, otherwise, fail.

replaceCondWhere

public boolean replaceCondWhere(Relation r,
                                Replacement rep,
                                boolean di,
                                boolean re)
replace Attributes in the condition in the Where clause.
Specified by:
replaceCondWhere in interface VSA_View_Definition
Parameters:
r - the attribute's relation.
rep - Replace ment of this relation with hashtable of substitute attributes.
di - ESQL dispensable parameter
re - ESQL replaceable parameter
Returns:
If replace successfull (view evolvable) return true. That means for (f,t), all attributes should be replaced, otherwise, fail.

attrSelect

public java.util.Vector attrSelect(Relation r,
                                   boolean di,
                                   boolean re)
Get Attributes in Select Clause.
Specified by:
attrSelect in interface VSA_View_Definition
Parameters:
r - the attribute's relation
di - ESQL dispensable parameter
re - ESQL replaceable parameter
Returns:
a Vector of attributes satisfied the specifications.

attrWhere

public java.util.Vector attrWhere(Relation r,
                                  boolean di,
                                  boolean re)
Get Attributes in Where Clause.
Specified by:
attrWhere in interface VSA_View_Definition
Parameters:
r - the attribute's relation
di - ESQL dispensable parameter
re - ESQL replaceable parameter
Returns:
a Vector of attributes satisfied the specifications.

VExtentoStr

java.lang.String VExtentoStr(int ext)
Return string representation of VExtent parameter

setName

public void setName(java.lang.String str)
Set View Definition's Name

setVExtent

public void setVExtent(int ext)
Set VE parameter of this View Definition

setSelect

public void setSelect(java.util.Vector clause)
Set Select Clause

setFrom

public void setFrom(java.util.Vector clause)
Set From clause

setWhere

public void setWhere(Condition_index clause)
Set Where clause

getESQL

public java.lang.String getESQL()
Get E-SQL of this view definition.
Returns:
E-SQL of this view definition.

getSQL

public java.lang.String getSQL()
Get SQL of this view definition without the IS information.
Returns:
SQL of this view definition.

getVExtent

public int getVExtent()

getClause

public java.util.Vector getClause(int type)
Get clause from this view definition.
Parameters:
type - type of clause. SELECT for SELECT clause, FROM for FROM clause, WHERE for WHERE clause. These are constants in this class.
Returns:
for type=SELECT: A vector of Attribute_Component.

getPSJList

public java.util.Vector getPSJList(int type)
Get PSJ List of this View Definition.
Parameters:
type - type of PSJ list. PROJECT for PROJECT list, SELECT for SELECT list, JOIN for JOIN list.
Returns:
a vector of PSJ list.

getName

public java.lang.String getName()
Return view name.

getISs

public java.util.Vector getISs()
Return vector of ISs of this VD. Return a vector of Information source names (in String format).

contains

public boolean contains(java.lang.String IS_name)
Descide whether VD contains some IS
Parameters:
IS_name - Information source name.
Returns:
true: VD has; false: VD hasn't

contains

public boolean contains(Relation rel)
Descide whether VD contains some Relation
Parameters:
IS_name - Information source name.
Rel_name - Relation name.
Returns:
true: VD has; false: VD hasn't

from_get

public Relation_Component from_get(Relation rel)
Get a Relation Component for specific Relation.
Parameters:
rel - the Relation
Returns:
if found, return RC reference, otherwise, null.

contains

public boolean contains(Attribute attr)
Descide whether VD contains some Attribute.
Parameters:
IS_name - Information source name.
Rel_name - Relation name.
Attr_name - Attribute name.
Returns:
true: VD has; false: VD hasn't.

toString

public java.lang.String toString()
Debug Function show the View_Definition
Overrides:
toString in class java.lang.Object

makeStrongest

public void makeStrongest()

evolvable

public boolean evolvable(Relation rel)
Check if this view is evolvable or not for a specific relation. It depends on theorem 1 in POC/SPOC paper. If this view is not evolvable, then all affected components are both indispensable and non-replaceable (false, false). We assume the View_Definition is in the strongest format.

evolvable

public boolean evolvable(Attribute attr)
Similar to evolvable for del_relation. Under same assumption, we only need to check the FROM clause.

clone

public java.lang.Object clone()
Clone the view definition. Need to be implemented.
Overrides:
clone in class java.lang.Object

replaceRelFrom

public void replaceRelFrom(Relation r,
                           Relation s)
Replace relation at From clause.
Specified by:
replaceRelFrom in interface VSA_View_Definition
Parameters:
r - relation to be replaced.
s - substitute relation.

dropComponents

public void dropComponents(java.util.Vector s)
Drop a vector of components from one view definition.
Specified by:
dropComponents in interface VSA_View_Definition

getDispensableComponent

public java.util.Vector getDispensableComponent()
Get Dispensable components of one view defintion.
Specified by:
getDispensableComponent in interface VSA_View_Definition

getRelComponent

Relation_Component getRelComponent(Relation r)
Get Relation_Component for specific Relation.
Parameters:
r - Reference of Relation in MKB
Returns:
Relation Component in FROM clause of View; null not found.

getCondComponents

public java.util.Vector getCondComponents(Attribute a)
Get Condition_Component for specific Attribute.
Parameters:
a - Reference of Attribute in MKB
Returns:
a vector of Condition_Component which contains the attribute.

getAttrComponent

public Attribute_Component getAttrComponent(Attribute attr)
Get an Attribute_Component from select clause for specific attribute
Parameters:
attr - The reference of attribute.
Returns:
the Attribute Component; not found return null

get

Attribute_Component get(java.util.Vector sec,
                        Attribute attr)
Get an Attribute Component from a vector of attribute_components clause for specific Attribute.
Parameters:
vec - the vector of Attribute Components.
attr - The reference of attribute.
Returns:
the Attribute Component; not found return null

dropAttrSelect

public void dropAttrSelect(java.util.Vector attrs)
Drop attribute-components from Select clause for specific vector of attributes
Parameters:
attrs - Vector of attributes

addRelFrom

public void addRelFrom(Relation r)
Add Relation to from clause of the View Definition.
Parameters:
r - Reference of relation to be added.

addJCs

public void addJCs(java.util.Vector jcs)
Add a Vector of JCs to the View Definition. Here I haven't considering the correctness of Join_Conditions. The default parameter for it is: true, true.
Parameters:
jcs - A Vector of Join Conditions

replaceAttrWhere

public void replaceAttrWhere(Attribute attr,
                             Attribute reattr)
Replace attribute in the Where clause.
Parameters:
attr - Attribute to be replaced.
reattr - Substitute Attribute.

getComponents

public java.util.Vector getComponents(Relation rel)
Get all components of one Relation
Parameters:
rel - the specific Relation.
Returns:
a Vector of components or a empty vector

getAttributes

public java.util.Vector getAttributes(Relation rel)
Get all attributes of one Relation of this View. It will contains all the attributes in the SELECT clause, and all the attributes in the JOIN Condition of the WHERE clause.
Parameters:
rel - the specific Relation.
Returns:
a Vector of unique attributes or a empty vector