package com.thinkaurelius.titan.hadoop.formats.edgelist.rdf;

import com.thinkaurelius.titan.diskstorage.configuration.ConfigNamespace;
import com.thinkaurelius.titan.diskstorage.configuration.ConfigOption;
import org.openrdf.rio.RDFFormat;

public class RDFConfig {

    public static final String URI = "uri";
    public static final String CONTEXT = "context";
    public static final String NAME = "name";

    public static enum Syntax {
        RDF_XML(RDFFormat.RDFXML),
        N_TRIPLES(RDFFormat.NTRIPLES),
        TURTLE(RDFFormat.TURTLE),
        N3(RDFFormat.N3),
        TRIX(RDFFormat.TRIX),
        TRIG(RDFFormat.TRIG);

        private final RDFFormat fmt;

        private Syntax(RDFFormat fmt) {
            this.fmt = fmt;
        }

        public RDFFormat getRDFFormat() {
            return fmt;
        }
    }

    public static final ConfigNamespace RDF_ROOT = new ConfigNamespace(null, "rdf", "RDF MapReduce format options");

    public static final ConfigOption<Syntax> RDF_FORMAT =
            new ConfigOption<Syntax>(RDF_ROOT, "format",
            "The format/syntax/dialect of the RDF input file(s)",
            ConfigOption.Type.LOCAL, Syntax.class);

    public static final ConfigOption<Boolean> RDF_USE_LOCALNAME =
            new ConfigOption<Boolean>(RDF_ROOT, "use-localname",
            "Whether to tolerate fragments when parsing RDF input",
            ConfigOption.Type.LOCAL, false);

    public static final ConfigOption<Boolean> RDF_LITERAL_AS_PROPERTY =
            new ConfigOption<Boolean>(RDF_ROOT, "literal-as-property",
            "Whether to turn RDF triples where the object is a literal value into " +
            "properties on the subject, where the property name is the predicate and " +
            "the property value is the literal object.",
            ConfigOption.Type.LOCAL, false);

    public static final ConfigOption<String[]> RDF_AS_PROPERTIES =
            new ConfigOption<String[]>(RDF_ROOT, "as-properties",
            "A comma-separated list of predicate URIs for which matching triples " +
            "will be converted into properties instead of edges",
            ConfigOption.Type.LOCAL, String[].class);

    public static final ConfigOption<String> RDF_BASE_URI =
            new ConfigOption<String>(RDF_ROOT, "base-uri",
            "The URI used to resolve any relative URI references encountered in the input",
            ConfigOption.Type.LOCAL, "http://thinkaurelius.com#");
}

@@ -55,16 +55,57 @@
 t.rdf;%0A%0A
+import com.google.common.base.Predicate;%0A
 import c
@@ -276,16 +276,51 @@
 ormat;%0A%0A
+import javax.annotation.Nullable;%0A%0A
 public c
@@ -2256,24 +2256,337 @@
 ring%5B%5D.class
+, new String%5B%5D%7B%7D,%0A            new Predicate%3CString%5B%5D%3E() %7B%0A                @Override%0A                public boolean apply(@Nullable String%5B%5D input) %7B%0A                    // Zero-length array is allowed (and the default), but null disallowed%0A                    return null != input;%0A                %7D%0A            %7D
 );%0A%0A    publ

Allow empty list of RDF as-properties URIs