Module: ODDB::State::Admin::RegistrationMethods

Includes:
FachinfoMethods
Included in:
Registration
Defined in:
src/state/admin/registration.rb

Constant Summary

Constants included from FachinfoMethods

FI_FILE_DIR

Instance Method Summary (collapse)

Methods included from FachinfoMethods

#assign_fachinfo

Instance Method Details

- (Object) do_update(keys)



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'src/state/admin/registration.rb', line 93

def do_update(keys)
  new_state = self
  hash = user_input(keys)
  if(@model.is_a?(Persistence::CreateItem) && error?)
    return new_state
  end
  resolve_company(hash)
  if(hash[:registration_date].nil? && hash[:revision_date].nil?)
    error = create_error('e_missing_reg_rev_date', 
      :registration_date, nil)
    @errors.store(:registration_date, error)
    error = create_error('e_missing_reg_rev_date', 
      :revision_date, nil)
    @errors.store(:revision_date, error)
  end
  ind = @session.user_input(:indication)
  sel = nil
  if(indication = @session.app.indication_by_text(ind))
    hash.store(:indication, indication.pointer)
  elsif(!ind.empty?)
    input = hash.dup
    input.store(:indication, ind)
    sel = SelectIndicationMethods::Selection.new(input, 
      @session.app.search_indications(ind), @model)
    new_state = self.class::SELECT_STATE.new(@session, sel)
  end
  new_state = get_fachinfo
  @model = @session.app.update(@model.pointer, hash, unique_email)
  if(sel)
    sel.registration = @model
  end
  new_state
end

- (Object) new_patent



126
127
128
129
130
131
132
133
134
135
136
137
# File 'src/state/admin/registration.rb', line 126

def new_patent
  pointer = @session.user_input(:pointer)
  model = pointer.resolve(@session.app)
  pat_pointer = pointer + [:patent]
  item = Persistence::CreateItem.new(pat_pointer)
  item.carry(:iksnr, model.iksnr)
  if(klass=resolve_state(pat_pointer))
    klass.new(@session, item)
  else
    self
  end
end

- (Object) new_sequence



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'src/state/admin/registration.rb', line 138

def new_sequence
  pointer = @session.user_input(:pointer)
  model = pointer.resolve(@session.app)
  seq_pointer = pointer + [:sequence]
  item = Persistence::CreateItem.new(seq_pointer)
  item.carry(:iksnr, model.iksnr)
  item.carry(:company, model.company)
  item.carry(:compositions, [])
  item.carry(:packages, {})
  if (klass=resolve_state(seq_pointer))
    klass.new(@session, item)
  else
    self
  end
end

- (Object) resolve_company(hash)



153
154
155
156
157
158
159
160
161
# File 'src/state/admin/registration.rb', line 153

def resolve_company(hash)
  comp_name = @session.user_input(:company_name)
  if(company = @session.company_by_name(comp_name) || @model.company)
    hash.store(:company, company.oid)
  else
    err = create_error(:e_unknown_company, :company_name, comp_name)
    @errors.store(:company_name, err)
  end
end