Search in sources :

Example 1 with ORecordSerializerStringAbstract

use of com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract in project orientdb by orientechnologies.

the class OConsoleDatabaseApp method exportRecord.

@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);
    }
}
Also used : ORecordSerializerStringAbstract(com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract) ORecordSerializer(com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializer) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Aggregations

ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)1 ORecordSerializer (com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializer)1 ORecordSerializerStringAbstract (com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract)1