Search in sources :

Example 26 with PrefixMapping

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

the class TestPrefixMappingTDB method persistent2.

// Persistent.
@Test
public void persistent2() {
    String dir = ConfigTest.getTestingDir();
    FileOps.clearDirectory(dir);
    DatasetPrefixesTDB prefixes = createTesting(Location.create(dir), new DatasetControlMRSW());
    PrefixMapping pmap1 = prefixes.getPrefixMapping();
    pmap1.setNsPrefix("x", "http://foo/");
    prefixes.close();
    prefixes = createTesting(Location.create(dir), new DatasetControlMRSW());
    assertEquals("http://foo/", pmap1.getNsPrefixURI("x"));
    prefixes.close();
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) DatasetControlMRSW(org.apache.jena.tdb.sys.DatasetControlMRSW) DatasetPrefixesTDB(org.apache.jena.tdb.store.DatasetPrefixesTDB) ConfigTest(org.apache.jena.tdb.ConfigTest)

Example 27 with PrefixMapping

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

the class Prologue method sub.

public Prologue sub(PrefixMapping newMappings, String base) {
    // New prefix mappings
    PrefixMapping ext = getPrefixMapping();
    if (newMappings != null)
        ext = new PrefixMapping2(ext, newMappings);
    // New base.
    IRIResolver r = resolver;
    if (base != null)
        r = IRIResolver.create(base);
    return new Prologue(ext, r);
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMapping2(org.apache.jena.sparql.util.PrefixMapping2) IRIResolver(org.apache.jena.riot.system.IRIResolver)

Example 28 with PrefixMapping

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

the class TestSSE_Forms method beforeClass.

@BeforeClass
public static void beforeClass() {
    original = SSE.getPrefixMapRead();
    PrefixMapping pmaptest = new PrefixMappingImpl().setNsPrefixes(original).removeNsPrefix("").removeNsPrefix("ex");
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) BeforeClass(org.junit.BeforeClass)

Example 29 with PrefixMapping

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

the class TestModelPrefixMapping method doOnlyFreshPrefixes.

/**
	 * Test that existing prefixes are not over-ridden by the default ones.
	 */
private void doOnlyFreshPrefixes() {
    final String newURI = "abc:def/";
    final Graph g = Factory.createDefaultGraph();
    final PrefixMapping pm = g.getPrefixMapping();
    pm.setNsPrefix(TestModelPrefixMapping.alphaPrefix, newURI);
    final Model m = ModelFactory.createModelForGraph(g);
    Assert.assertEquals(newURI, m.getNsPrefixURI(TestModelPrefixMapping.alphaPrefix));
    Assert.assertEquals(TestModelPrefixMapping.betaURI, m.getNsPrefixURI(TestModelPrefixMapping.betaPrefix));
}
Also used : AbstractTestPrefixMapping(org.apache.jena.shared.AbstractTestPrefixMapping) PrefixMapping(org.apache.jena.shared.PrefixMapping) Graph(org.apache.jena.graph.Graph) Model(org.apache.jena.rdf.model.Model)

Example 30 with PrefixMapping

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

the class FusekiLib method addDataInto.

public static void addDataInto(DatasetGraph src, DatasetGraph dest) {
    Iterator<Quad> iter = src.find(Node.ANY, Node.ANY, Node.ANY, Node.ANY);
    for (; iter.hasNext(); ) {
        Quad q = iter.next();
        dest.add(q);
    }
    PrefixMapping pmapSrc = src.getDefaultGraph().getPrefixMapping();
    PrefixMapping pmapDest = dest.getDefaultGraph().getPrefixMapping();
    pmapDest.withDefaultMappings(pmapSrc);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) PrefixMapping(org.apache.jena.shared.PrefixMapping)

Aggregations

PrefixMapping (org.apache.jena.shared.PrefixMapping)154 Test (org.junit.Test)47 PrefixMappingImpl (org.apache.jena.shared.impl.PrefixMappingImpl)34 Graph (org.apache.jena.graph.Graph)22 Path (org.apache.jena.sparql.path.Path)12 BaseTest (org.apache.jena.atlas.junit.BaseTest)11 Triple (org.apache.jena.graph.Triple)9 Resource (org.apache.jena.rdf.model.Resource)9 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 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 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)4 Dataset (org.apache.jena.query.Dataset)4