Search in sources :

Example 26 with PrefixMap

use of org.apache.jena.riot.system.PrefixMap in project jena by apache.

the class ThriftRDF method protocolToStream.

/**
 * Decode the contents of the TProtocol and send to the {@link StreamRDF}.
 * @param protocol TProtocol
 * @param dest Sink
 */
public static void protocolToStream(TProtocol protocol, StreamRDF dest) {
    PrefixMap pmap = PrefixMapFactory.create();
    final Thrift2StreamRDF s = new Thrift2StreamRDF(pmap, dest);
    dest.start();
    apply(protocol, z -> TRDF.visit(z, s));
    // Includes flushing the protocol.
    dest.finish();
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap)

Example 27 with PrefixMap

use of org.apache.jena.riot.system.PrefixMap in project jena by apache.

the class QueryExecDataset method insertPrefixesInto.

private void insertPrefixesInto(DatasetGraph dsg) {
    try {
        PrefixMap pmap = dsg.prefixes();
        if (dataset != null) {
            // Load the models prefixes first
            pmap.putAll(dataset.prefixes());
        }
        // Then add the queries (just the declared mappings)
        // so the query declarations override the data sources.
        query.getPrefixMapping().getNsPrefixMap().forEach((prefix, uri) -> pmap.add(prefix, uri));
    } catch (Exception ex) {
        Log.warn(this, "Exception in insertPrefixes: " + ex.getMessage(), ex);
    }
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap) QueryExecException(org.apache.jena.query.QueryExecException) QueryCancelledException(org.apache.jena.query.QueryCancelledException)

Example 28 with PrefixMap

use of org.apache.jena.riot.system.PrefixMap in project jena by apache.

the class QueryExecDataset method insertPrefixesInto.

private void insertPrefixesInto(Graph graph) {
    try {
        if (dataset != null) {
            // Load the models prefixes first
            PrefixMap m = dataset.prefixes();
            m.forEach((prefix, uri) -> graph.getPrefixMapping().setNsPrefix(prefix, uri));
        }
        // Then add the queries (just the declared mappings)
        // so the query declarations override the data sources.
        graph.getPrefixMapping().setNsPrefixes(query.getPrefixMapping());
    } catch (Exception ex) {
        Log.warn(this, "Exception in insertPrefixes: " + ex.getMessage(), ex);
    }
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap) QueryExecException(org.apache.jena.query.QueryExecException) QueryCancelledException(org.apache.jena.query.QueryCancelledException)

Example 29 with PrefixMap

use of org.apache.jena.riot.system.PrefixMap in project jena by apache.

the class TestPrefixMappingOverDatasetPrefixes method view.

@Override
protected PrefixMapping view() {
    StoragePrefixMap view = StoragePrefixesView.internal_viewDefaultGraph(dsgprefixes);
    PrefixMap pmap = PrefixesDboeFactory.newPrefixMap(view);
    return Prefixes.adapt(pmap);
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap)

Example 30 with PrefixMap

use of org.apache.jena.riot.system.PrefixMap in project jena by apache.

the class TestPrefixLib method abbreviate_1.

@Test
public void abbreviate_1() {
    PrefixMap prefixes = create();
    prefixes.add(pref1, "http://example.net/ns#");
    String x = PrefixLib.abbreviate(prefixes, "http://example.net/ns#xyz");
    assertEquals("pref1:xyz", x);
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap) Test(org.junit.Test)

Aggregations

PrefixMap (org.apache.jena.riot.system.PrefixMap)33 Test (org.junit.Test)16 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)10 Map (java.util.Map)3 Node (org.apache.jena.graph.Node)2 QueryCancelledException (org.apache.jena.query.QueryCancelledException)2 QueryExecException (org.apache.jena.query.QueryExecException)2 NodeFormatter (org.apache.jena.riot.out.NodeFormatter)2 NodeFormatterTTL (org.apache.jena.riot.out.NodeFormatterTTL)2 JsonLdApi (com.github.jsonldjava.core.JsonLdApi)1 JsonLdOptions (com.github.jsonldjava.core.JsonLdOptions)1 RDFDataset (com.github.jsonldjava.core.RDFDataset)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 Iter (org.apache.jena.atlas.iterator.Iter)1 JsonObject (org.apache.jena.atlas.json.JsonObject)1 JsonString (org.apache.jena.atlas.json.JsonString)1 StoragePrefixes (org.apache.jena.dboe.storage.StoragePrefixes)1