Commit | Line | Data |
93f4a354 |
1 | package SQL::Translator::XMI::Parser::V12; |
2 | |
3 | # ------------------------------------------------------------------- |
5365ac89 |
4 | # $Id: V12.pm,v 1.3 2003-10-03 13:17:28 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/; |
5365ac89 |
34 | $VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /(\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 | ], |
156 | }; |
157 | |
158 | |
159 | |
93f4a354 |
160 | $spec12->{operation} = { |
161 | name => "operation", |
162 | plural => "operations", |
163 | default_path => '//UML:Classifier.feature/UML:Operation[@xmi.id]', |
164 | attrib_data => |
165 | [qw/name visibility isSpecification ownerScope isQuery |
166 | concurrency isRoot isLeaf isAbstract/], |
167 | path_data => [ |
168 | { |
169 | name => "stereotype", |
170 | path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name', |
171 | default => "", |
172 | }, |
173 | ], |
174 | kids => [ |
175 | { |
176 | name => "parameters", |
177 | path => "UML:BehavioralFeature.parameter/UML:Parameter", |
178 | class => "parameter", |
179 | multiplicity => "*", |
180 | }, |
181 | { |
182 | name => "taggedValues", |
183 | path => 'UML:ModelElement.taggedValue/UML:TaggedValue', |
184 | class => "taggedValue", |
185 | multiplicity => "*", |
186 | map => "name", |
187 | }, |
188 | ], |
189 | }; |
190 | |
191 | $spec12->{parameter} = { |
192 | name => "parameter", |
193 | plural => "parameters", |
194 | default_path => '//UML:Parameter[@xmi.id]', |
195 | attrib_data => [qw/name isSpecification kind/], |
196 | path_data => [ |
197 | { |
198 | name => "stereotype", |
199 | path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name', |
200 | default => "", |
201 | }, |
202 | { |
203 | name => "datatype", |
204 | path => 'xmiDeref(UML:StructuralFeature.type/UML:DataType)/@name', |
205 | }, |
206 | ], |
207 | }; |
208 | |
209 | $spec12->{association} = { |
210 | name => "association", |
211 | plural => "associations", |
212 | isRoot => 1, |
213 | default_path => '//UML:Association[@xmi.id]', |
214 | attrib_data => [qw/name visibility isSpecification isNavigable ordering aggregation targetScope changeability/], |
215 | path_data => [ |
216 | { |
217 | name => "stereotype", |
218 | path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name', |
219 | default => "", |
220 | }, |
221 | ], |
222 | kids => [ |
223 | { |
224 | name => "ends", |
225 | path => "UML:Association.connection/UML:AssociationEnd", |
226 | class => "AssociationEnd", |
227 | multiplicity => "*", |
228 | }, |
229 | ], |
230 | }; |
231 | |
232 | $spec12->{AssociationEnd} = { |
233 | name => "End", |
234 | plural => "Ends", |
235 | default_path => '//UML:AssociationEnd', |
236 | attrib_data => [qw/name visibility isSpecification isNavigable ordering aggregation targetScope changeability/], |
237 | path_data => [ |
238 | { |
239 | name => "stereotype", |
240 | path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name', |
241 | default => "", |
242 | }, |
243 | { |
244 | name => "className", |
245 | path => 'xmiDeref(UML:AssociationEnd.participant/UML:Class)/@name', |
246 | default => "", |
247 | }, |
248 | ], |
249 | kids => [ |
42b5b9b6 |
250 | { |
251 | name => "association", |
252 | path => "../..", |
253 | class => "association", |
254 | multiplicity => "1", |
255 | }, |
93f4a354 |
256 | { |
257 | name => "participant", |
258 | path => "xmiDeref(UML:AssociationEnd.participant/UML:Class)", |
259 | class => "class", |
260 | multiplicity => "1", |
261 | }, |
93f4a354 |
262 | ], |
263 | }; |
264 | |
265 | # Set the spec and have the get_* methods generated |
266 | __PACKAGE__->XmiSpec($spec12); |
267 | |
268 | #----------------------------------------------------------------------------- |
269 | |
270 | # Test override |
271 | # sub get_classes { |
272 | # print "HELLO 1.2\n"; |
273 | # shift->SUPER::get_classes(@_); |
274 | # } |
275 | |
276 | 1; #=========================================================================== |
277 | |
278 | __END__ |
279 | |
280 | =head1 SYNOPSIS |
281 | |
282 | =head1 DESCRIPTION |
283 | |
284 | =head1 SEE ALSO |
285 | |
286 | perl(1). |
287 | |
288 | =head1 TODO |
289 | |
290 | =head1 BUGS |
291 | |
292 | =head1 VERSION HISTORY |
293 | |
294 | =head1 AUTHOR |
295 | |
296 | grommit <mark.addison@itn.co.uk> |
297 | |
298 | =cut |