Changed debug to dump xmi model data and not just classes.
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / XMI / Parser / V12.pm
CommitLineData
93f4a354 1package SQL::Translator::XMI::Parser::V12;
2
3# -------------------------------------------------------------------
4# $Id: V12.pm,v 1.1 2003-09-29 12:02:36 grommit Exp $
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
27SQL::Translator::XMI::Parser::V12 - Version 1.2 parser.
28
29=cut
30
31use strict;
32use 5.006_001;
33use vars qw/$VERSION/;
34$VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/;
35
36use base qw(SQL::Translator::XMI::Parser);
37
38my $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 {
122 name => "datatype",
123 path => 'xmiDeref(UML:StructuralFeature.type/UML:DataType)/@name',
124 },
125 {
126 name => "initialValue",
127 path => 'UML:Attribute.initialValue/UML:Expression/@body',
128 },
129 ],
130 kids => [
131 {
132 name => "taggedValues",
133 path => 'UML:ModelElement.taggedValue/UML:TaggedValue',
134 class => "taggedValue",
135 multiplicity => "*",
136 map => "name",
137 },
138 ],
139};
140
141$spec12->{operation} = {
142 name => "operation",
143 plural => "operations",
144 default_path => '//UML:Classifier.feature/UML:Operation[@xmi.id]',
145 attrib_data =>
146 [qw/name visibility isSpecification ownerScope isQuery
147 concurrency isRoot isLeaf isAbstract/],
148 path_data => [
149 {
150 name => "stereotype",
151 path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name',
152 default => "",
153 },
154 ],
155 kids => [
156 {
157 name => "parameters",
158 path => "UML:BehavioralFeature.parameter/UML:Parameter",
159 class => "parameter",
160 multiplicity => "*",
161 },
162 {
163 name => "taggedValues",
164 path => 'UML:ModelElement.taggedValue/UML:TaggedValue',
165 class => "taggedValue",
166 multiplicity => "*",
167 map => "name",
168 },
169 ],
170};
171
172$spec12->{parameter} = {
173 name => "parameter",
174 plural => "parameters",
175 default_path => '//UML:Parameter[@xmi.id]',
176 attrib_data => [qw/name isSpecification kind/],
177 path_data => [
178 {
179 name => "stereotype",
180 path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name',
181 default => "",
182 },
183 {
184 name => "datatype",
185 path => 'xmiDeref(UML:StructuralFeature.type/UML:DataType)/@name',
186 },
187 ],
188};
189
190$spec12->{association} = {
191 name => "association",
192 plural => "associations",
193 isRoot => 1,
194 default_path => '//UML:Association[@xmi.id]',
195 attrib_data => [qw/name visibility isSpecification isNavigable ordering aggregation targetScope changeability/],
196 path_data => [
197 {
198 name => "stereotype",
199 path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name',
200 default => "",
201 },
202 ],
203 kids => [
204 {
205 name => "ends",
206 path => "UML:Association.connection/UML:AssociationEnd",
207 class => "AssociationEnd",
208 multiplicity => "*",
209 },
210 ],
211};
212
213$spec12->{AssociationEnd} = {
214 name => "End",
215 plural => "Ends",
216 default_path => '//UML:AssociationEnd',
217 attrib_data => [qw/name visibility isSpecification isNavigable ordering aggregation targetScope changeability/],
218 path_data => [
219 {
220 name => "stereotype",
221 path => 'xmiDeref(UML:ModelElement.stereotype/UML:Stereotype)/@name',
222 default => "",
223 },
224 {
225 name => "className",
226 path => 'xmiDeref(UML:AssociationEnd.participant/UML:Class)/@name',
227 default => "",
228 },
229 ],
230 kids => [
231 {
232 name => "participant",
233 path => "xmiDeref(UML:AssociationEnd.participant/UML:Class)",
234 class => "class",
235 multiplicity => "1",
236 },
237 {
238 name => "association",
239 path => "../..",
240 class => "association",
241 multiplicity => "1",
242 },
243 ],
244};
245
246# Set the spec and have the get_* methods generated
247__PACKAGE__->XmiSpec($spec12);
248
249#-----------------------------------------------------------------------------
250
251# Test override
252# sub get_classes {
253# print "HELLO 1.2\n";
254# shift->SUPER::get_classes(@_);
255# }
256
2571; #===========================================================================
258
259__END__
260
261=head1 SYNOPSIS
262
263=head1 DESCRIPTION
264
265=head1 SEE ALSO
266
267perl(1).
268
269=head1 TODO
270
271=head1 BUGS
272
273=head1 VERSION HISTORY
274
275=head1 AUTHOR
276
277grommit <mark.addison@itn.co.uk>
278
279=cut