|
@@ -14,12 +14,14 @@ include "conformance_finding.alh"
|
|
|
include "typing.alh"
|
|
|
include "compiler.alh"
|
|
|
include "random.alh"
|
|
|
+include "io.alh"
|
|
|
|
|
|
String core_model_location = "models/core"
|
|
|
|
|
|
Element core = ?
|
|
|
String current_user_id
|
|
|
Element caches
|
|
|
+Element pm_tasks = ?
|
|
|
|
|
|
String function get_foldername(name : String):
|
|
|
Element result
|
|
@@ -465,20 +467,6 @@ Boolean function check_conformance(model_id : String):
|
|
|
|
|
|
return True!
|
|
|
|
|
|
-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")
|
|
|
- worklist = set_copy(worklist)
|
|
|
- while (set_len(worklist) > 0):
|
|
|
- // Check each finished element individually
|
|
|
- if (set_in(finished, list_read(set_pop(worklist), 0))):
|
|
|
- return True!
|
|
|
- return False!
|
|
|
-
|
|
|
Element function merge_models(models_dict : Element, operation_name : String):
|
|
|
core = import_node(core_model_location)
|
|
|
// 0) Find operation signature
|
|
@@ -642,7 +630,7 @@ Element function execute_operation(operation_id : String, input_models : Element
|
|
|
while (set_len(iter) > 0):
|
|
|
edge = set_pop(iter)
|
|
|
dict_add(output_metamodels, read_attribute(core, edge, "name"), full_name(readAssociationDestination(core, edge)))
|
|
|
-
|
|
|
+
|
|
|
// 1) Find merged metamodel
|
|
|
|
|
|
exact_type = read_type(core, operation_id)
|
|
@@ -661,6 +649,10 @@ Element function execute_operation(operation_id : String, input_models : Element
|
|
|
while (set_len(keys) > 0):
|
|
|
key = set_pop(keys)
|
|
|
Element mm
|
|
|
+ if (get_entry_id(input_models[key]) == ""):
|
|
|
+ // Input model doesn't exist yet, so create
|
|
|
+ cmd_model_add(input_metamodels[key], input_models[key], "")
|
|
|
+ log("Creating non-existing input model")
|
|
|
mm = get_full_model(get_entry_id(input_models[key]), get_entry_id(input_metamodels[key]))
|
|
|
if (element_eq(mm, read_root())):
|
|
|
log("Signature mismatch in operation for tag " + key)
|
|
@@ -717,14 +709,10 @@ Element function execute_operation(operation_id : String, input_models : Element
|
|
|
while (get_entry_id(model_name) != ""):
|
|
|
model_name = ".tmp/" + random_string(20)
|
|
|
model_create(merged_model, model_name, merged_metamodel_id, "Model")
|
|
|
- output("Operating on: " + cast_string(model_name))
|
|
|
+ log("Manual model created " + model_name + " : " + cast_string(read_attribute(core, merged_metamodel_id, "name")))
|
|
|
// We want to modify, so modify
|
|
|
- if (modify(merged_model, True)):
|
|
|
- // Overwrite the merged model
|
|
|
- model_overwrite(merged_model, get_entry_id(model_name), merged_metamodel_id)
|
|
|
- else:
|
|
|
- // Reload the merged model
|
|
|
- merged_model = get_full_model(get_entry_id(model_name), merged_metamodel_id)
|
|
|
+ do_spawn_modify(model_name, True)
|
|
|
+ merged_model = get_full_model(get_entry_id(model_name), merged_metamodel_id)
|
|
|
//model_delete(get_entry_id(model_name))
|
|
|
result = True
|
|
|
elif (exact_type == "ActionLanguage"):
|
|
@@ -790,17 +778,22 @@ Boolean function enact_action(pm : Element, element : String, mapping : Element)
|
|
|
Element output_mms
|
|
|
Element consumes_link
|
|
|
String name
|
|
|
- String value
|
|
|
String elem_name
|
|
|
Element keys
|
|
|
String key
|
|
|
String consume
|
|
|
String produce
|
|
|
+ Element input_traceability_model
|
|
|
+ String output_traceability_name
|
|
|
+ String output_traceability_type
|
|
|
Element output_map
|
|
|
|
|
|
inputs = dict_create()
|
|
|
outputs = dict_create()
|
|
|
output_map = dict_create()
|
|
|
+ input_traceability_model = read_root()
|
|
|
+ output_traceability_name = read_root()
|
|
|
+ output_traceability_type = read_root()
|
|
|
|
|
|
// Read out the referenced element from the MvC
|
|
|
transformation_id = get_entry_id(read_attribute(pm, element, "name"))
|
|
@@ -809,8 +802,19 @@ Boolean function enact_action(pm : Element, element : String, mapping : Element)
|
|
|
lst = allOutgoingAssociationInstances(pm, element, "Consumes")
|
|
|
while (set_len(lst) > 0):
|
|
|
consume = set_pop(lst)
|
|
|
- value = read_attribute(pm, readAssociationDestination(pm, consume), "name")
|
|
|
- dict_add(inputs, read_attribute(pm, consume, "name"), mapping[value])
|
|
|
+ elem = readAssociationDestination(pm, consume)
|
|
|
+ type_name = read_attribute(pm, elem, "type")
|
|
|
+ elem_name = read_attribute(pm, elem, "name")
|
|
|
+ if (cast_string(read_attribute(pm, consume, "name")) == "__traceability"):
|
|
|
+ log("Using input traceability model!")
|
|
|
+ log("Mapping: " + cast_string(mapping[elem_name]))
|
|
|
+ log("Type: " + cast_string(type_name))
|
|
|
+ log("Entry mapping: " + get_entry_id(mapping[elem_name]))
|
|
|
+ log("Entry type: " + get_entry_id(type_name))
|
|
|
+ input_traceability_model = model_copy(get_full_model(get_entry_id(mapping[elem_name]), get_entry_id(type_name)))
|
|
|
+ output_traceability_type = type_name
|
|
|
+ else:
|
|
|
+ dict_add(inputs, read_attribute(pm, consume, "name"), mapping[elem_name])
|
|
|
|
|
|
// Find all output model names and their metamodel
|
|
|
lst = allOutgoingAssociationInstances(pm, element, "Produces")
|
|
@@ -819,33 +823,46 @@ Boolean function enact_action(pm : Element, element : String, mapping : Element)
|
|
|
elem = readAssociationDestination(pm, produce)
|
|
|
type_name = read_attribute(pm, elem, "type")
|
|
|
elem_name = read_attribute(pm, elem, "name")
|
|
|
- dict_add(outputs, read_attribute(pm, produce, "name"), type_name)
|
|
|
- dict_add(output_map, read_attribute(pm, produce, "name"), mapping[elem_name])
|
|
|
+ if (cast_string(read_attribute(pm, produce, "name")) == "__traceability"):
|
|
|
+ output_traceability_name = mapping[elem_name]
|
|
|
+ else:
|
|
|
+ dict_add(outputs, read_attribute(pm, produce, "name"), type_name)
|
|
|
+ dict_add(output_map, read_attribute(pm, produce, "name"), mapping[elem_name])
|
|
|
|
|
|
if read_type(core, transformation_id) == "ActionLanguage":
|
|
|
log(string_join("Enacting ActionLanguage: ", read_attribute(pm, element, "name")))
|
|
|
- output(string_join("Enacting ActionLanguage: ", read_attribute(pm, element, "name")))
|
|
|
+ output("Success: ready for AL execution")
|
|
|
elif read_type(core, transformation_id) == "ManualOperation":
|
|
|
log(string_join("Enacting ManualOperation: ", read_attribute(pm, element, "name")))
|
|
|
- output(string_join("Enacting ManualOperation: ", read_attribute(pm, element, "name")))
|
|
|
+ output("Success: ready for MANUAL execution")
|
|
|
else:
|
|
|
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, read_root())
|
|
|
+ output("Success: ready for MT execution")
|
|
|
+
|
|
|
+ result = execute_operation(transformation_id, inputs, input_traceability_model)
|
|
|
|
|
|
if (element_eq(result, read_root())):
|
|
|
// Something went wrong!
|
|
|
+ output("Failure")
|
|
|
return False!
|
|
|
else:
|
|
|
+ // Check if we have to store traceability information
|
|
|
+ if (element_neq(output_traceability_name, read_root())):
|
|
|
+ // Yes, so store it
|
|
|
+ // Note that we have overwritten the previous input traceability model, which is why it was a copy
|
|
|
+ model_overwrite(input_traceability_model, get_entry_id(output_traceability_name), get_entry_id(output_traceability_type))
|
|
|
+ log("Writing output traceability model!")
|
|
|
+
|
|
|
keys = dict_keys(outputs)
|
|
|
while (set_len(keys) > 0):
|
|
|
key = set_pop(keys)
|
|
|
+ log("Overwriting model at " + key)
|
|
|
if (get_entry_id(output_map[key]) == ""):
|
|
|
// New model
|
|
|
model_create(result[key], output_map[key], get_entry_id(outputs[key]), "Model")
|
|
|
else:
|
|
|
model_overwrite(result[key], get_entry_id(output_map[key]), get_entry_id(outputs[key]))
|
|
|
+ output("Success")
|
|
|
return True!
|
|
|
|
|
|
Element function PM_signature(pm : Element):
|
|
@@ -861,6 +878,18 @@ Element function PM_signature(pm : Element):
|
|
|
|
|
|
return result!
|
|
|
|
|
|
+Void function enact_PM_activity(activity_to_task : Element, task_to_result : Element, pm : Element, element : String, mapping : Element):
|
|
|
+ Boolean result
|
|
|
+ pm_tasks = activity_to_task
|
|
|
+ set_add(activity_to_task[element], get_taskname())
|
|
|
+ result = enact_action(pm, element, mapping)
|
|
|
+ dict_add_fast(task_to_result, get_taskname(), result)
|
|
|
+
|
|
|
+ while (other_has_output(get_taskname())):
|
|
|
+ sleep(1)
|
|
|
+
|
|
|
+ return!
|
|
|
+
|
|
|
Void function enact_PM(pm : Element, mapping : Element):
|
|
|
Element worklist
|
|
|
String element
|
|
@@ -869,6 +898,7 @@ Void function enact_PM(pm : Element, mapping : Element):
|
|
|
Element tuple
|
|
|
Element counters
|
|
|
Element join_nodes
|
|
|
+ Element exec_nodes
|
|
|
Element keys
|
|
|
String key
|
|
|
|
|
@@ -889,6 +919,8 @@ Void function enact_PM(pm : Element, mapping : Element):
|
|
|
while (get_entry_id(mock_location) != ""):
|
|
|
mock_location = ".tmp/" + random_string(10)
|
|
|
dict_add(mapping, key, mock_location)
|
|
|
+ cmd_model_add(signature[key], mapping[key], "")
|
|
|
+ log("Mock location created " + cast_string(signature[key]) + " : " + cast_string(mapping[key]))
|
|
|
set_add(mock_locations, mock_location)
|
|
|
|
|
|
// Initialize Join counters
|
|
@@ -897,76 +929,117 @@ Void function enact_PM(pm : Element, mapping : Element):
|
|
|
while (set_len(join_nodes) > 0):
|
|
|
dict_add(counters, set_pop(join_nodes), 0)
|
|
|
|
|
|
+ // Initialize activity to task dictionary with empty sets
|
|
|
+ Element activity_to_task
|
|
|
+ Element task_to_activity
|
|
|
+ Element task_to_result
|
|
|
+
|
|
|
+ activity_to_task = dict_create()
|
|
|
+ task_to_activity = dict_create()
|
|
|
+ task_to_result = dict_create()
|
|
|
+ exec_nodes = allInstances(pm, "Exec")
|
|
|
+ while (set_len(exec_nodes) > 0):
|
|
|
+ dict_add(activity_to_task, set_pop(exec_nodes), set_create())
|
|
|
+
|
|
|
// Create the worklist with the Start instance as first element
|
|
|
worklist = set_create()
|
|
|
- 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
|
|
|
- tuple = set_pop(worklist)
|
|
|
- element = tuple[0]
|
|
|
- result = tuple[1]
|
|
|
-
|
|
|
- // Find the type (to see what to do with it)
|
|
|
- // this does not yet yield the type of transformation, if it is an Execution
|
|
|
- type = read_type(pm, element)
|
|
|
-
|
|
|
- if (type == "Start"):
|
|
|
- // Initial node, just progress to the next elements
|
|
|
- // Nothing to do here though, as we have just started
|
|
|
- result = True
|
|
|
- elif (type == "Finish"):
|
|
|
- // Should be impossible, as we would have ended...
|
|
|
- result = result
|
|
|
- elif (type == "Fork"):
|
|
|
- result = result
|
|
|
- elif (type == "Join"):
|
|
|
- // Only do this if all dependencies are fullfilled
|
|
|
- // So add to the counter of this Join
|
|
|
- dict_overwrite(counters, element, integer_addition(counters[element], 1))
|
|
|
-
|
|
|
- // Now check whether we have enough tokens to execute the Join itself
|
|
|
- Integer required
|
|
|
- Integer got
|
|
|
- required = set_len(allIncomingAssociationInstances(pm, element, "Next")) + set_len(allIncomingAssociationInstances(pm, element, "Else"))
|
|
|
- got = counters[element]
|
|
|
- if (got == required):
|
|
|
- // Reset counter to 0
|
|
|
- dict_overwrite(counters, element, 0)
|
|
|
-
|
|
|
- // And continue
|
|
|
- else:
|
|
|
- // We haven't gotten all yet, so we wait (i.e., continue without adding Next link to worklist)
|
|
|
- continue!
|
|
|
+ set_add(worklist, set_pop(allInstances(pm, "Start")))
|
|
|
+
|
|
|
+ // Keep on iterating until we reach finish
|
|
|
+ while (True):
|
|
|
+ // Check if there are PM elements to expand
|
|
|
+ if (set_len(worklist) > 0):
|
|
|
+ // There is something we can do, so do it!
|
|
|
+ element = set_pop(worklist)
|
|
|
|
|
|
- elif (type == "Exec"):
|
|
|
- // Execute a transformation
|
|
|
- // This the difficult part!
|
|
|
+ // Find the type (to see what to do with it)
|
|
|
+ // this does not yet yield the type of transformation, if it is an Execution
|
|
|
+ type = read_type(pm, element)
|
|
|
|
|
|
- result = enact_action(pm, element, mapping)
|
|
|
- output("Success")
|
|
|
+ // Some types have nothing to do, such as start and fork
|
|
|
+ // Therefore, they are not mentioned in the following conditional
|
|
|
|
|
|
- elif (type == "Decision"):
|
|
|
- // If the previous result is true, we add the normal one, otherwise the false one
|
|
|
- // 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_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_node(worklist, create_tuple(set_pop(allAssociationDestinations(pm, element, "Then")), True))
|
|
|
+ if (type == "Finish"):
|
|
|
+ // We have finished, so terminate
|
|
|
+ log("Finished node reached!")
|
|
|
+ break!
|
|
|
+ elif (type == "Join"):
|
|
|
+ // Only do this if all dependencies are fullfilled
|
|
|
+ // So add to the counter of this Join
|
|
|
+ dict_overwrite(counters, element, integer_addition(counters[element], 1))
|
|
|
+
|
|
|
+ // Now check whether we have enough tokens to execute the Join itself
|
|
|
+ Integer required
|
|
|
+ Integer got
|
|
|
+ required = set_len(allIncomingAssociationInstances(pm, element, "Next")) + set_len(allIncomingAssociationInstances(pm, element, "Else"))
|
|
|
+ got = counters[element]
|
|
|
+ if (got == required):
|
|
|
+ // Reset counter to 0
|
|
|
+ dict_overwrite(counters, element, 0)
|
|
|
+
|
|
|
+ // And continue
|
|
|
+ else:
|
|
|
+ // We haven't gotten all yet, so we wait (i.e., continue without adding Next link to worklist)
|
|
|
+ continue!
|
|
|
+
|
|
|
+ elif (type == "Exec"):
|
|
|
+ // Execute a transformation
|
|
|
+ // This the difficult part!
|
|
|
+
|
|
|
+ Element args
|
|
|
+ String taskname
|
|
|
+ args = list_create()
|
|
|
+ list_append(args, activity_to_task)
|
|
|
+ list_append(args, task_to_result)
|
|
|
+ list_append(args, pm)
|
|
|
+ list_append(args, element)
|
|
|
+ list_append(args, mapping)
|
|
|
+ taskname = spawn(enact_PM_activity, args)
|
|
|
+ output(taskname + " : " + cast_string(read_attribute(pm, element, "name")))
|
|
|
+ dict_add(task_to_activity, taskname, element)
|
|
|
continue!
|
|
|
|
|
|
- // We have finished the execution, so add all outgoing edges to the worklist
|
|
|
- Element all_next
|
|
|
- all_next = allAssociationDestinations(pm, element, "Next")
|
|
|
- String next
|
|
|
- while (set_len(all_next) > 0):
|
|
|
- next = set_pop(all_next)
|
|
|
- set_add_node(worklist, create_tuple(next, result))
|
|
|
+ // We have finished the execution, so add all outgoing edges to the worklist
|
|
|
+ Element all_next
|
|
|
+ all_next = allAssociationDestinations(pm, element, "Next")
|
|
|
+ String next
|
|
|
+ while (set_len(all_next) > 0):
|
|
|
+ next = set_pop(all_next)
|
|
|
+ set_add(worklist, next)
|
|
|
+ else:
|
|
|
+ // No new tasks to spawn, so go and check on all running activities
|
|
|
+ if (dict_len(task_to_result) > 0):
|
|
|
+ // There are outputs!
|
|
|
+ Element keys
|
|
|
+ String task
|
|
|
+
|
|
|
+ keys = dict_keys(task_to_result)
|
|
|
+ while (set_len(keys) > 0):
|
|
|
+ task = set_pop(keys)
|
|
|
+ result = task_to_result[task]
|
|
|
+
|
|
|
+ Element all_next
|
|
|
+ all_next = allAssociationDestinations(pm, task_to_activity[task], "Next")
|
|
|
+ String next
|
|
|
+ while (set_len(all_next) > 0):
|
|
|
+ next = set_pop(all_next)
|
|
|
+
|
|
|
+ if (read_type(pm, next) == "Decision"):
|
|
|
+ // Got decision node, so expand immediately
|
|
|
+ if (result):
|
|
|
+ set_add(worklist, set_pop(allAssociationDestinations(pm, next, "Then")))
|
|
|
+ else:
|
|
|
+ set_add(worklist, set_pop(allAssociationDestinations(pm, next, "Else")))
|
|
|
+ else:
|
|
|
+ // Other node, so just append for further processing
|
|
|
+ set_add(worklist, next)
|
|
|
|
|
|
- // Reached a finish element, so stop
|
|
|
+ set_remove(activity_to_task[task_to_activity[task]], task)
|
|
|
+ dict_delete(task_to_result, task)
|
|
|
+ dict_delete(task_to_activity, task)
|
|
|
+ else:
|
|
|
+ // No finished activities either, so we sleep for some time
|
|
|
+ sleep(0.1)
|
|
|
|
|
|
// Remove all mock locations again
|
|
|
while (set_len(mock_locations) > 0):
|
|
@@ -1039,30 +1112,25 @@ String function cmd_model_add(type : String, name : String, code : String):
|
|
|
// Type exists
|
|
|
if (allow_read(current_user_id, type_id)):
|
|
|
// And is readable
|
|
|
- if (get_entry_id(get_foldername(name)) != ""):
|
|
|
- // Folder doesn't exist yet!
|
|
|
- if (allow_write(current_user_id, get_entry_id(get_foldername(name)))):
|
|
|
- // Folder is writable
|
|
|
- if (get_entry_id(name) == ""):
|
|
|
- // Model doesn't exist yet
|
|
|
- Element mm
|
|
|
- mm = get_full_model(type_id, get_entry_id("formalisms/SimpleClassDiagrams"))
|
|
|
- if (element_eq(mm, read_root())):
|
|
|
- return "Type is not typed by formalisms/SimpleClassDiagrams: " + type!
|
|
|
+ create_folders(current_user_id, get_foldername(name))
|
|
|
+ //TODO check if bottommost existing model was writable by us
|
|
|
|
|
|
- new_model = compile_model(code, mm)
|
|
|
+ if (get_entry_id(name) == ""):
|
|
|
+ // Model doesn't exist yet
|
|
|
+ Element mm
|
|
|
+ mm = get_full_model(type_id, get_entry_id("formalisms/SimpleClassDiagrams"))
|
|
|
+ if (element_eq(mm, read_root())):
|
|
|
+ return "Type is not typed by formalisms/SimpleClassDiagrams: " + type!
|
|
|
|
|
|
- if (element_eq(new_model, read_root())):
|
|
|
- return "Compilation error"!
|
|
|
+ new_model = compile_model(code, mm)
|
|
|
|
|
|
- model_create(new_model, name, type_id, "Model")
|
|
|
- return "Success"!
|
|
|
- else:
|
|
|
- return "Model exists: " + name!
|
|
|
- else:
|
|
|
- return "Permission denied to folder: " + get_foldername(name)!
|
|
|
+ if (element_eq(new_model, read_root())):
|
|
|
+ return "Compilation error"!
|
|
|
+
|
|
|
+ model_create(new_model, name, type_id, "Model")
|
|
|
+ return "Success"!
|
|
|
else:
|
|
|
- return "No such folder: " + get_foldername(name)!
|
|
|
+ return "Model exists: " + name!
|
|
|
else:
|
|
|
return "Permission denied to model: " + type!
|
|
|
else:
|
|
@@ -1306,6 +1374,90 @@ String function cmd_model_render(model_name : String, mapper_name : String, rend
|
|
|
else:
|
|
|
return "Model not found: " + model_name!
|
|
|
|
|
|
+Boolean function do_spawn_modify(model_name : String, write : Boolean):
|
|
|
+ output("Please edit this model before sending next input: " + model_name)
|
|
|
+ input()
|
|
|
+ return False!
|
|
|
+
|
|
|
+Boolean function do_spawn_activity(transformation_id : String, tracability_name : String, inputs : Element, outputs : Element, output_map : Element):
|
|
|
+ Element lst
|
|
|
+ Element returnvalue
|
|
|
+ String taskname
|
|
|
+
|
|
|
+ lst = list_create()
|
|
|
+ returnvalue = set_create()
|
|
|
+ list_append(lst, returnvalue)
|
|
|
+ list_append(lst, transformation_id)
|
|
|
+ list_append(lst, tracability_name)
|
|
|
+ list_append(lst, inputs)
|
|
|
+ list_append(lst, outputs)
|
|
|
+ list_append(lst, output_map)
|
|
|
+ taskname = spawn(spawn_activity, lst)
|
|
|
+
|
|
|
+ output("Spawned activity on task: " + taskname)
|
|
|
+
|
|
|
+ while (set_len(returnvalue) == 0):
|
|
|
+ sleep(0.1)
|
|
|
+
|
|
|
+ output("Finished task: " + taskname)
|
|
|
+ return cast_boolean(set_pop(returnvalue))!
|
|
|
+
|
|
|
+Void function spawn_activity(returnvalue : Element, transformation_id : String, tracability_name : String, inputs : Element, outputs : Element, output_map : Element):
|
|
|
+ Element result
|
|
|
+ Element keys
|
|
|
+ String key
|
|
|
+
|
|
|
+ if (read_type(core, transformation_id) == "ActionLanguage"):
|
|
|
+ output("Success: ready for AL execution")
|
|
|
+ elif (read_type(core, transformation_id) == "ManualOperation"):
|
|
|
+ output("Success: ready for MANUAL execution")
|
|
|
+ else:
|
|
|
+ output("Success: ready for MT execution")
|
|
|
+
|
|
|
+ // Do tracability
|
|
|
+ Element tracability_model
|
|
|
+ if (tracability_name != ""):
|
|
|
+ // Check if exists
|
|
|
+ if (get_entry_id(tracability_name) == ""):
|
|
|
+ // No, so create
|
|
|
+ tracability_model = instantiate_model(get_full_model(get_entry_id("formalisms/Tracability"), get_entry_id("formalisms/SimpleClassDiagrams")))
|
|
|
+ model_create(tracability_model, tracability_name, get_entry_id("formalisms/Tracability"), "Model")
|
|
|
+ else:
|
|
|
+ // Yes, so read out
|
|
|
+ tracability_model = get_full_model(get_entry_id(tracability_name), get_entry_id("formalisms/Tracability"))
|
|
|
+ else:
|
|
|
+ tracability_model = read_root()
|
|
|
+
|
|
|
+ result = execute_operation(transformation_id, inputs, tracability_model)
|
|
|
+
|
|
|
+ // Flush tracability again, just to be sure
|
|
|
+ if (tracability_name != ""):
|
|
|
+ model_overwrite(tracability_model, get_entry_id(tracability_name), get_entry_id("formalisms/Tracability"))
|
|
|
+
|
|
|
+ // Now write out the models again
|
|
|
+ if (element_eq(result, read_root())):
|
|
|
+ // Something went wrong!
|
|
|
+ set_add(returnvalue, False)
|
|
|
+ output("Failure")
|
|
|
+ else:
|
|
|
+ keys = dict_keys(outputs)
|
|
|
+ while (set_len(keys) > 0):
|
|
|
+ key = set_pop(keys)
|
|
|
+
|
|
|
+ if (get_entry_id(outputs[key]) == ""):
|
|
|
+ // New model
|
|
|
+ model_create(result[key], outputs[key], get_entry_id(output_map[key]), "Model")
|
|
|
+ else:
|
|
|
+ model_overwrite(result[key], get_entry_id(outputs[key]), get_entry_id(output_map[key]))
|
|
|
+
|
|
|
+ set_add(returnvalue, True)
|
|
|
+ output("Success")
|
|
|
+
|
|
|
+ while (other_has_output(get_taskname())):
|
|
|
+ sleep(1)
|
|
|
+
|
|
|
+ return!
|
|
|
+
|
|
|
String function cmd_transformation_execute(transformation_name : String, source_models : Element, target_models : Element, tracability_name : String):
|
|
|
// Execute a transformation, whatever type it is
|
|
|
// First we detect the type, so we know how to prepare for invocation
|
|
@@ -1322,9 +1474,6 @@ String function cmd_transformation_execute(transformation_name : String, source_
|
|
|
String target_model_name
|
|
|
String source_model_name
|
|
|
String source_model_ID
|
|
|
- Element result
|
|
|
- Element keys
|
|
|
- String key
|
|
|
String assoc_name
|
|
|
|
|
|
transformation_id = get_entry_id(transformation_name)
|
|
@@ -1381,54 +1530,10 @@ String function cmd_transformation_execute(transformation_name : String, source_
|
|
|
else:
|
|
|
return "Permission denied to model: " + target_model_name!
|
|
|
|
|
|
- if (read_type(core, transformation_id) == "ActionLanguage"):
|
|
|
- output("Success: ready for AL execution")
|
|
|
- elif (read_type(core, transformation_id) == "ManualOperation"):
|
|
|
- output("Success: ready for MANUAL execution")
|
|
|
- else:
|
|
|
- output("Success: ready for MT execution")
|
|
|
-
|
|
|
- // Do tracability
|
|
|
- Element tracability_model
|
|
|
- if (tracability_name != ""):
|
|
|
- // Check if exists
|
|
|
- if (get_entry_id(tracability_name) == ""):
|
|
|
- // No, so create
|
|
|
- tracability_model = instantiate_model(get_full_model(get_entry_id("formalisms/Tracability"), get_entry_id("formalisms/SimpleClassDiagrams")))
|
|
|
- model_create(tracability_model, tracability_name, get_entry_id("formalisms/Tracability"), "Model")
|
|
|
- else:
|
|
|
- // Yes, so read out
|
|
|
- tracability_model = get_full_model(get_entry_id(tracability_name), get_entry_id("formalisms/Tracability"))
|
|
|
+ if (do_spawn_activity(transformation_id, tracability_name, inputs, outputs, output_map)):
|
|
|
+ return "Success"!
|
|
|
else:
|
|
|
- tracability_model = read_root()
|
|
|
-
|
|
|
- result = execute_operation(transformation_id, inputs, tracability_model)
|
|
|
-
|
|
|
- // Flush tracability again, just to be sure
|
|
|
- if (tracability_name != ""):
|
|
|
- model_overwrite(tracability_model, get_entry_id(tracability_name), get_entry_id("formalisms/Tracability"))
|
|
|
-
|
|
|
- // Now write out the models again
|
|
|
- if (element_eq(result, read_root())):
|
|
|
- // Something went wrong!
|
|
|
return "Failure"!
|
|
|
- else:
|
|
|
- keys = dict_keys(outputs)
|
|
|
- while (set_len(keys) > 0):
|
|
|
- key = set_pop(keys)
|
|
|
- log("Writing away model with key " + cast_string(key))
|
|
|
- log("Output map: " + dict_to_string(output_map))
|
|
|
- log("Outputs: " + dict_to_string(outputs))
|
|
|
-
|
|
|
- if (get_entry_id(outputs[key]) == ""):
|
|
|
- // New model
|
|
|
- log("New model!")
|
|
|
- model_create(result[key], outputs[key], get_entry_id(output_map[key]), "Model")
|
|
|
- else:
|
|
|
- log("Existing model!")
|
|
|
- model_overwrite(result[key], get_entry_id(outputs[key]), get_entry_id(output_map[key]))
|
|
|
-
|
|
|
- return "Success"!
|
|
|
else:
|
|
|
return "Model is not executable: " + transformation_name!
|
|
|
else:
|
|
@@ -1690,11 +1795,8 @@ String function transformation_add(source_models : Element, target_models : Elem
|
|
|
if (dict_len(source_models) + dict_len(target_models) > 0):
|
|
|
merged_formalism = model_fuse(formalism_map)
|
|
|
model_create(merged_formalism, "merged/" + operation_name, get_entry_id("formalisms/SimpleClassDiagrams"), "Model")
|
|
|
- output("Operating on: merged/" + operation_name)
|
|
|
- if (modify(merged_formalism, True)):
|
|
|
- model_overwrite(merged_formalism, get_entry_id("merged/" + operation_name), get_entry_id("formalisms/SimpleClassDiagrams"))
|
|
|
- else:
|
|
|
- merged_formalism = get_full_model(get_entry_id("merged/" + operation_name), get_entry_id("formalisms/SimpleClassDiagrams"))
|
|
|
+ do_spawn_modify("merged/" + operation_name, True)
|
|
|
+ merged_formalism = get_full_model(get_entry_id("merged/" + operation_name), get_entry_id("formalisms/SimpleClassDiagrams"))
|
|
|
|
|
|
if (operation_type == "manual"):
|
|
|
if (dict_len(source_models) + dict_len(target_models) == 0):
|
|
@@ -1840,11 +1942,8 @@ String function cmd_transformation_add_MT(source_models : Element, target_models
|
|
|
|
|
|
merged_formalism = model_fuse(to_ramify)
|
|
|
model_create(merged_formalism, "merged/" + operation_name, get_entry_id("formalisms/SimpleClassDiagrams"), "Model")
|
|
|
- output("Operating on: merged/" + operation_name)
|
|
|
- if (modify(merged_formalism, True)):
|
|
|
- model_overwrite(merged_formalism, get_entry_id("merged/" + operation_name), get_entry_id("formalisms/SimpleClassDiagrams"))
|
|
|
- else:
|
|
|
- merged_formalism = get_full_model(get_entry_id("merged/" + operation_name), get_entry_id("formalisms/SimpleClassDiagrams"))
|
|
|
+ do_spawn_modify("merged/" + operation_name, True)
|
|
|
+ merged_formalism = get_full_model(get_entry_id("merged/" + operation_name), get_entry_id("formalisms/SimpleClassDiagrams"))
|
|
|
model_overwrite(merged_formalism, get_entry_id("merged/" + operation_name), get_entry_id("formalisms/SimpleClassDiagrams"))
|
|
|
|
|
|
ramified_metamodel = ramify(merged_formalism)
|
|
@@ -2357,9 +2456,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
elif (cmd == "folder_create"):
|
|
|
output(cmd_folder_create(single_input("Folder name?")))
|
|
|
elif (cmd == "add_conformance"):
|
|
|
- log("Adding conformance relation...")
|
|
|
output(cmd_conformance_add(single_input("Model name?"), single_input("Metamodel name?")))
|
|
|
- log("Added!")
|
|
|
elif (cmd == "remove_conformance"):
|
|
|
// TODO
|
|
|
cmd = "FAIL"
|