@Override
public SeTable execute(ISession session, SeConnection connection) throws SeException,
IOException {
// SeConnection conn = session.unWrap();
SeLayer layer = new SeLayer(connection);
SeTable table;
/*
* Create a qualified table name with current user's name and the name of the table
* to be created, "EXAMPLE".
*/
String dbname = connection.getDatabaseName();
String user = connection.getUser();
StringBuffer sb = new StringBuffer();
if (dbname != null && dbname.length() > 0) {
sb.append(dbname).append(".");
}
if (user != null && user.length() > 0) {
sb.append(user).append(".");
}
String tableName = sb.append("VERSIONED_EXAMPLE").toString().toUpperCase();
table = new SeTable(connection, tableName);
layer.setTableName("VERSIONED_EXAMPLE");
try {
table.delete();
} catch (Exception e) {
// ignore, the table didn't exist already
}
SeColumnDefinition[] colDefs = new SeColumnDefinition[2];
boolean isNullable = true;
// first column to be SDE managed feature id
colDefs[0] = new SeColumnDefinition("ROW_ID", SeColumnDefinition.TYPE_INT32, 10, 0,
false);
colDefs[1] = new SeColumnDefinition("NAME", SeColumnDefinition.TYPE_STRING, 25, 0,
isNullable);
table.create(colDefs, getConfigKeyword());
layer.setSpatialColumnName("SHAPE");
/*
* Register the column to be used as feature id and managed by sde
*/
SeRegistration reg = new SeRegistration(connection, table.getName());
LOGGER.fine("setting rowIdColumnName to ROW_ID in table " + reg.getTableName());
reg.setRowIdColumnName("ROW_ID");
reg.setRowIdColumnType(SeRegistration.SE_REGISTRATION_ROW_ID_COLUMN_TYPE_SDE);
reg.alter();
layer.setShapeTypes(SeLayer.SE_NIL_TYPE_MASK | SeLayer.SE_POINT_TYPE_MASK);
layer.setGridSizes(1100.0, 0.0, 0.0);
layer.setDescription("Layer Example");
SeExtent ext = new SeExtent(0.0, 0.0, 10000.0, 10000.0);
layer.setExtent(ext);
/*
* Define the layer's Coordinate Reference
*/
SeCoordinateReference coordref = getGenericCoordRef();
layer.setCoordRef(coordref);
/*
* Spatially enable the new table...
*/
layer.setCreationKeyword(getConfigKeyword());
layer.create(3, 4);
// register the table as versioned
SeRegistration registration = new SeRegistration(connection, tableName);
registration.setMultiVersion(true);
registration.alter();