Changeset 21 for ruby/trunk/models
- Timestamp:
- Apr 30, 2008, 8:34:43 PM (16 years ago)
- Location:
- ruby/trunk/models
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/trunk/models/Rakefile
r4 r21 34 34 35 35 36 gem_spec = Gem::Specification.new do |s| 37 s.name = 'openehr_models' 38 s.author = 'Shinji KOBAYASHI, Akimichi TATSUKAWA' 39 s.version = '0.0.1' 40 s.summary = 'OpenEHR models' 41 s.email = 'openehr-jp@openehr.jp' 42 s.test_files = FileList['tests/test_*.rb', '*.adl'] 43 candidates = Dir.glob("{am,rm,docs,tests}/**/*") + FileList['COPYING', 'Rakefile','am.rb','assumed_library_types.rb','rm.rb'] 44 s.files = candidates.delete_if do |item| 45 item.include?(".svn") || item.include?("rdoc") 46 end 47 # s.files << FileList['COPYING', 'Rakefile','am.rb','assumed_library_types.rb','rm.rb'] 48 # s.require_paths += [".","am","rm"] 49 s.require_path = "." 50 # s.has_rdoc = true 51 # s.extra_rdoc_files = ["README"] 52 end 53 54 55 Rake::GemPackageTask.new(gem_spec) do |pkg| 56 pkg.need_zip = false 57 pkg.need_tar = false 58 end 59 60 #CLOBBER.include('rdoc') 61 #CLEAN.include('lib/*.output', 'log/*.log') 62 63 36 64 37 65 -
ruby/trunk/models/am.rb
r4 r21 17 17 module AM 18 18 module Archetype 19 autoload :A rchetype, "am/archetype/archetype.rb"19 autoload :ARCHETYPE, "am/archetype/archetype.rb" 20 20 autoload :Constraint_Model, "am/archetype/constraint_model/archetype_constraint.rb" 21 21 autoload :Ontology, "am/archetype/ontology.rb" 22 autoload :Archetype_Description, "am/archetype/archetype_description/archetype_description.rb" 22 23 module Archetype_Description 24 autoload :ARCHETYPE_DESCRIPTION, "am/archetype/archetype_description/archetype_description.rb" 25 end 26 23 27 module Constraint_Model 28 autoload :ARCHETYPE_CONSTRAINT, "am/archetype/constraint_model/archetype_constraint.rb" 24 29 autoload :Assertion, "am/archetype/constraint_model/assertion.rb" 25 30 autoload :Primitive, "am/archetype/constraint_model/primitive.rb" -
ruby/trunk/models/am/archetype/archetype.rb
r4 r21 9 9 CURRENT_ADL_VERSION = "2.0" 10 10 end 11 class Archetype < OpenEHR::RM::Common::Resource::Authored_Resource 11 12 class ARCHETYPE < OpenEHR::RM::Common::Resource::Authored_Resource 12 13 include ADL_Definition 13 14 attr_accessor :archetype_id, :concept_code, :is_controlled, :original_language, :parent_archtype_id, :uid … … 18 19 attr_accessor :revision_history, :translation 19 20 20 def initialize(parent_id, concept, 21 description, revision_history, is_controled, 22 definition, ontology, adl_version, 23 id = nil , original_language = nil, translation = nil) 21 def initialize(args = {}) 22 # def initialize(parent_id, concept, 23 # description, revision_history, is_controled, 24 # definition, ontology, adl_version, 25 # id = nil , original_language = nil, translation = nil) 24 26 # raise Exception.new("illegal argument error, id == nil") unless id 25 27 # raise Exception.new("illegal argument error, originalLanguage == nil") unless origina_language 26 28 27 29 # raise Exception.new("illegal argument error, translation == nil") unless translation 28 @adl_version = a dl_version29 @id = id30 @parent_id = parent_id31 @concept = concept32 @original_language = original_language33 @translation = translation34 @description = description35 @revision_history = revision_history36 @is_controled = is_controled37 @definition = definition38 @ontology = ontology30 @adl_version = args[:adl_version] if args[:adl_version] 31 @id = args[:id] ? args[:id] : nil 32 @parent_id = args[:parent_id] if args[:parent_id] 33 @concept = args[:concept] if args[:concept] 34 @original_language = args[:original_language] ? args[:original_language] : nil 35 @translation = args[:translation] ? args[:translation] : nil 36 @description = args[:description] if args[:description] 37 @revision_history = args[:revision_history] if args[:revision_history] 38 @is_controled = args[:is_controled] if args[:is_controled] 39 @definition = args[:definition] if args[:definition] 40 @ontology = args[:ontology] if args[:ontology] 39 41 # loadMaps(definition) 40 42 end -
ruby/trunk/models/am/archetype/archetype_description/archetype_description.rb
r4 r21 4 4 module Archetype 5 5 module Archetype_Description 6 class Archetype_Description 7 attr_accessor :archetype_package_uri, :lifecycle_state, :original_author, :other_contributors, :other_details 6 class ARCHETYPE_DESCRIPTION 7 attr_accessor :archetype_package_uri, :lifecycle_state, :original_author, :other_contributors, :other_details, :details 8 def initialize(args ={ }) 9 @details = args[:details] ? args[:details] : [] 10 end 8 11 end 9 12 -
ruby/trunk/models/am/archetype/constraint_model/archetype_constraint.rb
r4 r21 4 4 module Archetype 5 5 module Constraint_Model 6 class A rchetype_Constraint6 class ARCHETYPE_CONSTRAINT 7 7 8 8 end 9 10 class C_OBJECT < ARCHETYPE_CONSTRAINT 11 12 end 13 14 class C_ATTRIBUTE < ARCHETYPE_CONSTRAINT 15 16 end 17 18 class C_DEFINED_OBJECT < C_OBJECT 19 20 end 21 22 class C_PRIMITIVE_OBJECT < C_DEFINED_OBJECT 23 24 end 25 26 class C_COMPLEX_OBJECT < C_DEFINED_OBJECT 27 attr_accessor :attributes, :attributes_valid 28 29 end 30 31 class C_DOMAIN_TYPE < C_DEFINED_OBJECT 32 33 end 34 35 class C_REFERENCE_OBJECT < C_OBJECT 36 37 end 38 39 class ARCHETYPE_INTERNAL_REF < C_REFERENCE_OBJECT 40 41 end 42 43 class ARCHETYPE_SLOT < C_REFERENCE_OBJECT 44 45 end 46 47 class CONSTRAINT_REF < C_REFERENCE_OBJECT 48 49 end 50 9 51 end 10 52 end -
ruby/trunk/models/am/archetype/constraint_model/primitive.rb
r4 r21 3 3 module Archetype 4 4 module Constraint_Model 5 5 6 module Primitive 7 6 8 class C_Primitive 7 9 def assumed_value … … 18 20 end 19 21 end 22 20 23 class C_Boolean < C_Primitive 21 24 attr_accessor :assumed_value … … 50 53 end 51 54 end 55 52 56 private 57 53 58 def binary_consistency(true_valid, false_valid) 54 59 if !true_valid && !false_valid … … 57 62 end 58 63 end # of C_Boolean 64 59 65 class C_Integer < C_Primitive 60 66 -
ruby/trunk/models/assumed_library_types.rb
r4 r21 10 10 set_upper_included(upper_included) 11 11 end 12 12 13 def set_lower(lower) 13 14 check_lower_upper(lower, @upper) 14 15 end 16 15 17 def set_upper(upper) 16 18 check_lower_upper(@lower, upper) 17 19 end 20 18 21 def set_lower_included(lower_included) 19 22 if (lower == nil) && (lower_included != nil) … … 22 25 @lower_included = lower_included 23 26 end 27 24 28 def set_upper_included(upper_included) 25 29 @upper_included = upper_included … … 28 32 end 29 33 end 34 30 35 def has?(value) 31 36 if ((@lower < value) && (value < @upper) || … … 37 42 end 38 43 end 44 39 45 private 46 40 47 def check_lower_upper(lower, upper) 41 48 if (lower == nil) && (upper == nil) -
ruby/trunk/models/tests/test_archetype_model.rb
r4 r21 5 5 class ArchetypeModelTest < Test::Unit::TestCase 6 6 def setup 7 @archetype = OpenEHR::AM::Archetype::A rchetype.new(nil,nil,nil,nil,nil,nil,nil,nil)8 @archetype_description = OpenEHR::AM::Archetype::Archetype_Description::A rchetype_Description.new9 @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::A rchetype_Constraint.new7 @archetype = OpenEHR::AM::Archetype::ARCHETYPE.new #(nil,nil,nil,nil,nil,nil,nil,nil) 8 @archetype_description = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION.new 9 @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new 10 10 @assertion = OpenEHR::AM::Archetype::Constraint_Model::Assertion::Assertion.new 11 11 @c_primitive = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Primitive.new … … 13 13 @c_integer = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Integer.new 14 14 @archetype_ontology = OpenEHR::AM::Archetype::Ontology::Archetype_Ontology.new 15 16 @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new 17 @c_object = OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT.new 18 @c_defined_object = OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT.new 19 @c_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE.new 20 @c_primitive_object = OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT.new 21 @c_reference_object = OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT.new 22 @archetype_internal_ref = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.new 23 @archetype_slot = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.new 24 @constraint_ref = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.new 25 @c_domain_type = OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE.new 26 @c_complex_object = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new 15 27 end 16 28 17 29 def test_init 18 30 assert_instance_of OpenEHR::AM::Archetype::Ontology::Archetype_Ontology, @archetype_ontology 19 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::A rchetype_Constraint, @archetype_constraint20 assert_instance_of OpenEHR::AM::Archetype::Archetype_Description::A rchetype_Description, @archetype_description21 assert_instance_of OpenEHR::AM::Archetype::A rchetype, @archetype31 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint 32 assert_instance_of OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION, @archetype_description 33 assert_instance_of OpenEHR::AM::Archetype::ARCHETYPE, @archetype 22 34 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Assertion::Assertion, @assertion 23 35 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Primitive, @c_primitive 24 36 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Boolean, @c_boolean 37 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint 38 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT, @c_object 39 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT, @c_defined_object 40 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE, @c_attribute 41 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT, @c_primitive_object 42 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT, @c_reference_object 43 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF, @archetype_internal_ref 44 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT, @archetype_slot 45 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF, @constraint_ref 46 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE, @c_domain_type 47 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, @c_complex_object 25 48 end 49 26 50 def test_primitive 27 51 assert @c_boolean.true_valid?
Note:
See TracChangeset
for help on using the changeset viewer.