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, #fill_out_item, #on_document?, #on_page?, #open_document, #window_cleanup

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:         collection('KeyPersonnel'),
    special_review:        collection('SpecialReview'),
    budget_versions:       collection('BudgetVersions'),
    personnel_attachments: collection('PersonnelAttachments'),
    proposal_attachments:  collection('ProposalAttachments')
  }

  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



121
122
123
124
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 121

def add_budget_version opts={}
  opts[:version] ||= (@budget_versions.size+1).to_s
  @budget_versions.add merge_settings(opts)
end

#add_custom_data(opts = {}) ⇒ Object



126
127
128
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 126

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

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



78
79
80
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 78

def add_key_person opts={}
  @key_personnel.add merge_settings(opts)
end

#add_personnel_attachment(opts = {}) ⇒ Object



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

def add_personnel_attachment opts={}
  @personnel_attachments.add merge_settings(opts)
end

#add_proposal_attachment(opts = {}) ⇒ Object



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

def add_proposal_attachment opts={}
  @proposal_attachments.add merge_settings(opts)
end

#add_special_review(opts = {}) ⇒ Object



117
118
119
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 117

def add_special_review opts={}
  @special_review.add merge_settings(opts)
end

#blanket_approveObject



250
251
252
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 250

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



142
143
144
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 142

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

#complete_phs_training_questionnaire(opts = {}) ⇒ Object



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

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

#complete_s2s_questionnaire(opts = {}) ⇒ Object



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

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

def create
  window_cleanup
  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



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 170

def delete
  view '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



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 63

def edit opts={}
  open_proposal
  on Proposal do |edit|
    edit.proposal
    edit.expand_all
    edit.project_title.fit opts[:project_title]
    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



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 150

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,
       special_review: Marshal::load(Marshal.dump(@special_review)),
       custom_data: Marshal::load(Marshal.dump(@custom_data))
  @key_personnel.each do |person|
    project_person = make ProjectPersonnelObject, full_name: person[:full_name],
                          first_name: person[:first_name], last_name: person[:last_name],
                          lead_unit: person[:home_unit], role: person[:role],
                          project_role: person[:key_person_role], units: person[:units],
                          responsibility: person[:responsibility], space: person[:space],
                          financial: person[:financial], recognition: person[:recognition]
    ip.project_personnel << project_person
  end
  # TODO: Add more here as needed...
end

#open_proposalObject

TODO: Make this private. Step defs should use #view!



246
247
248
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 246

def open_proposal
  open_document @doc_header
end

#recall(reason = random_alphanums) ⇒ Object



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

def recall(reason=random_alphanums)
  @recall_reason=reason
  open_proposal
  on(Proposal).recall
  on Confirmation do |conf|
    conf.reason.set @recall_reason
    conf.yes
  end
  open_proposal
  @status=on(Proposal).document_status
end

#rejectObject



195
196
197
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 195

def reject
  # TODO - Coeus is buggy right now
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.



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

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.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/kuality-coeus/data_objects/proposal_development/proposal_development.rb', line 92

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
234
# 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}
  view '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
    view :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(StringFactory.damballa("#{tab}_button")).parent.class_name=~/tabcurrent$/
    on(Proposal).send(StringFactory.damballa(tab.to_s))
  end
end