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 +10 -5
- data/Manifest.txt +1 -2
- data/Manual.txt +88 -0
- data/README.txt +79 -48
- data/Rakefile +4 -3
- data/lib/ontomde-core/bootstrap_rdfs.rb +36 -37
- data/lib/ontomde-core/clone.rb +72 -73
- data/lib/ontomde-core/context.rb +114 -115
- data/lib/ontomde-core/customERB.rb +72 -72
- data/lib/ontomde-core/custom_method_missing.rb +52 -53
- data/lib/ontomde-core/delayed.rb +9 -9
- data/lib/ontomde-core/demoInstaller.rb +25 -25
- data/lib/ontomde-core/exceptions.rb +27 -28
- data/lib/ontomde-core/fileLoader.rb +191 -163
- data/lib/ontomde-core/fileTypes.rb +145 -133
- data/lib/ontomde-core/helper.rb +547 -538
- data/lib/ontomde-core/log.rb +32 -32
- data/lib/ontomde-core/meta.rb +410 -316
- data/lib/ontomde-core/profil.rb +60 -62
- data/lib/ontomde-core/resource.rb +277 -272
- data/lib/ontomde-core/resourceSet.rb +185 -173
- data/lib/ontomde-core/triplet.rb +159 -161
- data/lib/ontomde-core/version.rb +5 -5
- data/lib/ontomde-core.rb +26 -35
- data/test/protege/etatCivil.pprj +779 -526
- data/test/protege/etatCivil.rdf +3 -1
- data/test/protege/etatCivil.rdfs +6 -0
- data/test/protege/test_demo.rb +68 -46
- data/test/test_context.rb +88 -88
- data/test/test_ontomde-core.rb +9 -9
- data/test/test_protected.rb +291 -238
- data/test/test_uri.rb +37 -37
- data/test/unit_test_crash.rb +22 -22
- metadata +66 -59
- data/bin/ontomde-core +0 -0
- data/lib/ontomde-core/loader.rb +0 -70
data/History.txt
CHANGED
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
|
3
|
-
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
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
|
-
|
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
|
-
|
13
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
attr_reader :
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
data/lib/ontomde-core/clone.rb
CHANGED
@@ -1,73 +1,72 @@
|
|
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
|
-
|
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
|
+
|