@Override public void run() { exportDatabase(); }
@Override protected void configureODatabaseExport(ODatabaseExport dbExport) { dbExport.setOptions("-excludeAll=true -includeSchema=true"); }
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]; }
@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); } }
@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); } }
@Override public void export(final OutputStream output, final Set<String> excludedClassNames) throws IOException { checkNotNull(output); checkNotNull(excludedClassNames); log.debug("Exporting database: {}", name); try (ODatabaseDocumentTx db = openDb()) { checkState(db.exists(), "Database does not exist: %s", name); log.debug("Starting export"); ODatabaseExport exporter = new ODatabaseExport(db, output, new LoggingCommandOutputListener("EXPORT")); if (!excludedClassNames.isEmpty()) { log.debug("excluding : {}", excludedClassNames); // case-insensitive to allow for orient using upper-case by default (and https://www.prjhub.com/#/issues/10298) exporter.setExcludeClasses(ImmutableSortedSet.copyOf(nullsFirst(CASE_INSENSITIVE_ORDER), excludedClassNames)); } exporter.exportDatabase(); log.debug("Completed export"); } }
@Override public void writeData(Attributes attributes) throws IOException { OutputStream out = attributes.getResponse().getOutputStream(); GZIPOutputStream gzipOut = new GZIPOutputStream(out); ODatabaseDocumentInternal db = (ODatabaseDocumentInternal)OrientDbWebSession.get().getDatabase(); ODatabaseExport dbExport = new ODatabaseExport(db, gzipOut, LoggerOCommandOutputListener.INSTANCE); configureODatabaseExport(dbExport); dbExport.exportDatabase(); } });
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; }
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(); } } }
@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(); } }