Changeset 266 for ruby/trunk/lib/models/rm/support/identification.rb
- Timestamp:
- Sep 15, 2009, 8:33:04 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/trunk/lib/models/rm/support/identification.rb
r257 r266 51 51 attr_reader :domain_concept, :rm_name, :rm_entity, :rm_originator, :specialisation, :version_id 52 52 53 def initialize(value, domain_concept, rm_name, rm_entity, rm_originator, specialisation, version_id) 54 super(value) 55 self.domain_concept = domain_concept 56 self.rm_name = rm_name 57 self.rm_entity = rm_entity 58 self.rm_originator = rm_originator 59 self.specialisation = specialisation 60 self.version_id = version_id 61 end 62 53 def initialize(value) 54 super(value) 55 56 end 63 57 def domain_concept=(domain_concept) 64 58 raise ArgumentError, "domain concept not valid" if domain_concept.nil? or domain_concept.empty? … … 66 60 end 67 61 62 def value=(value) 63 if /([a-zA-Z]\w+)-([a-zA-Z]\w+)-([a-zA-Z]\w+)\.([a-zA-Z]\w+)(-([a-zA-Z]\w+))?\.(v[1-9]\d*)/ =~ value 64 self.rm_originator = $1 65 self.rm_name = $2 66 self.rm_entity = $3 67 self.concept_name = $4 68 self.specialisation = $6 69 self.version_id = $7 70 else 71 raise ArgumentError, 'invalid archetype id form' 72 end 73 end 74 75 def qualified_rm_entity 76 return @rm_originator + '-' + @rm_name + '-' + @rm_entity 77 end 78 79 def domain_concept 80 if @specialisation.nil? 81 return @concept_name 82 else 83 return @concept_name + '-' + @specialisation 84 end 85 end 86 87 def value 88 return self.qualified_rm_entity + self.domain_concept + '.' + @version_id 89 end 90 91 def concept_name=(concept_name) 92 if concept_name.nil? or concept_name.empty? 93 raise ArgumentError, 'concept_name is mandatory' 94 end 95 @concept_name = concept_name 96 end 97 98 def domain_concept=(domain_concept) 99 if domain_concept.nil? or domain_concept.empty? 100 raise ArgumentError, "domain concept not valid" 101 end 102 if /([a-zA-Z]\w+)(-([a-zA-Z]\w))?/ =~ domain_concept 103 self.concept_name = $1 104 self.specialisation = $3 105 else 106 raise ArgumentError, 'invalid domain concept form' 107 end 108 end 109 68 110 def rm_name=(rm_name) 69 111 raise ArgumentError, "rm_name not valid" if rm_name.nil? or rm_name.empty? … … 72 114 73 115 def rm_entity=(rm_entity) 74 raise ArgumentError, "rm_entity not valid" if rm_entity.nil? or rm_entity.empty? 116 if rm_entity.nil? or rm_entity.empty? 117 raise ArgumentError, "rm_entity is mandatory" 118 end 75 119 @rm_entity = rm_entity 76 120 end 77 121 78 122 def rm_originator=(rm_originator) 79 raise ArgumentError, "rm_originator not valid" if rm_originator.nil? or rm_originator.empty? 123 if rm_originator.nil? or rm_originator.empty? 124 raise ArgumentError, "rm_originator not valid" 125 end 80 126 @rm_originator = rm_originator 81 127 end 82 128 83 129 def specialisation=(specialisation) 84 # raise ArgumentError, "rm_specialisation not valid" if specialisation.nil? or specialisation.empty? 130 if !specialisation.nil? and specialisation.empty? 131 raise ArgumentError, "rm_specialisation not valid" 132 end 85 133 @specialisation = specialisation 86 134 end 135 87 136 def version_id=(version_id) 88 137 raise ArgumentError, "version_id not valid" if version_id.nil? or version_id.empty?
Note:
See TracChangeset
for help on using the changeset viewer.