KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > serversystem > dmlvalidation > constraintsystem > RestrictReferencedExecuter


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.dql.iterator.*;
7 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*;
8 import com.daffodilwoods.database.resource.*;
9 import com.daffodilwoods.database.utility.*;
10
11 /**
12  * Objective of the class is to check the matching row values in the child table
13  * when foreign constraint is specified with delete/update rule with action as
14  * RESTRICT. This method throws exception if child table has non-matching rows.
15  */

16 public class RestrictReferencedExecuter extends ReferencedExecuter {
17
18   /**
19    * Constructor : used to construct a new instance of foreign constraint with
20    * the given arguments.
21    * @param referencedConstraint Value of the Referenced Constraint Descriptor
22    * having the details of the referenced constraints
23    * @param globalSess instance of _ServerSession
24    * @throws DException
25    */

26   public RestrictReferencedExecuter( _ReferentialConstraint referencedConstraint, _ServerSession globalSess ) throws DException {
27     globalSession = globalSess;
28     setVariables( referencedConstraint );
29   }
30
31   /**
32    * The following method fires all the constraints which having delete/update rule
33    * restrict. This calls the private method to check if the cheild table having matching
34    * values.
35    */

36   public void checkReferencedConstraints( _StatementExecutionContext sec ) throws DException {
37     populateMatchingIterator();
38     for( int i=0; i<sub_superTable.size(); i++ )
39         matching_RESTRICT( i , sec );
40   }
41
42   /**
43    * The following method checks all rows from the iterator on child table having bve
44    * conditional columns as the referencing columns values from the child table and values
45    * same from the parent table. It throws exception if iterator having one or more rows.
46    * meaning, Parent table can not be updated, since refered by child table.
47    */

48   private void matching_RESTRICT( int tableIndex , _StatementExecutionContext sec ) throws DException {
49       ConstraintStore constraintStore = (ConstraintStore)matchingRowsPool.get(tableIndex) ;
50       RecordVersion recordVersion = sec.getRecordVersion();
51       _Iterator iterator = constraintStore.getIterator();
52       booleanvalueexpression bve = constraintStore.getCondition();
53       setParameterValues(iterator,bve,recordVersion.getPreviousRecord());
54       if( iterator == null || iterator.first() ) {
55          ;//// Removed By Program ** System.out.println(" ----------------------------------------------------------------------------------------- ");
56
P.showIterator( iterator );
57           throw new DException( "DSE1278",new Object JavaDoc[]{ referencedTable.getName() } );
58       }
59  }
60 }
61
Popular Tags