Class: Viewpoint::SPWS::Types::List

Inherits:
Object
  • Object
show all
Includes:
Viewpoint::SPWS::Types
Defined in:
lib/viewpoint/spws/types/list.rb

Overview

This class represents a Sharepoint List returned from the Lists Web Service

Direct Known Subclasses

DocumentLibrary, TasksList

Constant Summary

Constants included from Viewpoint::SPWS::Types

PRIORITY, STATUS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ws, xml) ⇒ List

Returns a new instance of List.

Parameters:

  • ws (Viewpoint::SPWS::Websvc::List)

    The webservice instance this List spawned from

  • xml (Nokogiri::XML::Element)

    the List element we are building from



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/viewpoint/spws/types/list.rb', line 29

def initialize(ws, xml)
  @ws             = ws
  @guid           = xml['ID']
  @title          = xml['Title']
  @description    = xml['Description']
  @hidden         = (xml['Hidden'] == 'True')
  @created        = DateTime.parse(xml['Created'])
  @modified       = DateTime.parse(xml['Modified'])
  @last_deleted   = DateTime.parse(xml['LastDeleted'])
  @item_count     = xml['ItemCount']
  @server_template= xml['ServerTemplate'].to_i
  @feature_id     = xml['FeatureId']
  @root_folder    = xml['RootFolder']
  #@xmldoc         = xml
  @list_path      = nil
end

Instance Attribute Details

#createdObject (readonly)

Returns the value of attribute created.



24
25
26
# File 'lib/viewpoint/spws/types/list.rb', line 24

def created
  @created
end

#descriptionObject (readonly)

Returns the value of attribute description.



24
25
26
# File 'lib/viewpoint/spws/types/list.rb', line 24

def description
  @description
end

#feature_idObject (readonly)

Returns the value of attribute feature_id.



24
25
26
# File 'lib/viewpoint/spws/types/list.rb', line 24

def feature_id
  @feature_id
end

#guidObject (readonly)

Returns the value of attribute guid.



24
25
26
# File 'lib/viewpoint/spws/types/list.rb', line 24

def guid
  @guid
end

#modifiedObject (readonly)

Returns the value of attribute modified.



24
25
26
# File 'lib/viewpoint/spws/types/list.rb', line 24

def modified
  @modified
end

#root_folderObject (readonly)

Returns the value of attribute root_folder.



24
25
26
# File 'lib/viewpoint/spws/types/list.rb', line 24

def root_folder
  @root_folder
end

#server_templateObject (readonly)

Returns the value of attribute server_template.



24
25
26
# File 'lib/viewpoint/spws/types/list.rb', line 24

def server_template
  @server_template
end

#titleObject (readonly)

Returns the value of attribute title.



24
25
26
# File 'lib/viewpoint/spws/types/list.rb', line 24

def title
  @title
end

Instance Method Details

#add_item!(opts) ⇒ Object

Add a ListItem

Parameters:

  • opts (Hash)

    options for List creation.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/viewpoint/spws/types/list.rb', line 57

def add_item!(opts)
  op = { :command => 'New', :id => 'New' }
  opts.keys.each do |k|
    case k
    when :priority
      op[k] = PRIORITY[opts[:priority]]
    when :status
      op[k] = STATUS[opts[:status]]
    when :percent_complete
      op[k] = opts[k] * 0.01
    else
      op[k] = opts[k]
    end
  end

  resp = @ws.update_list_items(@guid, :item_updates => [op])
  resp[:new].first
end

#delete!Object

Delete this List



77
78
79
# File 'lib/viewpoint/spws/types/list.rb', line 77

def delete!
  @ws.delete_list(@guid)
end

#get_item(item_id) ⇒ Object

Parameters:

  • item_id (String)

    The item id for the item you want to retrieve



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/viewpoint/spws/types/list.rb', line 87

def get_item(item_id)
  addl_fields = %w{LinkTitle Body AssignedTo Status Priority DueDate PercentComplete}

  i = @ws.get_list_items(@guid, :recursive => true, :view_fields => addl_fields) do |b|
    b.Query {
      b.Where {
        b.Eq {
          b.FieldRef(:Name => 'ID')
          b.Value(item_id, :Type => 'Counter')
        }
      }
    }
  end
  raise "Returned more than one item for #get_item" if(i.length > 1)
  i.first
end

#hidden?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/viewpoint/spws/types/list.rb', line 104

def hidden?
  @hidden
end

#itemsObject

Return the items in this List



82
83
84
# File 'lib/viewpoint/spws/types/list.rb', line 82

def items
  @ws.get_list_items(@guid)
end

#pathObject

Return the full-qualified path of this List



47
48
49
50
51
52
53
# File 'lib/viewpoint/spws/types/list.rb', line 47

def path
  return @list_path if @list_path
  site = @ws.spcon.site_base
  @list_path = "#{site.scheme}://#{site.host}"
  @list_path << ":#{site.port}" unless(site.port == 80 || site.port == 443)
  @list_path << @root_folder
end