01: package org.ontoware.rdfreactor.schema.bootstrap;
02:
03: import java.io.IOException;
04: import java.io.InputStream;
05:
06: import org.ontoware.rdf2go.RDF2Go;
07: import org.ontoware.rdf2go.exception.ModelRuntimeException;
08: import org.ontoware.rdf2go.model.Model;
09:
10: public class GenerateRuntime {
11:
12: public static final String outdir = "./target/test-gen";
13:
14: public static void main(String[] args) throws Exception {
15: // Model model = RDF2Go.getModelFactory().createModel();
16: // model.open();
17: // Model rdf = loadFromClassPathResource("rdf.xml");
18: // Model rdfs = loadFromClassPathResource("rdfs.xml");
19: // model.addAll(rdf.iterator());
20: // model.addAll(rdfs.iterator());
21: //
22: // CodeGenerator.generate(model, new File(outdir),
23: // "org.ontoware.rdfreactor.schema.rdfs", Reasoning.rdfs,
24: // false, "");
25:
26: // Model model = RDF2Go.getModelFactory().createModel();
27: // model.open();
28: // Model owl = loadFromClassPathResource("owl.xml");
29: // model.addAll(owl.iterator());
30: //
31: // CodeGenerator.generate(model, new File(outdir),
32: // "org.ontoware.rdfreactor.schema.owl", Reasoning.rdfs,
33: // false, "");
34: }
35:
36: public static Model loadFromClassPathResource(String resourceName) {
37: ClassLoader cl = Thread.currentThread().getContextClassLoader();
38: InputStream in = cl.getResourceAsStream(resourceName);
39: Model model = RDF2Go.getModelFactory().createModel();
40: model.open();
41: try {
42: model.readFrom(in);
43: } catch (ModelRuntimeException e) {
44: throw new RuntimeException(e);
45: } catch (IOException e) {
46: throw new RuntimeException(e);
47: }
48: return model;
49:
50: }
51:
52: }
|