Search in sources :

Example 71 with Resource

use of org.apache.jena.rdf.model.Resource in project jena by apache.

the class SchemagenMojo method processFile.

/**
     * Delegate the processing of the given file to schemagen itself
     * @param fileName
     * @throws SchemagenOptionsConfigurationException
     */
protected void processFile(String fileName) throws MojoExecutionException, SchemagenOptionsConfigurationException {
    getLog().info("processFile with " + fileName);
    getLog().info(optIndex.keySet().toString());
    SchemagenOptions so = optIndex.get(fileName);
    getLog().info("so = " + so);
    // if we have no options carrier for this file, we create one to contain
    // the name of the input file, and link it to the defaults
    String soFileName;
    if (so == null) {
        so = new SchemagenOptions(getDefaultOptions().getOutputOption());
        soFileName = fileName;
        so.setParent(getDefaultOptions());
    } else {
        soFileName = so.getOption(OPT.INPUT).asLiteral().getString();
    }
    getLog().info("input before adjustment: " + soFileName);
    boolean relative = !(soFileName.startsWith("http:") || soFileName.startsWith("https:") || soFileName.startsWith("file:"));
    getLog().info("relative = " + relative);
    getLog().info("baseDir = " + baseDir);
    getLog().info("getBaseDir() = " + getBaseDir());
    soFileName = relative ? "file:" + baseDir + File.separator + soFileName : soFileName;
    //fix windows paths
    if (File.separator.equals("\\")) {
        soFileName = soFileName.replaceAll("\\\\", "/");
    }
    getLog().info("input after adjustment: " + soFileName);
    Resource input = ResourceFactory.createResource(soFileName);
    so.setOption(OPT.INPUT, input);
    getLog().info("about to call run(): ");
    ensureTargetDirectory(so);
    new SchemagenAdapter().run(so);
}
Also used : Resource(org.apache.jena.rdf.model.Resource)

Example 72 with Resource

use of org.apache.jena.rdf.model.Resource in project jena by apache.

the class SchemagenOptionsTest method testGetResourceValueOPT3.

@Test
public void testGetResourceValueOPT3() throws SchemagenOptionsConfigurationException {
    SchemagenOptions so0 = new SchemagenOptions();
    SchemagenOptions so1 = new SchemagenOptions();
    so0.setParent(so1);
    Resource r0 = ResourceFactory.createResource("http://example.org/foo");
    Resource r1 = ResourceFactory.createResource("http://example.org/bar");
    so0.setOption(OPT.ROOT, r0);
    so1.setOption(OPT.ROOT, r1);
    assertEquals(r0, so0.getResource(OPT.ROOT));
}
Also used : Resource(org.apache.jena.rdf.model.Resource) Test(org.junit.Test)

Example 73 with Resource

use of org.apache.jena.rdf.model.Resource in project jena by apache.

the class TestConcurrentAccess method mrswGraph6.

@Test(expected = ConcurrentModificationException.class)
public void mrswGraph6() {
    Dataset d = TDBFactory.createDataset();
    Model m = d.getNamedModel("http://example");
    GraphUtil.addInto(m.getGraph(), buildGraph());
    Resource r = m.createResource("x");
    ExtendedIterator<Statement> iter1 = m.listStatements(r, null, (RDFNode) null);
    assertNotNull(iter1.next());
    Triple t = SSE.parseTriple("(<y> <p> 99)");
    m.getGraph().delete(t);
    iter1.next();
}
Also used : Triple(org.apache.jena.graph.Triple) Statement(org.apache.jena.rdf.model.Statement) Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 74 with Resource

use of org.apache.jena.rdf.model.Resource in project jena by apache.

the class TestDatasetTDB method load2.

private static void load2(Model model) {
    Resource r2 = model.createResource(base1 + "r2");
    Property p1 = model.createProperty(baseNS + "p1");
    model.add(r2, p1, "x1");
    model.add(r2, p1, "x2");
}
Also used : Resource(org.apache.jena.rdf.model.Resource) Property(org.apache.jena.rdf.model.Property)

Example 75 with Resource

use of org.apache.jena.rdf.model.Resource in project jena by apache.

the class TestConcurrentAccess method mrswGraph5.

@Test
public void mrswGraph5() {
    Dataset d = TDBFactory.createDataset();
    Model m = d.getNamedModel("http://example");
    GraphUtil.addInto(m.getGraph(), buildGraph());
    Resource r = m.createResource("x");
    ExtendedIterator<Statement> iter1 = m.listStatements(r, null, (RDFNode) null);
    while (iter1.hasNext()) iter1.next();
    Triple t = SSE.parseTriple("(<y> <p> 99)");
    m.getGraph().delete(t);
    iter1.hasNext();
}
Also used : Triple(org.apache.jena.graph.Triple) Statement(org.apache.jena.rdf.model.Statement) Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Aggregations

Resource (org.apache.jena.rdf.model.Resource)178 Model (org.apache.jena.rdf.model.Model)86 Test (org.junit.Test)55 Property (org.apache.jena.rdf.model.Property)34 RDFNode (org.apache.jena.rdf.model.RDFNode)24 Dataset (org.apache.jena.query.Dataset)20 Literal (org.apache.jena.rdf.model.Literal)17 BaseTest (org.apache.jena.atlas.junit.BaseTest)16 Node (org.apache.jena.graph.Node)16 Statement (org.apache.jena.rdf.model.Statement)14 UpdateBuilder (org.apache.jena.arq.querybuilder.UpdateBuilder)13 StringReader (java.io.StringReader)9 InfModel (org.apache.jena.rdf.model.InfModel)9 Reader (java.io.Reader)8 ArrayList (java.util.ArrayList)8 JsonString (org.apache.jena.atlas.json.JsonString)8 Triple (org.apache.jena.graph.Triple)8 JsonLDWriteContext (org.apache.jena.riot.JsonLDWriteContext)6 PrefixMapping (org.apache.jena.shared.PrefixMapping)6 SelectBuilder (org.apache.jena.arq.querybuilder.SelectBuilder)5