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

SimpleClassDiagrams ProcessModel {
    SimpleAttribute String {
        name = "String"
    }
    SimpleAttribute MvCName {
        name = "MvCName"
        constraint = $
            String function constraint(model : Element, name : String):
                if (bool_not(is_physical_string(model["model"][name]))):
                    return "MvCName has no string value"!
                else:
                    return "OK"!
            $
    }

    Class Activity {
        name = "Activity"
    }
    Class Start : Activity {
        name = "Start"
        lower_cardinality = 1
        upper_cardinality = 1
    }
    Class Finish : Activity {
        name = "Finish"
        lower_cardinality = 1
    }
    Class Fork : Activity {
        name = "Fork"
    }
    Class Join : Activity {
        name = "Join"
    }
    Class Decision : Activity {
        name = "Decision"
        constraint = $
            String function constraint(model : Element, name : String):
                if (read_nr_out(allOutgoingAssociationInstances(model, name, "Next")) == 0):
                    return "OK"!
                else:
                    return "Decision node cannot have a normal 'Next' link"!
            $
    }

    Class Exec : Activity {
        name = "Exec"
        name : MvCName
    }

    Class Data {
        name = "Data"
        name : MvCName
        type : MvCName
    }

    Association Produces (Exec, Data) {
        name : String
        name = "Produces"
    }
    Association Consumes (Exec, Data) {
        name : String
        name = "Consumes"
    }
    Association Then (Decision, Activity) {
        name = "Then"
    }
    Association Else (Decision, Activity) {
        name = "Else"
    }
    Association Next (Activity, Activity) {
        name = "Next"
    }
}

export ProcessModel to models/ProcessModel
