core_formalism.mvc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import models/SimpleClassDiagrams as SimpleClassDiagrams
  2. include "primitives.alh"
  3. SimpleClassDiagrams CoreFormalism {
  4. SimpleAttribute String {
  5. constraint = $
  6. String function constraint(model : Element, name : String):
  7. if (bool_not(is_physical_string(model["model"][name]))):
  8. return "String has no string value"!
  9. else:
  10. return "OK"!
  11. $
  12. }
  13. SimpleAttribute Permissions {
  14. constraint = $
  15. String function constraint(model : Element, name : String):
  16. Element self
  17. self = model["model"][name]
  18. if (bool_not(is_physical_string(self))):
  19. return "Permissions has no string value"!
  20. if (bool_not(string_len(self) == 3)):
  21. return "Permissions string is not of correct length"!
  22. if (bool_or(cast_s2i(string_get(self, 0)) < 0, cast_s2i(string_get(self, 0)) > 2)):
  23. return "Owner permission is not in range [0, 2]"!
  24. if (bool_or(cast_s2i(string_get(self, 1)) < 0, cast_s2i(string_get(self, 1)) > 2)):
  25. return "Group permission is not in range [0, 2]"!
  26. if (bool_or(cast_s2i(string_get(self, 2)) < 0, cast_s2i(string_get(self, 2)) > 2)):
  27. return "Other permission is not in range [0, 2]"!
  28. return "OK"!
  29. $
  30. }
  31. SimpleAttribute Boolean {
  32. constraint = $
  33. String function constraint(model : Element, name : String):
  34. if (bool_not(is_physical_boolean(model["model"][name]))):
  35. return "Boolean has no bool value"!
  36. else:
  37. return "OK"!
  38. $
  39. }
  40. SimpleAttribute Natural {
  41. constraint = $
  42. String function constraint(model : Element, name : String):
  43. if (bool_not(is_physical_int(model["model"][name]))):
  44. return "Natural has no integer value"!
  45. elif (integer_lt(model["model"][name], 0)):
  46. return "Natural has negative value"!
  47. else:
  48. return "OK"!
  49. $
  50. }
  51. SimpleAttribute TypeMapping {
  52. constraint = $
  53. String function constraint(model : Element, name : String):
  54. Element self
  55. self = model["model"][name]
  56. if (has_value(self)):
  57. return "TypeMapping cannot have a value for root node!"!
  58. Element keys
  59. String key
  60. keys = dict_keys(self)
  61. while (read_nr_out(keys) > 0):
  62. key = set_pop(keys)
  63. if (bool_not(is_physical_string(key))):
  64. return ("Key on type mapping is not a string: " + cast_e2s(key))!
  65. elif (bool_not(is_physical_string(self[key]))):
  66. return ("Value on type mapping is not a string for key " + cast_e2s(key))!
  67. return "OK"!
  68. $
  69. }
  70. Class User {
  71. name : String
  72. password : String
  73. admin : Boolean
  74. }
  75. Class Group {
  76. name : String
  77. }
  78. Association ownedBy (Group, User) {}
  79. Association belongsTo (User, Group) {}
  80. Class Model {
  81. name : String
  82. location : String
  83. permissions : Permissions
  84. }
  85. Association instanceOf (Model, Model) {
  86. type_mapping : TypeMapping
  87. }
  88. Association owner (Model, User) {
  89. target_lower_cardinality = 1
  90. target_upper_cardinality = 1
  91. }
  92. Association group (Model, Group) {
  93. target_lower_cardinality = 1
  94. target_upper_cardinality = 1
  95. }
  96. Class Transformation : Model {}
  97. Class ModelTransformation : Transformation {}
  98. Class ActionLanguage : Transformation {}
  99. Class ExternalTool : Transformation {}
  100. Class ManualOperation : Transformation {}
  101. Association transformInput (Model, Transformation) {
  102. name : String
  103. }
  104. Association transformOutput (Transformation, Model) {
  105. name : String
  106. }
  107. Association tracability (Model, Model) {
  108. type : String
  109. }
  110. Association semantics (instanceOf, ActionLanguage) {}
  111. Class Service {
  112. name : String
  113. port : String
  114. }
  115. }
  116. export CoreFormalism to models/CoreFormalism