import models/SimpleClassDiagrams as SimpleClassDiagrams
include "primitives.alh"

SimpleClassDiagrams CoreFormalism {
    Class String {
        $
            if (bool_not(is_physical_string(self))):
                return "String has no string value"!
            else:
                return "OK"!
        $
    }

    Class Permissions {
        $
            if (bool_not(is_physical_string(self))):
                return "Permissions has no string value"!
            else:
                return "OK"!
        $
    }

    Class Boolean {
        $
            if (bool_not(is_physical_boolean(self))):
                return "Boolean has no bool value"!
            else:
                return "OK"!
        $
    }

    Class Natural {
        $
            if (bool_not(is_physical_int(self))):
                return "Natural has no integer value"!
            elif (integer_lt(self, 0)):
                return "Natural has negative value"!
            else:
                return "OK"!
        $
    }

    Class User {
        name : String
        password : String
        admin : Boolean
    }

    Class Group {
        name : String
    }

    Association ownedBy (Group, User) {}
    Association belongsTo (User, Group) {}

    Class Model {
        name : String
        location : String
        permissions : Permissions
    }

    Association instanceOf (Model, Model) {}

    Association owner (Model, User) {
        target_lower_cardinality = 1
        target_upper_cardinality = 1
    }

    Association group (Model, Group) {
        target_lower_cardinality = 1
        target_upper_cardinality = 1
    }

    Class Transformation : Model {
        name : String
        location : String
    }

    Class ModelTransformation : Transformation {}

    Class ActionLanguage : Transformation {}

    Class ExternalTool : Transformation {}

    Class ManualTransformation : Transformation {}

    Association transformInput (Model, Transformation) {
        name : String
    }
    Association transformOutput (Transformation, Model) {
        name : String
    }

    Association tracability (Model, Model) {
        type : String
    }
}

export CoreFormalism to models/CoreFormalism
