|
@@ -12,25 +12,29 @@ include "metamodels.alh"
|
|
|
|
|
|
Element core = ?
|
|
|
|
|
|
+String scd_location = "models/SimpleClassDiagrams"
|
|
|
+String core_location = "models/CoreFormalism"
|
|
|
+String core_tm_location = "models/CoreFormalism_TypeMapping"
|
|
|
+String core_model_location = "models/core"
|
|
|
+String core_model_tm_location = "models/core_TypeMapping"
|
|
|
+
|
|
|
Void function main():
|
|
|
// Initialize the Core Formalism
|
|
|
- String core_location
|
|
|
String core_model
|
|
|
- String core_model_location
|
|
|
String core_formalism_model
|
|
|
- String scd_location
|
|
|
String scd_model
|
|
|
String admin_group
|
|
|
String admin_user
|
|
|
String nobody_group
|
|
|
+ String instance_of
|
|
|
+ Element scd
|
|
|
|
|
|
- scd_location = "models/SimpleClassDiagrams"
|
|
|
- core_location = "models/CoreFormalism"
|
|
|
- core_model_location = "models/core"
|
|
|
+ scd = initialize_SCD(scd_location)
|
|
|
|
|
|
// Create the Model itself and make public
|
|
|
core = instantiate_model(import_node(core_location))
|
|
|
- export_node(core_model_location, core)
|
|
|
+ export_node(core_model_location, core["model"])
|
|
|
+ export_node(core_model_tm_location, core["type_mapping"])
|
|
|
|
|
|
// Switch all new users to the user_function
|
|
|
// This accesses the bootstrap level, so do not change this unless you know what you are doing
|
|
@@ -81,7 +85,8 @@ Void function main():
|
|
|
instantiate_attribute(core, scd_model, "name", "SimpleClassDiagrams")
|
|
|
instantiate_attribute(core, scd_model, "location", scd_location)
|
|
|
instantiate_attribute(core, scd_model, "permissions", "221")
|
|
|
- instantiate_link(core, "instanceOf", "", scd_model, scd_model)
|
|
|
+ instance_of = instantiate_link(core, "instanceOf", "", scd_model, scd_model)
|
|
|
+ instantiate_attribute(core, instance_of, "type_mapping", scd["type_mapping"])
|
|
|
|
|
|
// Make necessary links for the formalism to the owners
|
|
|
instantiate_link(core, "group", "", scd_model, admin_group)
|
|
@@ -92,7 +97,8 @@ Void function main():
|
|
|
instantiate_attribute(core, core_formalism_model, "name", "CoreFormalism")
|
|
|
instantiate_attribute(core, core_formalism_model, "location", core_location)
|
|
|
instantiate_attribute(core, core_formalism_model, "permissions", "221")
|
|
|
- instantiate_link(core, "instanceOf", "", core_formalism_model, scd_model)
|
|
|
+ instance_of = instantiate_link(core, "instanceOf", "", core_formalism_model, scd_model)
|
|
|
+ instantiate_attribute(core, instance_of, "type_mapping", ???)
|
|
|
|
|
|
// Make necessary links for the formalism to the owners
|
|
|
instantiate_link(core, "group", "", core_formalism_model, admin_group)
|
|
@@ -103,7 +109,8 @@ Void function main():
|
|
|
instantiate_attribute(core, core_model, "name", "core")
|
|
|
instantiate_attribute(core, core_model, "location", core_model_location)
|
|
|
instantiate_attribute(core, core_model, "permissions", "200")
|
|
|
- instantiate_link(core, "instanceOf", "", core_model, core_formalism_model)
|
|
|
+ instance_of = instantiate_link(core, "instanceOf", "", core_model, core_formalism_model)
|
|
|
+ instantiate_attribute(core, instance_of, "type_mapping", core["type_mapping"])
|
|
|
|
|
|
// Make necessary links for the formalism to the owners
|
|
|
instantiate_link(core, "group", "", core_model, admin_group)
|
|
@@ -118,6 +125,25 @@ Void function main():
|
|
|
// Note that if there are no admin users left, it will be very difficult to manage, as nobody will have admin permissions!
|
|
|
return !
|
|
|
|
|
|
+Void function get_full_model(model_id : String):
|
|
|
+ Element m
|
|
|
+ Element all_links
|
|
|
+ String choice
|
|
|
+
|
|
|
+ m = create_node()
|
|
|
+ all_links = allOutgoingAssociations(core, model_id, "instanceOf")
|
|
|
+
|
|
|
+ if (read_nr_out(all_links) != 1):
|
|
|
+ log("WARNING: multiple instanceOf relations were detected for this model; picking one at random!")
|
|
|
+
|
|
|
+ choice = set_pop(allOutgoingAssociations(core, model_id, "instanceOf"))
|
|
|
+
|
|
|
+ dict_add(m, "model", import_node(read_attribute(core, model_id, "location")))
|
|
|
+ dict_add(m, "type_mapping", read_attribute(core, choice, "type_mapping"))
|
|
|
+ dict_add(m, "metamodel", import_node(read_attribute(core, choice, "location")))
|
|
|
+
|
|
|
+ return m!
|
|
|
+
|
|
|
Integer function get_relation_to_model(user_id : String, model_id : String):
|
|
|
if (set_in(allAssociationDestinations(core, model_id, "owner"), user_id)):
|
|
|
// We are the owner
|
|
@@ -224,7 +250,12 @@ Element function user_function():
|
|
|
exec(root["bootstrap/transform.alc"]["initializers"])
|
|
|
exec(root["bootstrap/conformance_scd.alc"]["initializers"])
|
|
|
exec(root["core/core_algorithm.alc"]["initializers"])
|
|
|
- core = import_node("models/core")
|
|
|
+
|
|
|
+ // Load in a hard-reference to the previously created model
|
|
|
+ core = create_node()
|
|
|
+ dict_add(core, "model", import_node(core_model_location))
|
|
|
+ dict_add(core, "metamodel", import_node(scd_location))
|
|
|
+ dict_add(core, "type_mapping", import_node(core_model_tm_location))
|
|
|
|
|
|
output("Log on as which user?")
|
|
|
username = input()
|
|
@@ -301,9 +332,10 @@ String function get_group_id(name : String):
|
|
|
Void function model_create(model : Element, name : String, user_id : String, type_id : String, kind : String):
|
|
|
String location
|
|
|
String model_id
|
|
|
+ String instance_of
|
|
|
|
|
|
location = "/models/" + cast_id2s(model)
|
|
|
- export_node(location, model)
|
|
|
+ export_node(location, model["model"])
|
|
|
|
|
|
// Manage meta-info
|
|
|
model_id = instantiate_node(core, kind, "")
|
|
@@ -312,7 +344,8 @@ Void function model_create(model : Element, name : String, user_id : String, typ
|
|
|
instantiate_attribute(core, model_id, "permissions", "200")
|
|
|
instantiate_link(core, "owner", "", model_id, user_id)
|
|
|
instantiate_link(core, "group", "", model_id, get_group_id("nobody"))
|
|
|
- instantiate_link(core, "instanceOf", "", model_id, type_id)
|
|
|
+ instance_of = instantiate_link(core, "instanceOf", "", model_id, type_id)
|
|
|
+ instantiate_attribute(core, instance_of, "type_mapping", model["type_mapping"])
|
|
|
|
|
|
return!
|
|
|
|
|
@@ -320,7 +353,7 @@ Void function model_overwrite(model : Element, model_id : String):
|
|
|
String location
|
|
|
|
|
|
location = "/models/" + cast_id2s(model)
|
|
|
- export_node(location, model)
|
|
|
+ export_node(location, model["model"])
|
|
|
|
|
|
// Change location in meta-data
|
|
|
unset_attribute(core, model_id, "location")
|
|
@@ -413,8 +446,10 @@ Void function user_function_skip_init(user_id : String):
|
|
|
if (get_model_id(name) == ""):
|
|
|
// Model doesn't exist yet
|
|
|
output("Waiting for model constructors...")
|
|
|
+ m = get_full_model(type_id)
|
|
|
+
|
|
|
+ new_model = construct_model_raw(m)
|
|
|
|
|
|
- new_model = construct_model_raw(import_node(read_attribute(core, type_id, "location")))
|
|
|
model_create(new_model, name, user_id, type_id, "Model")
|
|
|
output("Model upload success!")
|
|
|
else:
|
|
@@ -511,7 +546,8 @@ Void function user_function_skip_init(user_id : String):
|
|
|
String ramified_metamodel_id
|
|
|
Boolean result
|
|
|
|
|
|
- schedule_model = import_node(read_attribute(core, transformation_id, "location"))
|
|
|
+ schedule_model = get_full_model(transformation_id)
|
|
|
+
|
|
|
// Need to fall back to the default approach, which is way slower
|
|
|
// 1) Create empty instance of merged metamodel
|
|
|
|
|
@@ -523,7 +559,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
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")))
|
|
|
+ merged_model = instantiate_model(get_full_model(merged_metamodel_id))
|
|
|
|
|
|
// 2) Merge source models
|
|
|
|
|
@@ -535,7 +571,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
input_keys = dict_keys(inputs)
|
|
|
while (read_nr_out(input_keys) > 0):
|
|
|
key = set_pop(input_keys)
|
|
|
- model_join(merged_model, import_node(read_attribute(core, get_model_id(inputs[key]), "location")), key + "/")
|
|
|
+ model_join(merged_model, get_full_model(get_model_id(inputs[key])), key + "/")
|
|
|
|
|
|
// 3) Transform
|
|
|
|
|
@@ -551,7 +587,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
while (read_nr_out(output_keys) > 0):
|
|
|
key = set_pop(output_keys)
|
|
|
desired_metamodel_id = get_model_id(key)
|
|
|
- split_off_model = model_split(merged_model, import_node(read_attribute(core, desired_metamodel_id, "location")), key + "/")
|
|
|
+ split_off_model = model_split(merged_model, get_full_model(desired_metamodel_id), key + "/")
|
|
|
|
|
|
// Check if the destination model already exists
|
|
|
if (get_model_id(outputs[key]) == ""):
|
|
@@ -584,7 +620,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
if (allow_write(user_id, model_id)):
|
|
|
if (allow_read(user_id, set_pop(followAssociation(core, model_id, "instanceOf")))):
|
|
|
output("Waiting for model constructors...")
|
|
|
- new_model = construct_model_raw(import_node(read_attribute(core, set_pop(followAssociation(core, model_id, "instanceOf")), "location")))
|
|
|
+ new_model = construct_model_raw(get_full_model(set_pop(followAssociation(core, model_id, "instanceOf"))))
|
|
|
model_overwrite(new_model, model_id)
|
|
|
output("Model overwrite success!")
|
|
|
else:
|
|
@@ -606,7 +642,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
if (allow_read(user_id, model_id)):
|
|
|
type_id = set_pop(allAssociationDestinations(core, model_id, "instanceOf"))
|
|
|
if (allow_read(user_id, type_id)):
|
|
|
- modify(import_node(read_attribute(core, model_id, "location")), allow_write(user_id, model_id))
|
|
|
+ modify(get_full_model(model_id), allow_write(user_id, model_id))
|
|
|
else:
|
|
|
output("Permission denied")
|
|
|
else:
|
|
@@ -647,7 +683,6 @@ Void function user_function_skip_init(user_id : String):
|
|
|
String group
|
|
|
String name
|
|
|
String type
|
|
|
- String size
|
|
|
|
|
|
models = allInstances(core, "Model")
|
|
|
while (read_nr_out(models) > 0):
|
|
@@ -656,9 +691,8 @@ Void function user_function_skip_init(user_id : String):
|
|
|
owner = read_attribute(core, set_pop(allAssociationDestinations(core, m, "owner")), "name")
|
|
|
group = read_attribute(core, set_pop(allAssociationDestinations(core, m, "group")), "name")
|
|
|
name = read_attribute(core, m, "name")
|
|
|
- size = cast_i2s(read_nr_out(dict_read(import_node(read_attribute(core, m, "location")), "model")))
|
|
|
type = read_attribute(core, set_pop(allAssociationDestinations(core, m, "instanceOf")), "name")
|
|
|
- output(((((((((((" " + permissions) + " ") + owner) + " ") + group) + " ") + size) + " ") + name) + " : ") + type)
|
|
|
+ output(((((((((" " + permissions) + " ") + owner) + " ") + group) + " ") + name) + " : ") + type)
|
|
|
|
|
|
elif (cmd == "transformation_add_MT_language"):
|
|
|
// Create a model transformation language from a set of input and output formalisms
|
|
@@ -686,7 +720,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
if (allow_read(user_id, model_id)):
|
|
|
type_id = set_pop(allAssociationDestinations(core, model_id, "instanceOf"))
|
|
|
if (bool_or(old_type_id == "", type_id == old_type_id)):
|
|
|
- set_add(all_formalisms, create_tuple(name, import_node(read_attribute(core, model_id, "location"))))
|
|
|
+ set_add(all_formalisms, create_tuple(name, get_full_model(model_id)))
|
|
|
old_type_id = type_id
|
|
|
elif (old_type_id != type_id):
|
|
|
// Already have a previous type_id and now another: CLASH
|
|
@@ -750,7 +784,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
target_model_id = get_model_id(target_model_name)
|
|
|
if (target_model_id == ""):
|
|
|
// New model, so everything is fine
|
|
|
- target_model = ramify(import_node(read_attribute(core, merged_model_id, "location")))
|
|
|
+ target_model = ramify(get_full_model(merged_model_id))
|
|
|
model_create(target_model, target_model_name, user_id, set_pop(allAssociationDestinations(core, merged_model_id, "instanceOf")), "Model")
|
|
|
target_model_id = get_model_id(target_model_name)
|
|
|
tracability_link = instantiate_link(core, "tracability", "", target_model_id, merged_model_id)
|
|
@@ -758,7 +792,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
else:
|
|
|
// Existing model, so overwrite
|
|
|
if (allow_write(user_id, target_model_id)):
|
|
|
- target_model = ramify(import_node(read_attribute(core, merged_model_id, "location")))
|
|
|
+ target_model = ramify(get_full_model(merged_model_id))
|
|
|
model_overwrite(target_model, target_model_id)
|
|
|
model_delete_element(core, set_pop(allOutgoingAssociationInstances(core, target_model_id, "tracability")))
|
|
|
tracability_link = instantiate_link(core, "tracability", "", target_model_id, merged_model_id)
|
|
@@ -851,7 +885,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
String new_model
|
|
|
// Finished with all information, now create the model itself!
|
|
|
output("Waiting for model constructors...")
|
|
|
- new_model = construct_model_raw(import_node(read_attribute(core, ramified_metamodel_id, "location")))
|
|
|
+ new_model = construct_model_raw(get_full_model(ramified_metamodel_id))
|
|
|
model_create(new_model, name, user_id, ramified_metamodel_id, "ModelTransformation")
|
|
|
model_id = get_model_id(name)
|
|
|
|
|
@@ -895,7 +929,6 @@ Void function user_function_skip_init(user_id : String):
|
|
|
String group
|
|
|
String name
|
|
|
String type
|
|
|
- String size
|
|
|
|
|
|
models = allInstances(core, "Transformation")
|
|
|
while (read_nr_out(models) > 0):
|
|
@@ -904,9 +937,8 @@ Void function user_function_skip_init(user_id : String):
|
|
|
owner = read_attribute(core, set_pop(allAssociationDestinations(core, m, "owner")), "name")
|
|
|
group = read_attribute(core, set_pop(allAssociationDestinations(core, m, "group")), "name")
|
|
|
name = read_attribute(core, m, "name")
|
|
|
- size = cast_i2s(read_nr_out(dict_read(import_node(read_attribute(core, m, "location")), "model")))
|
|
|
type = read_attribute(core, set_pop(allAssociationDestinations(core, m, "instanceOf")), "name")
|
|
|
- output(((((((((((" " + permissions) + " ") + owner) + " ") + group) + " ") + size) + " ") + ((("[" + read_type(core, m)) + "] ") + name)) + " : ") + type)
|
|
|
+ output(((((((((" " + permissions) + " ") + owner) + " ") + group) + " ") + ((("[" + read_type(core, m)) + "] ") + name)) + " : ") + type)
|
|
|
|
|
|
elif (cmd == "permission_modify"):
|
|
|
String permissions
|