Class: KeyPersonObject

Inherits:
Object
  • Object
show all
Includes:
DataFactory, Foundry, Navigation, StringFactory
Defined in:
lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Navigation

#doc_search, #fill_out, #fill_out_item, #on_document?, #open_document, #window_cleanup

Methods included from Utilities

#get, #make_role, #make_user, #random_percentage, #set, #snake_case

Constructor Details

#initialize(browser, opts = {}) ⇒ KeyPersonObject

Note that you must pass in both first and last names (or neither).



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 16

def initialize(browser, opts={})
  @browser = browser

  defaults = {
    role:                            'Principal Investigator',
    units:                           [],
    degrees:                         collection('Degrees'),
    certified:                       true, # Set this to false if you do not want any Proposal Person Certification Questions answered
    certify_info_true:               'Y',
    potential_for_conflict:          'Y',
    submitted_financial_disclosures: 'Y',
    lobbying_activities:             'Y',
    excluded_from_transactions:      'Y',
    familiar_with_pla:               'Y'
  }

  set_options(defaults.merge(opts))
  requires :document_id
  @full_name="#{@first_name} #{@last_name}"
end

Instance Attribute Details

#certifiedObject

Returns the value of attribute certified.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def certified
  @certified
end

#certify_info_trueObject

Returns the value of attribute certify_info_true.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def certify_info_true
  @certify_info_true
end

#degreesObject

Returns the value of attribute degrees.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def degrees
  @degrees
end

#document_idObject

Returns the value of attribute document_id.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def document_id
  @document_id
end

#era_commons_nameObject

Returns the value of attribute era_commons_name.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def era_commons_name
  @era_commons_name
end

#excluded_from_transactionsObject

Returns the value of attribute excluded_from_transactions.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def excluded_from_transactions
  @excluded_from_transactions
end

#familiar_with_plaObject

Returns the value of attribute familiar_with_pla.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def familiar_with_pla
  @familiar_with_pla
end

#financialObject

Returns the value of attribute financial.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def financial
  @financial
end

#first_nameObject

Returns the value of attribute first_name.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def first_name
  @first_name
end

#full_nameObject

Returns the value of attribute full_name.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def full_name
  @full_name
end

#home_unitObject

Returns the value of attribute home_unit.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def home_unit
  @home_unit
end

#key_person_roleObject

Returns the value of attribute key_person_role.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def key_person_role
  @key_person_role
end

#last_nameObject

Returns the value of attribute last_name.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def last_name
  @last_name
end

#lobbying_activitiesObject

Returns the value of attribute lobbying_activities.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def lobbying_activities
  @lobbying_activities
end

#other_key_personsObject

Returns the value of attribute other_key_persons.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def other_key_persons
  @other_key_persons
end

#potential_for_conflictsObject

Returns the value of attribute potential_for_conflicts.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def potential_for_conflicts
  @potential_for_conflicts
end

#recognitionObject

Returns the value of attribute recognition.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def recognition
  @recognition
end

#responsibilityObject

Returns the value of attribute responsibility.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def responsibility
  @responsibility
end

#roleObject

Returns the value of attribute role.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def role
  @role
end

#spaceObject

Returns the value of attribute space.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def space
  @space
end

#submitted_financial_disclosuresObject

Returns the value of attribute submitted_financial_disclosures.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def 
  @submitted_financial_disclosures
end

#unitsObject

Returns the value of attribute units.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def units
  @units
end

#user_nameObject

Returns the value of attribute user_name.



8
9
10
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 8

def user_name
  @user_name
end

Instance Method Details

#add_degree_info(opts = {}) ⇒ Object



177
178
179
180
181
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 177

def add_degree_info opts={}
  defaults = { document_id: @document_id,
               person: @full_name }
  @degrees.add defaults.merge(opts)
end

#createObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
126
127
128
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 37

def create
  navigate
  # TODO: Add support for non-employee personnel...
  on(KeyPersonnel).employee_search
  if @last_name==nil
    on PersonLookup do |look|
      look.search
      look.return_random
    end
    on KeyPersonnel do |person|
      @full_name=person.person_name
      @last_name=@full_name[/\w+$/]
      @first_name=$~.pre_match.strip
    end
  else
    on PersonLookup do |look|
      look.last_name.set @last_name
      look.search
      look.return_value @full_name
    end
  end
  on KeyPersonnel do |person|
    # This conditional exists to deal with the fact that
    # a Principal Investigator can also be called a "PI/Contact",
    # in cases where it's an NIH proposal.
    if person.proposal_role.include? @role
      person.proposal_role.select @role
    else
      person.proposal_role.select_value role_value[@role]
      @role = person.proposal_role.selected_options[0].text
    end
    person.key_person_role.fit @key_person_role
    person.add_person
    break unless person.add_person_errors.empty? # ..we've thrown an error, so no need to continue this method...
    person.expand_all
    @user_name=person.user_name @full_name
    @home_unit=person.home_unit @full_name
    if @units.empty? # No units in @units, so we're not setting units
      # ...so, get the units from the UI:
      @units=person.units @full_name if @key_person_role==nil

    else # We have Units to add and update...
      # Temporarily store any existing units...
      person.add_unit_details(@full_name) unless @key_person_role==nil

      units=person.units @full_name
      # Note that this assumes we're adding
      # Unit(s) that aren't already present
      # in the list, so be careful!
      @units.each do |unit|
        person.unit_number(@full_name).set unit[:number]
        person.add_unit @full_name
      end
      break if person.unit_details_errors_div(@full_name).present?
      # Now add the previously existing units to
      # @units
      units.each { |unit| @units << unit }
    end

    # Now we groom the Unit Hashes, to include
    # the Combined Credit Split numbers...
    #
    # NOTE: Commenting out this code until we
    # determine either we need it or else we come up with
    # a better way to do this...
    #@units.each do |unit|
    #  [:space, :responsibility, :financial, :recognition].each do |item|
    #    unit[item] ||= unit.store(item, rand_num)
    #  # Then we update the UI with the values...
    #    person.send("unit_#{item.to_s}".to_sym, @full_name, unit[:number]).set unit[item]
    #  end
    #end

    # If it's a key person without units then they won't have credit splits,
    # otherwise, the person will, so fill them out...
    if @key_person_role==nil || !@units.empty?
      fill_out_item @full_name, person, :space, :responsibility, :financial, :recognition
    end

    # Proposal Person Certification
    if @certified
      person.include_certification_questions(@full_name) unless @key_person_role==nil
      cert_questions.each { |q| person.send(q, full_name, get(q)) }
    else
       cert_questions.each { |q| set(q, nil) }
    end

    # Add gathering/setting of more attributes here as needed
    fill_out_item @full_name, person, :era_commons_name
    person.save
  end
end

#deleteObject



183
184
185
186
187
188
189
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 183

def delete
  navigate
  on KeyPersonnel do |person|
    person.check_person @full_name
    person.delete_selected
  end
end

#delete_unitsObject



191
192
193
194
195
196
197
198
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 191

def delete_units
  @units.each do |unit|
    on KeyPersonnel do |units|
      units.delete_unit(@full_name, unit[:number])
    end
  end
  @units=[]
end

#edit(opts = {}) ⇒ Object

IMPORTANT NOTE: Add edit options to this method as needed.

HOWEVER: Do NOT add updating of Unit Credit Splits here. Those require special handling and thus have their own method: #update_unit_credit_splits



137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 137

def edit opts={}
  navigate
  on KeyPersonnel do |update|
    update.expand_all
    # Note: This is a dangerous short cut, as it may not
    # apply to every field that could be edited with this
    # method...
    opts.each do |field, value|
      update.send(field, @full_name).fit value
    end
    update.save
  end
  update_options(opts)
end

#update_unit_credit_splits(units = @units) ⇒ Object

This method requires a parameter that is an Array of Hashes. Though it defaults to the person object’s Example:

NUMBER”, :responsibility=>“33.33”


158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/kuality-coeus/data_objects/proposal_development/key_personnel.rb', line 158

def update_unit_credit_splits(units=@units)
  splits=[:responsibility, :financial, :recognition, :space]
  units.each do |unit|
    on KeyPersonnel do |update|
      update.unit_space(@full_name, unit[:number]).fit unit[:space]
      update.unit_responsibility(@full_name, unit[:number]).fit unit[:responsibility]
      update.unit_financial(@full_name, unit[:number]).fit unit[:financial]
      update.unit_recognition(@full_name, unit[:number]).fit unit[:recognition]
      update.save
    end
    splits.each do |split|
      unless unit[split]==nil
        @units[@units.find_index{|u| u[:number]==unit[:number]}][split]=unit[split]
      end
    end

  end
end