final String[] typeNameParts = featureType.getTypeName().split("\\.");
final String unqualifiedTypeName = typeNameParts[typeNameParts.length - 1];
// Create a new SeTable/SeLayer with the specified attributes....
SeTable table = null;
SeLayer layer = null;
// flag to know if the table was created by us when catching an
// exception.
boolean tableCreated = false;
// table/layer creation hints information
int rowIdType = SeRegistration.SE_REGISTRATION_ROW_ID_COLUMN_TYPE_NONE;
String rowIdColumn = null;
String configKeyword = "DEFAULTS";
if (hints.containsKey("configuration.keyword")) {
configKeyword = String.valueOf(hints.get("configuration.keyword"));
}
if (hints.get("rowid.column.type") instanceof String) {
String rowIdStr = (String) hints.get("rowid.column.type");
if (rowIdStr.equalsIgnoreCase("NONE")) {
rowIdType = SeRegistration.SE_REGISTRATION_ROW_ID_COLUMN_TYPE_NONE;
} else if (rowIdStr.equalsIgnoreCase("USER")) {
rowIdType = SeRegistration.SE_REGISTRATION_ROW_ID_COLUMN_TYPE_USER;
} else if (rowIdStr.equalsIgnoreCase("SDE")) {
rowIdType = SeRegistration.SE_REGISTRATION_ROW_ID_COLUMN_TYPE_SDE;
} else {
throw new DataSourceException(
"createSchema hint 'rowid.column.type' must be one of 'NONE', 'USER' or 'SDE'");
}
}
if (hints.get("rowid.column.name") instanceof String) {
rowIdColumn = (String) hints.get("rowid.column.name");
}
// placeholder to a catched exception to know in the finally block
// if we should cleanup the crap we left in the database
Exception error = null;
try {
// create a table with provided username
String qualifiedName = null;
if (unqualifiedTypeName.indexOf('.') == -1) {
// Use the already parsed name (unqualifiedTypeName)
qualifiedName = connection.getUser() + "." + unqualifiedTypeName; // featureType.getTypeName();
LOGGER.finer("new full qualified type name: " + qualifiedName);
} else {
qualifiedName = unqualifiedTypeName;
LOGGER.finer("full qualified type name provided by user: " + qualifiedName);
}
layer = new SeLayer(connection);
layer.setTableName(qualifiedName);
layer.setCreationKeyword(configKeyword);
final String HACK_COL_NAME = "gt_workaround_col_";
table = createSeTable(connection, qualifiedName, HACK_COL_NAME, configKeyword);
tableCreated = true;