1 package com.daffodilwoods.daffodildb.server.serversystem.dmlvalidation.constraintsystem; 2 3 import com.daffodilwoods.daffodildb.server.datadictionarysystem.*; 4 import com.daffodilwoods.daffodildb.server.datasystem.utility.*; 5 import com.daffodilwoods.daffodildb.server.serversystem.*; 6 import com.daffodilwoods.daffodildb.server.sql99.ddl.schemadefinition.*; 7 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.*; 8 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*; 9 import com.daffodilwoods.daffodildb.utils.field.*; 10 import com.daffodilwoods.database.general.*; 11 import com.daffodilwoods.database.resource.*; 12 13 18 19 public class SetDefaultReferencedExecuter extends ReferencedExecuter { 20 21 _DataDictionary dataDictionary; 22 23 32 public SetDefaultReferencedExecuter( _ReferentialConstraint referencedConstraint, _ServerSession globalSess , _DataDictionary dd ) throws DException { 33 globalSession = globalSess; 34 setVariables( referencedConstraint ); 35 dataDictionary = dd; 36 } 37 38 43 public void checkReferencedConstraints( _StatementExecutionContext sec ) throws DException { 44 populateMatchingIterator(); 45 for( int i=0; i< matchingRowsPool.size(); i++ ) 46 matching_SETDEFAULT( i , sec ); 47 } 48 49 54 private void matching_SETDEFAULT( int tableIndex , _StatementExecutionContext statementExecutionContext ) throws DException { 55 ConstraintStore constraintStore = (ConstraintStore)matchingRowsPool.get(tableIndex); 56 RecordVersion recordVersion = statementExecutionContext.getRecordVersion(); 57 _Iterator iterator = constraintStore.getIterator(); 58 booleanvalueexpression bve = constraintStore.getCondition(); 59 setParameterValues( iterator , bve , recordVersion.getPreviousRecord()); 60 defaultoption defaultExpression = null ; 61 Object [] value = new Object [referencingColumns.length]; 62 if( iterator.last() ){ 63 _ServerTable serverTable = statementExecutionContext.getServerTable( (QualifiedIdentifier)sub_superTable.get(tableIndex) ); 64 do { 65 for(int j=0 ; j< referencingColumns.length ; j++){ 66 defaultExpression = dataDictionary.getDefaultValueGetter( (QualifiedIdentifier)sub_superTable.get(tableIndex) ).getDefaultValueExpression(referencingColumns[j]); 67 try { 68 value[j] = ((FieldBase) defaultExpression.run(globalSession )).getObject(); 69 } catch( Exception e ) {} 70 } 71 serverTable.update( iterator , referencingColumns , value , statementExecutionContext ); 72 } while ( iterator.previous() ) ; 73 } 74 } 75 } 76 | Popular Tags |