@ConsoleCommand(aliases = { "display" }, description = "Display current record attributes", onlineHelp = "Console-Command-Display-Record") public void displayRecord( @ConsoleParameter(name = "number", description = "The number of the record in the most recent result set") final String iRecordNumber) { checkForDatabase(); if (iRecordNumber == null || currentResultSet == null) checkCurrentObject(); else { int recNumber = Integer.parseInt(iRecordNumber); if (currentResultSet.size() == 0) throw new OSystemException("No result set where to find the requested record. Execute a query first."); if (currentResultSet.size() <= recNumber) throw new OSystemException("The record requested is not part of current result set (0" + (currentResultSet.size() > 0 ? "-" + (currentResultSet.size() - 1) : "") + ")"); setCurrentRecord(recNumber); } dumpRecordDetails(); }
@ConsoleCommand(description = "Export the current record in the requested format", onlineHelp = "Console-Command-Export-Record") public void exportRecord(@ConsoleParameter(name = "format", description = "Format, such as 'json'") final String iFormat, @ConsoleParameter(name = "options", description = "Options", optional = true) String iOptions) throws IOException { checkForDatabase(); checkCurrentObject(); final ORecordSerializer serializer = ORecordSerializerFactory.instance().getFormat(iFormat.toLowerCase(Locale.ENGLISH)); if (serializer == null) { message("\nERROR: Format '" + iFormat + "' was not found."); printSupportedSerializerFormat(); return; } else if (!(serializer instanceof ORecordSerializerStringAbstract)) { message("\nERROR: Format '" + iFormat + "' does not export as text."); printSupportedSerializerFormat(); return; } if (iOptions == null || iOptions.length() <= 0) { iOptions = "rid,version,class,type,keepTypes,alwaysFetchEmbedded,fetchPlan:*:0,prettyPrint"; } try { out.println(currentRecord.toJSON(iOptions)); } catch (ODatabaseExportException e) { printError(e); } }