| 1 package com.daffodilwoods.daffodildb.server.serversystem.dmlvalidation.constraintsystem; 2 3 import java.util.*; 4 5 import com.daffodilwoods.daffodildb.server.datadictionarysystem.*; 6 import com.daffodilwoods.daffodildb.server.datasystem.utility._Record; 7 import com.daffodilwoods.daffodildb.server.serversystem.*; 8 import com.daffodilwoods.daffodildb.server.sql99.common.*; 9 import com.daffodilwoods.daffodildb.server.sql99.dql.execution.*; 10 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.*; 11 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*; 12 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 13 import com.daffodilwoods.database.general.*; 14 import com.daffodilwoods.database.resource.*; 15 16 17 29 30 31 public abstract class ReferencedExecuter { 32 33 ArrayList sub_superTable ; 34 ArrayList matchingRowsPool ; 35 booleanvalueexpression condition; 36 TableDetails tableDetails; 37 _ServerSession globalSession; 38 QualifiedIdentifier referencingTable , referencedTable ; 39 int type, match; 40 int[] referencedColumns , referencingColumns ; 41 42 48 public void populateMatchingIterator() throws DException { 49 if( matchingRowsPool.size() == 0 ) 50 for( int i=0; i<sub_superTable.size(); i++ ){ 51 _Iterator iterator = getIterator( condition ,(QualifiedIdentifier) sub_superTable.get(i) ) ; 52 ConstraintStore constraintStore = new ConstraintStore( iterator , referencingColumns , condition ); 53 matchingRowsPool.add(i,constraintStore ); 54 } 55 } 56 57 65 public _Iterator getIterator( booleanvalueexpression bve , QualifiedIdentifier tableName ) throws DException { 66 _SingleTableExecuter singleTE = new ConditionSingleTableExecuter( null , tableDetails , globalSession , bve , null ); 67 return globalSession.getIterator( tableName , singleTE ); 68 } 69 70 78 public void setParameterValues( _Iterator iterator , booleanvalueexpression condition, _Record previousRecord ) throws DException { 79 Object [] columnValues = null ; 80 columnValues = new Object [referencingColumns.length]; 81 for( int i=0; i<referencingColumns.length ; i++ ){ 82 Object value = previousRecord.getObject( referencedColumns[i]); 83 columnValues[i] = value ; 84 } 85 iterator.setConditionVariableValue( getReferences ((Object [])condition.getParameters(null)), columnValues , 1); 86 } 87 88 94 public _Reference[] getReferences(Object [] obj) throws DException { 95 int len = obj.length; 96 _Reference[] ref = new _Reference[len] ; 97 for( int i=0; i<len; i++ ) 98 ref[i] = (_Reference)obj[i] ; 99 return ref; 100 } 101 102 111 public _StatementExecutionContext getNewSEC( _StatementExecutionContext statementExecutionContext ) throws DException { 112 _StatementExecutionContext sss = new StatementExecutionContext(); 113 sss.setConstraintTypeDeferred( statementExecutionContext.isConstraintCheckedForDefferable() ); 114 sss.setRecordVersion( statementExecutionContext.getRecordVersion() ); 115 sss.setServerSession( statementExecutionContext.getServerSession() ); 116 sss.setServerSystem( statementExecutionContext.getServerSystem() ); 117 sss.setUserSession( statementExecutionContext.getUserSession() ); 118 return sss; 119 } 120 121 129 public void setVariables(_ReferentialConstraint referencedConstraints ) throws DException { 130 referencedColumns = referencedConstraints.getReferencedColumns(); 131 referencingColumns = referencedConstraints.getReferencingColumns(); 132 match = referencedConstraints.getMatch_Option() ; 133 referencingTable = referencedConstraints.getReferencingTable(); 134 referencedTable = referencedConstraints.getReferencedTable(); 135 tableDetails = new TableDetails(); 136 sub_superTable = referencedConstraints.getSub_SuperTables(); 137 tableDetails.setTableName(new String []{referencingTable.catalog,referencingTable.schema,referencingTable.name}); 138 condition = referencedConstraints.getMatchingRowsBVE(false); 139 tableDetails.cc = globalSession.getColumnCharacteristics(tableDetails.getQualifiedIdentifier()); 140 SetColumnProperties.setTableNamesAndDatatypesOfAllColumns(globalSession,condition.getColumnDetails(),new TableDetails[]{tableDetails},null,new ArrayList()); 141 matchingRowsPool = new ArrayList(); 142 } 143 144 145 151 public abstract void checkReferencedConstraints( _StatementExecutionContext sec ) throws DException ; 152 153 } 154 | Popular Tags |