} else {
geoms = g;
}
final SeCoordinateReference coordref = layer.getCoordRef();
final SeShape shapes[] = new SeShape[8];
for (int i = 0; i < shapes.length; i++) {
Geometry geom = geoms[i];
SeShape shape;
if (geom == null) {
shape = null;
} else {
IsValidOp validationOp = new IsValidOp(geom);
TopologyValidationError validationError = validationOp.getValidationError();
if (validationError != null) {
throw new IllegalArgumentException("Provided geometry is invalid: "
+ validationError.getMessage());
}
ArcSDEGeometryBuilder builder = ArcSDEGeometryBuilder.builderFor(geom.getClass());
shape = builder.constructShape(geom, coordref);
}
shapes[i] = shape;
}
/*
* Define the names of the columns that data is to be inserted into.
*/
final String[] columns = new String[8];
columns[0] = colDefs[1].getName(); // INT32 column
columns[1] = colDefs[2].getName(); // INT16 column
columns[2] = colDefs[3].getName(); // FLOAT32 column
columns[3] = colDefs[4].getName(); // FLOAT64 column
columns[4] = colDefs[5].getName(); // String column
columns[5] = colDefs[6].getName(); // NString column
columns[6] = colDefs[7].getName(); // Date column
columns[7] = "SHAPE"; // Shape column
Command<Void> insertDataCmd = new Command<Void>() {
@Override
public Void execute(ISession session, SeConnection connection) throws SeException,
IOException {
SeInsert insert = new SeInsert(connection);
insert.intoTable(layer.getName(), columns);
insert.setWriteMode(true);
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
// Year, month, date, hour, minute, second.
cal.set(2004, 06, 1, 0, 0, 0);
try {
for (int i = 1; i <= shapes.length; i++) {
SeRow row = insert.getRowToSet();
// col #0 is the sde managed row id
row.setInteger(0, Integer.valueOf(i));
row.setShort(1, Short.valueOf((short) i));
row.setFloat(2, new Float(i / 10.0F));
row.setDouble(3, new Double(i / 10D));
row.setString(4, "FEATURE_" + i);
row.setNString(5, "NSTRING_" + i);
cal.set(Calendar.DAY_OF_MONTH, i);
row.setTime(6, cal);
SeShape seShape = shapes[i - 1];
row.setShape(7, seShape);
insert.execute();
}
} finally {