1 package com.daffodilwoods.daffodildb.server.serversystem; 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.serversystem.datatriggersystem.*; 8 import com.daffodilwoods.daffodildb.server.serversystem.dmlvalidation.statementtriggersystem.*; 9 import com.daffodilwoods.daffodildb.server.sessionsystem.*; 10 import com.daffodilwoods.daffodildb.server.sql99.dml.*; 11 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 12 import com.daffodilwoods.daffodildb.utils.*; 13 import com.daffodilwoods.daffodildb.utils.field.*; 14 import com.daffodilwoods.database.general.*; 15 import com.daffodilwoods.database.resource.*; 16 17 public class StatementExecutionContext implements _StatementExecutionContext { 18 19 private _UserSession userSession; 20 private _TriggerExecutionContext triggerExecutionContext; 21 private _ServerSystem serverSystem; 22 private _ServerSession serverSession; 23 private RecordVersion recordVersion; 24 private _VariableValues rtv; 25 private boolean constraintTypeDeferred; 26 private boolean checkConstraintLaterOn; 27 private boolean performSameOperation; 28 private int[] autoIncrementColumnIndexes; 29 private String [] autoIncrementColumnNames; 30 public int autoGeneratedType = -1; 31 public DMLResult dmlResult; 32 boolean isExistingDMLResult = true; 33 private ArrayList createIndexList; 34 private boolean checkUserRights = true; 35 public boolean autoCommit = true; 36 private int triggerCount = 0; 37 private int procedureExceutionCount = 0; 38 39 public StatementExecutionContext() throws DException { 40 } 41 42 public void setUserSession(_UserSession userSession0) throws DException { 43 userSession = userSession0; 44 } 45 46 public void setTriggerExecutionContext(_TriggerExecutionContext triggerExecutionContext0) throws DException { 47 triggerExecutionContext = triggerExecutionContext0; 48 } 49 50 public final void setServerSystem(_ServerSystem serverSystem0) throws DException { 51 serverSystem = serverSystem0; 52 } 53 54 public void setVariableValues(_VariableValues rtv) throws DException { 55 this.rtv = rtv; 56 } 57 58 public _VariableValues getVariableValues() throws DException { 59 return rtv; 60 } 61 62 public final void setServerSession(_ServerSession serverSession) throws DException { 63 this.serverSession = serverSession; 64 } 65 66 public _UserSession getUserSession() throws DException { 67 return userSession; 68 } 69 70 public boolean getAutoGeneratedType() { 71 return autoGeneratedType != -1; 72 } 73 74 public _TriggerExecutionContext getTriggerExecutionContext() throws DException { 75 return triggerExecutionContext; 76 } 77 78 public _ServerSystem getServerSystem() throws DException { 79 return serverSystem; 80 } 81 82 public _ServerSession getServerSession() throws DException { 83 return serverSession; 84 } 85 86 public _StatementExecutionContext getChildStatementExecutionContext() throws DException { 87 StatementExecutionContext childSEC = new StatementExecutionContext(); 88 childSEC.setServerSystem(this.serverSystem); 89 childSEC.setServerSession(this.serverSession); 90 childSEC.setUserSession(this.userSession); 91 childSEC.triggerCount = triggerCount; 92 childSEC.procedureExceutionCount = procedureExceutionCount; 93 return childSEC; 94 } 95 96 public void setRecordVersion(RecordVersion recordVersion) throws DException { 97 this.recordVersion = recordVersion; 98 } 99 100 public RecordVersion getRecordVersion() throws DException { 101 return recordVersion; 102 } 103 104 public _ServerTable getServerTable(QualifiedIdentifier tableName) throws DException { 105 return serverSession.getServerTable(tableName); 106 } 107 108 public _StatementTriggerTable getStatementTriggerTable(QualifiedIdentifier tableName) throws DException { 109 return serverSystem.getStatementTriggerTable(serverSession.getDatabaseURL(), tableName); 110 } 111 112 public _SingleTableRetrievalSystem getSelectRequirements() throws DException { 113 return (_SingleTableRetrievalSystem) serverSession; 114 } 115 116 public _ColumnCharacteristics getColumnCharacteristics(QualifiedIdentifier tableName) throws DException { 117 return serverSession.getColumnCharacteristics(tableName); 118 } 119 120 public _DataTriggerTable getDataTriggerTable(QualifiedIdentifier tableName) throws DException { 121 return ( (ServerSession) serverSession).getDataTriggerTable(tableName); 122 } 123 124 public boolean isConstraintCheckedForDefferable() { 125 return constraintTypeDeferred; 126 } 127 128 public void setConstraintTypeDeferred(boolean flag) { 129 constraintTypeDeferred = flag; 130 } 131 132 public void setCheckConstraintToExecuteNow(boolean yesno) { 133 checkConstraintLaterOn = yesno; 134 } 135 136 public boolean checkConstraintNOW() { 137 return checkConstraintLaterOn; 138 } 139 140 public void setOperationTypePerformSameOperation(boolean flag) { 141 performSameOperation = flag; 142 } 143 144 public boolean getOperationTypeSameOrOpposite() { 145 return performSameOperation; 146 } 147 148 public void setAutoGeneratedInfo(int autoGeneratedType0, Object autoGenetatedValues) throws DException { 149 autoGeneratedType = autoGeneratedType0; 150 if (autoGeneratedType == _Connection.COLUMNINDEXES) { 151 int[] temp = (int[]) autoGenetatedValues; 152 autoIncrementColumnIndexes = new int[temp.length]; 153 for (int i = 0; i < temp.length; i++) 154 autoIncrementColumnIndexes[i] = temp[i] + 4; 155 } 156 if (autoGeneratedType == _Connection.COLUMNNAMES) 157 autoIncrementColumnNames = (String []) autoGenetatedValues; 158 } 159 160 public DMLResult getDMLResult() { 161 if (dmlResult == null) 162 dmlResult = new DMLResult(); 163 isExistingDMLResult = false; 164 return dmlResult; 165 } 166 167 public void updateDMLResult(QualifiedIdentifier tableName, int[] Columns, RecordVersion recordVersion) throws DException { 168 if (autoGeneratedType == -1) 169 return; 170 _ColumnCharacteristics cc = serverSession.getColumnCharacteristics(tableName); 171 if (dmlResult == null || (!isExistingDMLResult)) { 172 dmlResult = new DMLResult(); 173 isExistingDMLResult = true; 174 } 175 Object [] values = null; 176 int[] autoIndexes = null; 177 if (autoGeneratedType == _Connection.COLUMNINDEXES) { 178 try { 179 values = recordVersion.getCurrentRecord().getObject( 180 autoIncrementColumnIndexes); 181 } catch (ArrayIndexOutOfBoundsException ex) { 182 throw new DException("DSE8091", null); 183 } 184 autoIndexes = autoIncrementColumnIndexes; 185 } else if (autoGeneratedType == _Connection.COLUMNNAMES) { 186 autoIndexes = cc.getColumnIndexes(autoIncrementColumnNames); 187 values = recordVersion.getCurrentRecord().getObject(autoIndexes); 188 189 } else { 190 Object [] newValues = ColumnCharacteristicsUtilities.getAutoIncrementColumnIndexes(cc, Columns, recordVersion); 191 autoIndexes = (int[]) newValues[0]; 192 values = (Object []) newValues[1]; 193 } 194 if (values != null) { 195 values = convertFieldbaseToObject(values); 196 dmlResult.addValue(values); 197 } 198 if (!dmlResult.isInitialised) { 199 dmlResult.isInitialised(true); 200 dmlResult.setColumnCharacteristics(cc.getCCFromIndexes(cc, 0, autoIndexes)); 201 } 202 } 203 204 private Object [] convertFieldbaseToObject(Object [] values0) throws DException { 205 Object [] values = new Object [values0.length]; 206 for (int i = 0; i < values0.length; i++) { 207 values[i] = ( (FieldBase) values0[i]).getObject(); 208 } 209 return values; 210 } 211 212 public void setCreateIndexList(ArrayList createIndexList0) { 213 createIndexList = createIndexList0; 214 } 215 216 public ArrayList getCreateIndexList() { 217 return createIndexList; 218 } 219 220 public void addTriggerCount() { 221 triggerCount = triggerCount + 1; 222 } 223 224 public void subTriggerCount() { 225 triggerCount = triggerCount - 1; 226 } 227 228 public int getTriggerCount() { 229 return triggerCount; 230 } 231 232 public void addProcedureCount() { 233 procedureExceutionCount = procedureExceutionCount + 1; 234 } 235 236 public void subProcedureCount() { 237 procedureExceutionCount = procedureExceutionCount - 1; 238 } 239 240 public int getProcedureCount() { 241 return procedureExceutionCount; 242 } 243 244 public void setUserRight(boolean rights) { 245 checkUserRights = rights; 246 } 247 248 public boolean getUserRight() { 249 return checkUserRights; 250 } 251 252 public void setAutoCommit(boolean autoCommit0) { 253 autoCommit = autoCommit0; 254 } 255 256 public boolean getAutoCommit() { 257 return autoCommit; 258 } 259 } 260 | Popular Tags |