1 21 22 package org.apache.derby.impl.sql.catalog; 23 24 import org.apache.derby.iapi.types.DataTypeDescriptor; 25 import org.apache.derby.iapi.types.TypeId; 26 import org.apache.derby.iapi.types.DataValueDescriptor; 27 28 import org.apache.derby.iapi.types.TypeId; 29 import org.apache.derby.iapi.sql.dictionary.SystemColumn; 30 import org.apache.derby.catalog.TypeDescriptor; 31 32 import org.apache.derby.iapi.types.DataValueFactory; 33 import org.apache.derby.iapi.types.RowLocation; 34 35 import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory; 36 import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator; 37 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 38 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor; 39 import org.apache.derby.iapi.sql.dictionary.TupleDescriptor; 40 41 import org.apache.derby.iapi.sql.execute.ExecutionFactory; 42 import org.apache.derby.iapi.sql.execute.ExecIndexRow; 43 import org.apache.derby.iapi.sql.execute.ExecRow; 44 45 import org.apache.derby.iapi.error.StandardException; 46 47 import org.apache.derby.iapi.services.monitor.Monitor; 48 import org.apache.derby.catalog.UUID; 49 import org.apache.derby.iapi.services.uuid.UUIDFactory; 50 51 import org.apache.derby.iapi.services.sanity.SanityManager; 52 53 60 61 public class SYSSCHEMASRowFactory extends CatalogRowFactory 62 { 63 private static final String TABLENAME_STRING = "SYSSCHEMAS"; 64 65 public static final int SYSSCHEMAS_COLUMN_COUNT = 3; 66 67 public static final int SYSSCHEMAS_SCHEMAID = 1; 68 public static final int SYSSCHEMAS_SCHEMANAME = 2; 69 public static final int SYSSCHEMAS_SCHEMAAID = 3; 70 71 protected static final int SYSSCHEMAS_INDEX1_ID = 0; 72 protected static final int SYSSCHEMAS_INDEX2_ID = 1; 73 74 75 private static final int[][] indexColumnPositions = 76 { 77 {SYSSCHEMAS_SCHEMANAME}, 78 {SYSSCHEMAS_SCHEMAID} 79 }; 80 81 private static final boolean[] uniqueness = null; 82 83 private static final String [] uuids = 84 { 85 "80000022-00d0-fd77-3ed8-000a0a0b1900" ,"8000002a-00d0-fd77-3ed8-000a0a0b1900" ,"80000024-00d0-fd77-3ed8-000a0a0b1900" ,"80000026-00d0-fd77-3ed8-000a0a0b1900" }; 90 91 97 public SYSSCHEMASRowFactory(UUIDFactory uuidf, ExecutionFactory ef, DataValueFactory dvf, 98 boolean convertIdToLower) 99 { 100 super(uuidf,ef,dvf,convertIdToLower); 101 initInfo(SYSSCHEMAS_COLUMN_COUNT, TABLENAME_STRING, 102 indexColumnPositions, uniqueness, uuids ); 103 } 104 105 111 118 119 public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) 120 throws StandardException 121 { 122 DataTypeDescriptor dtd; 123 ExecRow row; 124 DataValueDescriptor col; 125 String name = null; 126 UUID oid = null; 127 String uuid = null; 128 String aid = null; 129 130 if (td != null) 131 { 132 SchemaDescriptor schemaDescriptor = (SchemaDescriptor)td; 133 134 name = schemaDescriptor.getSchemaName(); 135 oid = schemaDescriptor.getUUID(); 136 if ( oid == null ) 137 { 138 oid = getUUIDFactory().createUUID(); 139 schemaDescriptor.setUUID(oid); 140 } 141 uuid = oid.toString(); 142 143 aid = schemaDescriptor.getAuthorizationId(); 144 } 145 146 147 row = getExecutionFactory().getValueRow(SYSSCHEMAS_COLUMN_COUNT); 148 149 150 row.setColumn(1, dvf.getCharDataValue(uuid)); 151 152 153 row.setColumn(2, dvf.getVarcharDataValue(name)); 154 155 156 row.setColumn(3, dvf.getVarcharDataValue(aid)); 157 158 return row; 159 } 160 161 162 168 179 public TupleDescriptor buildDescriptor( 180 ExecRow row, 181 TupleDescriptor parentTupleDescriptor, 182 DataDictionary dd ) 183 throws StandardException 184 { 185 DataValueDescriptor col; 186 SchemaDescriptor descriptor; 187 String name; 188 UUID id; 189 String aid; 190 String uuid; 191 DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator(); 192 193 if (SanityManager.DEBUG) 194 { 195 SanityManager.ASSERT(row.nColumns() == SYSSCHEMAS_COLUMN_COUNT, 196 "Wrong number of columns for a SYSSCHEMAS row"); 197 } 198 199 col = row.getColumn(1); 201 uuid = col.getString(); 202 id = getUUIDFactory().recreateUUID(uuid); 203 204 col = row.getColumn(2); 206 name = col.getString(); 207 208 col = row.getColumn(3); 210 aid = col.getString(); 211 212 descriptor = ddg.newSchemaDescriptor(name, aid, id); 213 214 return descriptor; 215 } 216 217 223 public SystemColumn[] buildColumnList() 224 { 225 int index = 0; 226 SystemColumn[] columnList = new SystemColumn[SYSSCHEMAS_COLUMN_COUNT]; 227 228 230 columnList[index++] = new SystemColumnImpl( 231 convertIdCase( "SCHEMAID"), SYSSCHEMAS_SCHEMAID, 0, 0, false, "CHAR", true, 36 ); 240 columnList[index++] = 241 new SystemColumnImpl( convertIdCase( "SCHEMANAME"), SYSSCHEMAS_SCHEMANAME, false ); 246 247 columnList[index++] = 248 new SystemColumnImpl( convertIdCase( "AUTHORIZATIONID"), SYSSCHEMAS_SCHEMAAID, false ); 253 254 255 return columnList; 256 } 257 } 258 | Popular Tags |