|
@@ -295,23 +295,17 @@ Boolean function pm_finished(worklist : Element, pm : String):
|
|
|
Element finished
|
|
|
Integer cnt
|
|
|
Integer i
|
|
|
-
|
|
|
// Check if any of the "finish" elements are in the worklist
|
|
|
// If so, we can already finish, and therefore will stop immediately
|
|
|
finished = allInstances(pm, "Finish")
|
|
|
- i = 0
|
|
|
- cnt = set_len(finished)
|
|
|
-
|
|
|
worklist = set_copy(worklist)
|
|
|
while (set_len(worklist) > 0):
|
|
|
// Check each finished element individually
|
|
|
- if (set_in(finished, set_pop(worklist))):
|
|
|
+ if (set_in(finished, list_read(set_pop(worklist), 0))):
|
|
|
return True!
|
|
|
- i = i + 1
|
|
|
-
|
|
|
return False!
|
|
|
|
|
|
-Element function execute_operation(operation_id : String, input_models : Element, output_models : Element, tracability_model : Element):
|
|
|
+Element function execute_operation(operation_id : String, input_models : Element, tracability_model : Element):
|
|
|
// Operations are always in-place and uses only a single metamodel
|
|
|
// Therefore, we must:
|
|
|
// 1) Find merged metamodel
|
|
@@ -376,10 +370,10 @@ Element function execute_operation(operation_id : String, input_models : Element
|
|
|
|
|
|
merged_model = model_join(model_tuples, get_full_model(merged_metamodel_id, get_model_id("SimpleClassDiagrams")), tracability_model)
|
|
|
else:
|
|
|
- if (bool_and(dict_len(input_models) == 1, dict_len(output_models) == 0)):
|
|
|
+ if (bool_and(dict_len(input_models) == 1, dict_len(output_metamodels) == 0)):
|
|
|
// Just skip the merge...
|
|
|
merged_model = model_copy(get_full_model(get_model_id(input_models[set_pop(dict_keys(input_models))]), get_model_id(input_metamodels[set_pop(dict_keys(input_metamodels))])))
|
|
|
- elif (bool_and(dict_len(input_models) == 0, dict_len(output_models) == 0)):
|
|
|
+ elif (bool_and(dict_len(input_models) == 0, dict_len(output_metamodels) == 0)):
|
|
|
merged_model = read_root()
|
|
|
else:
|
|
|
log("Could not resolve intermediate merged metamodel")
|
|
@@ -419,10 +413,10 @@ Element function execute_operation(operation_id : String, input_models : Element
|
|
|
|
|
|
if (result):
|
|
|
model_tuples = set_create()
|
|
|
- keys = dict_keys(output_models)
|
|
|
+ keys = dict_keys(output_metamodels)
|
|
|
while (set_len(keys) > 0):
|
|
|
key = set_pop(keys)
|
|
|
- set_add_node(model_tuples, create_tuple(key, get_full_model(get_model_id(output_models[key]), get_model_id(output_metamodels[key]))))
|
|
|
+ set_add_node(model_tuples, create_tuple(key, get_full_model(get_model_id(output_metamodels[key]), get_model_id("SimpleClassDiagrams"))))
|
|
|
|
|
|
result = model_split(merged_model, model_tuples, tracability)
|
|
|
|
|
@@ -494,7 +488,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
|
|
|
log(string_join("Enacting ModelTransformation: ", read_attribute(pm, element, "name")))
|
|
|
output(string_join("Enacting ModelTransformation: ", read_attribute(pm, element, "name")))
|
|
|
|
|
|
- result = execute_operation(transformation_id, inputs, outputs, read_root())
|
|
|
+ result = execute_operation(transformation_id, inputs, read_root())
|
|
|
|
|
|
if (element_eq(result, read_root())):
|
|
|
// Something went wrong!
|
|
@@ -530,10 +524,11 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
|
|
|
|
|
|
// Create the worklist with the Start instance as first element
|
|
|
worklist = set_create()
|
|
|
- set_add(worklist, create_tuple(set_pop(allInstances(pm, "Start")), True))
|
|
|
+ set_add_node(worklist, create_tuple(set_pop(allInstances(pm, "Start")), True))
|
|
|
|
|
|
while (bool_not(pm_finished(worklist, pm))):
|
|
|
// Pop a random element from the list and execute it
|
|
|
+ log("POP WL")
|
|
|
tuple = set_pop(worklist)
|
|
|
element = tuple[0]
|
|
|
result = tuple[1]
|
|
@@ -581,11 +576,13 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
|
|
|
// in this context, that means that if it is false, we should add it manually to the list, and then continue the simulation loop
|
|
|
if (bool_not(result)):
|
|
|
// Apparently it is False, so map this to the "Else" branch
|
|
|
- set_add(worklist, create_tuple(set_pop(allAssociationDestinations(pm, element, "Else")), True))
|
|
|
+ log("POP ELSE")
|
|
|
+ set_add_node(worklist, create_tuple(set_pop(allAssociationDestinations(pm, element, "Else")), True))
|
|
|
continue!
|
|
|
else:
|
|
|
// Apparently it is True, so map this to the "Then" branch
|
|
|
- set_add(worklist, create_tuple(set_pop(allAssociationDestinations(pm, element, "Then")), True))
|
|
|
+ log("POP THEN")
|
|
|
+ set_add_node(worklist, create_tuple(set_pop(allAssociationDestinations(pm, element, "Then")), True))
|
|
|
continue!
|
|
|
|
|
|
// We have finished the execution, so add all outgoing edges to the worklist
|
|
@@ -593,8 +590,9 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
|
|
|
all_next = allAssociationDestinations(pm, element, "Next")
|
|
|
String next
|
|
|
while (set_len(all_next) > 0):
|
|
|
+ log("POP1")
|
|
|
next = set_pop(all_next)
|
|
|
- set_add(worklist, create_tuple(next, result))
|
|
|
+ set_add_node(worklist, create_tuple(next, result))
|
|
|
|
|
|
// Reached a finish element, so stop
|
|
|
output("Success")
|
|
@@ -774,15 +772,18 @@ String function cmd_model_render(user_id : String, model_name : String, mapper_n
|
|
|
tracability_model = get_full_model(get_model_id(tracability_name), get_model_id("TracabilityModel"))
|
|
|
|
|
|
// Do the operation itself!
|
|
|
- result = execute_operation(mapper_ID, inputs, output_map, tracability_model)
|
|
|
+ result = execute_operation(mapper_ID, inputs, tracability_model)
|
|
|
|
|
|
// Overwrite the previous rendered model
|
|
|
+ log("Rendered model: " + cast_v2s(get_model_id(output_map["rendered"])))
|
|
|
model_overwrite(result["rendered"], get_model_id(rendered_name), get_model_id(output_map["rendered"]))
|
|
|
+ log("Abstract model: " + cast_v2s(get_model_id(output_map["abstract"])))
|
|
|
model_overwrite(result["abstract"], get_model_id(model_name), get_model_id(output_map["abstract"]))
|
|
|
|
|
|
// Tracability updated in-place
|
|
|
- model_overwrite(tracability_model, get_model_id(tracability_name), get_model_id("TracabilityModel"))
|
|
|
- tracability_model = get_full_model(get_model_id(tracability_name), get_model_id("TracabilityModel"))
|
|
|
+ log("Tracability model: " + cast_v2s(get_model_id("Tracability")))
|
|
|
+ model_overwrite(tracability_model, get_model_id(tracability_name), get_model_id("Tracability"))
|
|
|
+ tracability_model = get_full_model(get_model_id(tracability_name), get_model_id("Tracability"))
|
|
|
|
|
|
// Also output the resulting model
|
|
|
return "Success: " + JSON_print(get_full_model(get_model_id(rendered_name), get_model_id(output_map["rendered"])))!
|
|
@@ -880,7 +881,7 @@ String function cmd_transformation_execute(user_id : String, transformation_name
|
|
|
output("Success: ready for MT execution")
|
|
|
|
|
|
log("Start execution: " + cast_e2s(transformation_id))
|
|
|
- result = execute_operation(transformation_id, inputs, output_map, read_root())
|
|
|
+ result = execute_operation(transformation_id, inputs, read_root())
|
|
|
|
|
|
// Now write out the models again
|
|
|
if (element_eq(result, read_root())):
|
|
@@ -935,7 +936,7 @@ String function cmd_new_verify(user_id : String, model_name : String, metamodel_
|
|
|
conformance_operation = set_pop(allAssociationDestinations(core, get_instanceOf_link(model_id, get_model_id(metamodel_name)), "semantics"))
|
|
|
inputs = dict_create()
|
|
|
dict_add(inputs, "SimpleClassDiagrams", model_name)
|
|
|
- result = execute_operation(conformance_operation, inputs, dict_create(), read_root())
|
|
|
+ result = execute_operation(conformance_operation, inputs, read_root())
|
|
|
return ""!
|
|
|
else:
|
|
|
return "Permission denied to model: " + model_name!
|
|
@@ -1104,7 +1105,6 @@ String function transformation_add(user_id : String, source_models : Element, ta
|
|
|
// Write out a merged metamodel containing all these models: this is the MM for the manual operation
|
|
|
// New location is available, so write
|
|
|
if (bool_not(bool_and(dict_len(source_models) == 0, dict_len(target_models) == 0))):
|
|
|
- log("Formalism map: " + list_to_string(formalism_map))
|
|
|
merged_formalism = model_fuse(formalism_map)
|
|
|
modify(merged_formalism, True)
|
|
|
|
|
@@ -1230,14 +1230,10 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
|
|
|
else:
|
|
|
return "Model not found: " + name!
|
|
|
|
|
|
- log("FUSE")
|
|
|
merged_formalism = model_fuse(to_ramify)
|
|
|
- log("MODIFY")
|
|
|
modify(merged_formalism, True)
|
|
|
- log("RAMIFY")
|
|
|
|
|
|
ramified_metamodel = ramify(merged_formalism)
|
|
|
- log("RAMify OK")
|
|
|
model_create(ramified_metamodel, "__RAM_" + operation_name, user_id, get_model_id("SimpleClassDiagrams"), "Model")
|
|
|
ramified_metamodel_id = get_model_id("__RAM_" + operation_name)
|
|
|
|
|
@@ -1246,11 +1242,9 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
|
|
|
String new_model
|
|
|
// Finished with all information, now create the model itself!
|
|
|
output("Waiting for model constructors...")
|
|
|
- log("Uploading model")
|
|
|
new_model = construct_model_raw(get_full_model(ramified_metamodel_id, get_model_id("SimpleClassDiagrams")))
|
|
|
model_create(new_model, operation_name, user_id, ramified_metamodel_id, "ModelTransformation")
|
|
|
model_id = get_model_id(operation_name)
|
|
|
- log("Uploaded model")
|
|
|
|
|
|
// Write out a merged metamodel containing all these models: this is the MM for the manual operation
|
|
|
// New location is available, so write
|
|
@@ -1264,7 +1258,6 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
|
|
|
// Add tracability links at this level
|
|
|
tracability_link = instantiate_link(core, "tracability", "", merged_formalism_id, ramified_metamodel_id)
|
|
|
instantiate_attribute(core, tracability_link, "type", "RAMified")
|
|
|
- log("Tracability OK")
|
|
|
|
|
|
// Extend metadata with info on source and target
|
|
|
String link
|
|
@@ -1283,7 +1276,6 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
|
|
|
dst = target[key]
|
|
|
link = instantiate_link(core, "transformOutput", "", model_id, dst)
|
|
|
instantiate_attribute(core, link, "name", key)
|
|
|
- log("Transform links oK")
|
|
|
|
|
|
return "Success"!
|
|
|
else:
|