|
@@ -13,6 +13,7 @@ include "utils.alh"
|
|
include "conformance_finding.alh"
|
|
include "conformance_finding.alh"
|
|
include "typing.alh"
|
|
include "typing.alh"
|
|
include "compiler.alh"
|
|
include "compiler.alh"
|
|
|
|
+include "random.alh"
|
|
|
|
|
|
String core_model_location = "models/core"
|
|
String core_model_location = "models/core"
|
|
|
|
|
|
@@ -763,7 +764,7 @@ Element function execute_operation(operation_id : String, input_models : Element
|
|
log("Negative result of execution")
|
|
log("Negative result of execution")
|
|
return read_root()!
|
|
return read_root()!
|
|
|
|
|
|
-Boolean function enact_action(pm : Element, element : String, prefix : String):
|
|
|
|
|
|
+Boolean function enact_action(pm : Element, element : String, mapping : Element):
|
|
Boolean result
|
|
Boolean result
|
|
String transformation_id
|
|
String transformation_id
|
|
Element lst
|
|
Element lst
|
|
@@ -796,7 +797,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String):
|
|
while (set_len(lst) > 0):
|
|
while (set_len(lst) > 0):
|
|
consume = set_pop(lst)
|
|
consume = set_pop(lst)
|
|
value = read_attribute(pm, readAssociationDestination(pm, consume), "name")
|
|
value = read_attribute(pm, readAssociationDestination(pm, consume), "name")
|
|
- dict_add(inputs, read_attribute(pm, consume, "name"), prefix + value)
|
|
|
|
|
|
+ dict_add(inputs, read_attribute(pm, consume, "name"), mapping[value])
|
|
|
|
|
|
// Find all output model names and their metamodel
|
|
// Find all output model names and their metamodel
|
|
lst = allOutgoingAssociationInstances(pm, element, "Produces")
|
|
lst = allOutgoingAssociationInstances(pm, element, "Produces")
|
|
@@ -806,7 +807,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String):
|
|
type_name = read_attribute(pm, elem, "type")
|
|
type_name = read_attribute(pm, elem, "type")
|
|
elem_name = read_attribute(pm, elem, "name")
|
|
elem_name = read_attribute(pm, elem, "name")
|
|
dict_add(outputs, read_attribute(pm, produce, "name"), type_name)
|
|
dict_add(outputs, read_attribute(pm, produce, "name"), type_name)
|
|
- dict_add(output_map, read_attribute(pm, produce, "name"), prefix + elem_name)
|
|
|
|
|
|
+ dict_add(output_map, read_attribute(pm, produce, "name"), mapping[elem_name])
|
|
|
|
|
|
if read_type(core, transformation_id) == "ActionLanguage":
|
|
if read_type(core, transformation_id) == "ActionLanguage":
|
|
log(string_join("Enacting ActionLanguage: ", read_attribute(pm, element, "name")))
|
|
log(string_join("Enacting ActionLanguage: ", read_attribute(pm, element, "name")))
|
|
@@ -834,7 +835,20 @@ Boolean function enact_action(pm : Element, element : String, prefix : String):
|
|
model_overwrite(result[key], get_entry_id(output_map[key]), get_entry_id(outputs[key]))
|
|
model_overwrite(result[key], get_entry_id(output_map[key]), get_entry_id(outputs[key]))
|
|
return True!
|
|
return True!
|
|
|
|
|
|
-Void function enact_PM(pm : Element, prefix : String):
|
|
|
|
|
|
+Element function PM_signature(pm : Element):
|
|
|
|
+ Element all_data
|
|
|
|
+ Element result
|
|
|
|
+ String entry
|
|
|
|
+
|
|
|
|
+ result = dict_create()
|
|
|
|
+ all_data = allInstances(pm, "Data")
|
|
|
|
+ while (set_len(all_data) > 0):
|
|
|
|
+ entry = set_pop(all_data)
|
|
|
|
+ dict_add(result, cast_string(read_attribute(pm, entry, "name")), cast_string(read_attribute(pm, entry, "type")))
|
|
|
|
+
|
|
|
|
+ return result!
|
|
|
|
+
|
|
|
|
+Void function enact_PM(pm : Element, mapping : Element):
|
|
Element worklist
|
|
Element worklist
|
|
String element
|
|
String element
|
|
String type
|
|
String type
|
|
@@ -842,9 +856,28 @@ Void function enact_PM(pm : Element, prefix : String):
|
|
Element tuple
|
|
Element tuple
|
|
Element counters
|
|
Element counters
|
|
Element join_nodes
|
|
Element join_nodes
|
|
|
|
+ Element keys
|
|
|
|
+ String key
|
|
|
|
|
|
output("Success")
|
|
output("Success")
|
|
|
|
|
|
|
|
+ // For all entries in the signature, not in the mapping, we add a mock location
|
|
|
|
+ Element signature
|
|
|
|
+ String mock_location
|
|
|
|
+ Element mock_locations
|
|
|
|
+ mock_locations = set_create()
|
|
|
|
+ signature = PM_signature(pm)
|
|
|
|
+ keys = dict_keys(signature)
|
|
|
|
+ while (set_len(keys) > 0):
|
|
|
|
+ key = set_pop(keys)
|
|
|
|
+ if (bool_not(dict_in(mapping, key))):
|
|
|
|
+ // Add mock location
|
|
|
|
+ mock_location = ""
|
|
|
|
+ while (get_entry_id(mock_location) != ""):
|
|
|
|
+ mock_location = ".tmp/" + random_string(10)
|
|
|
|
+ dict_add(mapping, key, mock_location)
|
|
|
|
+ set_add(mock_locations, mock_location)
|
|
|
|
+
|
|
// Initialize Join counters
|
|
// Initialize Join counters
|
|
counters = dict_create()
|
|
counters = dict_create()
|
|
join_nodes = allInstances(pm, "Join")
|
|
join_nodes = allInstances(pm, "Join")
|
|
@@ -897,7 +930,7 @@ Void function enact_PM(pm : Element, prefix : String):
|
|
// Execute a transformation
|
|
// Execute a transformation
|
|
// This the difficult part!
|
|
// This the difficult part!
|
|
|
|
|
|
- result = enact_action(pm, element, prefix)
|
|
|
|
|
|
+ result = enact_action(pm, element, mapping)
|
|
output("Success")
|
|
output("Success")
|
|
|
|
|
|
elif (type == "Decision"):
|
|
elif (type == "Decision"):
|
|
@@ -921,6 +954,11 @@ Void function enact_PM(pm : Element, prefix : String):
|
|
set_add_node(worklist, create_tuple(next, result))
|
|
set_add_node(worklist, create_tuple(next, result))
|
|
|
|
|
|
// Reached a finish element, so stop
|
|
// Reached a finish element, so stop
|
|
|
|
+
|
|
|
|
+ // Remove all mock locations again
|
|
|
|
+ while (set_len(mock_locations) > 0):
|
|
|
|
+ model_delete(get_entry_id(set_pop(mock_locations)))
|
|
|
|
+
|
|
return !
|
|
return !
|
|
|
|
|
|
String function cmd_help():
|
|
String function cmd_help():
|
|
@@ -1017,7 +1055,7 @@ String function cmd_model_add(type : String, name : String, code : String):
|
|
else:
|
|
else:
|
|
return "Model not found: " + type!
|
|
return "Model not found: " + type!
|
|
|
|
|
|
-String function cmd_process_execute(process : String, prefix : String):
|
|
|
|
|
|
+String function cmd_process_execute(process : String, mapping : Element):
|
|
// Execute a process model until it reaches termination
|
|
// Execute a process model until it reaches termination
|
|
String process_id
|
|
String process_id
|
|
|
|
|
|
@@ -1029,7 +1067,7 @@ String function cmd_process_execute(process : String, prefix : String):
|
|
if (element_eq(pm, read_root())):
|
|
if (element_eq(pm, read_root())):
|
|
return "Specified model cannot be interpreted as a ProcessModel: " + process!
|
|
return "Specified model cannot be interpreted as a ProcessModel: " + process!
|
|
|
|
|
|
- enact_PM(pm, prefix)
|
|
|
|
|
|
+ enact_PM(pm, mapping)
|
|
return "Success"!
|
|
return "Success"!
|
|
else:
|
|
else:
|
|
return "Permission denied to model: " + process!
|
|
return "Permission denied to model: " + process!
|
|
@@ -2187,7 +2225,7 @@ Void function user_function_skip_init(user_id : String):
|
|
elif (cmd == "model_add"):
|
|
elif (cmd == "model_add"):
|
|
output(cmd_model_add(single_input("Model type?"), single_input("Model name?"), single_input("Model textual representation?")))
|
|
output(cmd_model_add(single_input("Model type?"), single_input("Model name?"), single_input("Model textual representation?")))
|
|
elif (cmd == "process_execute"):
|
|
elif (cmd == "process_execute"):
|
|
- output(cmd_process_execute(single_input("Process to execute?"), single_input("Model prefix to use?")))
|
|
|
|
|
|
+ output(cmd_process_execute(single_input("Process to execute?"), dict_input("Model bindings to use?")))
|
|
elif (cmd == "transformation_between"):
|
|
elif (cmd == "transformation_between"):
|
|
output(cmd_transformation_between(dict_input("Source signature?"), dict_input("Target signature?")))
|
|
output(cmd_transformation_between(dict_input("Source signature?"), dict_input("Target signature?")))
|
|
elif (cmd == "model_render"):
|
|
elif (cmd == "model_render"):
|