lib/place/work_item.rb
# Retrieve a specific workitem (based on wid and url only)
Retrieve a specific workitem (based on wid and url only)
Retrieve a specific workitem ( based on wid and url only )
def retrieve
    content = IO.readlines(url).join('')
	doc = Nokogiri::XML(content)
    doc.xpath('//work-item/field').each do |field|
      self[field.attributes['id'].to_s] = field.content
    end
    self.type = self[:type]
	self.author = User.find_by_name(self[:author])
	unless self[:assignee].nil?
	  self[:assignee].split.each do |name|
	    u = User.find_by_name(name)
		unless u.nil?
	      self.assignees << u
		  u.assignments << self  
		end
	  end
	end
	self.timepoint = TimePoint.find_by_tid(self['timePoint'])
	%w(initialEstimate timeSpent remainingEstimate).each do |t|
	  self[t] = to_hours(self[t])
	end
    doc.xpath('/work-item/field[@id="linkedWorkItems"]/list/struct').each do |struct|
	  l = Link.create(
		:role		=> struct.xpath('item[@id="role"]').text,
		:suspect	=> struct.xpath('item[@id="suspect"]').text == 'true' ? true : false,
		:revision	=> struct.xpath('item[@id="revision"]').empty? ? false : true,
		:from		=> self,
		:to			=> WorkItem.find_by_wid(struct.xpath('item[@id="workItem"]').text),
		:from_wid	=> self.wid,
		:to_wid		=> struct.xpath('item[@id="workItem"]').text
		)
	end
	Dir.glob(File.dirname(url) + '/comment-*.xml').each do |filename|
	  c = Comment.create(:url => filename)
	  c.retrieve
	end
	Dir.glob(File.dirname(url) + '/workrecord-*.xml').each do |filename|
	  wr = WorkRecord.create(:url => filename)
	  wr.retrieve
	end
	Place.logger.info("retrieved workitem #{self.wid}")	
	self.save
  end
def retrieve content = IO . readlines ( url ) . join ( '' ) doc = Nokogiri :: XML ( content ) doc . xpath ( '//work-item/field' ) . each do | field | self [ field . attributes [ 'id' ] . to_s ] = field . content end self . type = self [ :type ] self . author = User . find_by_name ( self [ :author ] ) unless self [ :assignee ] . nil? self [ :assignee ] . split . each do | name | u = User . find_by_name ( name ) unless u . nil? self . assignees << u u . assignments << self end end end self . timepoint = TimePoint . find_by_tid ( self [ 'timePoint' ] ) %w( initialEstimate timeSpent remainingEstimate ) . each do | t | self [ t ] = to_hours ( self [ t ] ) end doc . xpath ( '/work-item/field[@id="linkedWorkItems"]/list/struct' ) . each do | struct | l = Link . create ( :role => struct . xpath ( 'item[@id="role"]' ) . text , :suspect => struct . xpath ( 'item[@id="suspect"]' ) . text == 'true' ? true : false , :revision => struct . xpath ( 'item[@id="revision"]' ) . empty? ? false : true , :from => self , :to => WorkItem . find_by_wid ( struct . xpath ( 'item[@id="workItem"]' ) . text ) , :from_wid => self . wid , :to_wid => struct . xpath ( 'item[@id="workItem"]' ) . text ) end Dir . glob ( File . dirname ( url ) + '/comment-*.xml' ) . each do | filename | c = Comment . create ( :url => filename ) c . retrieve end Dir . glob ( File . dirname ( url ) + '/workrecord-*.xml' ) . each do | filename | wr = WorkRecord . create ( :url => filename ) wr . retrieve end Place . logger . info ( "retrieved workitem #{self.wid}" ) self . save end
Retrieve a specific workitem (based on wid and url only)
Retrieve a specific workitem ( based on wid and url only )
# links # comments # workrecords