| 1 package com.daffodilwoods.daffodildb.server.serversystem.dmlvalidation.constraintsystem; 2 3 import com.daffodilwoods.daffodildb.server.datadictionarysystem.*; 4 import com.daffodilwoods.daffodildb.utils.comparator.*; 5 import com.daffodilwoods.database.general.*; 6 import com.daffodilwoods.database.resource.*; 7 8 16 public class ConstraintDatabase implements _ConstraintDatabase { 17 18 21 private boolean deferrable; 22 23 26 private _DataDictionary dataDictionary; 27 28 31 private WeakOrderedKeyList constraintTablePool = new WeakOrderedKeyList(new CTusjohDbtfJoTfotjujwfDpnqbsbups()); 32 33 39 public ConstraintDatabase(_DataDictionary dDictionary, boolean deff) throws DException { 40 dataDictionary = dDictionary; 41 deferrable = deff; 42 } 43 44 52 53 public synchronized _ConstraintTable getConstraintTable(QualifiedIdentifier tableName) throws DException { 54 _ConstraintTable constraintTable = (_ConstraintTable) constraintTablePool.get(tableName.getIdentifier()); 55 if (constraintTable != null) { 56 return constraintTable; 57 } 58 _DDSConstraintOperations DDSConstraintOperations = dataDictionary.getDDSConstraintsOperation(); 59 _CheckConstraintCharacteristics checkConstraintCharacteristics = DDSConstraintOperations.getCheckConstraintCharacteristics(tableName, deferrable); 60 _PrimaryAndUniqueConstraintCharacteristics primaryAndUniqueConstraintCharacteristics = DDSConstraintOperations.getPrimaryAndUniqueConstraintCharacteristics(tableName, deferrable); 61 _ReferencingConstraintCharacteristics referencingConstraintCharacteristics = DDSConstraintOperations.getReferencingConstraintCharacteristics(tableName, deferrable); 62 _ReferencedConstraintCharacteristics referencedConstraintCharacteristics = DDSConstraintOperations.getReferencedConstraintCharacteristics(tableName, deferrable); 63 boolean hasDefferred = DDSConstraintOperations.hasDefferedConstraints(tableName); 64 PrimaryAndUniqueConstraintVerifier primaryAndUniqueCV = new PrimaryAndUniqueConstraintVerifier(primaryAndUniqueConstraintCharacteristics, tableName, deferrable); 65 CheckConstraintsVerifier checkCV = new CheckConstraintsVerifier(checkConstraintCharacteristics, tableName, deferrable); 66 ReferencingConstraintsVerifier referencingCV = new ReferencingConstraintsVerifier(referencingConstraintCharacteristics, tableName, deferrable); 67 ReferencedConstraintsVerifier referencedCV = new ReferencedConstraintsVerifier(referencedConstraintCharacteristics, dataDictionary, tableName, deferrable); 68 constraintTable = (_ConstraintTable)new ConstraintTable(deferrable, primaryAndUniqueCV, checkCV, referencingCV, referencedCV, this, hasDefferred, tableName); 69 constraintTablePool.put(tableName.getIdentifier(), constraintTable); 70 return constraintTable; 71 } 72 73 78 79 public void removeTable(QualifiedIdentifier tableName) throws DException { 80 constraintTablePool.remove(tableName.getIdentifier()); 81 } 82 } 83 | Popular Tags |