ontomde-uml2 2.0.0 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/lib/ontomde-uml2.rb +1 -0
- data/lib/ontomde-uml2/UMLdatatypeMapping.rb +80 -51
- data/lib/ontomde-uml2/autoImplement.rb +27 -5
- data/lib/ontomde-uml2/createAndAdd.rb +15 -0
- data/lib/ontomde-uml2/kb/protege.rb +7 -7
- data/lib/ontomde-uml2/nocode.rb +45 -0
- data/lib/ontomde-uml2/owner.rb +12 -2
- data/lib/ontomde-uml2/uml2.rb +39 -0
- data/lib/ontomde-uml2/umlx.rb +25 -0
- data/lib/ontomde-uml2/version.rb +1 -1
- metadata +4 -3
data/Manifest.txt
CHANGED
@@ -24,6 +24,7 @@ lib/ontomde-uml2/kb/command.rb
|
|
24
24
|
lib/ontomde-uml2/kb/datatypeMapping.rb
|
25
25
|
lib/ontomde-uml2/kb/protege.rb
|
26
26
|
lib/ontomde-uml2/multipleInheritance.rb
|
27
|
+
lib/ontomde-uml2/nocode.rb
|
27
28
|
lib/ontomde-uml2/nt_old_to_nt_new.sh
|
28
29
|
lib/ontomde-uml2/owner.rb
|
29
30
|
lib/ontomde-uml2/salvageErrors.rb
|
data/lib/ontomde-uml2.rb
CHANGED
@@ -25,7 +25,7 @@ def addDataTypeMapping(umlDataTypeName,baseMapping,regexp=nil,&block)
|
|
25
25
|
end
|
26
26
|
DatatypeMapping#{rubyName}.class_eval( &block ) unless block.nil?
|
27
27
|
|
28
|
-
DatatypeMapping#{rubyName}.instance #register
|
28
|
+
DatatypeMapping#{rubyName}.instance.register #register
|
29
29
|
}
|
30
30
|
t=eval s
|
31
31
|
puts "Added datatype '#{umlDataTypeName}'"
|
@@ -37,7 +37,7 @@ class DatatypeMapping
|
|
37
37
|
return @@types
|
38
38
|
end
|
39
39
|
@@types=Array.new
|
40
|
-
def
|
40
|
+
def register
|
41
41
|
return if self.class==DatatypeMapping
|
42
42
|
@@types << self
|
43
43
|
#log.debug { %{registered(##{@@types.size}): #{self.class}} }
|
@@ -110,7 +110,10 @@ END
|
|
110
110
|
# max length of this element represented as a string
|
111
111
|
attr :maxStringLength
|
112
112
|
attr_writer :maxStringLength
|
113
|
-
|
113
|
+
def initialize
|
114
|
+
super
|
115
|
+
@maxStringLength=nil
|
116
|
+
end
|
114
117
|
|
115
118
|
def getValidationRegexp
|
116
119
|
#log.error %{getValidationRegexp not implemented for #{self.class}}
|
@@ -126,13 +129,16 @@ class DatatypeMappingText < DatatypeMapping
|
|
126
129
|
include Singleton
|
127
130
|
|
128
131
|
#default string length
|
129
|
-
|
132
|
+
def initialize
|
133
|
+
super
|
134
|
+
@maxStringLength=255 # aligned with mysql default
|
135
|
+
end
|
130
136
|
|
131
|
-
MATCHING_UML_NAME=[
|
137
|
+
MATCHING_UML_NAME=['string','shorttext','text']
|
132
138
|
#MATCHING_JAVA_NAME=["String","java.lang.String"]
|
133
139
|
|
134
140
|
def appliesTo?(datatype)
|
135
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
141
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
136
142
|
#return true if MATCHING_JAVA_NAME.include?(datatype.java_qualifiedName)
|
137
143
|
return false
|
138
144
|
end
|
@@ -144,10 +150,14 @@ end
|
|
144
150
|
|
145
151
|
class DatatypeMappingLargeText < DatatypeMappingText
|
146
152
|
include Singleton
|
153
|
+
def initialize
|
154
|
+
super
|
155
|
+
@maxStringLength=5000
|
156
|
+
end
|
147
157
|
HELPMSG=" "
|
148
|
-
MATCHING_UML_NAME=[
|
158
|
+
MATCHING_UML_NAME=['largetext','longtext']
|
149
159
|
def appliesTo?(datatype)
|
150
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
160
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
151
161
|
return false
|
152
162
|
end
|
153
163
|
|
@@ -159,9 +169,9 @@ end
|
|
159
169
|
|
160
170
|
class DatatypeMappingMimeType < DatatypeMappingText
|
161
171
|
include Singleton
|
162
|
-
MATCHING_UML_NAME=[
|
172
|
+
MATCHING_UML_NAME=['mimetype']
|
163
173
|
def appliesTo?(datatype)
|
164
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
174
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
165
175
|
end
|
166
176
|
|
167
177
|
def getHelp
|
@@ -179,10 +189,10 @@ end
|
|
179
189
|
|
180
190
|
class DatatypeMappingInteger < DatatypeMappingOrdinal
|
181
191
|
include Singleton
|
182
|
-
MATCHING_UML_NAME=[
|
192
|
+
MATCHING_UML_NAME=['integer','int']
|
183
193
|
#MATCHING_JAVA_NAME=[]
|
184
194
|
def appliesTo?(datatype)
|
185
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
195
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
186
196
|
# return true if MATCHING_JAVA_NAME.include?(datatype.java_qualifiedName)
|
187
197
|
return false
|
188
198
|
end
|
@@ -208,7 +218,7 @@ class DatatypeMappingLong < DatatypeMappingOrdinal
|
|
208
218
|
end
|
209
219
|
class DatatypeMappingLongObject < DatatypeMappingOrdinal
|
210
220
|
include Singleton
|
211
|
-
MATCHING_UML_NAME=["Long"]
|
221
|
+
MATCHING_UML_NAME=["Long","longOrNull"]
|
212
222
|
#MATCHING_JAVA_NAME=[]
|
213
223
|
def appliesTo?(datatype)
|
214
224
|
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
@@ -226,7 +236,7 @@ class DatatypeMappingFile < DatatypeMapping
|
|
226
236
|
MATCHING_UML_NAME=["file"]
|
227
237
|
def appliesTo?(datatype)
|
228
238
|
return false unless datatype.kind_of?(Muml_DataType)
|
229
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
239
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
230
240
|
#return datatype.struts_isBlob?
|
231
241
|
#return ["image"].include?(datatype.java_qualifiedName)
|
232
242
|
end
|
@@ -238,10 +248,10 @@ end
|
|
238
248
|
|
239
249
|
class DatatypeMappingBoolean < DatatypeMapping
|
240
250
|
include Singleton
|
241
|
-
MATCHING_UML_NAME=["
|
251
|
+
MATCHING_UML_NAME=["boolean"]
|
242
252
|
#MATCHING_JAVA_NAME=[]
|
243
253
|
def appliesTo?(datatype)
|
244
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
254
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
245
255
|
# return true if MATCHING_JAVA_NAME.include?(datatype.java_qualifiedName)
|
246
256
|
return false
|
247
257
|
end
|
@@ -259,10 +269,10 @@ end
|
|
259
269
|
# Calendar and TimeStamp should be prefered.
|
260
270
|
class DatatypeMappingTimeStamp < DatatypeMapping
|
261
271
|
include Singleton
|
262
|
-
MATCHING_UML_NAME=["
|
272
|
+
MATCHING_UML_NAME=["timestamp","date"]
|
263
273
|
#MATCHING_JAVA_NAME=[]
|
264
274
|
def appliesTo?(datatype)
|
265
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
275
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
266
276
|
#return true if MATCHING_JAVA_NAME.include?(datatype.java_qualifiedName)
|
267
277
|
return false
|
268
278
|
end
|
@@ -283,10 +293,10 @@ end
|
|
283
293
|
# Calendar and TimeStamp are used instead
|
284
294
|
class DatatypeMappingCalendar < DatatypeMapping
|
285
295
|
include Singleton
|
286
|
-
MATCHING_UML_NAME=["
|
296
|
+
MATCHING_UML_NAME=["calendar"]
|
287
297
|
#MATCHING_JAVA_NAME=[]
|
288
298
|
def appliesTo?(datatype)
|
289
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
299
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
290
300
|
#return true if MATCHING_JAVA_NAME.include?(datatype.java_qualifiedName)
|
291
301
|
return false
|
292
302
|
end
|
@@ -336,10 +346,10 @@ end
|
|
336
346
|
|
337
347
|
class DatatypeMappingURL < DatatypeMappingText
|
338
348
|
include Singleton
|
339
|
-
MATCHING_UML_NAME=["
|
349
|
+
MATCHING_UML_NAME=["url","uri"]
|
340
350
|
#MATCHING_JAVA_NAME=[]
|
341
351
|
def appliesTo?(datatype)
|
342
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
352
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
343
353
|
#return true if MATCHING_JAVA_NAME.include?(datatype.java_qualifiedName)
|
344
354
|
return false
|
345
355
|
end
|
@@ -351,9 +361,9 @@ end
|
|
351
361
|
|
352
362
|
class DatatypeMappingBLOB < DatatypeMapping
|
353
363
|
include Singleton
|
354
|
-
MATCHING_UML_NAME=["
|
364
|
+
MATCHING_UML_NAME=["blob"]
|
355
365
|
def appliesTo?(datatype)
|
356
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
366
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
357
367
|
return false
|
358
368
|
end
|
359
369
|
def getHelp
|
@@ -362,9 +372,9 @@ class DatatypeMappingBLOB < DatatypeMapping
|
|
362
372
|
end
|
363
373
|
class DatatypeMappingIMG < DatatypeMappingBLOB
|
364
374
|
include Singleton
|
365
|
-
MATCHING_UML_NAME=["
|
375
|
+
MATCHING_UML_NAME=["img","image"]
|
366
376
|
def appliesTo?(datatype)
|
367
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
377
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
368
378
|
return false
|
369
379
|
end
|
370
380
|
def getHelp
|
@@ -374,9 +384,9 @@ end
|
|
374
384
|
|
375
385
|
class DatatypeMappingGRAPHVIZ < DatatypeMappingLargeText
|
376
386
|
include Singleton
|
377
|
-
MATCHING_UML_NAME=["
|
387
|
+
MATCHING_UML_NAME=["graphviz"]
|
378
388
|
def appliesTo?(datatype)
|
379
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
389
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
380
390
|
return false
|
381
391
|
end
|
382
392
|
def getHelp
|
@@ -386,9 +396,9 @@ end
|
|
386
396
|
|
387
397
|
class DatatypeMappingPassword < DatatypeMappingText
|
388
398
|
include Singleton
|
389
|
-
MATCHING_UML_NAME=["
|
399
|
+
MATCHING_UML_NAME=["password"]
|
390
400
|
def appliesTo?(datatype)
|
391
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
401
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
392
402
|
return false
|
393
403
|
end
|
394
404
|
|
@@ -399,9 +409,9 @@ end
|
|
399
409
|
|
400
410
|
class DatatypeMappingEmailAddress < DatatypeMappingText
|
401
411
|
include Singleton
|
402
|
-
MATCHING_UML_NAME=["
|
412
|
+
MATCHING_UML_NAME=["emailaddress","emailadress"]
|
403
413
|
def appliesTo?(datatype)
|
404
|
-
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one)
|
414
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
405
415
|
return false
|
406
416
|
end
|
407
417
|
|
@@ -416,26 +426,45 @@ class DatatypeMappingEmailAddress < DatatypeMappingText
|
|
416
426
|
end
|
417
427
|
end
|
418
428
|
|
429
|
+
class DatatypeMappingSimpleUnixPath < DatatypeMappingText
|
430
|
+
include Singleton
|
431
|
+
MATCHING_UML_NAME=["simpleunixpath"]
|
432
|
+
def appliesTo?(datatype)
|
433
|
+
return true if MATCHING_UML_NAME.include?(datatype.uml_name_one.downcase)
|
434
|
+
return false
|
435
|
+
end
|
419
436
|
|
437
|
+
def getValidationRegexp
|
438
|
+
# // not valid
|
439
|
+
# ok: /a/b/c a a/b
|
440
|
+
#nok: //a ./a/b
|
441
|
+
return /([a-zA-Z0-9_%+-]\/?)*/
|
442
|
+
end
|
443
|
+
|
444
|
+
def getHelp
|
445
|
+
return "simple unix path (no relative, no space, no escape)"
|
446
|
+
end
|
447
|
+
end
|
420
448
|
|
421
|
-
DatatypeMappingGenericEnum.instance #register
|
422
|
-
|
423
|
-
DatatypeMappingCalendar.instance #register
|
424
|
-
DatatypeMappingText.instance #register
|
425
|
-
DatatypeMappingLargeText.instance #register
|
426
|
-
DatatypeMappingPassword.instance #register
|
427
|
-
DatatypeMappingEmailAddress.instance #register
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
449
|
+
DatatypeMappingGenericEnum.instance.register #register
|
450
|
+
|
451
|
+
DatatypeMappingCalendar.instance.register #register
|
452
|
+
DatatypeMappingText.instance.register #register
|
453
|
+
DatatypeMappingLargeText.instance.register #register
|
454
|
+
DatatypeMappingPassword.instance.register #register
|
455
|
+
DatatypeMappingEmailAddress.instance.register #register
|
456
|
+
DatatypeMappingSimpleUnixPath.instance.register #register
|
457
|
+
DatatypeMappingURL.instance.register #register
|
458
|
+
DatatypeMappingFile.instance.register #register
|
459
|
+
DatatypeMappingBoolean.instance.register #register
|
460
|
+
DatatypeMappingTimeStamp.instance.register #register
|
461
|
+
DatatypeMappingGenericClass.instance.register #register
|
462
|
+
DatatypeMappingLong.instance.register #register
|
463
|
+
DatatypeMappingLongObject.instance.register #register
|
464
|
+
DatatypeMappingInteger.instance.register #register
|
465
|
+
DatatypeMappingBLOB.instance.register #register
|
466
|
+
DatatypeMappingIMG.instance.register #register
|
467
|
+
DatatypeMappingGRAPHVIZ.instance.register #register
|
468
|
+
DatatypeMappingMimeType.instance.register #register
|
440
469
|
|
441
470
|
|
@@ -11,6 +11,18 @@ module Mrdf_Repository
|
|
11
11
|
}
|
12
12
|
end
|
13
13
|
end
|
14
|
+
class String
|
15
|
+
def str_to_uri
|
16
|
+
return self.tr(" <>:/","_")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
module Muml_Element
|
20
|
+
def umlx_copyStereotypesFrom!(ia)
|
21
|
+
ia.uml_appliedStereotype.each { |s|
|
22
|
+
self.uml_appliedStereotype_add(s)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
14
26
|
module Muml_Class
|
15
27
|
rdf_safe_attr_reader_many :umlx_autoImplementComplete
|
16
28
|
def umlx_autoImplementProperty!
|
@@ -29,9 +41,12 @@ module Muml_Class
|
|
29
41
|
#log.debug { "umlx_autoImplementProperty #{ia} for #{self} #{ia.umlx_isAssociation?}" }
|
30
42
|
next if impAttNames.include?(ia.uml_name.to_s)
|
31
43
|
if(ia.umlx_isAttribute?)
|
32
|
-
att=self.umlx_createAndAddProperty(ia.uml_name.to_s)
|
44
|
+
att=self.umlx_createAndAddProperty(self.rdf_uri+ia.uml_name.to_s.str_to_uri)
|
33
45
|
att.uml_name=ia.uml_name
|
34
46
|
att.uml_type=ia.uml_type
|
47
|
+
att.umlx_copyStereotypesFrom!(ia)
|
48
|
+
att.uml_upperValue=ia.uml_upperValue unless ia.uml_upperValue.empty?
|
49
|
+
att.uml_lowerValue=ia.uml_lowerValue unless ia.uml_lowerValue.empty?
|
35
50
|
else
|
36
51
|
#puts "create and add ..."
|
37
52
|
ms=ia.uml_association_one
|
@@ -40,12 +55,16 @@ module Muml_Class
|
|
40
55
|
#puts "ms=#{ms}"
|
41
56
|
#puts "ms1=#{ms1} #{ms1.uml_type}"
|
42
57
|
#puts "ms2=#{ms2} #{ms2.uml_type}"
|
43
|
-
m,m1,m2=self.umlx_createAndAddAssociation(self.rdf_uri+ia.uml_name.to_s,ia.uml_type)
|
58
|
+
m,m1,m2=self.umlx_createAndAddAssociation(self.rdf_uri+ia.uml_name.to_s.str_to_uri,ia.uml_type)
|
44
59
|
m1.uml_aggregation=ms1.uml_aggregation
|
45
60
|
m2.uml_aggregation=ms2.uml_aggregation
|
46
61
|
m1.uml_name=ms1.uml_name
|
47
62
|
m2.uml_name=ms2.uml_name
|
48
63
|
|
64
|
+
m.umlx_copyStereotypesFrom!(ms)
|
65
|
+
m1.umlx_copyStereotypesFrom!(ms1)
|
66
|
+
m2.umlx_copyStereotypesFrom!(ms2)
|
67
|
+
|
49
68
|
ms1.umlx_copyToAttributeProperty(m1)
|
50
69
|
ms2.umlx_copyToAttributeProperty(m2)
|
51
70
|
|
@@ -60,6 +79,7 @@ module Muml_Class
|
|
60
79
|
gen.uml_general_one.umlx_ImplementedAttributesNames(ret)
|
61
80
|
}
|
62
81
|
uml_ownedAttribute.each { |oa|
|
82
|
+
next if oa.uml_isStatic? || (oa.respond_to?(:java_isFinal?) && oa.java_isFinal?)
|
63
83
|
ret << oa.uml_name.to_s
|
64
84
|
}
|
65
85
|
return ret
|
@@ -116,12 +136,14 @@ module Muml_Class
|
|
116
136
|
impOper=umlx_ImplementedOperations
|
117
137
|
umlx_operationIShouldImplement.each { |sig,ia|
|
118
138
|
next if impOper.keys.include?(ia.umlx_signature)
|
119
|
-
|
120
|
-
|
139
|
+
c=umlx_createAndAddOperation(ia.rdf_uri+"_implem",ia.uml_name.to_s);
|
140
|
+
ia.umlx_autoImplementedBy_add(c) # used by javadoc
|
141
|
+
c.umlx_copyStereotypesFrom!(ia)
|
121
142
|
(ia.uml_ownedParameter+ia.uml_returnResult).each { |p|
|
122
143
|
cp=c.umlx_createAndAddParameter(p.rdf_uri+"_implem",p.uml_name_one)
|
123
144
|
p.umlx_copyToAttributeProperty(cp)
|
124
145
|
cp.uml_direction=p.uml_direction
|
146
|
+
cp.umlx_copyStereotypesFrom!(p)
|
125
147
|
}
|
126
148
|
# the new method is considered business Method if the original method is one
|
127
149
|
#NOTE: umlx_businessMethod? changed to umlx_businessMethod
|
@@ -173,7 +195,7 @@ end
|
|
173
195
|
module Muml_Operation
|
174
196
|
#operation this operation redefines.
|
175
197
|
rdf_safe_attr_reader_many :umlx_redefinesMethod
|
176
|
-
|
198
|
+
rdf_safe_attr_reader_many :umlx_autoImplementedBy
|
177
199
|
def umlx_signature
|
178
200
|
#todo: take parameter into account
|
179
201
|
r="#{uml_name}("
|
@@ -81,6 +81,21 @@ module Muml_Enumeration
|
|
81
81
|
return g
|
82
82
|
end
|
83
83
|
end
|
84
|
+
module Muml_Classifier
|
85
|
+
#Creates and add a new UML Enumeration.
|
86
|
+
#Return the newly created element.
|
87
|
+
#new_uri should be globaly unique.
|
88
|
+
def umlx_createAndAddEnumeration(new_uri,new_name=nil)
|
89
|
+
c=Cuml_Enumeration.new(rdf_Repository,new_uri)
|
90
|
+
#uml_nestedClassifier_add(c)
|
91
|
+
#puts "--------> #{self} #{new_name}"
|
92
|
+
c.umlx_owner=self
|
93
|
+
c.uml_name=new_name unless new_name.nil?
|
94
|
+
c.uml_visibility=::Cuml_VisibilityKind::Public
|
95
|
+
#puts "création classe #{new_name} in #{self.java_qualifiedName}"
|
96
|
+
return c
|
97
|
+
end
|
98
|
+
end
|
84
99
|
module Muml_Package
|
85
100
|
#Creates and add a new UML Enumeration.
|
86
101
|
#Return the newly created element.
|
@@ -151,7 +151,7 @@ module Muml_Classifier
|
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
|
-
module Muml_PrimitiveType
|
154
|
+
module Muml_DataType # and Muml_PrimitiveType and Muml_Enumeration
|
155
155
|
#protege uri for a primitive type
|
156
156
|
def prot_uri
|
157
157
|
return "#{NS_RDF_2000}rdf-schema#Literal"
|
@@ -294,20 +294,20 @@ module Muml_Property
|
|
294
294
|
|
295
295
|
write("<#{o.prot_uri}> <#{NS_RDF_2000}rdf-schema#domain> <#{e.prot_uri}> .\n");
|
296
296
|
append_comment
|
297
|
-
o.
|
298
|
-
if
|
299
|
-
write("<#{o.prot_uri}> <#{NS_RDF_2000}rdf-schema#range> <#{t.prot_uri}> .\n")
|
300
|
-
write(%{<#{o.prot_uri}> <http://protege.stanford.edu/system#range> "#{t.prot_primitive_type}" .\n})
|
301
|
-
elsif t.kind_of?(Cuml_Enumeration)
|
297
|
+
t=o.uml_type_one
|
298
|
+
if t.kind_of?(Cuml_Enumeration)
|
302
299
|
write("<#{o.prot_uri}> <#{NS_RDF_2000}rdf-schema#range> <#{NS_RDF_2000}rdf-schema#Literal> .\n")
|
303
300
|
write(%{<#{o.prot_uri}> <http://protege.stanford.edu/system#range> "symbol" .\n})
|
304
301
|
t.uml_ownedLiteral.each {|c|
|
305
302
|
write(%{<#{o.prot_uri}> <http://protege.stanford.edu/system#allowedValues> "#{c}" .\n})
|
306
303
|
}
|
304
|
+
elsif (t.kind_of?(Muml_PrimitiveType)||t.kind_of?(Muml_DataType))
|
305
|
+
write("<#{o.prot_uri}> <#{NS_RDF_2000}rdf-schema#range> <#{t.prot_uri}> .\n")
|
306
|
+
write(%{<#{o.prot_uri}> <http://protege.stanford.edu/system#range> "#{t.prot_primitive_type}" .\n})
|
307
307
|
else
|
308
308
|
write("<#{o.prot_uri}> <#{NS_RDF_2000}rdf-schema#range> <#{t.prot_uri}> .\n")
|
309
309
|
end
|
310
|
-
|
310
|
+
|
311
311
|
write("<#{o.prot_uri}> <#{NS_RDF_1999}22-rdf-syntax-ns#type> <http://protege.stanford.edu/kb#UML_SLOT> .\n")
|
312
312
|
write("<#{o.prot_uri}> <http://protege.stanford.edu/kb#UML_LABEL> \"#{o.prot_label}\".\n")
|
313
313
|
write("<#{o.prot_uri}> <#{NS_UML_CLASS}#UML_URI> \"#{UriNamespace.instance.unalias(o.rdf_uri)}\" .\n")
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Muml_Element
|
2
|
+
def umlx_addDependencies(s=Set.new)
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
module Mrdf_Repository
|
7
|
+
def umlx_removeNoCode!
|
8
|
+
s=Set.new
|
9
|
+
each { |k,v|
|
10
|
+
next unless v.kind_of?(Muml_Element)
|
11
|
+
next unless v.umlx_hasStereotype?('nocode')
|
12
|
+
v.umlx_addDependencies(s)
|
13
|
+
}
|
14
|
+
s.each { |v|
|
15
|
+
puts "cleaning nocode --> #{v.class} #{v}"
|
16
|
+
puts "TODO: cleaning code not finalized"
|
17
|
+
self.delete(v.rdf_uri)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
module Muml_Package
|
22
|
+
def umlx_addDependencies(s=Set.new)
|
23
|
+
return if s.include?(self)
|
24
|
+
s.add(self)
|
25
|
+
uml_ownedMember.each { |v|
|
26
|
+
v.umlx_addDependencies(s)
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
module Muml_Operation
|
31
|
+
def umlx_addDependencies(s=Set.new)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
module Muml_Class
|
35
|
+
def umlx_addDependencies(s=Set.new)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
module Muml_Interface
|
39
|
+
def umlx_addDependencies(s=Set.new)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
module Muml_Association
|
43
|
+
def umlx_addDependencies(s=Set.new)
|
44
|
+
end
|
45
|
+
end
|
data/lib/ontomde-uml2/owner.rb
CHANGED
@@ -25,8 +25,18 @@ module Muml_Classifier
|
|
25
25
|
end
|
26
26
|
def umlx_owner=(p)
|
27
27
|
old=umlx_owner_one
|
28
|
-
|
29
|
-
|
28
|
+
if old.nil?
|
29
|
+
#
|
30
|
+
elsif old.kind_of?(Muml_Package)
|
31
|
+
old.uml_ownedMember.delete(self)
|
32
|
+
else
|
33
|
+
old.uml_nestedClassifier.delete(self)
|
34
|
+
end
|
35
|
+
if p.kind_of?(Muml_Package)
|
36
|
+
p.uml_ownedMember_add(self)
|
37
|
+
else
|
38
|
+
p.uml_nestedClassifier_add(self)
|
39
|
+
end
|
30
40
|
ext_isReferencedBy_add(p)
|
31
41
|
end
|
32
42
|
end
|
data/lib/ontomde-uml2/uml2.rb
CHANGED
@@ -23,6 +23,35 @@ module Muml_Classifier
|
|
23
23
|
}
|
24
24
|
return s
|
25
25
|
end
|
26
|
+
|
27
|
+
# operation I own directly or indirectly via inheritance
|
28
|
+
def umlx_ownedOperationHierarchical()
|
29
|
+
ret=Set.new
|
30
|
+
umlx_classifier_generalization_indirect.each { |i|
|
31
|
+
i.uml_ownedOperation.each { |oo|
|
32
|
+
ret.add(oo)
|
33
|
+
}
|
34
|
+
}
|
35
|
+
self.uml_ownedOperation.each { |oo|
|
36
|
+
ret.add(oo)
|
37
|
+
}
|
38
|
+
return ret
|
39
|
+
end
|
40
|
+
|
41
|
+
# attribute I own directly or indirectly via inheritance
|
42
|
+
def umlx_ownedAttributeHierarchical()
|
43
|
+
ret=Set.new
|
44
|
+
umlx_classifier_generalization_indirect.each { |i|
|
45
|
+
i.uml_ownedAttribute.each { |oo|
|
46
|
+
ret.add(oo)
|
47
|
+
}
|
48
|
+
}
|
49
|
+
self.uml_ownedAttribute.each { |oo|
|
50
|
+
ret.add(oo)
|
51
|
+
}
|
52
|
+
return ret
|
53
|
+
end
|
54
|
+
|
26
55
|
end
|
27
56
|
|
28
57
|
module Muml_Namespace
|
@@ -32,6 +61,7 @@ module Muml_Namespace
|
|
32
61
|
def umlx_package
|
33
62
|
#TODO: utiliser relation inverse when available
|
34
63
|
p=umlx_owner_one
|
64
|
+
p=uml_nestedClassifier_inv_one0 if p.nil? && !self.kind_of?(Muml_Package)
|
35
65
|
return nil if p.kind_of?(Cuml_Model)
|
36
66
|
return p
|
37
67
|
end
|
@@ -62,6 +92,15 @@ module Muml_Namespace
|
|
62
92
|
def umlx_isARootNamespace?
|
63
93
|
return self.kind_of?(Muml_Model) || self.umlx_hasStereotype?("root")
|
64
94
|
end
|
95
|
+
|
96
|
+
# return root namespace for this element
|
97
|
+
def umlx_rootNamespace_one0
|
98
|
+
return self if umlx_isARootNamespace?
|
99
|
+
root=umlx_package
|
100
|
+
return nil if root.nil?
|
101
|
+
return root.umlx_rootNamespace_one0
|
102
|
+
end
|
103
|
+
|
65
104
|
# Returns the chain of namespace owning this element including this element
|
66
105
|
def umlx_hierarchy
|
67
106
|
isarn=self.umlx_isARootNamespace?
|
data/lib/ontomde-uml2/umlx.rb
CHANGED
@@ -426,6 +426,22 @@ module Muml_Namespace
|
|
426
426
|
ret
|
427
427
|
}
|
428
428
|
end
|
429
|
+
|
430
|
+
# Retrieves an interface from its qualified name.
|
431
|
+
# Class will be created if not present in model.
|
432
|
+
# Example:
|
433
|
+
# umlx_getOrCreateGeneric("java.util.Set")
|
434
|
+
def umlx_getOrCreateGeneric(qual_name,genericParams,startpoint=nil)
|
435
|
+
qual_name=%{#{qual_name}<#{genericParams}>}
|
436
|
+
return umlx_getOrCreateProc(qual_name,startpoint) { |owner,qual_name,c_name|
|
437
|
+
#TODO: duplication probable si plusieurs fois meme generic
|
438
|
+
ret=owner.umlx_createAndAddInterface(qual_name,c_name)
|
439
|
+
#ret.uml_name="#{qual_name}<#{genericParams}>"
|
440
|
+
ret.umlx_external=RDF_TRUE
|
441
|
+
ret.java_isGeneric=RDF_TRUE
|
442
|
+
ret
|
443
|
+
}
|
444
|
+
end
|
429
445
|
|
430
446
|
# Retrieves an enumeration from its qualified name.
|
431
447
|
# Class will be created if not present in model.
|
@@ -595,15 +611,24 @@ end
|
|
595
611
|
module Muml_Classifier
|
596
612
|
#returns every type assignable to this classifier
|
597
613
|
#(this includes self and any class deriving from it)
|
614
|
+
#Template parameter are filtered out
|
598
615
|
def umlx_assignableClassifier(ret=Set.new)
|
599
616
|
return ret if ret.include?(self)
|
600
617
|
ret<< self
|
601
618
|
uml_general_inv.each { |g|
|
602
619
|
g.uml_generalization_inv.each {|c|
|
620
|
+
next if c.umlx_isTemplateParameter?
|
603
621
|
c.umlx_assignableClassifier(ret)
|
604
622
|
}}
|
605
623
|
return ret
|
606
624
|
end
|
625
|
+
|
626
|
+
# heuristique.
|
627
|
+
# If element has no owner, it is a root class
|
628
|
+
# class in root package is not supported anyway.
|
629
|
+
def umlx_isTemplateParameter?
|
630
|
+
return umlx_owner_one.nil?
|
631
|
+
end
|
607
632
|
end
|
608
633
|
module Muml_Interface
|
609
634
|
#returns every type assignable to this classifier
|
data/lib/ontomde-uml2/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ontomde-uml2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orange-labs BIZZ/CIL/SAM
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-04-08 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.0.
|
23
|
+
version: 2.0.4
|
24
24
|
version:
|
25
25
|
description: "ontoMDE-uml2 contains UML2 meta-model and helper files to manipulate a UML2 model. ontoMDE-uml2 uses ontoMDE-core which provides core fonctionalities for loading a model in RDF/RDFS format. ontoMDE-UML2 is used by ontoMDE-java which contains rules for generating java Code. ontoMDE contains primitives for converting a UML2 model into a Prot\xE9g\xE9 2000 RDF/RDFS model. UML2 classes are converted into RDFS classes to allow data instances to be created. This feature is used heavily for providing editors for creating tests data for programs. == FEATURES/PROBLEMS: * UML2 meta-model definition in RDFS format * Ruby helper methods for handling a UML2 model. * UML Stereotype handling helpers. * UML predefined enumerations handling helper. * UML model manipulations helpers (add interface implementations, transform multiple inheritance into single inheritance, ...) UML2 to Protege 2000 features: * single and incremental use. * transparent update of name changes from source to target mode. * class * abstract class * interface * enumerated types * generalization links * implementation links * property, association, composition and aggregation * single and multivalued properties * mandatory fields (cardinaly=0 or >0) * UML documentation notes export to Protege 2000 for easy reference."
|
26
26
|
email: stephanepierre.carrie -nospam- @orange-ftgroup.com
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/ontomde-uml2/kb/datatypeMapping.rb
|
60
60
|
- lib/ontomde-uml2/kb/protege.rb
|
61
61
|
- lib/ontomde-uml2/multipleInheritance.rb
|
62
|
+
- lib/ontomde-uml2/nocode.rb
|
62
63
|
- lib/ontomde-uml2/nt_old_to_nt_new.sh
|
63
64
|
- lib/ontomde-uml2/owner.rb
|
64
65
|
- lib/ontomde-uml2/salvageErrors.rb
|