Commit | Line | Data |
93f4a354 |
1 | package SQL::Translator::XMI::Parser::V12; |
2 | |
3 | # ------------------------------------------------------------------- |
ef879f14 |
4 | # $Id: V12.pm,v 1.4 2003-10-03 18:07:13 grommit Exp $ |
93f4a354 |
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/; |
ef879f14 |
34 | $VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/; |
93f4a354 |
35 | |
36 | use base qw(SQL::Translator::XMI::Parser); |
37 | |
38 | my $spec12 = {}; |
39 | |
40 | $spec12->{class} = { |
41 | name => "class", |
42 | plural => "classes", |
43 | isRoot => 1, |
44 | default_path => '//UML:Class[@xmi.id]', |
45 | attrib_data => |
46 | [qw/name visibility isSpecification isRoot isLeaf isAbstract isActive/], |
47 | path_data => [ |
48 | { |
49 | name => "stereotype", |
50 | path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name', |
51 | default => "", |
52 | }, |
53 | ], |
54 | kids => [ |
55 | { |
56 | name => "attributes", |
57 | # name in data returned |
58 | path => "UML:Classifier.feature/UML:Attribute", |
59 | class => "attribute", |
60 | # Points to class in spec. get_attributes() called to parse it and |
61 | # adds filter_attributes to the args for get_classes(). |
62 | multiplicity => "*", |
63 | # How many we get back. Use '1' for 1 and '*' for lots. |
64 | # TODO If not set then decide depening on the return? |
65 | }, |
66 | { |
67 | name => "operations", |
68 | path => "UML:Classifier.feature/UML:Operation", |
69 | class => "operation", |
70 | multiplicity => "*", |
71 | }, |
72 | { |
73 | name => "taggedValues", |
74 | path => 'UML:ModelElement.taggedValue/UML:TaggedValue', |
75 | class => "taggedValue", |
76 | multiplicity => "*", |
77 | map => "name", |
78 | # Add a _map_taggedValues to the data. Its a hash of the name data |
79 | # which refs the normal list of kids |
80 | }, |
81 | { |
82 | name => "associationEnds", |
83 | path => '//UML:AssociationEnd.participant/UML:Class[@xmi.idref="${xmi.id}"]/../..', |
84 | # ${xmi.id} is a variable sub from the data defined for this thing. |
85 | # Not standard XPath! Done in the get sub |
86 | class => "AssociationEnd", |
87 | multiplicity => "*", |
88 | }, |
89 | ], |
90 | }; |
91 | |
92 | $spec12->{taggedValue} = { |
93 | name => "taggedValue", |
94 | plural => "taggedValues", |
95 | default_path => '//UML:TaggedValue[@xmi.id]', |
96 | attrib_data => [qw/isSpecification/], |
97 | path_data => [ |
98 | { |
99 | name => "dataValue", |
100 | path => 'UML:TaggedValue.dataValue/text()', |
101 | }, |
102 | { |
103 | name => "name", |
104 | path => 'xmiDeref(UML:TaggedValue.type/UML:TagDefinition)/@name', |
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 | { |
93f4a354 |
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 | }, |
5365ac89 |
134 | { |
135 | name => "dataType", |
136 | path => 'xmiDeref(UML:StructuralFeature.type/UML:DataType)', |
137 | class => "dataType", |
138 | multiplicity => "1", |
139 | }, |
93f4a354 |
140 | ], |
141 | }; |
142 | |
5365ac89 |
143 | $spec12->{dataType} = { |
144 | name => "datatype", |
145 | plural => "datatypes", |
146 | default_path => '//UML:DataType[@xmi.id]', |
147 | attrib_data => |
148 | [qw/name visibility isSpecification isRoot isLeaf isAbstract/], |
149 | path_data => [ |
150 | { |
151 | name => "stereotype", |
152 | path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name', |
153 | default => "", |
154 | }, |
155 | ], |
ef879f14 |
156 | kids => [ |
157 | { |
158 | name => "taggedValues", |
159 | path => 'UML:ModelElement.taggedValue/UML:TaggedValue', |
160 | class => "taggedValue", |
161 | multiplicity => "*", |
162 | map => "name", |
163 | }, |
164 | ], |
5365ac89 |
165 | }; |
166 | |
167 | |
168 | |
93f4a354 |
169 | $spec12->{operation} = { |
170 | name => "operation", |
171 | plural => "operations", |
172 | default_path => '//UML:Classifier.feature/UML:Operation[@xmi.id]', |
173 | attrib_data => |
174 | [qw/name visibility isSpecification ownerScope isQuery |
175 | concurrency isRoot isLeaf isAbstract/], |
176 | path_data => [ |
177 | { |
178 | name => "stereotype", |
179 | path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name', |
180 | default => "", |
181 | }, |
182 | ], |
183 | kids => [ |
184 | { |
185 | name => "parameters", |
186 | path => "UML:BehavioralFeature.parameter/UML:Parameter", |
187 | class => "parameter", |
188 | multiplicity => "*", |
189 | }, |
190 | { |
191 | name => "taggedValues", |
192 | path => 'UML:ModelElement.taggedValue/UML:TaggedValue', |
193 | class => "taggedValue", |
194 | multiplicity => "*", |
195 | map => "name", |
196 | }, |
197 | ], |
198 | }; |
199 | |
200 | $spec12->{parameter} = { |
201 | name => "parameter", |
202 | plural => "parameters", |
203 | default_path => '//UML:Parameter[@xmi.id]', |
204 | attrib_data => [qw/name isSpecification kind/], |
205 | path_data => [ |
206 | { |
207 | name => "stereotype", |
208 | path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name', |
209 | default => "", |
210 | }, |
211 | { |
212 | name => "datatype", |
213 | path => 'xmiDeref(UML:StructuralFeature.type/UML:DataType)/@name', |
214 | }, |
215 | ], |
216 | }; |
217 | |
218 | $spec12->{association} = { |
219 | name => "association", |
220 | plural => "associations", |
221 | isRoot => 1, |
222 | default_path => '//UML:Association[@xmi.id]', |
223 | attrib_data => [qw/name visibility isSpecification isNavigable ordering aggregation targetScope changeability/], |
224 | path_data => [ |
225 | { |
226 | name => "stereotype", |
227 | path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name', |
228 | default => "", |
229 | }, |
230 | ], |
231 | kids => [ |
232 | { |
233 | name => "ends", |
234 | path => "UML:Association.connection/UML:AssociationEnd", |
235 | class => "AssociationEnd", |
236 | multiplicity => "*", |
237 | }, |
238 | ], |
239 | }; |
240 | |
241 | $spec12->{AssociationEnd} = { |
242 | name => "End", |
243 | plural => "Ends", |
244 | default_path => '//UML:AssociationEnd', |
245 | attrib_data => [qw/name visibility isSpecification isNavigable ordering aggregation targetScope changeability/], |
246 | path_data => [ |
247 | { |
248 | name => "stereotype", |
249 | path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name', |
250 | default => "", |
251 | }, |
252 | { |
253 | name => "className", |
254 | path => 'xmiDeref(UML:AssociationEnd.participant/UML:Class)/@name', |
255 | default => "", |
256 | }, |
257 | ], |
258 | kids => [ |
42b5b9b6 |
259 | { |
260 | name => "association", |
261 | path => "../..", |
262 | class => "association", |
263 | multiplicity => "1", |
264 | }, |
93f4a354 |
265 | { |
266 | name => "participant", |
267 | path => "xmiDeref(UML:AssociationEnd.participant/UML:Class)", |
268 | class => "class", |
269 | multiplicity => "1", |
270 | }, |
93f4a354 |
271 | ], |
272 | }; |
273 | |
274 | # Set the spec and have the get_* methods generated |
275 | __PACKAGE__->XmiSpec($spec12); |
276 | |
277 | #----------------------------------------------------------------------------- |
278 | |
279 | # Test override |
280 | # sub get_classes { |
281 | # print "HELLO 1.2\n"; |
282 | # shift->SUPER::get_classes(@_); |
283 | # } |
284 | |
285 | 1; #=========================================================================== |
286 | |
287 | __END__ |
288 | |
289 | =head1 SYNOPSIS |
290 | |
291 | =head1 DESCRIPTION |
292 | |
293 | =head1 SEE ALSO |
294 | |
295 | perl(1). |
296 | |
297 | =head1 TODO |
298 | |
299 | =head1 BUGS |
300 | |
301 | =head1 VERSION HISTORY |
302 | |
303 | =head1 AUTHOR |
304 | |
305 | grommit <mark.addison@itn.co.uk> |
306 | |
307 | =cut |