ontomde-uml2 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,12 +41,13 @@ module Muml_Class
41
41
  #log.debug { "umlx_autoImplementProperty #{ia} for #{self} #{ia.umlx_isAssociation?}" }
42
42
  next if impAttNames.include?(ia.uml_name.to_s)
43
43
  if(ia.umlx_isAttribute?)
44
- att=self.umlx_createAndAddProperty(self.rdf_uri+ia.uml_name.to_s.str_to_uri)
44
+ att=self.umlx_createAndAddProperty(self.rdf_uri+ia.rdf_uri.to_s.str_to_uri)
45
45
  att.uml_name=ia.uml_name
46
46
  att.uml_type=ia.uml_type
47
47
  att.umlx_copyStereotypesFrom!(ia)
48
48
  att.uml_upperValue=ia.uml_upperValue unless ia.uml_upperValue.empty?
49
49
  att.uml_lowerValue=ia.uml_lowerValue unless ia.uml_lowerValue.empty?
50
+ att.uml_ownedComment=ia.uml_ownedComment unless ia.uml_ownedComment.empty?
50
51
  else
51
52
  #puts "create and add ..."
52
53
  ms=ia.uml_association_one
@@ -55,7 +56,7 @@ module Muml_Class
55
56
  #puts "ms=#{ms}"
56
57
  #puts "ms1=#{ms1} #{ms1.uml_type}"
57
58
  #puts "ms2=#{ms2} #{ms2.uml_type}"
58
- m,m1,m2=self.umlx_createAndAddAssociation(self.rdf_uri+ia.uml_name.to_s.str_to_uri,ia.uml_type)
59
+ m,m1,m2=self.umlx_createAndAddAssociation(self.rdf_uri+ia.rdf_uri.to_s.str_to_uri,ia.uml_type)
59
60
  m1.uml_aggregation=ms1.uml_aggregation
60
61
  m2.uml_aggregation=ms2.uml_aggregation
61
62
  m1.uml_name=ms1.uml_name
@@ -68,6 +69,9 @@ module Muml_Class
68
69
  ms1.umlx_copyToAttributeProperty(m1)
69
70
  ms2.umlx_copyToAttributeProperty(m2)
70
71
 
72
+ m1.uml_ownedComment=ms1.uml_ownedComment unless ms1.uml_ownedComment.empty?
73
+ m2.uml_ownedComment=ms2.uml_ownedComment unless ms2.uml_ownedComment.empty?
74
+
71
75
  #puts "m=#{m}"
72
76
  #puts "m1=#{m1} #{m1.uml_type}"
73
77
  #puts "m2=#{m2} #{m2.uml_type}"
@@ -137,6 +141,7 @@ module Muml_Class
137
141
  umlx_operationIShouldImplement.each { |sig,ia|
138
142
  next if impOper.keys.include?(ia.umlx_signature)
139
143
  c=umlx_createAndAddOperation(ia.rdf_uri+"_implem",ia.uml_name.to_s);
144
+ c.uml_ownedComment=ia.uml_ownedComment unless ia.uml_ownedComment.empty?
140
145
  ia.umlx_autoImplementedBy_add(c) # used by javadoc
141
146
  c.umlx_copyStereotypesFrom!(ia)
142
147
  (ia.uml_ownedParameter+ia.uml_returnResult).each { |p|
@@ -95,8 +95,43 @@ module Muml_Element
95
95
  end
96
96
  end
97
97
 
98
+ module Mrdf_Resource
99
+ def prot_ignorePackage?
100
+ return (!kind_of?(Muml_Package)) || rdf_uri=="http://xmda-reserved"
101
+ end
102
+ end
103
+
104
+ module Muml_Package
105
+ def prot_writePackage
106
+ e=self
107
+ write("<#{e.prot_uri}> <#{RDF_TYPE_URI}> <#{RDF_METACLASS_URI}> .\n")
108
+ write("<#{e.prot_uri}> <#{NS_RDF_2000}rdf-schema#label> \"[#{e.uml_name.to_s.nt_escape}]\" .\n")
109
+ write("<#{e.prot_uri}> <http://protege.stanford.edu/system#role> \"abstract\" .\n")
110
+ e.append_comment
111
+ e.prot_writeSubClassOf
98
112
 
99
- module Muml_Classifier
113
+ write("<#{e.prot_uri}> <#{NS_UML_CLASS}#UML_LABEL> \"[#{prot_label}]\" .\n")
114
+ write("<#{e.prot_uri}> <#{NS_UML_CLASS}#UML_URI> \"#{UriNamespace.instance.unalias(e.rdf_uri)}\" .\n")
115
+
116
+ end
117
+ def mainSubClassOfURI
118
+ return "#{NS_UML_CLASS}#UML_PACKAGE"
119
+ end
120
+
121
+
122
+ #writes sub class of rdf instructions
123
+ def prot_writeSubClassOf
124
+ t=umlx_owner_one
125
+ if t.nil? || t.prot_ignorePackage?
126
+ write("<#{prot_uri}> <#{RDF_SUBCLASSOF_URI}> <#{mainSubClassOfURI}> .\n")
127
+ else
128
+ write("<#{prot_uri}> <#{RDF_SUBCLASSOF_URI}> <#{t.prot_uri}> .\n")
129
+ end
130
+ end
131
+ end
132
+
133
+
134
+ module Muml_Namespace
100
135
  ProtegeURI=Hash.new
101
136
 
102
137
  #label used in protege 2000
@@ -144,8 +179,16 @@ module Muml_Classifier
144
179
  e.append_comment
145
180
  e.prot_writeSubClassOf
146
181
 
182
+ prefix= ''
183
+ prefix='UC: ' if e.kind_of?(Muml_UseCase)
184
+ prefix='I: ' if e.kind_of?(Muml_Interface)
185
+
186
+ # Place element in its package hierarchy
187
+ o=umlx_owner_one
188
+ write("<#{prot_uri}> <#{RDF_SUBCLASSOF_URI}> <#{o.prot_uri}> .\n") unless o.nil? || o.prot_ignorePackage?
189
+
147
190
  write("<#{e.prot_uri}> <#{RDF_SUBCLASSOF_URI}> <#{mainSubClassOfURI}> .\n")
148
- write("<#{e.prot_uri}> <#{NS_UML_CLASS}#UML_LABEL> \"#{prot_label}\" .\n")
191
+ write("<#{e.prot_uri}> <#{NS_UML_CLASS}#UML_LABEL> \"#{prefix}#{prot_label}\" .\n")
149
192
  write("<#{e.prot_uri}> <#{NS_UML_CLASS}#UML_URI> \"#{UriNamespace.instance.unalias(e.rdf_uri)}\" .\n")
150
193
 
151
194
  end
@@ -426,6 +469,14 @@ module Mrdf_Repository
426
469
  }
427
470
  end
428
471
 
472
+ # add package and its parent hierarchy
473
+ def addPackageHierarchy(usedPackage,package)
474
+ return unless package.kind_of?(Muml_Package)
475
+ return if usedPackage.include?(package)
476
+ return if package.prot_ignorePackage?
477
+ usedPackage.add(package)
478
+ addPackageHierarchy(usedPackage,package.umlx_owner_one)
479
+ end
429
480
 
430
481
  #generates Protege 2000 RDFS file of a knowledge base project.
431
482
  def generateProtegeKbRDFS(targetFile)
@@ -435,12 +486,15 @@ module Mrdf_Repository
435
486
  #mark temporary file for deletion
436
487
  mtk_addTempFileToDelete(targetFileRDFS)
437
488
 
489
+ usedPackage=Set.new
490
+
438
491
  mtk_writeSession(targetFileRDFS) {
439
492
  write(kbRDFS_header)
440
493
  uml_Model_all.each { |m|
441
494
  m.uml_Class_all.each {|c|
442
495
  next if c.kind_of?(Muml_Enumeration)
443
496
  c.prot_writeNTriple
497
+ addPackageHierarchy(usedPackage,c.umlx_owner_one)
444
498
  c.uml_ownedAttribute.each {|a|
445
499
  a.prot_writeNTriple
446
500
  }
@@ -451,9 +505,15 @@ module Mrdf_Repository
451
505
  }
452
506
  }
453
507
  }
508
+
454
509
  m.uml_UseCase_all.each {|uc|
510
+ addPackageHierarchy(usedPackage,uc.umlx_owner_one)
455
511
  uc.prot_writeNTriple
456
512
  }
513
+
514
+ usedPackage.each { |p|
515
+ p.prot_writePackage
516
+ }
457
517
  }
458
518
  kbRDFS_writeComponents
459
519
  write(kbRDFS_footer)
@@ -495,7 +555,7 @@ module Mrdf_Repository
495
555
  # Protege 2000 RDFS knowledge base file header
496
556
  def kbRDFS_header
497
557
  nt_top='# debut\n'
498
- ['UML_CLASS','UML_TEST_DATA_SET'].each {|c|
558
+ ['UML_CLASS','UML_TEST_DATA_SET','UML_PACKAGE'].each {|c|
499
559
  nt_top=nt_top+<<END2
500
560
  <#{NS_UML_CLASS}##{c}> <http://protege.stanford.edu/system#role> "abstract" .
501
561
  <#{NS_UML_CLASS}##{c}> <#{NS_RDF_2000}rdf-schema#label> "" .
@@ -632,12 +692,12 @@ END
632
692
  <#{NS_UML_CLASS}##{k}> <#{NS_RDF_1999}22-rdf-syntax-ns#type> <#{NS_RDF_1999}22-rdf-syntax-ns#Property> .
633
693
  <#{NS_UML_CLASS}##{k}> <#{NS_RDF_2000}rdf-schema#label> "#{k}" .
634
694
  <#{NS_UML_CLASS}##{k}> <#{NS_RDF_2000}rdf-schema#range> <#{NS_UML_CLASS}#UML_TEST_DATA_SET> .
635
- <#{NS_UML_CLASS}##{k}> <#{NS_RDF_2000}rdf-schema#domain> <#{NS_UML_CLASS}#UML_CLASS> .
695
+ <#{NS_UML_CLASS}##{k}> <#{NS_RDF_2000}rdf-schema#domain> <#{NS_UML_CLASS}#UML_PACKAGE> .
636
696
  <#{NS_UML_CLASS}##{k}> <http://protege.stanford.edu/system#inverseProperty> <#{NS_UML_CLASS}##{inv}> .
637
697
  <#{NS_UML_CLASS}##{inv}> <#{NS_RDF_1999}22-rdf-syntax-ns#type> <#{NS_RDF_1999}22-rdf-syntax-ns#Property> .
638
698
  <#{NS_UML_CLASS}##{inv}> <#{NS_RDF_2000}rdf-schema#label> "{k}" .
639
699
  <#{NS_UML_CLASS}##{inv}> <http://protege.stanford.edu/system#inverseProperty> <#{NS_UML_CLASS}##{k}> .
640
- <#{NS_UML_CLASS}##{inv}> <#{NS_RDF_2000}rdf-schema#range> <#{NS_UML_CLASS}#UML_CLASS> .
700
+ <#{NS_UML_CLASS}##{inv}> <#{NS_RDF_2000}rdf-schema#range> <#{NS_UML_CLASS}#UML_PACKAGE> .
641
701
  <#{NS_UML_CLASS}##{inv}> <#{NS_RDF_2000}rdf-schema#domain> <#{NS_UML_CLASS}#UML_TEST_DATA_SET> .
642
702
  END
643
703
  }
@@ -214,11 +214,14 @@ module Muml_Element
214
214
  #returns true if element has an applied stereotype named stereotype_name
215
215
  #test is not case sensitive
216
216
  def umlx_hasStereotype?(stereotype_name)
217
+ return !(umlx_returnStereotypeIfHas(stereotype_name).nil?)
218
+ end
219
+ def umlx_returnStereotypeIfHas(stereotype_name)
217
220
  uml_appliedStereotype.each { |s|
218
221
  next unless s.uml_name.to_s.casecmp(stereotype_name.to_s)==0
219
- return true
222
+ return s
220
223
  }
221
- return false
224
+ return nil
222
225
  end
223
226
  end
224
227
 
@@ -1,5 +1,5 @@
1
1
  module Ontomde
2
2
  module Uml2
3
- VERSION = '2.0.4'
3
+ VERSION = '2.0.5'
4
4
  end
5
5
  end
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
4
+ version: 2.0.5
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: 2009-04-08 00:00:00 +02:00
12
+ date: 2009-04-23 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.4
23
+ version: 2.0.5
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