Java Code Examples for org.apache.jena.ontology.OntModel#write()
The following examples show how to use
org.apache.jena.ontology.OntModel#write() .
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: ROEvoSerializer.java From incubator-taverna-language with Apache License 2.0 | 6 votes |
public void workflowHistory(Workflow mainWorkflow, OutputStream output) throws WriterException { OntModel model = ModelFactory.createOntologyModel(); Revision revision = mainWorkflow.getCurrentRevision(); Revision previous = revision.getPreviousRevision(); addRevision(model, revision); while (previous != null) { addRevision(model, previous); addPrevious(model, revision, previous); revision = previous; previous = revision.getPreviousRevision(); } java.net.URI baseURI = Workflow.WORKFLOW_ROOT; model.setNsPrefix("roevo", "http://purl.org/wf4ever/roevo#"); model.setNsPrefix("prov", "http://www.w3.org/ns/prov#"); model.setNsPrefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); model.write(output, "Turtle", baseURI.toASCIIString()); // throw new WriterException("Can't write to output", e); }
Example 2
Source File: WfdescSerialiser.java From incubator-taverna-language with Apache License 2.0 | 5 votes |
public void save(WorkflowBundle wfBundle, OutputStream output) throws WriterException { OntModel model; final URI baseURI; if (wfBundle.getMainWorkflow() != null) { Workflow mainWorkflow = wfBundle.getMainWorkflow(); baseURI = uriTools.uriForBean(mainWorkflow); model = save(wfBundle); } else { throw new WriterException("wfdesc format requires a main workflow"); } model.setNsPrefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); model.setNsPrefix("xsd", "http://www.w3.org/2001/XMLSchema#"); model.setNsPrefix("owl", "http://www.w3.org/2002/07/owl#"); model.setNsPrefix("prov", "http://www.w3.org/ns/prov#"); model.setNsPrefix("wfdesc", "http://purl.org/wf4ever/wfdesc#"); model.setNsPrefix("wf4ever", "http://purl.org/wf4ever/wf4ever#"); model.setNsPrefix("roterms", "http://purl.org/wf4ever/roterms#"); model.setNsPrefix("dc", "http://purl.org/dc/elements/1.1/"); model.setNsPrefix("dcterms", "http://purl.org/dc/terms/"); model.setNsPrefix("comp", "http://purl.org/DP/components#"); model.setNsPrefix("dep", "http://scape.keep.pt/vocab/dependencies#"); model.setNsPrefix("biocat", "http://biocatalogue.org/attribute/"); model.setNsPrefix("", "#"); try { model.write(output, Lang.TURTLE.getName(), baseURI.toString()); } catch (RiotException e) { throw new WriterException("Can't write to output", e); } }
Example 3
Source File: RdfEntityGraph.java From baleen with Apache License 2.0 | 5 votes |
@Override protected void outputModel(String documentSourceName, OntModel model) throws AnalysisEngineProcessException { try (OutputStream outputStream = createOutputStream(documentSourceName)) { model.write(outputStream, rdfFormat.getKey()); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
Example 4
Source File: Rdf.java From baleen with Apache License 2.0 | 5 votes |
@Override protected void outputModel(String documentSourceName, OntModel model) throws AnalysisEngineProcessException { try (OutputStream outputStream = createOutputStream(documentSourceName)) { model.write(outputStream, rdfFormat.getKey()); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
Example 5
Source File: RdfEntityGraph.java From baleen with Apache License 2.0 | 5 votes |
@Override protected void outputModel(String documentSourceName, OntModel model) throws AnalysisEngineProcessException { try (OutputStream outputStream = createOutputStream(documentSourceName)) { model.write(outputStream, rdfFormat.getKey()); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
Example 6
Source File: Rdf.java From baleen with Apache License 2.0 | 5 votes |
@Override protected void outputModel(String documentSourceName, OntModel model) throws AnalysisEngineProcessException { try (OutputStream outputStream = createOutputStream(documentSourceName)) { model.write(outputStream, rdfFormat.getKey()); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
Example 7
Source File: GetAllVocabLinksFromLOV.java From RDFUnit with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { RDFUnitUtils.fillSchemaServiceFromLOV(); OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RULE_INF, ModelFactory.createDefaultModel()); for (SchemaSource schema : SchemaService.getSourceListAll(false,null)){ QueryExecutionFactory qef = new QueryExecutionFactoryModel(schema.getModel()); String queryString = PrefixNSService.getSparqlPrefixDecl() + " SELECT DISTINCT ?s ?p ?o WHERE { " + " ?s ?p ?o ." + " FILTER (?p IN (owl:sameAs, owl:equivalentProperty, owl:equivalentClass))" + // " FILTER (strStarts(?s, 'http://dbpedia.org') || strStarts(?o, 'http://dbpedia.org')))" + "}"; try (QueryExecution qe = qef.createQueryExecution(queryString)) { qe.execSelect().forEachRemaining(qs -> { Resource s = qs.get("s").asResource(); Resource p = qs.get("p").asResource(); RDFNode o = qs.get("o"); model.add(s, ResourceFactory.createProperty(p.getURI()), o); // save the data in a file to read later }); } } try (OutputStream fos = new FileOutputStream("output.ttl")) { model.write(fos, "TURTLE"); } catch (Exception e) { throw new UnsupportedOperationException("Error writing file: " + e.getMessage(), e); } }
Example 8
Source File: OwlSchemaFactoryTest.java From baleen with Apache License 2.0 | 4 votes |
private void writeToConsole(OntModel model) { StringWriter writer = new StringWriter(); model.write(writer, RdfFormat.TURTLE.getKey()); System.out.println(writer.toString()); }