/** * Sets the Content Type for CONSTRUCT/DESCRIBE queries provided that the * format is supported * * @param contentType */ public void setModelContentType(String contentType) { // Check that this is a valid setting Lang lang = RDFLanguages.contentTypeToLang(contentType); if (lang == null) throw new IllegalArgumentException("Given Content Type '" + contentType + "' is not supported by RIOT"); if (!RDFLanguages.isTriples(lang)) throw new IllegalArgumentException("Given Content Type '" + contentType + "' is not a RDF Graph format"); modelContentType = contentType; }
/** * Sets the Content Type for CONSTRUCT/DESCRIBE queries provided that the * format is supported * * @param contentType */ public void setModelContentType(String contentType) { // Check that this is a valid setting Lang lang = RDFLanguages.contentTypeToLang(contentType); if (lang == null) throw new IllegalArgumentException("Given Content Type '" + contentType + "' is not supported by RIOT"); if (!RDFLanguages.isTriples(lang)) throw new IllegalArgumentException("Given Content Type '" + contentType + "' is not a RDF Graph format"); modelContentType = contentType; } }
@Override protected RecordWriter<TKey, TripleWritable> getRecordWriter(Writer writer, Configuration config, Path outputPath) throws IOException { Lang lang = RDFLanguages.filenameToLang(outputPath.getName()); if (lang == null) throw new IOException("There is no registered RDF language for the output file " + outputPath.toString()); if (!RDFLanguages.isTriples(lang)) throw new IOException( lang.getName() + " is not a RDF triples format, perhaps you wanted QuadsOutputFormat or TriplesOrQuadsOutputFormat instead?"); // This will throw an appropriate error if the language does not support writing triples return HadoopRdfIORegistry.<TKey>createTripleWriter(lang, writer, config); }
@Override protected RecordReader<LongWritable, TripleWritable> selectRecordReader(Lang lang) throws IOException { if (!RDFLanguages.isTriples(lang)) throw new IOException( lang.getLabel() + " is not a RDF triples format, perhaps you wanted QuadsInputFormat or TriplesOrQuadsInputFormat instead?"); // This will throw an appropriate error if the language does not support // triples return HadoopRdfIORegistry.createTripleReader(lang); }
@Override protected RecordReader<LongWritable, TripleWritable> selectRecordReader(Lang lang) throws IOException { if (!RDFLanguages.isTriples(lang)) throw new IOException( lang.getLabel() + " is not a RDF triples format, perhaps you wanted QuadsInputFormat or TriplesOrQuadsInputFormat instead?"); // This will throw an appropriate error if the language does not support // triples return HadoopRdfIORegistry.createTripleReader(lang); }
@Override protected RecordWriter<TKey, TripleWritable> getRecordWriter(Writer writer, Configuration config, Path outputPath) throws IOException { Lang lang = RDFLanguages.filenameToLang(outputPath.getName()); if (lang == null) throw new IOException("There is no registered RDF language for the output file " + outputPath.toString()); if (!RDFLanguages.isTriples(lang)) throw new IOException( lang.getName() + " is not a RDF triples format, perhaps you wanted QuadsOutputFormat or TriplesOrQuadsOutputFormat instead?"); // This will throw an appropriate error if the language does not support writing triples return HadoopRdfIORegistry.<TKey>createTripleWriter(lang, writer, config); }
/** Set the output format for sending RDF graphs to the remote server. * This is used for the SPARQ Graph Store Protocol. */ public RDFConnectionRemoteBuilder triplesFormat(RDFFormat fmtTriples) { if ( ! RDFLanguages.isTriples(fmtTriples.getLang()) ) throw new RiotException("Not a language for RDF Graphs: "+fmtTriples); this.outputTriples = fmtTriples; return this; }
/** Set the output format for sending RDF graphs to the remote server. * This is used for the SPARQ Graph Store Protocol. */ public RDFConnectionRemoteBuilder triplesFormat(RDFFormat fmtTriples) { if ( ! RDFLanguages.isTriples(fmtTriples.getLang()) ) throw new RiotException("Not a language for RDF Graphs: "+fmtTriples); this.outputTriples = fmtTriples; return this; }
/** Set the output format for sending RDF graphs to the remote server. * This is used for the SPARQ Graph Store Protocol. */ public RDFConnectionRemoteBuilder triplesFormat(Lang langTriples) { Objects.requireNonNull(langTriples); if ( ! RDFLanguages.isTriples(langTriples) ) throw new RiotException("Not a language for RDF triples: "+langTriples); RDFFormat fmt = RDFWriterRegistry.defaultSerialization(langTriples); if ( fmt == null ) throw new RiotException("Language name not recognized: "+langTriples); triplesFormat(fmt); return this; }
/** Set the output format for sending RDF graphs to the remote server. * This is used for the SPARQ Graph Store Protocol. */ public RDFConnectionRemoteBuilder triplesFormat(Lang langTriples) { Objects.requireNonNull(langTriples); if ( ! RDFLanguages.isTriples(langTriples) ) throw new RiotException("Not a language for RDF triples: "+langTriples); RDFFormat fmt = RDFWriterRegistry.defaultSerialization(langTriples); if ( fmt == null ) throw new RiotException("Language name not recognized: "+langTriples); triplesFormat(fmt); return this; }
@Override protected RecordWriter<TKey, QuadWritable> getRecordWriter(Writer writer, Configuration config, Path outputPath) throws IOException { Lang lang = RDFLanguages.filenameToLang(outputPath.getName()); if (lang == null) throw new IOException("There is no registered RDF language for the output file " + outputPath.toString()); if (!RDFLanguages.isQuads(lang) && !RDFLanguages.isTriples(lang)) throw new IOException(lang.getName() + " is not a RDF triples/quads format"); if (HadoopRdfIORegistry.hasQuadWriter(lang)) { // Supports quads directly return HadoopRdfIORegistry.<TKey> createQuadWriter(lang, writer, config); } else { // Try to create a triples writer and wrap downwards from quads // This will throw an error if a triple writer is not available return new QuadsToTriplesWriter<TKey>(HadoopRdfIORegistry.<TKey> createTripleWriter(lang, writer, config)); } }
@Override protected RecordReader<LongWritable, QuadWritable> selectRecordReader(Lang lang) throws IOException { if (!RDFLanguages.isQuads(lang) && !RDFLanguages.isTriples(lang)) throw new IOException(lang.getLabel() + " is not a RDF triples/quads format"); if (HadoopRdfIORegistry.hasQuadReader(lang)) { // Supports quads directly return HadoopRdfIORegistry.createQuadReader(lang); } else { // Try to create a triples reader and wrap upwards into quads // This will throw an error if a triple reader is not available return new TriplesToQuadsReader(HadoopRdfIORegistry.createTripleReader(lang)); } }
@Override protected RecordReader<LongWritable, QuadWritable> selectRecordReader(Lang lang) throws IOException { if (!RDFLanguages.isQuads(lang) && !RDFLanguages.isTriples(lang)) throw new IOException(lang.getLabel() + " is not a RDF triples/quads format"); if (HadoopRdfIORegistry.hasQuadReader(lang)) { // Supports quads directly return HadoopRdfIORegistry.createQuadReader(lang); } else { // Try to create a triples reader and wrap upwards into quads // This will throw an error if a triple reader is not available return new TriplesToQuadsReader(HadoopRdfIORegistry.createTripleReader(lang)); } }
@Override public void runTestForReal() { if ( RDFLanguages.isTriples(lang) ) run3() ; else run4() ; }
@Override public void runTestForReal() { if ( RDFLanguages.isTriples(lang) ) run3() ; else run4() ; }
@Override public void runTestForReal() { if ( RDFLanguages.isTriples(lang) ) run3() ; else run4() ; }
@Override public void runTestForReal() { // Could generalise run4() to cover both cases. // run3() predates dataset reading and is more tested. if ( RDFLanguages.isTriples(lang) ) run3() ; else run4() ; }
/** Send a file to named graph (or "default" or null for the default graph). * <p> * The Content-Type is inferred from the file extension. * <p> * "Replace" means overwrite existing data, othewise the date is added to the target. */ protected void upload(String graph, String file, boolean replace) { // if triples Lang lang = RDFLanguages.filenameToLang(file); if ( RDFLanguages.isQuads(lang) ) throw new ARQException("Can't load quads into a graph"); if ( ! RDFLanguages.isTriples(lang) ) throw new ARQException("Not an RDF format: "+file+" (lang="+lang+")"); String url = LibRDFConn.urlForGraph(svcGraphStore, graph); doPutPost(url, file, lang, replace); }
@Test public void jenaSystem_read_1() { assertTrue(RDFLanguages.isRegistered(JenaJSONLD.JSONLD)); assertTrue(RDFLanguages.isTriples(JenaJSONLD.JSONLD)); assertTrue(RDFLanguages.isQuads(JenaJSONLD.JSONLD)); }