I have a graph object that contains an XMLReader (with multiple sheets).
after initGraph(), I have a FOR-loop to change the sheetname and
execute the same graph object.
is it possible to change the sheetname after the graph was initialized?
if my code is not correct, can you give me the solution? thanks.
TransformationGraph graph = new TransformationGraph();
try {
graph = graphReader.read(new FileInputStream(graphFile)); ----------- read XML graph.
GraphExecutor.initGraph(graph);
} catch (Exception e) {
logger.error("Exception occurred: ", e);
logger.error("Failed to read graph !\n" + e.getMessage());
return;
}
// change the sheetname of the XLSReader and execute the graph object.
for (int i = 0; i < f.getNumsheets(); ++i) {
Map <String> nodes = graph.getNodes();
XLSReader xls = (XLSReader) nodes.get("XLS_READER0");
xls.setSheetName(f.sheetNames[i];) ----------- can I change the sheetname after the graph was init?????
Future<Result> result =null;
try {
result = executor.runGraph(graph, runtimeContext);
} catch (Exception e) {
logger.error("Failed graph execution!\n" + e.getMessage());
return;
}
} // end
after initGraph(), I have a FOR-loop to change the sheetname and
execute the same graph object.
is it possible to change the sheetname after the graph was initialized?
if my code is not correct, can you give me the solution? thanks.
TransformationGraph graph = new TransformationGraph();
try {
graph = graphReader.read(new FileInputStream(graphFile)); ----------- read XML graph.
GraphExecutor.initGraph(graph);
} catch (Exception e) {
logger.error("Exception occurred: ", e);
logger.error("Failed to read graph !\n" + e.getMessage());
return;
}
// change the sheetname of the XLSReader and execute the graph object.
for (int i = 0; i < f.getNumsheets(); ++i) {
Map <String> nodes = graph.getNodes();
XLSReader xls = (XLSReader) nodes.get("XLS_READER0");
xls.setSheetName(f.sheetNames[i];) ----------- can I change the sheetname after the graph was init?????
Future<Result> result =null;
try {
result = executor.runGraph(graph, runtimeContext);
} catch (Exception e) {
logger.error("Failed graph execution!\n" + e.getMessage());
return;
}
} // end
-
Hi,
you should most probably call init() on the XLSReader after you change its sheet name.
Jaro -
Hi:
I changed my code to set the sheetname of the XLSReader and call the init(). However, the graph object is not getting the new name.
TransformationGraph graph = new TransformationGraph();
try {
graph = graphReader.read(new FileInputStream(graphFile));
GraphExecutor.initGraph(graph);
} catch (Exception e) {
logger.error("Exception occurred: ", e);
logger.error("Failed to read graph !\n" + e.getMessage());
return;
}
// change the sheetname of the XLSReader and execute the graph object.
for (int i = 0; i < f.getNumsheets(); ++i) {
Map <String> nodes = graph.getNodes();
XLSReader xls = (XLSReader) nodes.get("XLS_READER0");
xls.setSheetName(f.sheetNames[i] ) <--- set a new sheetname.
Future<Result> result =null;
try {
Xls.init(); -------------- re-init the XLS reader. (sheetname did not change to the new name).
result = executor.runGraph(graph, runtimeContext);
} catch (Exception e) {
logger.error("Failed graph execution!\n" + e.getMessage());
return;
}
} // end -
Hi,
please try calling free() before the init(), that might help.
Jaro
Please sign in to leave a comment.
Comments 3