Package io.lumify.rdf

Source Code of io.lumify.rdf.RdfImportTool

package io.lumify.rdf;

import io.lumify.core.cmdline.CommandLineBase;
import io.lumify.core.exception.LumifyException;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.securegraph.Visibility;

import java.io.File;

public class RdfImportTool extends CommandLineBase {
    public static void main(String[] args) throws Exception {
        int res = new RdfImportTool().run(args);
        if (res != 0) {
            System.exit(res);
        }
    }

    @Override
    protected Options getOptions() {
        Options options = super.getOptions();

        options.addOption(
                OptionBuilder
                        .withLongOpt("in")
                        .withDescription("Input file")
                        .isRequired()
                        .hasArg(true)
                        .withArgName("filename")
                        .create("i")
        );

        return options;
    }

    @Override
    protected int run(CommandLine cmd) throws Exception {
        String inputFileName = cmd.getOptionValue("in");
        File inputFile = new File(inputFileName);
        if (!inputFile.exists()) {
            throw new LumifyException("Could not find file: " + inputFileName);
        }

        RdfGraphPropertyWorker rdfGraphPropertyWorker = new RdfGraphPropertyWorker();

        Visibility visibility = new Visibility("");
        rdfGraphPropertyWorker.importRdf(getGraph(), inputFile, null, visibility, getAuthorizations());
        getGraph().flush();

        return 0;
    }
}
TOP

Related Classes of io.lumify.rdf.RdfImportTool

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.