* that every leaf node is a measurement unit, and the objective tree
* leaves are one level higher. So we stop one level earlier,
* the units are not imported at the moment.
*/
public ObjectiveTree loadFreeMindStream(InputStream in, boolean hasUnits, boolean hasLeaves) {
MindMap map = new MindMap();
// load content into temporary structure
Digester digester = new Digester();
digester.setSchema("/data/schemas/freemind.xsd");
digester.setValidating(true);
digester.push(map);
digester.addObjectCreate("*/node",
"eu.planets_project.pp.plato.xml.freemind.Node");
digester.addSetProperties("*/node");
digester.addCallMethod("*/node/hook/text","setDESCRIPTION",0);
digester.addSetNext("*/node","addChild");
try {
//InputStream s = Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
digester.setUseContextClassLoader(true);
digester.parse(in);
} catch (IOException e) {
log.error("Error loading Freemind file. Cause: " + e.getMessage());
return null;
} catch (SAXException e) {
log.error("Document is not a valid Freemind file. Cause: " + e.getMessage());
return null;
}
// traverse temp structure of map and nodes and create ObjectiveTree
ObjectiveTree tree = new ObjectiveTree();
tree.setRoot(map.getObjectiveTreeRoot(hasUnits, hasLeaves));
if (tree.getRoot().isLeaf()) {
return null;
}
return tree;
}