|
@@ -218,7 +218,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
output("Transformation-specific operations")
|
|
|
output(" transformation_add_MT_language -- Create a RAMified metamodel")
|
|
|
output(" transformation_reRAMify -- RAMify a merged metamodel again")
|
|
|
- output(" transformation_add_MT -- TODO")
|
|
|
+ output(" transformation_add_MT -- Initialize a new model transformation")
|
|
|
output(" transformation_add_AL -- TODO")
|
|
|
output(" transformation_source_add -- TODO")
|
|
|
output(" transformation_source_delete -- TODO")
|
|
@@ -270,7 +270,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
output("Waiting for model constructors...")
|
|
|
|
|
|
// TODO Update construct_model call to this interface
|
|
|
- // new_model = construct_model(read_attribute(core, type_id, "location"))
|
|
|
+ new_model = construct_model(import_node(read_attribute(core, type_id, "location")))
|
|
|
|
|
|
output("Model upload success!")
|
|
|
location = "/models/" + cast_id2s(new_model)
|
|
@@ -291,6 +291,31 @@ Void function user_function_skip_init(user_id : String):
|
|
|
else:
|
|
|
output("Could not find type model!")
|
|
|
|
|
|
+ elif (cmd == "model_overwrite"):
|
|
|
+ // Overwrites an existing model without changing any metadata
|
|
|
+
|
|
|
+ output("Which model to overwrite?")
|
|
|
+ model_id = get_model_id(input())
|
|
|
+ if (model_id == ""):
|
|
|
+ if (allow_write(user_id, model_id)):
|
|
|
+ if (allow_read(user_id, followAssociation(core, model_id, "instanceOf"))):
|
|
|
+ output("Waiting for model constructors...")
|
|
|
+ new_model = construct_model(import_node(read_attribute(core, followAssociation(core, model_id, "instanceOf"), "location")))
|
|
|
+ output("Model upload success!")
|
|
|
+ location = "/models/" + cast_id2s(new_model)
|
|
|
+ export_node(new_model, location)
|
|
|
+
|
|
|
+ // Change location in meta-data
|
|
|
+ unset_attribute(core, model_id, "location")
|
|
|
+ instantiate_attribute(core, model_id, "location", location)
|
|
|
+ output("Model completely overwritten")
|
|
|
+ else:
|
|
|
+ output("Permission denied")
|
|
|
+ else:
|
|
|
+ output("Permission denied")
|
|
|
+ else:
|
|
|
+ output("No such model")
|
|
|
+
|
|
|
elif (cmd == "model_modify"):
|
|
|
// Model modify operation, which uses the mini_modify.alc operations, though with extensions for access control
|
|
|
String model_id
|
|
@@ -390,9 +415,10 @@ Void function user_function_skip_init(user_id : String):
|
|
|
output("Cannot add model as types not compatible with previous models; try again")
|
|
|
else:
|
|
|
output("Model not readable; try again")
|
|
|
- name = input()
|
|
|
else:
|
|
|
output("No such model; try again")
|
|
|
+
|
|
|
+ name = input()
|
|
|
|
|
|
// Merge both into a single metamodel
|
|
|
if (read_nr_out(source) > 0):
|
|
@@ -494,14 +520,94 @@ Void function user_function_skip_init(user_id : String):
|
|
|
// Add a model transformation model
|
|
|
// Just a usual model instantiation, but need to add the source and target links based on user info
|
|
|
String ramified_metamodel_id
|
|
|
+ String model_id
|
|
|
+ Element models
|
|
|
+ Element links
|
|
|
+ String link_id
|
|
|
+ Element supported
|
|
|
+ Element source
|
|
|
+ Element target
|
|
|
+ String name
|
|
|
+ String new_model_id
|
|
|
|
|
|
+ source = create_node()
|
|
|
+ target = create_node()
|
|
|
+ supported = create_node()
|
|
|
output("RAMified metamodel to use?")
|
|
|
ramified_metamodel_id = get_model_id(input())
|
|
|
if (ramified_metamodel_id != ""):
|
|
|
if (allow_read(user_id, ramified_metamodel_id)):
|
|
|
- // TODO follow chain of RAMified and merged tracability links to find possible source and target
|
|
|
- // TODO instantiate a new model of this metamodel and allow for an upload or whatever
|
|
|
- output("TODO")
|
|
|
+ output("Supported metamodels:")
|
|
|
+ links = allOutgoingAssociationInstances(core, ramified_metamodel_id, "tracability")
|
|
|
+ while (read_nr_out(links) > 0):
|
|
|
+ link_id = set_pop(linkss)
|
|
|
+ if (value_eq(read_attribute(core, link_id, "type"), "merged")):
|
|
|
+ output(string_join(" ", read_attribute(core, readAssociationDestination(core, link_id), "name")))
|
|
|
+ set_add(supported, readAssociationDestination(core, link_id))
|
|
|
+
|
|
|
+ output("")
|
|
|
+ output("Which ones do you want to use as source (empty string to finish)?")
|
|
|
+ name = input()
|
|
|
+ while (name != ""):
|
|
|
+ model_id = get_model_id(name)
|
|
|
+ if (model_id != ""):
|
|
|
+ if (set_in(supported, model_id)):
|
|
|
+ if (bool_not(set_in(source, model_id))):
|
|
|
+ set_add(source, model_id)
|
|
|
+ output("Model added as source")
|
|
|
+ else:
|
|
|
+ output("Model already selected as source")
|
|
|
+ else:
|
|
|
+ output("Model is not supported by RAMified metamodel!")
|
|
|
+ else:
|
|
|
+ output("No such model; try again")
|
|
|
+
|
|
|
+ name = input()
|
|
|
+
|
|
|
+ output("Which ones do you want to use as target (empty string to finish)?")
|
|
|
+ name = input()
|
|
|
+ while (name != ""):
|
|
|
+ model_id = get_model_id(name)
|
|
|
+ if (model_id != ""):
|
|
|
+ if (set_in(supported, model_id)):
|
|
|
+ if (bool_not(set_in(target, model_id))):
|
|
|
+ set_add(target, model_id)
|
|
|
+ output("Model added as target")
|
|
|
+ else:
|
|
|
+ output("Model already selected as target")
|
|
|
+ else:
|
|
|
+ output("Model is not supported by RAMified metamodel!")
|
|
|
+ else:
|
|
|
+ output("No such model; try again")
|
|
|
+
|
|
|
+ name = input()
|
|
|
+
|
|
|
+ output("Name of new transformation?")
|
|
|
+ name = input()
|
|
|
+
|
|
|
+ if (get_model_id(name) == ""):
|
|
|
+ // Finished with all information, now create the model itself!
|
|
|
+ new_model = instantiate_model(import_node(read_attribute(core, ramified_model_id, "location")))
|
|
|
+
|
|
|
+ location = "/models/" + cast_id2s(new_model)
|
|
|
+ export_node(new_model, location)
|
|
|
+
|
|
|
+ // Manage meta-info
|
|
|
+ new_model_id = instantiate_node(core, "ModelTransformation", "")
|
|
|
+ instantiate_attribute(core, new_model_id, "name", name)
|
|
|
+ instantiate_attribute(core, new_model_id, "location", location)
|
|
|
+ instantiate_attribute(core, new_model_id, "permissions", "200")
|
|
|
+ instantiate_link(core, "owner", "", new_model_id, user_id)
|
|
|
+ instantiate_link(core, "instanceOf", "", new_model_id, ramified_model_id)
|
|
|
+
|
|
|
+ while (read_nr_out(source) > 0):
|
|
|
+ instantiate_link(core, "transformInput", "", new_model_id, set_pop(source))
|
|
|
+ while (read_nr_out(target) > 0):
|
|
|
+ instantiate_link(core, "transformOutput", "", new_model_id, set_pop(target))
|
|
|
+
|
|
|
+ output("Meta-info correctly set!")
|
|
|
+ else:
|
|
|
+ output("Model already exists")
|
|
|
else:
|
|
|
output("Permission denied")
|
|
|
else:
|