protected void generateTransformedValues(Workspace workspace,
Worksheet worksheet, RepFactory f, HNode hNode,
JSONArray transformedRows, JSONArray errorValues, Integer limit)
throws JSONException, IOException {
SuperSelection selection = getSuperSelection(worksheet);
String trimmedTransformationCode = transformationCode.trim();
// Pedro: somehow we are getting empty statements, and these are causing
// exceptions.
if (trimmedTransformationCode.isEmpty()) {
trimmedTransformationCode = "return \"\"";
logger.info("Empty PyTransform statement in "
+ hNode.getColumnName());
}
String transformMethodStmt = PythonTransformationHelper
.getPythonTransformMethodDefinitionState(worksheet,
trimmedTransformationCode);
logger.debug("Executing PyTransform\n" + transformMethodStmt);
// Prepare the Python interpreter
PythonInterpreter interpreter = new PythonInterpreter();
PythonRepository repo = PythonRepository.getInstance();
repo.initializeInterperter(interpreter);
repo.importUserScripts(interpreter);
repo.compileAndAddToRepositoryAndExec(interpreter, transformMethodStmt);
Collection<Node> nodes = new ArrayList<Node>(Math.max(1000, worksheet
.getDataTable().getNumRows()));
worksheet.getDataTable().collectNodes(hNode.getHNodePath(f), nodes, selection);
Map<String, String> rowToValueMap = new HashMap<String, String>();
int counter = 0;
long starttime = System.currentTimeMillis();
// Go through all nodes collected for the column with given hNodeId
interpreter.set("workspaceid", workspace.getId());
interpreter.set("command", this);
interpreter.set("selectionName", selection.getName());
PyCode py = repo.getTransformCode();
int numRowsWithErrors = 0;
for (Node node : nodes) {