1 package com.daffodilwoods.daffodildb.server.sessionsystem; 2 3 import com.daffodilwoods.daffodildb.server.sql99.dql.execution._OrderCount; 4 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator; 5 import com.daffodilwoods.daffodildb.server.sql99.common.GeneralPurposeStaticClass; 6 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*; 7 import java.util.HashMap ; 8 import com.daffodilwoods.database.resource.DException; 9 import com.daffodilwoods.daffodildb.server.sql99.common.TableDetails; 10 import com.daffodilwoods.daffodildb.server.sql99.common._KeyColumnInformation; 11 import com.daffodilwoods.daffodildb.server.sql99.common.ColumnDetails; 12 import com.daffodilwoods.daffodildb.server.datasystem.utility.*; 13 import com.daffodilwoods.database.utility.*; 14 import com.daffodilwoods.database.sqlinitiator._Order; 15 import com.daffodilwoods.daffodildb.client._ExecutionPlan; 16 import com.daffodilwoods.daffodildb.client.ExecutionPlan; 17 import com.daffodilwoods.daffodildb.server.sql99.common.ExecutionPlanForBrowser; 18 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 19 import com.daffodilwoods.daffodildb.utils.field.FieldBase; 20 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator; 21 import java.util.Iterator ; 22 public class ForeignConstraintIterator extends BaseExceptionSingleIterator 23 implements _Iterator{ 24 _IndexIterator indexIterator; 25 _Iterator[][] allIterators ; 26 HashMap iteratorMap ; 27 Object [][] indexes ; 28 Object [][] references; 29 30 public ForeignConstraintIterator(_IndexIterator indexIterator0,HashMap map0, _Iterator[][] iteratorsList0, Object [][] indexes0,Object [][] references0) { 31 allIterators = iteratorsList0; 32 iteratorMap = map0; 33 indexes = indexes0; 34 references = references0; 35 indexIterator = indexIterator0; 36 } 37 public _OrderCount getOrderCounts() throws com.daffodilwoods.database.resource.DException { 38 39 throw new java.lang.UnsupportedOperationException ("Method getOrderCounts() not yet implemented."); 40 } 41 public TableDetails[] getTableDetails() throws com.daffodilwoods.database.resource.DException { 42 43 throw new java.lang.UnsupportedOperationException ("Method getTableDetails() not yet implemented."); 44 } 45 public _Iterator getBaseIterator(ColumnDetails column) throws com.daffodilwoods.database.resource.DException { 46 47 throw new java.lang.UnsupportedOperationException ("Method getBaseIterator() not yet implemented."); 48 } 49 public void setConditionVariableValue(_Reference[] parm1, Object [] parm2, int parm3) throws com.daffodilwoods.database.resource.DException { 50 } 51 public Object getColumnValues() throws com.daffodilwoods.database.resource.DException { 52 return indexIterator.getColumnValues((int[])null); 53 } 54 public _KeyColumnInformation[] getKeyColumnInformations() throws com.daffodilwoods.database.resource.DException { 55 return indexIterator.getKeyColumnInformations(); 56 } 57 public Object [] getUniqueColumnReference() throws com.daffodilwoods.database.resource.DException { 58 return indexIterator.getUniqueColumnReference(); 59 } 60 public boolean seek(Object parm1) throws com.daffodilwoods.database.resource.DException { 61 boolean found = indexIterator.seek(parm1); 62 if(found){ 63 allignAllIterators(indexIterator.getRecord()); 64 } 65 return found; 66 } 67 public Object getColumnValues(_Reference[] parm1) throws com.daffodilwoods.database.resource.DException { 68 Object [] values = new Object [parm1.length]; 69 for (int i = 0; i < parm1.length; i++) { 70 String [] aliasName = ((ColumnDetails)parm1[i]).getTableAliasArray(); 71 _Iterator iterator = (_Iterator) iteratorMap.get(aliasName); 72 if(iterator != null){ 73 try { 74 values[i] = iterator.getColumnValues(parm1[i]); 75 } 76 catch (DException ex) { 77 values[i] = null; 78 } 79 } 80 else 81 values[i] = ((Object [])indexIterator.getColumnValues(new _Reference[]{ parm1[i]}))[0]; 82 } 83 return values; 84 } 85 public Object getColumnValues(_Reference parm1) throws com.daffodilwoods.database.resource.DException { 86 String [] aliasName = ((ColumnDetails)parm1).getTableAliasArray(); 87 _Iterator iterator = (_Iterator) iteratorMap.get(aliasName); 88 if(iterator != null){ 89 try { 90 return iterator.getColumnValues(parm1); 91 } 92 catch (DException ex) { 93 return null; 94 } 95 } 96 return ((Object [])indexIterator.getColumnValues(new _Reference[]{parm1}))[0]; 97 } 98 public void setIterator(_Iterator parm1) throws com.daffodilwoods.database.resource.DException { 99 100 throw new java.lang.UnsupportedOperationException ("Method setIterator() not yet implemented."); 101 } 102 public boolean seekFromTop(_IndexPredicate[] parm1) throws com.daffodilwoods.database.resource.DException { 103 boolean found = indexIterator.seekFromTop(parm1); 104 if(found){ 105 allignAllIterators(indexIterator.getRecord()); 106 } 107 return found; 108 } 109 public boolean seekFromTopRelative(Object parm1) throws com.daffodilwoods.database.resource.DException { 110 boolean found = indexIterator.seekFromTopRelative(parm1); 111 if(found){ 112 allignAllIterators(indexIterator.getRecord()); 113 } 114 return found; 115 } 116 public boolean seekFromBottom(_IndexPredicate[] parm1) throws com.daffodilwoods.database.resource.DException { 117 boolean found = indexIterator.seekFromBottom(parm1); 118 if(found){ 119 allignAllIterators(indexIterator.getRecord()); 120 } 121 return found; 122 } 123 public boolean seekFromBottomRelative(Object parm1) throws com.daffodilwoods.database.resource.DException { 124 boolean found = indexIterator.seekFromBottomRelative(parm1); 125 if(found){ 126 allignAllIterators(indexIterator.getRecord()); 127 } 128 return found; 129 } 130 131 public boolean first() throws DException { 132 boolean firstFound = indexIterator.first(); 133 if(firstFound){ 134 _Record record = indexIterator.getRecord(); 135 allignAllIterators(record); 136 } 137 return firstFound; 138 } 139 140 private void allignAllIterators(_Record record) throws DException { 141 for (int i = 0; i < allIterators.length; i++) { 142 for (int j = 0; j < allIterators[i].length; j++) { 143 Object [] key = null; 144 int[] columns = (int[]) indexes[i][j]; 145 if(j==0) 146 key = record.getObject(columns); 147 else{ 148 _Record iteratorRecord = allIterators[i][j-1].getRecord(); 149 key = iteratorRecord.getObject(columns); 150 } 151 _Reference[] refs = GeneralPurposeStaticClass.changeReferences((Object [])references[i][j]); 152 allIterators[i][j].setConditionVariableValue(refs,key,1); 153 boolean isFirst = allIterators[i][j].first(); 154 if( !isFirst ){ 155 break; 156 } 157 } 158 } 159 } 160 public boolean last() throws com.daffodilwoods.database.resource.DException { 161 boolean lastFound = indexIterator.last(); 162 if(lastFound){ 163 _Record record = indexIterator.getRecord(); 164 allignAllIterators(record); 165 } 166 return lastFound; 167 } 168 public boolean next() throws com.daffodilwoods.database.resource.DException { 169 boolean nextFound = indexIterator.next(); 170 if(nextFound){ 171 _Record record = indexIterator.getRecord(); 172 allignAllIterators(record); 173 } 174 return nextFound; 175 } 176 public boolean previous() throws com.daffodilwoods.database.resource.DException { 177 boolean previousFound = indexIterator.previous(); 178 if(previousFound){ 179 _Record record = indexIterator.getRecord(); 180 allignAllIterators(record); 181 } 182 return previousFound; 183 } 184 public Object getKey() throws com.daffodilwoods.database.resource.DException { 185 return indexIterator.getKey(); 186 } 187 public void move(Object parm1) throws com.daffodilwoods.database.resource.DException { 188 indexIterator.move(parm1); 189 try { 190 _Record record = indexIterator.getRecord(); 191 allignAllIterators(record); 192 } 193 catch (DException ex) { 194 } 195 196 } 197 public Object getColumnValues(int[] parm1) throws com.daffodilwoods.database.resource.DException { 198 return indexIterator.getColumnValues(parm1); 199 } 200 public _Record getRecord() throws com.daffodilwoods.database.resource.DException { 201 return indexIterator.getRecord(); 202 } 203 204 205 public void addReferences(_Reference[] parm1) throws com.daffodilwoods.database.resource.DException { 206 207 throw new java.lang.UnsupportedOperationException ("Method addReferences() not yet implemented."); 208 } 209 public Object [][] getReferenceAndValuePair() throws DException { 210 throw new java.lang.UnsupportedOperationException ("Method getReferences() not yet implemented."); 211 } 212 public _Order getDefaultOrder() throws DException{ 213 214 throw new java.lang.UnsupportedOperationException ("Method getDefaultOrder() not yet implemented."); 215 } 216 217 public String toString() { 218 return " ForeignConstraintIterator [ "+indexIterator+" ] "; 219 } 220 221 public Object getColumnValues(int column) throws DException { 222 223 throw new java.lang.UnsupportedOperationException ("Method getColumnValues() not yet implemented."); 224 } 225 226 public _ExecutionPlan getExecutionPlan() throws DException{ 227 return new ExecutionPlan("ForeignConstraintIterator",null,null,null,null); 228 } 229 230 public ExecutionPlanForBrowser getExecutionPlanForBrowser() throws DException { 231 throw new UnsupportedOperationException ("Method Not Supported"); 232 } 233 public SuperComparator getComparator() { 234 return ((_IndexIteratorInfo)indexIterator).getComparator(); 235 } 236 public SuperComparator getObjectComparator() throws com.daffodilwoods.database.resource.DException { 237 return ((_IndexIteratorInfo)indexIterator).getObjectComparator(); 238 } 239 public _Iterator getBaseIteratorHasRecord(ColumnDetails hasRecordColumn) throws DException { 240 throw new DException("DSE565",new Object []{"getBaseIterator"}); 241 } 242 public FieldBase field(_Reference reference) throws com.daffodilwoods.database.resource.DException { 243 String [] aliasName = ((ColumnDetails)reference).getTableAliasArray(); 244 _Iterator iterator = (_Iterator) iteratorMap.get(aliasName); 245 if(iterator != null){ 246 try { 247 return iterator.field(reference); 248 } 249 catch (DException ex) { 250 return null; 251 } 252 } 253 return ((FieldBase[])indexIterator.fields(new _Reference[]{reference}))[0]; 254 } 255 public FieldBase[] fields(_Reference[] references) throws com.daffodilwoods.database.resource.DException { 256 FieldBase[] values = new FieldBase[references.length]; 257 for (int i = 0; i < references.length; i++) { 258 String [] aliasName = ((ColumnDetails)references[i]).getTableAliasArray(); 259 _Iterator iterator = (_Iterator) iteratorMap.get(aliasName); 260 if(iterator != null){ 261 try { 262 values[i] = iterator.field(references[i]); 263 } 264 catch (DException ex) { 265 values[i] = null; 266 } 267 } 268 else 269 values[i] = ((FieldBase[])indexIterator.fields(new _Reference[]{ references[i]}))[0]; 270 } 271 return values; 272 } 273 public FieldBase[] fields(int[] columns) throws com.daffodilwoods.database.resource.DException { 274 return indexIterator.fields(columns); 275 } 276 public void releaseResource() throws DException { 277 278 } 279 280 } 281 | Popular Tags |