1 21 22 package org.apache.derby.impl.sql.catalog; 23 24 import org.apache.derby.catalog.Dependable; 25 import org.apache.derby.catalog.DependableFinder; 26 27 import org.apache.derby.iapi.services.uuid.UUIDFactory; 28 import org.apache.derby.catalog.UUID; 29 30 import org.apache.derby.iapi.types.TypeId; 31 import org.apache.derby.iapi.sql.dictionary.SystemColumn; 32 import org.apache.derby.catalog.TypeDescriptor; 33 34 import org.apache.derby.iapi.services.sanity.SanityManager; 35 36 import org.apache.derby.iapi.types.DataValueDescriptor; 37 38 import org.apache.derby.iapi.types.DataValueFactory; 39 import org.apache.derby.iapi.types.RowLocation; 40 41 import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory; 42 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor; 43 import org.apache.derby.iapi.sql.dictionary.DependencyDescriptor; 44 import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator; 45 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 46 import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext; 47 import org.apache.derby.iapi.sql.dictionary.TupleDescriptor; 48 49 import org.apache.derby.iapi.sql.execute.ExecutionContext; 50 import org.apache.derby.iapi.sql.execute.ExecutionFactory; 51 import org.apache.derby.iapi.sql.execute.ExecIndexRow; 52 import org.apache.derby.iapi.sql.execute.ExecRow; 53 54 import org.apache.derby.iapi.error.StandardException; 55 56 import org.apache.derby.catalog.IndexDescriptor; 57 import org.apache.derby.iapi.reference.SQLState; 58 59 64 65 public class SYSDEPENDSRowFactory extends CatalogRowFactory 66 { 67 private static final String TABLENAME_STRING = "SYSDEPENDS"; 68 69 protected static final int SYSDEPENDS_COLUMN_COUNT = 4; 70 protected static final int SYSDEPENDS_DEPENDENTID = 1; 71 protected static final int SYSDEPENDS_DEPENDENTTYPE = 2; 72 protected static final int SYSDEPENDS_PROVIDERID = 3; 73 protected static final int SYSDEPENDS_PROVIDERTYPE = 4; 74 75 protected static final int SYSDEPENDS_INDEX1_ID = 0; 76 protected static final int SYSDEPENDS_INDEX2_ID = 1; 77 78 79 private static final boolean[] uniqueness = { 80 false, 81 false 82 }; 83 84 private static final int[][] indexColumnPositions = 85 { 86 {SYSDEPENDS_DEPENDENTID}, 87 {SYSDEPENDS_PROVIDERID} 88 }; 89 90 private static final String [] uuids = 91 { 92 "8000003e-00d0-fd77-3ed8-000a0a0b1900" ,"80000043-00d0-fd77-3ed8-000a0a0b1900" ,"80000040-00d0-fd77-3ed8-000a0a0b1900" ,"80000042-00d0-fd77-3ed8-000a0a0b1900" }; 97 98 104 public SYSDEPENDSRowFactory(UUIDFactory uuidf, ExecutionFactory ef, DataValueFactory dvf, 105 boolean convertIdToLower) 106 { 107 super(uuidf,ef,dvf,convertIdToLower); 108 initInfo(SYSDEPENDS_COLUMN_COUNT,TABLENAME_STRING, indexColumnPositions, 109 uniqueness, uuids ); 110 } 111 112 118 128 public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) 129 throws StandardException 130 { 131 DataValueDescriptor col; 132 ExecRow row; 133 String dependentID = null; 134 DependableFinder dependentBloodhound = null; 135 String providerID = null; 136 DependableFinder providerBloodhound = null; 137 138 if (td != null) 139 { 140 DependencyDescriptor dd = (DependencyDescriptor)td; 141 dependentID = dd.getUUID().toString(); 142 dependentBloodhound = dd.getDependentFinder(); 143 if ( dependentBloodhound == null ) 144 { 145 throw StandardException.newException(SQLState.DEP_UNABLE_TO_STORE); 146 } 147 148 providerID = dd.getProviderID().toString(); 149 providerBloodhound = dd.getProviderFinder(); 150 if ( providerBloodhound == null ) 151 { 152 throw StandardException.newException(SQLState.DEP_UNABLE_TO_STORE); 153 } 154 155 } 156 157 158 159 162 163 164 row = getExecutionFactory().getValueRow(SYSDEPENDS_COLUMN_COUNT); 165 166 167 row.setColumn(SYSDEPENDS_DEPENDENTID, dvf.getCharDataValue(dependentID)); 168 169 170 row.setColumn(SYSDEPENDS_DEPENDENTTYPE, 171 dvf.getDataValue(dependentBloodhound)); 172 173 174 row.setColumn(SYSDEPENDS_PROVIDERID, dvf.getCharDataValue(providerID)); 175 176 177 row.setColumn(SYSDEPENDS_PROVIDERTYPE, 178 dvf.getDataValue(providerBloodhound)); 179 180 return row; 181 } 182 183 189 198 public TupleDescriptor buildDescriptor( 199 ExecRow row, 200 TupleDescriptor parentTupleDescriptor, 201 DataDictionary dd ) 202 throws StandardException 203 { 204 DependencyDescriptor dependencyDesc = null; 205 206 if (SanityManager.DEBUG) 207 { 208 SanityManager.ASSERT( 209 row.nColumns() == SYSDEPENDS_COLUMN_COUNT, 210 "Wrong number of columns for a SYSDEPENDS row"); 211 } 212 213 DataValueDescriptor col; 214 String dependentIDstring; 215 UUID dependentUUID; 216 DependableFinder dependentBloodhound; 217 String providerIDstring; 218 UUID providerUUID; 219 DependableFinder providerBloodhound; 220 221 222 col = row.getColumn(SYSDEPENDS_DEPENDENTID); 223 dependentIDstring = col.getString(); 224 dependentUUID = getUUIDFactory().recreateUUID(dependentIDstring); 225 226 227 col = row.getColumn(SYSDEPENDS_DEPENDENTTYPE); 228 dependentBloodhound = (DependableFinder) col.getObject(); 229 230 231 col = row.getColumn(SYSDEPENDS_PROVIDERID); 232 providerIDstring = col.getString(); 233 providerUUID = getUUIDFactory().recreateUUID(providerIDstring); 234 235 236 col = row.getColumn(SYSDEPENDS_PROVIDERTYPE); 237 providerBloodhound = (DependableFinder) col.getObject(); 238 239 240 return new DependencyDescriptor(dependentUUID, dependentBloodhound, 241 providerUUID, providerBloodhound); 242 } 243 244 250 public SystemColumn[] buildColumnList() 251 { 252 int index = 0; 253 SystemColumn[] columnList = new SystemColumn[SYSDEPENDS_COLUMN_COUNT]; 254 255 257 columnList[index++] = 258 new SystemColumnImpl( 259 convertIdCase( "DEPENDENTID"), SYSDEPENDS_DEPENDENTID, 0, 0, false, "CHAR", true, 36 ); 268 269 columnList[index++] = 270 new SystemColumnImpl( 271 convertIdCase( "DEPENDENTFINDER"), SYSDEPENDS_DEPENDENTTYPE, 0, 0, false, "org.apache.derby.catalog.DependableFinder", false, TypeDescriptor.MAXIMUM_WIDTH_UNKNOWN ); 280 281 columnList[index++] = 282 new SystemColumnImpl( 283 convertIdCase( "PROVIDERID"), SYSDEPENDS_PROVIDERID, 285 0, 0, false, "CHAR", true, 36 ); 292 293 columnList[index++] = 294 new SystemColumnImpl( 295 convertIdCase( "PROVIDERFINDER"), SYSDEPENDS_PROVIDERTYPE, 0, 0, false, "org.apache.derby.catalog.DependableFinder", false, TypeDescriptor.MAXIMUM_WIDTH_UNKNOWN ); 304 305 return columnList; 306 } 307 } 308 | Popular Tags |