- final CompilationResult result = GraphCompiler.compile("1.1", sources, dependencies, null, prefs);
+
+ final CompilationResult result = Simantics.sync(new UniqueRead<CompilationResult>() {
+
+ @Override
+ public CompilationResult perform(ReadGraph graph) throws DatabaseException {
+
+ final Resource root = graph.syncRequest(new IndexRoot(r));
+ final String baseURI = graph.getURI(root);
+
+ ExternalFileLoader fileLoader = new ExternalFileLoader() {
+ @Override
+ public byte[] load(String fileName) throws IOException {
+ try {
+ GraphFileResource GF = GraphFileResource.getInstance(graph);
+ Resource file = graph.getResource(baseURI + "/" + fileName);
+ return graph.getRelatedValue(file, GF.HasFiledata, Bindings.BYTE_ARRAY);
+ } catch (DatabaseException e) {
+ throw new IOException(e);
+ }
+ }
+ };
+
+ return GraphCompiler.compile("1.1", sources, dependencies, fileLoader, prefs);
+
+ }
+
+ });