Browse Source

Added in some placeholders for future checks

Yentl Van Tendeloo 8 years ago
parent
commit
9edacfadcb
1 changed files with 24 additions and 14 deletions
  1. 24 14
      core/core_algorithm.alc

+ 24 - 14
core/core_algorithm.alc

@@ -328,6 +328,18 @@ Void function model_overwrite(model : Element, model_id : String):
 
 	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
+
+	return True!
+
 Void function user_function_skip_init(user_id : String):
 	String cmd
 
@@ -438,13 +450,23 @@ Void function user_function_skip_init(user_id : String):
 						inputs = create_node()
 						while (read_nr_out(sources) > 0):
 							source = set_pop(sources)
-							log("Got source link: " + cast_e2s(source))
 							output(string_join("Which model to bind for source element ", read_attribute(core, source, "name")))
 							source_model_name = input()
 							name_id = get_model_id(source_model_name)
 							if (name_id != ""):
 								if (allow_read(user_id, name_id)):
-									dict_add(inputs, read_attribute(core, source, "name"), source_model_name)
+									// Check for conformance to the specified metamodel!
+									Element specified_model
+									// TODO Maybe find out which conformance relation to use, as there might be multiple!
+									if (check_is_typed_by(name_id, source)):
+										if (check_conformance(name_id)):
+											dict_add(inputs, read_attribute(core, source, "name"), source_model_name)
+										else:
+											output("Model has correct type but does not conform completely!")
+											set_add(sources, source)
+									else:
+										output("Model has different type!")
+										set_add(sources, source)
 								else:
 									output("Permission denied")
 									set_add(sources, source)
@@ -494,9 +516,7 @@ Void function user_function_skip_init(user_id : String):
 							// 1) Create empty instance of merged metamodel
 
 							ramified_metamodel_id = set_pop(followAssociation(core, transformation_id, "instanceOf"))
-							log("Got ramified MM: " + ramified_metamodel_id)
 							trace_links = allOutgoingAssociationInstances(core, ramified_metamodel_id, "tracability")
-							log("With tracability links: " + set_to_string(trace_links))
 							merged_metamodel_id = ""
 							while (read_nr_out(trace_links) > 0):
 								trace_link_id = set_pop(trace_links)
@@ -530,23 +550,16 @@ Void function user_function_skip_init(user_id : String):
 								output_keys = dict_keys(outputs)
 								while (read_nr_out(output_keys) > 0):
 									key = set_pop(output_keys)
-									log("Key: " + key)
-									log("Model id: " + get_model_id(key))
 									desired_metamodel_id = get_model_id(key)
-									log("Instance of: " + desired_metamodel_id)
 									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]) == ""):
 										// New model
 										model_create(split_off_model, outputs[key], user_id, desired_metamodel_id, "Model")
-										log("Created new model with name: " + cast_v2s(outputs[key]))
-										log("Split off model has size: " + cast_v2s(read_nr_out(split_off_model["model"])))
 									else:
 										// Model exists, so we overwrite
 										model_overwrite(split_off_model, get_model_id(outputs[key]))
-										log("Overwrite existing model with name: " + cast_v2s(outputs[key]))
-										log("Split off model has size: " + cast_v2s(read_nr_out(split_off_model["model"])))
 							else:
 								output("Could not resolve intermediate merged metamodel")
 						elif (exact_type == "ActionLanguage"):
@@ -1084,9 +1097,6 @@ Void function user_function_skip_init(user_id : String):
 
 						overlap = set_overlap(allOutgoingAssociationInstances(core, other_user_id, "belongsTo"), allIncomingAssociationInstances(core, group_id, "belongsTo"))
 
-						log("Size of overlap: " + cast_v2s(read_nr_out(overlap)))
-						log("Overlap: " + set_to_string(overlap))
-
 						if (read_nr_out(overlap) == 0):
 							instantiate_link(core, "belongsTo", "", other_user_id, group_id)
 							output("User added to the group!")