KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
7 import com.daffodilwoods.daffodildb.server.datasystem.utility._Record;
8 import com.daffodilwoods.daffodildb.server.serversystem.*;
9 import com.daffodilwoods.daffodildb.server.sessionsystem.*;
10 import com.daffodilwoods.daffodildb.server.sql99.common.*;
11 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.*;
12 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*;
13 import com.daffodilwoods.daffodildb.server.sql99.utils.*;
14 import com.daffodilwoods.daffodildb.utils.field.*;
15 import com.daffodilwoods.database.general.*;
16 import com.daffodilwoods.database.resource.*;
17 import com.daffodilwoods.database.utility.*;
18 import com.daffodilwoods.daffodildb.utils.comparator.*;
19 import java.text.*;
20 import com.daffodilwoods.daffodildb.utils.*;
21 import com.daffodilwoods.daffodildb.server.datasystem.indexsystem.*;
22 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*;
23
24
25 /**
26  *
27  * <p>Title: Primary And Unique Constraints Verifier</p>
28  * <p>Description: </p>
29 * <p>Description: Objective of the class is to verify all the primary and unique constraints
30  * that have been applied on the table.
31  * */

32
33 public class PrimaryAndUniqueConstraintVerifier {
34   _PrimaryAndUniqueConstraintCharacteristics primarAndUniqueConstraintCharacteristics;
35   QualifiedIdentifier tableName;
36   boolean deferrable;
37   ConstraintStore primaryConstraintStore = null ;
38   TableDetails tableDetails ;
39   ColumnDetails[] columnDetails;
40   boolean checkedPrimary = false;
41   boolean checkedUnique = false;
42   HashMap uniqueIterator;
43   _ColumnCharacteristics cc;
44
45
46   /**
47    * used to construct a new instance of primary and unique constraint verifier with the given arguments.
48    * @param primarAndUniqueCharacteristics instance of _primaryanduniqueconstraintcharacteristics
49    * used to retreive the primary and unique constraints that have been applied on the table.
50    * @param tName name of the table.
51    * @param deff boolean used to determine whether the constraints are deferred type or not.
52    * @throws DException
53    */

54
55   public PrimaryAndUniqueConstraintVerifier(_PrimaryAndUniqueConstraintCharacteristics primarAndUniqueCharacteristics, QualifiedIdentifier tName , boolean deff ) throws DException {
56     primarAndUniqueConstraintCharacteristics = primarAndUniqueCharacteristics;
57     tableName = tName;
58     deferrable = deff ;
59     uniqueIterator = new HashMap();
60     tableDetails = new TableDetails();
61     tableDetails.setTableName(new String JavaDoc[]{tableName.catalog,tableName.schema,tableName.name});
62   }
63
64   /**
65    * verifies the Primary Constraints the by passing the call to verifyUniqueness,
66    * and throws exception accordingly if needed.
67    * @param columns columns for which the constraints are verified.
68    * @param sec instance of statementexecutioncontext
69    * @param globalSession instance of serversession.
70    * @throws DException
71    */

72
73   public synchronized void verifyPrimaryConstraints( int[] columns , _StatementExecutionContext sec , _ServerSession globalSession) throws DException{
74        if( primaryConstraintStore == null ){ // If iterator pool is empty
75
_UniqueConstraint p = null ; // generating it
76
if( !checkedPrimary ){
77            p = primarAndUniqueConstraintCharacteristics.getPrimaryConstraints() ;
78            checkedPrimary = true;
79          }
80          if( p == null ){
81            return ;
82          }
83          tableDetails.cc = globalSession.getColumnCharacteristics(tableDetails.getQualifiedIdentifier());
84          cc = sec.getColumnCharacteristics(tableName) ;
85          generateIteratorForPrimary( p , globalSession );
86        } // Generation of iterator
87
if(!deferrable){ // Constraints are immediate
88
ConstraintInformation constraintInformation = getConstraintInformation(sec.getUserSession()) ;
89          ArrayList immToDeff = constraintInformation.getImmediateToDefferedConstraints( tableName );
90          if( sec.getOperationTypeSameOrOpposite() ){ // Verifier is called fsor Table A
91
if( immToDeff == null )
92              fireConstraintsForPrimary(sec.getRecordVersion() );
93          }
94          else { // Verifier is called for Table B
95
if( immToDeff != null ){
96              String JavaDoc Cname;
97              for( int j=0; j<immToDeff.size(); j++ ){
98                Cname = (String JavaDoc) immToDeff.get(j);
99                if( primaryConstraintStore.constraintName.equalsIgnoreCase(Cname) )
100                  fireConstraintsForPrimary( sec.getRecordVersion() );
101              }
102            }
103          }
104        }
105        else { // Constraints are Deffered
106
ConstraintInformation constraintInformation = getConstraintInformation(sec.getUserSession()) ;
107          ArrayList deffToImm = constraintInformation.getDefferedToImmediateConstraints( tableName );
108          if(sec.getOperationTypeSameOrOpposite()){ // Verifier is called for Table B
109
if(deffToImm == null)
110              fireConstraintsForPrimary(sec.getRecordVersion() );
111            else{
112              if(!deffToImm.contains(primaryConstraintStore.constraintName))
113                fireConstraintsForPrimary(sec.getRecordVersion() );
114            }
115          }
116          else{ // Verifier is called for Table A
117
if(deffToImm!=null){
118              String JavaDoc cname = null;
119              for (int i = 0; i < deffToImm.size(); i++) {
120                cname = (String JavaDoc)deffToImm.get(i);
121                if(primaryConstraintStore.constraintName.equalsIgnoreCase(cname))
122                  fireConstraintsForPrimary(sec.getRecordVersion() );
123              }
124           }
125          }
126        }
127   }
128
129   /**
130    * verifies the Unique Constraints the by passing the call to verifyUniqueness,
131    * and throws exception accordingly if needed.
132    * @param columns columns for which the constraints are verified.
133    * @param sec instance of statementexecutioncontext
134    * @param globalSession instance of serversession.
135    * @throws DException
136    */

137
138
139   public synchronized void verifyUniqueConstraints( int[] columns , _StatementExecutionContext sec , _ServerSession globalSession) throws DException {
140         if( uniqueIterator.size() == 0 ){
141           _UniqueConstraint[] u = null ;
142           if( !checkedUnique ){
143             u = primarAndUniqueConstraintCharacteristics.getUniqueConstraints() ;
144             checkedUnique = true ;
145           }
146           if( u == null ){
147             return ;
148           }
149           tableDetails.cc = globalSession.getColumnCharacteristics(tableDetails.getQualifiedIdentifier());
150           cc = sec.getColumnCharacteristics(tableName) ;
151           generateIterators( u , globalSession );
152         }
153         ConstraintInformation constraintInformation = getConstraintInformation(sec.getUserSession()) ;
154         if(!deferrable){
155           ArrayList immToDeff = constraintInformation.getImmediateToDefferedConstraints( tableName );
156
157           if( sec.getOperationTypeSameOrOpposite() ){
158             if( immToDeff == null )
159               fireAllConstraints(sec.getRecordVersion());
160             else {
161               ArrayList constraintsToFire = getRequiredConstraintsToFire( immToDeff );
162               for( int i=0; i<constraintsToFire.size(); i++ )
163                 fireThisConstraint( (ConstraintStore)constraintsToFire.get(i) , sec.getRecordVersion());
164             }
165           }
166           else {
167             if( immToDeff != null ){
168               String JavaDoc Cname = null;
169               for( int j=0; j<immToDeff.size(); j++ ){
170                 Cname = (String JavaDoc) immToDeff.get(j);
171                 if( uniqueIterator.containsKey(Cname) )
172                   fireThisConstraint( (ConstraintStore)uniqueIterator.get(Cname) , sec.getRecordVersion() );
173               }
174             }
175           }
176           return;
177         }
178         else {
179           ArrayList deffToImm = constraintInformation.getDefferedToImmediateConstraints( tableName );
180
181           ArrayList constraintsToFire = null;
182           if( sec.getOperationTypeSameOrOpposite() ){
183             if( deffToImm == null )
184               fireAllConstraints(sec.getRecordVersion());
185             else {
186               constraintsToFire = getRequiredConstraintsToFire( deffToImm );
187               for( int i=0; i<constraintsToFire.size(); i++ )
188                 fireThisConstraint( (ConstraintStore)constraintsToFire.get(i) , sec.getRecordVersion() );
189             }
190           }
191           else
192           {
193             if( deffToImm != null ){
194               String JavaDoc Cname = null;
195               for( int j=0; j<deffToImm.size(); j++ ){
196                 Cname = (String JavaDoc) deffToImm.get(j);
197                 if( uniqueIterator.containsKey(Cname) )
198                   fireThisConstraint( (ConstraintStore)uniqueIterator.get(Cname) , sec.getRecordVersion() );
199               }
200             }
201           }
202         }
203   }
204
205
206   /**
207    * This method is used to check the unique constraints if any update is fired on the table.
208    */

209
210   public synchronized void verifyUniqueConstraintsForUpdate( int[] columns , _StatementExecutionContext sec , _ServerSession globalSession) throws DException {
211        if( uniqueIterator.size() == 0 ){
212          _UniqueConstraint[] u = null;
213          if( !checkedUnique ){
214            u = primarAndUniqueConstraintCharacteristics.getUniqueConstraints() ;
215            checkedUnique = true;
216          }
217          if( u == null){
218            return ;
219          }
220          tableDetails.cc = globalSession.getColumnCharacteristics(tableDetails.getQualifiedIdentifier());
221          _ColumnCharacteristics cc = sec.getColumnCharacteristics(tableName) ;
222          generateIterators( u , globalSession );
223        }
224
225        ConstraintInformation constraintInformation = getConstraintInformation(sec.getUserSession()) ;
226        if(!deferrable){
227          ArrayList immToDeff = constraintInformation.getImmediateToDefferedConstraints( tableName );
228
229          if( sec.getOperationTypeSameOrOpposite() ){
230            if( immToDeff == null )
231              fireAllConstraints(sec.getRecordVersion(),columns);
232            else {
233              ArrayList constraintsToFire = getRequiredConstraintsToFire( immToDeff );
234              for( int i=0; i<constraintsToFire.size(); i++ )
235                fireThisConstraint( (ConstraintStore)constraintsToFire.get(i) , sec.getRecordVersion(),columns);
236            }
237          }
238          else {
239            if( immToDeff != null ){
240              String JavaDoc Cname = null;
241              for( int j=0; j<immToDeff.size(); j++ ){
242                Cname = (String JavaDoc) immToDeff.get(j);
243                if( uniqueIterator.containsKey(Cname) )
244                  fireThisConstraint( (ConstraintStore)uniqueIterator.get(Cname) , sec.getRecordVersion(), columns );
245              }
246            }
247          }
248          return;
249        }
250        else {
251          ArrayList deffToImm = constraintInformation.getDefferedToImmediateConstraints( tableName );
252
253          ArrayList constraintsToFire = null;
254          if( sec.getOperationTypeSameOrOpposite() ){
255            if( deffToImm == null )
256              fireAllConstraints(sec.getRecordVersion(),columns);
257            else {
258              constraintsToFire = getRequiredConstraintsToFire( deffToImm );
259              for( int i=0; i<constraintsToFire.size(); i++ )
260                fireThisConstraint( (ConstraintStore)constraintsToFire.get(i) , sec.getRecordVersion(), columns );
261            }
262          }
263          else
264          {
265            if( deffToImm != null ){
266              String JavaDoc Cname = null;
267              for( int j=0; j<deffToImm.size(); j++ ){
268                Cname = (String JavaDoc) deffToImm.get(j);
269                if( uniqueIterator.containsKey(Cname) )
270                  fireThisConstraint( (ConstraintStore)uniqueIterator.get(Cname) , sec.getRecordVersion(),columns );
271              }
272            }
273          }
274        }
275   }
276
277   /**
278    * Verify Uniqueness of the entries by checking the no of entries in the iterator for the unique columns.
279    * @param constraintStore instance of constraint store to get the iterator.
280    * @param recordVersion instance of recordVersion to get the current record.
281    * @param serverSession instance of server session.
282    * @throws DException
283    */

284
285
286
287   private synchronized void verifyUniqueness( ConstraintStore constraintStore, RecordVersion recordVersion ) throws DException {
288         Object JavaDoc[] parameters = getParameters( constraintStore.columns , recordVersion.getCurrentRecord() );
289         _Iterator iterator = constraintStore.getIterator() ;
290         Object JavaDoc lastKey = constraintStore.getLastKey() ;
291       try {
292          if (lastKey == null || ( (_IndexIteratorInfo) iterator).getComparator().compare(parameters, lastKey) > 0) {
293             constraintStore.setLastKey(parameters);
294             return;
295          }
296       } catch (ClassCastException JavaDoc ex1) {
297          throw ex1;
298       }
299         try {
300           if (iterator.seek(parameters)) {
301             if (iterator.next()) {
302               Object JavaDoc[] newValues = (Object JavaDoc[]) iterator.getColumnValues(
303                   constraintStore.columns);
304               if(((_IndexIteratorInfo)iterator).getComparator().compare(parameters ,newValues ) == 0)
305                 throw new UniqueConstraintException("DSE1032", null);
306             }
307           }
308         }
309         catch (NullPointerException JavaDoc ex) {
310           if (SystemTables.isSystemTable(tableName.getIdentifier()))
311             return;
312           throw ex;
313         }
314   }
315
316
317   /**
318    * returns the an array of Object contaning the values of the columns specified.
319    * @param columns columns for which the values are required
320    * @param record record from which the values of corresponding columns are to be retreived.
321    * @return an array of parameters.
322    * @throws DException
323    */

324   private Object JavaDoc[] getParameters( int[] columns , _Record record ) throws DException {
325         Object JavaDoc[] parameters = new Object JavaDoc[columns.length];
326         for( int i = 0 ; i < columns.length ; i++ )
327            parameters[i] = record.getObject(columns[i]);
328         return parameters;
329   }
330
331
332 /**
333  * used to check for null columns.
334  * @param record record for which the check is made
335  * @param columns columns of the record on which the check is made.
336  * @return true if all the column values are null otherwise false.
337  * @throws DException
338  */

339
340   private boolean checkForAllNull( _Record record , int[] columns ) throws DException {
341
342        for( int i=0; i<columns.length; i++ )
343          if( ((FieldBase)record.getObject( columns[i] )).isNull() == false ){
344            return false;
345          }
346        return true;
347   }
348
349   /**
350    * used to generate iterators for the different unique constraints.
351    * @param uniqueConstraint array of the unique constraints on that table.
352    * @param globalSession instance of _serversession
353    * @param iterator arraylist used to maintain the different instances of constraint store.
354    * @throws DException
355    */

356
357   private void generateIterators( _UniqueConstraint[] uniqueConstraint , _ServerSession globalSession ) throws DException {
358         for( int i=0; i<uniqueConstraint.length; i++ ){
359           booleanvalueexpression bve = uniqueConstraint[i].getCondition();
360           SetColumnProperties.setTableNamesAndDatatypesOfAllColumns(globalSession, bve.getColumnDetails(),new TableDetails[]{tableDetails},null,new ArrayList());
361           _Iterator itera = ((GlobalSession)globalSession).getIterator(tableName ,uniqueConstraint[i].getColumns() ) ;
362           SuperComparator com = ( (_IndexIteratorInfo)itera ).getComparator() ;
363           Object JavaDoc lastKey = null;
364           if (itera.last())
365             lastKey = itera.getColumnValues(uniqueConstraint[i].getColumns());
366           ConstraintStore constraintStore = new ConstraintStore( itera , uniqueConstraint[i].getColumns() , bve );
367           constraintStore.setLastKey(lastKey) ;
368           constraintStore.setComparator(com) ;
369           String JavaDoc name = uniqueConstraint[i].getQualifiedIdentifier().getName();
370           constraintStore.setConstraintName(name);
371           constraintStore.setBitSet(uniqueConstraint[i].getBitSet());
372           uniqueIterator.put(name,constraintStore);
373         }
374   }
375
376
377   private void generateIteratorForPrimary(_UniqueConstraint uniqueConstraint , _ServerSession globalSession ) throws DException {
378        booleanvalueexpression bve = uniqueConstraint.getCondition();
379        SetColumnProperties.setTableNamesAndDatatypesOfAllColumns(globalSession,bve.getColumnDetails(),new TableDetails[]{tableDetails},null,null);
380        _Iterator iterator = ((GlobalSession)globalSession).getIterator(tableName ,uniqueConstraint.getColumns() ) ;
381       SuperComparator com = ( (_IndexIteratorInfo) iterator).getComparator();
382        Object JavaDoc lastKey = null;
383        if(iterator.last() )
384          lastKey = iterator.getColumnValues(uniqueConstraint.getColumns() );
385        primaryConstraintStore = new ConstraintStore( iterator , uniqueConstraint.getColumns() , bve );
386        primaryConstraintStore.setLastKey(lastKey) ;
387        primaryConstraintStore.setComparator(com) ;
388        String JavaDoc name = uniqueConstraint.getQualifiedIdentifier().getName();
389        primaryConstraintStore.setConstraintName(name);
390        primaryConstraintStore.setBitSet(uniqueConstraint.getBitSet());
391
392   }
393
394   /**
395    * used to get the refernces of the columns.
396    * @param obj object for which references are required.
397    * @return an array of references.
398    * @throws DException
399    */

400
401   private void fireThisConstraint(ConstraintStore cs , RecordVersion recordVersion,int[] columns) throws DException {
402     booleanvalueexpression BVE = null;
403     if( cs.fireDescriptor( columns ) ){
404       BVE = cs.getCondition();
405         try{
406           if( !checkForAllNull( recordVersion.getCurrentRecord() , cs.columns ) )
407             verifyUniqueness( cs , recordVersion );
408       }catch ( DException e ) {
409         if( e.getDseCode().equalsIgnoreCase("DSE1032") ){
410           UniqueConstraintException ue = new UniqueConstraintException("DSE1032",new Object JavaDoc[]{cs.constraintName,tableName.getIdentifier()});
411           ue.setCorrespondingTable( tableName );
412           ue.setRecord( recordVersion.getCurrentRecord() );
413           throw ue ;
414         }
415       }
416     }
417   }
418
419   private void fireThisConstraint(ConstraintStore cs , RecordVersion recordVersion) throws DException {
420     booleanvalueexpression BVE = null;
421     BVE = cs.getCondition();
422       try{
423         if (!checkForAllNull(recordVersion.getCurrentRecord(), cs.columns))
424           verifyUniqueness(cs, recordVersion);
425
426     }catch ( DException e ) {
427       if( e.getDseCode().equalsIgnoreCase("DSE1032") ){
428         UniqueConstraintException ue = new UniqueConstraintException("DSE1032",new Object JavaDoc[]{cs.constraintName,tableName.getIdentifier()});
429         ue.setCorrespondingTable( tableName );
430         ue.setRecord( recordVersion.getCurrentRecord() );
431         throw ue ;
432       }
433     }
434   }
435
436
437   /**
438    * This method fires appropriate constraints.
439    * @param recordVersion
440    * throws DException
441    */

442   private void fireAllConstraints(RecordVersion recordVersion) throws DException {
443     Iterator iterator = uniqueIterator.keySet().iterator() ;
444     ConstraintStore tempCStore = null;
445       while( iterator.hasNext() ){
446         String JavaDoc key = (String JavaDoc) iterator.next();
447         tempCStore = (ConstraintStore)uniqueIterator.get(key);
448         fireThisConstraint(tempCStore,recordVersion );
449       }
450  }
451
452  /**
453   * This method fires appropriate constraints.
454   * @param recordVersion
455   * @param columns
456   * @throws DException
457   */

458   private void fireAllConstraints(RecordVersion recordVersion,int[] columns) throws DException {
459     Iterator iterator = uniqueIterator.keySet().iterator() ;
460     ConstraintStore tempCStore = null;
461     do{
462       tempCStore = (ConstraintStore)uniqueIterator.get(iterator.next());
463       fireThisConstraint(tempCStore,recordVersion ,columns);
464     }while( iterator.hasNext() );
465   }
466
467
468   /**
469    * This method fires appropriate constraints.
470    * @param recordVersion
471    * @throws DException
472    */

473   private void fireConstraintsForPrimary(RecordVersion recordVersion) throws DException{
474     int[] cols = primaryConstraintStore.columns ;
475     _Record currentRecord = recordVersion.getCurrentRecord();
476     for( int j = 0 ; j < cols.length ; j++ )
477       if( ((FieldBase)currentRecord.getObject( cols[j]) ).isNull() ) {
478          ;//// Removed By Program ** System.out.println(" ------------------------------------------------------------------------------------------------------------------- ");
479
throw new DException("DSE1291",new Object JavaDoc[]{cc.getColumnName(cols[j]),tableName.getIdentifier(),});
480       }
481     try{
482       verifyUniqueness(primaryConstraintStore,recordVersion);
483     }catch ( DException e ) {
484       if( e.getDseCode().equalsIgnoreCase("DSE1032") ){
485         String JavaDoc[] columnsToReturn = new String JavaDoc[cols.length] ;
486         for( int k=0; k<cols.length; k++ )
487           columnsToReturn[k] = cc.getColumnName(cols[k]);
488         PrimaryConstraintException pce = new PrimaryConstraintException("DSE1255", new Object JavaDoc[]{primaryConstraintStore.constraintName, tableName.getIdentifier()});
489         pce.setCorrespondingTable( tableName );
490         pce.setRecord(recordVersion.getCurrentRecord());
491         pce.setPrimaryColumns( columnsToReturn );
492         throw pce ;
493       }
494     }
495   }
496
497   /**
498    * This method retruns a list of appropriate constraint names.
499    * @param sessionImmediateConstraints
500    * @return
501    */

502   private ArrayList getRequiredConstraintsToFire( ArrayList sessionImmediateConstraints ) {
503     ArrayList toRet = new ArrayList();
504     Iterator iterator = uniqueIterator.keySet().iterator() ;
505     String JavaDoc Cname = null ;
506     do{
507       Cname = (String JavaDoc)iterator.next();
508       if( !sessionImmediateConstraints.contains(Cname) )
509         toRet.add(uniqueIterator.get(Cname));
510     }while( iterator.hasNext() );
511     return toRet;
512   }
513
514   private ConstraintInformation getConstraintInformation( _UserSession userSession ) throws DException {
515     return ((Session)userSession.getSession()).getConstraintInformation();
516   }
517   /**
518    * verifies the Primary Constraints the by passing the call to verifyUniqueness,
519    * and throws exception accordingly if needed.
520    * @param columns columns for which the constraints are verified.
521    * @param sec instance of statementexecutioncontext
522    * @param globalSession instance of serversession.
523    * @throws DException
524    */

525
526   public synchronized void verifyPrimaryConstraintsForUpdate( int[] columns , _StatementExecutionContext sec , _ServerSession globalSession) throws DException{
527        if( primaryConstraintStore == null ){ // If iterator pool is empty
528
_UniqueConstraint p = null ; // generating it
529
if( !checkedPrimary ){
530            p = primarAndUniqueConstraintCharacteristics.getPrimaryConstraints() ;
531            checkedPrimary = true;
532          }
533          if( p == null ){
534            return ;
535          }
536          tableDetails.cc = globalSession.getColumnCharacteristics(tableDetails.getQualifiedIdentifier());
537          cc = sec.getColumnCharacteristics(tableName) ;
538          generateIteratorForPrimary( p , globalSession );
539        } // Generation of iterator
540
if(!primaryConstraintStore.fireDescriptor(columns)){
541           return;
542        }
543        if(!deferrable){ // Constraints are immediate
544
ConstraintInformation constraintInformation = getConstraintInformation(sec.getUserSession()) ;
545          ArrayList immToDeff = constraintInformation.getImmediateToDefferedConstraints( tableName );
546          if( sec.getOperationTypeSameOrOpposite() ){ // Verifier is called fsor Table A
547
if( immToDeff == null )
548              fireConstraintsForPrimary(sec.getRecordVersion() );
549          }
550          else { // Verifier is called for Table B
551
if( immToDeff != null ){
552              String JavaDoc Cname;
553              for( int j=0; j<immToDeff.size(); j++ ){
554                Cname = (String JavaDoc) immToDeff.get(j);
555                if( primaryConstraintStore.constraintName.equalsIgnoreCase(Cname) )
556                  fireConstraintsForPrimary( sec.getRecordVersion() );
557              }
558            }
559          }
560        }
561        else { // Constraints are Deffered
562
ConstraintInformation constraintInformation = getConstraintInformation(sec.getUserSession()) ;
563          ArrayList deffToImm = constraintInformation.getDefferedToImmediateConstraints( tableName );
564          if(sec.getOperationTypeSameOrOpposite()){ // Verifier is called for Table B
565
if(deffToImm == null)
566              fireConstraintsForPrimary(sec.getRecordVersion() );
567            else{
568              if(!deffToImm.contains(primaryConstraintStore.constraintName))
569                fireConstraintsForPrimary(sec.getRecordVersion() );
570            }
571          }
572          else{ // Verifier is called for Table A
573
if(deffToImm!=null){
574              String JavaDoc cname = null;
575              for (int i = 0; i < deffToImm.size(); i++) {
576                cname = (String JavaDoc)deffToImm.get(i);
577                if(primaryConstraintStore.constraintName.equalsIgnoreCase(cname))
578                  fireConstraintsForPrimary(sec.getRecordVersion() );
579              }
580           }
581          }
582        }
583   }
584
585
586
587
588 }
589
Popular Tags