Browse Source

Add transformation_signature and process_signature functions

Yentl Van Tendeloo 7 years ago
parent
commit
66c7e0bf3f
3 changed files with 63 additions and 0 deletions
  1. 31 0
      bootstrap/core_algorithm.alc
  2. 24 0
      wrappers/classes/modelverse.xml
  3. 8 0
      wrappers/modelverse.py

+ 31 - 0
bootstrap/core_algorithm.alc

@@ -1074,6 +1074,35 @@ String function cmd_process_execute(process : String, mapping : Element):
 	else:
 		return "Model not found: " + process!
 
+String function cmd_process_signature(process : String):
+	// Execute a process model until it reaches termination
+	String process_id
+	String result
+	Element signature
+	Element keys
+	String key
+
+	process_id = get_entry_id(process)
+	if (process_id != ""):
+		if (allow_read(current_user_id, process_id)):
+			Element pm
+			pm = get_full_model(process_id, get_entry_id("formalisms/ProcessModel"))
+			if (element_eq(pm, read_root())):
+				return "Specified model cannot be interpreted as a ProcessModel: " + process!
+
+			result = "Success: "
+			signature = PM_signature(pm)
+			keys = dict_keys(signature)
+			while (set_len(keys) > 0):
+				key = set_pop(keys)
+				result = result + key + " : " + cast_string(signature[key]) + "\n"
+
+			return result!
+		else:
+			return "Permission denied to model: " + process!
+	else:
+		return "Model not found: " + process!
+
 String function cmd_transformation_between(source_dict : String, target_dict : String):
 	Element result
 	Element subresult
@@ -2226,6 +2255,8 @@ Void function user_function_skip_init(user_id : String):
 			output(cmd_model_add(single_input("Model type?"), single_input("Model name?"), single_input("Model textual representation?")))
 		elif (cmd == "process_execute"):
 			output(cmd_process_execute(single_input("Process to execute?"), dict_input("Model bindings to use?")))
+		elif (cmd == "process_signature"):
+			output(cmd_process_signature(single_input("Process to execute?")))
 		elif (cmd == "transformation_between"):
 			output(cmd_transformation_between(dict_input("Source signature?"), dict_input("Target signature?")))
 		elif (cmd == "model_render"):

+ 24 - 0
wrappers/classes/modelverse.xml

@@ -560,6 +560,24 @@
                         </transition>
                     </state>
 
+                    <state id="process_signature">
+                        <onentry>
+                            <raise event="request">
+                                <parameter expr="['process_signature', self.parameters[0]]"/>
+                            </raise>
+                        </onentry>
+
+                        <transition cond="self.expect_response_partial('Success: ', pop=False)" target="../../wait_for_action/history">
+                            <script>
+                                results = self.split_response(self.responses.pop(0))
+                                signature = {i[0]: i[1] for i in result[1:].strip().split(" : ", 1)}
+                            </script>
+                            <raise event="result">
+                                <parameter expr="signature"/>
+                            </raise>
+                        </transition>
+                    </state>
+
                     <state id="store_on_scripted" initial="transformation_add_MT">
                         <state id="transformation_add_MT" initial="send_metadata">
                             <state id="send_metadata">
@@ -1608,6 +1626,12 @@
                             </script>
                         </transition>
 
+                        <transition cond="self.expect_action(None, 'process_signature')" target="../../operations/process_signature">
+                            <script>
+                                self.load_action(None)
+                            </script>
+                        </transition>
+
                         <transition cond="self.expect_action(None, 'transformation_add_MT')" target="../../operations/store_on_scripted/transformation_add_MT">
                             <script>
                                 self.load_action(None)

+ 8 - 0
wrappers/modelverse.py

@@ -242,6 +242,14 @@ def transformation_execute_MANUAL(operation_name, input_models_dict, output_mode
     INPUT("exit", context, [])
     return OUTPUT()
 
+def transformation_signature(operation_name):
+    INPUT("transformation_signature", None, [operation_name])
+    return OUTPUT()
+
+def process_signature(process_name):
+    INPUT("process_signature", None, [operation_name])
+    return OUTPUT()
+
 def permission_modify(model_name, permissions):
     INPUT("permission_modify", None, [model_name, permissions])
     return OUTPUT()