|
@@ -354,6 +354,22 @@ String function get_model_id(name : String):
|
|
|
|
|
|
return ""!
|
|
|
|
|
|
+String function get_service_id(name : String):
|
|
|
+ Element services
|
|
|
+ String service
|
|
|
+
|
|
|
+ services = allInstances(core, "Service")
|
|
|
+
|
|
|
+ log("Search " + name)
|
|
|
+ while (read_nr_out(services) > 0):
|
|
|
+ service = set_pop(services)
|
|
|
+ log("Check " + cast_v2s(read_attribute(core, service, "name")))
|
|
|
+ if (value_eq(read_attribute(core, service, "name"), name)):
|
|
|
+ log("Match!")
|
|
|
+ return service!
|
|
|
+
|
|
|
+ return ""!
|
|
|
+
|
|
|
String function get_user_id(name : String):
|
|
|
Element users
|
|
|
String user
|
|
@@ -503,6 +519,8 @@ Element function execute_operation(operation_id : String, input_models : Element
|
|
|
if (bool_and(read_nr_out(input_models) == 1, read_nr_out(output_models) == 0)):
|
|
|
// Just skip the merge...
|
|
|
merged_model = model_copy(get_full_model(get_model_id(read_edge_dst(read_out(input_models, 0)))))
|
|
|
+ elif (bool_and(read_nr_out(input_models) == 0, read_nr_out(output_models) == 0)):
|
|
|
+ merged_model = read_root()
|
|
|
else:
|
|
|
log("Could not resolve intermediate merged metamodel")
|
|
|
output("Could not resolve intermediate merged metamodel")
|
|
@@ -1173,9 +1191,6 @@ String function transformation_add(user_id : String, source_models : Element, ta
|
|
|
type_id = ""
|
|
|
old_type_id = ""
|
|
|
|
|
|
- if (bool_and(read_nr_out(source_models) == 0, read_nr_out(target_models) == 0)):
|
|
|
- return "Cannot create transformation without input or output"!
|
|
|
-
|
|
|
keys = dict_keys(source_models)
|
|
|
while (read_nr_out(keys) > 0):
|
|
|
key = set_pop(keys)
|
|
@@ -1229,8 +1244,9 @@ String function transformation_add(user_id : String, source_models : Element, ta
|
|
|
if (get_model_id(operation_name) == ""):
|
|
|
// Write out a merged metamodel containing all these models: this is the MM for the manual operation
|
|
|
// New location is available, so write
|
|
|
- merged_formalism = model_fuse(set_copy(formalism_map))
|
|
|
- modify(merged_formalism, True)
|
|
|
+ if (bool_not(bool_and(read_nr_out(source_models) == 0, read_nr_out(target_models) == 0))):
|
|
|
+ merged_formalism = model_fuse(set_copy(formalism_map))
|
|
|
+ modify(merged_formalism, True)
|
|
|
|
|
|
if (operation_type == "manual"):
|
|
|
// Finished with all information, now create the model itself!
|
|
@@ -1244,34 +1260,35 @@ String function transformation_add(user_id : String, source_models : Element, ta
|
|
|
model_create(import_node("AL/" + operation_name), operation_name, user_id, get_model_id("ActionLanguage"), "ActionLanguage")
|
|
|
model_id = get_model_id(operation_name)
|
|
|
|
|
|
- model_create(merged_formalism, "__merged_" + operation_name, user_id, type_id, "Model")
|
|
|
- merged_formalism_id = get_model_id("__merged_" + operation_name)
|
|
|
-
|
|
|
- // Add tracability links at this level
|
|
|
- while (read_nr_out(all_formalisms) > 0):
|
|
|
- source_formalism_id = set_pop(all_formalisms)
|
|
|
- tracability_link = instantiate_link(core, "tracability", "", merged_formalism_id, source_formalism_id)
|
|
|
- instantiate_attribute(core, tracability_link, "type", "merged")
|
|
|
-
|
|
|
- tracability_link = instantiate_link(core, "tracability", "", model_id, merged_formalism_id)
|
|
|
- instantiate_attribute(core, tracability_link, "type", "operatesOn")
|
|
|
-
|
|
|
- // Extend metadata with info on source and target
|
|
|
- String link
|
|
|
- String dst
|
|
|
-
|
|
|
- keys = dict_keys(source)
|
|
|
- while (read_nr_out(keys) > 0):
|
|
|
- key = set_pop(keys)
|
|
|
- link = instantiate_link(core, "transformInput", "", model_id, source[key])
|
|
|
- instantiate_attribute(core, link, "name", key)
|
|
|
-
|
|
|
- keys = dict_keys(target)
|
|
|
- while (read_nr_out(keys) > 0):
|
|
|
- key = set_pop(keys)
|
|
|
- link = instantiate_link(core, "transformOutput", "", model_id, target[key])
|
|
|
- instantiate_attribute(core, link, "name", key)
|
|
|
-
|
|
|
+ if (bool_not(bool_and(read_nr_out(source_models) == 0, read_nr_out(target_models) == 0))):
|
|
|
+ model_create(merged_formalism, "__merged_" + operation_name, user_id, type_id, "Model")
|
|
|
+ merged_formalism_id = get_model_id("__merged_" + operation_name)
|
|
|
+
|
|
|
+ // Add tracability links at this level
|
|
|
+ while (read_nr_out(all_formalisms) > 0):
|
|
|
+ source_formalism_id = set_pop(all_formalisms)
|
|
|
+ tracability_link = instantiate_link(core, "tracability", "", merged_formalism_id, source_formalism_id)
|
|
|
+ instantiate_attribute(core, tracability_link, "type", "merged")
|
|
|
+
|
|
|
+ tracability_link = instantiate_link(core, "tracability", "", model_id, merged_formalism_id)
|
|
|
+ instantiate_attribute(core, tracability_link, "type", "operatesOn")
|
|
|
+
|
|
|
+ // Extend metadata with info on source and target
|
|
|
+ String link
|
|
|
+ String dst
|
|
|
+
|
|
|
+ keys = dict_keys(source)
|
|
|
+ while (read_nr_out(keys) > 0):
|
|
|
+ key = set_pop(keys)
|
|
|
+ link = instantiate_link(core, "transformInput", "", model_id, source[key])
|
|
|
+ instantiate_attribute(core, link, "name", key)
|
|
|
+
|
|
|
+ keys = dict_keys(target)
|
|
|
+ while (read_nr_out(keys) > 0):
|
|
|
+ key = set_pop(keys)
|
|
|
+ link = instantiate_link(core, "transformOutput", "", model_id, target[key])
|
|
|
+ instantiate_attribute(core, link, "name", key)
|
|
|
+
|
|
|
return "Success"!
|
|
|
else:
|
|
|
return "Model exists: " + operation_name!
|
|
@@ -1705,6 +1722,28 @@ String function cmd_admin_demote(user_id : String, other_user_name : String):
|
|
|
else:
|
|
|
return "Permission denied to administrate: " + other_user_name!
|
|
|
|
|
|
+String function cmd_service_register(user_id : String, service_name : String):
|
|
|
+ // Active a service for this specific user
|
|
|
+ if (get_service_id(service_name) == ""):
|
|
|
+ String service
|
|
|
+ service = instantiate_node(core, "Service", "")
|
|
|
+ instantiate_attribute(core, service, "name", service_name)
|
|
|
+ instantiate_attribute(core, service, "port", get_taskname())
|
|
|
+ output("Success: " + get_taskname())
|
|
|
+
|
|
|
+ // Wait until we can stop the service
|
|
|
+ log("Waiting for service_stop")
|
|
|
+ while (cast_v2s(input()) != "\"service_stop\""):
|
|
|
+ output("Service is running on this task: stop it by sending 'service_stop'")
|
|
|
+ log("Finished")
|
|
|
+
|
|
|
+ model_delete_element(core, service)
|
|
|
+
|
|
|
+ // Service terminated
|
|
|
+ return "Success"!
|
|
|
+ else:
|
|
|
+ return "Service already exists: " + service_name!
|
|
|
+
|
|
|
Void function user_function_skip_init(user_id : String):
|
|
|
String cmd
|
|
|
String result
|
|
@@ -1774,6 +1813,8 @@ Void function user_function_skip_init(user_id : String):
|
|
|
output(cmd_admin_promote(user_id, single_input("User name?")))
|
|
|
elif (cmd == "admin_demote"):
|
|
|
output(cmd_admin_demote(user_id, single_input("User name?")))
|
|
|
+ elif (cmd == "service_register"):
|
|
|
+ output(cmd_service_register(user_id, single_input("Service name?")))
|
|
|
elif (cmd == "verbose"):
|
|
|
set_verbose(True)
|
|
|
elif (cmd == "quiet"):
|