Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: eacc8c7f6a14d10fdcbe8407991aa4a6a69b45fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
--/*******************************************************************************
-- * Copyright (c) 2015 Vienna University of Technology.
-- * All rights reserved. This program and the accompanying materials
-- * are made available under the terms of the Eclipse Public License v1.0
-- * which accompanies this distribution, and is available at
-- * http://www.eclipse.org/legal/epl-v10.html
-- *
-- * Contributors:
-- * Alexander Bergmayr (TU Wien) - initial API and implementation
-- * Manuel Wimmer (TU Wien) - initial API and implementation 
-- *
-- * Initially developed in the context of ARTIST EU project www.artist-project.eu
-- *******************************************************************************/

-- @nsURI UMLMM=http://www.eclipse.org/uml2/4.0.0/UML
-- @path JMM=http://www.eclipse.org/MoDisco/Java/0.2.incubation/java
-- @path TMM=pathmap://METAMODEL/Trace.ecore
-- @path CFGMM=/eu.artist.migration.mdt.jump.cm2up/metamodel/jump-configuration.ecore

-- Discovers UML Profiles from Java application code, frameworks and libraries.

module CodeModel2UMLProfile;-- creates UP the UML Profile and TM the Trace Model
-- from CM the Code Model discovered from a Java application / library
--      JP a Java-based UML Profile that provides Stereotypes for the parameterized types
		-- and proxies
--      JPT the Java Primitive Types library provided by the UML implementation
--      MC the UML meta-classes in terms of a UML model
--      UPT the UML Primitive Types library provided by the UML implementation
create UP: UMLMM, TM: TMM from CM: JMM, JP: UMLMM, JPT: UMLMM, MC: UMLMM, UPT: UMLMM,
		EPT: UMLMM, CFG : CFGMM;

-- TODO: default value of Strings - default values need to be generally revised
-- TODO: Code-generator: ID annotation nachziehen!		


-- helpers for Java-based processing
uses javaLibrary;
-- helpers for Stereotype application
uses profileLibrary;

helper def: getAnnotationTypeMemberDeclarations:
		Sequence(JMM!AnnotationTypeMemberDeclaration) =
	JMM!AnnotationTypeMemberDeclaration.allInstancesFrom('CM');

helper def: repeatingStereotypesCfg:
		OclAny = 
	CFGMM!ProfileConfigurationParameter.allInstancesFrom('CFG') -> first().repeatingStereotypes;

helper def: getRepeatableAnnotations:
		Sequence(JMM!Annotation) =
	JMM!Annotation.allInstancesFrom('CM') -> select(e | e.type.type.name = 'Repeatable');

-- check if the annotation type is repeatable
helper context JMM!AnnotationTypeDeclaration def : isRepeatable : Boolean =
	self.annotations -> exists(e | e.type.type.name = 'Repeatable');

-- check if the annotation type is a container annotation
helper context JMM!AnnotationTypeDeclaration def : isContainerAnnotation : Boolean =
	thisModule.getRepeatableAnnotations -> collect(e | e.values) -> flatten() -> exists(e | e.value.type.type = self);

helper context JMM!AnnotationTypeDeclaration def : requiresContainerAnnotation : Boolean =
	-- thisModule.repeatingStereotypesCfg = 'native' -> we don't need a container stereotype
	thisModule.repeatingStereotypesCfg = #composition or thisModule.repeatingStereotypesCfg = #emulation; 

helper def: getStereotypes: Sequence(UMLMM!Stereotype) =
	UMLMM!Stereotype.allInstancesFrom('JP');

helper def: profile: UMLMM!Profile =
	OclUndefined;

helper def: stereotype: UMLMM!Stereotype =
	OclUndefined;

helper def: proxyPackage: UMLMM!Package =
	OclUndefined;

helper def: trace: TMM!Trace =
	OclUndefined;

-- ensure that the trace model is generated
entrypoint rule createTrace() {
	to
		tr: TMM!Trace (
		)
	do {
		thisModule.trace <- tr;	
	}
}

-- init package for proxy elements
lazy rule initProxyPackage {
	from
		s1: JMM!Type
	to
		t1: UMLMM!Package (
			name <- 'proxy'
		)
	do {
		thisModule.profile.packagedElement <- t1;
		thisModule.proxyPackage <- t1;
		
		t1.applyProfile(UMLMM!Profile.allInstancesFrom('JP').first());
	}
}

-- create the profile
rule Model2Profile {
	from
		s1: JMM!Model
	to
		t1: UMLMM!Profile (
			--			packageImport <- Sequence{jpt, mc, upt},
			packageImport <- Sequence{mc,
						upt},
			metamodelReference <- mc,
			name <- s1.name,
			packagedElement <- s1.ownedElements -> select(e | not e.proxy and e.
					isAnnotationTypeContainer)
		),
		-- java primitive types
--		jpt : UMLMM!PackageImport(
--			importedPackage <- UMLMM!Model.allInstancesFrom('JPT').first()
--		),
		-- uml meta-classes
		mc: UMLMM!PackageImport (
			importedPackage <- UMLMM!Model.allInstancesFrom('MC').first()
		),
		-- uml primitive types
		upt: UMLMM!PackageImport (
			importedPackage <- UMLMM!Model.allInstancesFrom('UPT').first()
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'Model2Profile',
			targetElements <- Sequence{t1}
		)
	do {
		   -- global access to the profile
		thisModule.profile <- t1;
		   -- apply the profile for java generics / proxies
		t1.applyProfile(UMLMM!Profile.allInstancesFrom('JP').first());
		thisModule.stereotype <- UMLMM!Stereotype.allInstancesFrom('JP') -> any(e | e.name = 'JProfile');
		t1.applyStereotype(thisModule.stereotype);
		   
		   -- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;
	}
}

rule Package2Package {
	from
		s1: JMM!Package (
			not s1.proxy and s1.isAnnotationTypeContainer
		)
	to
		t1: UMLMM!Package (
			name <- s1.name,
			packagedElement <- s1.ownedPackages -> select(e | not e.proxy and
					e.isAnnotationTypeContainer) --,
			-- instead of selecting all required elements here let's do it in the
					-- corresponding rules
			-- of ClassDeclaration, EnumDeclaration, InterfaceDeclaration,
					-- AnnotationTypeDeclaration
--			packagedElement <- s1.ownedElements
			
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'Package2Package',
			targetElements <- Sequence{t1}
		)
	do {		
		   -- trace information
		tl.refSetValue('sourceElements', Sequence{s1});	
		thisModule.trace.traceLinks <- tl;
	}
}

-- but only enumerations that are required for the profile
rule EnumDeclaration2Enumeration {
	from
		s1: JMM!EnumDeclaration (
			s1.isEnumerationRelevant
		)
	to
		t1: UMLMM!Enumeration (
			name <- if (s1.refImmediateComposite().oclIsTypeOf(JMM!Package)) then
					s1.name
				else
					s1.name.concat('From').concat(s1.refImmediateComposite().name)
				endif,
			ownedLiteral <- s1.enumConstants -> select(e | not e.proxy or e.
					refImmediateComposite().isEnumerationRelevant),
			-- TODO: new CHECK !!
			ownedAttribute <- s1.bodyDeclarations -> select(e | e.
					oclIsTypeOf(JMM!FieldDeclaration)),
			-- with 'not e.proxy' we exclude the 'valueOf' method generated by the java
					-- compiler
			ownedOperation <- s1.bodyDeclarations -> select(e | e.
					oclIsTypeOf(JMM!MethodDeclaration) and not e.proxy)
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'EnumDeclaration2Enumeration',
			targetElements <- Sequence{t1}
		)
	do {
		-- if the required class declaration is a proxy then the proxy stereotype is
				-- applied
		if(s1.proxy = true) {
			if(thisModule.proxyPackage.oclIsUndefined()) {
				thisModule -> initProxyPackage(s1);
			}
			thisModule.proxyPackage.packagedElement <- t1;
			
			   -- apply the proxy stereotype
			thisModule.stereotype <- thisModule.getStereotypes -> select(e | e.name =
					'JProxyType').first();
			t1.applyStereotype(thisModule.stereotype);
			
			-- set the namepace of the proxy element if available
			if(s1.refImmediateComposite().oclIsTypeOf(JMM!Package)) {
				t1.setValue(thisModule.stereotype, 'namespace', s1.
						refImmediateComposite().getFullyQualifiedPackageName);
			}
			else {
				t1.setValue(thisModule.stereotype, 'namespace', 'NOT_AVAILABLE');	
			}
		}
		
		-- elements are contained either by packages or classifiers (nested elements)
		else {
			if(not s1.package.oclIsUndefined()) {
				thisModule.resolveTemp(s1.refImmediateComposite(), 't1').packagedElement
						<- t1;
			}
			else {
				   -- so let's get the package of the owner and put the stereotype there
						-- ... however 
				-- there is a problem when we generate code !!!!
				thisModule.resolveTemp(s1.refImmediateComposite().getJavaPackage(), 't1').
						packagedElement <- t1;
			}
		}
		
		-- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;		
	}
}

rule FieldDeclaration2Property {
	from
		s1: JMM!FieldDeclaration (
			not s1.proxy and s1.refImmediateComposite().oclIsTypeOf(JMM!EnumDeclaration)
					and s1.refImmediateComposite().isEnumerationRelevant
		)
	to
		t1: UMLMM!Property (
			-- TODO: fragments is 0..* - check the exact behaviour!
			name <- s1.fragments.first().name,
			type <- s1.type.getType(),
			isStatic <- s1.modifier.static
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'FieldDeclaration2Property',
			targetElements <- Sequence{t1}
		)
	do {
		   -- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;
	}
}

rule MethodDeclaration2Operation {
	from
		s1: JMM!MethodDeclaration (
			not s1.proxy and s1.refImmediateComposite().oclIsTypeOf(JMM!EnumDeclaration)
					and s1.refImmediateComposite().isEnumerationRelevant
		)
	to
		t1: UMLMM!Operation (
			name <- s1.name,
			ownedParameter <- s1.parameters -> collect(e | thisModule.createParameter(e))
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'MethodDeclaration2Operation',
			targetElements <- Sequence{t1}
		)
	do {
		   -- thisModule.applyStereotypes(s1, t1);
		
		-- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;
	}
}

lazy rule createParameter {
	from
		s1: JMM!SingleVariableDeclaration
	to
		t1: UMLMM!Parameter (
			name <- s1.name,
			type <- s1.type.getType(),
			direction <- #"in"
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'SingleVariableDeclaration2Paramter',
			targetElements <- Sequence{t1}
		)
	do {
		
		   -- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;
	}
}

rule EnumConstantDeclaration2EnumerationLiteral {
	from
		s1: JMM!EnumConstantDeclaration (
			s1.refImmediateComposite().isEnumerationRelevant
		)
	to
		t1: UMLMM!EnumerationLiteral (
			name <- s1.name
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'EnumConstantDeclaration2EnumerationLiteral',
			targetElements <- Sequence{t1}
		)
	do {
		   -- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;	
	}
}

-- but only classes that are required for the profile. Such classes can only be
-- bounded type parameters of java.lang.class
rule ClassDeclaration2Class {
	from
		-- since java.lang.Class is mapped to UML class, we need to exclude it here as
				-- well
		s1: JMM!ClassDeclaration (
			(s1.refImmediateComposite().getFullyQualifiedPackageName.concat('.').
					concat(s1.name) <> 'java.lang.Class') and (thisModule.
					getAnnotationTypeMemberDeclarations -> select(e | not e.type.
					oclIsUndefined()) -> select(e | e.type.type.
					oclIsTypeOf(JMM!ParameterizedType)) -> exists(f | f.type.type.
					typeArguments -> exists(g | g.type = s1)))
		)
	to
		t1: UMLMM!Class (
			name <- if (s1.refImmediateComposite().oclIsTypeOf(JMM!Package)) then
					s1.name
				else
					s1.name.concat('From').concat(s1.refImmediateComposite().name)
				endif
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'ClassDeclaration2Class',
			targetElements <- Sequence{t1}
		)
	do {		
		-- if the required class declaration is a proxy then the proxy stereotype is
				-- applied
		if(s1.proxy = true) {			
			if(thisModule.proxyPackage.oclIsUndefined()) {
				thisModule -> initProxyPackage(s1);
			}
			thisModule.proxyPackage.packagedElement <- t1;
			
			   -- apply the proxy stereotype
			thisModule.stereotype <- UMLMM!Stereotype.allInstancesFrom('JP') ->
					select(e | e.name = 'JProxyType').first();			
			t1.applyStereotype(thisModule.stereotype);
			
			-- set the namepace of the proxy element if available
			if(s1.refImmediateComposite().oclIsTypeOf(JMM!Package)) {
				t1.setValue(thisModule.stereotype, 'namespace', s1.
						refImmediateComposite().getFullyQualifiedPackageName);
			}
			else {
				t1.setValue(thisModule.stereotype, 'namespace', 'NOT_AVAILABLE');	
			}
		}
		
		-- nested classifiers are contained by classifiers rather than packages ;)
		else {
			if(thisModule.resolveTemp(s1.refImmediateComposite(), 't1').
					oclIsTypeOf(UMLMM!Package)) {
				thisModule.resolveTemp(s1.refImmediateComposite(), 't1').packagedElement
						<- t1;
			}
			else {
				   -- so let's get the package of the owner and put the stereotype there
						-- ... however 
				-- there is a problem when we generate code !!!!
				thisModule.resolveTemp(s1.refImmediateComposite().getJavaPackage(), 't1').
						packagedElement <- t1;
			}
		}
		
		-- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;
	}
}

-- but only interfaces that are required for the profile. Such classes can only be
-- bounded type parameters of java.lang.class
rule InterfaceDeclaration2Interface {
	from
		s1: JMM!InterfaceDeclaration (
			thisModule.getAnnotationTypeMemberDeclarations -> select(e | not e.type.
					oclIsUndefined()) -> select(e | e.type.type.
					oclIsTypeOf(JMM!ParameterizedType)) -> exists(f | f.type.type.
					typeArguments -> exists(g | g.type = s1))
		)
	to
		t1: UMLMM!Interface (
			name <- if (s1.refImmediateComposite().oclIsTypeOf(JMM!Package)) then
					s1.name
				else
					s1.name.concat('From').concat(s1.refImmediateComposite().name)
				endif
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'InterfaceDeclaration2Interface',
			targetElements <- Sequence{t1}
		)
	do {
		-- if the required class declaration is a proxy then the proxy stereotype is
				-- applied
		if(s1.proxy = true) {
			if(thisModule.proxyPackage.oclIsUndefined()) {
				thisModule.initProxyPackage(s1);
			}
			thisModule.proxyPackage.packagedElement <- t1;
			
			   -- apply the proxy stereotype
			thisModule.stereotype <- UMLMM!Stereotype.allInstancesFrom('JP') -> select(e
					| e.name = 'JProxyType').first();
			t1.applyStereotype(thisModule.stereotype);
			
			-- set the namepace of the proxy element if available
			if(s1.refImmediateComposite().oclIsTypeOf(JMM!Package)) {
				t1.setValue(thisModule.stereotype, 'namespace', s1.
						refImmediateComposite().getFullyQualifiedPackageName);
			}
			else {
				t1.setValue(thisModule.stereotype, 'namespace', 'NOT_AVAILABLE');	
			}
		}
		
		-- nested classifiers are contained by classifiers rather than packages ;)
		else {
			if(thisModule.resolveTemp(s1.refImmediateComposite(), 't1').
					oclIsTypeOf(UMLMM!Package)) {
				thisModule.resolveTemp(s1.refImmediateComposite(), 't1').packagedElement
						<- t1;
			}
			else {
				   -- so let's get the package of the owner and put the stereotype there
						-- ... however 
				-- there is a problem when we generate code !!!!
				thisModule.resolveTemp(s1.refImmediateComposite().getJavaPackage(), 't1').
						packagedElement <- t1;
			}
		}
		
		-- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;
	}
}

rule AnnotationTypeDeclaration2Stereotype {
	from
		-- only those AnnotationTypeDeclarations that are not proxies or return value of
				-- a AnnotationTypeMemberDeclaration
		s1: JMM!AnnotationTypeDeclaration (
			-- isn't a proxy
			not s1.proxy
			
			-- is a container stereotype required
			and ((s1.isContainerAnnotation and s1.requiresContainerAnnotation) or not s1.isContainerAnnotation)
			
			-- TODO: document this case
			or thisModule.getAnnotationTypeMemberDeclarations -> select(e | not e.type.oclIsUndefined()) -> 
			select(e | e.type.type.oclIsTypeOf(JMM!ParameterizedType)) -> exists(f | f.type.type.typeArguments ->
			exists(g | g.type = s1))
					
			-- we do have a proxy element that has been resolved. This happens if a
		    -- missing library has been added to the build path. If this
			-- library is not added then an UnresolvedTypeDeclaration
			-- is discovered by MoDisco.
			or (s1.proxy and s1.isRelevantForAnnotationTypes)
		)
	to
		t1: UMLMM!Stereotype (
			name <- if (s1.refImmediateComposite().oclIsTypeOf(JMM!Package)) then
					s1.name
				else
					s1.name.concat('From').concat(s1.refImmediateComposite().name)
				endif,
			-- can be set to public as no other visibility modifier is allowed for
					-- annotation types
			visibility <- #public,
			-- should not be done since then the stereotype cannot be instantiated (Java
					-- Feature or Bug ;) )
			-- isAbstract <- if s1.modifier.inheritance.toString() = 'abstract' then true
					-- else false endif,
			
			-- TODO : According to JLS, an annotation type declaration can also contain
					-- constant declarations
			-- class declarations etc. ... even annotation type declarations -> inner
					-- annotations
			-- this means bodyDeclarations may also be of type JMM!FieldDeclaration
			
			-- in findbugs haben wir den Fall einer ClassDeclaration innerhabl eienr
					-- AnnotationTypeDeclaration,
			-- see: edu.umd.cs.findbugs.internalAnnotations.SlashedClassName
			ownedAttribute <- s1.bodyDeclarations -> select(e | e.
					oclIsTypeOf(JMM!AnnotationTypeMemberDeclaration))
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'AnnotationTypeDeclaration2Stereotype',
			targetElements <- Sequence{t1}
		)
	do {		
		-- if the required class declaration is a proxy then the proxy stereotype is
				-- applied
		-- and the stereotype is added to a dedicated proxy package
		if(s1.proxy) {			
			if(thisModule.proxyPackage.oclIsUndefined()) {
				thisModule.initProxyPackage(s1);
			}
			thisModule.proxyPackage.packagedElement <- t1;
			
			   -- apply the proxy stereotype
			thisModule.stereotype <- UMLMM!Stereotype.allInstancesFrom('JP') -> select(e
					| e.name = 'JProxyType').first();
			t1.applyStereotype(thisModule.stereotype);
			
			-- set the namepace of the proxy element if available
			if(s1.refImmediateComposite().oclIsTypeOf(JMM!Package)) {
				t1.setValue(thisModule.stereotype, 'namespace', s1.
						refImmediateComposite().getFullyQualifiedPackageName);
			}
			else {
				t1.setValue(thisModule.stereotype, 'namespace', 'NOT_AVAILABLE');	
			}
		}
		
		-- TODO: nested classifiers are contained by classifiers rather than packages ;)
				-- ... however nested
		-- stereotypes are not actuall supported
		else {
			if(thisModule.resolveTemp(s1.refImmediateComposite(), 't1').
					oclIsTypeOf(UMLMM!Package)) {
				thisModule.resolveTemp(s1.refImmediateComposite(), 't1').packagedElement
						<- t1;
			}
			else {
				   -- so let's get the package of the owner and put the stereotype there
						-- ... however 
				-- there is a problem when we generate code !!!!
				thisModule.resolveTemp(s1.refImmediateComposite().getJavaPackage(), 't1').
						packagedElement <- t1;
			}
		}
		
		-- if the target annotation is not set at all then we have to trigger a lazy rule
				-- that produces extensions to
		-- all possible candidates
		if(not s1.proxy and not (s1.annotations -> exists(a | a.type.type.name =
				'Target'))) {
			for(javaElementType in thisModule.umlTarget.getKeys()) {
				for(umlElementType in thisModule.umlTarget.get(javaElementType)) {
 					thisModule.createExtension(s1, t1, umlElementType, javaElementType);
				}
			}
		}
		
		-- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;
	}
}

rule createExtension(annotationType: JMM!AnnotationTypeDeclaration, stereotype:
		UMLMM!Stereotype,
					 metaClass: UMLMM!Element, elementType: String) {
	to
		-- the extension relationship
		t1: UMLMM!Extension (
			name <- 'extension_'.concat(stereotype.name).concat('_').concat(metaClass.
					name),
			memberEnd <- Sequence{t2, t3},
			ownedEnd <- t3
		),
		-- the properties of the relationship (end points)
		t2: UMLMM!Property (
			name <- 'base_'.concat(metaClass.name),
			type <- metaClass,
			-- we set the lower bound to 0 because if the stereotype extends
			-- several metaclasses then we would get validation errors with 
			-- a lower bound 1
			lower <- 0,
			upper <- 1
		),
		t3: UMLMM!ExtensionEnd (
			name <- 'extension_'.concat(metaClass.name),
			aggregation <- #composite,
			type <- stereotype,
			lower <- 0,
			upper <- if(annotationType.isRepeatable) then (0-1) else 1 endif
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'createExtension',
			targetElements <- Sequence{t1,
						t2,
						t3}
		)		
	do {	
		   -- refers to the ownedAttribute of the stereotype
		stereotype.ownedAttribute <- t2;
		
		   -- refers to the profile that contains the stereotype
		stereotype.refImmediateComposite().packagedElement <- t1;
		
		-- if we create an extension of Type then we need a constraint as
		-- UML:Type is more general then Java:Type
		
		if(elementType = 'TYPE') {
			thisModule.createTypeConstraint(stereotype);
		}
		
		else if(elementType = 'CONSTRUCTOR') {
			thisModule.createConstructorConstraint(stereotype);
		}
		
		else if(elementType = 'METHOD') {
			thisModule.createMethodConstraint(stereotype);	
		}
		
		-- trace information
		tl.refSetValue('sourceElements', Sequence{annotationType});	
		thisModule.trace.traceLinks <- tl;
	}	
}

rule SingleVariableAccessMultiValued2Extension {
	from
		s1: JMM!SingleVariableAccess (
			s1.isMultiValuedAnnotationTarget
		)
	using {
		s2: JMM!AnnotationTypeDeclaration = s1.refImmediateComposite().
				refImmediateComposite().refImmediateComposite().refImmediateComposite();
	}
	to
		-- the extension relationship
		t1: UMLMM!Extension (
			name <- 'extension_'.concat(thisModule.resolveTemp(s2, 't1').name).
					concat('_').concat(thisModule.umlTarget.get(s1.variable.name).first().name),
			memberEnd <- Sequence{t2,
						t3},
			ownedEnd <- t3
		),
		-- the properties of the relationship (end points)
		t2: UMLMM!Property (
			name <- 'base_'.concat(thisModule.umlTarget.get(s1.variable.name).first().
					name),
			type <- thisModule.umlTarget.get(s1.variable.name).first(),
			lower <- 0,
			upper <- 1
		),
		t3: UMLMM!ExtensionEnd (
			name <- 'extension_'.concat(thisModule.umlTarget.get(s1.variable.name).
					first().name),
			aggregation <- #composite,
			type <- thisModule.resolveTemp(s2, 't1')
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'SingleVariableAccessMultiValued2Extension',
			targetElements <- Sequence{t1,
						t2,
						t3}
		)
	do {
		   -- refers to the ownedAttribute of the stereotype
		thisModule.resolveTemp(s2, 't1').ownedAttribute <- t2;
		
		   -- refers to the profile that contains the stereotype
		thisModule.resolveTemp(s2.getPackage(), 't1').packagedElement <- t1;
		
		-- if the target is of type FIELD, we do have to create an extension for
		-- EnumDeclaration as well;
		-- if we use Associatons, we may have to add another extension
		if(s1.variable.name = 'FIELD') {
			thisModule.createExtension(s2, thisModule.resolveTemp(s2, 't1'), thisModule.
					umlTarget.get(s1.variable.name).at(2), s1.variable.name);
		}
		
		-- if the target is of type METHOD, we do have to create an extension for
		-- Property as well as methods in annotationtypedeclrations are translated
		-- to property
		if(s1.variable.name = 'METHOD') {
			thisModule.createExtension(s2, thisModule.resolveTemp(s2, 't1'), thisModule.
					umlTarget.get(s1.variable.name).at(2), s1.variable.name);
		}
		
		-- in case of TYPE we do have to create the type constraint
		if(s1.variable.name = 'TYPE') {
			thisModule.createTypeConstraint(thisModule.resolveTemp(s2, 't1'));
		}
		
		-- in case of CONSTRUCTOR we do have to create the type constraint
		else if(s1.variable.name = 'CONSTRUCTOR') {
			thisModule.createConstructorConstraint(thisModule.resolveTemp(s2, 't1'));
		}
		
		-- trace information
		tl.refSetValue('sourceElements', Sequence{s1});	
		thisModule.trace.traceLinks <- tl;
	}
}

rule SingleVariableAccessSingleValued2Extension {
	from
		s1: JMM!SingleVariableAccess (
			s1.isSingleValuedAnnotationTarget
		)
	using {
		s2: JMM!AnnotationTypeDeclaration = s1.refImmediateComposite().
				refImmediateComposite().refImmediateComposite();
	}
	to
		-- the extension relationship
		t1: UMLMM!Extension (
			name <- 'extension_'.concat(thisModule.resolveTemp(s2, 't1').name).
					concat('_').concat(thisModule.umlTarget.get(s1.variable.name).first().name),
			memberEnd <- Sequence{t2,
						t3},
			ownedEnd <- t3
		),
		-- the properties of the relationship (end points)
		t2: UMLMM!Property (
			name <- 'base_'.concat(thisModule.umlTarget.get(s1.variable.name).first().
					name),
			type <- thisModule.umlTarget.get(s1.variable.name).first(),
			lower <- 0,
			upper <- 1
		),
		t3: UMLMM!ExtensionEnd (
			name <- 'extension_'.concat(thisModule.umlTarget.get(s1.variable.name).
					first().name),
			aggregation <- #composite,
			type <- thisModule.resolveTemp(s2, 't1')
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'SingleVariableAccessSingleValued2Extension',
			targetElements <- Sequence{t1,
						t2,
						t3}
		)
	do {
		   -- refers to the ownedAttribute of the stereotype
		thisModule.resolveTemp(s2, 't1').ownedAttribute <- t2;
		
		   -- refers to the profile that contains the stereotype
		thisModule.resolveTemp(s2.getPackage(), 't1').packagedElement <- t1;
		
		-- if the target is of type FIELD, we do have to create an extension for
		-- EnumDeclaration as well;
		-- if we use Associatons, we may have to add another extension
		if(s1.variable.name = 'FIELD') {
			thisModule.createExtension(s2, thisModule.resolveTemp(s2, 't1'), thisModule.
					umlTarget.get(s1.variable.name).at(2), s1.variable.name);
		}
		
		-- if the target is of type METHOD, we do have to create an extension for
		-- Property as well as methods in annotationtypedeclrations are translated
		-- to property
		if(s1.variable.name = 'METHOD') {
			thisModule.createExtension(s2, thisModule.resolveTemp(s2, 't1'), thisModule.
					umlTarget.get(s1.variable.name).at(2), s1.variable.name);
		}
		
		-- in case of TYPE we do have to create the type constraint
		if(s1.variable.name = 'TYPE') {
			thisModule.createTypeConstraint(thisModule.resolveTemp(s2, 't1'));
		}
		
		-- in case of CONSTRUCTOR we do have to create the type constraint
		else if(s1.variable.name = 'CONSTRUCTOR') {
			thisModule.createConstructorConstraint(thisModule.resolveTemp(s2, 't1'));
		}
		
		-- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;
	}
}

rule AnnotationTypeMemberDeclaration2Property {	
	from
		s1: JMM!AnnotationTypeMemberDeclaration (
			-- we need to exclude unresolved annotation type member declarations
			if(s1.oclIsTypeOf(JMM!AnnotationTypeMemberDeclaration) and not s1.proxy) then
			
				-- is a container stereotype required
				((s1.refImmediateComposite().isContainerAnnotation and s1.refImmediateComposite().requiresContainerAnnotation)
				 	or not s1.refImmediateComposite().isContainerAnnotation)
			
				or s1.refImmediateComposite().isRelevantForAnnotationTypes
				
			else false
			endif
		)
	to
		t1: UMLMM!Property (
			name <- s1.name,
			-- can be set to public as no other visibility modifier is allowed for
					-- annotation types
			visibility <- #public,
			-- the problem here is that we may have proxy member declaratios with no
					-- further type information
			type <- if (s1.type <> OclUndefined) then
					s1.type.getType()
				else
					UMLMM!PrimitiveType.allInstancesFrom('EPT') -> select(e | e.name =
							'EJavaObject').first()
				endif,
			-- is done in post processing ;)
			-- default <- if s1.default <> OclUndefined and
					-- s1.default.oclIsTypeOf(JMM!NumberLiteral) then 
			--			 s1.default.tokenValue else OclUndefined endif,
			-- TODO: provide example for an undefined type
			lower <- if s1.default <> OclUndefined then
					0
				else
					if s1.type <> OclUndefined then
						if s1.type.type.oclIsTypeOf(JMM!ArrayType) then
							0
						else
							1
						endif
					else
						1
					endif
				endif,
			upper <- if s1.type <> OclUndefined then
					if s1.type.type.oclIsTypeOf(JMM!ArrayType) then
						-1
					else
						1
					endif
				else
					1
				endif,
			-- if stereotypes are composed by other stereotypes
			aggregation <- if s1.type <> OclUndefined 
			               -- if the annotation member is of type Class then aggregation needs to be set to #none
						   then if(s1.type.isComplexType() and not s1.type.getType().oclIsTypeOf(UMLMM!Class)) then #composite else #none
								endif
						   else #none
						   endif
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'AnnotationTypeMemberDeclaration2Property',
			targetElements <- Sequence{t1}
		)
	do {
		
		-- TODO : Here we should also consider the discussion about OCL constraints for
		--        the allowed types as specified by the binding Class<T>
		-- same as above: the problem here is that we may have proxy member declaratios
				-- with no further type information
		if(s1.type <> OclUndefined) {
			if (s1.type.type.oclIsTypeOf(JMM!ParameterizedType)) {
				thisModule.stereotype <- thisModule.getStereotypes -> any(e | e.name =
						'JGenericType');
				t1.applyStereotype(thisModule.stereotype);
				
				t1.setValue(thisModule.stereotype, 'type', 'upperBounded');
							
				-- set the type of the 'binding' ... unbounded (default), upperbounded,
						-- lowerbounded, bounded;
				if (s1.type.type.typeArguments.first().type.
						oclIsTypeOf(JMM!WildCardType)) {
					
					-- if the type parameterized type is unresolved then create a proxy
							-- element
					-- design decision: it seems to be rather hard to express this part
							-- declaratively ;(
	
					if(not s1.type.type.typeArguments.first().type.bound.
							oclIsUndefined()) {				
						if(s1.type.type.typeArguments.first().type.bound.type.
								oclIsTypeOf(JMM!UnresolvedTypeDeclaration)) {
							
							   -- s1.refImmediateComposite().name.debug();
							-- s1.name.debug();
							thisModule.UnresolvedTypeDeclaration2Type(s1.type.type.
									typeArguments.first().type.bound.type); 	
						}
					}
					
					-- upperBounded case
					if (s1.type.type.typeArguments.first().type.name.startsWith('?' + ''
							+ ' extends')) {
						thisModule.stereotype <- thisModule.getStereotypes -> any(e | e.
								name = 'JGenericType');
						t1.setValue(thisModule.stereotype, 'type', 'upperBounded');
						
					 	--t1.setValue(thisModule.stereotype, 'type', 'upperBounded');
					 	--t1.setValue(thisModule.stereotype, 'parameter',
							-- thisModule.resolveTemp(s1.type.type.typeArguments.first().type.bound.typ
									-- e
									-- ,
							-- 't1').debug());
					}
					-- lowerBounded case
					else if (s1.type.type.typeArguments.first().type.name.toString().
							startsWith('? super')) {
					    t1.setValue(thisModule.stereotype, 'type', 'lowerBounded');
					   -- t1.setValue(thisModule.stereotype, 'parameter',
							-- thisModule.resolveTemp(s1.type.type.typeArguments.first().type.bound.typ
									-- e
									-- ,
							-- 't1').debug());
					}
				}
				
				-- bounded case
				else if (not s1.type.type.typeArguments.first().type.oclIsUndefined()) {
					
					   -- s1.name.debug();
						t1.setValue(thisModule.stereotype, 'type', 'bounded');
					t1.setValue(thisModule.stereotype, 'parameter', thisModule.
							resolveTemp(s1.type.type.typeArguments.first().type,
							't1'));	
				}
			}
			 
			if (s1.type.isComplexType()) {
				thisModule.AnnotationTypeMemberDeclaration2Association(s1);
			}
		}
		
		-- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;
	}
}

-- if we have UML properties with a complex type then we should create an UML association
lazy rule AnnotationTypeMemberDeclaration2Association {
	from
		s1: JMM!AnnotationTypeMemberDeclaration
	to
		t1: UMLMM!Association (
			name <- if (not s1.type.getType().name.oclIsUndefined()) then
					s1.name.concat('_').concat(s1.refImmediateComposite().name).concat('_').concat(s1.type.getType().name)
				else
					s1.name.concat('_').concat(s1.refImmediateComposite().name).concat('_').concat(s1.type.type.name)
				endif,
			memberEnd <- s1,
			memberEnd <- t2
		),
		t2: UMLMM!Property (
			-- the idea is to use the name of the Java field plus the classifier the 
			-- association points to
			name <- s1.name.concat('_').concat(s1.refImmediateComposite().name),
			-- can be set to public as no other visibility modifier is allowed for
					-- annotation types
			visibility <- #public,
			-- TODO: Think about the multiplicity
			lower <- 0,
			upper <- 1,
			type <- s1.refImmediateComposite()
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'AnnotationTypeMemberDeclaration2Association',
			targetElements <- Sequence{t1}
		)
	do {
		thisModule.resolveTemp(s1.refImmediateComposite().getPackage(), 't1').
				packagedElement <- t1;
		
		-- case java.lang.Class / java.lang.Class[]: we do not want to change the
				-- meta-class UML Class
		-- so the produced property is contained by the association		
		if( (s1.type.type.oclIsTypeOf(JMM!ParameterizedType)) or
				(s1.type.type.refImmediateComposite().getFullyQualifiedPackageName.toString().concat('.').concat(s1.type.type.name).toString()
				= 'java.lang.Class') or (  -- in case the Array is parameterized the name
				-- string also contains '<...>'
				s1.type.type.name.toString().startsWith('java.lang.Class') and s1.type.
						type.name.toString().endsWith('[]')) ) {
			
			t1.ownedEnd <- t2;
		}
		-- we follow the standard procedure and put the produced property into the 
		-- associated element
		else {
			if(s1.type.type.oclIsTypeOf(JMM!ArrayType)) {
				
				if(s1.type.type.elementType.type.
						oclIsTypeOf(JMM!UnresolvedTypeDeclaration)) {
					t1.ownedEnd <- t2;		
				}
				
				
				thisModule.resolveTemp(s1.type.type.elementType.type, 't1').
						ownedAttribute <- t2;
			}
			else {
				thisModule.resolveTemp(s1.type.type, 't1').ownedAttribute <- t2;
			}
		}
		
		-- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;

	}
}

-- Refers to Types that cannot be resolved. This happens if a library references elements
-- of another library for which we do not have access to the source. Then, we get only the
-- type information and the type access but not further information.
-- The idea is to transform those UnresolvedTypes that are used in the declaration of
-- of annotations, i.e., AnnotationTypeMemberDeclarations. This seems to be essential
-- to declare the AnnotationTypeMemberDeclaration.
rule UnresolvedTypeDeclaration2Type {
	from
		s1: JMM!UnresolvedTypeDeclaration (
			s1.usagesInTypeAccess -> exists(e | e.refImmediateComposite().
					oclIsTypeOf(JMM!AnnotationTypeMemberDeclaration)) or
			-- ArrayTypes need to be handled differently
			s1.usagesInTypeAccess -> collect(e | e.refImmediateComposite()) -> 
					select(e | e.oclIsTypeOf(JMM!ArrayType)) -> exists(e | e.usagesInTypeAccess ->
					exists(f | f.refImmediateComposite().oclIsTypeOf(JMM!AnnotationTypeMemberDeclaration)))
		)
	to
		t1: UMLMM!Class (
			name <- s1.name
		),
		-- trace information
		tl: TMM!TraceLink (
			ruleName <- 'UnresolvedTypeDeclaration2Type',
			targetElements <- Sequence{t1}
		)
	do {
		if(thisModule.proxyPackage.oclIsUndefined()) {
			thisModule -> initProxyPackage(s1);
		}
		thisModule.proxyPackage.packagedElement <- t1;
		
		   -- apply the proxy stereotype
		thisModule.stereotype <- UMLMM!Stereotype.allInstancesFrom('JP') ->
				select(e | e.name = 'JProxyType').first();			
		t1.applyStereotype(thisModule.stereotype);
		
		   -- trace information
		tl.refSetValue('sourceElements', Sequence{s1});
		thisModule.trace.traceLinks <- tl;
	}
}

-- we do need a constraint for the Type extension as only Class, Interface, Enumeration
-- and Stereotype
-- should be targets for the produced Stereotype
rule createTypeConstraint(stereotype: UMLMM!Stereotype) {
	to
		t1: UMLMM!Constraint (
			name <- 'typeConstraint',
			constrainedElement <- stereotype,
			context <- stereotype,
			specification <- t2
		),
		t2: UMLMM!OpaqueExpression (
			name <- 'typeConstraintExpression',
			-- the type constraint
--			body <- 'self.base_Type.oclIsUndefined() or
--					 (self.base_Type.oclIsTypeOf(uml::Class) or
--					  self.base_Type.oclIsTypeOf(uml::Interface) or
--					  self.base_Type.oclIsTypeOf(uml::Enumeration) or
--					  self.base_Type.oclIsTypeOf(uml::Stereotype))',
			body <- 'not self.base_Type.oclIsUndefined() implies Set{uml::Stereotype,
					uml::Class, uml::Enumeration, uml::Interface}
					 -> includes(self.base_Type.oclType())',
			-- the language we use to express the constraint
			language <- 'OCL'
		)
}

-- furthermore, we do need a constraint for the Operation extension if the Java element
-- type Constructor
-- is used
rule createConstructorConstraint(stereotype: UMLMM!Stereotype) {
	to
		t1: UMLMM!Constraint (
			name <- 'constructorConstraint',
			constrainedElement <- stereotype,
			context <- stereotype,
			specification <- t2
		),
		t2: UMLMM!OpaqueExpression (
			name <- 'constructorConstraintExpression',
			-- the type constraint
			-- body <- 'self.base_Operation.oclIsUndefined() or
			--		 self.base_Operation.name =
					-- self.base_Operation.oclContainer().oclAsType(uml::Classifier).name'
					-- ,
			body <- 'not self.base_Operation.oclIsUndefined() implies
					self.base_Operation.name =
				     self.base_Operation.oclContainer().oclAsType(uml::Classifier).name',
			-- the language we use to express the constraint
			language <- 'OCL'
		)
}

-- since we translation methods of annotationtypedeclarations to properties, we do have
-- to take care
-- that such properties can be stereotyped if ElementType.Method is set
rule createMethodConstraint(stereotype: UMLMM!Stereotype) {
	to
		t1: UMLMM!Constraint (
			name <- 'methodConstraint',
			constrainedElement <- stereotype,
			context <- stereotype,
			specification <- t2
		),
		t2: UMLMM!OpaqueExpression (
			name <- 'methodConstraintExpression',
			-- the type constraint
--			body <- 'self.base_Property.oclIsUndefined() or
--					 self.base_Property.oclContainer().oclIsTypeOf(uml::Stereotype)',
			body <- 'not self.base_Property.oclIsUndefined() implies
					 self.base_Property.oclContainer().oclIsTypeOf(uml::Stereotype)',
			-- the language we use to express the constraint
			language <- 'OCL'
		)	
}

-- currently we do not use UML's support for templates and template binding!
--rule ParameterizedType2Class {
--	from
--		s1 : JMM!ParameterizedType
--	to
--		t1 : UMLMM!Class (
--			name <- s1.name,
--			templateBinding <- s1.typeArguments
--		)
--}
--
--rule TypeAccessOfParameterizedType2TemplateBinding {
--	from
--		s1 : JMM!TypeAccess(
--				if s1.refImmediateComposite().oclIsTypeOf(JMM!ParameterizedType)
--				then s1.refImmediateComposite().typeArguments -> exists(e | e = s1)
--				else false endif)
--	to
--		t1 : UMLMM!TemplateBinding (
--			signature <-
		-- s1.refImmediateComposite().getParameterizedClassFromJavaLibrary().ownedTemplateSignatur
				-- e
				-- ,
		-- 
--			parameterSubstitution <- t2
--		),
--		
--		t2 : UMLMM!TemplateParameterSubstitution (
--			-- TODO : the assumption here is that we have only one parameter
--			formal <-
		-- s1.refImmediateComposite().getParameterizedClassFromJavaLibrary().ownedTemplateSignature.ownedParameter.first(
				-- )
				-- ,
		-- 
--			actual <- if s1.type.oclIsTypeOf(JMM!AnnotationTypeDeclaration) then
		-- s1.type else s1.getActualParameterFromModelLibrary() endif
--			-- TODO : in RSA the property ownedActual is set as well ... but then the
--- define step of UML2 plugin breaks!
--		)
--}

Back to the top