From 71f01c091bc746b67fde712add94a384d95e5802 Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Mon, 15 May 2017 10:53:28 +0300 Subject: [PATCH] CompilePGraphs takes previous bundled version of ontology #7229 Change-Id: I71520cf139aa4131031a59bd377ca82410d36044 --- .../simantics/modeling/CompilePGraphs.java | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java index 9b620c2f7..10e23c65b 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java @@ -89,21 +89,10 @@ public class CompilePGraphs { final Collection sources = new ArrayList<>(); Collection dependencies = new ArrayList<>(); - for (Bundle b : Activator.getContext().getBundles()) { - URL tg = b.getEntry("/graph.tg"); - if (tg == null) continue; - File f = url2file(FileLocator.resolve(tg), b.getSymbolicName()); - try { - dependencies.add(GraphCompiler.read(f)); - } catch (Exception e) { - throw new IOException("Failed to read compiled transferable graph as dependency: " + f, e); - } - } - - final TransferableGraph1 thisOntology = Simantics.sync(new UniqueRead() { + final Pair thisOntology = Simantics.sync(new UniqueRead>() { @Override - public TransferableGraph1 perform(ReadGraph graph) throws DatabaseException { + public Pair perform(ReadGraph graph) throws DatabaseException { Layer0 L0 = Layer0.getInstance(graph); Resource parent = graph.getSingleObject(r, L0.PartOf); @@ -130,12 +119,13 @@ public class CompilePGraphs { } }; + String uri = graph.getURI(r); SimanticsClipboardImpl clipboard = new SimanticsClipboardImpl(); ch.copyToClipboard(graph, clipboard); for (Set object : clipboard.getContents()) { TransferableGraph1 tg = ClipboardUtils.accept(graph, object, SimanticsKeys.KEY_TRANSFERABLE_GRAPH); if (tg != null) - return tg; + return Pair.make(uri, tg); } return null; @@ -145,7 +135,24 @@ public class CompilePGraphs { if (thisOntology == null) throw new DatabaseException("Failed to dump the containing ontology of " + r + " into TransferableGraph1"); - dependencies.add(thisOntology); + dependencies.add(thisOntology.second); + + for (Bundle b : Activator.getContext().getBundles()) { + String id = b.getSymbolicName(); + String name = (String) b.getHeaders().get("Bundle-Name"); + if (name == null) name = id; + if (name.equals(thisOntology.first)) + continue; + URL tg = b.getEntry("/graph.tg"); + if (tg == null) continue; + File f = url2file(FileLocator.resolve(tg), b.getSymbolicName()); + try { + dependencies.add(GraphCompiler.read(f)); + } catch (Exception e) { + throw new IOException("Failed to read compiled transferable graph as dependency: " + f, e); + } + } + Simantics.sync(new ReadRequest() { @Override -- 2.45.2