Class: Viewpoint::SPWS::Types::ListItem
- Inherits:
-
Object
- Object
- Viewpoint::SPWS::Types::ListItem
- Includes:
- Viewpoint::SPWS::Types
- Defined in:
- lib/viewpoint/spws/types/list_item.rb
Overview
This class represents a Sharepoint ListItem returned from the Lists Web Service
Constant Summary
Constants included from Viewpoint::SPWS::Types
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#created_date ⇒ Object
readonly
Returns the value of attribute created_date.
-
#due_date ⇒ Object
readonly
Returns the value of attribute due_date.
-
#editor ⇒ Object
readonly
Returns the value of attribute editor.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#file_ref ⇒ Object
readonly
Returns the value of attribute file_ref.
-
#guid ⇒ Object
readonly
Returns the value of attribute guid.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#link_title ⇒ Object
readonly
Returns the value of attribute link_title.
-
#modified_date ⇒ Object
readonly
Returns the value of attribute modified_date.
-
#object_type ⇒ Object
readonly
Returns the value of attribute object_type.
-
#percent_complete ⇒ Object
readonly
Returns the value of attribute percent_complete.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#assign(user) ⇒ Object
Assign this item to a user.
-
#assign!(user) ⇒ Object
Assign this item to a user.
-
#delete! ⇒ Object
Delete this ListItem.
-
#initialize(ws, list_id, xml) ⇒ ListItem
constructor
A new instance of ListItem.
-
#rename(title) ⇒ Object
Set a new title for this Item.
-
#rename!(title) ⇒ Object
Set a new title for this Item.
-
#save! ⇒ Object
Save any pending changes.
-
#set_percent_complete(pct) ⇒ Object
Set the percentage complete of this item.
-
#set_percent_complete!(pct) ⇒ Object
Set the percentage complete of this item.
-
#set_priority(priority) ⇒ Object
Set the priority of this Item.
-
#set_priority!(priority) ⇒ Object
Set the priority of this Item.
-
#set_status(status) ⇒ Object
Set the status of this Item.
-
#set_status!(status) ⇒ Object
Set the status of this Item.
-
#update! {|_self| ... } ⇒ Object
Pass a block of updates that will be committed in one transaction.
Constructor Details
#initialize(ws, list_id, xml) ⇒ ListItem
Returns a new instance of ListItem.
31 32 33 34 35 36 37 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 31 def initialize(ws, list_id, xml) @ws = ws @list_id = list_id @pending_updates = [] # a place to store updates before #save! is called @update_keys = {} # the variables to update after #save! parse_xml_fields(xml) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
24 25 26 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 24 def body @body end |
#created_date ⇒ Object (readonly)
Returns the value of attribute created_date.
25 26 27 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 25 def created_date @created_date end |
#due_date ⇒ Object (readonly)
Returns the value of attribute due_date.
25 26 27 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 25 def due_date @due_date end |
#editor ⇒ Object (readonly)
Returns the value of attribute editor.
24 25 26 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 24 def editor @editor end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
24 25 26 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 24 def file_name @file_name end |
#file_ref ⇒ Object (readonly)
Returns the value of attribute file_ref.
24 25 26 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 24 def file_ref @file_ref end |
#guid ⇒ Object (readonly)
Returns the value of attribute guid.
24 25 26 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 24 def guid @guid end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
24 25 26 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 24 def id @id end |
#link_title ⇒ Object (readonly)
Returns the value of attribute link_title.
26 27 28 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 26 def link_title @link_title end |
#modified_date ⇒ Object (readonly)
Returns the value of attribute modified_date.
25 26 27 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 25 def modified_date @modified_date end |
#object_type ⇒ Object (readonly)
Returns the value of attribute object_type.
24 25 26 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 24 def object_type @object_type end |
#percent_complete ⇒ Object (readonly)
Returns the value of attribute percent_complete.
26 27 28 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 26 def percent_complete @percent_complete end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
26 27 28 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 26 def priority @priority end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
26 27 28 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 26 def status @status end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
26 27 28 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 26 def title @title end |
Instance Method Details
#assign(user) ⇒ Object
should I return the String representation of the user or the Types::User?
Assign this item to a user
158 159 160 161 162 163 164 165 166 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 158 def assign(user) raise "There is already a pending assignment" if @update_keys[:@assigned_to] upd = { :id => @id, :command => 'Update', :AssignedTo => "#{user.id};##{user.login_name}", } @pending_updates << upd @update_keys[:@assigned_to] = 'ows_AssignedTo' user end |
#assign!(user) ⇒ Object
Assign this item to a user
170 171 172 173 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 170 def assign!(user) assign(user) save! end |
#delete! ⇒ Object
Delete this ListItem
63 64 65 66 67 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 63 def delete! del = [{ :id => @id, :command => 'Delete', :file_ref => full_file_ref }] @ws.update_list_items(@list_id, :item_updates => del) end |
#rename(title) ⇒ Object
Set a new title for this Item
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 72 def rename(title) raise "There is already a pending rename" if @update_keys[:@title] upd = { :id => @id, :command => 'Update', :title => title, } @pending_updates << upd @update_keys[:@title] = 'ows_Title' @update_keys[:@link_title] = 'ows_LinkTitle' title end |
#rename!(title) ⇒ Object
Set a new title for this Item
85 86 87 88 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 85 def rename!(title) rename(title) save! end |
#save! ⇒ Object
Save any pending changes
40 41 42 43 44 45 46 47 48 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 40 def save! return true if @pending_updates.empty? resp = @ws.update_list_items(@list_id, :item_updates => @pending_updates) # @todo check for success before emptying Arry update_local_vars resp[:update][0] @pending_updates.clear true resp end |
#set_percent_complete(pct) ⇒ Object
Set the percentage complete of this item.
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 134 def set_percent_complete(pct) if(!(0..100).include?(pct)) raise "Invalid :percent_complete #{topts[:percent_complete]}" end raise "There is already a pending percent complete change" if @update_keys[:@percent_complete] upd = { :id => @id, :command => 'Update', :percent_complete => pct, } @pending_updates << upd @update_keys[:@percent_complete] = 'ows_PercentComplete' pct end |
#set_percent_complete!(pct) ⇒ Object
Set the percentage complete of this item.
150 151 152 153 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 150 def set_percent_complete!(pct) set_percent_complete pct save! end |
#set_priority(priority) ⇒ Object
Set the priority of this Item
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 93 def set_priority(priority) raise "Invalid priority it must be one of: #{PRIORITY.keys.join(', ')}" unless PRIORITY[priority] raise "There is already a pending priority change" if @update_keys[:@priority] upd = { :id => @id, :command => 'Update', :priority => PRIORITY[priority], } @pending_updates << upd @update_keys[:@priority] = 'ows_Priority' priority end |
#set_priority!(priority) ⇒ Object
Set the priority of this Item
106 107 108 109 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 106 def set_priority!(priority) set_priority priority save! end |
#set_status(status) ⇒ Object
Set the status of this Item
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 114 def set_status(status) raise "Invalid status it must be one of: #{STATUS.keys.join(', ')}" unless STATUS[status] raise "There is already a pending status change" if @update_keys[:@status] upd = { :id => @id, :command => 'Update', :status => STATUS[status], } @pending_updates << upd @update_keys[:@status] = 'ows_Status' status end |
#set_status!(status) ⇒ Object
Set the status of this Item
127 128 129 130 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 127 def set_status!(status) set_status(status) save! end |
#update! {|_self| ... } ⇒ Object
Pass a block of updates that will be committed in one transaction
57 58 59 60 |
# File 'lib/viewpoint/spws/types/list_item.rb', line 57 def update! yield self if block_given? save! end |