use of org.apache.derby.iapi.sql.dictionary.AliasDescriptor in project derby by apache.
the class SYSALIASESRowFactory method makeRow.
// ///////////////////////////////////////////////////////////////////////////
//
// METHODS
//
// ///////////////////////////////////////////////////////////////////////////
/**
* Make a SYSALIASES row
*
* @return Row suitable for inserting into SYSALIASES.
*
* @exception StandardException thrown on failure
*/
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
DataValueDescriptor col;
String schemaID = null;
String javaClassName = null;
String sAliasType = null;
String aliasID = null;
String aliasName = null;
String specificName = null;
char cAliasType = AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR;
char cNameSpace = AliasInfo.ALIAS_NAME_SPACE_PROCEDURE_AS_CHAR;
boolean systemAlias = false;
AliasInfo aliasInfo = null;
if (td != null) {
AliasDescriptor ad = (AliasDescriptor) td;
aliasID = ad.getUUID().toString();
aliasName = ad.getDescriptorName();
schemaID = ad.getSchemaUUID().toString();
javaClassName = ad.getJavaClassName();
cAliasType = ad.getAliasType();
cNameSpace = ad.getNameSpace();
systemAlias = ad.getSystemAlias();
aliasInfo = ad.getAliasInfo();
specificName = ad.getSpecificName();
char[] charArray = new char[1];
charArray[0] = cAliasType;
sAliasType = new String(charArray);
if (SanityManager.DEBUG) {
switch(cAliasType) {
case AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR:
case AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR:
case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR:
case AliasInfo.ALIAS_TYPE_UDT_AS_CHAR:
case AliasInfo.ALIAS_TYPE_AGGREGATE_AS_CHAR:
break;
default:
SanityManager.THROWASSERT("Unexpected value (" + cAliasType + ") for aliasType");
}
}
}
/* Insert info into sysaliases */
/* RESOLVE - It would be nice to require less knowledge about sysaliases
* and have this be more table driven.
*/
/* Build the row to insert */
ExecRow row = getExecutionFactory().getValueRow(SYSALIASES_COLUMN_COUNT);
/* 1st column is ALIASID (UUID - char(36)) */
row.setColumn(SYSALIASES_ALIASID, new SQLChar(aliasID));
/* 2nd column is ALIAS (varchar(128))) */
row.setColumn(SYSALIASES_ALIAS, new SQLVarchar(aliasName));
// System.out.println(" added row-- " + aliasName);
/* 3rd column is SCHEMAID (UUID - char(36)) */
row.setColumn(SYSALIASES_SCHEMAID, new SQLChar(schemaID));
/* 4th column is JAVACLASSNAME (longvarchar) */
row.setColumn(SYSALIASES_JAVACLASSNAME, dvf.getLongvarcharDataValue(javaClassName));
/* 5th column is ALIASTYPE (char(1)) */
row.setColumn(SYSALIASES_ALIASTYPE, new SQLChar(sAliasType));
/* 6th column is NAMESPACE (char(1)) */
String sNameSpace = new String(new char[] { cNameSpace });
row.setColumn(SYSALIASES_NAMESPACE, new SQLChar(sNameSpace));
/* 7th column is SYSTEMALIAS (boolean) */
row.setColumn(SYSALIASES_SYSTEMALIAS, new SQLBoolean(systemAlias));
/* 8th column is ALIASINFO (org.apache.derby.catalog.AliasInfo) */
row.setColumn(SYSALIASES_ALIASINFO, new UserType(aliasInfo));
/* 9th column is specific name */
row.setColumn(SYSALIASES_SPECIFIC_NAME, new SQLVarchar(specificName));
return row;
}
Aggregations