Module: ObservationMatrixRowsHelper

Defined in:
app/helpers/observation_matrix_rows_helper.rb

Instance Method Summary collapse

Instance Method Details

#label_for_observation_matrix_row(observation_matrix_row) ⇒ String

Returns The label used in for general purpose internal use.

Returns:

  • (String)

    The label used in for general purpose internal use



16
17
18
19
# File 'app/helpers/observation_matrix_rows_helper.rb', line 16

def label_for_observation_matrix_row(observation_matrix_row)
  return observation_matrix_row.name if observation_matrix_row.name.present?
  label_for(observation_matrix_row.observation_object)
end

#observation_matrix_row_destroyable?(observation_matrix_row) ⇒ ObservationMatrixRow#id?

ONLY CACHE IF count == 1 ?!

Returns:

  • (ObservationMatrixRow#id, nil)

    if destroyable (represented by only a single OMRI of type Single) then return the ID



59
60
61
62
63
# File 'app/helpers/observation_matrix_rows_helper.rb', line 59

def observation_matrix_row_destroyable?(observation_matrix_row)
  if observation_matrix_row.cached_observation_matrix_row_item_id.present? && observation_matrix_row.reference_count == 1
    return observation_matrix_row.cached_observation_matrix_row_item_id
  end
end

#observation_matrix_row_label_csv(observation_matrix_row) ⇒ String?

Returns the object_label with any commas replaced by pipes.

Returns:

  • (String, nil)

    the object_label with any commas replaced by pipes



50
51
52
53
54
# File 'app/helpers/observation_matrix_rows_helper.rb', line 50

def observation_matrix_row_label_csv(observation_matrix_row)
  return observation_matrix_row.name if observation_matrix_row.name.present?
  o = observation_matrix_row.observation_object
  ('"' + label_for(o).gsub('"', "'") + '"').html_safe
end

#observation_matrix_row_label_nexml(observation_matrix_row) ⇒ Object



42
43
44
45
46
# File 'app/helpers/observation_matrix_rows_helper.rb', line 42

def observation_matrix_row_label_nexml(observation_matrix_row)
  return observation_matrix_row.name if observation_matrix_row.name.present?
  o = observation_matrix_row.observation_object
  label_for(o)
end

#observation_matrix_row_label_nexus(observation_matrix_row) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'app/helpers/observation_matrix_rows_helper.rb', line 32

def observation_matrix_row_label_nexus(observation_matrix_row)
  # TODO: this return is not guarunteed to be legal nexus
  return observation_matrix_row.name if observation_matrix_row.name.present?
  o = observation_matrix_row.observation_object
  s = label_for(o)
  s.gsub!(/[^\w]/, '_')
  s = '_' if s.blank?
  s.gsub(/_+/, '_')
end

#observation_matrix_row_label_tnt(observation_matrix_row) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/observation_matrix_rows_helper.rb', line 21

def observation_matrix_row_label_tnt(observation_matrix_row)
  # TODO: this return is not guarunteed to be legal TNT
  return observation_matrix_row.name if observation_matrix_row.name.present?
  o = observation_matrix_row.observation_object
  s = label_for(o)
  s.gsub!(/[^\w]/, '_')
  s.gsub!(/_+/, '_')
  s = '_' if s.blank?
  s + "_#{o.id}" # Code must return labels that will execute without error, ensure they are unique.
end


9
10
11
12
# File 'app/helpers/observation_matrix_rows_helper.rb', line 9

def observation_matrix_row_link(observation_matrix_row)
  return nil if observation_matrix_row.nil?
  link_to(observation_matrix_row_tag(observation_matrix_row).html_safe, observation_matrix_row)
end

#observation_matrix_row_tag(observation_matrix_row) ⇒ Object

Display in app



4
5
6
7
# File 'app/helpers/observation_matrix_rows_helper.rb', line 4

def observation_matrix_row_tag(observation_matrix_row)
  return nil if observation_matrix_row.nil?
  object_tag(observation_matrix_row.observation_object)
end