}
public void split(HashMap<Node, CellValue> oldNodeValueMap,
HashMap<Node, NodeStatus> oldNodeStatusMap) {
RepFactory factory = workspace.getFactory();
HNode hNode = factory.getHNode(hNodeId);
// The column should not have a nested table but check to make sure!
if (hNode.hasNestedTable()) {
logger.error("Column has nested table. Cannot perform split operation.");
return;
}
HNodePath selectedPath = null;
List<HNodePath> columnPaths = worksheet.getHeaders().getAllPaths();
for (HNodePath path : columnPaths) {
if (path.getLeaf().getId().equals(hNodeId)) {
hNode = path.getLeaf();
selectedPath = path;
break;
}
}
// Convert the delimiter into character primitive type
char delimiterChar = ',';
if (delimiter.equalsIgnoreCase("space"))
delimiterChar = ' ';
else if (delimiter.equalsIgnoreCase("tab"))
delimiterChar = '\t';
else {
delimiterChar = new Character(delimiter.charAt(0));
}
Collection<Node> nodes = new ArrayList<Node>();
worksheet.getDataTable().collectNodes(selectedPath, nodes, selection);
//pedro: 2012-10-09
// Need to save and clear the values before adding the nested table.
// Otherwise we have both a value and a nested table, which is not legal.
for (Node node : nodes) {
if (oldNodeValueMap != null)
oldNodeValueMap.put(node, node.getValue());
if (oldNodeStatusMap != null)
oldNodeStatusMap.put(node, node.getStatus());
node.clearValue(NodeStatus.edited);
}
//pedro: 2012-10-09
// Now that we cleared the values it is safe to add the nested table.
//
// Add the nested new HTable to the hNode
HTable newTable = hNode.addNestedTable("Comma Split Values", worksheet,
factory);
splitValueHNodeId = newTable.addHNode("Values", HNodeType.Transformation, worksheet, factory)
.getId();
for (Node node : nodes) {