easik.sketch.util.Export.Constraints
Class ExportPullback

java.lang.Object
  extended by easik.sketch.util.Export.Constraints.ExportConstraint
      extended by easik.sketch.util.Export.Constraints.ExportPullback

public class ExportPullback
extends ExportConstraint

A class to create a pullback constraint object, including all necessary information gleaned from the XML file. Should not be used for any other purpose than database exportation, as it contains no graphical information.

Since:
2006-05-22 Vera Ranieri
Version:
2006-08-28 Kevin Green
Author:
Vera Ranieri 2006, Kevin Green 2006

Field Summary
private  java.lang.String _targetTable
          The codomain of the paths in the pullback
private static java.lang.String PULL_A_INS_PROC_NAME
          The name of the after insert procedure for the pullback
private static java.lang.String PULL_DEL_PROC_NAME
          The name of the delete procedure for the pullback
 
Fields inherited from class easik.sketch.util.Export.Constraints.ExportConstraint
_a_i_tables, _b_d_tables, _b_i_tables, _baseTable, _db_name, _id, _paths, _procedureStrings
 
Constructor Summary
ExportPullback(int id)
          Constructor calling the constructor of the ExportConstraint superclass
 
Method Summary
private  java.lang.String getAllTablesInPullback()
          Returns a list of all names of tables in the pullback, separated by commas.
private  java.lang.String getAltPathConditions(ExportPath alt, ExportPath main)
          Gets the alternate path conditions for testing whether a pullback condition is formed.
private  java.lang.String getBeforeIfStatement()
          Gets the statements to determine whether the entry is a valid pullback entry.
private  java.lang.String getDeleteString()
          Gets the delete string for SQL deleting from the codomain of the pullback constraint, the element which is the codomain of the element being deleted from the domain.
private  java.lang.String getFinalInsertStatements(ExportPath path)
          Determines the INSERT statements necessary for the procedure called AFTER INSERT on the domain of path.
private  java.lang.String getIfStatement(ExportPath main, ExportPath alt)
          Gets the IF THEN SQL statement for this procedure.
private  java.lang.String getSecondIfStatement(ExportPath main, ExportPath alt)
          Gets the main path conditions to determine whether the pullback table contains elements along the path for every element in the alternate table which leads to the same element as the main table.
private  java.lang.String getSelectIntoStatement(ExportPath path, int p)
          Creates an INSERT INTO ...
private  java.lang.String getSelectStatement(ExportPath p)
          Determines the conditions required for an insert into the pullback table AFTER INSERT into the table for which the procedure is being called.
private  java.lang.String getSubConditions(ExportPath path)
          Gets the conditions for the insert, given the path, minus the initial conditions.
private  java.lang.String getTestForDuplicateStatement()
          Gets the string that determines whether the pullback has a duplicate entry.
private  void setAfterInsertProcs()
          Sets the procedures to be called AFTER INSERT on the tables which form the codomains of the first and third paths.
private  void setAIForTable(ExportPath mainP, ExportPath subP)
          Sets AFTER INSERT procedure for the table which is the domain of path mainP.
 void setBaseTable()
          Sets the base table of this constraint.
private  void setBeforeDeleteProcs()
          Sets the procedure to be called BEFORE DELETE on the domain of the pullback constraint.
 void setConstraintStrings()
          Sets all constraint strings for this constraint.
private  void setPullbackInsertProcs()
          Sets the procedure to be called BEFORE INSERT on the pull back table (that is, the base table) of this constraint.
 void setTargetTable()
          Sets the target table of this constraint.
 
Methods inherited from class easik.sketch.util.Export.Constraints.ExportConstraint
addPath, getBaseTable, getConstraintStrings, getPaths, getTimeNames, set_db_name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PULL_DEL_PROC_NAME

private static final java.lang.String PULL_DEL_PROC_NAME
The name of the delete procedure for the pullback

See Also:
Constant Field Values

PULL_A_INS_PROC_NAME

private static final java.lang.String PULL_A_INS_PROC_NAME
The name of the after insert procedure for the pullback

See Also:
Constant Field Values

_targetTable

private java.lang.String _targetTable
The codomain of the paths in the pullback

Constructor Detail

ExportPullback

public ExportPullback(int id)
Constructor calling the constructor of the ExportConstraint superclass

Parameters:
id - A unique id to identify this constraint from all others
Method Detail

setBaseTable

public void setBaseTable()
Sets the base table of this constraint. This base table is the domain of the two paths which form this constraint.

Overrides:
setBaseTable in class ExportConstraint

setTargetTable

public void setTargetTable()
Sets the target table of this constraint. This target table is the codomain of the two paths which form this constraint.

Overrides:
setTargetTable in class ExportConstraint

setConstraintStrings

public void setConstraintStrings()
Sets all constraint strings for this constraint.

Overrides:
setConstraintStrings in class ExportConstraint
Since:
2006-06-22 Vera Ranieri

setPullbackInsertProcs

private void setPullbackInsertProcs()
Sets the procedure to be called BEFORE INSERT on the pull back table (that is, the base table) of this constraint. This procedure ensures that any insert into the pullback table conforms to the pullback conditions.

Since:
2007-07-11 Vera Ranieri

getBeforeIfStatement

private java.lang.String getBeforeIfStatement()
Gets the statements to determine whether the entry is a valid pullback entry. If this is not the case, the procedure will fail

Returns:
The SQL statement to test for the pull back condition
Since:
2006-07-14 Vera Ranieri

getSelectIntoStatement

private java.lang.String getSelectIntoStatement(ExportPath path,
                                                int p)
Creates an INSERT INTO ... SELECT statement to insert into tables along a path

Parameters:
path - The path for which this insert statement is being called.
p - The index of the opposite path in the pullback
Returns:
The string of the insert into the pullback table
Since:
2006-07-14 Vera Ranieri

getTestForDuplicateStatement

private java.lang.String getTestForDuplicateStatement()
Gets the string that determines whether the pullback has a duplicate entry.

Returns:
The string of this test statement, formatted for SQL
Since:
2006-07-14 Vera Ranieri

setAfterInsertProcs

private void setAfterInsertProcs()
Sets the procedures to be called AFTER INSERT on the tables which form the codomains of the first and third paths.

Since:
006-07-07 Vera Ranieri

setAIForTable

private void setAIForTable(ExportPath mainP,
                           ExportPath subP)
Sets AFTER INSERT procedure for the table which is the domain of path mainP.

Parameters:
mainP - The path which has the table as its domain for which we want to set the procedure.
subP - The opposite path which has the same codomain as mainP
Since:
2006-07-07 Vera Ranieri

getIfStatement

private java.lang.String getIfStatement(ExportPath main,
                                        ExportPath alt)
Gets the IF THEN SQL statement for this procedure. This IF statement checks whether the path leading from the opposing path contains elements which lead to the same element as the path given, in the target table.
If this case is determined to be true, a second IF statement determines whether the base table already contains elements which link to these elements. If it does not, elements are added along the path leading to the opposing path table.
Elements are then added along the path into the original path table. Finally, the required elements are added to the pullback (base) table.
Should the inital case be determined to be false, then nothing will occur when the SQL statement is executed.

Parameters:
main - The path for which the procedure is being called
alt - The path opposing path for this procedure
Returns:
The string of the IF statement. This string is the body of the procedure.
Since:
2006-07-10 Vera Ranieri

getAltPathConditions

private java.lang.String getAltPathConditions(ExportPath alt,
                                              ExportPath main)
Gets the alternate path conditions for testing whether a pullback condition is formed. This is acheived by determining the conditions needed to determine if a match exists in the target table of the pullback.
Initially, the path is followed from the main path (i.e. the path for which this procedure is being called) to the target table. The path is then followed from the alternate path (i.e. the path which has as its codomain the same codomain as the main path) to see if a match occurs.

Parameters:
alt - The path which does not contain the table for which the procedure is being called.
main - The path which contains the table to which the procedure is being called.
Returns:
The string of the conditions to determine whether a match occurs.
Since:
2007-07-10 Vera Ranieri

getSecondIfStatement

private java.lang.String getSecondIfStatement(ExportPath main,
                                              ExportPath alt)
Gets the main path conditions to determine whether the pullback table contains elements along the path for every element in the alternate table which leads to the same element as the main table.
Should these elements not be yet present in the pullback table, elements are added in the path for every element in the alternate table.
This second IF statement ensures that elements along the opposite path of the pullback are not added until a match is formed in the pullback. If these elements have already been added (as by an earlier addition into the domain of the main path) nothing will occur when the SQL statement is executed.

Parameters:
alt - The path which does not contain the table for which the procedure is being called.
main - The path which contains the table to which the procedure is being called.
Returns:
The string of the second IF statement, described above.
Since:
2006-07-10 Vera Ranieri

getFinalInsertStatements

private java.lang.String getFinalInsertStatements(ExportPath path)
Determines the INSERT statements necessary for the procedure called AFTER INSERT on the domain of path. This includes inserting elements into any tables which are on the path leading from the base table of the pullback to the domain of path.
If inserts are necessary along that path, they are made prior to any inserts made into the pullback table.

Parameters:
path - The path which has, as its domain, the table for which the procedure is being called.
Returns:
The string of the INSERT statements.
Since:
2007-07-11 Vera Ranieri

getSelectStatement

private java.lang.String getSelectStatement(ExportPath p)
Determines the conditions required for an insert into the pullback table AFTER INSERT into the table for which the procedure is being called.
This table is the domain of path p. It is noted so that the reference to the parameter id can be made within the conditions stated.

Parameters:
p - The path for which the select statement must be determined.
Returns:
The string of the select statement
Since:
2006-07-07 Vera Ranieri

getSubConditions

private java.lang.String getSubConditions(ExportPath path)
Gets the conditions for the insert, given the path, minus the initial conditions. Separate from the getCondtions static method in ExportPath to ensure that initial conditions are not included.

Parameters:
path - The path for which we need the conditions.
Returns:
The string of the condtions.
Since:
2006-07-07 Vera Ranieri

setBeforeDeleteProcs

private void setBeforeDeleteProcs()
Sets the procedure to be called BEFORE DELETE on the domain of the pullback constraint.

Since:
2006-07-04 Vera Ranieri

getDeleteString

private java.lang.String getDeleteString()
Gets the delete string for SQL deleting from the codomain of the pullback constraint, the element which is the codomain of the element being deleted from the domain.

Returns:
The string formatted for SQL.
Since:
2006-07-04 Vera Ranieri

getAllTablesInPullback

private java.lang.String getAllTablesInPullback()
Returns a list of all names of tables in the pullback, separated by commas.

Returns:
The string of all the tables.
Since:
2007-07-11 Vera Ranieri