|
@@ -1,6 +1,7 @@
|
|
|
include "primitives.alh"
|
|
|
include "object_operations.alh"
|
|
|
include "modelling.alh"
|
|
|
+include "library.alh"
|
|
|
|
|
|
Boolean function main(model : Element):
|
|
|
// Contains three types of models: model, metamodel, and type_mapping.
|
|
@@ -10,13 +11,10 @@ Boolean function main(model : Element):
|
|
|
// Thus only the check for multiple inheritance is being done, which checks for attributes.
|
|
|
// A full example is given in the Modelverse's internal conformance relation.
|
|
|
|
|
|
- log("Performing conformance check!")
|
|
|
-
|
|
|
// Find all instances of classes
|
|
|
// First, find the class types
|
|
|
Element classes
|
|
|
classes = allInstances(model, "metamodel/Class")
|
|
|
- log("Got classes: " + set_to_string(classes))
|
|
|
|
|
|
Element links
|
|
|
String link
|
|
@@ -28,23 +26,58 @@ Boolean function main(model : Element):
|
|
|
instances = allInstances(model, "type_mapping/Instance")
|
|
|
while (set_len(instances) > 0):
|
|
|
instance = set_pop(instances)
|
|
|
- log("Found instance: " + instance)
|
|
|
- log(" Connects to: " + cast_string(set_pop(allAssociationDestinations(model, instance, "type_mapping/TypeLink"))))
|
|
|
- log("Association connects: " + instance + " --> " + cast_string(set_pop(allAssociationDestinations(model, instance, "type_mapping/TypeLink"))))
|
|
|
- //dict_add(type_mapping, "model/" + string_replace(readAssociationSource(model, link), "type_mapping/instance_", ""), "metamodel/" + string_replace(readAssociationDestination(model, link), "type_mapping/type_", ""))
|
|
|
+ dict_add(type_mapping, "model/" + string_replace(instance, "type_mapping/instance_", ""), "metamodel/" + string_replace(set_pop(allAssociationDestinations(model, instance, "type_mapping/TypeLink")), "type_mapping/type_", ""))
|
|
|
|
|
|
- log("Found type mapping: " + dict_to_string(type_mapping))
|
|
|
-
|
|
|
// Check if each attribute is there, and satisfies the constraints
|
|
|
instances = dict_keys(type_mapping)
|
|
|
while (set_len(instances) > 0):
|
|
|
instance = set_pop(instances)
|
|
|
- log("Found type: " + read_type(model, type_mapping[instance]))
|
|
|
if (read_type(model, type_mapping[instance]) == "metamodel/Class"):
|
|
|
// Got an instance of a Class
|
|
|
- log("Got a class instance: " + instance)
|
|
|
+ String type
|
|
|
+ Element inherits_from
|
|
|
+ type = type_mapping[instance]
|
|
|
+
|
|
|
+ Element outgoing_links
|
|
|
+ String outgoing_link
|
|
|
+ Element attrs
|
|
|
+
|
|
|
+ outgoing_links = allOutgoingAssociationInstances(model, instance, "")
|
|
|
+ attrs = dict_create()
|
|
|
+ while (set_len(outgoing_links) > 0):
|
|
|
+ outgoing_link = set_pop(outgoing_links)
|
|
|
+ String name
|
|
|
+ if (dict_in(type_mapping, outgoing_link)):
|
|
|
+ name = read_attribute(model, type_mapping[outgoing_link], "name")
|
|
|
+ dict_add(attrs, name, model["model"][readAssociationDestination(model, outgoing_link)])
|
|
|
|
|
|
// Fetch a list of attributes that should be defined
|
|
|
// TODO
|
|
|
+ inherits_from = allAssociationDestinations(model, type, "metamodel/Inheritance")
|
|
|
+
|
|
|
+ String superclass
|
|
|
+ Element defining_attributes
|
|
|
+ Element last_found
|
|
|
+
|
|
|
+ last_found = dict_create()
|
|
|
+ while (set_len(inherits_from) > 0):
|
|
|
+ superclass = set_pop(inherits_from)
|
|
|
+ defining_attributes = getInstantiatableAttributes(model, superclass, "metamodel/AttributeLink")
|
|
|
+ dict_update(last_found, defining_attributes)
|
|
|
+
|
|
|
+ Element keys
|
|
|
+ String attr
|
|
|
+ Element constraint
|
|
|
+ String result
|
|
|
+ keys = dict_keys(attrs)
|
|
|
+ while (set_len(keys) > 0):
|
|
|
+ attr = set_pop(keys)
|
|
|
+ constraint = get_func_AL_model(import_node(read_attribute(model, last_found[attr], "constraint")))
|
|
|
+ result = constraint(attrs[attr])
|
|
|
+
|
|
|
+ if (result != "OK"):
|
|
|
+ log("Conformance not OK: " + result)
|
|
|
+ return False!
|
|
|
|
|
|
+ log("Conformance OK")
|
|
|
return True!
|