Search in sources :

Example 21 with PrefixMapping

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

the class AbstractTestPrefixMapping method testEmptyDoesNotWipeURI.

/**
        Test that the empty prefix does not wipe an existing prefix for the same URI.
    */
public void testEmptyDoesNotWipeURI() {
    PrefixMapping pm = getMapping();
    pm.setNsPrefix("frodo", ropeURI);
    pm.setNsPrefix("", ropeURI);
    assertEquals(ropeURI, pm.getNsPrefixURI("frodo"));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 22 with PrefixMapping

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

the class AbstractTestPrefixMapping2 method prefix5.

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

Example 23 with PrefixMapping

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

the class AbstractTestPrefixMapping2 method prefix8.

@Test
public void prefix8() {
    PrefixMapping pmap = create();
    String x = "scheme:i_do_not_exist";
    assertEquals(x, pmap.expandPrefix(x));
    // Call again - used to cause problems. 
    assertEquals(x, pmap.expandPrefix(x));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 24 with PrefixMapping

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

the class AbstractTestPrefixMapping2 method prefix3.

@Test
public void prefix3() {
    String uri = "http://example/";
    PrefixMapping pmap = create();
    pmap.setNsPrefix("ex", uri);
    // Create a second view onto the same storage.
    PrefixMapping pmap2 = view();
    String x = pmap2.getNsPrefixURI("ex");
    assertNotNull(x);
    assertEquals(uri, x);
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 25 with PrefixMapping

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

the class sdbload method loadOne.

private void loadOne(String filename, boolean replace) {
    Model model = null;
    Dataset dataset = null;
    PrefixMapping pmap;
    Lang lang = RDFLanguages.filenameToLang(filename);
    if (lang == null)
        throw new CmdException("Data syntax not recognized: " + filename);
    // --graph or not
    if (modGraph.getGraphName() != null) {
        model = modGraph.getModel(getStore());
        pmap = model;
    } else {
        dataset = SDBFactory.connectDataset(getStore());
        pmap = dataset.asDatasetGraph().getDefaultGraph().getPrefixMapping();
    }
    // For monitoring only.
    Graph monitorGraph = (model == null) ? null : model.getGraph();
    if (replace) {
        if (model != null)
            model.removeAll();
        else
            dataset.asDatasetGraph().clear();
    }
    boolean showProgress = isVerbose() || getModTime().timingEnabled();
    if (showProgress)
        output.print("Start load: %s", filename);
    StreamRDF stream = streamToStore(pmap, getStore());
    if (modGraph.getGraphName() != null) {
        Node gn = NodeFactory.createURI(modGraph.getGraphName());
        stream = StreamRDFLib.extendTriplesToQuads(gn, stream);
    }
    ProgressMonitor progress = null;
    if (showProgress) {
        progress = new ProgressMonitor(filename, 100_000, 10, output);
        stream = new ProgressStreamRDF(stream, progress);
    }
    if (progress != null)
        progress.start();
    // Load!
    RDFDataMgr.parse(stream, filename, lang);
    if (progress != null) {
        progress.finish();
        progress.finishMessage();
    }
}
Also used : ProgressMonitor(org.apache.jena.atlas.lib.ProgressMonitor) PrefixMapping(org.apache.jena.shared.PrefixMapping) Graph(org.apache.jena.graph.Graph) ModGraph(sdb.cmd.ModGraph) ProgressStreamRDF(org.apache.jena.riot.system.ProgressStreamRDF) CmdException(jena.cmd.CmdException) ProgressStreamRDF(org.apache.jena.riot.system.ProgressStreamRDF) StreamRDF(org.apache.jena.riot.system.StreamRDF) Dataset(org.apache.jena.query.Dataset) Node(org.apache.jena.graph.Node) Model(org.apache.jena.rdf.model.Model) Lang(org.apache.jena.riot.Lang)

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