public static void loadGraph(INamedGraph graph, InputStream rdf, RDFFormat format,String baseURI) throws Exception { loadGraph(graph,rdf,format,baseURI,-1); }
public static void loadGraph(INamedGraph graph, String rdf, RDFFormat format) throws Exception { loadGraph(graph, new ByteArrayInputStream(rdf.getBytes()), format,""); }
public static void loadGraph(INamedGraph graph, File file) throws Exception { RDFFormat format = RDFFormat.forFileName(file.getName()); if (format == null) { if (file.getName().endsWith(".owl")) { format = RDFFormat.RDFXML; } } loadGraph(graph, new FileInputStream(file), format,""); }
/** * Specify an ontology needed by one of the generation ontologies. One of these * entreis should be added for every import in every ontology to generate. * We have this call because imports in Jena don't work all that well. * @param ontologyFile The InputStream containing the ontology document * @param ontlang The Ontology Language, owl or rdfs. * @param rdflang The seriazation format of the ontology file (N3,RDF/XM,...all Jena formats) * @param ontologyURI The URI of the ontology * @param packagename The Java package that generate classes should be in. */ public void addOntologyDependency(InputStream ontologyFile, String ontLang, String rdflang, String ontologyURI, String packagename) { try { INamedGraph temp = createOntGraph(false, ontLang); if (rdflang != null) GraphUtils.loadGraph(temp, ontologyFile, RDFFormat.valueOf(rdflang),ontologyURI); else GraphUtils.loadGraph(temp, ontologyFile, RDFFormat.RDFXML,ontologyURI); if (ontLang != null && ontLang.equals(ONT_LANG_RDFS)) { temp = Rdfs2Owl.convertToOwl(temp, ontologyURI); } GraphUtils.addGraph(ontGraph, temp); registerOntology(temp, ontologyURI, packagename, false); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Specify an ontology to generate * @param ontologyFile The InputStream containing the ontology document * @param ontlang The Ontology Language, owl or rdfs. * @param rdflang The seriazation format of the ontology file (N3,RDF/XM,...all Jena formats) * @param ontologyURI The URI of the ontology * @param packagename The Java package that generate classes should be in. */ public void addOntologyToGenerate(InputStream ontologyFile, String ontLang, String rdflang, String ontologyURI, String packagename) { try { INamedGraph temp = createOntGraph(false, ontLang); if (rdflang != null) GraphUtils.loadGraph(temp, ontologyFile, RDFFormat.valueOf(rdflang),ontologyURI); else GraphUtils.loadGraph(temp, ontologyFile, RDFFormat.RDFXML,ontologyURI); if (ontLang != null && ontLang.equals(ONT_LANG_RDFS)) { temp = Rdfs2Owl.convertToOwl(temp, ontologyURI); } addConcreteEnumClasses(temp); GraphUtils.addGraph(ontGraph, temp); //GraphUtils.writeGraph(temp, System.err); registerOntology(temp, ontologyURI, packagename, true); } catch (Exception e) { throw new RuntimeException(e); } }