|
@@ -40,9 +40,7 @@ String function get_instanceOf_link(model_id : String, metamodel_id : String):
|
|
|
if (set_len(all_links) > 1):
|
|
|
log("WARNING: multiple instanceOf relations were detected for this model; picking one at random!")
|
|
|
elif (set_len(all_links) == 0):
|
|
|
- log("ERROR: untyped model; crashing")
|
|
|
- log("Instance model: " + cast_v2s(read_attribute(core, model_id, "name")))
|
|
|
- log("Type model: " + cast_v2s(read_attribute(core, metamodel_id, "name")))
|
|
|
+ return read_root()!
|
|
|
|
|
|
choice = set_pop(all_links)
|
|
|
|
|
@@ -58,15 +56,42 @@ Element function get_full_model(model_id : String, metamodel_id : String):
|
|
|
|
|
|
m = dict_create()
|
|
|
dict_add(m, "model", import_node(read_attribute(core, model_id, "location")))
|
|
|
- dict_add(m, "type_mapping", import_node(read_attribute(core, set_pop(allAssociationDestinations(core, choice, "typing")), "location")))
|
|
|
- dict_add(m, "semantics", set_pop(allAssociationDestinations(core, choice, "semantics")))
|
|
|
|
|
|
- if (readAssociationDestination(core, choice) == model_id):
|
|
|
+ // TODO for now this is restricted to the fixed semantics
|
|
|
+ // dict_add(m, "semantics", set_pop(allAssociationDestinations(core, choice, "semantics")))
|
|
|
+ dict_add(m, "semantics", get_model_id("conformance_mv"))
|
|
|
+
|
|
|
+ if (metamodel_id == model_id):
|
|
|
// Found the meta-circular level, so we can stop!
|
|
|
dict_add(m, "metamodel", m)
|
|
|
else:
|
|
|
- dict_add(m, "metamodel", get_full_model(readAssociationDestination(core, choice), get_model_id("SimpleClassDiagrams")))
|
|
|
-
|
|
|
+ dict_add(m, "metamodel", get_full_model(metamodel_id, get_model_id("SimpleClassDiagrams")))
|
|
|
+
|
|
|
+ if (element_neq(choice, read_root())):
|
|
|
+ if (set_len(allAssociationDestinations(core, choice, "typing")) == 1):
|
|
|
+ // Add the preferred original type mapping
|
|
|
+ dict_add(m, "type_mapping", import_node(read_attribute(core, set_pop(allAssociationDestinations(core, choice, "typing")), "location")))
|
|
|
+ else:
|
|
|
+ // Start from scratch
|
|
|
+ dict_add(m, "type_mapping", new_type_mapping())
|
|
|
+ else:
|
|
|
+ // 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)
|
|
|
+
|
|
|
+ // Check if we could find a mapping
|
|
|
+ // TODO assume that we always can!
|
|
|
+
|
|
|
return m!
|
|
|
|
|
|
Integer function get_relation_to_model(user_id : String, model_id : String):
|
|
@@ -1033,7 +1058,10 @@ String function cmd_model_list():
|
|
|
models = allInstances(core, "Model")
|
|
|
while (set_len(models) > 0):
|
|
|
m = set_pop(models)
|
|
|
- result = (result + string_join((string_join(" ", read_attribute(core, m, "name")) + " : "), read_attribute(core, set_pop(allAssociationDestinations(core, m, "instanceOf")), "name"))) + "\n"
|
|
|
+ if (set_len(allAssociationDestinations(core, m, "instanceOf")) > 0):
|
|
|
+ result = (result + string_join((string_join(" ", read_attribute(core, m, "name")) + " : "), read_attribute(core, set_pop(allAssociationDestinations(core, m, "instanceOf")), "name"))) + "\n"
|
|
|
+ else:
|
|
|
+ result = result + string_join(string_join(" ", read_attribute(core, m, "name")), " : None\n")
|
|
|
return result!
|
|
|
|
|
|
String function cmd_model_list_full():
|
|
@@ -1055,7 +1083,12 @@ String function cmd_model_list_full():
|
|
|
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")
|
|
|
- type = read_attribute(core, set_pop(allAssociationDestinations(core, m, "instanceOf")), "name")
|
|
|
+
|
|
|
+ if (set_len(allAssociationDestinations(core, m, "instanceOf")) > 0):
|
|
|
+ type = read_attribute(core, set_pop(allAssociationDestinations(core, m, "instanceOf")), "name")
|
|
|
+ else:
|
|
|
+ type = "None"
|
|
|
+
|
|
|
result = (result + (((((((((" " + permissions) + " ") + owner) + " ") + group) + " ") + name) + " : ") + type)) + "\n"
|
|
|
|
|
|
return result!
|