Browse Source

Avoid using allIncomingAssociationInstances in the finding of typing links

Yentl Van Tendeloo 8 years ago
parent
commit
1378302afc
2 changed files with 16 additions and 5 deletions
  1. 4 4
      bootstrap/conformance_finding.alc
  2. 12 1
      bootstrap/core_algorithm.alc

+ 4 - 4
bootstrap/conformance_finding.alc

@@ -32,10 +32,10 @@ Boolean function find_type_mapping(model : Element):
 	// 2) find a mapping based on the current partial mapping, but only if it is not yet complete
 	// TODO this must be expanded for other things than trivial metamodels!
 	if (dict_len(model["model"]) > dict_len(tm)):
-		log("Model is incompletely typed!")
-		log("Model has: " + set_to_string(dict_keys(model["model"])))
-		log("Type mapping has: " + set_to_string(dict_keys(tm)))
-		log("Missing: " + set_to_string(set_difference(dict_keys(model["model"]), dict_keys(tm))))
+		// log("Model is incompletely typed!")
+		// log("Model has: " + set_to_string(dict_keys(model["model"])))
+		// log("Type mapping has: " + set_to_string(dict_keys(tm)))
+		// log("Missing: " + set_to_string(set_difference(dict_keys(model["model"]), dict_keys(tm))))
 
 		// TODO for now, this only returns something for a simple case, where the MM has one edge, and one node
 		//      and it makes the assumption that SCD is the M3 level...

+ 12 - 1
bootstrap/core_algorithm.alc

@@ -32,7 +32,18 @@ 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"))!
+	Element result
+	Element options
+	String elem
+
+	result = set_create()
+	options = allOutgoingAssociationInstances(core, model_id, "instanceOf")
+	while (set_len(options) > 0):
+		elem = set_pop(options)
+		if (value_eq(readAssociationDestination(core, elem), metamodel_id)):
+			set_add(result, elem)
+
+	return result!
 
 String function get_instanceOf_link(model_id : String, metamodel_id : String):
 	Element all_links