"Add column failed to create " + newColumnName
+ " because it already exists!"));
}
//add new column to this table
//add column after the column with hNodeId
HNode ndid = hTable.addNewHNodeAfter(hNodeId, HNodeType.Transformation, workspace.getFactory(), newColumnName, worksheet,true);
if(ndid == null)
{
logger.error("Unable to add new HNode!");
throw new KarmaException("Unable to add new HNode!");
}
//add as first column in the table if hNodeId is null
//HNode ndid = currentTable.addNewHNodeAfter(null, vWorkspace.getRepFactory(), newColumnName, worksheet,true);
//save the new hNodeId for undo
newHNodeId = ndid.getId();
// Populate the column with default value if default value is present
if (this.defaultValue != null && !this.defaultValue.equals("")) {
populateRowsWithDefaultValues(worksheet, workspace.getFactory());
}
//create container and return hNodeId of newly created column
UpdateContainer c = new UpdateContainer(new AddColumnUpdate(newHNodeId, worksheetId));
c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet)));
c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace, ndid.getHNodePath(workspace.getFactory())));
return c;
} catch (Exception e) {
logger.error("Error in AddColumnCommand" + e.toString());
Util.logException(logger, e);
return new UpdateContainer(new ErrorUpdate(e.getMessage()));