Search in sources :

Example 31 with PrefixMapping

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

the class SecuredPrefixMappingTest method runTests.

public static void runTests(final SecurityEvaluator securityEvaluator, final PrefixMapping prefixMapping) throws Exception {
    final PrefixMapping pm = prefixMapping;
    Assert.assertNotNull("PrefixMapping may not be null", pm);
    Assert.assertTrue("PrefixMapping should be secured", pm instanceof SecuredPrefixMapping);
    final SecuredPrefixMappingTest pmTest = new SecuredPrefixMappingTest(securityEvaluator) {

        @Override
        public void setup() {
            this.securedMapping = (SecuredPrefixMapping) pm;
        }
    };
    Method lockTest = null;
    for (final Method m : pmTest.getClass().getMethods()) {
        if (m.isAnnotationPresent(Test.class)) {
            // lock test must come last
            if (m.getName().equals("testLock")) {
                lockTest = m;
            } else {
                pmTest.setup();
                m.invoke(pmTest);
            }
        }
    }
    Assert.assertNotNull("Did not find 'testLock' method", lockTest);
    pmTest.setup();
    lockTest.invoke(pmTest);
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) SecuredPrefixMapping(org.apache.jena.permissions.graph.SecuredPrefixMapping) SecuredPrefixMapping(org.apache.jena.permissions.graph.SecuredPrefixMapping) Method(java.lang.reflect.Method)

Example 32 with PrefixMapping

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

the class AbstractTestGraphOverDataset method graphDSG_prefixes_1.

// ---- prefixes
@Test
public void graphDSG_prefixes_1() {
    Graph g = makeNamedGraph(baseDSG, gn1);
    PrefixMapping pmap = g.getPrefixMapping();
    assertNotNull(pmap);
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Graph(org.apache.jena.graph.Graph) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 33 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project webofneeds by researchstudio-sat.

the class CommentModeratedFacet method connectFromOwner.

@Override
public void connectFromOwner(Connection con, Model content, WonMessage wonMessage) throws NoSuchNeedException, IllegalMessageForNeedStateException, ConnectionAlreadyExistsException {
    super.connectFromOwner(con, content, wonMessage);
    /* when connected change linked data*/
    PrefixMapping prefixMapping = PrefixMapping.Factory.create();
    prefixMapping.setNsPrefix(SIOC.getURI(), "sioc");
    content.withDefaultMappings(prefixMapping);
    content.setNsPrefix("sioc", SIOC.getURI());
    Resource post = content.createResource(con.getConnectionURI() + "/p/", SIOC.POST);
    content.add(content.createStatement(content.getResource(con.getConnectionURI().toString()), SIOC.HAS_REPLY, content.getResource(con.getRemoteConnectionURI().toString())));
    logger.debug(RdfUtils.toString(content));
    con.getDatasetHolder().getDataset().setDefaultModel(content);
    datasetHolderRepository.save(con.getDatasetHolder());
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Resource(org.apache.jena.rdf.model.Resource)

Example 34 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project webofneeds by researchstudio-sat.

the class WonLinkedDataUtils method getConnectionNetwork.

public static Dataset getConnectionNetwork(URI atomURI, URI webId, LinkedDataSource linkedDataSource) {
    assert linkedDataSource != null : "linkedDataSource must not be null";
    int depth = 5;
    int maxRequests = 1000;
    List<Path> propertyPaths = new ArrayList<>();
    PrefixMapping pmap = new PrefixMappingImpl();
    pmap.withDefaultMappings(PrefixMapping.Standard);
    pmap.setNsPrefix("won", WON.getURI());
    pmap.setNsPrefix("msg", WONMSG.getURI());
    propertyPaths.add(PathParser.parse("won:connections", pmap));
    propertyPaths.add(PathParser.parse("won:connections/rdfs:member", pmap));
    return linkedDataSource.getDataForResourceWithPropertyPath(atomURI, webId, propertyPaths, maxRequests, depth);
}
Also used : Path(org.apache.jena.sparql.path.Path) PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl)

Example 35 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project webofneeds by researchstudio-sat.

the class WonLinkedDataUtils method getFullAtomDataset.

public static Dataset getFullAtomDataset(URI atomURI, LinkedDataSource linkedDataSource) {
    assert linkedDataSource != null : "linkedDataSource must not be null";
    int depth = 7;
    int maxRequests = 1000;
    List<Path> propertyPaths = new ArrayList<>();
    PrefixMapping pmap = new PrefixMappingImpl();
    pmap.withDefaultMappings(PrefixMapping.Standard);
    pmap.setNsPrefix("won", WON.getURI());
    pmap.setNsPrefix("msg", WONMSG.getURI());
    propertyPaths.add(PathParser.parse("won:connections", pmap));
    propertyPaths.add(PathParser.parse("won:connections/rdfs:member", pmap));
    propertyPaths.add(PathParser.parse("won:connections/rdfs:member/won:messageContainer", pmap));
    propertyPaths.add(PathParser.parse("won:connections/rdfs:member/won:messageContainer/rdfs:member", pmap));
    propertyPaths.add(PathParser.parse("won:connections/rdfs:member/won:messageContainer/rdfs:member/msg:correspondingRemoteMessage", pmap));
    propertyPaths.add(PathParser.parse("won:connections/rdfs:member/won:messageContainer/rdfs:member/msg:previousMessage", pmap));
    propertyPaths.add(PathParser.parse("won:connections/rdfs:member/won:sourceAtom", pmap));
    propertyPaths.add(PathParser.parse("won:connections/rdfs:member/won:sourceAtom/won:messageContainer", pmap));
    propertyPaths.add(PathParser.parse("won:connections/rdfs:member/won:sourceAtom/won:messageContainer/rdfs:member", pmap));
    propertyPaths.add(PathParser.parse("won:connections/rdfs:member/won:sourceAtom/won:messageContainer/rdfs:member/msg:previousMessage", pmap));
    return linkedDataSource.getDataForResourceWithPropertyPath(atomURI, atomURI, propertyPaths, maxRequests, depth);
}
Also used : Path(org.apache.jena.sparql.path.Path) PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl)

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