/** Looks up the {@link Resource}s for a given string, that might be comma delimited. **/ private static ImmutableList<Resource> getPhoneOrMailTypes( String type, Map<String, Resource> map) { return ImmutableList.copyOf( Arrays.stream(type.split(",")).map(t -> { Resource r = map.get(t.toLowerCase()); if (r == null) { logger.warn("%s didn't contain '%s' from %s", map, t.toLowerCase(), type); r = ModelFactory.createDefaultModel().getResource(VCARD4.NS + t); } return r; }) .collect(Collectors.toList())); } }
private static List<Resource> getContainedResource(Model model, String url) { ImmutableList.Builder<Resource> results = new ImmutableList.Builder<>(); Resource self = model.getResource(url); self.listProperties(model.createProperty("http://www.w3.org/ns/ldp#contains")) .forEachRemaining(s-> results.add(s.getResource())); /*List<Statement> containedStatements = getProperties( self, "http://www.w3.org/ns/ldp#contains"); for (Statement s : containedStatements) { results.add(s.getResource()); }*/ return results.build(); }
private Resource getPersonResource(String data) { String example = "https://example.com/resource1"; Model defaultModel = ModelFactory.createDefaultModel(); Model model = defaultModel.read( new StringReader(data), example, "TURTLE"); return model.getResource(example + "#this"); }
private String createIndex(String url, String slug, SolidUtilities utilities) throws Exception { Model model = ModelFactory.createDefaultModel(); Resource containerResource = model.createResource("#this"); containerResource.addProperty(RDF.type, model.getResource(VCARD4.NS + "AddressBook")); containerResource.addProperty( model.createProperty(VCARD4.NS + "nameEmailIndex"), model.createResource("people.ttl")); containerResource.addProperty( model.createProperty(VCARD4.NS + "groupIndex"), model.createResource("groups.ttl")); containerResource.addProperty(DC_11.title, slug); return utilities.postContent( url, "index", BASIC_RESOURCE_TYPE, model); }
/** * <p> * Answer true if this resource is a member of the class denoted by the * given URI.</p> * * @param uri Denotes the URI of a class to which this value may belong * @return True if this resource has the given class as one of its <code>rdf:type</code>'s. */ @Override public boolean hasRDFType( String uri ) { return hasRDFType( getModel().getResource( uri ) ); }
@Override public Collection<TestCase> getTestCases(Model model, Resource graph) { List<TestCase> results = new LinkedList<TestCase>(); for(Resource resource : JenaUtil.getAllInstances(model.getResource(DASH.JSTestCase.getURI()))) { results.add(new JSTestCase(graph, resource)); } return results; }
public static Model addRejects(Model messageModel, URI... toReject) { Resource baseRes = RdfUtils.findOrCreateBaseResource(messageModel); if (toReject == null) return messageModel; for(URI uri: toReject) { if (uri != null) { baseRes.addProperty(WONAGR.REJECTS, baseRes.getModel().getResource(uri.toString())); } } return messageModel; }
/** * Run a single test of any sort, performing any appropriate logging * and error reporting. */ public void runTest(String test) { runTest(testDefinitions.getResource(test)); }
/** * Run a single test of any sort, performing any appropriate logging * and error reporting. */ public void runTest(String test) { runTest(testDefinitions.getResource(test)); }
public void setShapesGraphReference(URI shapesGraphReference) { createContentNodeIfNonExist(NeedContentPropertyType.GOAL); Collection<Resource> nodes = getContentNodes(NeedContentPropertyType.GOAL); for (Resource node : nodes) { node.removeAll(WON.HAS_SHAPES_GRAPH); node.addProperty(WON.HAS_SHAPES_GRAPH, getNeedModel().getResource(shapesGraphReference.toString())); } }
public void testGetResource() { final String uri = "http://aldabaran.hpl.hp.com/rdf/test4/a" + 110; final Resource r = model.getResource(uri); Assert.assertEquals(uri, r.getURI()); }
public void testGetResource() { final String uri = "http://aldabaran.hpl.hp.com/rdf/test4/a" + 110; final Resource r = model.getResource(uri); Assert.assertEquals(uri, r.getURI()); }
public static String getSignedGraphUri(String signatureGraphUri, Model signatureGraph) { String signedGraphUri = null; Resource resource = signatureGraph.getResource(signatureGraphUri); NodeIterator ni = signatureGraph.listObjectsOfProperty(resource, WONMSG.HAS_SIGNED_GRAPH_PROPERTY); if (ni.hasNext()) { signedGraphUri = ni.next().asResource().getURI(); } return signedGraphUri; }
public static int countMarkers( Model m ) { int count = 0; Resource marker = m.getResource( "http://jena.hpl.hp.com/2003/03/testont#Marker" ); for (StmtIterator i = m.listStatements( null, RDF.type, marker ); i.hasNext(); ) { count++; i.next(); } return count; }
public static int countMarkers( Model m ) { int count = 0; Resource marker = m.getResource( "http://jena.hpl.hp.com/2003/03/testont#Marker" ); for (StmtIterator i = m.listStatements( null, RDF.type, marker ); i.hasNext(); ) { count++; i.next(); } return count; }
private Resource copyNode(Resource node) { if (node.isAnon()) return node.getModel().createResource(); int i = 0; String uri = node.getURI() + RandomStringUtils.randomAlphanumeric(4); String newUri = uri+"_"+ i; while (node.getModel().containsResource(new ResourceImpl(newUri))){ i++; newUri = uri+"_"+i; } return node.getModel().getResource(newUri); }
/** * Cycle bug in transitive reasoner */ public void testTransitiveCycleBug() { Model m = FileManager.get().loadModel( "file:testing/reasoners/bugs/unbroken.n3" ); OntModel om = ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM_TRANS_INF, m ); OntClass rootClass = om.getOntClass( RDFS.Resource.getURI() ); Resource c = m.getResource("c"); Set<OntClass> direct = rootClass.listSubClasses( true ).toSet(); assertFalse( direct.contains( c ) ); } /**
protected RDFList getListRoot( final Model m ) { final Resource root = m.getResource(TestList.NS + "root"); Assert.assertNotNull("Root resource should not be null", root); final Resource listHead = root.getRequiredProperty( m.getProperty(TestList.NS + "p")).getResource(); final RDFList l = listHead.as(RDFList.class); Assert.assertNotNull("as(RDFList) should not return null for root", l); return l; }
protected RDFList getListRoot( final Model m ) { final Resource root = m.getResource(TestList.NS + "root"); Assert.assertNotNull("Root resource should not be null", root); final Resource listHead = root.getRequiredProperty( m.getProperty(TestList.NS + "p")).getResource(); final RDFList l = listHead.as(RDFList.class); Assert.assertNotNull("as(RDFList) should not return null for root", l); return l; }
@Before public void setup() { baseModel = createModel(); baseModel.removeAll(); baseModel.add(SecuredRDFNodeTest.s, SecuredRDFNodeTest.p, SecuredRDFNodeTest.o); baseModel.add(SecuredRDFNodeTest.s, SecuredRDFNodeTest.p2, "yeehaw"); baseModel.add(SecuredRDFNodeTest.s, SecuredRDFNodeTest.p2, "yeehaw yall", "us"); baseModel.add(SecuredRDFNodeTest.s, SecuredRDFNodeTest.p2, "whohoo", "uk"); securedModel = Factory.getInstance(securityEvaluator, "http://example.com/securedGraph", baseModel); baseRDFNode = baseModel.getResource(SecuredRDFNodeTest.o.getURI()); securedRDFNode = SecuredRDFNodeImpl.getInstance(securedModel, baseRDFNode); }