|
@@ -28,6 +28,9 @@ Void function initialize_core():
|
|
|
|
|
|
return !
|
|
|
|
|
|
+Boolean function is_typed_by(model_id : String, metamodel_id : String):
|
|
|
+ return (set_len(get_instanceOf_links(model_id, metamodel_id)) > 0)!
|
|
|
+
|
|
|
Element function get_instanceOf_links(model_id : String, metamodel_id : String):
|
|
|
return set_overlap(allOutgoingAssociationInstances(core, model_id, "instanceOf"), allIncomingAssociationInstances(core, metamodel_id, "instanceOf"))!
|
|
|
|
|
@@ -35,7 +38,7 @@ String function get_instanceOf_link(model_id : String, metamodel_id : String):
|
|
|
Element all_links
|
|
|
String choice
|
|
|
|
|
|
- all_links = set_overlap(allOutgoingAssociationInstances(core, model_id, "instanceOf"), allIncomingAssociationInstances(core, metamodel_id, "instanceOf"))
|
|
|
+ all_links = get_instanceOf_links(model_id, metamodel_id)
|
|
|
|
|
|
if (set_len(all_links) > 1):
|
|
|
log("WARNING: multiple instanceOf relations were detected for this model; picking one at random!")
|
|
@@ -78,19 +81,9 @@ Element function get_full_model(model_id : String, metamodel_id : String):
|
|
|
// Start from scratch
|
|
|
dict_add(m, "type_mapping", new_type_mapping())
|
|
|
|
|
|
- // Perform corrections on the type mapping, based on the current knowledge
|
|
|
- if (element_neq(choice, read_root())):
|
|
|
- // There was an instanceOf link, but we can remove that one as we resolved the new type
|
|
|
- model_delete_element(core, choice)
|
|
|
-
|
|
|
- if (find_type_mapping(m)):
|
|
|
- // Export the type_mapping that we found just now
|
|
|
- if (element_neq(choice, read_root())):
|
|
|
- // There was a previou one, which we remove now
|
|
|
- model_delete_element(core, choice)
|
|
|
+ find_type_mapping(m)
|
|
|
|
|
|
- // Check if we could find a mapping
|
|
|
- // TODO assume that we always can!
|
|
|
+ // TODO store the found type model somewhere
|
|
|
|
|
|
return m!
|
|
|
|
|
@@ -269,6 +262,26 @@ String function get_group_id(name : String):
|
|
|
|
|
|
return ""!
|
|
|
|
|
|
+String function export_typing(model : Element, name : String, user_id : String):
|
|
|
+ String result
|
|
|
+ result = instantiate_node(core, "TypeMapping", "")
|
|
|
+
|
|
|
+ // Create type mapping model
|
|
|
+ String location
|
|
|
+ location = "type_mappings/" + cast_id2s(model["type_mapping"])
|
|
|
+ export_node(location, model["type_mapping"])
|
|
|
+
|
|
|
+ String instance_of
|
|
|
+ instantiate_attribute(core, result, "name", "TM_" + name)
|
|
|
+ instantiate_attribute(core, result, "location", location)
|
|
|
+ instantiate_attribute(core, result, "permissions", "200")
|
|
|
+ instantiate_link(core, "owner", "", result, user_id)
|
|
|
+ instantiate_link(core, "group", "", result, get_group_id("nobody"))
|
|
|
+ instance_of = instantiate_link(core, "instanceOf", "", result, get_model_id("TypeMapping"))
|
|
|
+ instantiate_link(core, "semantics", "", instance_of, get_model_id("conformance_mv"))
|
|
|
+
|
|
|
+ return result!
|
|
|
+
|
|
|
Void function model_create(model : Element, name : String, user_id : String, type_id : String, kind : String):
|
|
|
String location
|
|
|
String model_id
|
|
@@ -288,18 +301,7 @@ Void function model_create(model : Element, name : String, user_id : String, typ
|
|
|
instantiate_link(core, "semantics", "", instance_of, get_model_id("conformance_mv"))
|
|
|
|
|
|
// Create type mapping model
|
|
|
- location = "models/" + cast_id2s(model["type_mapping"])
|
|
|
- export_node(location, model["type_mapping"])
|
|
|
-
|
|
|
- model_id = instantiate_node(core, "TypeMapping", "")
|
|
|
- instantiate_link(core, "typing", "", instance_of, model_id)
|
|
|
- instantiate_attribute(core, model_id, "name", "TM_" + name)
|
|
|
- instantiate_attribute(core, model_id, "location", location)
|
|
|
- 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"))
|
|
|
- instance_of = instantiate_link(core, "instanceOf", "", model_id, get_model_id("TypeMapping"))
|
|
|
- instantiate_link(core, "semantics", "", instance_of, get_model_id("conformance_mv"))
|
|
|
+ instantiate_link(core, "typing", "", instance_of, export_typing(model, name, user_id))
|
|
|
|
|
|
return!
|
|
|
|
|
@@ -317,24 +319,20 @@ Void function model_overwrite(model : Element, model_id : String, metamodel_id :
|
|
|
instantiate_attribute(core, model_id, "location", location)
|
|
|
|
|
|
// Update the instanceOf relation of the context in which we are working
|
|
|
- // TODO This needs to be fixed: all previous connections should be cleared probably
|
|
|
String choice
|
|
|
- String typing_model_id
|
|
|
choice = get_instanceOf_link(model_id, metamodel_id)
|
|
|
- typing_model_id = set_pop(allAssociationDestinations(core, choice, "typing"))
|
|
|
+ if (element_neq(choice, read_root())):
|
|
|
+ // There was a link, so we remove it
|
|
|
+ model_delete_element(core, choice)
|
|
|
|
|
|
- location = "models/" + cast_id2s(model["type_mapping"])
|
|
|
- export_node(location, model["type_mapping"])
|
|
|
- instantiate_attribute(core, typing_model_id, "location", location)
|
|
|
+ // Create a new instanceOf relation now
|
|
|
+ String instance_of
|
|
|
+ instance_of = instantiate_link(core, "instanceOf", "", model_id, metamodel_id)
|
|
|
+ instantiate_link(core, "semantics", "", instance_of, get_model_id("conformance_mv"))
|
|
|
+ instantiate_link(core, "typing", "", instance_of, export_typing(model, read_attribute(core, model_id, "name"), get_user_id("admin")))
|
|
|
|
|
|
return!
|
|
|
|
|
|
-Boolean function check_is_typed_by(model_id : String, metamodel_id : String):
|
|
|
- // TODO check if there is actually an instanceOf link between them
|
|
|
- // --> quick check!
|
|
|
-
|
|
|
- return True!
|
|
|
-
|
|
|
Boolean function check_conformance(model_id : String):
|
|
|
// TODO check if it actually conforms, considering that instanceOf link
|
|
|
// --> in-depth check
|
|
@@ -880,14 +878,8 @@ String function cmd_transformation_execute(user_id : String, transformation_name
|
|
|
if (source_model_ID != ""):
|
|
|
if (allow_read(user_id, source_model_ID)):
|
|
|
// Check for conformance to the requested metamodel
|
|
|
- if (check_is_typed_by(source_model_ID, source)):
|
|
|
- if (check_conformance(source_model_ID)):
|
|
|
- dict_add(inputs, assoc_name, source_model_name)
|
|
|
- continue!
|
|
|
- else:
|
|
|
- return "Incorrectly typed model: " + source_model_name!
|
|
|
- else:
|
|
|
- return "Incorrectly typed model: " + source_model_name!
|
|
|
+ dict_add(inputs, assoc_name, source_model_name)
|
|
|
+ continue!
|
|
|
else:
|
|
|
return "Permission denied to model: " + source_model_name!
|
|
|
else:
|
|
@@ -972,10 +964,12 @@ String function cmd_new_verify(user_id : String, model_name : String, metamodel_
|
|
|
model_id = get_model_id(model_name)
|
|
|
if (model_id != ""):
|
|
|
if (allow_read(user_id, model_id)):
|
|
|
- String conformance_operation
|
|
|
- Element conformance
|
|
|
+ Element full_model
|
|
|
+ Element conformance_operation
|
|
|
+
|
|
|
+ full_model = get_full_model(get_model_id(model_name), get_model_id(metamodel_name))
|
|
|
+ conformance_operation = full_model["semantics"]
|
|
|
|
|
|
- conformance_operation = set_pop(allAssociationDestinations(core, get_instanceOf_link(model_id, get_model_id(metamodel_name)), "semantics"))
|
|
|
inputs = dict_create()
|
|
|
dict_add(inputs, "SimpleClassDiagrams", model_name)
|
|
|
result = execute_operation(conformance_operation, inputs, read_root())
|
|
@@ -1247,7 +1241,7 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
|
|
|
if (model_id != ""):
|
|
|
if (allow_read(user_id, name)):
|
|
|
// Check whether or not it is SimpleClassDiagrams
|
|
|
- if (set_len(get_instanceOf_links(model_id, get_model_id("SimpleClassDiagrams"))) > 0):
|
|
|
+ if (is_typed_by(model_id, get_model_id("SimpleClassDiagrams"))):
|
|
|
if (bool_not(dict_in(source, key))):
|
|
|
dict_add(source, key, model_id)
|
|
|
set_add_node(to_ramify, create_tuple(key, get_full_model(model_id, get_model_id("SimpleClassDiagrams"))))
|
|
@@ -1267,7 +1261,7 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
|
|
|
model_id = get_model_id(name)
|
|
|
if (model_id != ""):
|
|
|
if (allow_read(user_id, name)):
|
|
|
- if (set_len(get_instanceOf_links(model_id, get_model_id("SimpleClassDiagrams"))) > 0):
|
|
|
+ if (is_typed_by(model_id, get_model_id("SimpleClassDiagrams"))):
|
|
|
if (bool_not(dict_in(target, key))):
|
|
|
if (dict_in(source, key)):
|
|
|
if (value_eq(model_id, source[key])):
|