try{
if(hTableId==null || hTableId.isEmpty()){
//get table id based on the hNodeId
if(hNodeId==null)
throw new KarmaException("TableId and NodeId are empty. Can't add column.");
hTableId = workspace.getFactory().getHNode(hNodeId).getHTableId();
}
HTable hTable = workspace.getFactory().getHTable(hTableId);
if(hTable == null)
{
logger.error("No HTable for id "+ hTableId);
throw new KarmaException("No HTable for id "+ hTableId );
}
if (null != hTable.getHNodeFromColumnName(newColumnName)) {
logger.error("Add column failed to create " + newColumnName
+ " because it already exists!");
return new UpdateContainer(new ErrorUpdate(
"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