Class: ProposalDevelopmentObject

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Navigation

#doc_search, #fill_out, #on_document?, #on_page?, #open_document

Methods included from Utilities

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

Constructor Details

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

Returns a new instance of ProposalDevelopmentObject.



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

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

  defaults = {
    proposal_type:         'New',
    lead_unit:             '::random::',
    activity_type:         '::random::',
    project_title:         random_alphanums,
    sponsor_code:          '::random::',
    sponsor_type_code:     '::random::',
    project_start_date:    next_week[:date_w_slashes], # TODO: Think about using the date object here, and not the string
    project_end_date:      next_year[:date_w_slashes],
    sponsor_deadline_date: next_week[:date_w_slashes],
    mail_by:               '::random::',
    mail_type:             '::random::',
    key_personnel:         KeyPersonnelCollection.new,
    special_review:        SpecialReviewCollection.new,
    budget_versions:       BudgetVersionsCollection.new,
    personnel_attachments: PersonnelAttachmentsCollection.new,
    proposal_attachments:  ProposalAttachmentsCollection.new
  }

  set_options(defaults.merge(opts))
end

Instance Attribute Details

#activity_typeObject

Returns the value of attribute activity_type.



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

def activity_type
  @activity_type
end

#budget_versionsObject

Returns the value of attribute budget_versions.



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

def budget_versions
  @budget_versions
end

#compliance_questionsObject

Returns the value of attribute compliance_questions.



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

def compliance_questions
  @compliance_questions
end

#createdObject

Returns the value of attribute created.



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

def created
  @created
end

#custom_dataObject

Returns the value of attribute custom_data.



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

def custom_data
  @custom_data
end

#document_idObject

Returns the value of attribute document_id.



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

def document_id
  @document_id
end

#initiatorObject

Returns the value of attribute initiator.



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

def initiator
  @initiator
end

#key_personnelObject

Returns the value of attribute key_personnel.



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

def key_personnel
  @key_personnel
end

#kuali_u_questionsObject

Returns the value of attribute kuali_u_questions.



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

def kuali_u_questions
  @kuali_u_questions
end

#lead_unitObject

Returns the value of attribute lead_unit.



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

def lead_unit
  @lead_unit
end

#mail_byObject

Returns the value of attribute mail_by.



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

def mail_by
  @mail_by
end

#mail_typeObject

Returns the value of attribute mail_type.



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

def mail_type
  @mail_type
end

#opportunity_idObject

Returns the value of attribute opportunity_id.



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

def opportunity_id
  @opportunity_id
end

#permissionsObject

Returns the value of attribute permissions.



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

def permissions
  @permissions
end

#personnel_attachmentsObject

Returns the value of attribute personnel_attachments.



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

def personnel_attachments
  @personnel_attachments
end

#project_end_dateObject

Returns the value of attribute project_end_date.



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

def project_end_date
  @project_end_date
end

#project_start_dateObject

Returns the value of attribute project_start_date.



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

def project_start_date
  @project_start_date
end

#project_titleObject

Returns the value of attribute project_title.



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

def project_title
  @project_title
end

#proposal_attachmentsObject

Returns the value of attribute proposal_attachments.



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

def proposal_attachments
  @proposal_attachments
end

#proposal_numberObject

Returns the value of attribute proposal_number.



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

def proposal_number
  @proposal_number
end

#proposal_questionsObject

Returns the value of attribute proposal_questions.



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

def proposal_questions
  @proposal_questions
end

#proposal_typeObject

Returns the value of attribute proposal_type.



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

def proposal_type
  @proposal_type
end

#recall_reasonObject

Returns the value of attribute recall_reason.



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

def recall_reason
  @recall_reason
end

#s2s_questionnaireObject

Returns the value of attribute s2s_questionnaire.



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

def s2s_questionnaire
  @s2s_questionnaire
end

#special_reviewObject

Returns the value of attribute special_review.



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

def special_review
  @special_review
end

Returns the value of attribute sponsor_code.



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

def sponsor_code
  @sponsor_code
end

Returns the value of attribute sponsor_deadline_date.



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

def sponsor_deadline_date
  @sponsor_deadline_date
end

Returns the value of attribute sponsor_type_code.



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

def sponsor_type_code
  @sponsor_type_code
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#add_budget_version(opts = {}) ⇒ Object



128
129
130
131
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 128

def add_budget_version opts={}
  opts[:version] ||= (@budget_versions.size+1).to_s
  @budget_versions << prep(BudgetVersionsObject, opts)
end

#add_custom_data(opts = {}) ⇒ Object



133
134
135
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 133

def add_custom_data opts={}
  @custom_data = prep(CustomDataObject, opts)
end

#add_key_person(opts = {}) ⇒ Object Also known as: add_principal_investigator



85
86
87
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 85

def add_key_person opts={}
  @key_personnel << prep(KeyPersonObject, opts)
end

#add_personnel_attachment(opts = {}) ⇒ Object



144
145
146
147
148
149
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 144

def add_personnel_attachment opts={}
  merge_settings(opts)
  p_a = make PersonnelAttachmentObject, opts
  p_a.add
  @personnel_attachments << p_a
end

#add_proposal_attachment(opts = {}) ⇒ Object



137
138
139
140
141
142
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 137

def add_proposal_attachment opts={}
  merge_settings(opts)
  p_a = make ProposalAttachmentObject, opts
  p_a.add
  @proposal_attachments << p_a
end

#add_special_review(opts = {}) ⇒ Object



124
125
126
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 124

def add_special_review opts={}
  @special_review << prep(SpecialReviewObject, opts)
end

#blanket_approveObject



248
249
250
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 248

def blanket_approve
  submit :ba
end

#closeObject



199
200
201
202
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 199

def close
  open_proposal
  on(Proposal).close
end

#complete_phs_fellowship_questionnaire(opts = {}) ⇒ Object



155
156
157
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 155

def complete_phs_fellowship_questionnaire opts={}
  @phs_fellowship_questionnaire = prep(PHSFellowshipQuestionnaireObject, opts)
end

#complete_phs_training_questionnaire(opts = {}) ⇒ Object



159
160
161
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 159

def complete_phs_training_questionnaire opts={}
  @phs_training_questionnaire = prep(PHSTrainingQuestionnaireObject, opts)
end

#complete_s2s_questionnaire(opts = {}) ⇒ Object



151
152
153
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 151

def complete_s2s_questionnaire opts={}
  @s2s_questionnaire = prep(S2SQuestionnaireObject, opts)
end

#createObject



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
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 42

def create
  on BasePage do |page|
    if page.windows.size > 1 && page.portal_window.exists?
      page.return_to_portal
      page.close_children
    elsif page.windows.size > 1
      page.use_new_tab
      page.close_parents
    end
  end
  visit(Researcher).create_proposal
  on Proposal do |doc|
    @doc_header=doc.doc_title
    @document_id=doc.document_id
    @status=doc.document_status
    @initiator=doc.initiator
    @created=doc.created
    doc.expand_all
    fill_out doc, :proposal_type, :activity_type,
                  :project_title, :project_start_date, :project_end_date,
                  :sponsor_deadline_date, :mail_by, :mail_type#, :description
    set_sponsor_code
    set_lead_unit
    doc.save
    @proposal_number=doc.proposal_number
    @permissions = make PermissionsObject, document_id: @document_id, aggregators: [@initiator]
  end
end

#deleteObject



175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 175

def delete
  proposal_actions
  on(ProposalActions).delete_proposal
  on(Confirmation).yes
  # Have to update the data object's status value
  # in a valid way (getting it from the system)
  visit DocumentSearch do |search|
    search.document_id.set @document_id
    search.search
    @status=search.doc_status @document_id
  end
end

#edit(opts = {}) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 71

def edit opts={}
  open_proposal
  on Proposal do |edit|
    edit.proposal
    edit.expand_all
    edit.project_start_date.fit opts[:project_start_date]
    edit.opportunity_id.fit opts[:opportunity_id]
    edit.proposal_type.fit opts[:proposal_type]
    # TODO: Add more stuff here as necessary
    edit.save
  end
  update_options(opts)
end

#make_institutional_proposalObject



163
164
165
166
167
168
169
170
171
172
173
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 163

def make_institutional_proposal
  # TODO: Write any preparatory web site functional steps and page scraping code
  ip = make InstitutionalProposalObject, dev_proposal_number: @proposal_number,
       proposal_type: @proposal_type,
       activity_type: @activity_type,
       project_title: @project_title,
       project_personnel: Marshal::load(Marshal.dump(@key_personnel)),
       special_review: Marshal::load(Marshal.dump(@special_review)),
       custom_data: Marshal::load(Marshal.dump(@custom_data))
       # TODO: Add more here as needed...
end

#open_proposalObject



244
245
246
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 244

def open_proposal
  open_document @doc_header
end

#recall(type, reason = random_alphanums) ⇒ Object



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

def recall(type, reason=random_alphanums)
  types={:revision=>:recall_to_action_list, :cancel=>:recall_and_cancel}
  @recall_reason=reason
  open_proposal
  on(Proposal).recall
  on Confirmation do |conf|
    conf.reason.set @recall_reason
    conf.send(types[type])
  end
end

#saveObject

Note: This method does not navigate because the assumption is that the only time you need to save the proposal is when you are on the proposal. You will never need to open the proposal and then immediately save it.



240
241
242
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 240

def save
  on(Proposal).save
end

#set_valid_credit_splitsObject

This method simply sets all the credit splits to equal values based on how many persons and units are attached to the Proposal. If more complicated credit splits are needed, these will have to be coded in the step def, accessing the key person objects directly.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 99

def set_valid_credit_splits
  # calculate a "person" split value that will work
  # based on the number of people attached...
  split = (100.0/@key_personnel.with_units.size).round(2)

  # Now make a hash to use for editing the person's splits...
  splits = {responsibility: split, financial: split, recognition: split, space: split}

  # Now we update the KeyPersonObjects' instance variables
  # for their own splits as well as for their units
  @key_personnel.with_units.each do |person|
    person.edit splits
    units_split = (100.0/person.units.size).round(2)
    # Make a temp container for the units we're updating...
    units = []
    person.units.each { |unit| units << {:number=>unit[:number]} }
    # Iterate through the units, updating their credit splits with the
    # valid split amount...
    units.each do |unit|
      [:responsibility, :financial, :recognition, :space].each { |item| unit[item]=units_split }
    end
    person.update_unit_credit_splits units
  end
end

#submit(type = :s) ⇒ Object



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 211

def submit(type=:s)
  types={:s=>:submit, :ba=>:blanket_approve,
         :to_sponsor=>:submit_to_sponsor, :to_s2s=>:submit_to_s2s}
  proposal_actions
  on(ProposalActions).send(types[type])
  if type==:to_sponsor
    on NotificationEditor do |page|
      # A breaking of the design pattern, here,
      # but we have no alternative...
      @status=page.document_status
      page.send_fyi
    end
  elsif type == :to_s2s
    on S2S do |page|
      @status=page.document_status
    end
  else
    on ProposalActions do |page|
      page.data_validation_header.wait_until_present
      @status=page.document_status
    end
  end
end

#view(tab) ⇒ Object



204
205
206
207
208
209
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 204

def view(tab)
  open_proposal
  unless @status=='CANCELED' || on(Proposal).send((tab.to_s+'_button').to_sym).parent.class_name=~/tabcurrent$/
    on(Proposal).send(tab)
  end
end