org.simantics.silk.ontology;bundle-version="1.1.0",
org.simantics.image.ui;bundle-version="1.0.0",
org.simantics.export.core;bundle-version="1.0.0",
- org.slf4j.api
+ org.slf4j.api,
+ org.simantics.graphfile.ontology
Export-Package: org.simantics.modeling.ui,
org.simantics.modeling.ui.actions,
org.simantics.modeling.ui.chart.property,
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.IndexRoot;
import org.simantics.db.common.request.ObjectsWithType;
import org.simantics.db.common.request.ReadRequest;
import org.simantics.db.common.request.UniqueRead;
import org.simantics.db.layer0.util.TransferableGraphConfiguration2;
import org.simantics.db.service.SerialisationSupport;
import org.simantics.graph.compiler.CompilationResult;
+import org.simantics.graph.compiler.ExternalFileLoader;
import org.simantics.graph.compiler.GraphCompiler;
import org.simantics.graph.compiler.GraphCompilerPreferences;
import org.simantics.graph.compiler.ValidationMode;
import org.simantics.graph.representation.Identity;
import org.simantics.graph.representation.Root;
import org.simantics.graph.representation.TransferableGraph1;
+import org.simantics.graphfile.ontology.GraphFileResource;
import org.simantics.layer0.Layer0;
import org.simantics.ltk.ISource;
import org.simantics.ltk.Problem;
prefs.validate = true;
prefs.validateRelationRestrictions = ValidationMode.ERROR;
prefs.validateResourceHasType = ValidationMode.IGNORE;
- 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);
+
+ }
+
+ });
for(Problem problem : result.getErrors())
errorStringBuilder.append(problem.getLocation() + ": " + problem.getDescription() + "\n");