activefacts 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/Rakefile +3 -0
- data/bin/afgen +9 -3
- data/bin/cql +0 -0
- data/examples/CQL/Address.cql +7 -7
- data/examples/CQL/Blog.cql +8 -8
- data/examples/CQL/CompanyDirectorEmployee.cql +3 -3
- data/examples/CQL/Death.cql +2 -2
- data/examples/CQL/Genealogy.cql +21 -21
- data/examples/CQL/Marriage.cql +1 -1
- data/examples/CQL/Metamodel.cql +34 -29
- data/examples/CQL/MultiInheritance.cql +3 -3
- data/examples/CQL/OilSupply.cql +9 -9
- data/examples/CQL/Orienteering.cql +27 -27
- data/examples/CQL/PersonPlaysGame.cql +2 -2
- data/examples/CQL/SchoolActivities.cql +3 -3
- data/examples/CQL/SimplestUnary.cql +1 -1
- data/examples/CQL/SubtypePI.cql +4 -4
- data/examples/CQL/Warehousing.cql +12 -12
- data/examples/CQL/WindowInRoomInBldg.cql +4 -4
- data/lib/activefacts/api/concept.rb +3 -2
- data/lib/activefacts/api/constellation.rb +1 -1
- data/lib/activefacts/api/entity.rb +12 -1
- data/lib/activefacts/api/instance.rb +1 -1
- data/lib/activefacts/api/role.rb +1 -1
- data/lib/activefacts/api/standard_types.rb +9 -1
- data/lib/activefacts/api/support.rb +4 -0
- data/lib/activefacts/api/value.rb +1 -0
- data/lib/activefacts/api/vocabulary.rb +2 -59
- data/lib/activefacts/cql/DataTypes.treetop +10 -1
- data/lib/activefacts/cql/Expressions.treetop +1 -1
- data/lib/activefacts/cql/FactTypes.treetop +1 -1
- data/lib/activefacts/cql/Language/English.treetop +2 -2
- data/lib/activefacts/generate/absorption.rb +0 -2
- data/lib/activefacts/generate/cql.rb +6 -8
- data/lib/activefacts/generate/cql/html.rb +1 -1
- data/lib/activefacts/generate/oo.rb +60 -40
- data/lib/activefacts/generate/ordered.rb +30 -21
- data/lib/activefacts/generate/ruby.rb +38 -15
- data/lib/activefacts/generate/sql/mysql.rb +257 -0
- data/lib/activefacts/generate/sql/server.rb +0 -1
- data/lib/activefacts/input/cql.rb +0 -2
- data/lib/activefacts/persistence/columns.rb +51 -24
- data/lib/activefacts/persistence/concept.rb +158 -36
- data/lib/activefacts/persistence/reference.rb +13 -8
- data/lib/activefacts/support.rb +40 -2
- data/lib/activefacts/version.rb +1 -1
- data/lib/activefacts/vocabulary/extensions.rb +5 -6
- data/spec/absorption_spec.rb +8 -11
- data/spec/api/autocounter.rb +1 -1
- data/spec/api/constellation.rb +1 -1
- data/spec/api/entity_type.rb +1 -1
- data/spec/api/instance.rb +1 -1
- data/spec/api/roles.rb +1 -1
- data/spec/api/value_type.rb +1 -1
- data/spec/cql_cql_spec.rb +2 -4
- data/spec/cql_parse_spec.rb +2 -4
- data/spec/cql_ruby_spec.rb +2 -4
- data/spec/cql_sql_spec.rb +4 -4
- data/spec/cql_symbol_tables_spec.rb +1 -1
- data/spec/cql_unit_spec.rb +6 -6
- data/spec/cqldump_spec.rb +6 -6
- data/spec/norma_cql_spec.rb +2 -4
- data/spec/norma_ruby_spec.rb +2 -4
- data/spec/norma_sql_spec.rb +2 -4
- data/spec/norma_tables_spec.rb +4 -7
- metadata +29 -6
data/Manifest.txt
CHANGED
@@ -52,6 +52,7 @@ lib/activefacts/generate/null.rb
|
|
52
52
|
lib/activefacts/generate/oo.rb
|
53
53
|
lib/activefacts/generate/ordered.rb
|
54
54
|
lib/activefacts/generate/ruby.rb
|
55
|
+
lib/activefacts/generate/sql/mysql.rb
|
55
56
|
lib/activefacts/generate/sql/server.rb
|
56
57
|
lib/activefacts/generate/text.rb
|
57
58
|
lib/activefacts/input/cql.rb
|
data/Rakefile
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
%w[rubygems rake rake/clean fileutils newgem rubigen spec spec/rake/spectask].each { |f| require f }
|
2
2
|
|
3
|
+
require 'hanna/rdoctask'
|
4
|
+
|
3
5
|
require File.dirname(__FILE__) + '/lib/activefacts'
|
4
6
|
|
5
7
|
# Generate all the Rake tasks
|
@@ -19,6 +21,7 @@ $hoe = Hoe.new('activefacts', ActiveFacts::VERSION) do |p|
|
|
19
21
|
# Magic Hoe hook to prevent the generation of diagrams:
|
20
22
|
ENV['NODOT'] = 'yes'
|
21
23
|
p.spec_extras[:rdoc_options] = %w{
|
24
|
+
-S -T hanna
|
22
25
|
-A has_one -A one_to_one -A maybe
|
23
26
|
-x lib/activefacts/cql/.*.rb
|
24
27
|
-x lib/activefacts/vocabulary/.*.rb
|
data/bin/afgen
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#! env ruby
|
1
|
+
#! /usr/bin/env ruby
|
2
2
|
#
|
3
3
|
# ActiveFacts: Read a Vocabulary (from a NORMA, CQL or other file) and run a generator
|
4
4
|
#
|
@@ -7,11 +7,17 @@
|
|
7
7
|
$:.unshift File.dirname(File.expand_path(__FILE__))+"/../lib"
|
8
8
|
|
9
9
|
require 'rubygems'
|
10
|
-
require 'ruby-debug'
|
11
10
|
require 'activefacts'
|
12
11
|
require 'activefacts/vocabulary'
|
13
12
|
|
14
|
-
|
13
|
+
if ENV['DEBUG']
|
14
|
+
begin
|
15
|
+
require 'ruby-debug'
|
16
|
+
debugger if debug :exception
|
17
|
+
rescue LoadError
|
18
|
+
# Ok, no debugger, tough luck.
|
19
|
+
end
|
20
|
+
end
|
15
21
|
true # Ok, got the stack set up, continue to the fault
|
16
22
|
|
17
23
|
arg = ARGV.shift
|
data/bin/cql
CHANGED
File without changes
|
data/examples/CQL/Address.cql
CHANGED
@@ -3,13 +3,13 @@ vocabulary Address;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
City is
|
7
|
-
CompanyName is
|
8
|
-
FamilyName is
|
9
|
-
GivenNames is
|
10
|
-
Number is
|
11
|
-
Postcode is
|
12
|
-
StreetLine is
|
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);
|
13
13
|
|
14
14
|
/*
|
15
15
|
* Entity Types
|
data/examples/CQL/Blog.cql
CHANGED
@@ -3,14 +3,14 @@ vocabulary Blog;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
AuthorId is
|
7
|
-
CommentId is
|
8
|
-
Name is
|
9
|
-
Ordinal is
|
10
|
-
PostId is
|
11
|
-
Style is
|
12
|
-
Text is
|
13
|
-
TopicId is
|
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();
|
14
14
|
|
15
15
|
/*
|
16
16
|
* Entity Types
|
@@ -3,9 +3,9 @@ vocabulary CompanyDirectorEmployee;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
CompanyName is
|
7
|
-
EmployeeNr is
|
8
|
-
Name is
|
6
|
+
CompanyName is written as VariableLengthText(48);
|
7
|
+
EmployeeNr is written as SignedInteger(32);
|
8
|
+
Name is written as VariableLengthText(48);
|
9
9
|
|
10
10
|
/*
|
11
11
|
* Entity Types
|
data/examples/CQL/Death.cql
CHANGED
@@ -3,8 +3,8 @@ vocabulary Death;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
CauseOfDeath is
|
7
|
-
PersonName is
|
6
|
+
CauseOfDeath is written as VariableLengthText();
|
7
|
+
PersonName is written as VariableLengthText(40);
|
8
8
|
|
9
9
|
/*
|
10
10
|
* Entity Types
|
data/examples/CQL/Genealogy.cql
CHANGED
@@ -3,27 +3,27 @@ vocabulary Genealogy;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
Address is
|
7
|
-
Certificate is
|
8
|
-
Day is
|
9
|
-
Email is
|
10
|
-
EventID is
|
11
|
-
EventLocation is
|
12
|
-
EventRoleName is
|
13
|
-
EventTypeID is
|
14
|
-
EventTypeName is
|
15
|
-
Gender is
|
16
|
-
Month is
|
17
|
-
Name is
|
18
|
-
Occupation is
|
19
|
-
Official is
|
20
|
-
PersonID is
|
21
|
-
Picture is
|
22
|
-
RoleID is
|
23
|
-
SourceID is
|
24
|
-
SourceName is
|
25
|
-
UserID is
|
26
|
-
Year is
|
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);
|
27
27
|
|
28
28
|
/*
|
29
29
|
* Entity Types
|
data/examples/CQL/Marriage.cql
CHANGED
data/examples/CQL/Metamodel.cql
CHANGED
@@ -3,27 +3,28 @@ vocabulary Metamodel;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
Adjective is
|
7
|
-
ConstraintId is
|
8
|
-
Denominator is
|
9
|
-
Enforcement is
|
10
|
-
Exponent is
|
11
|
-
FactId is
|
12
|
-
FactTypeId is
|
13
|
-
Frequency is
|
14
|
-
InstanceId is
|
15
|
-
Length is
|
16
|
-
Name is
|
17
|
-
Numerator is
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
6
|
+
Adjective is written as VariableLengthText(64);
|
7
|
+
ConstraintId is written as AutoCounter();
|
8
|
+
Denominator is written as UnsignedInteger(32);
|
9
|
+
Enforcement is written as VariableLengthText(16);
|
10
|
+
Exponent is written as SignedSmallInteger(32);
|
11
|
+
FactId is written as AutoCounter();
|
12
|
+
FactTypeId is written as AutoCounter();
|
13
|
+
Frequency is written as UnsignedInteger(32);
|
14
|
+
InstanceId is written as AutoCounter();
|
15
|
+
Length is written as UnsignedInteger(32);
|
16
|
+
Name is written as VariableLengthText(64);
|
17
|
+
Numerator is written as Decimal();
|
18
|
+
Offset is written as Decimal();
|
19
|
+
Ordinal is written as UnsignedSmallInteger(32);
|
20
|
+
Pronoun is written as VariableLengthText(20) restricted to {'feminine', 'masculine', 'personal'};
|
21
|
+
RingType is written as VariableLengthText();
|
22
|
+
RoleSequenceId is written as AutoCounter();
|
23
|
+
Scale is written as UnsignedInteger(32);
|
24
|
+
Text is written as VariableLengthText(256);
|
25
|
+
UnitId is written as AutoCounter();
|
26
|
+
Value is written as VariableLengthText(256);
|
27
|
+
ValueRestrictionId is written as AutoCounter();
|
27
28
|
|
28
29
|
/*
|
29
30
|
* Entity Types
|
@@ -89,6 +90,7 @@ Unit is identified by its Id;
|
|
89
90
|
Name is of Unit,
|
90
91
|
Unit is called one Name;
|
91
92
|
Unit has at most one Coefficient;
|
93
|
+
Unit has at most one Offset;
|
92
94
|
Unit is fundamental;
|
93
95
|
Derivation is where
|
94
96
|
Unit (as DerivedUnit) is derived from base-Unit (as BaseUnit) [acyclic, intransitive];
|
@@ -106,15 +108,13 @@ Vocabulary is identified by Name where
|
|
106
108
|
Vocabulary is called one Name;
|
107
109
|
Vocabulary contains Constraint,
|
108
110
|
Constraint belongs to at most one Vocabulary;
|
109
|
-
|
110
|
-
|
111
|
+
Vocabulary includes Unit,
|
112
|
+
Unit is in one Vocabulary;
|
111
113
|
|
112
114
|
Feature is identified by Vocabulary and Name where
|
113
115
|
Feature belongs to at most one Vocabulary,
|
114
116
|
Vocabulary contains Feature,
|
115
117
|
Feature is called one Name;
|
116
|
-
Correspondence is where
|
117
|
-
in Import imported-Feature corresponds to at most one local-Feature;
|
118
118
|
|
119
119
|
Population is identified by Vocabulary and Name where
|
120
120
|
Vocabulary includes Population,
|
@@ -140,8 +140,6 @@ SetEqualityConstraint is a kind of SetComparisonConstraint;
|
|
140
140
|
SetExclusionConstraint is a kind of SetComparisonConstraint;
|
141
141
|
SetExclusionConstraint is mandatory;
|
142
142
|
|
143
|
-
Alias is a kind of Feature;
|
144
|
-
|
145
143
|
Concept is a kind of Feature;
|
146
144
|
Concept uses at most one Pronoun;
|
147
145
|
Concept is independent;
|
@@ -190,6 +188,11 @@ ValueType is of at most one Unit;
|
|
190
188
|
ValueType has at most one ValueRestriction;
|
191
189
|
ValueType is subtype of at most one super-ValueType (as Supertype) [acyclic],
|
192
190
|
Supertype is supertype of ValueType;
|
191
|
+
Parameter is where
|
192
|
+
Name is a parameter of ValueType,
|
193
|
+
ValueType has parameter called Name;
|
194
|
+
ParamValue is where
|
195
|
+
Value for Parameter applies to at most one ValueType;
|
193
196
|
|
194
197
|
/*
|
195
198
|
* Constraints:
|
@@ -202,8 +205,7 @@ for each Constraint exactly one of these holds:
|
|
202
205
|
SetConstraint is a subtype of Constraint,
|
203
206
|
RingConstraint is a subtype of Constraint;
|
204
207
|
for each Feature exactly one of these holds:
|
205
|
-
Concept is a subtype of Feature
|
206
|
-
Alias is a subtype of Feature;
|
208
|
+
Concept is a subtype of Feature;
|
207
209
|
Instance plays RoleValue and Instance is of Concept
|
208
210
|
if and only if
|
209
211
|
RoleValue is of Role and FactType has Ordinal role played by Concept;
|
@@ -243,3 +245,6 @@ each ValueRange occurs at least one time in
|
|
243
245
|
each combination Vocabulary, Name occurs at most one time in
|
244
246
|
Vocabulary contains Constraint,
|
245
247
|
Name is of Constraint;
|
248
|
+
each combination Vocabulary, Name occurs at most one time in
|
249
|
+
Vocabulary includes Unit,
|
250
|
+
Name is of Unit;
|
@@ -3,9 +3,9 @@ vocabulary MultiInheritance;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
EmployeeID is
|
7
|
-
PersonName is
|
8
|
-
TFN is
|
6
|
+
EmployeeID is written as AutoCounter();
|
7
|
+
PersonName is written as VariableLengthText();
|
8
|
+
TFN is written as FixedLengthText(9);
|
9
9
|
|
10
10
|
/*
|
11
11
|
* Entity Types
|
data/examples/CQL/OilSupply.cql
CHANGED
@@ -3,15 +3,15 @@ vocabulary OilSupply;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
Cost is
|
7
|
-
MonthCode is
|
8
|
-
ProductName is
|
9
|
-
Quantity is
|
10
|
-
RefineryName is
|
11
|
-
RegionName is
|
12
|
-
Season is
|
13
|
-
TransportMethod is
|
14
|
-
YearNr is
|
6
|
+
Cost is written as Money();
|
7
|
+
MonthCode is written as FixedLengthText();
|
8
|
+
ProductName is written as VariableLengthText();
|
9
|
+
Quantity is written as UnsignedInteger(32);
|
10
|
+
RefineryName is written as VariableLengthText(80);
|
11
|
+
RegionName is written as VariableLengthText();
|
12
|
+
Season is written as VariableLengthText(6) restricted to {'Autumn', 'Spring', 'Summer', 'Winter'};
|
13
|
+
TransportMethod is written as VariableLengthText() restricted to {'Rail', 'Road', 'Sea'};
|
14
|
+
YearNr is written as SignedInteger(32);
|
15
15
|
|
16
16
|
/*
|
17
17
|
* Entity Types
|
@@ -3,33 +3,33 @@ vocabulary Orienteering;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
Accessibility is
|
7
|
-
ClubCode is
|
8
|
-
ClubName is
|
9
|
-
ControlNumber is
|
10
|
-
Course is
|
11
|
-
EntryID is
|
12
|
-
EventID is
|
13
|
-
EventName is
|
14
|
-
FamilyName is
|
15
|
-
Gender is
|
16
|
-
GivenName is
|
17
|
-
Location is
|
18
|
-
MapID is
|
19
|
-
MapName is
|
20
|
-
Number is
|
21
|
-
PersonID is
|
22
|
-
Placing is
|
23
|
-
PointValue is
|
24
|
-
PostCode is
|
25
|
-
PunchID is
|
26
|
-
Score is
|
27
|
-
ScoringMethod is
|
28
|
-
SeriesID is
|
29
|
-
SeriesName is
|
30
|
-
StartTime is
|
31
|
-
Time is
|
32
|
-
Year is
|
6
|
+
Accessibility is written as FixedLengthText(1) restricted to {'A'..'D'};
|
7
|
+
ClubCode is written as VariableLengthText(6);
|
8
|
+
ClubName is written as VariableLengthText(32);
|
9
|
+
ControlNumber is written as UnsignedInteger(32) restricted to {1..1000};
|
10
|
+
Course is written as VariableLengthText(16) restricted to {'A'..'E', 'PW'};
|
11
|
+
EntryID is written as AutoCounter();
|
12
|
+
EventID is written as AutoCounter();
|
13
|
+
EventName is written as VariableLengthText(50);
|
14
|
+
FamilyName is written as VariableLengthText(48);
|
15
|
+
Gender is written as FixedLengthText(1) restricted to {'F', 'M'};
|
16
|
+
GivenName is written as VariableLengthText(48);
|
17
|
+
Location is written as VariableLengthText(200);
|
18
|
+
MapID is written as AutoCounter();
|
19
|
+
MapName is written as VariableLengthText(80);
|
20
|
+
Number is written as UnsignedInteger(32) restricted to {1..100};
|
21
|
+
PersonID is written as AutoCounter();
|
22
|
+
Placing is written as UnsignedInteger(32);
|
23
|
+
PointValue is written as UnsignedInteger(32);
|
24
|
+
PostCode is written as UnsignedInteger(32);
|
25
|
+
PunchID is written as AutoCounter();
|
26
|
+
Score is written as SignedInteger(32);
|
27
|
+
ScoringMethod is written as VariableLengthText(32) restricted to {'Scatter', 'Score', 'Special'};
|
28
|
+
SeriesID is written as AutoCounter();
|
29
|
+
SeriesName is written as VariableLengthText(40);
|
30
|
+
StartTime is written as DateAndTime();
|
31
|
+
Time is written as DateAndTime();
|
32
|
+
Year is written as UnsignedInteger(32) restricted to {1900..3000};
|
33
33
|
|
34
34
|
/*
|
35
35
|
* Entity Types
|
@@ -3,8 +3,8 @@ vocabulary PersonPlaysGame;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
GameCode is
|
7
|
-
PersonName is
|
6
|
+
GameCode is written as FixedLengthText();
|
7
|
+
PersonName is written as VariableLengthText();
|
8
8
|
|
9
9
|
/*
|
10
10
|
* Entity Types
|
@@ -3,9 +3,9 @@ vocabulary SchoolActivities;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
ActivityName is
|
7
|
-
SchoolName is
|
8
|
-
StudentName is
|
6
|
+
ActivityName is written as VariableLengthText(32);
|
7
|
+
SchoolName is written as VariableLengthText();
|
8
|
+
StudentName is written as VariableLengthText();
|
9
9
|
|
10
10
|
/*
|
11
11
|
* Entity Types
|
data/examples/CQL/SubtypePI.cql
CHANGED
@@ -3,10 +3,10 @@ vocabulary SubtypePI;
|
|
3
3
|
/*
|
4
4
|
* Value Types
|
5
5
|
*/
|
6
|
-
EntrantID is
|
7
|
-
FamilyName is
|
8
|
-
GivenName is
|
9
|
-
TeamID is
|
6
|
+
EntrantID is written as AutoCounter();
|
7
|
+
FamilyName is written as VariableLengthText();
|
8
|
+
GivenName is written as VariableLengthText();
|
9
|
+
TeamID is written as AutoCounter();
|
10
10
|
|
11
11
|
/*
|
12
12
|
* Entity Types
|