use of com.tinkerpop.blueprints.util.io.graphml.GraphMLWriter in project orientdb by orientechnologies.
the class OGremlinConsole method exportDatabase.
@Override
@ConsoleCommand(description = "Export a database", splitInWords = false, onlineHelp = "Console-Command-Export")
public void exportDatabase(@ConsoleParameter(name = "options", description = "Export options") String iText) throws IOException {
checkForDatabase();
final List<String> items = OStringSerializerHelper.smartSplit(iText, ' ');
final String fileName = items.size() <= 1 || items.get(1).charAt(0) == '-' ? null : items.get(1);
if (fileName != null && (fileName.endsWith(".graphml") || fileName.endsWith(".xml"))) {
message("\nExporting database in GRAPHML format to " + iText + "...");
try {
final OrientGraph g = (OrientGraph) OrientGraphFactory.getTxGraphImplFactory().getGraph(currentDatabase);
g.setUseLog(false);
g.setWarnOnForceClosingTx(false);
// CREATE THE EXPORT FILE IF NOT EXIST YET
final File f = new File(fileName);
if (f.getParentFile() != null) {
f.getParentFile().mkdirs();
}
f.createNewFile();
new GraphMLWriter(g).outputGraph(fileName);
} catch (ODatabaseImportException e) {
printError(e);
}
} else
// BASE EXPORT
super.exportDatabase(iText);
}
use of com.tinkerpop.blueprints.util.io.graphml.GraphMLWriter in project hale by halestudio.
the class TransformationTreeMetadataHook method processTransformationTree.
/**
* @see TransformationTreeHook#processTransformationTree(TransformationTree,
* TreeState, MutableInstance)
*/
@Override
public void processTransformationTree(TransformationTree tree, TreeState state, MutableInstance target) {
if (state == TreeState.SOURCE_POPULATED) {
// TODO key per state - for
// now only support this
// state
TreeGraphProvider prov = new TreeGraphMLProvider(tree);
Graph graph = prov.generateGraph();
GraphMLWriter writer = new GraphMLWriter(graph);
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
writer.outputGraph(out);
} catch (Exception e) {
log.error("Error converting GraphML Graph to String", e);
}
String graphstring = new String(out.toByteArray());
target.setMetaData(KEY_POPULATED_TREE, graphstring);
}
}
Aggregations