|
@@ -4,6 +4,21 @@ include "object_operations.alh"
|
|
include "constructors.alh"
|
|
include "constructors.alh"
|
|
include "modelling.alh"
|
|
include "modelling.alh"
|
|
|
|
|
|
|
|
+Element function set_copy(a : Element):
|
|
|
|
+ Element b
|
|
|
|
+ Integer i
|
|
|
|
+ Integer count
|
|
|
|
+
|
|
|
|
+ b = create_node()
|
|
|
|
+ i = 0
|
|
|
|
+ count = read_nr_out(a)
|
|
|
|
+
|
|
|
|
+ while (i < count):
|
|
|
|
+ set_add(b, read_edge_dst(read_out(a, i)))
|
|
|
|
+ i = i + 1
|
|
|
|
+
|
|
|
|
+ return b
|
|
|
|
+
|
|
Boolean function is_direct_instance(model : Element, instance : String, type : String):
|
|
Boolean function is_direct_instance(model : Element, instance : String, type : String):
|
|
// Just check whether or not the type mapping specifies the type as the type of the instance
|
|
// Just check whether or not the type mapping specifies the type as the type of the instance
|
|
return element_eq(dict_read_node(model["type_mapping"], model["model"][instance]), model["metamodel"]["model"][type])
|
|
return element_eq(dict_read_node(model["type_mapping"], model["model"][instance]), model["metamodel"]["model"][type])
|
|
@@ -49,6 +64,43 @@ Boolean function is_nominal_subtype(metamodel : Element, subclass : String, supe
|
|
|
|
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
+Element function precompute_cardinalities(model : Element):
|
|
|
|
+ Integer slc
|
|
|
|
+ Integer suc
|
|
|
|
+ Integer tlc
|
|
|
|
+ Integer tuc
|
|
|
|
+ String key
|
|
|
|
+ Element tmp_dict
|
|
|
|
+ Element cardinalities
|
|
|
|
+ Element keys
|
|
|
|
+ Element metamodel
|
|
|
|
+
|
|
|
|
+ metamodel = model["metamodel"]
|
|
|
|
+ keys = allInstances(metamodel, "Association")
|
|
|
|
+
|
|
|
|
+ cardinalities = create_node()
|
|
|
|
+ while (0 < list_len(keys)):
|
|
|
|
+ key = set_pop(keys)
|
|
|
|
+ tmp_dict = create_node()
|
|
|
|
+ slc = read_attribute(metamodel, key, "source_lower_cardinality")
|
|
|
|
+ suc = read_attribute(metamodel, key, "source_upper_cardinality")
|
|
|
|
+ tlc = read_attribute(metamodel, key, "target_lower_cardinality")
|
|
|
|
+ tuc = read_attribute(metamodel, key, "target_upper_cardinality")
|
|
|
|
+
|
|
|
|
+ if (element_neq(slc, read_root())):
|
|
|
|
+ dict_add(tmp_dict, "slc", slc)
|
|
|
|
+ if (element_neq(suc, read_root())):
|
|
|
|
+ dict_add(tmp_dict, "suc", suc)
|
|
|
|
+ if (element_neq(tlc, read_root())):
|
|
|
|
+ dict_add(tmp_dict, "tlc", tlc)
|
|
|
|
+ if (element_neq(tuc, read_root())):
|
|
|
|
+ dict_add(tmp_dict, "tuc", tuc)
|
|
|
|
+
|
|
|
|
+ if (list_len(tmp_dict) > 0):
|
|
|
|
+ dict_add(cardinalities, key, tmp_dict)
|
|
|
|
+
|
|
|
|
+ return cardinalities
|
|
|
|
+
|
|
String function conformance_scd(model : Element):
|
|
String function conformance_scd(model : Element):
|
|
// Initialization
|
|
// Initialization
|
|
Element keys
|
|
Element keys
|
|
@@ -65,7 +117,7 @@ String function conformance_scd(model : Element):
|
|
Element cardinalities
|
|
Element cardinalities
|
|
Element scd
|
|
Element scd
|
|
Integer instances
|
|
Integer instances
|
|
-
|
|
|
|
|
|
+ String type_name
|
|
Element spo_cache
|
|
Element spo_cache
|
|
Element spi_cache
|
|
Element spi_cache
|
|
|
|
|
|
@@ -76,46 +128,19 @@ String function conformance_scd(model : Element):
|
|
scd = import_node("models/SimpleClassDiagrams")
|
|
scd = import_node("models/SimpleClassDiagrams")
|
|
metamodel = model["metamodel"]
|
|
metamodel = model["metamodel"]
|
|
typing = model["type_mapping"]
|
|
typing = model["type_mapping"]
|
|
- cardinalities = create_node()
|
|
|
|
|
|
+
|
|
|
|
|
|
// Create dictionary with all associations and allowed cardinalities
|
|
// Create dictionary with all associations and allowed cardinalities
|
|
if (list_len(model["model"]) > 0):
|
|
if (list_len(model["model"]) > 0):
|
|
- Integer slc
|
|
|
|
- Integer suc
|
|
|
|
- Integer tlc
|
|
|
|
- Integer tuc
|
|
|
|
- String key
|
|
|
|
- Element tmp_dict
|
|
|
|
- String type_name
|
|
|
|
-
|
|
|
|
- keys = allInstances(metamodel, "Association")
|
|
|
|
- while (0 < list_len(keys)):
|
|
|
|
- key = set_pop(keys)
|
|
|
|
- tmp_dict = create_node()
|
|
|
|
- slc = read_attribute(metamodel, key, "source_lower_cardinality")
|
|
|
|
- suc = read_attribute(metamodel, key, "source_upper_cardinality")
|
|
|
|
- tlc = read_attribute(metamodel, key, "target_lower_cardinality")
|
|
|
|
- tuc = read_attribute(metamodel, key, "target_upper_cardinality")
|
|
|
|
-
|
|
|
|
- if (element_neq(slc, read_root())):
|
|
|
|
- dict_add(tmp_dict, "slc", slc)
|
|
|
|
- if (element_neq(suc, read_root())):
|
|
|
|
- dict_add(tmp_dict, "suc", suc)
|
|
|
|
- if (element_neq(tlc, read_root())):
|
|
|
|
- dict_add(tmp_dict, "tlc", tlc)
|
|
|
|
- if (element_neq(tuc, read_root())):
|
|
|
|
- dict_add(tmp_dict, "tuc", tuc)
|
|
|
|
-
|
|
|
|
- if (list_len(tmp_dict) > 0):
|
|
|
|
- dict_add(cardinalities, key, tmp_dict)
|
|
|
|
|
|
+ cardinalities = precompute_cardinalities(model)
|
|
|
|
|
|
// Iterate over each element of the model, finding out whether everything is fine
|
|
// Iterate over each element of the model, finding out whether everything is fine
|
|
keys = dict_keys(model["model"])
|
|
keys = dict_keys(model["model"])
|
|
while (0 < list_len(keys)):
|
|
while (0 < list_len(keys)):
|
|
model_name = set_pop(keys)
|
|
model_name = set_pop(keys)
|
|
- log("Check " + model_name)
|
|
|
|
element = model["model"][model_name]
|
|
element = model["model"][model_name]
|
|
type_name = reverseKeyLookup(metamodel["model"], dict_read_node(typing, element))
|
|
type_name = reverseKeyLookup(metamodel["model"], dict_read_node(typing, element))
|
|
|
|
+ log((("Check " + model_name) + " : ") + type_name)
|
|
|
|
|
|
if (bool_not(dict_in_node(typing, element))):
|
|
if (bool_not(dict_in_node(typing, element))):
|
|
return "Model has no type specified: " + model_name
|
|
return "Model has no type specified: " + model_name
|
|
@@ -123,8 +148,9 @@ String function conformance_scd(model : Element):
|
|
if (bool_not(set_in_node(metamodel["model"], dict_read_node(typing, element)))):
|
|
if (bool_not(set_in_node(metamodel["model"], dict_read_node(typing, element)))):
|
|
return "Type of element not in specified metamodel: " + model_name
|
|
return "Type of element not in specified metamodel: " + model_name
|
|
|
|
|
|
- if (bool_not(is_nominal_instance(model, model_name, type_name))):
|
|
|
|
- return "Element is not an instance of its specified type: " + model_name
|
|
|
|
|
|
+ // This is true by definition of is_nominal_instance
|
|
|
|
+ //if (bool_not(is_nominal_instance(model, model_name, type_name))):
|
|
|
|
+ // return "Element is not an instance of its specified type: " + model_name
|
|
|
|
|
|
if (is_edge(element)):
|
|
if (is_edge(element)):
|
|
src_model = reverseKeyLookup(model["model"], read_edge_src(element))
|
|
src_model = reverseKeyLookup(model["model"], read_edge_src(element))
|
|
@@ -146,7 +172,8 @@ String function conformance_scd(model : Element):
|
|
// First the incoming, so we are at B in the above figure
|
|
// First the incoming, so we are at B in the above figure
|
|
if (bool_not(dict_in(spo_cache, type_name))):
|
|
if (bool_not(dict_in(spo_cache, type_name))):
|
|
dict_add(spo_cache, type_name, selectPossibleOutgoing(metamodel, type_name, dict_keys(cardinalities)))
|
|
dict_add(spo_cache, type_name, selectPossibleOutgoing(metamodel, type_name, dict_keys(cardinalities)))
|
|
- check_list = spo_cache[type_name]
|
|
|
|
|
|
+
|
|
|
|
+ check_list = set_copy(spo_cache[type_name])
|
|
while (0 < list_len(check_list)):
|
|
while (0 < list_len(check_list)):
|
|
check_type = set_pop(check_list)
|
|
check_type = set_pop(check_list)
|
|
if (dict_in(cardinalities, check_type)):
|
|
if (dict_in(cardinalities, check_type)):
|
|
@@ -171,7 +198,8 @@ String function conformance_scd(model : Element):
|
|
// Identical, but for outgoing, and thus for A in the figure
|
|
// Identical, but for outgoing, and thus for A in the figure
|
|
if (bool_not(dict_in(spi_cache, type_name))):
|
|
if (bool_not(dict_in(spi_cache, type_name))):
|
|
dict_add(spi_cache, type_name, selectPossibleIncoming(metamodel, type_name, dict_keys(cardinalities)))
|
|
dict_add(spi_cache, type_name, selectPossibleIncoming(metamodel, type_name, dict_keys(cardinalities)))
|
|
- check_list = spi_cache[type_name]
|
|
|
|
|
|
+
|
|
|
|
+ check_list = set_copy(spi_cache[type_name])
|
|
while (0 < list_len(check_list)):
|
|
while (0 < list_len(check_list)):
|
|
check_type = set_pop(check_list)
|
|
check_type = set_pop(check_list)
|
|
if (dict_in(cardinalities, check_type)):
|
|
if (dict_in(cardinalities, check_type)):
|