expressir 0.2.5-x64-mingw32 → 0.2.7-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (526) hide show
  1. checksums.yaml +5 -5
  2. data/.cross_rubies +30 -0
  3. data/.github/workflows/rake.yml +45 -46
  4. data/.github/workflows/release.yml +84 -75
  5. data/.gitignore +17 -15
  6. data/.gitmodules +3 -3
  7. data/.rspec +2 -2
  8. data/.rubocop.yml +508 -508
  9. data/Gemfile +4 -6
  10. data/README.adoc +147 -147
  11. data/Rakefile +11 -17
  12. data/bin/console +12 -12
  13. data/bin/rspec +29 -29
  14. data/bin/setup +8 -8
  15. data/demo.rb +18 -18
  16. data/docs/development.md +90 -90
  17. data/exe/expressir +20 -20
  18. data/exe/generate-parser +47 -47
  19. data/expressir.gemspec +43 -40
  20. data/lib/expressir/cli/ui.rb +36 -36
  21. data/lib/expressir/cli.rb +27 -27
  22. data/lib/expressir/config.rb +23 -23
  23. data/lib/expressir/express/aggregate_dimension.rb +38 -38
  24. data/lib/expressir/express/attribute.rb +15 -15
  25. data/lib/expressir/express/comment.rb +7 -7
  26. data/lib/expressir/express/defined_type.rb +36 -36
  27. data/lib/expressir/express/derived.rb +65 -65
  28. data/lib/expressir/express/derived_aggregate.rb +43 -43
  29. data/lib/expressir/express/entity.rb +137 -137
  30. data/lib/expressir/express/explicit.rb +70 -70
  31. data/lib/expressir/express/explicit_aggregate.rb +46 -46
  32. data/lib/expressir/express/explicit_or_derived.rb +16 -16
  33. data/lib/expressir/express/global_rule.rb +44 -44
  34. data/lib/expressir/express/interface_specification.rb +51 -51
  35. data/lib/expressir/express/interfaced_item.rb +38 -38
  36. data/lib/expressir/express/inverse.rb +46 -46
  37. data/lib/expressir/express/inverse_aggregate.rb +37 -37
  38. data/lib/expressir/express/model_element.rb +7 -7
  39. data/lib/expressir/express/named_type.rb +19 -19
  40. data/lib/expressir/express/remark.rb +8 -8
  41. data/lib/expressir/express/repository.rb +306 -306
  42. data/lib/expressir/express/schema_definition.rb +96 -96
  43. data/lib/expressir/express/subtype_constraint.rb +14 -14
  44. data/lib/expressir/express/type.rb +26 -26
  45. data/lib/expressir/express/type_aggregate.rb +42 -42
  46. data/lib/expressir/express/type_enum.rb +29 -29
  47. data/lib/expressir/express/type_parser.rb +45 -45
  48. data/lib/expressir/express/type_select.rb +82 -82
  49. data/lib/expressir/express/unique_rule.rb +35 -35
  50. data/lib/expressir/express/where_rule.rb +32 -32
  51. data/lib/expressir/express.rb +11 -11
  52. data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
  53. data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
  54. data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
  55. data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
  56. data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
  57. data/lib/expressir/express_exp/formatter.rb +1449 -1449
  58. data/lib/expressir/express_exp/parser.rb +40 -35
  59. data/lib/expressir/express_exp/visitor.rb +2463 -2450
  60. data/lib/expressir/express_parser.rb +30 -30
  61. data/lib/expressir/model/attribute.rb +26 -26
  62. data/lib/expressir/model/constant.rb +16 -16
  63. data/lib/expressir/model/entity.rb +45 -45
  64. data/lib/expressir/model/enumeration_item.rb +10 -10
  65. data/lib/expressir/model/expressions/aggregate_initializer.rb +12 -12
  66. data/lib/expressir/model/expressions/aggregate_item.rb +14 -14
  67. data/lib/expressir/model/expressions/attribute_reference.rb +14 -14
  68. data/lib/expressir/model/expressions/binary_expression.rb +39 -39
  69. data/lib/expressir/model/expressions/call.rb +14 -14
  70. data/lib/expressir/model/expressions/entity_constructor.rb +14 -14
  71. data/lib/expressir/model/expressions/group_reference.rb +14 -14
  72. data/lib/expressir/model/expressions/index_reference.rb +16 -16
  73. data/lib/expressir/model/expressions/interval.rb +20 -20
  74. data/lib/expressir/model/expressions/query_expression.rb +25 -25
  75. data/lib/expressir/model/expressions/simple_reference.rb +12 -12
  76. data/lib/expressir/model/expressions/unary_expression.rb +18 -18
  77. data/lib/expressir/model/function.rb +61 -61
  78. data/lib/expressir/model/identifier.rb +9 -8
  79. data/lib/expressir/model/interface.rb +17 -17
  80. data/lib/expressir/model/literals/binary.rb +12 -12
  81. data/lib/expressir/model/literals/integer.rb +12 -12
  82. data/lib/expressir/model/literals/logical.rb +16 -16
  83. data/lib/expressir/model/literals/real.rb +12 -12
  84. data/lib/expressir/model/literals/string.rb +14 -14
  85. data/lib/expressir/model/parameter.rb +16 -16
  86. data/lib/expressir/model/procedure.rb +59 -59
  87. data/lib/expressir/model/renamed_ref.rb +12 -12
  88. data/lib/expressir/model/repository.rb +18 -18
  89. data/lib/expressir/model/rule.rb +61 -61
  90. data/lib/expressir/model/schema.rb +66 -66
  91. data/lib/expressir/model/scope.rb +16 -16
  92. data/lib/expressir/model/statements/alias.rb +25 -25
  93. data/lib/expressir/model/statements/assignment.rb +14 -14
  94. data/lib/expressir/model/statements/call.rb +14 -14
  95. data/lib/expressir/model/statements/case.rb +16 -16
  96. data/lib/expressir/model/statements/case_action.rb +14 -14
  97. data/lib/expressir/model/statements/compound.rb +12 -12
  98. data/lib/expressir/model/statements/escape.rb +7 -7
  99. data/lib/expressir/model/statements/if.rb +16 -16
  100. data/lib/expressir/model/statements/null.rb +7 -7
  101. data/lib/expressir/model/statements/repeat.rb +33 -33
  102. data/lib/expressir/model/statements/return.rb +12 -12
  103. data/lib/expressir/model/statements/skip.rb +7 -7
  104. data/lib/expressir/model/subtype_constraint.rb +26 -26
  105. data/lib/expressir/model/type.rb +23 -23
  106. data/lib/expressir/model/types/aggregate.rb +16 -16
  107. data/lib/expressir/model/types/array.rb +20 -20
  108. data/lib/expressir/model/types/bag.rb +16 -16
  109. data/lib/expressir/model/types/binary.rb +14 -14
  110. data/lib/expressir/model/types/boolean.rb +7 -7
  111. data/lib/expressir/model/types/enumeration.rb +18 -18
  112. data/lib/expressir/model/types/generic.rb +12 -12
  113. data/lib/expressir/model/types/generic_entity.rb +12 -12
  114. data/lib/expressir/model/types/integer.rb +7 -7
  115. data/lib/expressir/model/types/list.rb +18 -18
  116. data/lib/expressir/model/types/logical.rb +7 -7
  117. data/lib/expressir/model/types/number.rb +7 -7
  118. data/lib/expressir/model/types/real.rb +12 -12
  119. data/lib/expressir/model/types/select.rb +20 -20
  120. data/lib/expressir/model/types/set.rb +16 -16
  121. data/lib/expressir/model/types/string.rb +14 -14
  122. data/lib/expressir/model/unique.rb +14 -14
  123. data/lib/expressir/model/variable.rb +16 -16
  124. data/lib/expressir/model/where.rb +14 -14
  125. data/lib/expressir/model.rb +64 -64
  126. data/lib/expressir/parser/owl_parser.rb +8 -8
  127. data/lib/expressir/parser.rb +6 -6
  128. data/lib/expressir/version.rb +3 -3
  129. data/lib/expressir.rb +21 -21
  130. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +9589 -9589
  131. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +36619 -36619
  132. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +13293 -13293
  133. data/original/examples/employment/eclipse/.project +17 -17
  134. data/original/examples/employment/eclipse/Express/employment_schema.exp +33 -33
  135. data/original/examples/employment/eclipse/Express/employment_schema.xmi +77 -77
  136. data/original/examples/employment/eclipse/Express/employment_schema.xml +92 -92
  137. data/original/examples/employment/eclipse/Models/Employment.uml +4 -4
  138. data/original/examples/employment/eclipse/Models/Employment.umldi +240 -240
  139. data/original/examples/employment/eclipse/readme.txt +6 -6
  140. data/original/examples/employment/employment_schema.exp +33 -33
  141. data/original/examples/employment/employment_schema.rb +232 -232
  142. data/original/examples/employment/employment_schema.xml +92 -92
  143. data/original/examples/employment/employment_schema___module.rb +46 -46
  144. data/original/examples/employment/employment_schema___p28attr.rb +126 -126
  145. data/original/examples/employment/employment_schema___p28inst.rb +26 -26
  146. data/original/examples/employment/example_employment_data.xml +1 -1
  147. data/original/examples/employment/example_employment_data_copy.xml +1 -1
  148. data/original/examples/employment/example_employment_reader.rb +30 -30
  149. data/original/examples/employment/example_employment_writer.rb +51 -51
  150. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +3710 -3710
  151. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +35880 -35880
  152. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +15357 -15357
  153. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +9467 -9467
  154. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +8404 -8404
  155. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +43147 -43147
  156. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +18341 -18341
  157. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +11631 -11631
  158. data/original/examples/syntax/remark.exp +146 -145
  159. data/original/examples/syntax/remark_formatted.exp +174 -173
  160. data/original/examples/syntax/syntax.exp +311 -310
  161. data/original/examples/syntax/syntax_formatted.exp +1190 -1186
  162. data/original/exp2ruby.rb +525 -525
  163. data/original/expsm.rb +34 -34
  164. data/original/mapping_owl.rb +1018 -1018
  165. data/original/mapping_sysml.rb +2281 -2281
  166. data/original/mapping_uml2.rb +598 -598
  167. data/original/mapping_uml2_eclipse.rb +433 -433
  168. data/original/reeper.rb +134 -134
  169. data/rakelib/cross-ruby.rake +308 -0
  170. data/spec/acceptance/express_to_owl_spec.rb +18 -18
  171. data/spec/acceptance/version_spec.rb +12 -12
  172. data/spec/expressir/express/repository_spec.rb +25 -25
  173. data/spec/expressir/express_exp/ap233_spec.rb +22 -22
  174. data/spec/expressir/express_exp/format_remark_spec.rb +28 -28
  175. data/spec/expressir/express_exp/format_syntax_spec.rb +28 -28
  176. data/spec/expressir/express_exp/parse_remark_spec.rb +346 -345
  177. data/spec/expressir/express_exp/parse_syntax_spec.rb +3003 -2998
  178. data/spec/expressir/model/find_spec.rb +110 -110
  179. data/spec/expressr_spec.rb +5 -5
  180. data/spec/spec_helper.rb +17 -17
  181. data/spec/support/console_helper.rb +29 -29
  182. metadata +32 -370
  183. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +0 -118
  184. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +0 -637
  185. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -984
  186. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +0 -652
  187. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -990
  188. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +0 -652
  189. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -990
  190. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +0 -652
  191. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -990
  192. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/Info.plist +0 -26
  193. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/antlrcpp_ios.h +0 -17
  194. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +0 -3024
  195. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  196. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  197. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +0 -76
  198. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +0 -80
  199. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +0 -80
  200. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.cpp +0 -10
  201. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.h +0 -167
  202. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.cpp +0 -10
  203. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.h +0 -121
  204. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -34
  205. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +0 -27
  206. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +0 -155
  207. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +0 -69
  208. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.cpp +0 -61
  209. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.h +0 -59
  210. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.cpp +0 -25
  211. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.h +0 -36
  212. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.cpp +0 -414
  213. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.h +0 -200
  214. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.cpp +0 -11
  215. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.h +0 -37
  216. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +0 -195
  217. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.h +0 -158
  218. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +0 -39
  219. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +0 -74
  220. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.cpp +0 -78
  221. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.h +0 -79
  222. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp +0 -15
  223. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.h +0 -35
  224. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +0 -333
  225. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.h +0 -466
  226. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp +0 -84
  227. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.h +0 -80
  228. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +0 -64
  229. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +0 -99
  230. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +0 -51
  231. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +0 -32
  232. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.cpp +0 -18
  233. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.h +0 -24
  234. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.cpp +0 -12
  235. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -218
  236. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.cpp +0 -19
  237. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.h +0 -45
  238. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -295
  239. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -196
  240. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -75
  241. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +0 -52
  242. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.cpp +0 -36
  243. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.h +0 -31
  244. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +0 -92
  245. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +0 -88
  246. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.cpp +0 -46
  247. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.h +0 -42
  248. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +0 -648
  249. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -467
  250. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +0 -306
  251. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +0 -179
  252. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +0 -141
  253. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +0 -147
  254. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +0 -53
  255. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.h +0 -38
  256. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -66
  257. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.h +0 -98
  258. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +0 -167
  259. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +0 -164
  260. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +0 -143
  261. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +0 -137
  262. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.cpp +0 -27
  263. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.h +0 -32
  264. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +0 -53
  265. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.h +0 -155
  266. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.cpp +0 -9
  267. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -92
  268. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenFactory.h +0 -30
  269. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.cpp +0 -9
  270. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +0 -85
  271. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.cpp +0 -11
  272. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.h +0 -137
  273. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +0 -425
  274. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +0 -293
  275. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +0 -211
  276. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +0 -123
  277. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp +0 -270
  278. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.h +0 -115
  279. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +0 -104
  280. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +0 -193
  281. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.cpp +0 -9
  282. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.h +0 -23
  283. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +0 -137
  284. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +0 -167
  285. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +0 -209
  286. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +0 -112
  287. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +0 -113
  288. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +0 -148
  289. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +0 -228
  290. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +0 -110
  291. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +0 -64
  292. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +0 -50
  293. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +0 -758
  294. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +0 -85
  295. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
  296. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
  297. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +0 -63
  298. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +0 -87
  299. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +0 -72
  300. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +0 -133
  301. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNType.h +0 -20
  302. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
  303. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
  304. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +0 -33
  305. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +0 -33
  306. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.cpp +0 -16
  307. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.h +0 -68
  308. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +0 -82
  309. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +0 -43
  310. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +0 -31
  311. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +0 -30
  312. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
  313. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +0 -22
  314. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
  315. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +0 -21
  316. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
  317. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +0 -24
  318. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
  319. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +0 -21
  320. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.cpp +0 -14
  321. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.h +0 -47
  322. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.cpp +0 -14
  323. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.h +0 -70
  324. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.cpp +0 -25
  325. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +0 -227
  326. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -17
  327. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +0 -30
  328. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
  329. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
  330. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +0 -35
  331. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +0 -39
  332. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.cpp +0 -15
  333. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.h +0 -43
  334. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +0 -158
  335. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +0 -109
  336. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +0 -84
  337. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +0 -44
  338. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +0 -628
  339. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +0 -210
  340. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +0 -9
  341. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +0 -66
  342. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +0 -107
  343. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +0 -115
  344. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +0 -55
  345. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +0 -55
  346. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +0 -63
  347. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +0 -62
  348. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +0 -87
  349. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +0 -63
  350. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +0 -82
  351. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +0 -56
  352. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +0 -61
  353. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +0 -47
  354. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +0 -57
  355. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +0 -47
  356. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +0 -57
  357. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +0 -56
  358. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +0 -61
  359. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +0 -47
  360. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +0 -55
  361. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +0 -56
  362. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +0 -55
  363. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.cpp +0 -16
  364. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.h +0 -42
  365. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
  366. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +0 -22
  367. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
  368. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +0 -27
  369. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +0 -25
  370. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +0 -12
  371. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +0 -20
  372. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.cpp +0 -102
  373. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.h +0 -102
  374. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +0 -1366
  375. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +0 -904
  376. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
  377. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +0 -25
  378. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
  379. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +0 -22
  380. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +0 -32
  381. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +0 -29
  382. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +0 -17
  383. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +0 -62
  384. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +0 -34
  385. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +0 -39
  386. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +0 -662
  387. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +0 -254
  388. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +0 -201
  389. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +0 -436
  390. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +0 -179
  391. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +0 -60
  392. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +0 -30
  393. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +0 -29
  394. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
  395. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +0 -25
  396. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
  397. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +0 -25
  398. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +0 -37
  399. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +0 -40
  400. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +0 -377
  401. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +0 -222
  402. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +0 -32
  403. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +0 -30
  404. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +0 -81
  405. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +0 -36
  406. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
  407. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +0 -21
  408. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
  409. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +0 -35
  410. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +0 -19
  411. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +0 -21
  412. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
  413. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +0 -21
  414. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +0 -44
  415. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +0 -76
  416. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +0 -25
  417. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +0 -25
  418. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +0 -127
  419. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +0 -91
  420. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +0 -67
  421. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +0 -32
  422. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +0 -100
  423. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +0 -144
  424. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +0 -20
  425. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +0 -23
  426. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +0 -124
  427. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +0 -31
  428. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +0 -89
  429. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +0 -84
  430. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +0 -521
  431. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +0 -198
  432. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +0 -134
  433. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +0 -76
  434. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.cpp +0 -4
  435. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.h +0 -21
  436. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -13
  437. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +0 -170
  438. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +0 -43
  439. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +0 -110
  440. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +0 -76
  441. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +0 -248
  442. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +0 -78
  443. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -163
  444. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +0 -36
  445. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +0 -54
  446. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
  447. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
  448. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +0 -128
  449. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
  450. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +0 -19
  451. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +0 -23
  452. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +0 -33
  453. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +0 -71
  454. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.h +0 -53
  455. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -15
  456. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +0 -102
  457. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.cpp +0 -9
  458. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.h +0 -39
  459. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeProperty.h +0 -50
  460. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.cpp +0 -9
  461. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +0 -57
  462. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +0 -49
  463. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +0 -31
  464. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
  465. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +0 -32
  466. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +0 -57
  467. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +0 -33
  468. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +0 -241
  469. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.h +0 -78
  470. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.cpp +0 -9
  471. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.h +0 -44
  472. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.cpp +0 -69
  473. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h +0 -132
  474. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +0 -64
  475. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h +0 -105
  476. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +0 -371
  477. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h +0 -185
  478. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp +0 -77
  479. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.h +0 -117
  480. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.cpp +0 -39
  481. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h +0 -86
  482. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.cpp +0 -28
  483. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h +0 -51
  484. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp +0 -36
  485. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.h +0 -80
  486. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +0 -154
  487. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.h +0 -86
  488. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.cpp +0 -31
  489. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.h +0 -40
  490. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +0 -173
  491. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.g4 +0 -64
  492. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +0 -56
  493. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.tokens +0 -12
  494. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.cpp +0 -13
  495. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.h +0 -22
  496. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.cpp +0 -20
  497. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.h +0 -27
  498. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +0 -30
  499. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.h +0 -26
  500. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.cpp +0 -20
  501. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.h +0 -25
  502. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +0 -33
  503. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.h +0 -26
  504. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.cpp +0 -23
  505. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.h +0 -23
  506. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.cpp +0 -24
  507. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.h +0 -23
  508. data/ext/express-parser/antlrgen/Express.interp +0 -532
  509. data/ext/express-parser/antlrgen/Express.tokens +0 -190
  510. data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +0 -7
  511. data/ext/express-parser/antlrgen/ExpressBaseListener.h +0 -623
  512. data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +0 -7
  513. data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +0 -816
  514. data/ext/express-parser/antlrgen/ExpressLexer.cpp +0 -1169
  515. data/ext/express-parser/antlrgen/ExpressLexer.h +0 -85
  516. data/ext/express-parser/antlrgen/ExpressLexer.interp +0 -534
  517. data/ext/express-parser/antlrgen/ExpressLexer.tokens +0 -190
  518. data/ext/express-parser/antlrgen/ExpressListener.cpp +0 -7
  519. data/ext/express-parser/antlrgen/ExpressListener.h +0 -616
  520. data/ext/express-parser/antlrgen/ExpressParser.cpp +0 -17284
  521. data/ext/express-parser/antlrgen/ExpressParser.h +0 -3696
  522. data/ext/express-parser/antlrgen/ExpressVisitor.cpp +0 -7
  523. data/ext/express-parser/antlrgen/ExpressVisitor.h +0 -422
  524. data/ext/express-parser/express_parser.cpp +0 -17931
  525. data/ext/express-parser/extconf.rb +0 -34
  526. data/lib/express_parser.so +0 -0
@@ -1,2281 +1,2281 @@
1
- require 'erb'
2
- require 'uuid'
3
- require 'nokogiri'
4
- include Nokogiri
5
-
6
- # EXPRESS to SysML Mapping
7
- # Version 0.5
8
- #
9
- # This function navigates the EXPRESS STEPMod Model Ruby Classes
10
- # and performs a structural EXPRESS-to-SysML (1.4) mapping using Ruby ERB templates.
11
- # The output is in XMI 2.1 or 2.5 syntax in a file named <schema>.xmi if one schema input and 'Model.xmi' if more than one schema input.
12
- #
13
- # Real, Number, Integer, Boolean, String -> New Primitive Type
14
- # Binary, Logical -> New PrimitiveType
15
- # Schema -> Package
16
- # Entity (subtype of) -> Class (Generalization) + Block stereotype
17
- # Select Type -> Class & Generalization + Block/value and <<Auxillary>> stereotype
18
- # Agg Type -> Collapsed into attribute if just used, converted into class with elements if part of aggregation or select type
19
- # Enum Type -> Enumeration and EnumerationLiteral
20
- # Explicit Attribute (Optional) Primitive or Enum -> Property owned by Class (with lower)
21
- # Explicit Attribute (Optional) Entity -> Property owned by Class (with lower) plus Association owning other end property
22
- # Explicit Attribute 1-D SET, BAG, LIST of Select or Entity -> Property owned by Class (with lower)
23
- # plus Association owning other end property and multiplicity, unique and ordered set
24
- # Explicit Attribute 1-D SET, BAG, LIST of Primitive or Enum -> Property owned by Class and multiplicity, unique and ordered set
25
- # Higher level aggregations create intermediary blocks
26
- # Explicit Attribute of Entity/Select/Builtin Redeclaration (Renamed) -> Property with (new) name that redefines inherited Property
27
- # Inverse Attribute -> Association end adjustment
28
- # Inverse Attribute Redeclaration (Renamed) -> Property with (new) name that redefines inherited Property
29
- # USE or REFERENCE (even with named items) -> UML PackageImport between Packages
30
- #
31
- #######################################################################################
32
-
33
- def get_uuid(id)
34
- if $uuidsRequired
35
- uuidmap = $uuidxml.xpath('//uuidmap[@id="' + id + '"]').first
36
- if !uuidmap.nil?
37
- $olduuids.delete uuidmap
38
- return ' xmi:uuid="' + uuidmap.attributes["uuid"].to_s.strip + '"'
39
- else
40
- theUUID = $uuid.generate
41
- uuidtext = theUUID.to_s.strip
42
- uuidmap = Nokogiri::XML::Node.new("uuidmap", $uuidxml)
43
- uuidmap['id'] = id
44
- uuidmap['uuid'] = theUUID
45
- $uuidxml.root.add_child uuidmap
46
- return ' xmi:uuid="' + theUUID + '"'
47
- end
48
- else
49
- return ""
50
- end
51
- end
52
-
53
- def get_where(id,rule)
54
- if !$wherexml.nil?
55
- wheremap = $wherexml.xpath('//wheremap[@id="' + id + '"]').first
56
- if !wheremap.nil?
57
- return wheremap.at("OCL").inner_html
58
- else
59
- wheremap = Nokogiri::XML::Node.new("wheremap", $wherexml)
60
- wheremap['id'] = id
61
- express = Nokogiri::XML::Node.new("EXPRESS", $wherexml)
62
- express.content = rule
63
- wheremap.add_child express
64
- ocl = Nokogiri::XML::Node.new("OCL", $wherexml)
65
- wheremap.add_child ocl
66
- $wherexml.root.add_child wheremap
67
- return ""
68
- end
69
- else
70
- return ""
71
- end
72
- end
73
-
74
- def put_ops(name, file)
75
- # operation template
76
- operation_template = %{<ownedOperation xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Operation">
77
- <name><%= op_name %></name>
78
- <ownedRule xmi:id="<%= xmiid %>-body"<%= get_uuid(xmiid+'-body') %> xmi:type="uml:Constraint">
79
- <specification xmi:id="<%= xmiid %>-spec"<%= get_uuid(xmiid+'-spec') %> xmi:type="uml:OpaqueExpression">
80
- <body><%= op_ocl %></body>
81
- <language>OCL2.0</language>
82
- </specification>
83
- </ownedRule>}
84
-
85
- parameter_template = %{<ownedParameter xmi:id="<%= par_xmiid %>"<%= get_uuid(par_xmiid) %> xmi:type="uml:Parameter">
86
- <name><%= par_name %></name>
87
- <type xmi:idref="<%= par_type %>"/>
88
- </ownedParameter>}
89
-
90
- return_template = %{<ownedParameter xmi:id="<%= xmiid %>-return"<%= get_uuid(xmiid+'-return') %> xmi:type="uml:Parameter">
91
- <direction>return</direction>
92
- <type xmi:idref="<%= ret_type %>"/>
93
- </ownedParameter>}
94
-
95
- operation_end = %{</ownedOperation>}
96
-
97
- if !$opsxml.nil?
98
- ops = $opsxml.xpath('//operation[@for="' + name + '"]')
99
- for op in ops
100
- body = op.at('body')
101
- if !body.nil?
102
- op_ocl = body.content
103
- op_name = op['name']
104
- ret_type = op['type']
105
- xmiid = '_2_op_' + name + '_' + op_name
106
- res = ERB.new(operation_template)
107
- t = res.result(binding)
108
- file.puts t
109
-
110
- params = op.xpath('./param')
111
- for param in params
112
- par_name = param['name']
113
- par_xmiid = xmiid + '-' + par_name
114
- par_type = param['type']
115
- res = ERB.new(parameter_template)
116
- t = res.result(binding)
117
- file.puts t
118
- end
119
- res = ERB.new(return_template)
120
- t = res.result(binding)
121
- file.puts t
122
- res = ERB.new(operation_end)
123
- t = res.result(binding)
124
- file.puts t
125
- else
126
- puts 'Operation ' + name + '.' + op['name'] + ' has no body - ignored!'
127
- end
128
- end
129
- end
130
- end
131
-
132
- def isEncapsulated (type, attrib)
133
- encapsulated = false
134
- rules = type.wheres.select {|w| w.name == "encapsulated"}
135
- if rules.length > 0
136
- for rule in rules
137
- if rule.expression == "SIZEOF(USEDIN(SELF, '')) = 1"
138
- encapsulated = true
139
- elsif rule.expression == "SIZEOF(QUERY(elem <* SELF | SIZEOF(USEDIN(elem, '')) = 1)) = SIZEOF(SELF)"
140
- encapsulated = true
141
- elsif rule.expression[0..24] == "SIZEOF(USEDIN(SELF, '') -"
142
- encapsulated = !(rule.expression[25..-1].include? ("." + attrib.entity.name.upcase + "." + attrib.name.upcase))
143
- else
144
- puts "Unknown encapsulated rule: " + rule.expression
145
- end
146
- if encapsulated
147
- break
148
- end
149
- end
150
- end
151
- if (type.kind_of? EXPSM::Entity) && !encapsulated
152
- for supertype in type.supertypes_array
153
- encapsulated = isEncapsulated(supertype, attrib)
154
- if encapsulated
155
- break
156
- end
157
- end
158
- end
159
- return encapsulated
160
- end
161
-
162
- def isEncapsulatedInto (parent, entity, attrib)
163
- encapsulated = false
164
- rules = parent.wheres.select {|w| w.name == "encapsulateInto"}
165
- if rules.length > 0
166
- for rule in rules
167
- ruleString = rule.expression.upcase
168
- if ruleString[0..6] == "EXISTS("
169
- closeParen = ruleString.index(')')
170
- if ruleString[closeParen..-1].include? " XOR (SIZEOF(TYPEOF(SELF) *"
171
- if !ruleString[closeParen+28..-1].include? ('.'+entity.name.upcase+'''')
172
- encapsulated = (ruleString[6..closeParen].include? ('('+attrib.name.upcase+')'))
173
- end
174
- else
175
- encapsulated = (ruleString[6..closeParen].include? ('('+attrib.name.upcase+')'))
176
- end
177
- else
178
- puts "Unknown encapsulateInto rule: " + rule.expression
179
- end
180
- if encapsulated
181
- break
182
- end
183
- end
184
- end
185
- if !encapsulated
186
- for supertype in parent.supertypes_array
187
- encapsulated = isEncapsulatedInto(supertype, entity, attrib)
188
- if encapsulated
189
- break
190
- end
191
- end
192
- end
193
- return encapsulated
194
- end
195
-
196
- def map_from_express(mapinput, passedArgs)
197
- # Enter file name here to override defaults (<schema>.xmi if one schema, and Model.xmi if more than one)
198
- output_xmi_filename = nil
199
-
200
- noprune = false
201
- schemaId = false
202
- $uuidsRequired = true
203
- xmiVersion = "2.1"
204
- dtHandle = "local"
205
- outPath = nil
206
- for arg in passedArgs
207
- argarray = arg.split('=')
208
- case argarray[0]
209
- when "noprune" then noprune = true
210
- when "nouuids" then $uuidsRequired = false
211
- when "path" then outPath = argarray[1]
212
- when "schemaid" then schemaId = true
213
- when "xmi" then xmiVersion = argarray[1]
214
- when "types" then dtHandle = argarray[1]
215
- end
216
- end
217
-
218
- case xmiVersion
219
- when "2.1" then $StandardProfile = "StandardProfileL2"
220
- when "2.5" then $StandardProfile = "StandardProfile"
221
- else
222
- puts "XMI version "+xmiVersion+" is not handled!"
223
- exit
224
- end
225
-
226
- case dtHandle
227
- when "local"
228
- puts "Data types will generated within the package structure"
229
- when "ignore"
230
- puts "Data types will not be generated"
231
- when "export"
232
- puts "Data types will be exported to DataTypes.xmi"
233
- else
234
- puts "Data type handling option: "+dtHandle+" not valid!"
235
- exit
236
- end
237
-
238
- if dtHandle != "local"
239
- if outPath.nil?
240
- puts "path must be specified when type=" + dtHandle
241
- exit
242
- end
243
- end
244
-
245
- uuidSafe = nil
246
- uuidOldSafe = nil
247
- if $uuidsRequired
248
- $uuid = UUID.new
249
- if File.exists?("UUIDs.xml")
250
- uuidfile = File.open("UUIDs.xml")
251
- $uuidxml = Nokogiri::XML(uuidfile, &:noblanks)
252
- uuidfile.close
253
- else
254
- $uuidxml = Nokogiri::XML::Builder.new { |b| b.uuids }.doc
255
- end
256
- $olduuids = $uuidxml.xpath('//uuidmap')
257
- end
258
-
259
- if File.exists?("WhereRuleMapping.xml")
260
- wherefile = File.open("WhereRuleMapping.xml")
261
- $wherexml = Nokogiri::XML(wherefile, &:noblanks)
262
- wherefile.close
263
- end
264
-
265
- if File.exists?("Operators.xml")
266
- opsfile = File.open("Operators.xml")
267
- $opsxml = Nokogiri::XML(opsfile, &:noblanks)
268
- opsfile.close
269
- end
270
-
271
- # datatypes for builtin types that have been exported
272
- datatype_hash = Hash.new
273
-
274
- # XMI File Start Template (includes datatypes for builtin with no direct UML equivalent)
275
- overall_start_template = %{<?xml version="1.0" encoding="UTF-8"?><%
276
- if xmiVersion == "2.1" %>
277
- <xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.omg.org/spec/UML/20090901" xmlns:StandardProfileL2="http://schema.omg.org/spec/UML/2.3/StandardProfileL2.xmi" xmlns:sysml="http://www.omg.org/spec/SysML/20100301/SysML-profile"><%
278
- else %>
279
- <xmi:XMI xmlns:uml='http://www.omg.org/spec/UML/20131001' xmlns:xmi='http://www.omg.org/spec/XMI/20131001' xmlns:StandardProfile='http://www.omg.org/spec/UML/20131001/StandardProfile' xmlns:sysml='http://www.omg.org/spec/SysML/20150709/SysML'><%
280
- end
281
- $dtprefix=''
282
- if !outPath.nil?
283
- pathElements = outPath.split('/')
284
- if dtHandle=='local'
285
- for elem in pathElements
286
- $dtprefix = $dtprefix + elem[0]
287
- end
288
- $dtprefix = $dtprefix + '_'
289
- end
290
- end %>}
291
-
292
- # Package Structure Start
293
- package_start = %{<%
294
- if outPath.nil?
295
- name = "SysMLfromEXPRESS"
296
- else
297
- pathElements = outPath.split('/')
298
- name = pathElements[-1]
299
- end %>
300
- <uml:Package xmi:id="_0_<%= name %>"<%= get_uuid('_0_'+name) %> xmi:type="uml:Package">
301
- <name><%= name %></name>}
302
-
303
- # Apply SysML profile
304
- apply_sysml = %{<profileApplication xmi:id="_profileApplication0"<%= get_uuid('_profileApplication0') %> xmi:type="uml:ProfileApplication"><%
305
- if xmiVersion == "2.1" %>
306
- <appliedProfile href="http://www.omg.org/spec/SysML/20100301/SysML-profile.uml#_0"/><%
307
- else %>
308
- <appliedProfile href="http://www.omg.org/spec/SysML/20150709/SysML.xmi#_SysML__0"/><%
309
- end %>
310
- </profileApplication>}
311
-
312
- # Package end
313
- package_end = %{</uml:Package>}
314
-
315
- # XMI File End Template
316
- overall_end_template = %{</xmi:XMI>}
317
-
318
- #DATA TYPEs
319
- data_types = %{<packagedElement xmi:id="<%= $dtprefix %>BINARY"<%= get_uuid($dtprefix+'BINARY') %> xmi:type="uml:PrimitiveType">
320
- <name>Binary</name>
321
- </packagedElement>
322
- <packagedElement xmi:id="<%= $dtprefix %>STRING"<%= get_uuid($dtprefix+'STRING') %> xmi:type="uml:PrimitiveType">
323
- <name>String</name>
324
- </packagedElement>
325
- <packagedElement xmi:id="<%= $dtprefix %>NUMBER"<%= get_uuid($dtprefix+'NUMBER') %> xmi:type="uml:PrimitiveType">
326
- <name>Number</name>
327
- <isAbstract>true</isAbstract>
328
- </packagedElement>
329
- <packagedElement xmi:id="<%= $dtprefix %>REAL"<%= get_uuid($dtprefix+'REAL') %> xmi:type="uml:PrimitiveType">
330
- <name>Real</name>
331
- <generalization xmi:id="_generalization-<%= $dtprefix %>REAL_NUMBER"<%= get_uuid('_generalization-'+$dtprefix+'REAL_NUMBER') %> xmi:type="uml:Generalization">
332
- <general xmi:idref="<%= $dtprefix %>NUMBER"/>
333
- </generalization>
334
- </packagedElement>
335
- <packagedElement xmi:id="<%= $dtprefix %>INTEGER"<%= get_uuid($dtprefix+'INTEGER') %> xmi:type="uml:PrimitiveType">
336
- <name>Integer</name>
337
- <generalization xmi:id="_generalization-<%= $dtprefix %>INTEGER_REAL"<%= get_uuid('_generalization-'+$dtprefix+'INTEGER_REAL') %> xmi:type="uml:Generalization">
338
- <general xmi:idref="<%= $dtprefix %>REAL"/>
339
- </generalization>
340
- </packagedElement>
341
- <packagedElement xmi:id="<%= $dtprefix %>LOGICAL"<%= get_uuid($dtprefix+'LOGICAL') %> xmi:type="uml:Enumeration">
342
- <name>Logical</name>
343
- <ownedLiteral xmi:id="<%= $dtprefix %>UNKNOWN"<%= get_uuid($dtprefix+'UNKNOWN') %> xmi:type="uml:EnumerationLiteral">
344
- <name>Unknown</name>
345
- </ownedLiteral>
346
- </packagedElement>
347
- <packagedElement xmi:id="<%= $dtprefix %>BOOLEAN"<%= get_uuid($dtprefix+'BOOLEAN') %> xmi:type="uml:Enumeration">
348
- <name>Boolean</name>
349
- <generalization xmi:id="<%= $dtprefix %>_generalization-<%= $dtprefix %>BOOLEAN-LOGICAL"<%= get_uuid('_generalization-'+$dtprefix+'BOOLEAN-LOGICAL') %> xmi:type="uml:Generalization">
350
- <general xmi:idref="<%= $dtprefix %>LOGICAL"/>
351
- </generalization>
352
- <ownedLiteral xmi:id="<%= $dtprefix %>TRUE"<%= get_uuid($dtprefix+'TRUE') %> xmi:type="uml:EnumerationLiteral">
353
- <name>True</name>
354
- </ownedLiteral>
355
- <ownedLiteral xmi:id="<%= $dtprefix %>FALSE"<%= get_uuid($dtprefix+'FALSE') %> xmi:type="uml:EnumerationLiteral">
356
- <name>False</name>
357
- </ownedLiteral>
358
- </packagedElement>}
359
-
360
- #DATA TYPE end
361
- data_type_stereos = %{<sysml:ValueType xmi:id="<%= $dtprefix %>LOGICAL_VT"<%= get_uuid($dtprefix+'LOGICAL_VT') %>>
362
- <base_DataType xmi:idref="<%= $dtprefix %>LOGICAL"/>
363
- </sysml:ValueType>
364
- <sysml:ValueType xmi:id="<%= $dtprefix %>BOOLEAN_VT"<%= get_uuid($dtprefix+'BOOLEAN_VT') %>>
365
- <base_DataType xmi:idref="<%= $dtprefix %>BOOLEAN"/>
366
- </sysml:ValueType>
367
- <sysml:ValueType xmi:id="<%= $dtprefix %>NUMBER_VT"<%= get_uuid($dtprefix+'NUMBER_VT') %>>
368
- <base_DataType xmi:idref="<%= $dtprefix %>NUMBER"/>
369
- </sysml:ValueType>
370
- <sysml:ValueType xmi:id="<%= $dtprefix %>REAL_VT"<%= get_uuid($dtprefix+'REAL_VT') %>>
371
- <base_DataType xmi:idref="<%= $dtprefix %>REAL"/>
372
- </sysml:ValueType>
373
- <sysml:ValueType xmi:id="<%= $dtprefix %>INTEGER_VT"<%= get_uuid($dtprefix+'INTEGER_VT') %>>
374
- <base_DataType xmi:idref="<%= $dtprefix %>INTEGER"/>
375
- </sysml:ValueType>
376
- <sysml:ValueType xmi:id="<%= $dtprefix %>STRING_VT"<%= get_uuid($dtprefix+'STRING_VT') %>>
377
- <base_DataType xmi:idref="<%= $dtprefix %>STRING"/>
378
- </sysml:ValueType>
379
- <sysml:ValueType xmi:id="<%= $dtprefix %>BINARY_VT"<%= get_uuid($dtprefix+'BINARY_VT') %>>
380
- <base_DataType xmi:idref="<%= $dtprefix %>BINARY"/>
381
- </sysml:ValueType>}
382
-
383
- # SCHEMA Start Template
384
- schema_start_template = %{<% if schema_list.size > 1 %><packagedElement<% else %><uml:Package<% end %> xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Package">
385
- <name><%= schema.name %></name>}
386
-
387
- # SCHEMA INTERFACE Template
388
- schema_interface_template = %{<packageImport xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:PackageImport">
389
- <importedPackage xmi:idref="_1_<%= interfaced_schema.foreign_schema_id %>"/>
390
- </packageImport>}
391
-
392
- # SCHEMA End Template
393
- schema_end_template = %{<% if schema_list.size > 1 %></packagedElement><% else %></uml:Package><% end %>}
394
-
395
- # ENTITY Block Template
396
- entity_block_template = %{<sysml:Block xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %>>
397
- <base_Class xmi:idref="<%= baseClass %>"/>
398
- </sysml:Block>}
399
-
400
- # ENTITY Start Template
401
- entity_start_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Class">
402
- <name><%= entity.name %></name><% if entity.isAbs %>
403
- <isAbstract>true</isAbstract><% end %>}
404
-
405
- # SUBTYPE OF Template
406
- supertype_template = %{<generalization xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Generalization">
407
- <general xmi:idref="<%= xmiid_general %>"/>
408
- </generalization>}
409
-
410
- # ENTITY End Template
411
- entity_end_template = %{</packagedElement>}
412
-
413
- # ENUMERATION Start Template
414
- enum_start_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Enumeration">
415
- <name><%= enum.name %></name><% if !general.nil?
416
- if !datatype_hash[general].nil? %>
417
- <generalization xmi:id="<%= gen_xmiid %>"<%= get_uuid(gen_xmiid) %> xmi:type="uml:Generalization">
418
- <general href="<%= datatype_hash[general] %>"/>
419
- </generalization><% else %>
420
- <generalization xmi:id="<%= gen_xmiid %>"<%= get_uuid(gen_xmiid) %> xmi:type="uml:Generalization">
421
- <general xmi:idref="<%= xmiid_general %>"/>
422
- </generalization>
423
- <% end
424
- end%>}
425
-
426
- # ENUMERATION ITEM Template
427
- enum_item_template = %{<ownedLiteral xmi:id="<%= enumitem_xmiid %>"<%= get_uuid(enumitem_xmiid) %> xmi:type="uml:EnumerationLiteral">
428
- <name><%= enumitem %></name>
429
- </ownedLiteral>}
430
-
431
- # ENUMERATION End Template
432
- enum_end_template = %{</packagedElement>}
433
-
434
- # SELECT Start Template
435
- select_start_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="<% if selectTypeType[type.name] == "Type" %>uml:DataType<% else %>uml:Class<% end %>">
436
- <name><%= type.name %></name>
437
- <isAbstract>true</isAbstract>}
438
-
439
- # SELECT End Template
440
- select_end_template = %{</packagedElement>}
441
-
442
- # SELECT Stereotype Template
443
- select_stereotype_template = %{<<%= $StandardProfile %>:Auxiliary xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %>>
444
- <base_Class xmi:idref="<%= baseClass %>"/>
445
- </<%= $StandardProfile %>:Auxiliary>}
446
-
447
- # Template covering the output file contents for each attribute that is an entity
448
- attribute_entity_template = %{<ownedAttribute xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Property">
449
- <name><%= attr.name %></name><% if islist %>
450
- <isOrdered>true</isOrdered><% end %><% if !isset %>
451
- <isUnique>false</isUnique><% end %>
452
- <type xmi:idref="<%= domain_xmiid %>"/><% if (direct_inverse and !encapsulatedInto) or encapsulated %>
453
- <aggregation>composite</aggregation><% end %>
454
- <association xmi:idref="<%= assoc_xmiid %>"/><% if attr.redeclare_entity %>
455
- <redefinedProperty xmi:idref="<%= redefined_xmiid %>"/><% end %>}
456
-
457
- # INVERSE ATTRIBUTE Template
458
- inverse_attribute_template = %{<ownedAttribute xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Property">
459
- <name><%= inverse.name %></name><% if !isset %>
460
- <isUnique>false</isUnique><% end %>
461
- <isReadOnly>true</isReadOnly><% if encapsulatedInto %>
462
- <aggregation>composite</aggregation><% end %>
463
- <type xmi:idref="<%= domain_xmiid %>"/>
464
- <association xmi:idref="<%= assoc_xmiid %>"/><% if inverse.redeclare_entity %>
465
- <redefinedProperty xmi:idref="<%= redefined_xmiid %>"/><% end %>}
466
-
467
- #Template covering multiplicities
468
- multiplicity = %{<% dummy = nil
469
- if lower == '0' %><lowerValue xmi:id="<%= xmiid %>-lowerValue"<%= get_uuid(xmiid + '-lowerValue') %> xmi:type="uml:LiteralInteger"/><%
470
- else
471
- if lower != '1' %><lowerValue xmi:id="<%= xmiid %>-lowerValue"<%= get_uuid(xmiid + '-lowerValue') %> xmi:type=<% if /\\d+/ === lower %>"uml:LiteralInteger"<% else %>"uml:LiteralString"<% end %>>
472
- <value><%= lower %></value>
473
- </lowerValue><%
474
- else
475
- dummy = get_uuid(xmiid + '-lowerValue')
476
- end
477
- end %><% if dummy.nil? %>
478
- <% end %><% if upper != '1' %><upperValue xmi:id="<%= xmiid %>-upperValue"<%= get_uuid(xmiid + '-upperValue') %> xmi:type=<% if /(\\d+|\\*)/ === upper %>"uml:LiteralUnlimitedNatural"<% else %>"uml:LiteralString"<% end %>>
479
- <value><%= upper %></value>
480
- </upperValue><%
481
- else
482
- dummy = get_uuid(xmiid + '-upperValue')
483
- end %>}
484
-
485
- #Template covering attribute wrapup
486
- attribute_end = %{</ownedAttribute>}
487
-
488
-
489
- # EXPLICIT ATTRIBUTE ENTITY Create Association Template
490
- attribute_entity_association_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Association">
491
- <memberEnd xmi:idref="<%= attr_xmiid %>"/><%
492
- if !inverse_exists %>
493
- <memberEnd xmi:idref="<%= xmiid + '-end' %>"/>
494
- <ownedEnd xmi:id="<%= xmiid %>-end"<%= get_uuid(xmiid+'-end') %> xmi:type="uml:Property"><% if encapsulatedInto %>
495
- <aggregation>composite</aggregation><% end %>
496
- <type xmi:idref="<%= owner_xmiid %>"/>
497
- <association xmi:idref="<%= xmiid %>"/>
498
- <lowerValue xmi:id="<%= xmiid %>-end-lowerValue"<%= get_uuid(xmiid+'-end-lowerValue') %> xmi:type="uml:LiteralInteger"/><%
499
- if encapsulated
500
- dummy = get_uuid(xmiid+'-end-upperValue')
501
- else %>
502
- <upperValue xmi:id="<%= xmiid %>-end-upperValue"<%= get_uuid(xmiid+'-end-upperValue') %> xmi:type="uml:LiteralUnlimitedNatural">
503
- <value>*</value>
504
- </upperValue><%
505
- end %>
506
- </ownedEnd><%
507
- else %><memberEnd xmi:idref="<%= iattr_xmiid %>"/><%
508
- end %><%
509
- if general_exists %>
510
- <generalization xmi:id="<%= general_xmiid %>"<%= get_uuid(general_xmiid) %> xmi:type="uml:Generalization">
511
- <general xmi:idref="<%= redefined_xmiid %>"/>
512
- </generalization><%
513
- end %>
514
- </packagedElement>}
515
-
516
-
517
- # INVERSE ATTRIBUTE ENTITY Create Association Template
518
- inverse_entity_association_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Association">
519
- <memberEnd xmi:idref="<%= xmiid + '-end' %>"/>
520
- <memberEnd xmi:idref="<%= iattr_xmiid %>"/>
521
- <ownedEnd xmi:id="<%= xmiid %>-end"<%= get_uuid(xmiid+'-end') %> xmi:type="uml:Property">
522
- <type xmi:idref="<%= owner_xmiid %>"/>
523
- <association xmi:idref="<%= xmiid %>"/><% xmiid = xmiid + '-end' %>}
524
-
525
- inverse_entity_association_end = %{</ownedEnd>
526
- <generalization xmi:id="<%= general_xmiid %>"<%= get_uuid(general_xmiid) %> xmi:type="uml:Generalization">
527
- <general xmi:idref="<%= redefined_xmiid %>"/>
528
- </generalization>
529
- </packagedElement>}
530
-
531
-
532
- # EXPLICIT ATTRIBUTE SIMPLE TYPE Template
533
- attribute_builtin_template = %{<ownedAttribute xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Property">
534
- <name><%= attr.name %></name><% if islist %>
535
- <isOrdered>true</isOrdered><% end %><% if !isset %>
536
- <isUnique>false</isUnique><% end %>
537
- <aggregation>composite</aggregation><% if attr.redeclare_entity %>
538
- <redefinedProperty xmi:idref="<%= redefined_xmiid %>"/><% end %><% if !nestedAggs[domain_name].nil? %>
539
- <type xmi:idref="<%= prefix+domain_name %>"/><% else if !datatype_hash[domain_name].nil? %>
540
- <type href="<%= datatype_hash[domain_name] %>"/><% else %>
541
- <type xmi:idref="<%= $dtprefix+domain_name %>"/><% end end %>}
542
-
543
-
544
- # EXPLICIT ATTRIBUTE ENUM and TYPE Template
545
- attribute_enum_type_template = %{<ownedAttribute xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Property">
546
- <name><%= attr.name %></name>
547
- <type xmi:idref="<%= type_xmiid %>"/><% if islist %>
548
- <isOrdered>true</isOrdered><% end %><% if !isset %>
549
- <isUnique>false</isUnique><% end %>
550
- <aggregation>composite</aggregation>}
551
-
552
- # Lower bound constraint template
553
- bound_constraint = %{<ownedRule xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Constraint">
554
- <name><%= name %>_LB</name>
555
- <constrainedElement xmi:idref="<%= xmiid_entity %>"/>
556
- <specification xmi:id="<%= xmiid %>-spec"<%= get_uuid(xmiid+'-spec') %> xmi:type="uml:OpaqueExpression">
557
- <body><%= name %>-&gt;isEmpty() or <%= name %>-&gt;size() &gt;= <%= bound %></body>
558
- <language>OCL2.0</language>
559
- </specification>
560
- </ownedRule>}
561
-
562
- # UNIQUE rule template
563
- unique_template = %{<ownedRule xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Constraint">
564
- <name><%= unique.name %></name>
565
- <constrainedElement xmi:idref="<%= xmiid_entity %>"/>
566
- <specification xmi:id="<%= xmiid %>-spec"<%= get_uuid(xmiid+'-spec') %> xmi:type="uml:OpaqueExpression">
567
- <body><%= entity.name %>::allInstances()-&gt;isUnique(<%= unique_text %>)</body>
568
- <language>OCL2.0</language>
569
- </specification>
570
- </ownedRule>}
571
-
572
- # WHERE rule template
573
- where_template = %{<ownedRule xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Constraint">
574
- <name><%= where.name %></name>
575
- <constrainedElement xmi:idref="<%= xmiidref %>"/>
576
- <specification xmi:id="<%= xmiid %>-spec"<%= get_uuid(xmiid+'-spec') %> xmi:type="uml:OpaqueExpression">
577
- <body><%= where_ocl %></body>
578
- <language>OCL2.0</language>
579
- </specification>
580
- </ownedRule>}
581
-
582
- # TYPE Template
583
- type_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:PrimitiveType">
584
- <name><%= type.name %></name><% if !datatype_hash[type.domain].nil? %>
585
- <generalization xmi:id="_supertype<%= xmiid %>"<%= get_uuid('_supertype'+xmiid) %> xmi:type="uml:Generalization">
586
- <general href="<%= datatype_hash[type.domain] %>"/>
587
- </generalization><% else %>
588
- <generalization xmi:id="_supertype<%= xmiid %>"<%= get_uuid('_supertype'+xmiid) %> xmi:type="uml:Generalization">
589
- <general xmi:idref="<%= $dtprefix+xmiid_general %>"/>
590
- </generalization>
591
- <% end %>}
592
-
593
- # ProxyTYPE Start Template
594
- proxy_start_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Class">
595
- <name><%= type.name %>Proxy</name>
596
- <ownedAttribute xmi:id="<%= xmiid %>_value"<%= get_uuid(xmiid + "_value") %> xmi:type="uml:Property">
597
- <name>value</name>
598
- <type xmi:idref="<%= xmiid_type %>"/>
599
- <aggregation>composite</aggregation>
600
- </ownedAttribute><%
601
- dummy = get_uuid(xmiid + "_value-lowerValue")
602
- dummy = get_uuid(xmiid + "_value-upperValue")
603
- %>}
604
-
605
- # AggTYPE Start Template
606
- aggtype_start_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Class">
607
- <name><%= type_name %></name>}
608
-
609
- aggtype_attribute = %{<ownedAttribute xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Property">
610
- <name>elements</name><% if islist %>
611
- <isOrdered>true</isOrdered><% end %><% if !isset %>
612
- <isUnique>false</isUnique><% end %><% if datatype_hash[type.domain].nil? %>
613
- <type xmi:idref="<%= xmiid_type %>"/><% else %>
614
- <type href="<%= datatype_hash[type.domain] %>"/><% end %><% if associationNeeded %>
615
- <association xmi:idref="<%= assoc_xmiid %>"/><% else %>
616
- <aggregation>composite</aggregation><% end %>}
617
-
618
- aggtype_association = %{<packagedElement xmi:id="<%= assoc_xmiid %>"<%= get_uuid(assoc_xmiid) %> xmi:type="uml:Association">
619
- <memberEnd xmi:idref="<%= xmiid %>"/>
620
- <memberEnd xmi:idref="<%= assoc_xmiid + '-end' %>"/>
621
- <ownedEnd xmi:id="<%= assoc_xmiid %>-end"<%= get_uuid(assoc_xmiid+'-end') %> xmi:type="uml:Property">
622
- <type xmi:idref="<%= xmiid_type %>"/>
623
- <association xmi:idref="<%= assoc_xmiid %>"/>
624
- <lowerValue xmi:id="<%= assoc_xmiid %>-end-lowerValue"<%= get_uuid(assoc_xmiid+'-end-lowerValue') %> xmi:type="uml:LiteralInteger"/>
625
- </ownedEnd>
626
- </packagedElement>}
627
-
628
- # TYPE Stereotype Template
629
- type_stereotype_template = %{<<%= $StandardProfile %>:Type xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %>>
630
- <base_Class xmi:idref="<%= baseClass %>"/>
631
- </<%= $StandardProfile %>:Type>}
632
-
633
- #TYPE end Template
634
- type_end_template=%{</packagedElement>}
635
-
636
- # TYPE ValueType Template
637
- valuetype_template = %{<sysml:ValueType xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %>>
638
- <base_DataType xmi:idref="<%= baseType %>"/>
639
- </sysml:ValueType>}
640
-
641
- #############################################################################################
642
- # Set up list of schemas to process, input may be a repository containing schemas or a single schema
643
- #############################################################################################
644
-
645
- if mapinput.kind_of? EXPSM::Repository
646
- schema_list = mapinput.schemas
647
- elsif mapinput.kind_of? EXPSM::SchemaDefinition
648
- schema_list = [mapinput]
649
- else
650
- puts "ERROR : map_from_express input no Repository instance or Schema instance"
651
- exit
652
- end
653
-
654
- # Set up XMI output file
655
-
656
- if schema_list.size == 1
657
- if output_xmi_filename.nil?
658
- schema = schema_list[0]
659
- output_xmi_filename = schema.name.to_s + ".xmi"
660
- end
661
- if schemaId
662
- get_prefix = lambda {|schema| '_' + schema.name + '-'}
663
- else
664
- get_prefix = lambda {|schema| '_'}
665
- end
666
- else
667
- if output_xmi_filename.nil?
668
- output_xmi_filename = 'Model.xmi'
669
- end
670
- get_prefix = lambda {|schema| '_' + schema.name + '-'}
671
- end
672
-
673
- file = File.new(output_xmi_filename, "w")
674
- puts 'reeper : Writing output to file ' + output_xmi_filename
675
-
676
- # Evaluate and write file start template
677
- res = ERB.new(overall_start_template)
678
- t = res.result(binding)
679
- file.puts t
680
-
681
- if dtHandle != "local"
682
- pathElements = outPath.split('/')
683
- relPath = "DataTypes.xmi"
684
- for elem in pathElements
685
- relPath = "../" + relPath
686
- end
687
- datatype_hash["LOGICAL"] = relPath + "#LOGICAL"
688
- datatype_hash["BOOLEAN"] = relPath + "#BOOLEAN"
689
- datatype_hash["NUMBER"] = relPath + "#NUMBER"
690
- datatype_hash["REAL"] = relPath + "#REAL"
691
- datatype_hash["INTEGER"] = relPath + "#INTEGER"
692
- datatype_hash["STRING"] = relPath + "#STRING"
693
- datatype_hash["BINARY"] = relPath + "#BINARY"
694
- end
695
-
696
- # sort out data types
697
- if dtHandle != "ignore"
698
- if dtHandle == "local"
699
- dtfile = file
700
- else
701
- dtfile = File.new("DataTypes.xmi","w")
702
- res = ERB.new(overall_start_template)
703
- t = res.result(binding)
704
- dtfile.puts t
705
- if $uuidsRequired
706
- uuidSafe = $uuidxml
707
- uuidOldSafe = $olduuids
708
- if File.exists?("DataTypes_UUIDs.xml")
709
- uuidfile = File.open("DataTypes_UUIDs.xml")
710
- $uuidxml = Nokogiri::XML(uuidfile, &:noblanks)
711
- uuidfile.close
712
- else
713
- $uuidxml = Nokogiri::XML::Builder.new { |b| b.uuids }.doc
714
- end
715
- $olduuids = $uuidxml.xpath('//uuidmap')
716
- end
717
- xmiid = "_0_" + $dtprefix + "DataTypes"
718
- dtfile.puts '<uml:Package xmi:id="'+ xmiid +'"' + get_uuid(xmiid) +' xmi:type="uml:Package">'
719
- dtfile.puts '<name>DataTypes</name>'
720
- res = ERB.new(apply_sysml)
721
- t = res.result(binding)
722
- dtfile.puts t
723
- end
724
- res = ERB.new(data_types)
725
- t = res.result(binding)
726
- dtfile.puts t
727
- if dtHandle == "export"
728
- dtfile.puts '</uml:Package>'
729
- end
730
- if !uuidSafe.nil?
731
- tmp = uuidSafe
732
- uuidSafe = $uuidxml
733
- $uuidxml = tmp
734
- tmp = uuidOldSafe
735
- uuidOldSafe = $olduuids
736
- $olduuids = tmp
737
- end
738
- end
739
-
740
- # Set up list of all EXPRESS Inverses in all schemas
741
- all_inverse_list = []
742
- direct_inverses = []
743
- # Set up list of all EXPRESS Selects in all schemas
744
- all_select_list = []
745
- renamed_select_list = []
746
- # setup global proxy type handling
747
- typeProxies = Hash.new
748
-
749
- # build all_select_list
750
- for schema in schema_list
751
- select_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::TypeSelect }
752
- all_select_list = all_select_list + select_list
753
- type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::Type and !e.isBuiltin}
754
- for type in type_list
755
- superselect = NamedType.find_by_name( type.domain )
756
- while (superselect.instance_of? EXPSM::Type and !superselect.isBuiltin)
757
- superselect = NamedType.find_by_name(superselect.domain)
758
- end
759
- if superselect.kind_of? EXPSM::TypeSelect
760
- renamed_select_list << type
761
- end
762
- end
763
- end
764
-
765
- # Set up storage for handling Aggregate and Select Types correctly
766
- aggTypes = Hash.new
767
- specialSelects = Hash.new
768
-
769
- # determine Aggregate and Select types needing special consideration
770
- for schema in schema_list
771
- entity_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Entity }
772
- for entity in entity_list
773
- attr_list = entity.attributes.find_all{ |e| e.kind_of? EXPSM::Explicit }
774
- for attr in attr_list
775
- if attr.instance_of? EXPSM::ExplicitAggregate
776
- orig_domain = NamedType.find_by_name( attr.domain )
777
- if orig_domain.class.to_s == "EXPSM::TypeAggregate"
778
- if aggTypes[attr.domain].nil?
779
- aggTypes[attr.domain] = orig_domain
780
- end
781
- end
782
- end
783
- if attr.redeclare_entity
784
- attr_domain = NamedType.find_by_name(attr.domain)
785
- if attr_domain.instance_of? EXPSM::TypeSelect
786
- supertype = NamedType.find_by_name( attr.redeclare_entity )
787
- if attr.redeclare_oldname
788
- redeclOf = supertype.find_attr_by_name( attr.redeclare_oldname )
789
- else
790
- redeclOf = supertype.find_attr_by_name( attr.name )
791
- end
792
- redecl_domain = NamedType.find_by_name( redeclOf.domain )
793
- case redecl_domain.class.to_s
794
- when 'EXPSM::Entity', 'EXPSM::TypeSelect'
795
- if specialSelects[attr.domain].nil?
796
- specialSelects[attr.domain] = [redecl_domain]
797
- else
798
- if !specialSelects[attr.domain].include?(redecl_domain)
799
- specialSelects[attr.domain].push(redecl_domain)
800
- end
801
- end
802
- end
803
- end
804
- end
805
- end
806
- end
807
- end
808
-
809
- # Set up storage for handling select types correctly
810
- selectTypeType = Hash.new
811
-
812
- # determine the type of select
813
- # - entity if only contains entities
814
- # - type if only contains types
815
- # - hybrid if a mixture
816
- # - remove if a single object in list
817
- unknownSelect = all_select_list.dup
818
- for select in unknownSelect
819
- if (select.selectitems_array.size == 1 && !noprune)
820
- if !select.selectitems_array[0].kind_of? EXPSM::TypeSelect
821
- puts select.name + " is pruned since it only contains one element"
822
- selectTypeType[select.name] = "Remove"
823
- end
824
- end
825
- entcount = 0
826
- typcount = 0
827
- select.selectitems_array.each do |e|
828
- case e.class.to_s
829
- when "EXPSM::Entity" then entcount += 1
830
- when "EXPSM::Type" then typcount += 1
831
- when "EXPSM::TypeEnum" then typcount += 1
832
- when "EXPSM::TypeAggregate"
833
- if selectTypeType[select.name] != "Remove"
834
- entcount += 1
835
- if aggTypes[e.name].nil?
836
- aggTypes[e.name] = e
837
- end
838
- end
839
- when "EXPSM::TypeSelect"
840
- case selectTypeType[e.name]
841
- when "Entity" then entcount += 1
842
- when "Type" then typcount += 1
843
- when "Hybrid" then selectTypeType[select.name] = "Hybrid"
844
- when "Remove"
845
- case e.selectitems_array[0].class.to_s
846
- when "EXPSM::Entity" then entcount += 1
847
- when "EXPSM::Type" then typcount += 1
848
- end
849
- end
850
- else
851
- puts "unknown class " + e.class.to_s + " for " + select.name
852
- end
853
- end
854
-
855
- if selectTypeType[select.name].nil?
856
- case select.selectitems_array.size
857
- when entcount then selectTypeType[select.name] = "Entity"
858
- when typcount then selectTypeType[select.name] = "Type"
859
- else
860
- if (entcount > 0) && (typcount > 0)
861
- selectTypeType[select.name] = "Hybrid"
862
- else
863
- unknownSelect.push select
864
- end
865
- end
866
- end
867
- if selectTypeType[select.name] == "Hybrid"
868
- puts select.name + " is Hybrid select - proxy block(s) generated."
869
- end
870
- end
871
-
872
- # process subsetted select types
873
- selectSubset = Hash.new
874
- selectSubs = Hash.new
875
- for select in renamed_select_list
876
- superselect = NamedType.find_by_name( select.domain )
877
- if superselect.kind_of? EXPSM::TypeSelect
878
- temp = []
879
- superselect.selectitems_array.each{|e|
880
- if e.kind_of? EXPSM::TypeSelect
881
- e.selectitems_array.each{|inner|
882
- if inner.kind_of? EXPSM::TypeSelect
883
- puts "select of select select for " + superselect.name
884
- else
885
- temp << inner.name
886
- end}
887
- else
888
- temp << e.name
889
- end}
890
- if selectSubset[superselect.name].nil?
891
- selectSubset[superselect.name] = temp.dup
892
- end
893
- select.wheres.each{|rule| ruleString = rule.expression.upcase
894
- if ruleString[0..5] == "NOT ('"
895
- startPos = ruleString.index('.',6) + 1
896
- endPos = ruleString.index("'",startPos) - 1
897
- removeName = ruleString[startPos..endPos]
898
- temp.reject!{|e| e.upcase == removeName}
899
- else
900
- puts "Unexpected expression: " + rule.expression
901
- end
902
- }
903
- selectSubset[select.name] = temp
904
- selectSubset[superselect.name] = selectSubset[superselect.name] - temp
905
- if selectSubs[superselect.name].nil?
906
- selectSubs[superselect.name] = [select.name]
907
- else
908
- selectSubs[superselect.name] << select.name
909
- end
910
- selectTypeType[select.name] = selectTypeType[superselect.name]
911
- else
912
- puts "ERROR: Unhandled select subset for " + superselect.name
913
- end
914
- end
915
-
916
- if schema_list.size > 1
917
- res = ERB.new(package_start)
918
- t = res.result(binding)
919
- file.puts t
920
-
921
- #Apply sysml profile
922
- res = ERB.new(apply_sysml)
923
- t = res.result(binding)
924
- file.puts t
925
- end
926
-
927
- for schema in schema_list
928
- # Set up storage for handling nested Aggregates correctly
929
- nestedAggs = Hash.new
930
- nestedTypes = Hash.new
931
- prefix = get_prefix.call(schema)
932
-
933
- entity_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Entity }
934
- for entity in entity_list
935
- entity_inverse_list = entity.attributes.find_all{ |e| e.kind_of? EXPSM::Inverse }
936
- for inverse in entity_inverse_list
937
- all_inverse_list.push inverse
938
- end
939
- end
940
-
941
- # Evaluate and write schema start template
942
- xmiid = '_1_' + schema.name
943
- res = ERB.new(schema_start_template)
944
- t = res.result(binding)
945
- file.puts t
946
-
947
- if schema_list.size == 1
948
- #Apply sysml profile
949
- res = ERB.new(apply_sysml)
950
- t = res.result(binding)
951
- file.puts t
952
- end
953
-
954
- interfaced_schema_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::InterfaceSpecification}
955
- for interfaced_schema in interfaced_schema_list
956
- # Evaluate and write schema interface template
957
- xmiid = '_2_' + schema.name + '-' + interfaced_schema.foreign_schema_id
958
- res = ERB.new(schema_interface_template)
959
- t = res.result(binding)
960
- file.puts t
961
- end
962
-
963
- # Map EXPRESS TYPE of Builtin
964
- type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::Type and e.isBuiltin}
965
- for type in type_list
966
- xmiid = prefix + type.name
967
- xmiid_type = xmiid
968
- xmiid_general = type.domain
969
- if ["BOOLEAN", "LOGICAL"].include?(type.domain)
970
- enum = type
971
- general = type.domain
972
- gen_xmiid = '_supertype' + xmiid
973
- res = ERB.new(enum_start_template)
974
- t = res.result(binding)
975
- file.puts t
976
- else
977
- res = ERB.new(type_template)
978
- t = res.result(binding)
979
- file.puts t
980
- end
981
-
982
- # Map TYPE Select has Type as item
983
- for select in type.selectedBy
984
- # sort out what type of select we are dealing with
985
- case selectTypeType[select.name]
986
- when "Type"
987
- superName = select.name
988
- subset = selectSubset[superName]
989
- if !subset.nil?
990
- if !subset.include?(type.name)
991
- selectSubs[superName].each{|e|
992
- if selectSubset[e].include?(type.name)
993
- superName = e
994
- end}
995
- end
996
- end
997
- xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
998
- xmiid_general = prefix + superName
999
- res = ERB.new(supertype_template)
1000
- t = res.result(binding)
1001
- file.puts t
1002
- when "Hybrid"
1003
- typeProxy = typeProxies[type.name]
1004
- if typeProxy.nil?
1005
- typeProxies[type.name] = type
1006
- end
1007
- when "Remove"
1008
- # do nothing
1009
- end
1010
- end
1011
-
1012
- # Map EXPRESS Where rules
1013
- whererules = type.wheres.select {|w| w.name[0..10] != "encapsulate"}
1014
- if whererules.size > 0
1015
- for where in whererules
1016
- xmiid = '_3_whr' + prefix + type.name + '-' + where.name.to_s
1017
- where_ocl = get_where(xmiid, where.expression)
1018
- if where_ocl.size > 0
1019
- xmiidref = xmiid_type
1020
- res = ERB.new(where_template)
1021
- t = res.result(binding)
1022
- file.puts t
1023
- else
1024
- puts "Where rule " + type.name + "." + where.name + " not mapped to OCL - ignored!"
1025
- end
1026
- end
1027
- end
1028
-
1029
- put_ops(type.name, file)
1030
-
1031
- res = ERB.new(type_end_template)
1032
- t = res.result(binding)
1033
- file.puts t
1034
- end
1035
-
1036
- # Map EXPRESS TYPE of TYPE
1037
- type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::Type and !e.isBuiltin}
1038
- for type in type_list
1039
- domain = NamedType.find_by_name( type.domain )
1040
- xmiid = prefix + type.name
1041
- xmiid_type = xmiid
1042
- # deal with special cases
1043
- case domain.class.to_s
1044
- when "EXPSM::TypeSelect"
1045
- res = ERB.new(select_start_template)
1046
- t = res.result(binding)
1047
- file.puts t
1048
-
1049
- xmiid = '_2_superselect' + prefix + type.name + '-' + type.domain
1050
- xmiid_general = prefix + type.domain
1051
- res = ERB.new(supertype_template)
1052
- t = res.result(binding)
1053
- file.puts t
1054
-
1055
- when "EXPSM::TypeEnum"
1056
- enum = type
1057
- gen_xmiid = '_2_superenum' + prefix + type.name + '-' + type.domain
1058
- xmiid_general = prefix + type.domain
1059
- general = type.domain
1060
- res = ERB.new(enum_start_template)
1061
- t = res.result(binding)
1062
- file.puts t
1063
-
1064
- else
1065
- xmiid_general = prefix + type.domain
1066
- res = ERB.new(type_template)
1067
- t = res.result(binding)
1068
- file.puts t
1069
- end
1070
-
1071
- # Map TYPE Select has Type as item
1072
- if selectTypeType[type.name] == "Type"
1073
- for select in type.selectedBy
1074
- case selectTypeType[select.name]
1075
- when "Type"
1076
- superName = select.name
1077
- subset = selectSubset[superName]
1078
- if !subset.nil?
1079
- if !subset.include?(type.name)
1080
- selectSubs[superName].each{|e|
1081
- if selectSubset[e].include?(type.name)
1082
- superName = e
1083
- end}
1084
- end
1085
- end
1086
- xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1087
- xmiid_general = prefix + superName
1088
- res = ERB.new(supertype_template)
1089
- t = res.result(binding)
1090
- file.puts t
1091
- when "Hybrid"
1092
- typeProxy = typeProxies[type.name]
1093
- if typeProxy.nil?
1094
- typeProxies[type.name] = type
1095
- end
1096
- when "Remove"
1097
- # do nothing
1098
- end
1099
- end
1100
- else
1101
- for select in type.selectedBy
1102
- if selectTypeType[select.name] != "Remove"
1103
- superName = select.name
1104
- subset = selectSubset[superName]
1105
- if !subset.nil?
1106
- if !subset.include?(type.name)
1107
- selectSubs[superName].each{|e|
1108
- if selectSubset[e].include?(type.name)
1109
- superName = e
1110
- end}
1111
- end
1112
- end
1113
- xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1114
- xmiid_general = prefix + superName
1115
- res = ERB.new(supertype_template)
1116
- t = res.result(binding)
1117
- file.puts t
1118
- end
1119
- end
1120
- end
1121
-
1122
- case domain.class.to_s
1123
- when "EXPSM::TypeSelect"
1124
- when "EXPSM::TypeEnum"
1125
- #Map EXPRESS Where rules
1126
- whererules = type.wheres.select {|w| w.name[0..10] != "encapsulate"}
1127
- if whererules.size > 0
1128
- for where in whererules
1129
- xmiid = '_3_whr' + prefix + type.name + '-' + where.name.to_s
1130
- where_ocl = where.expression.gsub("<>", "&lt;&gt;")
1131
- xmiidref = xmiid_type
1132
- res = ERB.new(where_template)
1133
- t = res.result(binding)
1134
- file.puts t
1135
- end
1136
- end
1137
- else
1138
- #Map EXPRESS Where rules
1139
- whererules = type.wheres.select {|w| w.name[0..10] != "encapsulate"}
1140
- if whererules.size > 0
1141
- for where in whererules
1142
- xmiid = '_3_whr' + prefix + type.name + '-' + where.name.to_s
1143
- where_ocl = get_where(xmiid, where.expression)
1144
- if where_ocl.size > 0
1145
- xmiidref = xmiid_type
1146
- res = ERB.new(where_template)
1147
- t = res.result(binding)
1148
- file.puts t
1149
- else
1150
- puts "Where rule " + type.name + "." + where.name + " not mapped to OCL - ignored!"
1151
- end
1152
- end
1153
- end
1154
-
1155
- put_ops(type.name, file)
1156
- end
1157
-
1158
- res = ERB.new(type_end_template)
1159
- t = res.result(binding)
1160
- file.puts t
1161
- end
1162
-
1163
- aggTypes.each_value do |type|
1164
- if type.schema == schema
1165
- # Evaluate and write aggType start template
1166
- # initialize default cardinailty constraints
1167
- isset = true
1168
- islist = false
1169
-
1170
- upper = type.dimensions[0].upper
1171
- if upper == '?'
1172
- upper = '*'
1173
- end
1174
- lower = type.dimensions[0].lower
1175
- if type.dimensions[0].aggrtype == 'ARRAY'
1176
- puts 'Warning ARRAY not fully supported for '+type.name
1177
- upper = (upper.to_i - lower.to_i + 1).to_s
1178
- lower = upper
1179
- end
1180
- if type.dimensions[0].aggrtype == 'LIST'
1181
- islist = true
1182
- end
1183
- if type.dimensions[0].aggrtype == 'BAG'
1184
- isset = false
1185
- end
1186
- if type.dimensions[0].aggrtype == 'LIST' and !type.dimensions[0].isUnique
1187
- isset = false
1188
- end
1189
-
1190
- xmiid = prefix + type.name
1191
- associationNeeded = false
1192
- if type.isBuiltin
1193
- xmiid_type = $dtprefix + type.domain
1194
- else
1195
- xmiid_type = prefix + type.domain
1196
-
1197
- domain = NamedType.find_by_name( type.domain )
1198
- case domain.class.to_s
1199
- when "EXPSM::Entity"
1200
- associationNeeded = true
1201
- when "EXPSM::Type"
1202
- case selectTypeType[type.domain]
1203
- when "Entity", "Hybrid"
1204
- associationNeeded = true
1205
- end
1206
- when "EXPSM::TypeAggregate"
1207
- if !aggTypes[type.domain].nil?
1208
- associationNeeded = true
1209
- end
1210
- when "EXPSM::TypeSelect"
1211
- case selectTypeType[type.domain]
1212
- when "Entity", "Hybrid"
1213
- associationNeeded = true
1214
- end
1215
- end
1216
- end
1217
-
1218
- type_name = type.name
1219
- res = ERB.new(aggtype_start_template)
1220
- t = res.result(binding)
1221
- file.puts t
1222
-
1223
- # Map TYPE Select has Entity as item
1224
- for select in type.selectedBy
1225
- superName = select.name
1226
- subset = selectSubset[superName]
1227
- if !subset.nil?
1228
- if !subset.include?(type.name)
1229
- selectSubs[superName].each{|e|
1230
- if selectSubset[e].include?(type.name)
1231
- superName = e
1232
- end}
1233
- end
1234
- end
1235
- xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1236
- xmiid_general = prefix + superName
1237
- res = ERB.new(supertype_template)
1238
- t = res.result(binding)
1239
- file.puts t
1240
- end
1241
-
1242
- if associationNeeded
1243
- assoc_xmiid = '_1_association' + prefix + type.name + '-elements'
1244
- end
1245
-
1246
- xmiid = '_2_attr' + prefix + type.name + "-elements"
1247
- res = ERB.new(aggtype_attribute)
1248
- t = res.result(binding)
1249
- file.puts t
1250
-
1251
- res = ERB.new(multiplicity,0,"<>")
1252
- t = res.result(binding)
1253
- if !t.nil? && t.size>0
1254
- file.puts t
1255
- end
1256
-
1257
- res = ERB.new(attribute_end)
1258
- t = res.result(binding)
1259
- file.puts t
1260
-
1261
- res = ERB.new(type_end_template)
1262
- t = res.result(binding)
1263
- file.puts t
1264
-
1265
- if associationNeeded
1266
- res = ERB.new(aggtype_association)
1267
- t = res.result(binding)
1268
- file.puts t
1269
- end
1270
- end
1271
- end
1272
-
1273
- # Map EXPRESS Enumeration Types
1274
- enum_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::TypeEnum }
1275
- for enum in enum_list
1276
-
1277
- superenum = enum.extends_item
1278
- general = nil
1279
- if !superenum.nil?
1280
- if superenum.kind_of? EXPSM::TypeEnum
1281
- # Write Enum Item template for parent (maps to UML same as EXPRESS supertype)
1282
- gen_xmiid = '_2_superenum' + prefix + enum.name + '-' + superenum.name
1283
- xmiid_general = get_prefix.call(superenum.schema) + superenum.name
1284
- general = superenum.name
1285
- end
1286
- end
1287
- # Evaluate and write TYPE Enum start template
1288
- xmiid = prefix + enum.name
1289
- res = ERB.new(enum_start_template)
1290
- t = res.result(binding)
1291
- file.puts t
1292
-
1293
- # Map TYPE Select has Enum as item
1294
- for select in enum.selectedBy
1295
- # sort out what type of select we are dealing with
1296
- case selectTypeType[select.name]
1297
- when "Type"
1298
- superName = select.name
1299
- subset = selectSubset[superName]
1300
- if !subset.nil?
1301
- if !subset.include?(enum.name)
1302
- selectSubs[superName].each{|e|
1303
- if selectSubset[e].include?(enum.name)
1304
- superName = e
1305
- end}
1306
- end
1307
- end
1308
- xmiid = '_2_selectitem' + prefix + enum.name + '-' + superName
1309
- xmiid_general = prefix + superName
1310
- res = ERB.new(supertype_template)
1311
- t = res.result(binding)
1312
- file.puts t
1313
- when "Hybrid"
1314
- typeProxy = typeProxies[enum.name]
1315
- if typeProxy.nil?
1316
- typeProxies[enum.name] = enum
1317
- end
1318
- when "Remove"
1319
- # do nothing
1320
- end
1321
- end
1322
-
1323
- # Evaluate and write Enum Item template for each item
1324
- enumitem_name_list = enum.items.scan(/\w+/)
1325
- for enumitem in enumitem_name_list
1326
- enumitem_xmiid = '_1_enumitem' + prefix + enum.name + '-' + enumitem
1327
- res = ERB.new(enum_item_template)
1328
- t = res.result(binding)
1329
- file.puts t
1330
- end
1331
-
1332
- # Evaluate and write TYPE Enum end template
1333
- res = ERB.new(enum_end_template)
1334
- t = res.result(binding)
1335
- file.puts t
1336
- end
1337
-
1338
- # Map EXPRESS TYPE Selects
1339
- select_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::TypeSelect }
1340
- for type in select_list
1341
- if selectTypeType[type.name] != "Remove"
1342
- # Evaluate and write TYPE Select start template
1343
- xmiid = prefix + type.name
1344
- res = ERB.new(select_start_template)
1345
- t = res.result(binding)
1346
- file.puts t
1347
-
1348
- # Deal with ad-hoc subtype constraints on entities
1349
- superentities = specialSelects[type.name]
1350
- if !superentities.nil?
1351
- superentities.each {|superentity|
1352
- xmiid = '_2_superentity' + prefix + type.name + '-' + superentity.name
1353
- xmiid_general = get_prefix.call(superentity.schema) + superentity.name
1354
- res = ERB.new(supertype_template)
1355
- t = res.result(binding)
1356
- file.puts t}
1357
- end
1358
-
1359
- superselect = type.extends_item
1360
- if !superselect.nil?
1361
- if superselect.kind_of? EXPSM::TypeSelect
1362
- if !superentities.include?(superselect)
1363
- # Write Select Item template for parent (maps to UML same as EXPRESS supertype)
1364
- xmiid = '_2_superselect' + prefix + type.name + '-' + superselect.name
1365
- xmiid_general = get_prefix.call(superselect.schema) + superselect.name
1366
- res = ERB.new(supertype_template)
1367
- t = res.result(binding)
1368
- file.puts t
1369
- end
1370
- end
1371
- end
1372
-
1373
- # Evaluate and write Select Item template for each item (maps to UML same as EXPRESS supertype)
1374
- if selectTypeType[type.name] == "Type"
1375
- for superselect in type.selectedBy
1376
- case selectTypeType[superselect.name]
1377
- when "Hybrid"
1378
- typeProxy = typeProxies[type.name]
1379
- if typeProxy.nil?
1380
- typeProxies[type.name] = type
1381
- end
1382
- when "Remove"
1383
- # do nothing
1384
- else
1385
- superName = superselect.name
1386
- subset = selectSubset[superselect.name]
1387
- if !subset.nil?
1388
- if !subset.include?(type.name)
1389
- selectSubs[superselect.name].each{|e|
1390
- if selectSubset[e].include?(type.name)
1391
- superName = e
1392
- end}
1393
- end
1394
- end
1395
- if superentities.nil? || superentities.all?{|superentity| superentity.name != superName}
1396
- xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1397
- xmiid_general = prefix + superName
1398
- res = ERB.new(supertype_template)
1399
- t = res.result(binding)
1400
- file.puts t
1401
- end
1402
- end
1403
- end
1404
- else
1405
- for superselect in type.selectedBy
1406
- if selectTypeType[superselect.name] !="Remove"
1407
- superName = superselect.name
1408
- subset = selectSubset[superselect.name]
1409
- if !subset.nil?
1410
- if !subset.include?(type.name)
1411
- selectSubs[superselect.name].each{|e|
1412
- if selectSubset[e].include?(type.name)
1413
- superName = e
1414
- end}
1415
- end
1416
- end
1417
- if superentities.nil? || superentities.all?{|superentity| superentity.name != superName}
1418
- xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1419
- xmiid_general = prefix + superName
1420
- res = ERB.new(supertype_template)
1421
- t = res.result(binding)
1422
- file.puts t
1423
- end
1424
- end
1425
- end
1426
- end
1427
-
1428
- # Evaluate and write TYPE Select end template
1429
- res = ERB.new(select_end_template)
1430
- t = res.result(binding)
1431
- file.puts t
1432
- end
1433
- end
1434
-
1435
- typeProxies.each_value do |type|
1436
- if type.schema == schema
1437
- # Evaluate and write proxy start template
1438
- xmiid_type = prefix + type.name
1439
- xmiid = xmiid_type + "_Proxy"
1440
- res = ERB.new(proxy_start_template)
1441
- t = res.result(binding)
1442
- file.puts t
1443
-
1444
- # Map TYPE Select has Entity as item
1445
- for select in type.selectedBy
1446
- if selectTypeType[select.name] == "Hybrid"
1447
- superName = select.name
1448
- subset = selectSubset[superName]
1449
- if !subset.nil?
1450
- if !subset.include?(type.name)
1451
- selectSubs[superName].each{|e|
1452
- if selectSubset[e].include?(type.name)
1453
- superName = e
1454
- end}
1455
- end
1456
- end
1457
- xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1458
- xmiid_general = prefix + superName
1459
- res = ERB.new(supertype_template)
1460
- t = res.result(binding)
1461
- file.puts t
1462
- end
1463
- end
1464
-
1465
- res = ERB.new(type_end_template)
1466
- t = res.result(binding)
1467
- file.puts t
1468
- end
1469
- end
1470
-
1471
- entity_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Entity }
1472
-
1473
- # Map EXPRESS Explicit Attribute resulting UML Association (the Association is referenced from Class resulting from Entity)
1474
- for entity in entity_list
1475
- attr_list = entity.attributes.find_all{ |e| e.kind_of? EXPSM::Explicit }
1476
- for attr in attr_list
1477
-
1478
- domain_name = attr.domain
1479
- orig_domain = NamedType.find_by_name(domain_name)
1480
- attr_domain = orig_domain
1481
- agg_domain = nil
1482
- attrType = nil
1483
- associationNeeded = false
1484
- begin
1485
- unchanged = true
1486
- case attr_domain.class.to_s
1487
- when "EXPSM::Entity"
1488
- associationNeeded = true
1489
- when "EXPSM::Type"
1490
- case selectTypeType[domain_name]
1491
- when "Entity", "Hybrid"
1492
- associationNeeded = true
1493
- end
1494
- #ignore unhandled named aggregations
1495
- when "EXPSM::TypeAggregate"
1496
- if aggTypes[domain_name].nil?
1497
- attrType = attr_domain
1498
- agg_domain = attr_domain
1499
- if attr_domain.isBuiltin
1500
- domain_name = attr_domain.domain
1501
- attr_domain = nil
1502
- else
1503
- domain_name = attr_domain.domain
1504
- attr_domain = NamedType.find_by_name(domain_name)
1505
- unchanged = false
1506
- end
1507
- else
1508
- associationNeeded = true
1509
- end
1510
- when "EXPSM::TypeSelect"
1511
- case selectTypeType[domain_name]
1512
- when "Entity", "Hybrid"
1513
- associationNeeded = true
1514
- # ignore removed select types
1515
- when "Remove"
1516
- attr_domain = attr_domain.selectitems_array[0]
1517
- domain_name = attr_domain.name
1518
- unchanged = false
1519
- end
1520
- end
1521
- end until unchanged
1522
-
1523
- if attr.instance_of? EXPSM::ExplicitAggregate
1524
- attrType = attr
1525
- end
1526
-
1527
- if !attrType.nil?
1528
- if attrType.rank > 1
1529
- associationNeeded = true
1530
- for i in 2..attrType.rank
1531
- domain_name = attrType.dimensions[i-1].aggrtype+domain_name
1532
- end
1533
- end
1534
- end
1535
-
1536
- if associationNeeded
1537
- xmiid = '_1_association' + prefix + entity.name + '-' + attr.name
1538
- attr_xmiid = '_2_attr' + prefix + entity.name + '-' + attr.name
1539
- owner_xmiid = prefix + entity.name
1540
- if attr_domain.nil?
1541
- domain_xmiid = prefix + domain_name
1542
- else
1543
- domain_xmiid = get_prefix.call(attr_domain.schema) + attr_domain.name
1544
- end
1545
-
1546
- general_exists = false
1547
- if attr.redeclare_entity
1548
- general_exists = true
1549
- redeclare_entity = NamedType.find_by_name( attr.redeclare_entity )
1550
- general_xmiid = '_2_general' + prefix + entity.name + '-' + attr.name
1551
- if attr.redeclare_oldname
1552
- redefined_xmiid = '_1_association' + get_prefix.call(redeclare_entity.schema) + attr.redeclare_entity + '-' + attr.redeclare_oldname
1553
- else
1554
- redefined_xmiid = '_1_association' + get_prefix.call(redeclare_entity.schema) + attr.redeclare_entity + '-' + attr.name
1555
- end
1556
- end
1557
-
1558
- # check if inverse refers to this attribute, affects how association is written
1559
- inverse_exists = false
1560
- direct_inverse = false
1561
- for inverse in all_inverse_list
1562
- if inverse.reverseAttr == attr
1563
- if attr.domain == inverse.entity.name
1564
- iattr_xmiid = '_2_attr' + get_prefix.call(inverse.entity.schema) + inverse.entity.name + '-' + inverse.name
1565
- direct_inverses.push inverse
1566
- all_inverse_list.delete inverse
1567
- if !inverse.instance_of? EXPSM::InverseAggregate
1568
- direct_inverse = true
1569
- end
1570
- inverse_exists = true
1571
- end
1572
- end
1573
- end
1574
-
1575
- encapsulated = false
1576
- if !attr_domain.nil?
1577
- if attr_domain == orig_domain
1578
- encapsulated = isEncapsulated(attr_domain, attr)
1579
- else
1580
- if !agg_domain.nil?
1581
- encapsulated = isEncapsulated(agg_domain, attr)
1582
- end
1583
- if !encapsulated
1584
- encapsulated = isEncapsulated(attr_domain, attr)
1585
- if !encapsulated
1586
- encapsulated = isEncapsulated(orig_domain, attr)
1587
- end
1588
- end
1589
- end
1590
- end
1591
-
1592
- encapsulatedInto = false
1593
- if !inverse_exists
1594
- encapsulatedInto = isEncapsulatedInto(entity, entity, attr)
1595
- end
1596
-
1597
- res = ERB.new(attribute_entity_association_template)
1598
- t = res.result(binding)
1599
- file.puts t
1600
- end
1601
- end
1602
- end
1603
-
1604
- # Map EXPRESS Inverse Attribute resulting UML Association (the Association is referenced from Class resulting from Entity)
1605
- for inverse in all_inverse_list
1606
- if inverse.entity.schema == schema
1607
- temp_id = get_prefix.call(inverse.entity.schema) + inverse.entity.name + '-' + inverse.name
1608
- xmiid = '_1_association' + temp_id
1609
- owner_xmiid = get_prefix.call(inverse.entity.schema) + inverse.entity.name
1610
- iattr_xmiid = '_2_attr' + temp_id
1611
-
1612
- general_xmiid = '_2_general' + temp_id
1613
- redefined_xmiid = '_1_association' + get_prefix.call(inverse.reverseAttr.entity.schema) + inverse.reverseAttr.entity.name + '-' + inverse.reverseAttr_id
1614
-
1615
- lower = '1'
1616
- upper = '1'
1617
- if inverse.reverseAttr.instance_of? EXPSM::ExplicitAggregate
1618
- if inverse.reverseAttr.rank == 1
1619
- upper = inverse.reverseAttr.dimensions[0].upper
1620
- if upper == '?'
1621
- upper = '*'
1622
- end
1623
- lower = inverse.reverseAttr.dimensions[0].lower
1624
- end
1625
- end
1626
- if inverse.reverseAttr.isOptional
1627
- lower = '0'
1628
- end
1629
- res = ERB.new(inverse_entity_association_template)
1630
- t = res.result(binding)
1631
- file.puts t
1632
-
1633
- res = ERB.new(multiplicity,0,"<>")
1634
- t = res.result(binding)
1635
- if !t.nil? && t.size>0
1636
- file.puts t
1637
- end
1638
-
1639
- res = ERB.new(inverse_entity_association_end)
1640
- t = res.result(binding)
1641
- file.puts t
1642
- end
1643
- end
1644
-
1645
- # Map EXPRESS Entity Types
1646
- for entity in entity_list
1647
- lowBounds = Hash.new
1648
-
1649
- # Evaluate and write ENTITY start template
1650
- xmiid = prefix + entity.name
1651
- xmiid_entity = xmiid
1652
- res = ERB.new(entity_start_template)
1653
- t = res.result(binding)
1654
- file.puts t
1655
-
1656
-
1657
- # Map Entity is SUBTYPE OF (i.e. list of supertypes)
1658
- for supertype in entity.supertypes_array
1659
- xmiid = '_2_supertype' + prefix + entity.name + '-' + supertype.name
1660
- xmiid_general = get_prefix.call(supertype.schema) + supertype.name
1661
- res = ERB.new(supertype_template)
1662
- t = res.result(binding)
1663
- file.puts t
1664
- end
1665
-
1666
- # Map TYPE Select has Entity as item
1667
- for select in entity.selectedBy
1668
- if selectTypeType[select.name] != "Remove"
1669
- superName = select.name
1670
- subset = selectSubset[superName]
1671
- if !subset.nil?
1672
- if !subset.include?(entity.name)
1673
- selectSubs[superName].each{|e|
1674
- if selectSubset[e].include?(entity.name)
1675
- superName = e
1676
- end}
1677
- end
1678
- end
1679
- xmiid = '_2_selectitem' + prefix + entity.name + '-' + superName
1680
- xmiid_general = prefix + superName
1681
- res = ERB.new(supertype_template)
1682
- t = res.result(binding)
1683
- file.puts t
1684
- else
1685
- # if in a select list that has been removed make it a subtype of all selects that include the removed select
1686
- for superselect in all_select_list
1687
- if superselect.selectitems_array.include?(select)
1688
- superName = superselect.name
1689
- subset = selectSubset[superName]
1690
- if !subset.nil?
1691
- if !subset.include?(select.name)
1692
- selectSubs[superName].each{|e|
1693
- if selectSubset[e].include?(select.name)
1694
- superName = e
1695
- end}
1696
- end
1697
- end
1698
- puts entity.name + " added to " + superName
1699
- puts " following removal of " + select.name
1700
- xmiid = '_2_selectitem' + prefix + entity.name + '-' + superName
1701
- xmiid_general = prefix + superName
1702
- res = ERB.new(supertype_template)
1703
- t = res.result(binding)
1704
- file.puts t
1705
- end
1706
- end
1707
- end
1708
- end
1709
-
1710
- # Map EXPRESS Explicit Attributes
1711
- attr_list = entity.attributes.find_all{ |e| e.kind_of? EXPSM::Explicit }
1712
- for attr in attr_list
1713
- xmiid = '_2_attr' + prefix + entity.name + '-' + attr.name
1714
-
1715
- # set up references resulting from attribute being a redeclaration
1716
- if attr.redeclare_entity
1717
- redeclare_entity = NamedType.find_by_name( attr.redeclare_entity )
1718
- if attr.redeclare_oldname
1719
- redefined_xmiid = '_2_attr' + get_prefix.call(redeclare_entity.schema) + attr.redeclare_entity + '-' + attr.redeclare_oldname
1720
- else
1721
- redefined_xmiid = '_2_attr' + get_prefix.call(redeclare_entity.schema) + attr.redeclare_entity + '-' + attr.name
1722
- end
1723
- end
1724
-
1725
- # initialize default cardinailty constraints
1726
- lower = '1'
1727
- upper = '1'
1728
- isset = true
1729
- islist = false
1730
-
1731
- domain_name = attr.domain
1732
- orig_domain = NamedType.find_by_name( attr.domain )
1733
- attr_domain = orig_domain
1734
- agg_domain = nil
1735
- attrType = nil
1736
- associationNeeded = false
1737
- begin
1738
- unchanged = true
1739
- case attr_domain.class.to_s
1740
- when "EXPSM::Entity"
1741
- associationNeeded = true
1742
- when "EXPSM::Type"
1743
- case selectTypeType[attr_domain.name]
1744
- when "Entity", "Hybrid"
1745
- associationNeeded = true
1746
- end
1747
- #ignore unhandled named aggregations
1748
- when "EXPSM::TypeAggregate"
1749
- if aggTypes[attr.domain].nil?
1750
- attrType = attr_domain
1751
- agg_domain = attr_domain
1752
- if attr_domain.isBuiltin
1753
- domain_name = attr_domain.domain
1754
- attr_domain = nil
1755
- else
1756
- newDomain = NamedType.find_by_name( attr_domain.domain )
1757
- attr_domain = newDomain
1758
- domain_name = attr_domain.name
1759
- unchanged = false
1760
- end
1761
- else
1762
- associationNeeded = true
1763
- end
1764
- when "EXPSM::TypeSelect"
1765
- case selectTypeType[attr_domain.name]
1766
- when "Entity", "Hybrid"
1767
- associationNeeded = true
1768
- # ignore removed select types
1769
- when "Remove"
1770
- attr_domain = attr_domain.selectitems_array[0]
1771
- domain_name = attr_domain.name
1772
- unchanged = false
1773
- end
1774
- end
1775
- end until unchanged
1776
-
1777
- # set up cardinailty constraints from attribute being a 1-D aggregate
1778
- # or a type defined to be a 1-D aggregate
1779
- if attr.instance_of? EXPSM::ExplicitAggregate
1780
- attrType = attr
1781
- end
1782
-
1783
- if !attrType.nil?
1784
- upper = attrType.dimensions[0].upper
1785
- if upper == '?'
1786
- upper = '*'
1787
- end
1788
- lower = attrType.dimensions[0].lower
1789
- if attrType.dimensions[0].aggrtype == 'ARRAY'
1790
- puts 'Warning ARRAY not fully supported for '+attr.name
1791
- end
1792
- if attrType.dimensions[0].aggrtype == 'LIST'
1793
- islist = true
1794
- end
1795
- if attrType.dimensions[0].aggrtype == 'BAG'
1796
- isset = false
1797
- end
1798
- if attrType.dimensions[0].aggrtype == 'LIST' and !attrType.dimensions[0].isUnique
1799
- isset = false
1800
- end
1801
- if attrType.rank > 1
1802
- associationNeeded = true
1803
- for i in 2..attrType.rank
1804
- domain_name = attrType.dimensions[i-1].aggrtype+domain_name+lower+upper
1805
- nestedAggs[domain_name] = attrType.dimensions[i-1]
1806
- nestedTypes[domain_name] = attrType
1807
- end
1808
- end
1809
- end
1810
- if attr.isOptional
1811
- case lower
1812
- when '0','1'
1813
- else
1814
- lowBounds[attr.name] = lower
1815
- end
1816
- lower = '0'
1817
- end
1818
-
1819
- # Map EXPRESS Explicit Attributes that need an association
1820
- if associationNeeded
1821
- if attr_domain.nil?
1822
- domain_xmiid = prefix + domain_name
1823
- else
1824
- domain_xmiid = get_prefix.call(attr_domain.schema) + domain_name
1825
- end
1826
- assoc_xmiid = '_1_association' + prefix + entity.name + '-' + attr.name
1827
-
1828
- direct_inverse = false
1829
- encapsulatedInto = false
1830
- for inverse in direct_inverses
1831
- if inverse.reverseAttr == attr
1832
- if !inverse.instance_of? EXPSM::InverseAggregate
1833
- direct_inverse = true
1834
- encapsulatedInto = isEncapsulatedInto(entity, entity, attr)
1835
- end
1836
- end
1837
- end
1838
-
1839
- if !attr_domain.nil?
1840
- if attr_domain == orig_domain
1841
- encapsulated = isEncapsulated(attr_domain, attr)
1842
- else
1843
- if !agg_domain.nil?
1844
- encapsulated = isEncapsulated(agg_domain, attr)
1845
- else
1846
- encapsulated = false
1847
- end
1848
- if !encapsulated
1849
- encapsulated = isEncapsulated(attr_domain, attr)
1850
- if !encapsulated
1851
- encapsulated = isEncapsulated(orig_domain, attr)
1852
- end
1853
- end
1854
- end
1855
- end
1856
-
1857
- res = ERB.new(attribute_entity_template,0,"<>")
1858
- t = res.result(binding)
1859
- file.puts t
1860
- else
1861
- # Map EXPRESS Explicit Attributes of Builtin
1862
- if attr.isBuiltin or (attr_domain.nil?)
1863
- res = ERB.new(attribute_builtin_template,0,"<>")
1864
- t = res.result(binding)
1865
- file.puts t
1866
- else
1867
- # Map EXPRESS Explicit Attributes of TYPE, TYPE Enum and TYPE Select (type)
1868
- type_xmiid = get_prefix.call(attr_domain.schema) + domain_name
1869
- res = ERB.new(attribute_enum_type_template,0,"<>")
1870
- t = res.result(binding)
1871
- file.puts t
1872
- end
1873
- end
1874
-
1875
- res = ERB.new(multiplicity,0,"<>")
1876
- t = res.result(binding)
1877
- if !t.nil? && t.size>0
1878
- file.puts t
1879
- end
1880
-
1881
- res = ERB.new(attribute_end)
1882
- t = res.result(binding)
1883
- file.puts t
1884
- end
1885
-
1886
- #Map EXPRESS Inverse Attributes
1887
- inverse_attr_list = entity.attributes.find_all{ |e| e.kind_of? EXPSM::Inverse }
1888
- for inverse in inverse_attr_list
1889
- xmiid = '_2_attr' + prefix + entity.name + '-' + inverse.name
1890
- # set up references resulting from attribute being a redeclaration
1891
- if inverse.redeclare_entity
1892
- if inverse.redeclare_oldname
1893
- redefined_xmiid = '_2_attr' + prefix + inverse.redeclare_entity + '-' + inverse.redeclare_oldname
1894
- else
1895
- redefined_xmiid = '_2_attr' + prefix + inverse.redeclare_entity + '-' + inverse.name
1896
- end
1897
- end
1898
-
1899
- lower = '1'
1900
- upper = '1'
1901
- isset = true
1902
- if inverse.instance_of? EXPSM::InverseAggregate
1903
- lower = '0'
1904
- upper = '*'
1905
- if inverse.upper != '?'
1906
- upper = inverse.upper
1907
- end
1908
- if inverse.lower != '0'
1909
- lower = inverse.lower
1910
- end
1911
- if inverse.aggrtype == 'BAG'
1912
- isset = false
1913
- end
1914
- end
1915
- domain_xmiid = prefix + inverse.reverseEntity.name
1916
- if all_inverse_list.include?(inverse)
1917
- assoc_xmiid = '_1_association' + get_prefix.call(inverse.reverseEntity.schema) + entity.name + '-' + inverse.name
1918
- else
1919
- if inverse.reverseAttr.domain == entity.name
1920
- assoc_xmiid = '_1_association' + get_prefix.call(inverse.reverseEntity.schema) + inverse.reverseEntity.name + '-' + inverse.reverseAttr_id
1921
- else
1922
- assoc_xmiid = '_1_association' + get_prefix.call(inverse.reverseEntity.schema) + entity.name + '-' + inverse.reverseAttr_id
1923
- end
1924
- end
1925
-
1926
- encapsulatedInto = isEncapsulatedInto(inverse.reverseEntity, inverse.reverseEntity, inverse.reverseAttr)
1927
-
1928
- res = ERB.new(inverse_attribute_template)
1929
- t = res.result(binding)
1930
- file.puts t
1931
-
1932
- res = ERB.new(multiplicity,0,"<>")
1933
- t = res.result(binding)
1934
- if !t.nil? && t.size>0
1935
- file.puts t
1936
- end
1937
-
1938
- res = ERB.new(attribute_end)
1939
- t = res.result(binding)
1940
- file.puts t
1941
- end
1942
-
1943
- # Create lower bound constraints where required
1944
- lowBounds.each do |name, bound|
1945
- xmiid = '_3_lb' + prefix + entity.name + '-' + name
1946
- res = ERB.new(bound_constraint)
1947
- t = res.result(binding)
1948
- file.puts t
1949
- end
1950
-
1951
- # Map EXPRESS Unique rules
1952
- if entity.uniques.size > 0
1953
- for unique in entity.uniques
1954
- xmiid = '_3_uniq' + prefix + entity.name + '-' + unique.name
1955
- if unique.attributes.size == 1
1956
- unique_text = unique.attributes[0]
1957
- else
1958
- unique_text = 'Sequence{'+ unique.attributes.join(', ') +'}'
1959
- end
1960
- res = ERB.new(unique_template)
1961
- t = res.result(binding)
1962
- file.puts t
1963
- end
1964
- end
1965
-
1966
- # Map EXPRESS Where rules
1967
- whererules = entity.wheres.select {|w| w.name[0..10] != "encapsulate"}
1968
- if whererules.size > 0
1969
- for where in whererules
1970
- xmiid = '_3_whr' + prefix + entity.name + '-' + where.name.to_s
1971
- where_ocl = get_where(xmiid, where.expression)
1972
- if where_ocl.size > 0
1973
- xmiidref = xmiid_entity
1974
- res = ERB.new(where_template)
1975
- t = res.result(binding)
1976
- file.puts t
1977
- else
1978
- puts "Where rule " + entity.name + "." + where.name.to_s + " not mapped to OCL - ignored!"
1979
- end
1980
- end
1981
- end
1982
-
1983
- # Evaluate and write ENTITY end template
1984
- res = ERB.new(entity_end_template)
1985
- t = res.result(binding)
1986
- file.puts t
1987
- end
1988
-
1989
- nestedAggs.each do |type_name, dimension|
1990
- # Evaluate and write aggType start template
1991
- # initialize default cardinailty constraints
1992
- isset = true
1993
- islist = false
1994
-
1995
- upper = dimension.upper
1996
- if upper == '?'
1997
- upper = '*'
1998
- end
1999
- lower = dimension.lower
2000
- if dimension.aggrtype == 'LIST'
2001
- islist = true
2002
- end
2003
- if dimension.aggrtype == 'BAG'
2004
- isset = false
2005
- end
2006
- if dimension.aggrtype == 'LIST' and !dimension.isUnique
2007
- isset = false
2008
- end
2009
-
2010
- xmiid = prefix + type_name
2011
- type = nestedTypes[type_name]
2012
- associationNeeded = false
2013
-
2014
- if type.isBuiltin
2015
- xmiid_type = $dtprefix + type.domain
2016
- else
2017
- xmiid_type = prefix + type.domain
2018
-
2019
- domain = NamedType.find_by_name( type.domain )
2020
- case domain.class.to_s
2021
- when "EXPSM::Entity"
2022
- associationNeeded = true
2023
- when "EXPSM::Type"
2024
- case selectTypeType[type.domain]
2025
- when "Entity", "Hybrid"
2026
- associationNeeded = true
2027
- end
2028
- when "EXPSM::TypeAggregate"
2029
- if !aggTypes[type.domain].nil?
2030
- associationNeeded = true
2031
- end
2032
- when "EXPSM::TypeSelect"
2033
- case selectTypeType[type.domain]
2034
- when "Entity", "Hybrid"
2035
- associationNeeded = true
2036
- end
2037
- end
2038
- end
2039
- res = ERB.new(aggtype_start_template)
2040
- t = res.result(binding)
2041
- file.puts t
2042
-
2043
- if associationNeeded
2044
- assoc_xmiid = '_1_association' + prefix + type.name + '-elements'
2045
- end
2046
-
2047
- xmiid = '_2_attr' + prefix + type.name + "-elements"
2048
- res = ERB.new(aggtype_attribute)
2049
- t = res.result(binding)
2050
- file.puts t
2051
-
2052
- res = ERB.new(multiplicity,0,"<>")
2053
- t = res.result(binding)
2054
- if !t.nil? && t.size>0
2055
- file.puts t
2056
- end
2057
-
2058
- res = ERB.new(attribute_end)
2059
- t = res.result(binding)
2060
- file.puts t
2061
-
2062
- res = ERB.new(type_end_template)
2063
- t = res.result(binding)
2064
- file.puts t
2065
-
2066
- if associationNeeded
2067
- res = ERB.new(aggtype_association)
2068
- t = res.result(binding)
2069
- file.puts t
2070
- end
2071
- end
2072
-
2073
- # Evaluate and write SCHEMA end template
2074
- res = ERB.new(schema_end_template)
2075
- t = res.result(binding)
2076
- file.puts t
2077
- end
2078
-
2079
- if schema_list.size > 1
2080
- res = ERB.new(package_end)
2081
- t = res.result(binding)
2082
- file.puts t
2083
- end
2084
-
2085
- # Map EXPRESS Entity Types to blocks
2086
- for schema in schema_list
2087
- prefix = get_prefix.call(schema)
2088
-
2089
- entity_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Entity }
2090
-
2091
- for entity in entity_list
2092
- # Evaluate and write ENTITY Block template
2093
- baseClass = prefix + entity.name
2094
- xmiid = baseClass + '-Block'
2095
- res = ERB.new(entity_block_template)
2096
- t = res.result(binding)
2097
- file.puts t
2098
- end
2099
-
2100
- type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::TypeEnum}
2101
- for type in type_list
2102
- # Evaluate and write TYPE ValueType template
2103
- baseType = prefix + type.name
2104
- xmiid = baseType + '-ValueType'
2105
- res = ERB.new(valuetype_template)
2106
- t = res.result(binding)
2107
- file.puts t
2108
- end
2109
-
2110
- type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::Type and e.isBuiltin}
2111
- for type in type_list
2112
- # Evaluate and write TYPE ValueType template
2113
- baseType = prefix + type.name
2114
- xmiid = baseType + '-ValueType'
2115
- res = ERB.new(valuetype_template)
2116
- t = res.result(binding)
2117
- file.puts t
2118
- end
2119
-
2120
- type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::Type and !e.isBuiltin}
2121
- for type in type_list
2122
- superselect = NamedType.find_by_name( type.domain )
2123
- if !superselect.kind_of? EXPSM::TypeSelect
2124
- # Evaluate and write TYPE ValueType template
2125
- baseType = prefix + type.name
2126
- xmiid = baseType + '-ValueType'
2127
- res = ERB.new(valuetype_template)
2128
- t = res.result(binding)
2129
- file.puts t
2130
- end
2131
- end
2132
- end
2133
-
2134
- for select in all_select_list
2135
- case selectTypeType[select.name]
2136
- when "Type"
2137
- # Evaluate and write TYPE ValueType template
2138
- baseType = prefix + select.name
2139
- xmiid = baseType + '-ValueType'
2140
- res = ERB.new(valuetype_template)
2141
- t = res.result(binding)
2142
- file.puts t
2143
- xmiid = baseType + '-Auxiliary'
2144
- res = ERB.new(select_stereotype_template)
2145
- t = res.result(binding)
2146
- file.puts t
2147
- when "Remove"
2148
- # do nothing
2149
- else
2150
- # Evaluate and write ENTITY Block template
2151
- baseClass = prefix + select.name
2152
- xmiid = baseClass + '-Block'
2153
- res = ERB.new(entity_block_template)
2154
- t = res.result(binding)
2155
- file.puts t
2156
- xmiid = baseClass + '-Auxiliary'
2157
- res = ERB.new(select_stereotype_template)
2158
- t = res.result(binding)
2159
- file.puts t
2160
- end
2161
- end
2162
-
2163
- selectSubset.each_key do |select|
2164
- if selectSubs[select].nil?
2165
- case selectTypeType[select]
2166
- when "Type"
2167
- # Evaluate and write TYPE ValueType template
2168
- baseType = prefix + select
2169
- xmiid = baseType + '-ValueType'
2170
- res = ERB.new(valuetype_template)
2171
- t = res.result(binding)
2172
- file.puts t
2173
- xmiid = baseType + '-Auxiliary'
2174
- res = ERB.new(select_stereotype_template)
2175
- t = res.result(binding)
2176
- file.puts t
2177
- when "Remove"
2178
- # do nothing
2179
- else
2180
- # Evaluate and write ENTITY Block template
2181
- baseClass = prefix + select
2182
- xmiid = baseClass + '-Block'
2183
- res = ERB.new(entity_block_template)
2184
- t = res.result(binding)
2185
- file.puts t
2186
- xmiid = baseClass + '-Auxiliary'
2187
- res = ERB.new(select_stereotype_template)
2188
- t = res.result(binding)
2189
- file.puts t
2190
- end
2191
- end
2192
- end
2193
-
2194
- typeProxies.each_value do |type|
2195
- # Evaluate and write ENTITY Block template
2196
- baseClass = prefix + type.name + "_Proxy"
2197
- xmiid = baseClass + '-Block'
2198
- res = ERB.new(entity_block_template)
2199
- t = res.result(binding)
2200
- file.puts t
2201
- xmiid = baseClass + '-Type'
2202
- res = ERB.new(type_stereotype_template)
2203
- t = res.result(binding)
2204
- file.puts t
2205
- end
2206
-
2207
- aggTypes.each_value do |type|
2208
- # Evaluate and write ENTITY Block template
2209
- baseClass = prefix + type.name
2210
- xmiid = baseClass + '-Block'
2211
- res = ERB.new(entity_block_template)
2212
- t = res.result(binding)
2213
- file.puts t
2214
- xmiid = baseClass + '-Type'
2215
- res = ERB.new(type_stereotype_template)
2216
- t = res.result(binding)
2217
- file.puts t
2218
- end
2219
-
2220
- nestedTypes.each_key do |type_name|
2221
- # Evaluate and write ENTITY Block template
2222
- baseClass = prefix + type_name
2223
- xmiid = baseClass + '-Block'
2224
- res = ERB.new(entity_block_template)
2225
- t = res.result(binding)
2226
- file.puts t
2227
- xmiid = baseClass + '-Type'
2228
- res = ERB.new(type_stereotype_template)
2229
- t = res.result(binding)
2230
- file.puts t
2231
- end
2232
-
2233
- if dtHandle != "ignore"
2234
- if dtHandle == "export"
2235
- if !uuidSafe.nil?
2236
- tmp = uuidSafe
2237
- uuidSafe = $uuidxml
2238
- $uuidxml = tmp
2239
- tmp = uuidOldSafe
2240
- uuidOldSafe = $olduuids
2241
- $olduuids = tmp
2242
- end
2243
- end
2244
- res = ERB.new(data_type_stereos)
2245
- t = res.result(binding)
2246
- dtfile.puts t
2247
- if dtHandle == "export"
2248
- res = ERB.new(overall_end_template)
2249
- t = res.result(binding)
2250
- dtfile.puts t
2251
- if !uuidSafe.nil?
2252
- for uuidmap in $olduuids
2253
- uuidmap.remove
2254
- end
2255
- File.open("DataTypes_UUIDs.xml","w"){|file| $uuidxml.write_xml_to file}
2256
- $uuidxml = uuidSafe
2257
- $olduuids = uuidOldSafe
2258
- end
2259
- dtfile.close
2260
- end
2261
- end
2262
-
2263
- # Evaluate and write file end template
2264
- res = ERB.new(overall_end_template)
2265
- t = res.result(binding)
2266
- file.puts t
2267
-
2268
- file.close
2269
-
2270
- if $uuidsRequired
2271
- for uuidmap in $olduuids
2272
- uuidmap.remove
2273
- end
2274
- File.open("UUIDs.xml","w"){|file| $uuidxml.write_xml_to file}
2275
- end
2276
-
2277
- if !$wherexml.nil?
2278
- File.open("WhereRuleMapping.xml","w"){|file| $wherexml.write_xml_to file}
2279
- end
2280
- end
2281
-
1
+ require 'erb'
2
+ require 'uuid'
3
+ require 'nokogiri'
4
+ include Nokogiri
5
+
6
+ # EXPRESS to SysML Mapping
7
+ # Version 0.5
8
+ #
9
+ # This function navigates the EXPRESS STEPMod Model Ruby Classes
10
+ # and performs a structural EXPRESS-to-SysML (1.4) mapping using Ruby ERB templates.
11
+ # The output is in XMI 2.1 or 2.5 syntax in a file named <schema>.xmi if one schema input and 'Model.xmi' if more than one schema input.
12
+ #
13
+ # Real, Number, Integer, Boolean, String -> New Primitive Type
14
+ # Binary, Logical -> New PrimitiveType
15
+ # Schema -> Package
16
+ # Entity (subtype of) -> Class (Generalization) + Block stereotype
17
+ # Select Type -> Class & Generalization + Block/value and <<Auxillary>> stereotype
18
+ # Agg Type -> Collapsed into attribute if just used, converted into class with elements if part of aggregation or select type
19
+ # Enum Type -> Enumeration and EnumerationLiteral
20
+ # Explicit Attribute (Optional) Primitive or Enum -> Property owned by Class (with lower)
21
+ # Explicit Attribute (Optional) Entity -> Property owned by Class (with lower) plus Association owning other end property
22
+ # Explicit Attribute 1-D SET, BAG, LIST of Select or Entity -> Property owned by Class (with lower)
23
+ # plus Association owning other end property and multiplicity, unique and ordered set
24
+ # Explicit Attribute 1-D SET, BAG, LIST of Primitive or Enum -> Property owned by Class and multiplicity, unique and ordered set
25
+ # Higher level aggregations create intermediary blocks
26
+ # Explicit Attribute of Entity/Select/Builtin Redeclaration (Renamed) -> Property with (new) name that redefines inherited Property
27
+ # Inverse Attribute -> Association end adjustment
28
+ # Inverse Attribute Redeclaration (Renamed) -> Property with (new) name that redefines inherited Property
29
+ # USE or REFERENCE (even with named items) -> UML PackageImport between Packages
30
+ #
31
+ #######################################################################################
32
+
33
+ def get_uuid(id)
34
+ if $uuidsRequired
35
+ uuidmap = $uuidxml.xpath('//uuidmap[@id="' + id + '"]').first
36
+ if !uuidmap.nil?
37
+ $olduuids.delete uuidmap
38
+ return ' xmi:uuid="' + uuidmap.attributes["uuid"].to_s.strip + '"'
39
+ else
40
+ theUUID = $uuid.generate
41
+ uuidtext = theUUID.to_s.strip
42
+ uuidmap = Nokogiri::XML::Node.new("uuidmap", $uuidxml)
43
+ uuidmap['id'] = id
44
+ uuidmap['uuid'] = theUUID
45
+ $uuidxml.root.add_child uuidmap
46
+ return ' xmi:uuid="' + theUUID + '"'
47
+ end
48
+ else
49
+ return ""
50
+ end
51
+ end
52
+
53
+ def get_where(id,rule)
54
+ if !$wherexml.nil?
55
+ wheremap = $wherexml.xpath('//wheremap[@id="' + id + '"]').first
56
+ if !wheremap.nil?
57
+ return wheremap.at("OCL").inner_html
58
+ else
59
+ wheremap = Nokogiri::XML::Node.new("wheremap", $wherexml)
60
+ wheremap['id'] = id
61
+ express = Nokogiri::XML::Node.new("EXPRESS", $wherexml)
62
+ express.content = rule
63
+ wheremap.add_child express
64
+ ocl = Nokogiri::XML::Node.new("OCL", $wherexml)
65
+ wheremap.add_child ocl
66
+ $wherexml.root.add_child wheremap
67
+ return ""
68
+ end
69
+ else
70
+ return ""
71
+ end
72
+ end
73
+
74
+ def put_ops(name, file)
75
+ # operation template
76
+ operation_template = %{<ownedOperation xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Operation">
77
+ <name><%= op_name %></name>
78
+ <ownedRule xmi:id="<%= xmiid %>-body"<%= get_uuid(xmiid+'-body') %> xmi:type="uml:Constraint">
79
+ <specification xmi:id="<%= xmiid %>-spec"<%= get_uuid(xmiid+'-spec') %> xmi:type="uml:OpaqueExpression">
80
+ <body><%= op_ocl %></body>
81
+ <language>OCL2.0</language>
82
+ </specification>
83
+ </ownedRule>}
84
+
85
+ parameter_template = %{<ownedParameter xmi:id="<%= par_xmiid %>"<%= get_uuid(par_xmiid) %> xmi:type="uml:Parameter">
86
+ <name><%= par_name %></name>
87
+ <type xmi:idref="<%= par_type %>"/>
88
+ </ownedParameter>}
89
+
90
+ return_template = %{<ownedParameter xmi:id="<%= xmiid %>-return"<%= get_uuid(xmiid+'-return') %> xmi:type="uml:Parameter">
91
+ <direction>return</direction>
92
+ <type xmi:idref="<%= ret_type %>"/>
93
+ </ownedParameter>}
94
+
95
+ operation_end = %{</ownedOperation>}
96
+
97
+ if !$opsxml.nil?
98
+ ops = $opsxml.xpath('//operation[@for="' + name + '"]')
99
+ for op in ops
100
+ body = op.at('body')
101
+ if !body.nil?
102
+ op_ocl = body.content
103
+ op_name = op['name']
104
+ ret_type = op['type']
105
+ xmiid = '_2_op_' + name + '_' + op_name
106
+ res = ERB.new(operation_template)
107
+ t = res.result(binding)
108
+ file.puts t
109
+
110
+ params = op.xpath('./param')
111
+ for param in params
112
+ par_name = param['name']
113
+ par_xmiid = xmiid + '-' + par_name
114
+ par_type = param['type']
115
+ res = ERB.new(parameter_template)
116
+ t = res.result(binding)
117
+ file.puts t
118
+ end
119
+ res = ERB.new(return_template)
120
+ t = res.result(binding)
121
+ file.puts t
122
+ res = ERB.new(operation_end)
123
+ t = res.result(binding)
124
+ file.puts t
125
+ else
126
+ puts 'Operation ' + name + '.' + op['name'] + ' has no body - ignored!'
127
+ end
128
+ end
129
+ end
130
+ end
131
+
132
+ def isEncapsulated (type, attrib)
133
+ encapsulated = false
134
+ rules = type.wheres.select {|w| w.name == "encapsulated"}
135
+ if rules.length > 0
136
+ for rule in rules
137
+ if rule.expression == "SIZEOF(USEDIN(SELF, '')) = 1"
138
+ encapsulated = true
139
+ elsif rule.expression == "SIZEOF(QUERY(elem <* SELF | SIZEOF(USEDIN(elem, '')) = 1)) = SIZEOF(SELF)"
140
+ encapsulated = true
141
+ elsif rule.expression[0..24] == "SIZEOF(USEDIN(SELF, '') -"
142
+ encapsulated = !(rule.expression[25..-1].include? ("." + attrib.entity.name.upcase + "." + attrib.name.upcase))
143
+ else
144
+ puts "Unknown encapsulated rule: " + rule.expression
145
+ end
146
+ if encapsulated
147
+ break
148
+ end
149
+ end
150
+ end
151
+ if (type.kind_of? EXPSM::Entity) && !encapsulated
152
+ for supertype in type.supertypes_array
153
+ encapsulated = isEncapsulated(supertype, attrib)
154
+ if encapsulated
155
+ break
156
+ end
157
+ end
158
+ end
159
+ return encapsulated
160
+ end
161
+
162
+ def isEncapsulatedInto (parent, entity, attrib)
163
+ encapsulated = false
164
+ rules = parent.wheres.select {|w| w.name == "encapsulateInto"}
165
+ if rules.length > 0
166
+ for rule in rules
167
+ ruleString = rule.expression.upcase
168
+ if ruleString[0..6] == "EXISTS("
169
+ closeParen = ruleString.index(')')
170
+ if ruleString[closeParen..-1].include? " XOR (SIZEOF(TYPEOF(SELF) *"
171
+ if !ruleString[closeParen+28..-1].include? ('.'+entity.name.upcase+'''')
172
+ encapsulated = (ruleString[6..closeParen].include? ('('+attrib.name.upcase+')'))
173
+ end
174
+ else
175
+ encapsulated = (ruleString[6..closeParen].include? ('('+attrib.name.upcase+')'))
176
+ end
177
+ else
178
+ puts "Unknown encapsulateInto rule: " + rule.expression
179
+ end
180
+ if encapsulated
181
+ break
182
+ end
183
+ end
184
+ end
185
+ if !encapsulated
186
+ for supertype in parent.supertypes_array
187
+ encapsulated = isEncapsulatedInto(supertype, entity, attrib)
188
+ if encapsulated
189
+ break
190
+ end
191
+ end
192
+ end
193
+ return encapsulated
194
+ end
195
+
196
+ def map_from_express(mapinput, passedArgs)
197
+ # Enter file name here to override defaults (<schema>.xmi if one schema, and Model.xmi if more than one)
198
+ output_xmi_filename = nil
199
+
200
+ noprune = false
201
+ schemaId = false
202
+ $uuidsRequired = true
203
+ xmiVersion = "2.1"
204
+ dtHandle = "local"
205
+ outPath = nil
206
+ for arg in passedArgs
207
+ argarray = arg.split('=')
208
+ case argarray[0]
209
+ when "noprune" then noprune = true
210
+ when "nouuids" then $uuidsRequired = false
211
+ when "path" then outPath = argarray[1]
212
+ when "schemaid" then schemaId = true
213
+ when "xmi" then xmiVersion = argarray[1]
214
+ when "types" then dtHandle = argarray[1]
215
+ end
216
+ end
217
+
218
+ case xmiVersion
219
+ when "2.1" then $StandardProfile = "StandardProfileL2"
220
+ when "2.5" then $StandardProfile = "StandardProfile"
221
+ else
222
+ puts "XMI version "+xmiVersion+" is not handled!"
223
+ exit
224
+ end
225
+
226
+ case dtHandle
227
+ when "local"
228
+ puts "Data types will generated within the package structure"
229
+ when "ignore"
230
+ puts "Data types will not be generated"
231
+ when "export"
232
+ puts "Data types will be exported to DataTypes.xmi"
233
+ else
234
+ puts "Data type handling option: "+dtHandle+" not valid!"
235
+ exit
236
+ end
237
+
238
+ if dtHandle != "local"
239
+ if outPath.nil?
240
+ puts "path must be specified when type=" + dtHandle
241
+ exit
242
+ end
243
+ end
244
+
245
+ uuidSafe = nil
246
+ uuidOldSafe = nil
247
+ if $uuidsRequired
248
+ $uuid = UUID.new
249
+ if File.exists?("UUIDs.xml")
250
+ uuidfile = File.open("UUIDs.xml")
251
+ $uuidxml = Nokogiri::XML(uuidfile, &:noblanks)
252
+ uuidfile.close
253
+ else
254
+ $uuidxml = Nokogiri::XML::Builder.new { |b| b.uuids }.doc
255
+ end
256
+ $olduuids = $uuidxml.xpath('//uuidmap')
257
+ end
258
+
259
+ if File.exists?("WhereRuleMapping.xml")
260
+ wherefile = File.open("WhereRuleMapping.xml")
261
+ $wherexml = Nokogiri::XML(wherefile, &:noblanks)
262
+ wherefile.close
263
+ end
264
+
265
+ if File.exists?("Operators.xml")
266
+ opsfile = File.open("Operators.xml")
267
+ $opsxml = Nokogiri::XML(opsfile, &:noblanks)
268
+ opsfile.close
269
+ end
270
+
271
+ # datatypes for builtin types that have been exported
272
+ datatype_hash = Hash.new
273
+
274
+ # XMI File Start Template (includes datatypes for builtin with no direct UML equivalent)
275
+ overall_start_template = %{<?xml version="1.0" encoding="UTF-8"?><%
276
+ if xmiVersion == "2.1" %>
277
+ <xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.omg.org/spec/UML/20090901" xmlns:StandardProfileL2="http://schema.omg.org/spec/UML/2.3/StandardProfileL2.xmi" xmlns:sysml="http://www.omg.org/spec/SysML/20100301/SysML-profile"><%
278
+ else %>
279
+ <xmi:XMI xmlns:uml='http://www.omg.org/spec/UML/20131001' xmlns:xmi='http://www.omg.org/spec/XMI/20131001' xmlns:StandardProfile='http://www.omg.org/spec/UML/20131001/StandardProfile' xmlns:sysml='http://www.omg.org/spec/SysML/20150709/SysML'><%
280
+ end
281
+ $dtprefix=''
282
+ if !outPath.nil?
283
+ pathElements = outPath.split('/')
284
+ if dtHandle=='local'
285
+ for elem in pathElements
286
+ $dtprefix = $dtprefix + elem[0]
287
+ end
288
+ $dtprefix = $dtprefix + '_'
289
+ end
290
+ end %>}
291
+
292
+ # Package Structure Start
293
+ package_start = %{<%
294
+ if outPath.nil?
295
+ name = "SysMLfromEXPRESS"
296
+ else
297
+ pathElements = outPath.split('/')
298
+ name = pathElements[-1]
299
+ end %>
300
+ <uml:Package xmi:id="_0_<%= name %>"<%= get_uuid('_0_'+name) %> xmi:type="uml:Package">
301
+ <name><%= name %></name>}
302
+
303
+ # Apply SysML profile
304
+ apply_sysml = %{<profileApplication xmi:id="_profileApplication0"<%= get_uuid('_profileApplication0') %> xmi:type="uml:ProfileApplication"><%
305
+ if xmiVersion == "2.1" %>
306
+ <appliedProfile href="http://www.omg.org/spec/SysML/20100301/SysML-profile.uml#_0"/><%
307
+ else %>
308
+ <appliedProfile href="http://www.omg.org/spec/SysML/20150709/SysML.xmi#_SysML__0"/><%
309
+ end %>
310
+ </profileApplication>}
311
+
312
+ # Package end
313
+ package_end = %{</uml:Package>}
314
+
315
+ # XMI File End Template
316
+ overall_end_template = %{</xmi:XMI>}
317
+
318
+ #DATA TYPEs
319
+ data_types = %{<packagedElement xmi:id="<%= $dtprefix %>BINARY"<%= get_uuid($dtprefix+'BINARY') %> xmi:type="uml:PrimitiveType">
320
+ <name>Binary</name>
321
+ </packagedElement>
322
+ <packagedElement xmi:id="<%= $dtprefix %>STRING"<%= get_uuid($dtprefix+'STRING') %> xmi:type="uml:PrimitiveType">
323
+ <name>String</name>
324
+ </packagedElement>
325
+ <packagedElement xmi:id="<%= $dtprefix %>NUMBER"<%= get_uuid($dtprefix+'NUMBER') %> xmi:type="uml:PrimitiveType">
326
+ <name>Number</name>
327
+ <isAbstract>true</isAbstract>
328
+ </packagedElement>
329
+ <packagedElement xmi:id="<%= $dtprefix %>REAL"<%= get_uuid($dtprefix+'REAL') %> xmi:type="uml:PrimitiveType">
330
+ <name>Real</name>
331
+ <generalization xmi:id="_generalization-<%= $dtprefix %>REAL_NUMBER"<%= get_uuid('_generalization-'+$dtprefix+'REAL_NUMBER') %> xmi:type="uml:Generalization">
332
+ <general xmi:idref="<%= $dtprefix %>NUMBER"/>
333
+ </generalization>
334
+ </packagedElement>
335
+ <packagedElement xmi:id="<%= $dtprefix %>INTEGER"<%= get_uuid($dtprefix+'INTEGER') %> xmi:type="uml:PrimitiveType">
336
+ <name>Integer</name>
337
+ <generalization xmi:id="_generalization-<%= $dtprefix %>INTEGER_REAL"<%= get_uuid('_generalization-'+$dtprefix+'INTEGER_REAL') %> xmi:type="uml:Generalization">
338
+ <general xmi:idref="<%= $dtprefix %>REAL"/>
339
+ </generalization>
340
+ </packagedElement>
341
+ <packagedElement xmi:id="<%= $dtprefix %>LOGICAL"<%= get_uuid($dtprefix+'LOGICAL') %> xmi:type="uml:Enumeration">
342
+ <name>Logical</name>
343
+ <ownedLiteral xmi:id="<%= $dtprefix %>UNKNOWN"<%= get_uuid($dtprefix+'UNKNOWN') %> xmi:type="uml:EnumerationLiteral">
344
+ <name>Unknown</name>
345
+ </ownedLiteral>
346
+ </packagedElement>
347
+ <packagedElement xmi:id="<%= $dtprefix %>BOOLEAN"<%= get_uuid($dtprefix+'BOOLEAN') %> xmi:type="uml:Enumeration">
348
+ <name>Boolean</name>
349
+ <generalization xmi:id="<%= $dtprefix %>_generalization-<%= $dtprefix %>BOOLEAN-LOGICAL"<%= get_uuid('_generalization-'+$dtprefix+'BOOLEAN-LOGICAL') %> xmi:type="uml:Generalization">
350
+ <general xmi:idref="<%= $dtprefix %>LOGICAL"/>
351
+ </generalization>
352
+ <ownedLiteral xmi:id="<%= $dtprefix %>TRUE"<%= get_uuid($dtprefix+'TRUE') %> xmi:type="uml:EnumerationLiteral">
353
+ <name>True</name>
354
+ </ownedLiteral>
355
+ <ownedLiteral xmi:id="<%= $dtprefix %>FALSE"<%= get_uuid($dtprefix+'FALSE') %> xmi:type="uml:EnumerationLiteral">
356
+ <name>False</name>
357
+ </ownedLiteral>
358
+ </packagedElement>}
359
+
360
+ #DATA TYPE end
361
+ data_type_stereos = %{<sysml:ValueType xmi:id="<%= $dtprefix %>LOGICAL_VT"<%= get_uuid($dtprefix+'LOGICAL_VT') %>>
362
+ <base_DataType xmi:idref="<%= $dtprefix %>LOGICAL"/>
363
+ </sysml:ValueType>
364
+ <sysml:ValueType xmi:id="<%= $dtprefix %>BOOLEAN_VT"<%= get_uuid($dtprefix+'BOOLEAN_VT') %>>
365
+ <base_DataType xmi:idref="<%= $dtprefix %>BOOLEAN"/>
366
+ </sysml:ValueType>
367
+ <sysml:ValueType xmi:id="<%= $dtprefix %>NUMBER_VT"<%= get_uuid($dtprefix+'NUMBER_VT') %>>
368
+ <base_DataType xmi:idref="<%= $dtprefix %>NUMBER"/>
369
+ </sysml:ValueType>
370
+ <sysml:ValueType xmi:id="<%= $dtprefix %>REAL_VT"<%= get_uuid($dtprefix+'REAL_VT') %>>
371
+ <base_DataType xmi:idref="<%= $dtprefix %>REAL"/>
372
+ </sysml:ValueType>
373
+ <sysml:ValueType xmi:id="<%= $dtprefix %>INTEGER_VT"<%= get_uuid($dtprefix+'INTEGER_VT') %>>
374
+ <base_DataType xmi:idref="<%= $dtprefix %>INTEGER"/>
375
+ </sysml:ValueType>
376
+ <sysml:ValueType xmi:id="<%= $dtprefix %>STRING_VT"<%= get_uuid($dtprefix+'STRING_VT') %>>
377
+ <base_DataType xmi:idref="<%= $dtprefix %>STRING"/>
378
+ </sysml:ValueType>
379
+ <sysml:ValueType xmi:id="<%= $dtprefix %>BINARY_VT"<%= get_uuid($dtprefix+'BINARY_VT') %>>
380
+ <base_DataType xmi:idref="<%= $dtprefix %>BINARY"/>
381
+ </sysml:ValueType>}
382
+
383
+ # SCHEMA Start Template
384
+ schema_start_template = %{<% if schema_list.size > 1 %><packagedElement<% else %><uml:Package<% end %> xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Package">
385
+ <name><%= schema.name %></name>}
386
+
387
+ # SCHEMA INTERFACE Template
388
+ schema_interface_template = %{<packageImport xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:PackageImport">
389
+ <importedPackage xmi:idref="_1_<%= interfaced_schema.foreign_schema_id %>"/>
390
+ </packageImport>}
391
+
392
+ # SCHEMA End Template
393
+ schema_end_template = %{<% if schema_list.size > 1 %></packagedElement><% else %></uml:Package><% end %>}
394
+
395
+ # ENTITY Block Template
396
+ entity_block_template = %{<sysml:Block xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %>>
397
+ <base_Class xmi:idref="<%= baseClass %>"/>
398
+ </sysml:Block>}
399
+
400
+ # ENTITY Start Template
401
+ entity_start_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Class">
402
+ <name><%= entity.name %></name><% if entity.isAbs %>
403
+ <isAbstract>true</isAbstract><% end %>}
404
+
405
+ # SUBTYPE OF Template
406
+ supertype_template = %{<generalization xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Generalization">
407
+ <general xmi:idref="<%= xmiid_general %>"/>
408
+ </generalization>}
409
+
410
+ # ENTITY End Template
411
+ entity_end_template = %{</packagedElement>}
412
+
413
+ # ENUMERATION Start Template
414
+ enum_start_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Enumeration">
415
+ <name><%= enum.name %></name><% if !general.nil?
416
+ if !datatype_hash[general].nil? %>
417
+ <generalization xmi:id="<%= gen_xmiid %>"<%= get_uuid(gen_xmiid) %> xmi:type="uml:Generalization">
418
+ <general href="<%= datatype_hash[general] %>"/>
419
+ </generalization><% else %>
420
+ <generalization xmi:id="<%= gen_xmiid %>"<%= get_uuid(gen_xmiid) %> xmi:type="uml:Generalization">
421
+ <general xmi:idref="<%= xmiid_general %>"/>
422
+ </generalization>
423
+ <% end
424
+ end%>}
425
+
426
+ # ENUMERATION ITEM Template
427
+ enum_item_template = %{<ownedLiteral xmi:id="<%= enumitem_xmiid %>"<%= get_uuid(enumitem_xmiid) %> xmi:type="uml:EnumerationLiteral">
428
+ <name><%= enumitem %></name>
429
+ </ownedLiteral>}
430
+
431
+ # ENUMERATION End Template
432
+ enum_end_template = %{</packagedElement>}
433
+
434
+ # SELECT Start Template
435
+ select_start_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="<% if selectTypeType[type.name] == "Type" %>uml:DataType<% else %>uml:Class<% end %>">
436
+ <name><%= type.name %></name>
437
+ <isAbstract>true</isAbstract>}
438
+
439
+ # SELECT End Template
440
+ select_end_template = %{</packagedElement>}
441
+
442
+ # SELECT Stereotype Template
443
+ select_stereotype_template = %{<<%= $StandardProfile %>:Auxiliary xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %>>
444
+ <base_Class xmi:idref="<%= baseClass %>"/>
445
+ </<%= $StandardProfile %>:Auxiliary>}
446
+
447
+ # Template covering the output file contents for each attribute that is an entity
448
+ attribute_entity_template = %{<ownedAttribute xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Property">
449
+ <name><%= attr.name %></name><% if islist %>
450
+ <isOrdered>true</isOrdered><% end %><% if !isset %>
451
+ <isUnique>false</isUnique><% end %>
452
+ <type xmi:idref="<%= domain_xmiid %>"/><% if (direct_inverse and !encapsulatedInto) or encapsulated %>
453
+ <aggregation>composite</aggregation><% end %>
454
+ <association xmi:idref="<%= assoc_xmiid %>"/><% if attr.redeclare_entity %>
455
+ <redefinedProperty xmi:idref="<%= redefined_xmiid %>"/><% end %>}
456
+
457
+ # INVERSE ATTRIBUTE Template
458
+ inverse_attribute_template = %{<ownedAttribute xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Property">
459
+ <name><%= inverse.name %></name><% if !isset %>
460
+ <isUnique>false</isUnique><% end %>
461
+ <isReadOnly>true</isReadOnly><% if encapsulatedInto %>
462
+ <aggregation>composite</aggregation><% end %>
463
+ <type xmi:idref="<%= domain_xmiid %>"/>
464
+ <association xmi:idref="<%= assoc_xmiid %>"/><% if inverse.redeclare_entity %>
465
+ <redefinedProperty xmi:idref="<%= redefined_xmiid %>"/><% end %>}
466
+
467
+ #Template covering multiplicities
468
+ multiplicity = %{<% dummy = nil
469
+ if lower == '0' %><lowerValue xmi:id="<%= xmiid %>-lowerValue"<%= get_uuid(xmiid + '-lowerValue') %> xmi:type="uml:LiteralInteger"/><%
470
+ else
471
+ if lower != '1' %><lowerValue xmi:id="<%= xmiid %>-lowerValue"<%= get_uuid(xmiid + '-lowerValue') %> xmi:type=<% if /\\d+/ === lower %>"uml:LiteralInteger"<% else %>"uml:LiteralString"<% end %>>
472
+ <value><%= lower %></value>
473
+ </lowerValue><%
474
+ else
475
+ dummy = get_uuid(xmiid + '-lowerValue')
476
+ end
477
+ end %><% if dummy.nil? %>
478
+ <% end %><% if upper != '1' %><upperValue xmi:id="<%= xmiid %>-upperValue"<%= get_uuid(xmiid + '-upperValue') %> xmi:type=<% if /(\\d+|\\*)/ === upper %>"uml:LiteralUnlimitedNatural"<% else %>"uml:LiteralString"<% end %>>
479
+ <value><%= upper %></value>
480
+ </upperValue><%
481
+ else
482
+ dummy = get_uuid(xmiid + '-upperValue')
483
+ end %>}
484
+
485
+ #Template covering attribute wrapup
486
+ attribute_end = %{</ownedAttribute>}
487
+
488
+
489
+ # EXPLICIT ATTRIBUTE ENTITY Create Association Template
490
+ attribute_entity_association_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Association">
491
+ <memberEnd xmi:idref="<%= attr_xmiid %>"/><%
492
+ if !inverse_exists %>
493
+ <memberEnd xmi:idref="<%= xmiid + '-end' %>"/>
494
+ <ownedEnd xmi:id="<%= xmiid %>-end"<%= get_uuid(xmiid+'-end') %> xmi:type="uml:Property"><% if encapsulatedInto %>
495
+ <aggregation>composite</aggregation><% end %>
496
+ <type xmi:idref="<%= owner_xmiid %>"/>
497
+ <association xmi:idref="<%= xmiid %>"/>
498
+ <lowerValue xmi:id="<%= xmiid %>-end-lowerValue"<%= get_uuid(xmiid+'-end-lowerValue') %> xmi:type="uml:LiteralInteger"/><%
499
+ if encapsulated
500
+ dummy = get_uuid(xmiid+'-end-upperValue')
501
+ else %>
502
+ <upperValue xmi:id="<%= xmiid %>-end-upperValue"<%= get_uuid(xmiid+'-end-upperValue') %> xmi:type="uml:LiteralUnlimitedNatural">
503
+ <value>*</value>
504
+ </upperValue><%
505
+ end %>
506
+ </ownedEnd><%
507
+ else %><memberEnd xmi:idref="<%= iattr_xmiid %>"/><%
508
+ end %><%
509
+ if general_exists %>
510
+ <generalization xmi:id="<%= general_xmiid %>"<%= get_uuid(general_xmiid) %> xmi:type="uml:Generalization">
511
+ <general xmi:idref="<%= redefined_xmiid %>"/>
512
+ </generalization><%
513
+ end %>
514
+ </packagedElement>}
515
+
516
+
517
+ # INVERSE ATTRIBUTE ENTITY Create Association Template
518
+ inverse_entity_association_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Association">
519
+ <memberEnd xmi:idref="<%= xmiid + '-end' %>"/>
520
+ <memberEnd xmi:idref="<%= iattr_xmiid %>"/>
521
+ <ownedEnd xmi:id="<%= xmiid %>-end"<%= get_uuid(xmiid+'-end') %> xmi:type="uml:Property">
522
+ <type xmi:idref="<%= owner_xmiid %>"/>
523
+ <association xmi:idref="<%= xmiid %>"/><% xmiid = xmiid + '-end' %>}
524
+
525
+ inverse_entity_association_end = %{</ownedEnd>
526
+ <generalization xmi:id="<%= general_xmiid %>"<%= get_uuid(general_xmiid) %> xmi:type="uml:Generalization">
527
+ <general xmi:idref="<%= redefined_xmiid %>"/>
528
+ </generalization>
529
+ </packagedElement>}
530
+
531
+
532
+ # EXPLICIT ATTRIBUTE SIMPLE TYPE Template
533
+ attribute_builtin_template = %{<ownedAttribute xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Property">
534
+ <name><%= attr.name %></name><% if islist %>
535
+ <isOrdered>true</isOrdered><% end %><% if !isset %>
536
+ <isUnique>false</isUnique><% end %>
537
+ <aggregation>composite</aggregation><% if attr.redeclare_entity %>
538
+ <redefinedProperty xmi:idref="<%= redefined_xmiid %>"/><% end %><% if !nestedAggs[domain_name].nil? %>
539
+ <type xmi:idref="<%= prefix+domain_name %>"/><% else if !datatype_hash[domain_name].nil? %>
540
+ <type href="<%= datatype_hash[domain_name] %>"/><% else %>
541
+ <type xmi:idref="<%= $dtprefix+domain_name %>"/><% end end %>}
542
+
543
+
544
+ # EXPLICIT ATTRIBUTE ENUM and TYPE Template
545
+ attribute_enum_type_template = %{<ownedAttribute xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Property">
546
+ <name><%= attr.name %></name>
547
+ <type xmi:idref="<%= type_xmiid %>"/><% if islist %>
548
+ <isOrdered>true</isOrdered><% end %><% if !isset %>
549
+ <isUnique>false</isUnique><% end %>
550
+ <aggregation>composite</aggregation>}
551
+
552
+ # Lower bound constraint template
553
+ bound_constraint = %{<ownedRule xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Constraint">
554
+ <name><%= name %>_LB</name>
555
+ <constrainedElement xmi:idref="<%= xmiid_entity %>"/>
556
+ <specification xmi:id="<%= xmiid %>-spec"<%= get_uuid(xmiid+'-spec') %> xmi:type="uml:OpaqueExpression">
557
+ <body><%= name %>-&gt;isEmpty() or <%= name %>-&gt;size() &gt;= <%= bound %></body>
558
+ <language>OCL2.0</language>
559
+ </specification>
560
+ </ownedRule>}
561
+
562
+ # UNIQUE rule template
563
+ unique_template = %{<ownedRule xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Constraint">
564
+ <name><%= unique.name %></name>
565
+ <constrainedElement xmi:idref="<%= xmiid_entity %>"/>
566
+ <specification xmi:id="<%= xmiid %>-spec"<%= get_uuid(xmiid+'-spec') %> xmi:type="uml:OpaqueExpression">
567
+ <body><%= entity.name %>::allInstances()-&gt;isUnique(<%= unique_text %>)</body>
568
+ <language>OCL2.0</language>
569
+ </specification>
570
+ </ownedRule>}
571
+
572
+ # WHERE rule template
573
+ where_template = %{<ownedRule xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Constraint">
574
+ <name><%= where.name %></name>
575
+ <constrainedElement xmi:idref="<%= xmiidref %>"/>
576
+ <specification xmi:id="<%= xmiid %>-spec"<%= get_uuid(xmiid+'-spec') %> xmi:type="uml:OpaqueExpression">
577
+ <body><%= where_ocl %></body>
578
+ <language>OCL2.0</language>
579
+ </specification>
580
+ </ownedRule>}
581
+
582
+ # TYPE Template
583
+ type_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:PrimitiveType">
584
+ <name><%= type.name %></name><% if !datatype_hash[type.domain].nil? %>
585
+ <generalization xmi:id="_supertype<%= xmiid %>"<%= get_uuid('_supertype'+xmiid) %> xmi:type="uml:Generalization">
586
+ <general href="<%= datatype_hash[type.domain] %>"/>
587
+ </generalization><% else %>
588
+ <generalization xmi:id="_supertype<%= xmiid %>"<%= get_uuid('_supertype'+xmiid) %> xmi:type="uml:Generalization">
589
+ <general xmi:idref="<%= $dtprefix+xmiid_general %>"/>
590
+ </generalization>
591
+ <% end %>}
592
+
593
+ # ProxyTYPE Start Template
594
+ proxy_start_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Class">
595
+ <name><%= type.name %>Proxy</name>
596
+ <ownedAttribute xmi:id="<%= xmiid %>_value"<%= get_uuid(xmiid + "_value") %> xmi:type="uml:Property">
597
+ <name>value</name>
598
+ <type xmi:idref="<%= xmiid_type %>"/>
599
+ <aggregation>composite</aggregation>
600
+ </ownedAttribute><%
601
+ dummy = get_uuid(xmiid + "_value-lowerValue")
602
+ dummy = get_uuid(xmiid + "_value-upperValue")
603
+ %>}
604
+
605
+ # AggTYPE Start Template
606
+ aggtype_start_template = %{<packagedElement xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Class">
607
+ <name><%= type_name %></name>}
608
+
609
+ aggtype_attribute = %{<ownedAttribute xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %> xmi:type="uml:Property">
610
+ <name>elements</name><% if islist %>
611
+ <isOrdered>true</isOrdered><% end %><% if !isset %>
612
+ <isUnique>false</isUnique><% end %><% if datatype_hash[type.domain].nil? %>
613
+ <type xmi:idref="<%= xmiid_type %>"/><% else %>
614
+ <type href="<%= datatype_hash[type.domain] %>"/><% end %><% if associationNeeded %>
615
+ <association xmi:idref="<%= assoc_xmiid %>"/><% else %>
616
+ <aggregation>composite</aggregation><% end %>}
617
+
618
+ aggtype_association = %{<packagedElement xmi:id="<%= assoc_xmiid %>"<%= get_uuid(assoc_xmiid) %> xmi:type="uml:Association">
619
+ <memberEnd xmi:idref="<%= xmiid %>"/>
620
+ <memberEnd xmi:idref="<%= assoc_xmiid + '-end' %>"/>
621
+ <ownedEnd xmi:id="<%= assoc_xmiid %>-end"<%= get_uuid(assoc_xmiid+'-end') %> xmi:type="uml:Property">
622
+ <type xmi:idref="<%= xmiid_type %>"/>
623
+ <association xmi:idref="<%= assoc_xmiid %>"/>
624
+ <lowerValue xmi:id="<%= assoc_xmiid %>-end-lowerValue"<%= get_uuid(assoc_xmiid+'-end-lowerValue') %> xmi:type="uml:LiteralInteger"/>
625
+ </ownedEnd>
626
+ </packagedElement>}
627
+
628
+ # TYPE Stereotype Template
629
+ type_stereotype_template = %{<<%= $StandardProfile %>:Type xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %>>
630
+ <base_Class xmi:idref="<%= baseClass %>"/>
631
+ </<%= $StandardProfile %>:Type>}
632
+
633
+ #TYPE end Template
634
+ type_end_template=%{</packagedElement>}
635
+
636
+ # TYPE ValueType Template
637
+ valuetype_template = %{<sysml:ValueType xmi:id="<%= xmiid %>"<%= get_uuid(xmiid) %>>
638
+ <base_DataType xmi:idref="<%= baseType %>"/>
639
+ </sysml:ValueType>}
640
+
641
+ #############################################################################################
642
+ # Set up list of schemas to process, input may be a repository containing schemas or a single schema
643
+ #############################################################################################
644
+
645
+ if mapinput.kind_of? EXPSM::Repository
646
+ schema_list = mapinput.schemas
647
+ elsif mapinput.kind_of? EXPSM::SchemaDefinition
648
+ schema_list = [mapinput]
649
+ else
650
+ puts "ERROR : map_from_express input no Repository instance or Schema instance"
651
+ exit
652
+ end
653
+
654
+ # Set up XMI output file
655
+
656
+ if schema_list.size == 1
657
+ if output_xmi_filename.nil?
658
+ schema = schema_list[0]
659
+ output_xmi_filename = schema.name.to_s + ".xmi"
660
+ end
661
+ if schemaId
662
+ get_prefix = lambda {|schema| '_' + schema.name + '-'}
663
+ else
664
+ get_prefix = lambda {|schema| '_'}
665
+ end
666
+ else
667
+ if output_xmi_filename.nil?
668
+ output_xmi_filename = 'Model.xmi'
669
+ end
670
+ get_prefix = lambda {|schema| '_' + schema.name + '-'}
671
+ end
672
+
673
+ file = File.new(output_xmi_filename, "w")
674
+ puts 'reeper : Writing output to file ' + output_xmi_filename
675
+
676
+ # Evaluate and write file start template
677
+ res = ERB.new(overall_start_template)
678
+ t = res.result(binding)
679
+ file.puts t
680
+
681
+ if dtHandle != "local"
682
+ pathElements = outPath.split('/')
683
+ relPath = "DataTypes.xmi"
684
+ for elem in pathElements
685
+ relPath = "../" + relPath
686
+ end
687
+ datatype_hash["LOGICAL"] = relPath + "#LOGICAL"
688
+ datatype_hash["BOOLEAN"] = relPath + "#BOOLEAN"
689
+ datatype_hash["NUMBER"] = relPath + "#NUMBER"
690
+ datatype_hash["REAL"] = relPath + "#REAL"
691
+ datatype_hash["INTEGER"] = relPath + "#INTEGER"
692
+ datatype_hash["STRING"] = relPath + "#STRING"
693
+ datatype_hash["BINARY"] = relPath + "#BINARY"
694
+ end
695
+
696
+ # sort out data types
697
+ if dtHandle != "ignore"
698
+ if dtHandle == "local"
699
+ dtfile = file
700
+ else
701
+ dtfile = File.new("DataTypes.xmi","w")
702
+ res = ERB.new(overall_start_template)
703
+ t = res.result(binding)
704
+ dtfile.puts t
705
+ if $uuidsRequired
706
+ uuidSafe = $uuidxml
707
+ uuidOldSafe = $olduuids
708
+ if File.exists?("DataTypes_UUIDs.xml")
709
+ uuidfile = File.open("DataTypes_UUIDs.xml")
710
+ $uuidxml = Nokogiri::XML(uuidfile, &:noblanks)
711
+ uuidfile.close
712
+ else
713
+ $uuidxml = Nokogiri::XML::Builder.new { |b| b.uuids }.doc
714
+ end
715
+ $olduuids = $uuidxml.xpath('//uuidmap')
716
+ end
717
+ xmiid = "_0_" + $dtprefix + "DataTypes"
718
+ dtfile.puts '<uml:Package xmi:id="'+ xmiid +'"' + get_uuid(xmiid) +' xmi:type="uml:Package">'
719
+ dtfile.puts '<name>DataTypes</name>'
720
+ res = ERB.new(apply_sysml)
721
+ t = res.result(binding)
722
+ dtfile.puts t
723
+ end
724
+ res = ERB.new(data_types)
725
+ t = res.result(binding)
726
+ dtfile.puts t
727
+ if dtHandle == "export"
728
+ dtfile.puts '</uml:Package>'
729
+ end
730
+ if !uuidSafe.nil?
731
+ tmp = uuidSafe
732
+ uuidSafe = $uuidxml
733
+ $uuidxml = tmp
734
+ tmp = uuidOldSafe
735
+ uuidOldSafe = $olduuids
736
+ $olduuids = tmp
737
+ end
738
+ end
739
+
740
+ # Set up list of all EXPRESS Inverses in all schemas
741
+ all_inverse_list = []
742
+ direct_inverses = []
743
+ # Set up list of all EXPRESS Selects in all schemas
744
+ all_select_list = []
745
+ renamed_select_list = []
746
+ # setup global proxy type handling
747
+ typeProxies = Hash.new
748
+
749
+ # build all_select_list
750
+ for schema in schema_list
751
+ select_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::TypeSelect }
752
+ all_select_list = all_select_list + select_list
753
+ type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::Type and !e.isBuiltin}
754
+ for type in type_list
755
+ superselect = NamedType.find_by_name( type.domain )
756
+ while (superselect.instance_of? EXPSM::Type and !superselect.isBuiltin)
757
+ superselect = NamedType.find_by_name(superselect.domain)
758
+ end
759
+ if superselect.kind_of? EXPSM::TypeSelect
760
+ renamed_select_list << type
761
+ end
762
+ end
763
+ end
764
+
765
+ # Set up storage for handling Aggregate and Select Types correctly
766
+ aggTypes = Hash.new
767
+ specialSelects = Hash.new
768
+
769
+ # determine Aggregate and Select types needing special consideration
770
+ for schema in schema_list
771
+ entity_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Entity }
772
+ for entity in entity_list
773
+ attr_list = entity.attributes.find_all{ |e| e.kind_of? EXPSM::Explicit }
774
+ for attr in attr_list
775
+ if attr.instance_of? EXPSM::ExplicitAggregate
776
+ orig_domain = NamedType.find_by_name( attr.domain )
777
+ if orig_domain.class.to_s == "EXPSM::TypeAggregate"
778
+ if aggTypes[attr.domain].nil?
779
+ aggTypes[attr.domain] = orig_domain
780
+ end
781
+ end
782
+ end
783
+ if attr.redeclare_entity
784
+ attr_domain = NamedType.find_by_name(attr.domain)
785
+ if attr_domain.instance_of? EXPSM::TypeSelect
786
+ supertype = NamedType.find_by_name( attr.redeclare_entity )
787
+ if attr.redeclare_oldname
788
+ redeclOf = supertype.find_attr_by_name( attr.redeclare_oldname )
789
+ else
790
+ redeclOf = supertype.find_attr_by_name( attr.name )
791
+ end
792
+ redecl_domain = NamedType.find_by_name( redeclOf.domain )
793
+ case redecl_domain.class.to_s
794
+ when 'EXPSM::Entity', 'EXPSM::TypeSelect'
795
+ if specialSelects[attr.domain].nil?
796
+ specialSelects[attr.domain] = [redecl_domain]
797
+ else
798
+ if !specialSelects[attr.domain].include?(redecl_domain)
799
+ specialSelects[attr.domain].push(redecl_domain)
800
+ end
801
+ end
802
+ end
803
+ end
804
+ end
805
+ end
806
+ end
807
+ end
808
+
809
+ # Set up storage for handling select types correctly
810
+ selectTypeType = Hash.new
811
+
812
+ # determine the type of select
813
+ # - entity if only contains entities
814
+ # - type if only contains types
815
+ # - hybrid if a mixture
816
+ # - remove if a single object in list
817
+ unknownSelect = all_select_list.dup
818
+ for select in unknownSelect
819
+ if (select.selectitems_array.size == 1 && !noprune)
820
+ if !select.selectitems_array[0].kind_of? EXPSM::TypeSelect
821
+ puts select.name + " is pruned since it only contains one element"
822
+ selectTypeType[select.name] = "Remove"
823
+ end
824
+ end
825
+ entcount = 0
826
+ typcount = 0
827
+ select.selectitems_array.each do |e|
828
+ case e.class.to_s
829
+ when "EXPSM::Entity" then entcount += 1
830
+ when "EXPSM::Type" then typcount += 1
831
+ when "EXPSM::TypeEnum" then typcount += 1
832
+ when "EXPSM::TypeAggregate"
833
+ if selectTypeType[select.name] != "Remove"
834
+ entcount += 1
835
+ if aggTypes[e.name].nil?
836
+ aggTypes[e.name] = e
837
+ end
838
+ end
839
+ when "EXPSM::TypeSelect"
840
+ case selectTypeType[e.name]
841
+ when "Entity" then entcount += 1
842
+ when "Type" then typcount += 1
843
+ when "Hybrid" then selectTypeType[select.name] = "Hybrid"
844
+ when "Remove"
845
+ case e.selectitems_array[0].class.to_s
846
+ when "EXPSM::Entity" then entcount += 1
847
+ when "EXPSM::Type" then typcount += 1
848
+ end
849
+ end
850
+ else
851
+ puts "unknown class " + e.class.to_s + " for " + select.name
852
+ end
853
+ end
854
+
855
+ if selectTypeType[select.name].nil?
856
+ case select.selectitems_array.size
857
+ when entcount then selectTypeType[select.name] = "Entity"
858
+ when typcount then selectTypeType[select.name] = "Type"
859
+ else
860
+ if (entcount > 0) && (typcount > 0)
861
+ selectTypeType[select.name] = "Hybrid"
862
+ else
863
+ unknownSelect.push select
864
+ end
865
+ end
866
+ end
867
+ if selectTypeType[select.name] == "Hybrid"
868
+ puts select.name + " is Hybrid select - proxy block(s) generated."
869
+ end
870
+ end
871
+
872
+ # process subsetted select types
873
+ selectSubset = Hash.new
874
+ selectSubs = Hash.new
875
+ for select in renamed_select_list
876
+ superselect = NamedType.find_by_name( select.domain )
877
+ if superselect.kind_of? EXPSM::TypeSelect
878
+ temp = []
879
+ superselect.selectitems_array.each{|e|
880
+ if e.kind_of? EXPSM::TypeSelect
881
+ e.selectitems_array.each{|inner|
882
+ if inner.kind_of? EXPSM::TypeSelect
883
+ puts "select of select select for " + superselect.name
884
+ else
885
+ temp << inner.name
886
+ end}
887
+ else
888
+ temp << e.name
889
+ end}
890
+ if selectSubset[superselect.name].nil?
891
+ selectSubset[superselect.name] = temp.dup
892
+ end
893
+ select.wheres.each{|rule| ruleString = rule.expression.upcase
894
+ if ruleString[0..5] == "NOT ('"
895
+ startPos = ruleString.index('.',6) + 1
896
+ endPos = ruleString.index("'",startPos) - 1
897
+ removeName = ruleString[startPos..endPos]
898
+ temp.reject!{|e| e.upcase == removeName}
899
+ else
900
+ puts "Unexpected expression: " + rule.expression
901
+ end
902
+ }
903
+ selectSubset[select.name] = temp
904
+ selectSubset[superselect.name] = selectSubset[superselect.name] - temp
905
+ if selectSubs[superselect.name].nil?
906
+ selectSubs[superselect.name] = [select.name]
907
+ else
908
+ selectSubs[superselect.name] << select.name
909
+ end
910
+ selectTypeType[select.name] = selectTypeType[superselect.name]
911
+ else
912
+ puts "ERROR: Unhandled select subset for " + superselect.name
913
+ end
914
+ end
915
+
916
+ if schema_list.size > 1
917
+ res = ERB.new(package_start)
918
+ t = res.result(binding)
919
+ file.puts t
920
+
921
+ #Apply sysml profile
922
+ res = ERB.new(apply_sysml)
923
+ t = res.result(binding)
924
+ file.puts t
925
+ end
926
+
927
+ for schema in schema_list
928
+ # Set up storage for handling nested Aggregates correctly
929
+ nestedAggs = Hash.new
930
+ nestedTypes = Hash.new
931
+ prefix = get_prefix.call(schema)
932
+
933
+ entity_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Entity }
934
+ for entity in entity_list
935
+ entity_inverse_list = entity.attributes.find_all{ |e| e.kind_of? EXPSM::Inverse }
936
+ for inverse in entity_inverse_list
937
+ all_inverse_list.push inverse
938
+ end
939
+ end
940
+
941
+ # Evaluate and write schema start template
942
+ xmiid = '_1_' + schema.name
943
+ res = ERB.new(schema_start_template)
944
+ t = res.result(binding)
945
+ file.puts t
946
+
947
+ if schema_list.size == 1
948
+ #Apply sysml profile
949
+ res = ERB.new(apply_sysml)
950
+ t = res.result(binding)
951
+ file.puts t
952
+ end
953
+
954
+ interfaced_schema_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::InterfaceSpecification}
955
+ for interfaced_schema in interfaced_schema_list
956
+ # Evaluate and write schema interface template
957
+ xmiid = '_2_' + schema.name + '-' + interfaced_schema.foreign_schema_id
958
+ res = ERB.new(schema_interface_template)
959
+ t = res.result(binding)
960
+ file.puts t
961
+ end
962
+
963
+ # Map EXPRESS TYPE of Builtin
964
+ type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::Type and e.isBuiltin}
965
+ for type in type_list
966
+ xmiid = prefix + type.name
967
+ xmiid_type = xmiid
968
+ xmiid_general = type.domain
969
+ if ["BOOLEAN", "LOGICAL"].include?(type.domain)
970
+ enum = type
971
+ general = type.domain
972
+ gen_xmiid = '_supertype' + xmiid
973
+ res = ERB.new(enum_start_template)
974
+ t = res.result(binding)
975
+ file.puts t
976
+ else
977
+ res = ERB.new(type_template)
978
+ t = res.result(binding)
979
+ file.puts t
980
+ end
981
+
982
+ # Map TYPE Select has Type as item
983
+ for select in type.selectedBy
984
+ # sort out what type of select we are dealing with
985
+ case selectTypeType[select.name]
986
+ when "Type"
987
+ superName = select.name
988
+ subset = selectSubset[superName]
989
+ if !subset.nil?
990
+ if !subset.include?(type.name)
991
+ selectSubs[superName].each{|e|
992
+ if selectSubset[e].include?(type.name)
993
+ superName = e
994
+ end}
995
+ end
996
+ end
997
+ xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
998
+ xmiid_general = prefix + superName
999
+ res = ERB.new(supertype_template)
1000
+ t = res.result(binding)
1001
+ file.puts t
1002
+ when "Hybrid"
1003
+ typeProxy = typeProxies[type.name]
1004
+ if typeProxy.nil?
1005
+ typeProxies[type.name] = type
1006
+ end
1007
+ when "Remove"
1008
+ # do nothing
1009
+ end
1010
+ end
1011
+
1012
+ # Map EXPRESS Where rules
1013
+ whererules = type.wheres.select {|w| w.name[0..10] != "encapsulate"}
1014
+ if whererules.size > 0
1015
+ for where in whererules
1016
+ xmiid = '_3_whr' + prefix + type.name + '-' + where.name.to_s
1017
+ where_ocl = get_where(xmiid, where.expression)
1018
+ if where_ocl.size > 0
1019
+ xmiidref = xmiid_type
1020
+ res = ERB.new(where_template)
1021
+ t = res.result(binding)
1022
+ file.puts t
1023
+ else
1024
+ puts "Where rule " + type.name + "." + where.name + " not mapped to OCL - ignored!"
1025
+ end
1026
+ end
1027
+ end
1028
+
1029
+ put_ops(type.name, file)
1030
+
1031
+ res = ERB.new(type_end_template)
1032
+ t = res.result(binding)
1033
+ file.puts t
1034
+ end
1035
+
1036
+ # Map EXPRESS TYPE of TYPE
1037
+ type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::Type and !e.isBuiltin}
1038
+ for type in type_list
1039
+ domain = NamedType.find_by_name( type.domain )
1040
+ xmiid = prefix + type.name
1041
+ xmiid_type = xmiid
1042
+ # deal with special cases
1043
+ case domain.class.to_s
1044
+ when "EXPSM::TypeSelect"
1045
+ res = ERB.new(select_start_template)
1046
+ t = res.result(binding)
1047
+ file.puts t
1048
+
1049
+ xmiid = '_2_superselect' + prefix + type.name + '-' + type.domain
1050
+ xmiid_general = prefix + type.domain
1051
+ res = ERB.new(supertype_template)
1052
+ t = res.result(binding)
1053
+ file.puts t
1054
+
1055
+ when "EXPSM::TypeEnum"
1056
+ enum = type
1057
+ gen_xmiid = '_2_superenum' + prefix + type.name + '-' + type.domain
1058
+ xmiid_general = prefix + type.domain
1059
+ general = type.domain
1060
+ res = ERB.new(enum_start_template)
1061
+ t = res.result(binding)
1062
+ file.puts t
1063
+
1064
+ else
1065
+ xmiid_general = prefix + type.domain
1066
+ res = ERB.new(type_template)
1067
+ t = res.result(binding)
1068
+ file.puts t
1069
+ end
1070
+
1071
+ # Map TYPE Select has Type as item
1072
+ if selectTypeType[type.name] == "Type"
1073
+ for select in type.selectedBy
1074
+ case selectTypeType[select.name]
1075
+ when "Type"
1076
+ superName = select.name
1077
+ subset = selectSubset[superName]
1078
+ if !subset.nil?
1079
+ if !subset.include?(type.name)
1080
+ selectSubs[superName].each{|e|
1081
+ if selectSubset[e].include?(type.name)
1082
+ superName = e
1083
+ end}
1084
+ end
1085
+ end
1086
+ xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1087
+ xmiid_general = prefix + superName
1088
+ res = ERB.new(supertype_template)
1089
+ t = res.result(binding)
1090
+ file.puts t
1091
+ when "Hybrid"
1092
+ typeProxy = typeProxies[type.name]
1093
+ if typeProxy.nil?
1094
+ typeProxies[type.name] = type
1095
+ end
1096
+ when "Remove"
1097
+ # do nothing
1098
+ end
1099
+ end
1100
+ else
1101
+ for select in type.selectedBy
1102
+ if selectTypeType[select.name] != "Remove"
1103
+ superName = select.name
1104
+ subset = selectSubset[superName]
1105
+ if !subset.nil?
1106
+ if !subset.include?(type.name)
1107
+ selectSubs[superName].each{|e|
1108
+ if selectSubset[e].include?(type.name)
1109
+ superName = e
1110
+ end}
1111
+ end
1112
+ end
1113
+ xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1114
+ xmiid_general = prefix + superName
1115
+ res = ERB.new(supertype_template)
1116
+ t = res.result(binding)
1117
+ file.puts t
1118
+ end
1119
+ end
1120
+ end
1121
+
1122
+ case domain.class.to_s
1123
+ when "EXPSM::TypeSelect"
1124
+ when "EXPSM::TypeEnum"
1125
+ #Map EXPRESS Where rules
1126
+ whererules = type.wheres.select {|w| w.name[0..10] != "encapsulate"}
1127
+ if whererules.size > 0
1128
+ for where in whererules
1129
+ xmiid = '_3_whr' + prefix + type.name + '-' + where.name.to_s
1130
+ where_ocl = where.expression.gsub("<>", "&lt;&gt;")
1131
+ xmiidref = xmiid_type
1132
+ res = ERB.new(where_template)
1133
+ t = res.result(binding)
1134
+ file.puts t
1135
+ end
1136
+ end
1137
+ else
1138
+ #Map EXPRESS Where rules
1139
+ whererules = type.wheres.select {|w| w.name[0..10] != "encapsulate"}
1140
+ if whererules.size > 0
1141
+ for where in whererules
1142
+ xmiid = '_3_whr' + prefix + type.name + '-' + where.name.to_s
1143
+ where_ocl = get_where(xmiid, where.expression)
1144
+ if where_ocl.size > 0
1145
+ xmiidref = xmiid_type
1146
+ res = ERB.new(where_template)
1147
+ t = res.result(binding)
1148
+ file.puts t
1149
+ else
1150
+ puts "Where rule " + type.name + "." + where.name + " not mapped to OCL - ignored!"
1151
+ end
1152
+ end
1153
+ end
1154
+
1155
+ put_ops(type.name, file)
1156
+ end
1157
+
1158
+ res = ERB.new(type_end_template)
1159
+ t = res.result(binding)
1160
+ file.puts t
1161
+ end
1162
+
1163
+ aggTypes.each_value do |type|
1164
+ if type.schema == schema
1165
+ # Evaluate and write aggType start template
1166
+ # initialize default cardinailty constraints
1167
+ isset = true
1168
+ islist = false
1169
+
1170
+ upper = type.dimensions[0].upper
1171
+ if upper == '?'
1172
+ upper = '*'
1173
+ end
1174
+ lower = type.dimensions[0].lower
1175
+ if type.dimensions[0].aggrtype == 'ARRAY'
1176
+ puts 'Warning ARRAY not fully supported for '+type.name
1177
+ upper = (upper.to_i - lower.to_i + 1).to_s
1178
+ lower = upper
1179
+ end
1180
+ if type.dimensions[0].aggrtype == 'LIST'
1181
+ islist = true
1182
+ end
1183
+ if type.dimensions[0].aggrtype == 'BAG'
1184
+ isset = false
1185
+ end
1186
+ if type.dimensions[0].aggrtype == 'LIST' and !type.dimensions[0].isUnique
1187
+ isset = false
1188
+ end
1189
+
1190
+ xmiid = prefix + type.name
1191
+ associationNeeded = false
1192
+ if type.isBuiltin
1193
+ xmiid_type = $dtprefix + type.domain
1194
+ else
1195
+ xmiid_type = prefix + type.domain
1196
+
1197
+ domain = NamedType.find_by_name( type.domain )
1198
+ case domain.class.to_s
1199
+ when "EXPSM::Entity"
1200
+ associationNeeded = true
1201
+ when "EXPSM::Type"
1202
+ case selectTypeType[type.domain]
1203
+ when "Entity", "Hybrid"
1204
+ associationNeeded = true
1205
+ end
1206
+ when "EXPSM::TypeAggregate"
1207
+ if !aggTypes[type.domain].nil?
1208
+ associationNeeded = true
1209
+ end
1210
+ when "EXPSM::TypeSelect"
1211
+ case selectTypeType[type.domain]
1212
+ when "Entity", "Hybrid"
1213
+ associationNeeded = true
1214
+ end
1215
+ end
1216
+ end
1217
+
1218
+ type_name = type.name
1219
+ res = ERB.new(aggtype_start_template)
1220
+ t = res.result(binding)
1221
+ file.puts t
1222
+
1223
+ # Map TYPE Select has Entity as item
1224
+ for select in type.selectedBy
1225
+ superName = select.name
1226
+ subset = selectSubset[superName]
1227
+ if !subset.nil?
1228
+ if !subset.include?(type.name)
1229
+ selectSubs[superName].each{|e|
1230
+ if selectSubset[e].include?(type.name)
1231
+ superName = e
1232
+ end}
1233
+ end
1234
+ end
1235
+ xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1236
+ xmiid_general = prefix + superName
1237
+ res = ERB.new(supertype_template)
1238
+ t = res.result(binding)
1239
+ file.puts t
1240
+ end
1241
+
1242
+ if associationNeeded
1243
+ assoc_xmiid = '_1_association' + prefix + type.name + '-elements'
1244
+ end
1245
+
1246
+ xmiid = '_2_attr' + prefix + type.name + "-elements"
1247
+ res = ERB.new(aggtype_attribute)
1248
+ t = res.result(binding)
1249
+ file.puts t
1250
+
1251
+ res = ERB.new(multiplicity,0,"<>")
1252
+ t = res.result(binding)
1253
+ if !t.nil? && t.size>0
1254
+ file.puts t
1255
+ end
1256
+
1257
+ res = ERB.new(attribute_end)
1258
+ t = res.result(binding)
1259
+ file.puts t
1260
+
1261
+ res = ERB.new(type_end_template)
1262
+ t = res.result(binding)
1263
+ file.puts t
1264
+
1265
+ if associationNeeded
1266
+ res = ERB.new(aggtype_association)
1267
+ t = res.result(binding)
1268
+ file.puts t
1269
+ end
1270
+ end
1271
+ end
1272
+
1273
+ # Map EXPRESS Enumeration Types
1274
+ enum_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::TypeEnum }
1275
+ for enum in enum_list
1276
+
1277
+ superenum = enum.extends_item
1278
+ general = nil
1279
+ if !superenum.nil?
1280
+ if superenum.kind_of? EXPSM::TypeEnum
1281
+ # Write Enum Item template for parent (maps to UML same as EXPRESS supertype)
1282
+ gen_xmiid = '_2_superenum' + prefix + enum.name + '-' + superenum.name
1283
+ xmiid_general = get_prefix.call(superenum.schema) + superenum.name
1284
+ general = superenum.name
1285
+ end
1286
+ end
1287
+ # Evaluate and write TYPE Enum start template
1288
+ xmiid = prefix + enum.name
1289
+ res = ERB.new(enum_start_template)
1290
+ t = res.result(binding)
1291
+ file.puts t
1292
+
1293
+ # Map TYPE Select has Enum as item
1294
+ for select in enum.selectedBy
1295
+ # sort out what type of select we are dealing with
1296
+ case selectTypeType[select.name]
1297
+ when "Type"
1298
+ superName = select.name
1299
+ subset = selectSubset[superName]
1300
+ if !subset.nil?
1301
+ if !subset.include?(enum.name)
1302
+ selectSubs[superName].each{|e|
1303
+ if selectSubset[e].include?(enum.name)
1304
+ superName = e
1305
+ end}
1306
+ end
1307
+ end
1308
+ xmiid = '_2_selectitem' + prefix + enum.name + '-' + superName
1309
+ xmiid_general = prefix + superName
1310
+ res = ERB.new(supertype_template)
1311
+ t = res.result(binding)
1312
+ file.puts t
1313
+ when "Hybrid"
1314
+ typeProxy = typeProxies[enum.name]
1315
+ if typeProxy.nil?
1316
+ typeProxies[enum.name] = enum
1317
+ end
1318
+ when "Remove"
1319
+ # do nothing
1320
+ end
1321
+ end
1322
+
1323
+ # Evaluate and write Enum Item template for each item
1324
+ enumitem_name_list = enum.items.scan(/\w+/)
1325
+ for enumitem in enumitem_name_list
1326
+ enumitem_xmiid = '_1_enumitem' + prefix + enum.name + '-' + enumitem
1327
+ res = ERB.new(enum_item_template)
1328
+ t = res.result(binding)
1329
+ file.puts t
1330
+ end
1331
+
1332
+ # Evaluate and write TYPE Enum end template
1333
+ res = ERB.new(enum_end_template)
1334
+ t = res.result(binding)
1335
+ file.puts t
1336
+ end
1337
+
1338
+ # Map EXPRESS TYPE Selects
1339
+ select_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::TypeSelect }
1340
+ for type in select_list
1341
+ if selectTypeType[type.name] != "Remove"
1342
+ # Evaluate and write TYPE Select start template
1343
+ xmiid = prefix + type.name
1344
+ res = ERB.new(select_start_template)
1345
+ t = res.result(binding)
1346
+ file.puts t
1347
+
1348
+ # Deal with ad-hoc subtype constraints on entities
1349
+ superentities = specialSelects[type.name]
1350
+ if !superentities.nil?
1351
+ superentities.each {|superentity|
1352
+ xmiid = '_2_superentity' + prefix + type.name + '-' + superentity.name
1353
+ xmiid_general = get_prefix.call(superentity.schema) + superentity.name
1354
+ res = ERB.new(supertype_template)
1355
+ t = res.result(binding)
1356
+ file.puts t}
1357
+ end
1358
+
1359
+ superselect = type.extends_item
1360
+ if !superselect.nil?
1361
+ if superselect.kind_of? EXPSM::TypeSelect
1362
+ if !superentities.include?(superselect)
1363
+ # Write Select Item template for parent (maps to UML same as EXPRESS supertype)
1364
+ xmiid = '_2_superselect' + prefix + type.name + '-' + superselect.name
1365
+ xmiid_general = get_prefix.call(superselect.schema) + superselect.name
1366
+ res = ERB.new(supertype_template)
1367
+ t = res.result(binding)
1368
+ file.puts t
1369
+ end
1370
+ end
1371
+ end
1372
+
1373
+ # Evaluate and write Select Item template for each item (maps to UML same as EXPRESS supertype)
1374
+ if selectTypeType[type.name] == "Type"
1375
+ for superselect in type.selectedBy
1376
+ case selectTypeType[superselect.name]
1377
+ when "Hybrid"
1378
+ typeProxy = typeProxies[type.name]
1379
+ if typeProxy.nil?
1380
+ typeProxies[type.name] = type
1381
+ end
1382
+ when "Remove"
1383
+ # do nothing
1384
+ else
1385
+ superName = superselect.name
1386
+ subset = selectSubset[superselect.name]
1387
+ if !subset.nil?
1388
+ if !subset.include?(type.name)
1389
+ selectSubs[superselect.name].each{|e|
1390
+ if selectSubset[e].include?(type.name)
1391
+ superName = e
1392
+ end}
1393
+ end
1394
+ end
1395
+ if superentities.nil? || superentities.all?{|superentity| superentity.name != superName}
1396
+ xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1397
+ xmiid_general = prefix + superName
1398
+ res = ERB.new(supertype_template)
1399
+ t = res.result(binding)
1400
+ file.puts t
1401
+ end
1402
+ end
1403
+ end
1404
+ else
1405
+ for superselect in type.selectedBy
1406
+ if selectTypeType[superselect.name] !="Remove"
1407
+ superName = superselect.name
1408
+ subset = selectSubset[superselect.name]
1409
+ if !subset.nil?
1410
+ if !subset.include?(type.name)
1411
+ selectSubs[superselect.name].each{|e|
1412
+ if selectSubset[e].include?(type.name)
1413
+ superName = e
1414
+ end}
1415
+ end
1416
+ end
1417
+ if superentities.nil? || superentities.all?{|superentity| superentity.name != superName}
1418
+ xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1419
+ xmiid_general = prefix + superName
1420
+ res = ERB.new(supertype_template)
1421
+ t = res.result(binding)
1422
+ file.puts t
1423
+ end
1424
+ end
1425
+ end
1426
+ end
1427
+
1428
+ # Evaluate and write TYPE Select end template
1429
+ res = ERB.new(select_end_template)
1430
+ t = res.result(binding)
1431
+ file.puts t
1432
+ end
1433
+ end
1434
+
1435
+ typeProxies.each_value do |type|
1436
+ if type.schema == schema
1437
+ # Evaluate and write proxy start template
1438
+ xmiid_type = prefix + type.name
1439
+ xmiid = xmiid_type + "_Proxy"
1440
+ res = ERB.new(proxy_start_template)
1441
+ t = res.result(binding)
1442
+ file.puts t
1443
+
1444
+ # Map TYPE Select has Entity as item
1445
+ for select in type.selectedBy
1446
+ if selectTypeType[select.name] == "Hybrid"
1447
+ superName = select.name
1448
+ subset = selectSubset[superName]
1449
+ if !subset.nil?
1450
+ if !subset.include?(type.name)
1451
+ selectSubs[superName].each{|e|
1452
+ if selectSubset[e].include?(type.name)
1453
+ superName = e
1454
+ end}
1455
+ end
1456
+ end
1457
+ xmiid = '_2_selectitem' + prefix + type.name + '-' + superName
1458
+ xmiid_general = prefix + superName
1459
+ res = ERB.new(supertype_template)
1460
+ t = res.result(binding)
1461
+ file.puts t
1462
+ end
1463
+ end
1464
+
1465
+ res = ERB.new(type_end_template)
1466
+ t = res.result(binding)
1467
+ file.puts t
1468
+ end
1469
+ end
1470
+
1471
+ entity_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Entity }
1472
+
1473
+ # Map EXPRESS Explicit Attribute resulting UML Association (the Association is referenced from Class resulting from Entity)
1474
+ for entity in entity_list
1475
+ attr_list = entity.attributes.find_all{ |e| e.kind_of? EXPSM::Explicit }
1476
+ for attr in attr_list
1477
+
1478
+ domain_name = attr.domain
1479
+ orig_domain = NamedType.find_by_name(domain_name)
1480
+ attr_domain = orig_domain
1481
+ agg_domain = nil
1482
+ attrType = nil
1483
+ associationNeeded = false
1484
+ begin
1485
+ unchanged = true
1486
+ case attr_domain.class.to_s
1487
+ when "EXPSM::Entity"
1488
+ associationNeeded = true
1489
+ when "EXPSM::Type"
1490
+ case selectTypeType[domain_name]
1491
+ when "Entity", "Hybrid"
1492
+ associationNeeded = true
1493
+ end
1494
+ #ignore unhandled named aggregations
1495
+ when "EXPSM::TypeAggregate"
1496
+ if aggTypes[domain_name].nil?
1497
+ attrType = attr_domain
1498
+ agg_domain = attr_domain
1499
+ if attr_domain.isBuiltin
1500
+ domain_name = attr_domain.domain
1501
+ attr_domain = nil
1502
+ else
1503
+ domain_name = attr_domain.domain
1504
+ attr_domain = NamedType.find_by_name(domain_name)
1505
+ unchanged = false
1506
+ end
1507
+ else
1508
+ associationNeeded = true
1509
+ end
1510
+ when "EXPSM::TypeSelect"
1511
+ case selectTypeType[domain_name]
1512
+ when "Entity", "Hybrid"
1513
+ associationNeeded = true
1514
+ # ignore removed select types
1515
+ when "Remove"
1516
+ attr_domain = attr_domain.selectitems_array[0]
1517
+ domain_name = attr_domain.name
1518
+ unchanged = false
1519
+ end
1520
+ end
1521
+ end until unchanged
1522
+
1523
+ if attr.instance_of? EXPSM::ExplicitAggregate
1524
+ attrType = attr
1525
+ end
1526
+
1527
+ if !attrType.nil?
1528
+ if attrType.rank > 1
1529
+ associationNeeded = true
1530
+ for i in 2..attrType.rank
1531
+ domain_name = attrType.dimensions[i-1].aggrtype+domain_name
1532
+ end
1533
+ end
1534
+ end
1535
+
1536
+ if associationNeeded
1537
+ xmiid = '_1_association' + prefix + entity.name + '-' + attr.name
1538
+ attr_xmiid = '_2_attr' + prefix + entity.name + '-' + attr.name
1539
+ owner_xmiid = prefix + entity.name
1540
+ if attr_domain.nil?
1541
+ domain_xmiid = prefix + domain_name
1542
+ else
1543
+ domain_xmiid = get_prefix.call(attr_domain.schema) + attr_domain.name
1544
+ end
1545
+
1546
+ general_exists = false
1547
+ if attr.redeclare_entity
1548
+ general_exists = true
1549
+ redeclare_entity = NamedType.find_by_name( attr.redeclare_entity )
1550
+ general_xmiid = '_2_general' + prefix + entity.name + '-' + attr.name
1551
+ if attr.redeclare_oldname
1552
+ redefined_xmiid = '_1_association' + get_prefix.call(redeclare_entity.schema) + attr.redeclare_entity + '-' + attr.redeclare_oldname
1553
+ else
1554
+ redefined_xmiid = '_1_association' + get_prefix.call(redeclare_entity.schema) + attr.redeclare_entity + '-' + attr.name
1555
+ end
1556
+ end
1557
+
1558
+ # check if inverse refers to this attribute, affects how association is written
1559
+ inverse_exists = false
1560
+ direct_inverse = false
1561
+ for inverse in all_inverse_list
1562
+ if inverse.reverseAttr == attr
1563
+ if attr.domain == inverse.entity.name
1564
+ iattr_xmiid = '_2_attr' + get_prefix.call(inverse.entity.schema) + inverse.entity.name + '-' + inverse.name
1565
+ direct_inverses.push inverse
1566
+ all_inverse_list.delete inverse
1567
+ if !inverse.instance_of? EXPSM::InverseAggregate
1568
+ direct_inverse = true
1569
+ end
1570
+ inverse_exists = true
1571
+ end
1572
+ end
1573
+ end
1574
+
1575
+ encapsulated = false
1576
+ if !attr_domain.nil?
1577
+ if attr_domain == orig_domain
1578
+ encapsulated = isEncapsulated(attr_domain, attr)
1579
+ else
1580
+ if !agg_domain.nil?
1581
+ encapsulated = isEncapsulated(agg_domain, attr)
1582
+ end
1583
+ if !encapsulated
1584
+ encapsulated = isEncapsulated(attr_domain, attr)
1585
+ if !encapsulated
1586
+ encapsulated = isEncapsulated(orig_domain, attr)
1587
+ end
1588
+ end
1589
+ end
1590
+ end
1591
+
1592
+ encapsulatedInto = false
1593
+ if !inverse_exists
1594
+ encapsulatedInto = isEncapsulatedInto(entity, entity, attr)
1595
+ end
1596
+
1597
+ res = ERB.new(attribute_entity_association_template)
1598
+ t = res.result(binding)
1599
+ file.puts t
1600
+ end
1601
+ end
1602
+ end
1603
+
1604
+ # Map EXPRESS Inverse Attribute resulting UML Association (the Association is referenced from Class resulting from Entity)
1605
+ for inverse in all_inverse_list
1606
+ if inverse.entity.schema == schema
1607
+ temp_id = get_prefix.call(inverse.entity.schema) + inverse.entity.name + '-' + inverse.name
1608
+ xmiid = '_1_association' + temp_id
1609
+ owner_xmiid = get_prefix.call(inverse.entity.schema) + inverse.entity.name
1610
+ iattr_xmiid = '_2_attr' + temp_id
1611
+
1612
+ general_xmiid = '_2_general' + temp_id
1613
+ redefined_xmiid = '_1_association' + get_prefix.call(inverse.reverseAttr.entity.schema) + inverse.reverseAttr.entity.name + '-' + inverse.reverseAttr_id
1614
+
1615
+ lower = '1'
1616
+ upper = '1'
1617
+ if inverse.reverseAttr.instance_of? EXPSM::ExplicitAggregate
1618
+ if inverse.reverseAttr.rank == 1
1619
+ upper = inverse.reverseAttr.dimensions[0].upper
1620
+ if upper == '?'
1621
+ upper = '*'
1622
+ end
1623
+ lower = inverse.reverseAttr.dimensions[0].lower
1624
+ end
1625
+ end
1626
+ if inverse.reverseAttr.isOptional
1627
+ lower = '0'
1628
+ end
1629
+ res = ERB.new(inverse_entity_association_template)
1630
+ t = res.result(binding)
1631
+ file.puts t
1632
+
1633
+ res = ERB.new(multiplicity,0,"<>")
1634
+ t = res.result(binding)
1635
+ if !t.nil? && t.size>0
1636
+ file.puts t
1637
+ end
1638
+
1639
+ res = ERB.new(inverse_entity_association_end)
1640
+ t = res.result(binding)
1641
+ file.puts t
1642
+ end
1643
+ end
1644
+
1645
+ # Map EXPRESS Entity Types
1646
+ for entity in entity_list
1647
+ lowBounds = Hash.new
1648
+
1649
+ # Evaluate and write ENTITY start template
1650
+ xmiid = prefix + entity.name
1651
+ xmiid_entity = xmiid
1652
+ res = ERB.new(entity_start_template)
1653
+ t = res.result(binding)
1654
+ file.puts t
1655
+
1656
+
1657
+ # Map Entity is SUBTYPE OF (i.e. list of supertypes)
1658
+ for supertype in entity.supertypes_array
1659
+ xmiid = '_2_supertype' + prefix + entity.name + '-' + supertype.name
1660
+ xmiid_general = get_prefix.call(supertype.schema) + supertype.name
1661
+ res = ERB.new(supertype_template)
1662
+ t = res.result(binding)
1663
+ file.puts t
1664
+ end
1665
+
1666
+ # Map TYPE Select has Entity as item
1667
+ for select in entity.selectedBy
1668
+ if selectTypeType[select.name] != "Remove"
1669
+ superName = select.name
1670
+ subset = selectSubset[superName]
1671
+ if !subset.nil?
1672
+ if !subset.include?(entity.name)
1673
+ selectSubs[superName].each{|e|
1674
+ if selectSubset[e].include?(entity.name)
1675
+ superName = e
1676
+ end}
1677
+ end
1678
+ end
1679
+ xmiid = '_2_selectitem' + prefix + entity.name + '-' + superName
1680
+ xmiid_general = prefix + superName
1681
+ res = ERB.new(supertype_template)
1682
+ t = res.result(binding)
1683
+ file.puts t
1684
+ else
1685
+ # if in a select list that has been removed make it a subtype of all selects that include the removed select
1686
+ for superselect in all_select_list
1687
+ if superselect.selectitems_array.include?(select)
1688
+ superName = superselect.name
1689
+ subset = selectSubset[superName]
1690
+ if !subset.nil?
1691
+ if !subset.include?(select.name)
1692
+ selectSubs[superName].each{|e|
1693
+ if selectSubset[e].include?(select.name)
1694
+ superName = e
1695
+ end}
1696
+ end
1697
+ end
1698
+ puts entity.name + " added to " + superName
1699
+ puts " following removal of " + select.name
1700
+ xmiid = '_2_selectitem' + prefix + entity.name + '-' + superName
1701
+ xmiid_general = prefix + superName
1702
+ res = ERB.new(supertype_template)
1703
+ t = res.result(binding)
1704
+ file.puts t
1705
+ end
1706
+ end
1707
+ end
1708
+ end
1709
+
1710
+ # Map EXPRESS Explicit Attributes
1711
+ attr_list = entity.attributes.find_all{ |e| e.kind_of? EXPSM::Explicit }
1712
+ for attr in attr_list
1713
+ xmiid = '_2_attr' + prefix + entity.name + '-' + attr.name
1714
+
1715
+ # set up references resulting from attribute being a redeclaration
1716
+ if attr.redeclare_entity
1717
+ redeclare_entity = NamedType.find_by_name( attr.redeclare_entity )
1718
+ if attr.redeclare_oldname
1719
+ redefined_xmiid = '_2_attr' + get_prefix.call(redeclare_entity.schema) + attr.redeclare_entity + '-' + attr.redeclare_oldname
1720
+ else
1721
+ redefined_xmiid = '_2_attr' + get_prefix.call(redeclare_entity.schema) + attr.redeclare_entity + '-' + attr.name
1722
+ end
1723
+ end
1724
+
1725
+ # initialize default cardinailty constraints
1726
+ lower = '1'
1727
+ upper = '1'
1728
+ isset = true
1729
+ islist = false
1730
+
1731
+ domain_name = attr.domain
1732
+ orig_domain = NamedType.find_by_name( attr.domain )
1733
+ attr_domain = orig_domain
1734
+ agg_domain = nil
1735
+ attrType = nil
1736
+ associationNeeded = false
1737
+ begin
1738
+ unchanged = true
1739
+ case attr_domain.class.to_s
1740
+ when "EXPSM::Entity"
1741
+ associationNeeded = true
1742
+ when "EXPSM::Type"
1743
+ case selectTypeType[attr_domain.name]
1744
+ when "Entity", "Hybrid"
1745
+ associationNeeded = true
1746
+ end
1747
+ #ignore unhandled named aggregations
1748
+ when "EXPSM::TypeAggregate"
1749
+ if aggTypes[attr.domain].nil?
1750
+ attrType = attr_domain
1751
+ agg_domain = attr_domain
1752
+ if attr_domain.isBuiltin
1753
+ domain_name = attr_domain.domain
1754
+ attr_domain = nil
1755
+ else
1756
+ newDomain = NamedType.find_by_name( attr_domain.domain )
1757
+ attr_domain = newDomain
1758
+ domain_name = attr_domain.name
1759
+ unchanged = false
1760
+ end
1761
+ else
1762
+ associationNeeded = true
1763
+ end
1764
+ when "EXPSM::TypeSelect"
1765
+ case selectTypeType[attr_domain.name]
1766
+ when "Entity", "Hybrid"
1767
+ associationNeeded = true
1768
+ # ignore removed select types
1769
+ when "Remove"
1770
+ attr_domain = attr_domain.selectitems_array[0]
1771
+ domain_name = attr_domain.name
1772
+ unchanged = false
1773
+ end
1774
+ end
1775
+ end until unchanged
1776
+
1777
+ # set up cardinailty constraints from attribute being a 1-D aggregate
1778
+ # or a type defined to be a 1-D aggregate
1779
+ if attr.instance_of? EXPSM::ExplicitAggregate
1780
+ attrType = attr
1781
+ end
1782
+
1783
+ if !attrType.nil?
1784
+ upper = attrType.dimensions[0].upper
1785
+ if upper == '?'
1786
+ upper = '*'
1787
+ end
1788
+ lower = attrType.dimensions[0].lower
1789
+ if attrType.dimensions[0].aggrtype == 'ARRAY'
1790
+ puts 'Warning ARRAY not fully supported for '+attr.name
1791
+ end
1792
+ if attrType.dimensions[0].aggrtype == 'LIST'
1793
+ islist = true
1794
+ end
1795
+ if attrType.dimensions[0].aggrtype == 'BAG'
1796
+ isset = false
1797
+ end
1798
+ if attrType.dimensions[0].aggrtype == 'LIST' and !attrType.dimensions[0].isUnique
1799
+ isset = false
1800
+ end
1801
+ if attrType.rank > 1
1802
+ associationNeeded = true
1803
+ for i in 2..attrType.rank
1804
+ domain_name = attrType.dimensions[i-1].aggrtype+domain_name+lower+upper
1805
+ nestedAggs[domain_name] = attrType.dimensions[i-1]
1806
+ nestedTypes[domain_name] = attrType
1807
+ end
1808
+ end
1809
+ end
1810
+ if attr.isOptional
1811
+ case lower
1812
+ when '0','1'
1813
+ else
1814
+ lowBounds[attr.name] = lower
1815
+ end
1816
+ lower = '0'
1817
+ end
1818
+
1819
+ # Map EXPRESS Explicit Attributes that need an association
1820
+ if associationNeeded
1821
+ if attr_domain.nil?
1822
+ domain_xmiid = prefix + domain_name
1823
+ else
1824
+ domain_xmiid = get_prefix.call(attr_domain.schema) + domain_name
1825
+ end
1826
+ assoc_xmiid = '_1_association' + prefix + entity.name + '-' + attr.name
1827
+
1828
+ direct_inverse = false
1829
+ encapsulatedInto = false
1830
+ for inverse in direct_inverses
1831
+ if inverse.reverseAttr == attr
1832
+ if !inverse.instance_of? EXPSM::InverseAggregate
1833
+ direct_inverse = true
1834
+ encapsulatedInto = isEncapsulatedInto(entity, entity, attr)
1835
+ end
1836
+ end
1837
+ end
1838
+
1839
+ if !attr_domain.nil?
1840
+ if attr_domain == orig_domain
1841
+ encapsulated = isEncapsulated(attr_domain, attr)
1842
+ else
1843
+ if !agg_domain.nil?
1844
+ encapsulated = isEncapsulated(agg_domain, attr)
1845
+ else
1846
+ encapsulated = false
1847
+ end
1848
+ if !encapsulated
1849
+ encapsulated = isEncapsulated(attr_domain, attr)
1850
+ if !encapsulated
1851
+ encapsulated = isEncapsulated(orig_domain, attr)
1852
+ end
1853
+ end
1854
+ end
1855
+ end
1856
+
1857
+ res = ERB.new(attribute_entity_template,0,"<>")
1858
+ t = res.result(binding)
1859
+ file.puts t
1860
+ else
1861
+ # Map EXPRESS Explicit Attributes of Builtin
1862
+ if attr.isBuiltin or (attr_domain.nil?)
1863
+ res = ERB.new(attribute_builtin_template,0,"<>")
1864
+ t = res.result(binding)
1865
+ file.puts t
1866
+ else
1867
+ # Map EXPRESS Explicit Attributes of TYPE, TYPE Enum and TYPE Select (type)
1868
+ type_xmiid = get_prefix.call(attr_domain.schema) + domain_name
1869
+ res = ERB.new(attribute_enum_type_template,0,"<>")
1870
+ t = res.result(binding)
1871
+ file.puts t
1872
+ end
1873
+ end
1874
+
1875
+ res = ERB.new(multiplicity,0,"<>")
1876
+ t = res.result(binding)
1877
+ if !t.nil? && t.size>0
1878
+ file.puts t
1879
+ end
1880
+
1881
+ res = ERB.new(attribute_end)
1882
+ t = res.result(binding)
1883
+ file.puts t
1884
+ end
1885
+
1886
+ #Map EXPRESS Inverse Attributes
1887
+ inverse_attr_list = entity.attributes.find_all{ |e| e.kind_of? EXPSM::Inverse }
1888
+ for inverse in inverse_attr_list
1889
+ xmiid = '_2_attr' + prefix + entity.name + '-' + inverse.name
1890
+ # set up references resulting from attribute being a redeclaration
1891
+ if inverse.redeclare_entity
1892
+ if inverse.redeclare_oldname
1893
+ redefined_xmiid = '_2_attr' + prefix + inverse.redeclare_entity + '-' + inverse.redeclare_oldname
1894
+ else
1895
+ redefined_xmiid = '_2_attr' + prefix + inverse.redeclare_entity + '-' + inverse.name
1896
+ end
1897
+ end
1898
+
1899
+ lower = '1'
1900
+ upper = '1'
1901
+ isset = true
1902
+ if inverse.instance_of? EXPSM::InverseAggregate
1903
+ lower = '0'
1904
+ upper = '*'
1905
+ if inverse.upper != '?'
1906
+ upper = inverse.upper
1907
+ end
1908
+ if inverse.lower != '0'
1909
+ lower = inverse.lower
1910
+ end
1911
+ if inverse.aggrtype == 'BAG'
1912
+ isset = false
1913
+ end
1914
+ end
1915
+ domain_xmiid = prefix + inverse.reverseEntity.name
1916
+ if all_inverse_list.include?(inverse)
1917
+ assoc_xmiid = '_1_association' + get_prefix.call(inverse.reverseEntity.schema) + entity.name + '-' + inverse.name
1918
+ else
1919
+ if inverse.reverseAttr.domain == entity.name
1920
+ assoc_xmiid = '_1_association' + get_prefix.call(inverse.reverseEntity.schema) + inverse.reverseEntity.name + '-' + inverse.reverseAttr_id
1921
+ else
1922
+ assoc_xmiid = '_1_association' + get_prefix.call(inverse.reverseEntity.schema) + entity.name + '-' + inverse.reverseAttr_id
1923
+ end
1924
+ end
1925
+
1926
+ encapsulatedInto = isEncapsulatedInto(inverse.reverseEntity, inverse.reverseEntity, inverse.reverseAttr)
1927
+
1928
+ res = ERB.new(inverse_attribute_template)
1929
+ t = res.result(binding)
1930
+ file.puts t
1931
+
1932
+ res = ERB.new(multiplicity,0,"<>")
1933
+ t = res.result(binding)
1934
+ if !t.nil? && t.size>0
1935
+ file.puts t
1936
+ end
1937
+
1938
+ res = ERB.new(attribute_end)
1939
+ t = res.result(binding)
1940
+ file.puts t
1941
+ end
1942
+
1943
+ # Create lower bound constraints where required
1944
+ lowBounds.each do |name, bound|
1945
+ xmiid = '_3_lb' + prefix + entity.name + '-' + name
1946
+ res = ERB.new(bound_constraint)
1947
+ t = res.result(binding)
1948
+ file.puts t
1949
+ end
1950
+
1951
+ # Map EXPRESS Unique rules
1952
+ if entity.uniques.size > 0
1953
+ for unique in entity.uniques
1954
+ xmiid = '_3_uniq' + prefix + entity.name + '-' + unique.name
1955
+ if unique.attributes.size == 1
1956
+ unique_text = unique.attributes[0]
1957
+ else
1958
+ unique_text = 'Sequence{'+ unique.attributes.join(', ') +'}'
1959
+ end
1960
+ res = ERB.new(unique_template)
1961
+ t = res.result(binding)
1962
+ file.puts t
1963
+ end
1964
+ end
1965
+
1966
+ # Map EXPRESS Where rules
1967
+ whererules = entity.wheres.select {|w| w.name[0..10] != "encapsulate"}
1968
+ if whererules.size > 0
1969
+ for where in whererules
1970
+ xmiid = '_3_whr' + prefix + entity.name + '-' + where.name.to_s
1971
+ where_ocl = get_where(xmiid, where.expression)
1972
+ if where_ocl.size > 0
1973
+ xmiidref = xmiid_entity
1974
+ res = ERB.new(where_template)
1975
+ t = res.result(binding)
1976
+ file.puts t
1977
+ else
1978
+ puts "Where rule " + entity.name + "." + where.name.to_s + " not mapped to OCL - ignored!"
1979
+ end
1980
+ end
1981
+ end
1982
+
1983
+ # Evaluate and write ENTITY end template
1984
+ res = ERB.new(entity_end_template)
1985
+ t = res.result(binding)
1986
+ file.puts t
1987
+ end
1988
+
1989
+ nestedAggs.each do |type_name, dimension|
1990
+ # Evaluate and write aggType start template
1991
+ # initialize default cardinailty constraints
1992
+ isset = true
1993
+ islist = false
1994
+
1995
+ upper = dimension.upper
1996
+ if upper == '?'
1997
+ upper = '*'
1998
+ end
1999
+ lower = dimension.lower
2000
+ if dimension.aggrtype == 'LIST'
2001
+ islist = true
2002
+ end
2003
+ if dimension.aggrtype == 'BAG'
2004
+ isset = false
2005
+ end
2006
+ if dimension.aggrtype == 'LIST' and !dimension.isUnique
2007
+ isset = false
2008
+ end
2009
+
2010
+ xmiid = prefix + type_name
2011
+ type = nestedTypes[type_name]
2012
+ associationNeeded = false
2013
+
2014
+ if type.isBuiltin
2015
+ xmiid_type = $dtprefix + type.domain
2016
+ else
2017
+ xmiid_type = prefix + type.domain
2018
+
2019
+ domain = NamedType.find_by_name( type.domain )
2020
+ case domain.class.to_s
2021
+ when "EXPSM::Entity"
2022
+ associationNeeded = true
2023
+ when "EXPSM::Type"
2024
+ case selectTypeType[type.domain]
2025
+ when "Entity", "Hybrid"
2026
+ associationNeeded = true
2027
+ end
2028
+ when "EXPSM::TypeAggregate"
2029
+ if !aggTypes[type.domain].nil?
2030
+ associationNeeded = true
2031
+ end
2032
+ when "EXPSM::TypeSelect"
2033
+ case selectTypeType[type.domain]
2034
+ when "Entity", "Hybrid"
2035
+ associationNeeded = true
2036
+ end
2037
+ end
2038
+ end
2039
+ res = ERB.new(aggtype_start_template)
2040
+ t = res.result(binding)
2041
+ file.puts t
2042
+
2043
+ if associationNeeded
2044
+ assoc_xmiid = '_1_association' + prefix + type.name + '-elements'
2045
+ end
2046
+
2047
+ xmiid = '_2_attr' + prefix + type.name + "-elements"
2048
+ res = ERB.new(aggtype_attribute)
2049
+ t = res.result(binding)
2050
+ file.puts t
2051
+
2052
+ res = ERB.new(multiplicity,0,"<>")
2053
+ t = res.result(binding)
2054
+ if !t.nil? && t.size>0
2055
+ file.puts t
2056
+ end
2057
+
2058
+ res = ERB.new(attribute_end)
2059
+ t = res.result(binding)
2060
+ file.puts t
2061
+
2062
+ res = ERB.new(type_end_template)
2063
+ t = res.result(binding)
2064
+ file.puts t
2065
+
2066
+ if associationNeeded
2067
+ res = ERB.new(aggtype_association)
2068
+ t = res.result(binding)
2069
+ file.puts t
2070
+ end
2071
+ end
2072
+
2073
+ # Evaluate and write SCHEMA end template
2074
+ res = ERB.new(schema_end_template)
2075
+ t = res.result(binding)
2076
+ file.puts t
2077
+ end
2078
+
2079
+ if schema_list.size > 1
2080
+ res = ERB.new(package_end)
2081
+ t = res.result(binding)
2082
+ file.puts t
2083
+ end
2084
+
2085
+ # Map EXPRESS Entity Types to blocks
2086
+ for schema in schema_list
2087
+ prefix = get_prefix.call(schema)
2088
+
2089
+ entity_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Entity }
2090
+
2091
+ for entity in entity_list
2092
+ # Evaluate and write ENTITY Block template
2093
+ baseClass = prefix + entity.name
2094
+ xmiid = baseClass + '-Block'
2095
+ res = ERB.new(entity_block_template)
2096
+ t = res.result(binding)
2097
+ file.puts t
2098
+ end
2099
+
2100
+ type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::TypeEnum}
2101
+ for type in type_list
2102
+ # Evaluate and write TYPE ValueType template
2103
+ baseType = prefix + type.name
2104
+ xmiid = baseType + '-ValueType'
2105
+ res = ERB.new(valuetype_template)
2106
+ t = res.result(binding)
2107
+ file.puts t
2108
+ end
2109
+
2110
+ type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::Type and e.isBuiltin}
2111
+ for type in type_list
2112
+ # Evaluate and write TYPE ValueType template
2113
+ baseType = prefix + type.name
2114
+ xmiid = baseType + '-ValueType'
2115
+ res = ERB.new(valuetype_template)
2116
+ t = res.result(binding)
2117
+ file.puts t
2118
+ end
2119
+
2120
+ type_list = schema.contents.find_all{ |e| e.instance_of? EXPSM::Type and !e.isBuiltin}
2121
+ for type in type_list
2122
+ superselect = NamedType.find_by_name( type.domain )
2123
+ if !superselect.kind_of? EXPSM::TypeSelect
2124
+ # Evaluate and write TYPE ValueType template
2125
+ baseType = prefix + type.name
2126
+ xmiid = baseType + '-ValueType'
2127
+ res = ERB.new(valuetype_template)
2128
+ t = res.result(binding)
2129
+ file.puts t
2130
+ end
2131
+ end
2132
+ end
2133
+
2134
+ for select in all_select_list
2135
+ case selectTypeType[select.name]
2136
+ when "Type"
2137
+ # Evaluate and write TYPE ValueType template
2138
+ baseType = prefix + select.name
2139
+ xmiid = baseType + '-ValueType'
2140
+ res = ERB.new(valuetype_template)
2141
+ t = res.result(binding)
2142
+ file.puts t
2143
+ xmiid = baseType + '-Auxiliary'
2144
+ res = ERB.new(select_stereotype_template)
2145
+ t = res.result(binding)
2146
+ file.puts t
2147
+ when "Remove"
2148
+ # do nothing
2149
+ else
2150
+ # Evaluate and write ENTITY Block template
2151
+ baseClass = prefix + select.name
2152
+ xmiid = baseClass + '-Block'
2153
+ res = ERB.new(entity_block_template)
2154
+ t = res.result(binding)
2155
+ file.puts t
2156
+ xmiid = baseClass + '-Auxiliary'
2157
+ res = ERB.new(select_stereotype_template)
2158
+ t = res.result(binding)
2159
+ file.puts t
2160
+ end
2161
+ end
2162
+
2163
+ selectSubset.each_key do |select|
2164
+ if selectSubs[select].nil?
2165
+ case selectTypeType[select]
2166
+ when "Type"
2167
+ # Evaluate and write TYPE ValueType template
2168
+ baseType = prefix + select
2169
+ xmiid = baseType + '-ValueType'
2170
+ res = ERB.new(valuetype_template)
2171
+ t = res.result(binding)
2172
+ file.puts t
2173
+ xmiid = baseType + '-Auxiliary'
2174
+ res = ERB.new(select_stereotype_template)
2175
+ t = res.result(binding)
2176
+ file.puts t
2177
+ when "Remove"
2178
+ # do nothing
2179
+ else
2180
+ # Evaluate and write ENTITY Block template
2181
+ baseClass = prefix + select
2182
+ xmiid = baseClass + '-Block'
2183
+ res = ERB.new(entity_block_template)
2184
+ t = res.result(binding)
2185
+ file.puts t
2186
+ xmiid = baseClass + '-Auxiliary'
2187
+ res = ERB.new(select_stereotype_template)
2188
+ t = res.result(binding)
2189
+ file.puts t
2190
+ end
2191
+ end
2192
+ end
2193
+
2194
+ typeProxies.each_value do |type|
2195
+ # Evaluate and write ENTITY Block template
2196
+ baseClass = prefix + type.name + "_Proxy"
2197
+ xmiid = baseClass + '-Block'
2198
+ res = ERB.new(entity_block_template)
2199
+ t = res.result(binding)
2200
+ file.puts t
2201
+ xmiid = baseClass + '-Type'
2202
+ res = ERB.new(type_stereotype_template)
2203
+ t = res.result(binding)
2204
+ file.puts t
2205
+ end
2206
+
2207
+ aggTypes.each_value do |type|
2208
+ # Evaluate and write ENTITY Block template
2209
+ baseClass = prefix + type.name
2210
+ xmiid = baseClass + '-Block'
2211
+ res = ERB.new(entity_block_template)
2212
+ t = res.result(binding)
2213
+ file.puts t
2214
+ xmiid = baseClass + '-Type'
2215
+ res = ERB.new(type_stereotype_template)
2216
+ t = res.result(binding)
2217
+ file.puts t
2218
+ end
2219
+
2220
+ nestedTypes.each_key do |type_name|
2221
+ # Evaluate and write ENTITY Block template
2222
+ baseClass = prefix + type_name
2223
+ xmiid = baseClass + '-Block'
2224
+ res = ERB.new(entity_block_template)
2225
+ t = res.result(binding)
2226
+ file.puts t
2227
+ xmiid = baseClass + '-Type'
2228
+ res = ERB.new(type_stereotype_template)
2229
+ t = res.result(binding)
2230
+ file.puts t
2231
+ end
2232
+
2233
+ if dtHandle != "ignore"
2234
+ if dtHandle == "export"
2235
+ if !uuidSafe.nil?
2236
+ tmp = uuidSafe
2237
+ uuidSafe = $uuidxml
2238
+ $uuidxml = tmp
2239
+ tmp = uuidOldSafe
2240
+ uuidOldSafe = $olduuids
2241
+ $olduuids = tmp
2242
+ end
2243
+ end
2244
+ res = ERB.new(data_type_stereos)
2245
+ t = res.result(binding)
2246
+ dtfile.puts t
2247
+ if dtHandle == "export"
2248
+ res = ERB.new(overall_end_template)
2249
+ t = res.result(binding)
2250
+ dtfile.puts t
2251
+ if !uuidSafe.nil?
2252
+ for uuidmap in $olduuids
2253
+ uuidmap.remove
2254
+ end
2255
+ File.open("DataTypes_UUIDs.xml","w"){|file| $uuidxml.write_xml_to file}
2256
+ $uuidxml = uuidSafe
2257
+ $olduuids = uuidOldSafe
2258
+ end
2259
+ dtfile.close
2260
+ end
2261
+ end
2262
+
2263
+ # Evaluate and write file end template
2264
+ res = ERB.new(overall_end_template)
2265
+ t = res.result(binding)
2266
+ file.puts t
2267
+
2268
+ file.close
2269
+
2270
+ if $uuidsRequired
2271
+ for uuidmap in $olduuids
2272
+ uuidmap.remove
2273
+ end
2274
+ File.open("UUIDs.xml","w"){|file| $uuidxml.write_xml_to file}
2275
+ end
2276
+
2277
+ if !$wherexml.nil?
2278
+ File.open("WhereRuleMapping.xml","w"){|file| $wherexml.write_xml_to file}
2279
+ end
2280
+ end
2281
+