ontomde-core 1.0.2 → 1.0.4

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.
data/History.txt CHANGED
@@ -1,5 +1,10 @@
1
- == 1.0.0 / 2007-10-27
2
-
3
- * 1 major enhancement
4
- * Birthday!
5
-
1
+
2
+ == / 2007-12-27
3
+ * added rdfs range handling.
4
+ * rdf attribute type is now check on assignement.
5
+
6
+ == 1.0.0 / 2007-10-27
7
+
8
+ * 1 major enhancement
9
+ * First public release
10
+
data/Manifest.txt CHANGED
@@ -1,12 +1,11 @@
1
1
  History.txt
2
2
  Manifest.txt
3
3
  README.txt
4
+ Manual.txt
4
5
  Rakefile
5
- bin/ontomde-core
6
6
  lib/ontomde-core.rb
7
7
  lib/ontomde-core/version.rb
8
8
  lib/ontomde-core/context.rb
9
- lib/ontomde-core/loader.rb
10
9
  lib/ontomde-core/bootstrap_rdfs.rb
11
10
  lib/ontomde-core/delayed.rb
12
11
  lib/ontomde-core/profil.rb
data/Manual.txt ADDED
@@ -0,0 +1,88 @@
1
+ == ontoMDE-core stand-alone usage
2
+
3
+ basic usage of ontoMDE implies the following steps:
4
+ * create or use an existing ontology (a RDF model)
5
+ * create methods an ruby classes to do whatever you want (generate Java/C++ code, transform your model, whatever).
6
+ * load the ontology model into Ruby
7
+ * load an ontology instance (data) into ruby
8
+
9
+
10
+ == RDFS class loading
11
+ When invoking loadMetaModelFromFile, ontoMDE does the following things:
12
+ * Create a class for every RDFS class prefixed by C
13
+ (ex: RDFS class with uri uml:DataType produces a ruby class Cuml_DataType)
14
+ * Create a module for every RDFS class prefixed by M
15
+ (ex: RDFS class with uri uml:DataType produces a ruby module Muml_DataType)
16
+ * Map RDFS generalization into module imports
17
+ (ex: ruby class Cuml_DataType includes module Muml_DataType and Muml_NamedElement because RDFS class with uri uml:DataType inherits from uml:NamedElement)
18
+ * Creates Ruby property in module class for every RDF property
19
+ (ex: Muml_NamedElement has a uml_name property)
20
+
21
+ Note:examples are taken from UML MetaModel included in ontomde-uml library
22
+
23
+ == Property accessors
24
+ ontoMDE offers several accessor methods for accessing a property. Accessors name derive from property name. If a property name is for example, uml_name, accessors will be uml_name, uml_name_one, uml_name_one0, ...
25
+
26
+ === <prop>
27
+ returns a list of elements.
28
+ example: uml_name, uml_ownedElement
29
+
30
+ === <prop>_one
31
+ returns <prop> first element.
32
+ Fails if <prop> list does not contain exactly one element.
33
+ example: uml_name_one
34
+
35
+ === <prop>_one0
36
+ returns <prop> first element or nil if <prop> list is empty
37
+ Fails if uml_name list contains more than one element.
38
+ example: uml_name_one0
39
+
40
+ === <prop>?
41
+ returns true or false
42
+ Because RDF stores string literal "true" or "false" this method must be used instead of <prop>_one if a boolean value is expected.
43
+ example: uml_isOrdered? , uml_isAbstract?
44
+
45
+ === <prop>_inv
46
+ returns elements
47
+ important note: <prop>_inv is *not* ordered.
48
+ example: uml_ownedElement_inv?
49
+
50
+ === <prop>_inv_one
51
+ returns first and only element in <prop>_inv.
52
+ Throws an exception if <prop>_inv does not contain exactly one element.
53
+ example:
54
+
55
+ === <prop>_inv_one0
56
+ returns first and only element in <prop>_inv, null if empty.
57
+ Throws an exception if <prop>_inv contains more than one element.
58
+ example:
59
+
60
+
61
+ ==Code generator facilities
62
+
63
+ ontoMDE-core provides facilities for writing into a file without carrying around file descriptors. A write method is defined on every ontoMDE-core model object that can be used anywhere in code, as long as it is called from inside a writeSession.
64
+
65
+ mtk_writeSession("yourFileName.java") {
66
+ write("Package\n)
67
+ (...)
68
+ }
69
+
70
+ File generated by ontoMDE-core are in fact separated into blocks. Certain blocks can be preserved on subsequent generation. This is usefull if a file is meant to be customized, by for example, providing an implementation for a java method.
71
+
72
+ Generated code will be in a protected block if it is inside a mtk_protected clause.
73
+
74
+ mtk_writeSession("yourFileName.java") {
75
+ write("Package\n)
76
+ (...)
77
+ mtk_protected {
78
+ write ("this is inside protected zone")
79
+ }
80
+ write ("this is *not* inside protected zone")
81
+ }
82
+
83
+
84
+
85
+
86
+
87
+ ==Context handling facilities
88
+
data/README.txt CHANGED
@@ -1,48 +1,79 @@
1
- ontomde-core
2
- by FIX (your name)
3
- FIX (url)
4
-
5
- == DESCRIPTION:
6
-
7
- FIX (describe your package)
8
-
9
- == FEATURES/PROBLEMS:
10
-
11
- * FIX (list of features or problems)
12
-
13
- == SYNOPSIS:
14
-
15
- FIX (code sample of usage)
16
-
17
- == REQUIREMENTS:
18
-
19
- * FIX (list of requirements)
20
-
21
- == INSTALL:
22
-
23
- * FIX (sudo gem install, anything else)
24
-
25
- == LICENSE:
26
-
27
- (The MIT License)
28
-
29
- Copyright (c) 2007 FIX
30
-
31
- Permission is hereby granted, free of charge, to any person obtaining
32
- a copy of this software and associated documentation files (the
33
- 'Software'), to deal in the Software without restriction, including
34
- without limitation the rights to use, copy, modify, merge, publish,
35
- distribute, sublicense, and/or sell copies of the Software, and to
36
- permit persons to whom the Software is furnished to do so, subject to
37
- the following conditions:
38
-
39
- The above copyright notice and this permission notice shall be
40
- included in all copies or substantial portions of the Software.
41
-
42
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ ontomde-core
2
+ by Stephane (Pierre) Carrie 2005-2007
3
+ http://ontomde.rubyforge.org
4
+
5
+ == DESCRIPTION:
6
+
7
+ ontoMDE-core is basically a library for loading a RDFS model in ruby memory and process it to do something usefull such as generating Java or C++ code.
8
+
9
+ ontoMDE-core is used by ontoMDE-uml2 which adds UML2 meta-model definitions and some helper methods. ontoMDE-uml2 is in turn used by ontoMDE-uml2-java which adds methods and rules to generate java5 code.
10
+
11
+ But ontoMDE-core is *not* *UML* *specific* and can be used with *any* RDF[http://en.wikipedia.org/wiki/Resource_Description_Framework] / RDFS[http://en.wikipedia.org/wiki/RDF_Schema] model such as those created with Protege_2000[http://protege.stanford.edu]. This opens to ontoMDE-core users the ability to generate code from custom DSL[http://en.wikipedia.org/wiki/Domain_Specific_Language] models, or join different models.
12
+
13
+ == FEATURES/PROBLEMS:
14
+ RDF handling library
15
+ * RDF/ntriples native ruby file reader
16
+ * RDFS to Ruby class file converter
17
+ * RDF data reader
18
+ Code generator helper library
19
+ * file write library helper with protected zone handling
20
+ * tag based code reverse library
21
+
22
+ == SYNOPSIS:
23
+
24
+ (example extracted from test/model)
25
+
26
+ require 'ontomde-core'
27
+
28
+ # create a new model instance
29
+ model=Crdf_Model.new
30
+
31
+ # loads metamodel and creates Ruby classes
32
+ model.loadMetaModelFromFile("etatCivil.rdfs",true)
33
+
34
+ # load data from file and creates Ruby objects
35
+ model.loadModelFromFile("etatCivil.rdf",true)
36
+
37
+ # very basic browsing of loaded data
38
+ model.each { |k,c|
39
+ puts "#{c} #{k} #{c.rdf_uri"
40
+ }
41
+ == Manual
42
+ Please refer to MANUAL.txt for additional information on ontoMDE-core.
43
+
44
+ == REQUIREMENTS:
45
+
46
+ * UNIX users should install redland[http://librdf.org/] if they wish to process RDF files not in N-TRIPLES format such as Protege 2000 XML/RDF files.
47
+
48
+ == INSTALL:
49
+
50
+ * (UNIX) sudo gem install ontomde-core
51
+ * (WIN ) gem install ontomde-core
52
+
53
+ Additional information is available on ontoMDE web site :
54
+ http://ontomde.rubyforge.org/website/download.html
55
+ == LICENSE:
56
+
57
+ Copyright (C) 2008 Orange-labs
58
+ 38 rue General Leclerc
59
+ 92130 ISSY LES MOULINEAUX, France
60
+
61
+ This program is free software: you can redistribute it and/or modify
62
+ it under the terms of the GNU Affero General Public License as
63
+ published by the Free Software Foundation, either version 3 of the
64
+ License, or (at your option) any later version.
65
+
66
+ This program is distributed in the hope that it will be useful,
67
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
68
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69
+ GNU Affero General Public License for more details.
70
+
71
+ You should have received a copy of the GNU Affero General Public License
72
+ along with this program. If not, see http://www.gnu.org/licenses/.
73
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
74
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
75
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
76
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
77
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
78
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
79
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -8,12 +8,13 @@ Hoe.new('ontomde-core', Ontomde::Core::VERSION) do |p|
8
8
  p.rubyforge_name = 'ontomde'
9
9
  p.author = 'Stephane (Pierre) Carrie'
10
10
  p.email = 'stephanepierre.carrie@orange-ftgroup.com'
11
- p.summary = 'OntoMDE core cartridge (RDF/RDFS handling,helpers)'
12
- # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
- # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
11
+ p.summary = 'OntoMDE core cartridge (RDF/RDFS handling,code generation helpers)'
12
+ p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
+ p.url="http://ontomde.rubyforge.org"
14
14
  p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
15
  p.spec_extras[:required_ruby_version] = '>= 1.8.4'
16
16
  p.extra_deps=[ ['ontomde-redland-win','= 1.0.3'] ]
17
+ p.spec_extras={ :required_ruby_version => '>=1.8.6',:required_rubygems_version => '>=1.0.0' }
17
18
  end
18
19
 
19
20
  # vim: syntax=Ruby
@@ -1,37 +1,36 @@
1
- # Bootstrap of rdfs metamodel
2
- #:include: ../shared/license.rdoc
3
-
4
- module Mrdfs_Resource
5
- end
6
-
7
- module Mrdfs_Class
8
- end
9
-
10
- class Crdfs_Class < Crdf_Resource
11
- include Mrdfs_Class
12
- attr_reader :ClassGenerated
13
- attr_writer :ClassGenerated
14
- def initialize(model,uri)
15
- super(model,uri)
16
- @mtk_rubyClassGenerated=false
17
- end
18
- end
19
- module Mrdf_Property
20
- end
21
-
22
- class Crdf_Property < Crdf_Resource
23
- include Mrdf_Property
24
- attr_reader :rdfs_domain, :rdfs_range
25
- attr_reader :sys_inverseProperty
26
- @rdfs_domain=ArrayOrSingleElement.new()
27
- #attr_writer :rdfs_domain, :rdfs_range
28
- end
29
-
30
- module Mrdfs_Literal
31
- end
32
-
33
- class Crdfs_Literal < Crdf_Resource
34
- include Mrdfs_Literal
35
- attr_reader :rdfs_domain, :rdfs_range
36
- #attr_writer :rdfs_domain, :rdfs_range
37
- end
1
+ # Bootstrap of rdfs metamodel
2
+
3
+ module Mrdfs_Resource
4
+ end
5
+
6
+ module Mrdfs_Class
7
+ end
8
+
9
+ class Crdfs_Class < Crdf_Resource
10
+ include Mrdfs_Class
11
+ attr_reader :ClassGenerated
12
+ attr_writer :ClassGenerated
13
+ def initialize(model,uri)
14
+ super(model,uri)
15
+ @mtk_rubyClassGenerated=false
16
+ end
17
+ end
18
+ module Mrdf_Property
19
+ end
20
+
21
+ class Crdf_Property < Crdf_Resource
22
+ include Mrdf_Property
23
+ attr_reader :rdfs_domain, :rdfs_range
24
+ attr_reader :sys_inverseProperty
25
+ @rdfs_domain=ArrayOrSingleElement.new()
26
+ #attr_writer :rdfs_domain, :rdfs_range
27
+ end
28
+
29
+ module Mrdfs_Literal
30
+ end
31
+
32
+ class Crdfs_Literal < Crdf_Resource
33
+ include Mrdfs_Literal
34
+ attr_reader :rdfs_domain, :rdfs_range
35
+ #attr_writer :rdfs_domain, :rdfs_range
36
+ end
@@ -1,73 +1,72 @@
1
- #Model transformation methods
2
- #:include: ../shared/license.rdoc
3
-
4
- class String
5
- # Clones a string
6
- # return self by default.(String are not cloned)
7
- def rdfx_clone
8
- return self
9
- end
10
- end
11
-
12
- module Mrdf_Resource
13
- # Clones a uml resource.
14
- # Referenced objects are cloned if rdfx_copyOnClone says so.
15
- def rdfx_clone
16
- c=self.clone
17
- c.rdf_uri="_transient_#{c.object_id}"
18
- c.rdf_model[c.rdf_uri]=c
19
-
20
- instance_variables.each { |v|
21
- ivg=instance_variable_get(v)
22
- next if (!ivg.kind_of?(ArrayOrSingleElement)) ||
23
- (!isResetable?(v)) ||
24
- (!rdfx_copyOnClone?(v))
25
-
26
- newVal=createEmptyAttributeValue
27
- #puts "clone v=#{v}"
28
- self.instance_variable_get(v).each { | res|
29
- newVal.push(res.rdfx_clone)
30
- c.instance_variable_set(v,newVal)
31
- }
32
- }
33
- return c
34
- end
35
-
36
- # Returns true if object should be copied on clone for this property.
37
- # NOTE:
38
- # returns true if property name contains "_owned". (works for UML)
39
- def rdfx_copyOnClone?(prop)
40
- return prop.include?('_owned')
41
- #copyOrClone=copyOnCloneProperties[prop]
42
- #if copyOrClone.nil?
43
- #puts "WARNING: unspecified copy on clone for #{prop} on #{self.class.name}"
44
- #end
45
- #return copyOrClone
46
- end
47
- end
48
- #module Mrdf_Resource
49
- # #CopyOnCloneProperties={ }
50
- # def copyOnCloneProperties
51
- # #CopyOnCloneProperties
52
- # end
53
- #end
54
- #module Muml_Class
55
- # CopyOnCloneProperties={ '@uml_packageableElement_packageableElement_visibility' => true,
56
- # '@uml_structuredClassifier_ownedAttribute' => true,
57
- # '@mtk_rubyClassGenerated' => true,
58
- # '@uml_classifier_generalization' => true,
59
- # '@uml_namedElement_visibility' => true,
60
- # '@uml_namedElement_clientDependency' => true,
61
- # '@umlx_packageableElement_owner' => true,
62
- # '@ext_isReferencedBy' => true,
63
- # '@uml_class_ownedOperation' => true,
64
- # '@uml_behavioredClassifier_implementation' => true,
65
- # '@uml_namedElement_name' => true }
66
- # #def copyOnCloneProperties
67
- # # CopyOnCloneProperties #_class
68
- # #end
69
- #end
70
-
71
-
72
-
73
-
1
+ #
2
+
3
+ class String
4
+ # Clones a string
5
+ # return self by default.(String are not cloned)
6
+ def rdfx_clone
7
+ return self
8
+ end
9
+ end
10
+
11
+ module Mrdf_Resource
12
+ # Clones a uml resource.
13
+ # Referenced objects are cloned if rdfx_copyOnClone says so.
14
+ def rdfx_clone
15
+ c=self.clone
16
+ c.rdf_uri="_transient_#{c.object_id}"
17
+ c.rdf_model[c.rdf_uri]=c
18
+
19
+ instance_variables.each { |v|
20
+ ivg=instance_variable_get(v)
21
+ next if (!ivg.kind_of?(ArrayOrSingleElement)) ||
22
+ (!isResetable?(v)) ||
23
+ (!rdfx_copyOnClone?(v))
24
+
25
+ newVal=createEmptyAttributeValue
26
+ #puts "clone v=#{v}"
27
+ self.instance_variable_get(v).each { | res|
28
+ newVal.push(res.rdfx_clone)
29
+ c.instance_variable_set(v,newVal)
30
+ }
31
+ }
32
+ return c
33
+ end
34
+
35
+ # Returns true if object should be copied on clone for this property.
36
+ # NOTE:
37
+ # returns true if property name contains "_owned". (works for UML)
38
+ def rdfx_copyOnClone?(prop)
39
+ return prop.include?('_owned')
40
+ #copyOrClone=copyOnCloneProperties[prop]
41
+ #if copyOrClone.nil?
42
+ #puts "WARNING: unspecified copy on clone for #{prop} on #{self.class.name}"
43
+ #end
44
+ #return copyOrClone
45
+ end
46
+ end
47
+ #module Mrdf_Resource
48
+ # #CopyOnCloneProperties={ }
49
+ # def copyOnCloneProperties
50
+ # #CopyOnCloneProperties
51
+ # end
52
+ #end
53
+ #module Muml_Class
54
+ # CopyOnCloneProperties={ '@uml_packageableElement_packageableElement_visibility' => true,
55
+ # '@uml_structuredClassifier_ownedAttribute' => true,
56
+ # '@mtk_rubyClassGenerated' => true,
57
+ # '@uml_classifier_generalization' => true,
58
+ # '@uml_namedElement_visibility' => true,
59
+ # '@uml_namedElement_clientDependency' => true,
60
+ # '@umlx_packageableElement_owner' => true,
61
+ # '@ext_isReferencedBy' => true,
62
+ # '@uml_class_ownedOperation' => true,
63
+ # '@uml_behavioredClassifier_implementation' => true,
64
+ # '@uml_namedElement_name' => true }
65
+ # #def copyOnCloneProperties
66
+ # # CopyOnCloneProperties #_class
67
+ # #end
68
+ #end
69
+
70
+
71
+
72
+