|
@@ -18,7 +18,7 @@ Boolean function is_nominal_instance(model : Element, instance : String, type :
|
|
|
return False
|
|
|
|
|
|
if (bool_not(dict_in_node(model["type_mapping"], model["model"][instance]))):
|
|
|
- // Doesn't even have a type
|
|
|
+ // doesn't even have a type
|
|
|
return False
|
|
|
|
|
|
return is_nominal_subtype(model["metamodel"], reverseKeyLookup(model["metamodel"]["model"], dict_read_node(model["type_mapping"], model["model"][instance])), type)
|
|
@@ -109,30 +109,24 @@ String function conformance_scd(model : Element):
|
|
|
log("Check " + model_name)
|
|
|
element = model["model"][model_name]
|
|
|
|
|
|
- log("1")
|
|
|
if (bool_not(dict_in_node(typing, element))):
|
|
|
return "Model has no type specified: " + model_name
|
|
|
|
|
|
- log("2")
|
|
|
if (bool_not(set_in_node(metamodel["model"], dict_read_node(typing, element)))):
|
|
|
return "Type of element not in specified metamodel: " + model_name
|
|
|
|
|
|
- log("3")
|
|
|
if (bool_not(is_nominal_instance(model, model_name, reverseKeyLookup(metamodel["model"], dict_read_node(typing, element))))):
|
|
|
return "Element is not an instance of its specified type: " + model_name
|
|
|
|
|
|
- log("4")
|
|
|
if (is_edge(element)):
|
|
|
src_model = reverseKeyLookup(model["model"], read_edge_src(element))
|
|
|
dst_model = reverseKeyLookup(model["model"], read_edge_dst(element))
|
|
|
src_metamodel = reverseKeyLookup(metamodel["model"], read_edge_src(dict_read_node(typing, element)))
|
|
|
dst_metamodel = reverseKeyLookup(metamodel["model"], read_edge_dst(dict_read_node(typing, element)))
|
|
|
|
|
|
- log("5")
|
|
|
if (bool_not(is_nominal_instance(model, src_model, src_metamodel))):
|
|
|
return "Source of model edge not typed by source of type: " + model_name
|
|
|
|
|
|
- log("6")
|
|
|
if (bool_not(is_nominal_instance(model, dst_model, dst_metamodel))):
|
|
|
return "Destination of model edge not typed by source of type: " + model_name
|
|
|
|
|
@@ -142,41 +136,39 @@ String function conformance_scd(model : Element):
|
|
|
// A ---------------------> B
|
|
|
//
|
|
|
// First the incoming, so we are at B in the above figure
|
|
|
- log("7")
|
|
|
check_list = selectPossibleOutgoing(model, model_name, dict_keys(cardinalities))
|
|
|
while (0 < list_len(check_list)):
|
|
|
check_type = set_pop(check_list)
|
|
|
if (dict_in(cardinalities, check_type)):
|
|
|
// Cardinalities defined for this association, so check them
|
|
|
- instances = list_len(allOutgoingAssociationInstances(model, model_name, check_type))
|
|
|
- if (dict_in(cardinalities[check_type], "tlc")):
|
|
|
- // A lower cardinality was defined at the target
|
|
|
- if (integer_gt(cardinalities[check_type]["tlc"], instances)):
|
|
|
- return "Lower cardinality violation for outgoing edge at " + model_name
|
|
|
- if (dict_in(cardinalities[check_type], "tuc")):
|
|
|
- // An upper cardinality was defined at the target
|
|
|
- if (integer_lt(cardinalities[check_type]["tuc"], instances)):
|
|
|
- return "Upper cardinality violation for outgoing edge at " + model_name
|
|
|
+ if (bool_or(dict_in(cardinalities[check_type], "tlc"), dict_in(cardinalities[check_type], "tuc"))):
|
|
|
+ instances = list_len(allOutgoingAssociationInstances(model, model_name, check_type))
|
|
|
+ if (dict_in(cardinalities[check_type], "tlc")):
|
|
|
+ // A lower cardinality was defined at the target
|
|
|
+ if (integer_gt(cardinalities[check_type]["tlc"], instances)):
|
|
|
+ return "Lower cardinality violation for outgoing edge at " + model_name
|
|
|
+ if (dict_in(cardinalities[check_type], "tuc")):
|
|
|
+ // An upper cardinality was defined at the target
|
|
|
+ if (integer_lt(cardinalities[check_type]["tuc"], instances)):
|
|
|
+ return "Upper cardinality violation for outgoing edge at " + model_name
|
|
|
|
|
|
// Identical, but for outgoing, and thus for A in the figure
|
|
|
- log("8")
|
|
|
check_list = selectPossibleIncoming(model, model_name, dict_keys(cardinalities))
|
|
|
while (0 < list_len(check_list)):
|
|
|
- log("LOOP")
|
|
|
check_type = set_pop(check_list)
|
|
|
if (dict_in(cardinalities, check_type)):
|
|
|
// Cardinalities defined for this association, so check them
|
|
|
- instances = list_len(allIncomingAssociationInstances(model, model_name, check_type))
|
|
|
- if (dict_in(cardinalities[check_type], "slc")):
|
|
|
- // A lower cardinality was defined at the source
|
|
|
- if (integer_gt(cardinalities[check_type]["slc"], instances)):
|
|
|
- return "Lower cardinality violation for incoming edge at " + model_name
|
|
|
- if (dict_in(cardinalities[check_type], "suc")):
|
|
|
- // An upper cardinality was defined at the source
|
|
|
- if (integer_lt(cardinalities[check_type]["suc"], instances)):
|
|
|
- return "Upper cardinality violation for incoming edge at " + model_name
|
|
|
-
|
|
|
- log("10")
|
|
|
+ if (bool_or(dict_in(cardinalities[check_type], "slc"), dict_in(cardinalities[check_type], "suc"))):
|
|
|
+ instances = list_len(allIncomingAssociationInstances(model, model_name, check_type))
|
|
|
+ if (dict_in(cardinalities[check_type], "slc")):
|
|
|
+ // A lower cardinality was defined at the source
|
|
|
+ if (integer_gt(cardinalities[check_type]["slc"], instances)):
|
|
|
+ return "Lower cardinality violation for incoming edge at " + model_name
|
|
|
+ if (dict_in(cardinalities[check_type], "suc")):
|
|
|
+ // An upper cardinality was defined at the source
|
|
|
+ if (integer_lt(cardinalities[check_type]["suc"], instances)):
|
|
|
+ return "Upper cardinality violation for incoming edge at " + model_name
|
|
|
+
|
|
|
Element constraint_function
|
|
|
constraint_function = read_attribute(metamodel, reverseKeyLookup(metamodel["model"], dict_read_node(typing, element)), "constraint")
|
|
|
if (element_neq(constraint_function, read_root())):
|