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

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

refs #39, #65

File size: 3.5 KB
RevLine 
[102]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
[4]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
[102]15
[4]16 class Pathable
[102]17 attr_accessor :parent
18 def initialize(parent = nil)
[4]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
[7]36 end
[102]37
[4]38 class Locatable < Pathable
39 include Locater_Constants
[8]40 attr_accessor :uid, :archetype_node_id, :archetype_details
[4]41 attr_accessor :feeder_audit, :links, :parent
[8]42 def initialize(uid, archetype_node_id, name, archetype_details,
[4]43 feeder_audit, links, parent)
44 super(parent)
[7]45 if archetype_node_id.nil?
[4]46 raise ArgumentError, "null archetype_node_id"
47 end
[7]48 if name.nil?
[4]49 raise ArgumentError, "name is empty"
50 end
[7]51 if links.nil?
[4]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
[8]59 @parent = parent
[4]60 end
61 def item_at_path(path)
[7]62 if !@path.nil?
63 if @path == ""
64 raise ArgumentError, "path is not valid"
65 end
66 end
[4]67 end
[7]68 def items_at_path(path)
[4]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?
[7]80 !archetype_details.nil?
[4]81 end
82 end
[102]83 class Archetyped
84 attr_reader :archetype_id, :rm_version
85 attr_accessor :template_id
86 def initialize(archetype_id, rm_version, template_id = nil)
87 self.archetype_id = archetype_id
88 self.rm_version = rm_version
89 @template_id = template_id
90 end
91 def archetype_id=(archetype_id)
92 raise ArgumentError, "invalid archetype_id" if archetype_id.nil?
93 @archetype_id = archetype_id
94 end
95 def rm_version=(rm_version)
96 raise ArgumentError, "invalid rm_version" if rm_version.nil? or rm_version.empty?
97 @rm_version = rm_version
98 end
99 end
[4]100 end # end of Archetyped
101 end # end of Common
102 end # end of RM
103end # end of OpenEHR
Note: See TracBrowser for help on using the repository browser.