source: ruby/trunk/lib/models/rm/common/archetyped.rb@ 104

Last change on this file since 104 was 104, checked in by KOBAYASHI, Shinji, 16 years ago

fixed #46
refs #62, #65, #50

arranged structure of test_reference_model.rb
divided test classes

File size: 4.1 KB
Line 
1# This module is based on the UML,
2# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109318114715_211173_0Report.html
3# Ticket refs #65
4module OpenEHR
5 module RM
6 module Common
7 module Archetyped
8 module Locater_Constants
9 CURRENT_TRANSACTION_ID = "current"
10 FRAGMENT_SEPARATOR = "#"
11 CONTENT_PATH_SEPARATOR = "|"
12 ORGANIZER_PATH_SEPARATOR = "/"
13 MULTIPART_ID_DELIMITER = "::"
14 end
15
16 class Pathable
17 attr_accessor :parent
18 def initialize(parent = nil)
19 @parent = parent
20 end
21 def item_at_path(path)
22 raise NotImplementError, "item_at_path must be implemented"
23 end
24 def items_at_path(path)
25 raise NotImplementError, "items_at_path must be implemented"
26 end
27 def path_exists?(path)
28 raise NotImplementError, "path_exists? must be implemented"
29 end
30 def path_of_item(item)
31 raise NotImplementError, "path_of_item must be implemented"
32 end
33 def path_unique(path)
34 raise NotImplementError, "path_unique must be implemented"
35 end
36 end
37
38 class Locatable < Pathable
39 include Locater_Constants
40 attr_accessor :uid, :archetype_node_id, :archetype_details
41 attr_accessor :feeder_audit, :links, :parent
42 def initialize(uid, archetype_node_id, name, archetype_details,
43 feeder_audit, links, parent)
44 super(parent)
45 if archetype_node_id.nil?
46 raise ArgumentError, "null archetype_node_id"
47 end
48 if name.nil?
49 raise ArgumentError, "name is empty"
50 end
51 if links.nil?
52 raise ArgumentError, "links is empty"
53 end
54 @uid = uid
55 @archetype_node_id = archetype_node_id
56 @archetype_details = archetype_details
57 @feeder_audit = feeder_audit
58 @links = links
59 @parent = parent
60 end
61 def item_at_path(path)
62 if !@path.nil?
63 if @path == ""
64 raise ArgumentError, "path is not valid"
65 end
66 end
67 end
68 def items_at_path(path)
69 raise NotImplementError, "items_at_path must be implemented"
70 end
71 def path_exists?
72 raise NotImplementError, "path_exists? must be implemented"
73 end
74 def path_unique
75 raise NotImplementError, "path_unique must be implemented"
76 end
77 def concept
78 end
79 def is_archetype_root?
80 !archetype_details.nil?
81 end
82 end
83
84 class Archetyped
85 attr_reader :archetype_id, :rm_version
86 attr_accessor :template_id
87 def initialize(archetype_id, rm_version, template_id = nil)
88 self.archetype_id = archetype_id
89 self.rm_version = rm_version
90 @template_id = template_id
91 end
92 def archetype_id=(archetype_id)
93 raise ArgumentError, "invalid archetype_id" if archetype_id.nil?
94 @archetype_id = archetype_id
95 end
96 def rm_version=(rm_version)
97 raise ArgumentError, "invalid rm_version" if rm_version.nil? or rm_version.empty?
98 @rm_version = rm_version
99 end
100 end
101
102 class Link
103 attr_reader :meaning, :target, :type
104 def initialize(meaning, target, type)
105 self.meaning = meaning
106 self.target = target
107 self.type = type
108 end
109 def meaning=(meaning)
110 raise ArgumentError, "meaning should not be nil" if meaning.nil?
111 @meaning = meaning
112 end
113 def target=(target)
114 raise ArgumentError, "target should not be nil" if target.nil?
115 @target = target
116 end
117 def type=(type)
118 raise ArgumentError, "type should not be nil" if type.nil?
119 @type = type
120 end
121 end
122 end # end of Archetyped
123 end # end of Common
124 end # end of RM
125end # end of OpenEHR
Note: See TracBrowser for help on using the repository browser.