Search in sources :

Example 91 with PrefixMapping

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

the class AbstractTestPrefixMapping method testLock.

public void testLock() {
    PrefixMapping A = getMapping();
    assertSame(A, A.lock());
    /* */
    try {
        A.setNsPrefix("crisp", crispURI);
        fail("mapping should be frozen");
    } catch (PrefixMapping.JenaLockedException e) {
        pass();
    }
    /* */
    try {
        A.setNsPrefixes(A);
        fail("mapping should be frozen");
    } catch (PrefixMapping.JenaLockedException e) {
        pass();
    }
    /* */
    try {
        A.setNsPrefixes(new HashMap<String, String>());
        fail("mapping should be frozen");
    } catch (PrefixMapping.JenaLockedException e) {
        pass();
    }
    /* */
    try {
        A.removeNsPrefix("toast");
        fail("mapping should be frozen");
    } catch (PrefixMapping.JenaLockedException e) {
        pass();
    }
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 92 with PrefixMapping

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

the class TestModelFactory method testSetDefaultPrefixMapping.

@SuppressWarnings("deprecation")
public void testSetDefaultPrefixMapping() {
    final PrefixMapping original = ModelCom.getDefaultModelPrefixes();
    final PrefixMapping pm = PrefixMapping.Factory.create();
    ModelFactory.setDefaultModelPrefixes(pm);
    Assert.assertSame(pm, ModelCom.getDefaultModelPrefixes());
    Assert.assertSame(pm, ModelFactory.getDefaultModelPrefixes());
    ModelCom.setDefaultModelPrefixes(original);
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 93 with PrefixMapping

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

the class DefaultPrefixUtils method getDefaultPrefixes.

public static PrefixMapping getDefaultPrefixes() {
    PrefixMapping ret = PrefixMapping.Factory.create();
    setDefaultPrefixes(ret);
    return ret;
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 94 with PrefixMapping

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

the class WonLinkedDataUtils method getConversationAndNeedsDataset.

public static Dataset getConversationAndNeedsDataset(URI connectionURI, 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:hasEventContainer", pmap));
    propertyPaths.add(PathParser.parse("won:hasEventContainer/rdfs:member", pmap));
    propertyPaths.add(PathParser.parse("won:hasEventContainer/rdfs:member/msg:hasCorrespondingRemoteMessage", pmap));
    propertyPaths.add(PathParser.parse("won:hasEventContainer/rdfs:member/msg:hasPreviousMessage", pmap));
    propertyPaths.add(PathParser.parse("won:belongsToNeed", pmap));
    propertyPaths.add(PathParser.parse("won:belongsToNeed/won:hasEventContainer", pmap));
    propertyPaths.add(PathParser.parse("won:belongsToNeed/won:hasEventContainer/rdfs:member", pmap));
    propertyPaths.add(PathParser.parse("won:belongsToNeed/won:hasEventContainer/rdfs:member/msg:hasPreviousMessage", pmap));
    propertyPaths.add(PathParser.parse("won:hasRemoteNeed", pmap));
    propertyPaths.add(PathParser.parse("won:hasRemoteNeed/won:hasEventContainer", pmap));
    propertyPaths.add(PathParser.parse("won:hasRemoteNeed/won:hasEventContainer/rdfs:member", pmap));
    propertyPaths.add(PathParser.parse("won:hasRemoteNeed/won:hasEventContainer/rdfs:member/msg:hasPreviousMessage", pmap));
    propertyPaths.add(PathParser.parse("won:hasRemoteConnection", pmap));
    propertyPaths.add(PathParser.parse("won:hasRemoteConnection/won:hasEventContainer", pmap));
    propertyPaths.add(PathParser.parse("won:hasRemoteConnection/won:hasEventContainer/rdfs:member", pmap));
    propertyPaths.add(PathParser.parse("won:hasRemoteConnection/won:hasEventContainer/rdfs:member/msg:hasCorrespondingRemoteMessage", pmap));
    propertyPaths.add(PathParser.parse("won:hasRemoteConnection/won:hasEventContainer/rdfs:member/msg:hasPreviousMessage", pmap));
    URI requesterWebId = WonLinkedDataUtils.getNeedURIforConnectionURI(connectionURI, linkedDataSource);
    return linkedDataSource.getDataForResourceWithPropertyPath(connectionURI, requesterWebId, propertyPaths, maxRequests, depth);
}
Also used : Path(org.apache.jena.sparql.path.Path) PrefixMapping(org.apache.jena.shared.PrefixMapping) ArrayList(java.util.ArrayList) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) URI(java.net.URI)

Example 95 with PrefixMapping

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

the class CommentFacet method addDataManagedByFacet.

private void addDataManagedByFacet(final Connection con) {
    Need need = needRepository.findOneByNeedURI(con.getNeedURI());
    Dataset needContent = need.getDatatsetHolder().getDataset();
    Model facetManagedGraph = getFacetManagedGraph(con.getNeedURI(), needContent);
    List<URI> properties = new ArrayList<>();
    PrefixMapping prefixMapping = PrefixMapping.Factory.create();
    // prefixMapping.setNsPrefix(SIOC.getURI(),"sioc");
    facetManagedGraph.withDefaultMappings(prefixMapping);
    facetManagedGraph.setNsPrefix("sioc", SIOC.getURI());
    Resource post = facetManagedGraph.createResource(con.getNeedURI().toString(), SIOC.POST);
    Resource reply = facetManagedGraph.createResource(con.getRemoteNeedURI().toString(), SIOC.POST);
    facetManagedGraph.add(facetManagedGraph.createStatement(facetManagedGraph.getResource(con.getNeedURI().toString()), SIOC.HAS_REPLY, facetManagedGraph.getResource(con.getRemoteNeedURI().toString())));
    // add WON node link
    logger.debug("linked data:" + RdfUtils.toString(facetManagedGraph));
    need.getDatatsetHolder().setDataset(needContent);
    needRepository.save(need);
}
Also used : Need(won.protocol.model.Need) PrefixMapping(org.apache.jena.shared.PrefixMapping) Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model) ArrayList(java.util.ArrayList) Resource(org.apache.jena.rdf.model.Resource) URI(java.net.URI)

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