4b1f7eb61ac50daa599649ceb14cb4796fe57639
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / XMI / Parser / V12.pm
1 package SQL::Translator::XMI::Parser::V12;
2
3 # -------------------------------------------------------------------
4 # $Id$
5 # -------------------------------------------------------------------
6 # Copyright (C) 2003 Mark Addison <mark.addison@itn.co.uk>,
7 #
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; version 2.
11 #
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 # 02111-1307  USA
21 # -------------------------------------------------------------------
22
23 =pod
24
25 =head1 NAME
26
27 SQL::Translator::XMI::Parser::V12 - Version 1.2 parser.
28
29 =cut
30
31 use strict;
32 use 5.006_001;
33 use vars qw/$VERSION/;
34 $VERSION = sprintf "%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/;
35
36 use base qw(SQL::Translator::XMI::Parser);
37
38 my $spec12 = {};
39
40 $spec12->{taggedValue} = {
41     name   => "taggedValue",
42     plural => "taggedValues",
43     default_path => '//UML:TaggedValue[@xmi.id]',
44     attrib_data  => [qw/isSpecification/],
45     path_data => [
46         { 
47             name  => "dataValue",
48             path  => 'UML:TaggedValue.dataValue/text()',
49         },
50         { 
51             name  => "name",
52             path  => 'xmiDeref(UML:TaggedValue.type/UML:TagDefinition)/@name',
53         },
54     ],
55 };
56
57 $spec12->{class} = {
58     name    => "class",
59     plural  => "classes",
60         isRoot  => 1,
61     default_path => '//UML:Class[@xmi.id]',
62     attrib_data => 
63         [qw/name visibility isSpecification isRoot isLeaf isAbstract isActive/],
64     path_data => [
65         { 
66             name  => "stereotype",
67             path  => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name',
68             default => "",
69         },
70     ],
71     kids => [
72         { 
73             name  => "attributes",
74             # name in data returned
75             path  => "UML:Classifier.feature/UML:Attribute",
76             class => "attribute", 
77             # Points to class in spec. get_attributes() called to parse it and
78             # adds filter_attributes to the args for get_classes().
79             multiplicity => "*",
80             # How many we get back. Use '1' for 1 and '*' for lots.
81                         # TODO If not set then decide depening on the return?
82         },
83         {
84             name  => "operations",
85             path  => "UML:Classifier.feature/UML:Operation",
86             class => "operation", 
87             multiplicity => "*",
88         },
89         {
90             name  => "taggedValues",
91             path  => 'UML:ModelElement.taggedValue/UML:TaggedValue',
92             class => "taggedValue",
93             multiplicity => "*",
94                         map => "name",
95                 # Add a _map_taggedValues to the data. Its a hash of the name data
96                         # which refs the normal list of kids
97                 },
98                 {
99             name  => "associationEnds",
100                         path  => '//UML:AssociationEnd.participant/UML:Class[@xmi.idref="${xmi.id}"]/../..',
101                         # ${xmi.id} is a variable sub from the data defined for this thing.
102                         # Not standard XPath! Done in the get sub
103                         class => "AssociationEnd",
104             multiplicity => "*",
105         },
106     ],
107 };
108
109 $spec12->{attribute} = {
110     name => "attribute",
111     plural => "attributes",
112     default_path => '//UML:Classifier.feature/UML:Attribute[@xmi.id]',
113     attrib_data => 
114         [qw/name visibility isSpecification ownerScope/],
115     path_data => [
116         { 
117             name  => "stereotype",
118             path  => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name',
119             default => "",
120         },
121         { 
122             name  => "initialValue",
123             path  => 'UML:Attribute.initialValue/UML:Expression/@body',
124         },
125     ],
126     kids => [
127         { 
128             name  => "taggedValues",
129             path  => 'UML:ModelElement.taggedValue/UML:TaggedValue',
130             class => "taggedValue", 
131             multiplicity => "*",
132                         map => "name",
133         },
134         { 
135             name  => "dataType",
136             path  => 'xmiDeref(UML:StructuralFeature.type/UML:DataType)',
137             class => "dataType", 
138             multiplicity => "1",
139         },
140     ],
141 };
142
143 $spec12->{dataType} = {
144     name   => "datatype",
145     plural => "datatypes",
146         isRoot => 1,
147     default_path => '//UML:DataType[@xmi.id]',
148     attrib_data  =>
149         [qw/name visibility isSpecification isRoot isLeaf isAbstract/],
150     path_data => [
151         { 
152             name  => "stereotype",
153             path  => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name',
154             default => "",
155         },
156     ],
157     kids => [
158         { 
159             name  => "taggedValues",
160             path  => 'UML:ModelElement.taggedValue/UML:TaggedValue',
161             class => "taggedValue", 
162             multiplicity => "*",
163                         map => "name",
164         },
165     ],
166 };
167
168
169
170 $spec12->{operation} = {
171     name => "operation",
172     plural => "operations",
173     default_path => '//UML:Classifier.feature/UML:Operation[@xmi.id]',
174     attrib_data => 
175         [qw/name visibility isSpecification ownerScope isQuery
176             concurrency isRoot isLeaf isAbstract/],
177     path_data => [
178         { 
179             name  => "stereotype",
180             path  => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name',
181             default => "",
182         },
183     ],
184     kids => [
185         { 
186             name  => "parameters",
187             path  => "UML:BehavioralFeature.parameter/UML:Parameter",
188             class => "parameter", 
189             multiplicity => "*",
190         },
191         { 
192             name  => "taggedValues",
193             path  => 'UML:ModelElement.taggedValue/UML:TaggedValue',
194             class => "taggedValue", 
195             multiplicity => "*",
196                         map => "name",
197         },
198     ],
199 };
200
201 $spec12->{parameter} = {
202     name   => "parameter",
203     plural => "parameters",
204     default_path => '//UML:Parameter[@xmi.id]',
205     attrib_data  => [qw/name isSpecification kind/],
206     path_data => [
207         { 
208             name  => "stereotype",
209             path  => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name',
210             default => "",
211         },
212         { 
213             name  => "datatype",
214             path  => 'xmiDeref(UML:StructuralFeature.type/UML:DataType)/@name',
215         },
216     ],
217 };
218
219 $spec12->{association} = {
220     name   => "association",
221     plural => "associations",
222         isRoot => 1,
223     default_path => '//UML:Association[@xmi.id]',
224     attrib_data  => [qw/name visibility isSpecification isNavigable ordering aggregation targetScope changeability/],
225     path_data => [
226         {
227             name  => "stereotype",
228             path  => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name',
229             default => "",
230         },
231         ],
232         kids => [
233         {
234             name  => "associationEnds",
235             path  => "UML:Association.connection/UML:AssociationEnd",
236             class => "AssociationEnd", 
237             multiplicity => "*",
238         },
239     ],
240 };
241
242 $spec12->{AssociationEnd} = {
243     name   => "End",
244     plural => "Ends",
245     default_path => '//UML:AssociationEnd',
246     attrib_data  => [qw/name visibility isSpecification isNavigable ordering aggregation targetScope changeability/],
247     path_data => [
248         {
249             name  => "stereotype",
250             path  => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name',
251             default => "",
252         },
253         {
254             name  => "className",
255             path  => 'xmiDeref(UML:AssociationEnd.participant/UML:Class)/@name',
256             default => "",
257         },
258         ],
259     kids => [
260                 {
261             name  => "association",
262             path  => "../..",
263             class => "association", 
264             multiplicity => "1",
265         },
266         {
267             name  => "participant",
268             path  => "xmiDeref(UML:AssociationEnd.participant/UML:Class)",
269             class => "class", 
270             multiplicity => "1",
271         },
272         {
273             name  => "multiplicity",
274             #path  => "xmiDeref(UML:AssociationEnd.multiplicity/UML:Multiplicity)",
275             path  => 'UML:AssociationEnd.multiplicity/UML:Multiplicity',
276             class => "multiplicity", 
277             multiplicity => "1",
278         },
279     ],
280 };
281
282 $spec12->{multiplicity} = {
283     name   => "multiplicity",
284     plural => "multiplicities",
285     default_path => '//UML:Multiplicity[@xmi.id]',
286     attrib_data  => [qw//],
287     path_data => [
288         { 
289             name  => "rangeLower",
290             path  => 'xmiDeref(UML:Multiplicity.range/UML:MultiplicityRange)/@lower',
291         },
292         { 
293             name  => "rangeUpper",
294             path  => 'xmiDeref(UML:Multiplicity.range/UML:MultiplicityRange)/@upper',
295         },
296     ],
297 };
298
299 # Set the spec and have the get_* methods generated
300 __PACKAGE__->XmiSpec($spec12);
301
302
303 1; #===========================================================================
304
305 __END__
306
307 =head1 SYNOPSIS
308
309 =head1 DESCRIPTION
310
311 =head1 SEE ALSO
312
313 perl(1).
314
315 =head1 TODO
316
317 =head1 BUGS
318
319 =head1 VERSION HISTORY
320
321 =head1 AUTHOR
322
323 grommit <mark.addison@itn.co.uk>
324
325 =cut