@ConsoleCommand(description = "Export a database", splitInWords = false, onlineHelp = "Console-Command-Export") public void exportDatabase(@ConsoleParameter(name = "options", description = "Export options") final String iText) throws IOException { checkForDatabase(); out.println(new StringBuilder("Exporting current database to: ").append(iText).append(" in GZipped JSON format ...")); final List<String> items = OStringSerializerHelper.smartSplit(iText, ' '); final String fileName = items.size() <= 1 || items.get(1).charAt(0) == '-' ? null : items.get(1); final String options = fileName != null ? iText.substring(items.get(0).length() + items.get(1).length() + 1).trim() : iText; try { new ODatabaseExport(currentDatabase, fileName, this).setOptions(options).exportDatabase().close(); } catch (ODatabaseExportException e) { printError(e); } }
@Override public void exportGraph(String outputDirectory) throws IOException { if (log.isDebugEnabled()) { log.debug("Running export to {" + outputDirectory + "} directory."); } ODatabaseDocumentTx db = factory.getDatabase(); try { OCommandOutputListener listener = new OCommandOutputListener() { @Override public void onMessage(String iText) { System.out.println(iText); } }; String dateString = formatter.format(new Date()); String exportFile = "export_" + dateString; new File(outputDirectory).mkdirs(); ODatabaseExport export = new ODatabaseExport(db, new File(outputDirectory, exportFile).getAbsolutePath(), listener); export.exportDatabase(); export.close(); } finally { db.close(); } }
protected String exportEvent(String path) { final String[] result = new String[1]; OrientGraph graph = ServiceLocator.getInstance().getGraph(); try{ OCommandOutputListener listener = new OCommandOutputListener() { @Override public void onMessage(String iText) { result[0] = result[0] + iText; } }; ODatabaseExport export = new ODatabaseExport(graph.getRawGraph(), path, listener); export.exportDatabase(); export.close(); } catch(IOException ioe) { ioe.printStackTrace(); } finally { graph.shutdown(); } return result[0]; }
public static void exp() { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try{ OCommandOutputListener listener = new OCommandOutputListener() { @Override public void onMessage(String iText) { System.out.print(iText); } }; ODatabaseExport export = new ODatabaseExport(graph.getRawGraph(), "/tmp/export", listener); export.exportDatabase(); export.close(); } catch(IOException ioe) { ioe.printStackTrace(); } finally { graph.shutdown(); } } }
@ConsoleCommand(description = "Export a database schema") public void exportSchema(@ConsoleParameter(name = "output-file", description = "Output file path") final String iOutputFilePath) throws IOException { checkForDatabase(); message("\nExporting current database to: " + iOutputFilePath + "..."); try { ODatabaseExport exporter = new ODatabaseExport(currentDatabase, iOutputFilePath, this); exporter.setIncludeRecords(false); exporter.exportDatabase().close(); } catch (ODatabaseExportException e) { printError(e); } }
public ODatabaseExport exportDatabase() { try { listener.onMessage("\nStarted export of database '" + database.getName() + "' to " + fileName + "..."); long time = System.currentTimeMillis(); if (includeInfo) exportInfo(); if (includeClusterDefinitions) exportClusters(); if (includeSchema) exportSchema(); if (includeRecords) exportRecords(); if (includeIndexDefinitions) exportIndexDefinitions(); if (includeManualIndexes) exportManualIndexes(); listener.onMessage("\n\nDatabase export completed in " + (System.currentTimeMillis() - time) + "ms"); writer.flush(); } catch (Exception e) { OLogManager.instance().error(this, "Error on exporting database '%s' to: %s", e, database.getName(), fileName); throw new ODatabaseExportException("Error on exporting database '" + database.getName() + "' to: " + fileName, e); } finally { close(); } return this; }