]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ModelTransferableGraphSource.java
Delete temporary files after use in delayed writes and model TG export
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / ModelTransferableGraphSource.java
index 8602da82789d97de8830f1927dcd4b5d53c7295b..a39e336d9903f39a1b33fba30eed90ef6dc07a6e 100644 (file)
@@ -52,6 +52,7 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
 
        TIntArrayList externalParents = new TIntArrayList();
        ArrayList<String> externalNames = new ArrayList<String>();
 
        TIntArrayList externalParents = new TIntArrayList();
        ArrayList<String> externalNames = new ArrayList<String>();
+       TreeMap<String,String> downloads = new TreeMap<String,String>();
 
        public ModelTransferableGraphSource(final ReadGraph graph, TransferableGraphConfiguration2 configuration, final DomainProcessorState state, File ... fs) throws DatabaseException {
 
 
        public ModelTransferableGraphSource(final ReadGraph graph, TransferableGraphConfiguration2 configuration, final DomainProcessorState state, File ... fs) throws DatabaseException {
 
@@ -118,6 +119,8 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
                
                this.resourceCount = state.id;
                
                
                this.resourceCount = state.id;
                
+               state.extensions.put(ExternalDownloadBean.EXTENSION_KEY, new Variant(ExternalDownloadBean.BINDING, new ExternalDownloadBean(downloads)));
+               
        }
 
        int indent = 0;
        }
 
        int indent = 0;
@@ -200,6 +203,11 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
                        state.ids.put(r, state.id);
                        // Ensure that this resource is included into the set of externals to maintain the total number of externals 
                        state.externals.add(r);
                        state.ids.put(r, state.id);
                        // Ensure that this resource is included into the set of externals to maintain the total number of externals 
                        state.externals.add(r);
+                       String download = graph.getPossibleRelatedValue(res, L0.Ontology_download, Bindings.STRING);
+                       if(download != null) {
+                               String uri = graph.getURI(res);
+                               downloads.put(uri, download);
+                       }
                        return state.id++;
                }
        }
                        return state.id++;
                }
        }
@@ -382,11 +390,14 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
 
                // Declare internal and external roots
                for(RootSpec r : configuration.roots) {
 
                // Declare internal and external roots
                for(RootSpec r : configuration.roots) {
-                       Resource type = graph.getPossibleType(r.resource, L0.Entity);
-                       if(type == null) type = L0.Entity;
+                       String typeId = r.type;
+                       if (typeId == null) {
+                               Resource type = graph.getPossibleType(r.resource, L0.Entity);
+                               typeId = type != null ? graph.getURI(type) : Layer0.URIs.Entity;
+                       }
                        procedure.execute(new Identity(
                                        state.ids.get(support.getTransientId(r.resource)),
                        procedure.execute(new Identity(
                                        state.ids.get(support.getTransientId(r.resource)),
-                                       new Root(r.name, graph.getURI(type))));
+                                       new Root(r.name, typeId)));
                }
 
                for(int i = 0; i < state.externals.size() ; i++) {
                }
 
                for(int i = 0; i < state.externals.size() ; i++) {