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.serversystem.*; 7 import com.daffodilwoods.database.resource.*; 8 9 10 22 23 24 public class ReferencedConstraints 25 { 26 BitSet bitSet = null; 27 BitSet universalBitSet = null; 28 int bitsetlength = 0; 29 ReferencedExecuter referencedExecuter; 30 boolean noAction; 31 32 33 46 47 public ReferencedConstraints( _ReferentialConstraint referencedConstraints , _DataDictionary dd , _ServerSession gSession , boolean deleteUpdate ) throws DException { 48 int type ; 49 int match = referencedConstraints.getMatch_Option(); 50 if( deleteUpdate ){ 51 type = referencedConstraints.getDelete_Rule() ; 52 if( type == TypeConstant.NO_ACTION ) 53 noAction = true ; 54 if( type == TypeConstant.CASCADE ) 55 referencedExecuter = new DeleteCascadeReferencedExecuter( referencedConstraints , gSession ); 56 else if( type == TypeConstant.SETNULL ) 57 referencedExecuter = new SetNullReferencedExecuter( referencedConstraints , gSession ); 58 else if ( type == TypeConstant.SETDEFAULT ) 59 referencedExecuter = new SetDefaultReferencedExecuter( referencedConstraints , gSession , dd ); 60 else if ( type == TypeConstant.RESTRICT ) 61 referencedExecuter = new RestrictReferencedExecuter( referencedConstraints , gSession ); 62 } 63 else { 64 type = referencedConstraints.getUpdate_Rule(); 65 if( type == TypeConstant.NO_ACTION ) 66 noAction = true ; 67 if( (match == TypeConstant.Match_Simple || match == TypeConstant.Match_Full) && type == TypeConstant.CASCADE ) 68 referencedExecuter = new UpdateSFCascadeReferencedExecuter( referencedConstraints , gSession ); 69 else if( type == TypeConstant.SETNULL ) 70 referencedExecuter = new SetNullReferencedExecuter( referencedConstraints , gSession ); 71 else if( type == TypeConstant.SETDEFAULT ) 72 referencedExecuter = new SetDefaultReferencedExecuter( referencedConstraints , gSession , dd ); 73 else if (type == TypeConstant.RESTRICT ) 74 referencedExecuter = new RestrictReferencedExecuter( referencedConstraints , gSession ); 75 else if( match == TypeConstant.Match_Partial && type == TypeConstant.CASCADE ) 76 referencedExecuter = new UpdatePartialCascadeReferencedExecuter( referencedConstraints , gSession ); 77 } 78 } 79 80 85 86 public void checkReferencedConstraints( _StatementExecutionContext sec ) throws DException { 87 if( noAction ) 88 return; 89 referencedExecuter.checkReferencedConstraints( sec ); 90 } 91 92 96 97 public void setBitSet( BitSet bs ) { 98 bitsetlength = bs.length(); 99 bitSet = bs; 100 universalBitSet = new BitSet(bs.length()); 101 } 102 103 108 109 public boolean fireDescriptor( int[] col ) { 110 BitSet gotBitSet = new BitSet(bitsetlength); 111 for( int i=0; i<col.length; i++ ) 112 gotBitSet.set(col[i]); 113 gotBitSet.and(bitSet); 114 return !(gotBitSet.equals(universalBitSet)); 115 } 116 117 118 119 127 } 128 | Popular Tags |