|
@@ -6,6 +6,8 @@ include "object_operations.alh"
|
|
|
include "mini_modify.alh"
|
|
|
include "model_management.alh"
|
|
|
include "ramify.alh"
|
|
|
+include "conformance_scd.alh"
|
|
|
+include "transform.alh"
|
|
|
|
|
|
Element core = ?
|
|
|
|
|
@@ -196,6 +198,7 @@ String function get_group_id(name : String):
|
|
|
|
|
|
Void function model_create(model : Element, name : String, user_id : String, type_id : String):
|
|
|
String location
|
|
|
+ String model_id
|
|
|
|
|
|
location = "/models/" + cast_id2s(model)
|
|
|
export_node(model, location)
|
|
@@ -296,7 +299,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(import_node(read_attribute(core, type_id, "location")))
|
|
|
+ new_model = construct_model_raw(import_node(read_attribute(core, type_id, "location")))
|
|
|
model_create(new_model, name, user_id, type_id)
|
|
|
output("Model upload success!")
|
|
|
else:
|
|
@@ -316,6 +319,9 @@ Void function user_function_skip_init(user_id : String):
|
|
|
String source
|
|
|
String target
|
|
|
String name_id
|
|
|
+ Element inputs
|
|
|
+ Element outputs
|
|
|
+ Element trace_links
|
|
|
|
|
|
output("Which transformation do you want to execute?")
|
|
|
transformation_id = get_model_id(input())
|
|
@@ -323,7 +329,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
if (allow_read(user_id, transformation_id)):
|
|
|
if (is_nominal_instance(core, transformation_id, "Transformation")):
|
|
|
// Read out source and target links
|
|
|
- sources = readOutgoingAssociationInstances(core, transformation_id, "transformInput")
|
|
|
+ sources = allOutgoingAssociationInstances(core, transformation_id, "transformInput")
|
|
|
inputs = create_node()
|
|
|
while (read_nr_out(source) > 0):
|
|
|
source = set_pop(sources)
|
|
@@ -339,7 +345,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
output("No such model")
|
|
|
set_add(sources, source)
|
|
|
|
|
|
- targets = readOutgoingAssociationInstances(core, transformation_id, "transformOutput")
|
|
|
+ targets = allOutgoingAssociationInstances(core, transformation_id, "transformOutput")
|
|
|
outputs = create_node()
|
|
|
while (read_nr_out(targets) > 0):
|
|
|
target = set_pop(targets)
|
|
@@ -361,6 +367,10 @@ Void function user_function_skip_init(user_id : String):
|
|
|
// First check for this exception, as it is much faster
|
|
|
Element input_model
|
|
|
Element schedule_model
|
|
|
+ String trace_link_id
|
|
|
+ Element merged_model
|
|
|
+ String merged_metamodel_id
|
|
|
+ String ramified_metamodel_id
|
|
|
|
|
|
schedule_model = import_node(read_attribute(core, transformation_id, "location"))
|
|
|
if (bool_and(bool_and(read_nr_out(inputs) == 1, read_nr_out(outputs) == 1), set_equality(inputs, outputs))):
|
|
@@ -371,24 +381,27 @@ Void function user_function_skip_init(user_id : String):
|
|
|
// Need to fall back to the default approach, which is way slower
|
|
|
// 1) Create empty instance of merged metamodel
|
|
|
|
|
|
- trace_links = allOutgoingAssociationInstances(core, transformation_id, "tracability")
|
|
|
- ramified_metamodel = ""
|
|
|
+ ramified_metamodel_id = followAssociation(core, transformation_id, "instanceOf")
|
|
|
+ trace_links = allOutgoingAssociationInstances(core, ramified_metamodel_id, "tracability")
|
|
|
+ merged_metamodel_id = ""
|
|
|
while (read_nr_out(trace_links) > 0):
|
|
|
trace_link_id = set_pop(trace_links)
|
|
|
- if (read_attribute(core, trace_link_id, "type") == "ramified"):
|
|
|
- ramified_metamodel = readAssociationDestination(core, trace_link_id)
|
|
|
- if (ramified_metamodel != ""):
|
|
|
- merged_model = instantiate_model(import_node(merged_metamodel))
|
|
|
+ if (value_eq(read_attribute(core, trace_link_id, "type"), "ramified")):
|
|
|
+ merged_metamodel_id = readAssociationDestination(core, trace_link_id)
|
|
|
+ if (merged_metamodel_id != ""):
|
|
|
+ merged_model = instantiate_model(import_node(read_attribute(core, merged_metamodel_id, "location")))
|
|
|
|
|
|
// 2) Merge source models
|
|
|
|
|
|
String key
|
|
|
Element keys
|
|
|
+ Element input_keys
|
|
|
+ Element output_keys
|
|
|
+
|
|
|
input_keys = dict_keys(inputs)
|
|
|
while (read_nr_out(input_keys) > 0):
|
|
|
key = set_pop(input_keys)
|
|
|
- model = import_node(read_attribute(core, inputs[key], "location"))
|
|
|
- model_join(merged_model, model, key)
|
|
|
+ model_join(merged_model, import_node(read_attribute(core, inputs[key], "location")), key)
|
|
|
|
|
|
// 3) Transform
|
|
|
|
|
@@ -396,12 +409,14 @@ Void function user_function_skip_init(user_id : String):
|
|
|
|
|
|
// 4) Split in different files depending on type
|
|
|
|
|
|
+ String desired_metamodel_id
|
|
|
+ Element split_off_model
|
|
|
+
|
|
|
output_keys = dict_keys(outputs)
|
|
|
while (read_nr_out(output_keys) > 0):
|
|
|
key = set_pop(output_keys)
|
|
|
- desired_metamodel_id = followAssociation(core, outputs[key])
|
|
|
- desired_metamodel = import_node(read_attribute(core, desired_metamodel_id, "location"))
|
|
|
- split_off_model = model_split(merged_model, desired_metamodel, key)
|
|
|
+ desired_metamodel_id = followAssociation(core, outputs[key], "instanceOf")
|
|
|
+ split_off_model = model_split(merged_model, import_node(read_attribute(core, desired_metamodel_id, "location")), key)
|
|
|
|
|
|
// Check if the destination model already exists
|
|
|
if (get_model_id(outputs[key]) == ""):
|
|
@@ -414,7 +429,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
else:
|
|
|
output("Could not resolve intermediate merged metamodel")
|
|
|
elif (exact_type == "ActionLanguage"):
|
|
|
- output("Not Implemented yet!)
|
|
|
+ output("Not Implemented yet!")
|
|
|
else:
|
|
|
output("Did not know how to interpret model of type " + exact_type)
|
|
|
else:
|
|
@@ -426,6 +441,8 @@ Void function user_function_skip_init(user_id : String):
|
|
|
|
|
|
elif (cmd == "model_overwrite"):
|
|
|
// Overwrites an existing model without changing any metadata
|
|
|
+ String model_id
|
|
|
+ Element new_model
|
|
|
|
|
|
output("Which model to overwrite?")
|
|
|
model_id = get_model_id(input())
|
|
@@ -433,7 +450,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
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")))
|
|
|
+ new_model = construct_model_raw(import_node(read_attribute(core, followAssociation(core, model_id, "instanceOf"), "location")))
|
|
|
model_overwrite(new_model, model_id)
|
|
|
output("Model overwrite success!")
|
|
|
else:
|
|
@@ -629,13 +646,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
|
|
|
if (merged_model_id != ""):
|
|
|
new_model = ramify(core["model"][merged_model_id])
|
|
|
-
|
|
|
- location = "/models/" + cast_id2s(new_model)
|
|
|
- export_node(new_model, location)
|
|
|
-
|
|
|
- // Update meta-info
|
|
|
- unset_attribute(core, model_id, "location")
|
|
|
- instantiate_attribute(core, model_id, "location", location)
|
|
|
+ model_overwrite(new_model, model_id)
|
|
|
else:
|
|
|
output("Could not determine original model of RAMified metamodel!")
|
|
|
else:
|
|
@@ -667,7 +678,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
output("Supported metamodels:")
|
|
|
links = allOutgoingAssociationInstances(core, ramified_metamodel_id, "tracability")
|
|
|
while (read_nr_out(links) > 0):
|
|
|
- link_id = set_pop(linkss)
|
|
|
+ link_id = set_pop(links)
|
|
|
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))
|
|
@@ -713,20 +724,14 @@ Void function user_function_skip_init(user_id : String):
|
|
|
name = input()
|
|
|
|
|
|
if (get_model_id(name) == ""):
|
|
|
+ String new_model
|
|
|
// 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)
|
|
|
+ new_model = instantiate_model(import_node(read_attribute(core, ramified_metamodel_id, "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)
|
|
|
+ model_create(new_model, name, user_id, ramified_metamodel_id)
|
|
|
+ model_id = get_model_id(name)
|
|
|
|
|
|
+ // Extend metadata with info on source and target
|
|
|
while (read_nr_out(source) > 0):
|
|
|
instantiate_link(core, "transformInput", "", new_model_id, set_pop(source))
|
|
|
while (read_nr_out(target) > 0):
|