activefacts 0.8.6 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/Manifest.txt +33 -2
  2. data/README.rdoc +30 -36
  3. data/Rakefile +16 -20
  4. data/bin/afgen +17 -11
  5. data/bin/cql +313 -36
  6. data/download.html +43 -19
  7. data/examples/CQL/Address.cql +15 -15
  8. data/examples/CQL/Blog.cql +8 -8
  9. data/examples/CQL/CompanyDirectorEmployee.cql +6 -5
  10. data/examples/CQL/Death.cql +3 -3
  11. data/examples/CQL/Diplomacy.cql +48 -0
  12. data/examples/CQL/Genealogy.cql +41 -41
  13. data/examples/CQL/Insurance.cql +311 -0
  14. data/examples/CQL/JoinEquality.cql +35 -0
  15. data/examples/CQL/Marriage.cql +1 -1
  16. data/examples/CQL/Metamodel.cql +290 -185
  17. data/examples/CQL/MetamodelNext.cql +420 -0
  18. data/examples/CQL/Monogamy.cql +24 -0
  19. data/examples/CQL/MonthInSeason.cql +27 -0
  20. data/examples/CQL/Moon.cql +23 -0
  21. data/examples/CQL/MultiInheritance.cql +4 -4
  22. data/examples/CQL/NonRoleId.cql +14 -0
  23. data/examples/CQL/OddIdentifier.cql +18 -0
  24. data/examples/CQL/OilSupply.cql +24 -24
  25. data/examples/CQL/OneToOnes.cql +17 -0
  26. data/examples/CQL/Orienteering.cql +55 -55
  27. data/examples/CQL/OrienteeringER.cql +58 -0
  28. data/examples/CQL/PersonPlaysGame.cql +2 -2
  29. data/examples/CQL/RedundantDependency.cql +34 -0
  30. data/examples/CQL/SchoolActivities.cql +5 -5
  31. data/examples/CQL/SeparateSubtype.cql +28 -0
  32. data/examples/CQL/ServiceDirector.cql +283 -0
  33. data/examples/CQL/SimplestUnary.cql +2 -2
  34. data/examples/CQL/SubtypePI.cql +11 -11
  35. data/examples/CQL/Supervision.cql +38 -0
  36. data/examples/CQL/Tests.Test5.Load.cql +38 -0
  37. data/examples/CQL/WaiterTips.cql +33 -0
  38. data/examples/CQL/Warehousing.cql +55 -53
  39. data/examples/CQL/WindowInRoomInBldg.cql +9 -9
  40. data/examples/CQL/unit.cql +433 -544
  41. data/examples/index.html +314 -170
  42. data/examples/intro.html +6 -176
  43. data/examples/local.css +8 -4
  44. data/index.html +40 -25
  45. data/lib/activefacts/api/concept.rb +2 -2
  46. data/lib/activefacts/api/constellation.rb +4 -4
  47. data/lib/activefacts/api/instance.rb +2 -2
  48. data/lib/activefacts/api/instance_index.rb +4 -0
  49. data/lib/activefacts/api/numeric.rb +3 -1
  50. data/lib/activefacts/api/role.rb +1 -1
  51. data/lib/activefacts/api/standard_types.rb +23 -16
  52. data/lib/activefacts/api/support.rb +3 -1
  53. data/lib/activefacts/api/vocabulary.rb +4 -0
  54. data/lib/activefacts/cql/CQLParser.treetop +87 -39
  55. data/lib/activefacts/cql/Concepts.treetop +95 -69
  56. data/lib/activefacts/cql/Context.treetop +11 -2
  57. data/lib/activefacts/cql/Expressions.treetop +23 -59
  58. data/lib/activefacts/cql/FactTypes.treetop +141 -95
  59. data/lib/activefacts/cql/Language/English.treetop +33 -21
  60. data/lib/activefacts/cql/LexicalRules.treetop +6 -1
  61. data/lib/activefacts/cql/Terms.treetop +75 -26
  62. data/lib/activefacts/cql/ValueTypes.treetop +52 -54
  63. data/lib/activefacts/cql/compiler.rb +46 -1691
  64. data/lib/activefacts/cql/compiler/constraint.rb +602 -0
  65. data/lib/activefacts/cql/compiler/entity_type.rb +425 -0
  66. data/lib/activefacts/cql/compiler/fact.rb +300 -0
  67. data/lib/activefacts/cql/compiler/fact_type.rb +230 -0
  68. data/lib/activefacts/cql/compiler/reading.rb +832 -0
  69. data/lib/activefacts/cql/compiler/shared.rb +109 -0
  70. data/lib/activefacts/cql/compiler/value_type.rb +104 -0
  71. data/lib/activefacts/cql/parser.rb +132 -81
  72. data/lib/activefacts/generate/cql.rb +397 -274
  73. data/lib/activefacts/generate/oo.rb +13 -12
  74. data/lib/activefacts/generate/ordered.rb +107 -117
  75. data/lib/activefacts/generate/ruby.rb +34 -38
  76. data/lib/activefacts/generate/sql/mysql.rb +62 -45
  77. data/lib/activefacts/generate/sql/server.rb +59 -42
  78. data/lib/activefacts/input/cql.rb +6 -3
  79. data/lib/activefacts/input/orm.rb +991 -557
  80. data/lib/activefacts/persistence/columns.rb +16 -12
  81. data/lib/activefacts/persistence/foreignkey.rb +7 -4
  82. data/lib/activefacts/persistence/index.rb +3 -4
  83. data/lib/activefacts/persistence/reference.rb +5 -2
  84. data/lib/activefacts/support.rb +20 -14
  85. data/lib/activefacts/version.rb +1 -1
  86. data/lib/activefacts/vocabulary.rb +1 -0
  87. data/lib/activefacts/vocabulary/extensions.rb +328 -44
  88. data/lib/activefacts/vocabulary/metamodel.rb +145 -20
  89. data/lib/activefacts/vocabulary/verbaliser.rb +621 -0
  90. data/spec/absorption_spec.rb +4 -4
  91. data/spec/api/value_type.rb +1 -1
  92. data/spec/cql/context_spec.rb +45 -22
  93. data/spec/cql/deontic_spec.rb +88 -0
  94. data/spec/cql/matching_spec.rb +517 -0
  95. data/spec/cql/samples_spec.rb +88 -31
  96. data/spec/cql/unit_spec.rb +58 -37
  97. data/spec/cql_cql_spec.rb +12 -7
  98. data/spec/cql_mysql_spec.rb +3 -7
  99. data/spec/cql_parse_spec.rb +0 -4
  100. data/spec/cql_ruby_spec.rb +1 -4
  101. data/spec/cql_sql_spec.rb +5 -18
  102. data/spec/cql_symbol_tables_spec.rb +3 -0
  103. data/spec/cqldump_spec.rb +0 -2
  104. data/spec/helpers/array_matcher.rb +35 -0
  105. data/spec/helpers/ctrl_c_support.rb +52 -0
  106. data/spec/helpers/diff_matcher.rb +38 -0
  107. data/spec/helpers/file_matcher.rb +5 -3
  108. data/spec/helpers/string_matcher.rb +39 -0
  109. data/spec/helpers/test_parser.rb +13 -0
  110. data/spec/norma_cql_spec.rb +13 -5
  111. data/spec/norma_ruby_spec.rb +11 -3
  112. data/spec/{absorption_ruby_spec.rb → norma_ruby_sql_spec.rb} +37 -32
  113. data/spec/norma_sql_spec.rb +11 -5
  114. data/spec/norma_tables_spec.rb +33 -29
  115. data/spec/spec_helper.rb +4 -1
  116. data/status.html +92 -23
  117. metadata +102 -36
  118. data/lib/activefacts/generate/cql/html.rb +0 -403
data/download.html CHANGED
@@ -13,15 +13,17 @@
13
13
  </h2>
14
14
 
15
15
  <p>
16
- ActiveFacts is <a href="http://rubygems.rubyforge.org/">packaged</a>
17
- as a <a href="http://www.ruby-lang.org/">Ruby</a> <a href="http://gems.rubyforge.org/">GEM</a>.
18
- You should install Ruby, and say
16
+ ActiveFacts is packaged as a <a href="http://www.ruby-lang.org/">Ruby</a> <a href="http://gems.rubyforge.org/">GEM</a>.
17
+ If you have Ruby installed, just say (omit "sudo" on Windows):
19
18
  </p>
20
19
 
21
20
  <pre>
22
21
  sudo gem install activefacts
23
22
  </pre>
24
23
 
24
+ <h3 class="title">
25
+ API Documentation
26
+ </h3>
25
27
  <p>
26
28
  After installing, you can read the Ruby API documentation by visiting
27
29
  <a href="http://localhost:8808/">http://localhost:8808/</a> in your browser after starting
@@ -30,41 +32,63 @@
30
32
  gem server
31
33
  </pre>
32
34
 
35
+ <h3 class="title">
36
+ The ActiveFacts generator
37
+ </h3>
33
38
  <p>
34
- CQL Examples are provided in a directory under your gem directory, and you can generate
35
- code from them using commands like the following (change the path to your gem repository):
39
+ CQL Examples are provided in the <b>examples/CQL</b> directory under activefacts in your gem directory
40
+ (mine is <b>/opt/local/lib/ruby/gems/1.8/gems/</b>). Copy the files you're interested in and you can
41
+ generate code from them using commands like the following:
36
42
  </p>
37
43
 
38
44
  <pre>
39
- afgen --ruby /opt/local/lib/ruby/gems/1.8/gems/activefacts-0.6.0/examples/CQL/OilSupply.cql
40
- afgen --sql/server /opt/local/lib/ruby/gems/1.8/gems/activefacts-0.6.0/examples/CQL/Warehousing.cql
45
+ afgen --ruby OilSupply.cql
46
+ afgen --sql/server Warehousing.cql
41
47
  </pre>
42
48
 
43
49
  <p>
44
50
  <em>afgen</em> also reads <em>.orm</em> files from <a href="http://ormfoundation.org/files">NORMA</a>.
51
+ You might also try the CQL command line tool.
45
52
  </p>
46
53
 
47
- <h3>Source Code Repository</h3>
54
+ <h3 class="title">
55
+ Installing on Windows
56
+ </h3>
48
57
  <p>
49
- The <a href="http://subversion.tigris.org/">Subversion</a> repository is also available
50
- at <a href="http://rubyforge.org/projects/activefacts/">RubyForge</a>.
51
- If you're on Windows and don't have Subversion installed, you can also
52
- get a client like Tortoise or cygwin. If you use a command-line <em>svn</em> client, say:
58
+ Use the Ruby 1.8.7 installer from <a href="http://rubyinstaller.org/downloads/">RubyInstaller</a>.
59
+ After running the installer, you need to add Ruby to your PATH. The default install location is
60
+ C:\Ruby187\, so execute the following command in a Windows command prompt:
53
61
  </p>
54
62
  <pre>
55
- svn checkout http://activefacts.rubyforge.org/svn/
56
-
57
- or
58
-
59
- svn checkout svn://rubyforge.org/var/svn/activefacts
63
+ PATH C:\Ruby187\bin;%PATH%
60
64
  </pre>
65
+ <p>
66
+ Or right-click "My Computer" -%gt; Properties -%gt; Advanced -%gt; Environment Variables -%gt; System Variables
67
+ Scroll down to find the entry for Path and double-click it. Click in the Variable value: text widget and move the cursor to the start of the value before typing <b>C:\Ruby187;</b> before the first entry. Hit Ok three times and start a new command prompt.
68
+ </p>
69
+ <p>
70
+ If you got that all right, you should be able to enter the interactive Ruby
71
+ interpreter in the command prompt by typing <b>irb &lt;ENTER&gt;</b>. Exit
72
+ from irb (^D) and you should be able to use <b>gem install activefacts</b>
73
+ as above. If your computer is behind a firewall, download the activefacts
74
+ gem file, along with those for
75
+ <a href="http://rubygems.org/gems/treetop/versions/1.4.8">Treetop</a>,
76
+ <a href="http://rubygems.org/gems/polyglot/versions/0.3.1">Polyglot</a> and
77
+ <a href="http://rubygems.org/gems/rake/versions/0.8.7">Rake</a>, and use
78
+ <b>gem install &lt;file&gt;.gem</b> to install those in the reverse order.
79
+ </p>
80
+
81
+ <h3>Source Code Repository</h3>
82
+ <p>
83
+ The source code is available at <a href="http://github.com/cjheath/activefacts/">GitHub</a>.
84
+ </p>
61
85
 
62
86
  <h3>Object Role Modeling</h3>
63
87
  <p>
64
- If you want to draw your own <a href="www.orm.net">Object Role Modeling</a>
88
+ If you want to draw your own <a href="http://www.orm.net">Object Role Modeling</a>
65
89
  diagrams and have a copy of Windows Visual Studio (pro only, not Express),
66
90
  you can freely download and install the <a href="http://www.ormfoundation.com/files/">Neumont ORM Architect</a>.
67
- The example models are available in the correct format from the SVN repository.
91
+ The example models are available in the correct format from the <a href="examples/">examples directory</a>.
68
92
  The ActiveFacts generator <em>afgen</em> can process ORM files as easily as
69
93
  CQL files, though a little slower due to the volume of XML to be parsed.
70
94
  </p>
@@ -3,13 +3,13 @@ vocabulary Address;
3
3
  /*
4
4
  * Value Types
5
5
  */
6
- City is written as VariableLengthText(64);
7
- CompanyName is written as VariableLengthText;
8
- FamilyName is written as VariableLengthText(20);
9
- GivenNames is written as VariableLengthText(20);
10
- Number is written as VariableLengthText(12);
11
- Postcode is written as VariableLengthText;
12
- StreetLine is written as VariableLengthText(64);
6
+ City is written as String(64);
7
+ Company Name is written as String;
8
+ Family Name is written as String(20);
9
+ Given Names is written as String(20);
10
+ Number is written as String(12);
11
+ Postcode is written as String;
12
+ Street Line is written as String(64);
13
13
 
14
14
  /*
15
15
  * Entity Types
@@ -18,15 +18,15 @@ Company is identified by its Name;
18
18
 
19
19
  Family is identified by its Name;
20
20
 
21
- Person is identified by Family and GivenNames where
21
+ Person is identified by Family and Given Names where
22
22
  Person is of one Family,
23
23
  Family includes Person,
24
- Person has one GivenNames;
24
+ Person has one Given Names;
25
25
 
26
- Street is identified by first-StreetLine and second-StreetLine and third-StreetLine where
27
- Street includes one first-StreetLine,
28
- Street includes at most one second-StreetLine,
29
- Street includes at most one third-StreetLine;
26
+ Street is identified by first-Street Line and second-Street Line and third-Street Line where
27
+ Street includes one first-Street Line,
28
+ Street includes at most one second-Street Line,
29
+ Street includes at most one third-Street Line;
30
30
 
31
31
  Address is identified by street-Number and Street and City and Postcode where
32
32
  Address is at at most one street-Number,
@@ -40,5 +40,5 @@ Person lives at at most one Address;
40
40
  /*
41
41
  * Constraints:
42
42
  */
43
- Street includes third-StreetLine
44
- only if Street includes second-StreetLine;
43
+ Street includes third Street Line
44
+ only if Street includes second Street Line;
@@ -3,14 +3,14 @@ vocabulary Blog;
3
3
  /*
4
4
  * Value Types
5
5
  */
6
- AuthorId is written as AutoCounter;
7
- CommentId is written as AutoCounter;
8
- Name is written as VariableLengthText(64);
9
- Ordinal is written as UnsignedInteger(32);
10
- PostId is written as AutoCounter;
11
- Style is written as VariableLengthText(20);
12
- Text is written as LargeLengthText;
13
- TopicId is written as AutoCounter;
6
+ Author Id is written as Auto Counter;
7
+ Comment Id is written as Auto Counter;
8
+ Name is written as String(64);
9
+ Ordinal is written as Unsigned Integer(32);
10
+ Post Id is written as Auto Counter;
11
+ Style is written as String(20);
12
+ Text is written as Text;
13
+ Topic Id is written as Auto Counter;
14
14
 
15
15
  /*
16
16
  * Entity Types
@@ -3,15 +3,16 @@ vocabulary CompanyDirectorEmployee;
3
3
  /*
4
4
  * Value Types
5
5
  */
6
- CompanyName is written as VariableLengthText(48);
7
- EmployeeNr is written as SignedInteger(32);
8
- Name is written as VariableLengthText(48);
6
+ Company Name is written as String(48);
7
+ Date is written as Date;
8
+ Employee Nr is written as Signed Integer(32);
9
+ Name is written as String(48);
9
10
 
10
11
  /*
11
12
  * Entity Types
12
13
  */
13
14
  Company is identified by its Name where
14
- Company is called CompanyName;
15
+ Company is called Company Name;
15
16
  Company is listed;
16
17
 
17
18
  Meeting is identified by Date and Meeting is board meeting and Company where
@@ -48,4 +49,4 @@ Manager is ceo;
48
49
  /*
49
50
  * Constraints:
50
51
  */
51
- either that Employee is ceo or that Employee is supervised by some Manager but not both;
52
+ either Employee is supervised by Manager(1) or Employee is a Manager(2) that is ceo but not both;
@@ -3,8 +3,8 @@ vocabulary Death;
3
3
  /*
4
4
  * Value Types
5
5
  */
6
- CauseOfDeath is written as VariableLengthText;
7
- PersonName is written as VariableLengthText(40);
6
+ Cause Of Death is written as String;
7
+ Person Name is written as String(40);
8
8
 
9
9
  /*
10
10
  * Entity Types
@@ -13,5 +13,5 @@ Person is identified by its Name [independent];
13
13
 
14
14
  Death is where
15
15
  Person is dead;
16
- Death was due to at most one CauseOfDeath;
16
+ Death was due to at most one Cause Of Death;
17
17
 
@@ -0,0 +1,48 @@
1
+ vocabulary Diplomacy;
2
+
3
+ /*
4
+ * Value Types
5
+ */
6
+ CountryName is written as String;
7
+ DiplomatName is written as String;
8
+ LanguageName is written as String;
9
+
10
+ /*
11
+ * Entity Types
12
+ */
13
+ Country is identified by its Name;
14
+
15
+ Diplomat is identified by its Name;
16
+ Diplomat represents one Country;
17
+ Diplomat serves in one Country;
18
+
19
+ Language is identified by its Name;
20
+
21
+ LanguageUse is where
22
+ Language is spoken in Country,
23
+ Country uses at least one Language;
24
+
25
+ Ambassador is a kind of Diplomat;
26
+
27
+ Fluency is where
28
+ Diplomat speaks at least one Language,
29
+ Language is spoken by Diplomat;
30
+
31
+ Representation is where
32
+ Ambassador is from Country(1) to Country(2),
33
+ Country(1) is represented in Country(2) by one Ambassador;
34
+
35
+ /*
36
+ * Constraints:
37
+ */
38
+ for each Diplomat, Country at most one of these holds:
39
+ Diplomat serves in Country,
40
+ Diplomat represents Country;
41
+ Ambassador is from Country(1) to Country(2)
42
+ only if Ambassador is a kind of Diplomat that represents Country(1);
43
+ Ambassador is from Country(2) to Country(1)
44
+ only if Ambassador is a kind of Diplomat that serves in Country(1);
45
+ Diplomat serves in Country
46
+ only if Diplomat speaks Language that is spoken in Country;
47
+ each Ambassador occurs at least one time in
48
+ Ambassador is from Country to Country;
@@ -3,47 +3,47 @@ vocabulary Genealogy;
3
3
  /*
4
4
  * Value Types
5
5
  */
6
- Address is written as VariableLengthText(128);
7
- Certificate is written as VariableLengthText(64);
8
- Day is written as UnsignedInteger(32) restricted to {1..31};
9
- Email is written as VariableLengthText(64);
10
- EventID is written as AutoCounter;
11
- EventLocation is written as VariableLengthText(128);
12
- EventRoleName is written as VariableLengthText restricted to {'Celebrant', 'Father', 'Husband', 'Mother', 'Subject', 'Wife'};
13
- EventTypeID is written as AutoCounter;
14
- EventTypeName is written as VariableLengthText(16) restricted to {'Birth', 'Burial', 'Christening', 'Death', 'Divorce', 'Marriage'};
15
- Gender is written as FixedLengthText(1) restricted to {'F', 'M'};
16
- Month is written as UnsignedInteger(32) restricted to {1..12};
17
- Name is written as VariableLengthText(128);
18
- Occupation is written as VariableLengthText(128);
19
- Official is written as VariableLengthText(64);
20
- PersonID is written as AutoCounter;
21
- Picture is written as PictureRawData(20);
22
- RoleID is written as AutoCounter;
23
- SourceID is written as AutoCounter;
24
- SourceName is written as VariableLengthText(128);
25
- UserID is written as AutoCounter;
26
- Year is written as UnsignedInteger(32);
6
+ Address is written as String(128);
7
+ Certificate is written as String(64);
8
+ Day is written as Unsigned Integer(32) restricted to {1..31};
9
+ Email is written as String(64);
10
+ Event ID is written as Auto Counter;
11
+ Event Location is written as String(128);
12
+ Event Role Name is written as String restricted to {'Celebrant', 'Father', 'Husband', 'Mother', 'Subject', 'Wife'};
13
+ Event Type ID is written as Auto Counter;
14
+ Event Type Name is written as String(16) restricted to {'Birth', 'Burial', 'Christening', 'Death', 'Divorce', 'Marriage'};
15
+ Gender is written as Char(1) restricted to {'F', 'M'};
16
+ Month is written as Unsigned Integer(32) restricted to {1..12};
17
+ Name is written as String(128);
18
+ Occupation is written as String(128);
19
+ Official is written as String(64);
20
+ Person ID is written as Auto Counter;
21
+ Picture is written as Image(20);
22
+ Role ID is written as Auto Counter;
23
+ Source ID is written as Auto Counter;
24
+ Source Name is written as String(128);
25
+ User ID is written as Auto Counter;
26
+ Year is written as Unsigned Integer(32);
27
27
 
28
28
  /*
29
29
  * Entity Types
30
30
  */
31
31
  Event is identified by its ID;
32
32
  Event is certified by at most one Certificate;
33
- Event occurred at at most one EventLocation;
33
+ Event occurred at at most one Event Location;
34
34
  Event was confirmed by at most one Official;
35
35
 
36
- EventDate is identified by min-Year and max-Year and Month and Day where
37
- EventDate wasnt before at most one min-Year,
38
- EventDate wasnt after at most one max-Year,
39
- EventDate occurred in at most one Month,
40
- EventDate occurred on at most one Day;
41
- Event occurred on at most one EventDate;
36
+ Event Date is identified by min-Year and max-Year and Month and Day where
37
+ Event Date wasnt before at most one min-Year,
38
+ Event Date wasnt after at most one max-Year,
39
+ Event Date occurred in at most one Month,
40
+ Event Date occurred on at most one Day;
41
+ Event occurred on at most one Event Date;
42
42
 
43
- EventType is identified by its ID;
44
- Event is of at most one EventType;
45
- EventType is called one EventTypeName,
46
- EventTypeName is name of at most one EventType;
43
+ Event Type is identified by its ID;
44
+ Event is of at most one Event Type;
45
+ Event Type is called one Event Type Name,
46
+ Event Type Name is name of at most one Event Type;
47
47
 
48
48
  Person is identified by its ID;
49
49
  Address is of Person,
@@ -61,12 +61,12 @@ preferred-Picture is of Person,
61
61
  Person has at most one preferred-Picture;
62
62
 
63
63
  Role is identified by its ID;
64
- Role is called one EventRoleName,
65
- EventRoleName is name of one Role;
64
+ Role is called one Event Role Name,
65
+ Event Role Name is name of one Role;
66
66
 
67
67
  Source is identified by its ID;
68
- Source has one SourceName,
69
- SourceName is of at most one Source;
68
+ Source has one Source Name,
69
+ Source Name is of at most one Source;
70
70
 
71
71
  User is identified by its ID;
72
72
  Email is of User,
@@ -86,12 +86,12 @@ Participation is where
86
86
  /*
87
87
  * Constraints:
88
88
  */
89
+ each Event Date occurs at least one time in
90
+ Event Date wasnt before min Year,
91
+ Event Date wasnt after max Year,
92
+ Event Date occurred in Month,
93
+ Event Date occurred on Day;
89
94
  each Event occurs at least one time in
90
95
  Person played Role in Event according to Source;
91
- each EventDate occurs at least one time in
92
- EventDate wasnt before min-Year,
93
- EventDate wasnt after max-Year,
94
- EventDate occurred in Month,
95
- EventDate occurred on Day;
96
96
  each Person occurs at least one time in
97
97
  Person played Role in Event according to Source;
@@ -0,0 +1,311 @@
1
+ vocabulary Insurance;
2
+
3
+ /*
4
+ * Value Types
5
+ */
6
+ Alias is written as Char(3);
7
+ Application Nr is written as Signed Integer(32);
8
+ Asset ID is written as Auto Counter;
9
+ Badge is written as String;
10
+ Charge is written as String;
11
+ City is written as String;
12
+ Claim ID is written as Auto Counter;
13
+ Claim Sequence is written as Unsigned Integer(32) restricted to {1..999};
14
+ Colour is written as String;
15
+ Contact Method is written as Char(1) restricted to {'B', 'H', 'M'};
16
+ Count is written as Unsigned Integer(32);
17
+ Cover Type Code is written as Char;
18
+ Cover Type Name is written as String;
19
+ Date is written as Date;
20
+ Date Time is written as Date Time;
21
+ Demerit Kind Name is written as String;
22
+ Description is written as String(1024);
23
+ Email is written as String;
24
+ Engine Number is written as String;
25
+ ITC Claimed is written as Decimal(18,2) restricted to {0.0..100.0};
26
+ Intoxication is written as String;
27
+ Liability Code is written as Char(1) restricted to {'D', 'L', 'R', 'U'};
28
+ License Number is written as String;
29
+ License Type is written as String;
30
+ Location is written as String;
31
+ Loss Type Code is written as Char;
32
+ Lost Item Nr is written as Signed Integer(32);
33
+ Make is written as String;
34
+ Model is written as String;
35
+ Name is written as String(256);
36
+ Occupation is written as String;
37
+ Party ID is written as Auto Counter;
38
+ Phone Nr is written as String;
39
+ Place is written as String;
40
+ Policy Serial is written as Unsigned Integer(32) restricted to {1..99999};
41
+ Policy Wording Text is written as String;
42
+ Postcode is written as String;
43
+ Price is written as Decimal(18,2);
44
+ Prod Description is written as String(80);
45
+ Product Code is written as Unsigned Integer(8) restricted to {1..99};
46
+ Reason is written as String;
47
+ Registration Nr is written as Char(8);
48
+ Report Nr is written as Signed Integer(32);
49
+ State Code is written as Unsigned Integer(8) restricted to {0..9};
50
+ State Name is written as String(256);
51
+ Street is written as String(256);
52
+ Test Result is written as String;
53
+ Time is written as Time;
54
+ Title is written as String;
55
+ VIN is written as Unsigned Integer(32);
56
+ Year Nr is written as Signed Integer(32);
57
+
58
+ /*
59
+ * Entity Types
60
+ */
61
+ Application is identified by its Nr;
62
+
63
+ Asset is identified by its ID;
64
+
65
+ Claim is identified by its ID;
66
+ Claim has one Claim Sequence (as p_sequence),
67
+ p_sequence is of Claim;
68
+
69
+ Cover Type is identified by its Code;
70
+ Cover Type has one Cover Type Name,
71
+ Cover Type Name is of at most one Cover Type;
72
+
73
+ Demerit Kind is identified by its Name [independent];
74
+
75
+ Incident is identified by Claim where
76
+ Claim concerns at most one Incident,
77
+ Incident is of one Claim;
78
+ Incident relates to loss on one Date Time;
79
+
80
+ Liability is identified by its Code restricted to {'D', 'L', 'R', 'U'};
81
+
82
+ Loss Type is identified by its Code;
83
+ Loss Type implies at most one Liability;
84
+ Loss Type involves driving;
85
+ Loss Type is single vehicle incident;
86
+
87
+ Lost Item is identified by Incident and Lost Item Nr where
88
+ Lost Item was lost in one Incident,
89
+ Lost Item has one Lost Item Nr,
90
+ Lost Item Nr is of Lost Item;
91
+ Description is of Lost Item,
92
+ Lost Item has one Description;
93
+ Lost Item was purchased on at most one purchase-Date;
94
+ Lost Item was purchased at at most one purchase-Place;
95
+ Lost Item was purchased for at most one purchase-Price;
96
+
97
+ Party is identified by its ID;
98
+ Party is a company;
99
+
100
+ Person is a kind of Party;
101
+ Person has at most one Occupation;
102
+ Person has one Title;
103
+ Person has at most one birth-Date;
104
+ Person has one family-Name;
105
+ Person has one given-Name;
106
+
107
+ Phone is identified by its Nr;
108
+
109
+ Police Report is identified by Incident where
110
+ Incident is covered by at most one Police Report,
111
+ Police Report covers one Incident;
112
+ Police Report was to at most one officer-Name;
113
+ Police Report has at most one police-Report Nr;
114
+ Police Report was on at most one report-Date Time;
115
+ Police Report was by at most one reporter-Name;
116
+ Police Report was at at most one station-Name;
117
+
118
+ Policy Wording is identified by its Text;
119
+
120
+ Product is identified by its Code;
121
+ Alias is of at most one Product,
122
+ Product has at most one Alias;
123
+ Prod Description is of at most one Product,
124
+ Product has at most one Prod Description;
125
+
126
+ Registration is identified by its Nr;
127
+
128
+ State is identified by its Code [independent];
129
+ State Name is of at most one State,
130
+ State has at most one State Name;
131
+
132
+ Vehicle is a kind of Asset identified by VIN where
133
+ Vehicle has one VIN,
134
+ VIN is of at most one Vehicle;
135
+ Registration is of Vehicle,
136
+ Vehicle has one Registration;
137
+ Vehicle is of at most one Colour;
138
+ Vehicle has at most one Engine Number;
139
+ Vehicle has commercial registration;
140
+
141
+ Vehicle Incident is a kind of Incident [separate];
142
+ Vehicle Incident has at most one Description;
143
+ Vehicle Incident resulted from at most one Loss Type;
144
+ Vehicle Incident was caused by at most one Reason;
145
+ Vehicle Incident involved at most one previous_damage-Description;
146
+ Vehicle Incident resulted in vehicle being towed to at most one towed-Location;
147
+ Vehicle Incident occurred during at most one weather-Description;
148
+
149
+ Vehicle Type is identified by Make and Model and Badge where
150
+ Vehicle Type is of one Make,
151
+ Vehicle Type is of one Model,
152
+ Badge is of Vehicle Type,
153
+ Vehicle Type has at most one Badge;
154
+ Vehicle is of one Vehicle Type;
155
+
156
+ Witness is identified by Incident and Name where
157
+ Incident was seen by Witness,
158
+ Witness saw one Incident,
159
+ Witness is called one Name;
160
+ Witness has at most one contact-Phone;
161
+
162
+ Year is identified by its Nr;
163
+ Vehicle is of one model-Year restricted to {1900..2100};
164
+
165
+ Address is identified by Street and City and Postcode and State where
166
+ Address is at one Street,
167
+ Address is in one City,
168
+ Address is in at most one Postcode,
169
+ Address is in at most one State;
170
+ Incident relates to loss at one Address;
171
+ Party has at most one postal-Address;
172
+ Person lives at at most one Address;
173
+ Witness lives at at most one Address;
174
+
175
+ Authorised Rep is a kind of Party;
176
+
177
+ Client is a kind of Party;
178
+
179
+ Company is a kind of Party;
180
+ Company has one contact-Person,
181
+ Person is contact for Company;
182
+
183
+ Contact Methods is identified by Person where
184
+ Person has one Contact Methods,
185
+ Contact Methods are for one Person;
186
+ Contact Methods includes at most one Email;
187
+ Contact Methods includes at most one business-Phone;
188
+ Contact Methods prefers at most one contact-Time;
189
+ Contact Methods includes at most one home-Phone;
190
+ Contact Methods includes at most one mobile-Phone;
191
+ Contact Methods has at most one preferred-Contact Method;
192
+
193
+ Contractor is a kind of Company;
194
+
195
+ Contractor Appointment is where
196
+ Claim involves Contractor,
197
+ Contractor is appointed to handle Claim;
198
+
199
+ Cover Wording is where
200
+ Cover Type used Policy Wording from start-Date;
201
+
202
+ Dealer is a kind of Party;
203
+ Vehicle was sold by at most one Dealer;
204
+
205
+ Driver is a kind of Person;
206
+
207
+ Driving is where
208
+ Vehicle Incident involves at most one Driver,
209
+ Driver drove covered vehicle in at least one Vehicle Incident;
210
+ Driving followed at most one Intoxication;
211
+ Driving resulted in at most one blood-Test Result;
212
+ Driving resulted in at most one breath-Test Result;
213
+ Driving (as driver_hospitalised) resulted in driver taken to at most one hospital-Name;
214
+ Driving was without owners consent for at most one nonconsent-Reason;
215
+ Driving was unlicenced for at most one unlicensed-Reason;
216
+
217
+ Driving Charge is where
218
+ Driving resulted in at most one Charge;
219
+ Driving Charge is a warning;
220
+
221
+ Finance Institution is a kind of Company;
222
+ Vehicle is subject to finance with at most one Finance Institution;
223
+
224
+ Insurer is a kind of Company;
225
+
226
+ Investigator is a kind of Contractor;
227
+
228
+ License is identified by Driver where
229
+ Driver holds at most one License,
230
+ License is held by one Driver;
231
+ License has one License Number,
232
+ License Number is of at most one License;
233
+ License is of one License Type,
234
+ License Type has License instance;
235
+ License was granted in at most one Year restricted to {1990..2100};
236
+ License is international;
237
+
238
+ Lodgement is where
239
+ Claim was lodged by at most one Person;
240
+ Lodgement was made at at most one Date Time;
241
+
242
+ Policy is identified by p_year and p_product and p_state and p_serial where
243
+ Policy was issued in one Year (as p_year) restricted to {0..99},
244
+ Policy is for product having one Product (as p_product),
245
+ Policy issued in state having one State (as p_state),
246
+ Policy has one Policy Serial (as p_serial);
247
+ Application is for Policy,
248
+ Policy has one Application;
249
+ Claim is on one Policy,
250
+ Policy has Claim;
251
+ ITC Claimed is for Policy,
252
+ Policy has at most one ITC Claimed;
253
+ Policy was sold by at most one Authorised Rep,
254
+ Authorised Rep sold Policy;
255
+ Policy belongs to one Client,
256
+ Client has Policy;
257
+
258
+ Property Damage is identified by Incident and Address where
259
+ Incident caused Property Damage,
260
+ Property Damage was damaged in at most one Incident,
261
+ Property Damage is at one Address,
262
+ Address is of Property Damage;
263
+ Property Damage owner has contact at most one Phone;
264
+ Property Damage belongs to at most one owner-Name;
265
+
266
+ Repairer is a kind of Contractor;
267
+
268
+ Solicitor is a kind of Contractor;
269
+
270
+ Third Party is where
271
+ Person was third party in Vehicle Incident;
272
+ Third Party is insured by at most one Insurer;
273
+ Third Party vehicle is of at most one Vehicle Type;
274
+ Third Party vehicle is of at most one model-Year;
275
+ Third Party drove at most one vehicle-Registration;
276
+
277
+ Underwriting Demerit is identified by Vehicle Incident and Demerit Kind where
278
+ Vehicle Incident occurred despite Underwriting Demerit,
279
+ Underwriting Demerit preceded one Vehicle Incident,
280
+ Underwriting Demerit has one Demerit Kind,
281
+ Demerit Kind is of Underwriting Demerit;
282
+ Underwriting Demerit occurred at most one occurrence-Count times;
283
+
284
+ Assessor is a kind of Contractor;
285
+
286
+ Cover is where
287
+ Policy provides Cover Type over Asset,
288
+ Cover Type over Asset is provided by Policy;
289
+
290
+ Motor Policy is a kind of Policy;
291
+
292
+ Single Motor Policy is a kind of Motor Policy;
293
+
294
+ Motor Fleet Policy is a kind of Motor Policy;
295
+
296
+ /*
297
+ * Constraints:
298
+ */
299
+ either Motor Policy is a Single Motor Policy or Motor Policy is a Motor Fleet Policy but not both;
300
+ Party is a Company that has contact Person
301
+ if and only if
302
+ Party is a company;
303
+ each Contact Methods occurs at least one time in
304
+ Contact Methods includes mobile Phone,
305
+ Contact Methods includes home Phone,
306
+ Contact Methods includes business Phone,
307
+ Contact Methods includes Email;
308
+ each combination Policy, Claim Sequence occurs at most one time in
309
+ Claim is on Policy,
310
+ Claim has Claim Sequence;
311
+ either Witness lives at Address or Witness has contact Phone;