Browse Source

Merge branch 'testing' into new_JIT

Yentl Van Tendeloo 7 years ago
parent
commit
fe4a89a125
4 changed files with 260 additions and 172 deletions
  1. 32 0
      bootstrap/core_algorithm.alc
  2. 20 0
      wrappers/classes/modelverse.xml
  3. 4 0
      wrappers/modelverse.py
  4. 204 172
      wrappers/modelverse_SCCD.py

+ 32 - 0
bootstrap/core_algorithm.alc

@@ -1048,6 +1048,7 @@ String function cmd_help():
 	result = ""
 	result = result + ("Model operations\n")
 	result = result + ("    model_add                       -- Add a new model\n")
+	result = result + ("    model_move                      -- Move a model to a different location\n")
 	result = result + ("    model_modify                    -- Modify an existing model\n")
 	result = result + ("    model_list                      -- List all models\n")
 	result = result + ("    model_list_full                 -- List all models with full info\n")
@@ -1095,6 +1096,35 @@ String function cmd_help():
 
 	return result!
 
+String function cmd_model_move(source : String, target : String):
+	String source_id
+	source_id = get_entry_id(source)
+	if (source_id != ""):
+		if (get_entry_id(target) == ""):
+			// Create folders on path to the target
+			create_folders(current_user_id, get_foldername(target))
+
+			// Change location, first the name
+			instantiate_attribute(core, source_id, "name", target)
+
+			// Now the folder links
+			Element links
+			links = allIncomingAssociationInstances(core, source_id, "contains")
+			while (set_len(links) > 0):
+				model_delete_element(core, set_pop(links))
+			instantiate_link(core, "contains", "", get_entry_id(get_foldername(target)), source_id)
+
+			// Flush caches
+			dict_add(caches["models"], target, caches["models"][source])
+			dict_delete(caches["models"], source)
+
+			// Done
+			return "Success"!
+		else:
+			return "Model exists: " + target!
+	else:
+		return "Model does not exist: " + source!
+
 String function cmd_model_add(type : String, name : String, code : String):
 	// Model addition operation, which uses model upload commands of the compiler
 	String location
@@ -2369,6 +2399,8 @@ Void function user_function_skip_init(user_id : String):
 			output(cmd_help())
 		elif (cmd == "model_add"):
 			output(cmd_model_add(single_input("Model type?"), single_input("Model name?"), single_input("Model textual representation?")))
+		elif (cmd == "model_move"):
+			output(cmd_model_move(single_input("Model name?"), single_input("New location?")))
 		elif (cmd == "process_execute"):
 			output(cmd_process_execute(single_input("Process to execute?"), dict_input("Model bindings to use?")))
 		elif (cmd == "process_signature"):

+ 20 - 0
wrappers/classes/modelverse.xml

@@ -353,6 +353,20 @@
                         </state>
                     </state>
 
+                    <state id="model_move">
+                        <onentry>
+                            <raise event="request">
+                                <parameter expr="['model_move', self.parameters[0], self.parameters[1]]"/>
+                            </raise>
+                        </onentry>
+
+                        <transition cond="self.expect_response('Success')" target="../../wait_for_action/history">
+                            <raise event="result">
+                                <parameter expr="None"/>
+                            </raise>
+                        </transition>
+                    </state>
+
                     <state id="model_delete">
                         <onentry>
                             <raise event="request">
@@ -1557,6 +1571,12 @@
                             </script>
                         </transition>
 
+                        <transition cond="self.expect_action(None, 'model_move')" target="../../operations/model_move">
+                            <script>
+                                self.load_action(None)
+                            </script>
+                        </transition>
+
                         <transition cond="self.expect_action(None, 'model_delete')" target="../../operations/model_delete">
                             <script>
                                 self.load_action(None)

+ 4 - 0
wrappers/modelverse.py

@@ -227,6 +227,10 @@ def model_add(model_name, metamodel_name, model_code=""):
     INPUT("model_add", None, [model_name, metamodel_name, model_code])
     return OUTPUT()
 
+def model_move(source_name, target_name):
+    INPUT("model_move", None, [source_name, target_name])
+    return OUTPUT()
+
 def model_delete(model_name):
     INPUT("model_delete", None, [model_name])
     return OUTPUT()

File diff suppressed because it is too large
+ 204 - 172
wrappers/modelverse_SCCD.py