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