From 6194f1704004053162e52be432e48cff4130eccf Mon Sep 17 00:00:00 2001
From: baigner <benedikt.aigner@rwth-aachen.de>
Date: Thu, 16 Aug 2018 15:40:17 +0200
Subject: [PATCH] Started bug fixing. NOT FINISHED

Former-commit-id: e73b1aa14908fda35c163e971e153e5261bb7866
---
 kadmos/vistoms/vistoms.py | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/kadmos/vistoms/vistoms.py b/kadmos/vistoms/vistoms.py
index 8c801d24d..db1f10f88 100644
--- a/kadmos/vistoms/vistoms.py
+++ b/kadmos/vistoms/vistoms.py
@@ -16,7 +16,7 @@ from shutil import copyfile
 import networkx as nx
 from flask import Flask, render_template, request, jsonify, send_from_directory
 from kadmos.cmdows.cmdows import find_cmdows_file
-from kadmos.graph import load, FundamentalProblemGraph, KadmosGraph
+from kadmos.graph import load, FundamentalProblemGraph, KadmosGraph, RepositoryConnectivityGraph
 
 app = Flask(__name__)
 
@@ -106,13 +106,6 @@ def kadmos_upload_file():
                     dgFile.save(os.path.join(UPLOAD_FOLDER, dgFile.filename))
 
                 loaded_graph = load(graphFileName, file_check_critical=False)
-                if "name" not in loaded_graph.graph:
-                    loaded_graph.graph["name"] = os.path.splitext(dgFile.filename)[0].replace("_",".")
-                # Remove the uploaded file (and if existing, database directory) from the temp folder
-                os.remove(graphFileName)
-                if os.path.exists(database_dir):
-                    shutil.rmtree(database_dir)
-
                 if isinstance(loaded_graph, tuple):
                     graph = loaded_graph[0]
                     mpg = loaded_graph[1]
@@ -130,6 +123,13 @@ def kadmos_upload_file():
                     graph = loaded_graph
                     mpg = None
 
+                if "name" not in graph.graph:
+                    graph.graph["name"] = os.path.splitext(dgFile.filename)[0].replace("_",".")
+                # Remove the uploaded file (and if existing, database directory) from the temp folder
+                os.remove(graphFileName)
+                if os.path.exists(database_dir):
+                    shutil.rmtree(database_dir)
+
                 #save the graph as kdms file in temp folder
                 graph.save(os.path.join(UPLOAD_FOLDER, TEMP_FILE+'_'+newGraphID+'.kdms'),file_type='kdms',
                            graph_check_critical=False, mpg=mpg)
@@ -990,6 +990,13 @@ def kadmos_add_design_competence():
 
             # Here the original graph and the new graph including the design competence are merged
             new_graph = KadmosGraph(nx.compose(graph, graph_dc))
+            if isinstance(graph, RepositoryConnectivityGraph):
+                new_graph = RepositoryConnectivityGraph(new_graph)
+            elif isinstance(graph, FundamentalProblemGraph):
+                new_graph = FundamentalProblemGraph(new_graph)
+            else:
+                raise AssertionError("ERROR: Could not do this!")
+
             # new_graph.graph['name'] = graph.graph['name']
             # new_graph.graph['id'] = graphID
             # new_graph.graph['description'] = graph.graph['description']
@@ -1981,7 +1988,7 @@ if __name__ == '__main__':
         folder = os.path.join(args[args.index('-folder') + 1],'')
         assert isinstance(folder, basestring), 'Folder should be a string.'
     else:
-        folder = None
+        folder = "C:/Users/aigne/Desktop/vistoms_tmp"
     # Check if open_vistoms is given in args
     if '-open' in args:
         open_vistoms = args[args.index('-open') + 1]
-- 
GitLab