Search in sources :

Example 66 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class QueryExecutionBase method insertPrefixesInto.

private void insertPrefixesInto(Model model) {
    try {
        if (dataset != null) {
            // Load the models prefixes first
            PrefixMapping m = dataset.getDefaultModel();
            model.setNsPrefixes(m);
        }
        // Then add the queries (just the declared mappings)
        // so the query declarations override the data sources.
        model.setNsPrefixes(query.getPrefixMapping());
    } catch (Exception ex) {
        Log.warn(this, "Exception in insertPrefixes: " + ex.getMessage(), ex);
    }
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 67 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class MgtFunctions method prefixes.

/** Return prefixes for the datasets, SPARQL syntax. */
public static String prefixes(HttpServletRequest request) {
    String dsName = dataset(request);
    DatasetRef desc = getFromRegistry(dsName);
    if (desc == null)
        return "<not found>";
    DatasetGraph dsg = desc.dataset;
    if (dsg instanceof DatasetGraphTDB) {
        PrefixMapping pmap = ((DatasetGraphTDB) dsg).getPrefixes().getPrefixMapping();
        Prologue prologue = new Prologue(pmap);
        IndentedLineBuffer buff = new IndentedLineBuffer();
        PrologueSerializer.output(buff, prologue);
        buff.append("\n");
        return buff.asString();
    }
    return "";
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Prologue(org.apache.jena.sparql.core.Prologue) DatasetRef(org.apache.jena.fuseki.server.DatasetRef) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 68 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class DatasetPrefixStorageLogger method getPrefixMapping.

@Override
public PrefixMapping getPrefixMapping() {
    PrefixMapping x = other.getPrefixMapping();
    info("getPrefixMapping() -> " + x);
    return x;
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 69 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class DatasetPrefixStorageLogger method getPrefixMapping.

@Override
public PrefixMapping getPrefixMapping(String graphName) {
    PrefixMapping x = other.getPrefixMapping(graphName);
    info("getPrefixMapping(" + graphName + ") -> " + x);
    return x;
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 70 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class TestPrefixMappingSDB method prefix5.

@Test
public void prefix5() {
    String uri = "http://example/";
    PrefixMapping pmap = new PrefixMappingSDB(defaultPrefixURI, sdb);
    pmap.setNsPrefix("ex", uri);
    assertEquals(uri + "foo", pmap.expandPrefix("ex:foo"));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMappingSDB(org.apache.jena.sdb.graph.PrefixMappingSDB) Test(org.junit.Test)

Aggregations

PrefixMapping (org.apache.jena.shared.PrefixMapping)149 Test (org.junit.Test)47 PrefixMappingImpl (org.apache.jena.shared.impl.PrefixMappingImpl)29 Graph (org.apache.jena.graph.Graph)22 BaseTest (org.apache.jena.atlas.junit.BaseTest)11 Triple (org.apache.jena.graph.Triple)9 Resource (org.apache.jena.rdf.model.Resource)9 Path (org.apache.jena.sparql.path.Path)8 ConfigTest (org.apache.jena.tdb.ConfigTest)8 DatasetPrefixesTDB (org.apache.jena.tdb.store.DatasetPrefixesTDB)8 ContractTest (org.xenei.junit.contract.ContractTest)8 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)7 ArrayList (java.util.ArrayList)5 Node (org.apache.jena.graph.Node)5 Query (org.apache.jena.query.Query)5 Model (org.apache.jena.rdf.model.Model)5 PrefixMappingSDB (org.apache.jena.sdb.graph.PrefixMappingSDB)5 URI (java.net.URI)4 HashMap (java.util.HashMap)4 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)4