map { |memb| [memb[0], ids[memb[0]][memb[1].to_i] || memb[1], memb[2]] }
return r
end
+
+ def read
+ begin
+ changeset = Changeset.find(params[:id])
+ render :text => changeset.to_xml.to_s, :content_type => "text/xml"
+ rescue ActiveRecord::RecordNotFound
+ render :nothing => true, :status => :not_found
+ end
+ end
def upload
if not request.put?
end
end
end
+
+ def to_xml
+ doc = OSM::API.new.get_xml_doc
+ doc.root << to_xml_node()
+ return doc
+ end
+ def to_xml_node(user_display_name_cache = nil)
+ el1 = XML::Node.new 'changeset'
+ el1['id'] = self.id.to_s
+
+ user_display_name_cache = {} if user_display_name_cache.nil?
+
+ if user_display_name_cache and user_display_name_cache.key?(self.user_id)
+ # use the cache if available
+ elsif self.user.data_public?
+ user_display_name_cache[self.user_id] = self.user.display_name
+ else
+ user_display_name_cache[self.user_id] = nil
+ end
+
+ el1['user'] = user_display_name_cache[self.user_id] unless user_display_name_cache[self.user_id].nil?
+
+ self.tags.each do |k,v|
+ el2 = XML::Node.new('tag')
+ el2['k'] = k.to_s
+ el2['v'] = v.to_s
+ el1 << el2
+ end
+
+ el1['created_at'] = self.created_at.xmlschema
+
+ return el1
+ end
end
# API
map.connect "api/#{API_VERSION}/changeset/create", :controller => 'changeset', :action => 'create'
+ map.connect "api/#{API_VERSION}/changeset/:id", :controller => 'changeset', :action => 'read'
map.connect "api/#{API_VERSION}/changeset/upload", :controller => 'changeset', :action => 'upload'
map.connect "api/#{API_VERSION}/node/create", :controller => 'node', :action => 'create'