uk.ac.bbk.dcs.automed.evolution.schemaEvolution
Class DataSourceSchemaEvolution

java.lang.Object
  extended by uk.ac.bbk.dcs.automed.evolution.schemaEvolution.SchemaEvolution
      extended by uk.ac.bbk.dcs.automed.evolution.schemaEvolution.DataSourceSchemaEvolution
All Implemented Interfaces:
EvolutionInterface

public class DataSourceSchemaEvolution
extends SchemaEvolution

Class that handles the evolution of a data source schema.

Author:
Lucas Zamboulis, Dheeraj Mudgil

Field Summary
protected  java.lang.Object domainKnowledge
           
protected  Schema newDerivedSchema
           
protected  boolean newDerivedSchemaCreated
           
private static java.lang.String QUERY_EXTEND_CONTRACT1
           
private static java.lang.String QUERY_EXTEND_CONTRACT2
           
protected  boolean removeDescendants
          If true, Range Void Any descendants are to be removed from union and/or derived schema
protected  boolean removeOldPathway
          If true, old pathway is to be removed
 
Fields inherited from class uk.ac.bbk.dcs.automed.evolution.schemaEvolution.SchemaEvolution
dataSourceSchemas, derivedSchema, EVOLUTION_TYPE_SCHEMA_AND_DATA, EVOLUTION_TYPE_SCHEMA_ONLY, evolutionPathway, evolutionType, EVOLVED_SCHEMA_TYPE_DATASOURCE, EVOLVED_SCHEMA_TYPE_DERIVED, evolvedSchemaType, logger, pathwaysToUnionSchemas, pathwayToDerivedSchema, unionSchemas
 
Constructor Summary
protected DataSourceSchemaEvolution()
           
 
Method Summary
static boolean canBeRemoved(SchemaObject so, Schema source, Schema[] targets)
           
static boolean compare(java.util.Set constructsToMatch, ASG g)
          This method compares a set of constructs one by one with the Cell object of AutoMed.
static boolean compare(java.lang.String schemeString, Cell c)
           
private  java.util.Set descendants(SchemaObject so, int indexOfOrigEvolvedSchema)
          Gets the descendant constructs in the derived schema.
private  java.util.Set getDescendantsToRemove(java.util.Set descendants)
           
protected  Schema getNewDerivedSchema()
           
protected  boolean getNewDerivedSchemaCreated()
           
private  int indexOfMatchingTransformation(Transformation[] ts, Transformation t)
           
 void processContractTransformation(Transformation t)
          Processes a contract transformation
 void processExtendTransformation(Transformation t)
          Processes an extend transformation
private  SchemaObject[] sortDescendantsToRemove(java.util.Set descendantsToRemove)
           
 
Methods inherited from class uk.ac.bbk.dcs.automed.evolution.schemaEvolution.SchemaEvolution
getDataSourceSchemas, getDerivedSchema, getEvolutionPathway, getEvolutionType, getEvolvedSchemaType, getPathwaysToUnionSchemas, getPathwayToDerivedSchema, processAddTransformation, processDataSourceSchemaEvolution, processDeleteTransformation, processDerivedSchemaEvolution, processEvolution, processIdentTransformation, processNewPathways, processRenameTransformation, setPathwayToDerivedSchema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUERY_EXTEND_CONTRACT1

private static final java.lang.String QUERY_EXTEND_CONTRACT1
See Also:
Constant Field Values

QUERY_EXTEND_CONTRACT2

private static final java.lang.String QUERY_EXTEND_CONTRACT2
See Also:
Constant Field Values

removeDescendants

protected boolean removeDescendants
If true, Range Void Any descendants are to be removed from union and/or derived schema


removeOldPathway

protected boolean removeOldPathway
If true, old pathway is to be removed


domainKnowledge

protected java.lang.Object domainKnowledge

newDerivedSchemaCreated

protected boolean newDerivedSchemaCreated

newDerivedSchema

protected Schema newDerivedSchema
Constructor Detail

DataSourceSchemaEvolution

protected DataSourceSchemaEvolution()
Method Detail

processExtendTransformation

public void processExtendTransformation(Transformation t)
Description copied from class: SchemaEvolution
Processes an extend transformation

Overrides:
processExtendTransformation in class SchemaEvolution
Parameters:
t - transformation to process

indexOfMatchingTransformation

private int indexOfMatchingTransformation(Transformation[] ts,
                                          Transformation t)
                                   throws EvolutionException
Parameters:
ts - input pathway in the form of an array of transformations
t - a transformation in ts
Returns:
a 'matching' transformtion, i.e. one that is about the same schema object and is of the inverse action type of t
Throws:
EvolutionException - if ts contains no matching transformation of t, or if t is not a contract transformation

processContractTransformation

public void processContractTransformation(Transformation t)
                                   throws EvolutionException
Description copied from class: SchemaEvolution
Processes a contract transformation

Overrides:
processContractTransformation in class SchemaEvolution
Parameters:
t - transformation to process
Throws:
EvolutionException

descendants

private java.util.Set descendants(SchemaObject so,
                                  int indexOfOrigEvolvedSchema)
                           throws EvolutionException
Gets the descendant constructs in the derived schema. Since the union schemas are assumed to be virtual, there is no need to check the descendant schema constructs in the union schema.

Parameters:
so - input schema object
indexOfOrigEvolvedSchema - the index in dataSourceSchemas of the schema that has undergone evolution
Returns:
set the constructs of s2 that are descendants of so
Throws:
EvolutionException - thrown if a problem is encountered during the search for descendants

compare

public static boolean compare(java.util.Set constructsToMatch,
                              ASG g)
This method compares a set of constructs one by one with the Cell object of AutoMed.

Parameters:
Set - All constructs that needed to be searched.
c - cell Object
Returns:
boolean True, if the match is found else false.

compare

public static boolean compare(java.lang.String schemeString,
                              Cell c)
Parameters:
toMatch - string to match with the Cell.
c - current Cell
Returns:
boolean true if the schema object is

getDescendantsToRemove

private java.util.Set getDescendantsToRemove(java.util.Set descendants)
                                      throws EvolutionException
Parameters:
descendants - set of constructs affected by the evolution of the data source schema
Returns:
Set constructs that have been found to always reformulate/evaluate to QUERY_EXTEND_CONTRACT1 or QUERY_EXTEND_CONTRACT2 and so could be contracted from derived schema
Throws:
EvolutionException

canBeRemoved

public static boolean canBeRemoved(SchemaObject so,
                                   Schema source,
                                   Schema[] targets)
                            throws EvolutionException
Parameters:
so - constr
source - source schema
target - target schema
Returns:
true is so evaluates to QUERY_EXTEND_CONTRACT, when submitted as query to s and evaluated against t - dynamic checking through QueryProcessor
Throws:
EvolutionException - thrown if parsing or query processing problem occurs

sortDescendantsToRemove

private SchemaObject[] sortDescendantsToRemove(java.util.Set descendantsToRemove)
Parameters:
descendantsToRemove - the constructs that can be removed from the derived schema
Returns:
the input set, sorted so that link constructs are removed before link-nodal constructs, which in turn should be removed before nodal constructs - all this is to ensure schema integrity

getNewDerivedSchemaCreated

protected boolean getNewDerivedSchemaCreated()

getNewDerivedSchema

protected Schema getNewDerivedSchema()