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();
}
}
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);
}
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;
}
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);
}
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);
}
Aggregations