Java Code Examples for org.apache.jena.rdf.model.Model#getResource()
The following examples show how to use
org.apache.jena.rdf.model.Model#getResource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SolidUtilities.java From data-transfer-project with Apache License 2.0 | 6 votes |
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(); }
Example 2
Source File: JenaTransformationRepairSwitchMonitored.java From trainbenchmark with Eclipse Public License 1.0 | 6 votes |
@Override public void activate(final Collection<JenaSwitchMonitoredMatch> matches) throws Exception { final Model model = driver.getModel(); final Property sensorEdge = model.getProperty(BASE_PREFIX + MONITORED_BY); final Resource sensorType = model.getResource(BASE_PREFIX + SENSOR); for (final JenaSwitchMonitoredMatch match : matches) { final Resource sw = match.getSw(); final Long newVertexId = driver.generateNewVertexId(); final Resource sensor = model.createResource(BASE_PREFIX + ID_PREFIX + newVertexId); model.add(model.createStatement(sw, sensorEdge, sensor)); model.add(model.createStatement(sensor, RDF.type, sensorType)); } }
Example 3
Source File: SPDXLicenseInfoFactory.java From tools with Apache License 2.0 | 6 votes |
/** * @param uri * @return * @throws InvalidSPDXAnalysisException */ protected static SPDXStandardLicense getLicenseFromStdLicModel(String uri) throws InvalidSPDXAnalysisException { String id = uri.substring(STANDARD_LICENSE_URI_PREFIX.length()); if (STANDARD_LICENSES.containsKey(id)) { return STANDARD_LICENSES.get(id); } Model licenseModel = getLicenseModel(uri); if (licenseModel == null) { throw(new InvalidSPDXAnalysisException("No standard license was found at "+uri)); } Resource licResource = licenseModel.getResource(uri); if (licResource == null || !licenseModel.containsResource(licenseModel.asRDFNode(licResource.asNode()))) { throw(new InvalidSPDXAnalysisException("No standard license was found at "+uri)); } SPDXStandardLicense retval = new SPDXStandardLicense(licenseModel, licResource.asNode()); STANDARD_LICENSES.put(id, retval); return retval; }
Example 4
Source File: RoundTripToRdfTest.java From data-transfer-project with Apache License 2.0 | 5 votes |
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"); }
Example 5
Source File: RdfEntityGraphConsumerTest.java From baleen with Apache License 2.0 | 5 votes |
@Test public void testEntityGraphRdf() throws AnalysisEngineProcessException, ResourceInitializationException, IOException, URISyntaxException { processJCas( RdfEntityGraphConsumer.PARAM_QUERY_ENDPOINT, "http://localhost:3330/ds/query", RdfEntityGraphConsumer.PARAM_UPDATE_ENDPOINT, "http://localhost:3330/ds/update", RdfEntityGraphConsumer.PARAM_STORE_ENDPOINT, "http://localhost:3330/ds/data"); Model expected = RDFDataMgr.loadModel(EXPECTED_DOCUMENT_FILE.toURI().toString()); Model model = ds.getDefaultModel(); Resource resource = expected.getResource( "http://baleen.dstl.gov.uk/8b408a0c7163fdfff06ced3e80d7d2b3acd9db900905c4783c28295b8c996165"); resource.removeProperties(); // Get rid of the timestamp StmtIterator listStatements = expected.listStatements(); while (listStatements.hasNext()) { Statement statement = listStatements.next(); assertTrue("Missing statement " + statement.toString(), model.contains(statement)); } assertTrue(model.containsAll(expected)); }
Example 6
Source File: RdfDocumentGraphConsumerTest.java From baleen with Apache License 2.0 | 5 votes |
@Test public void testDocumentGraphRdf() throws AnalysisEngineProcessException, ResourceInitializationException, IOException, URISyntaxException { processJCas( RdfDocumentGraphConsumer.PARAM_QUERY_ENDPOINT, "http://localhost:" + port + "/ds/query", RdfDocumentGraphConsumer.PARAM_UPDATE_ENDPOINT, "http://localhost:" + port + "/ds/update", RdfDocumentGraphConsumer.PARAM_STORE_ENDPOINT, "http://localhost:" + port + "/ds/data"); Model expected = RDFDataMgr.loadModel(EXPECTED_DOCUMENT_FILE.toURI().toString()); Model model = ds.getDefaultModel(); Resource resource = expected.getResource( "http://baleen.dstl.gov.uk/8b408a0c7163fdfff06ced3e80d7d2b3acd9db900905c4783c28295b8c996165"); resource.removeProperties(); // Get rid of the timestamp StmtIterator listStatements = expected.listStatements(); while (listStatements.hasNext()) { Statement statement = listStatements.next(); assertTrue("Missing statement " + statement.toString(), model.contains(statement)); } assertTrue(model.containsAll(expected)); }
Example 7
Source File: RdfDocumentGraphConsumerTest.java From baleen with Apache License 2.0 | 5 votes |
@Test public void testDocumentGraphRdfithRelationsAsLinks() throws AnalysisEngineProcessException, ResourceInitializationException, IOException, URISyntaxException { processJCas( RdfDocumentGraphConsumer.PARAM_QUERY_ENDPOINT, "http://localhost:" + port + "/ds/query", RdfDocumentGraphConsumer.PARAM_UPDATE_ENDPOINT, "http://localhost:" + port + "/ds/update", RdfDocumentGraphConsumer.PARAM_STORE_ENDPOINT, "http://localhost:" + port + "/ds/data", RdfDocumentGraphConsumer.PARAM_OUTPUT_RELATIONS_AS_LINKS, true); Model expected = RDFDataMgr.loadModel(EXPECTED_DOCUMENT_RELATION_AS_LINKS_FILE.toURI().toString()); Model model = ds.getDefaultModel(); Resource resource = expected.getResource( "http://baleen.dstl.gov.uk/8b408a0c7163fdfff06ced3e80d7d2b3acd9db900905c4783c28295b8c996165"); resource.removeProperties(); // Get rid of the timestamp StmtIterator listStatements = expected.listStatements(); while (listStatements.hasNext()) { Statement statement = listStatements.next(); assertTrue("Missing statement " + statement.toString(), model.contains(statement)); } assertTrue(model.containsAll(expected)); }
Example 8
Source File: BatchShapeTargetReaderTest.java From RDFUnit with Apache License 2.0 | 5 votes |
@Test public void testRead() throws RdfReaderException { Model shapesModel = RdfReaderFactory.createResourceReader(shapeResource).read(); Resource r1 = shapesModel.getResource("http://example.org/MyShape"); Set<ShapeTarget> targets1 = BatchShapeTargetReader.create().read(r1); assertThat(targets1) .hasSize(2); }
Example 9
Source File: AbstractRDFModelBasedSameAsRetriever.java From gerbil with GNU Affero General Public License v3.0 | 4 votes |
public static void findLinks(String uri, Set<String> uris, Model model) { Resource resource = model.getResource(uri); for (int i = 0; i < SAME_AS_PROPERTIES.length; ++i) { findLinks(resource, uris, model, SAME_AS_PROPERTIES[i]); } }