diff options
| author | Marc Florisson | 2013-01-03 17:30:15 +0100 |
|---|---|---|
| committer | Marc Florisson | 2013-01-03 17:30:15 +0100 |
| commit | e75205a04d6f915bc7f2fdbe66ac2d10e1334e46 (patch) | |
| tree | a525fc9b4ac3256f35fed5ce4a72eb891de1d142 /app/views/api | |
| parent | 32e6dcf8c87184f73e3010e32bc76b558a92d5ed (diff) | |
| download | chouette-core-e75205a04d6f915bc7f2fdbe66ac2d10e1334e46.tar.bz2 | |
fix api v1
Diffstat (limited to 'app/views/api')
| -rw-r--r-- | app/views/api/v1/companies/short_description.rabl | 6 | ||||
| -rw-r--r-- | app/views/api/v1/companies/show.rabl | 5 | ||||
| -rw-r--r-- | app/views/api/v1/connection_links/show.rabl | 21 | ||||
| -rw-r--r-- | app/views/api/v1/journey_patterns/short_description.rabl | 6 | ||||
| -rw-r--r-- | app/views/api/v1/journey_patterns/show.rabl | 31 | ||||
| -rw-r--r-- | app/views/api/v1/lines/short_description.rabl | 6 | ||||
| -rw-r--r-- | app/views/api/v1/lines/show.rabl | 18 | ||||
| -rw-r--r-- | app/views/api/v1/networks/short_description.rabl | 6 | ||||
| -rw-r--r-- | app/views/api/v1/networks/show.rabl | 7 | ||||
| -rw-r--r-- | app/views/api/v1/routes/short_description.rabl | 7 | ||||
| -rw-r--r-- | app/views/api/v1/routes/show.rabl | 37 | ||||
| -rw-r--r-- | app/views/api/v1/stop_areas/short_description.rabl | 10 | ||||
| -rw-r--r-- | app/views/api/v1/stop_areas/show.rabl | 24 | ||||
| -rw-r--r-- | app/views/api/v1/time_tables/show.rabl | 18 | ||||
| -rw-r--r-- | app/views/api/v1/trident_objects/short_description.rabl | 3 | ||||
| -rw-r--r-- | app/views/api/v1/trident_objects/show.rabl | 5 | ||||
| -rw-r--r-- | app/views/api/v1/vehicle_journeys/show.rabl | 36 |
17 files changed, 164 insertions, 82 deletions
diff --git a/app/views/api/v1/companies/short_description.rabl b/app/views/api/v1/companies/short_description.rabl new file mode 100644 index 000000000..4382f1f2e --- /dev/null +++ b/app/views/api/v1/companies/short_description.rabl @@ -0,0 +1,6 @@ +object @company +extends "api/v1/trident_objects/short_description" + +[ :name, :short_name, :registration_number].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/companies/show.rabl b/app/views/api/v1/companies/show.rabl index b7234081c..b2b064c54 100644 --- a/app/views/api/v1/companies/show.rabl +++ b/app/views/api/v1/companies/show.rabl @@ -1,5 +1,6 @@ object @company extends "api/v1/trident_objects/show" -attributes :name, :short_name, :organizational_unit, :operating_department_name -attributes :code, :phone, :fax, :email, :registration_number +[ :name, :short_name, :organizational_unit, :operating_department_name, :code, :phone, :fax, :email, :registration_number].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/connection_links/show.rabl b/app/views/api/v1/connection_links/show.rabl index ad3fae7dd..ce3410f83 100644 --- a/app/views/api/v1/connection_links/show.rabl +++ b/app/views/api/v1/connection_links/show.rabl @@ -1,13 +1,16 @@ object @connection_link extends "api/v1/trident_objects/show" -attributes :connection_link_type, :name, :comment -attributes :link_distance, :link_type, :default_duration, :frequent_traveller_duration, :occasional_traveller_duration -attributes :mobility_restricted_traveller_duration, :mobility_restricted_suitability, :stairs_availability, :lift_availability, :int_user_needs +[ :name, :link_distance, :link_type, :default_duration, + :frequent_traveller_duration, :occasional_traveller_duration, :mobility_restricted_traveller_duration, + :mobility_restricted_suitability, :stairs_availability, :lift_availability, :comment].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end -child :departure => :departure do - attributes :objectid, :name, :area_type, :longitude, :latitude, :long_lat_type -end -child :arrival => :arrival do - attributes :objectid, :name, :area_type, :longitude, :latitude, :long_lat_type -end +node :start_of_link_short_description do |connection| + partial("api/v1/stop_areas/short_description", :object => connection.departure) unless connection.departure.nil? +end + +node :end_of_link_short_description do |connection| + partial("api/v1/stop_areas/short_description", :object => connection.arrival) unless connection.arrival.nil? +end diff --git a/app/views/api/v1/journey_patterns/short_description.rabl b/app/views/api/v1/journey_patterns/short_description.rabl new file mode 100644 index 000000000..5932f85f7 --- /dev/null +++ b/app/views/api/v1/journey_patterns/short_description.rabl @@ -0,0 +1,6 @@ +object @journey_pattern +extends "api/v1/trident_objects/short_description" + +[ :name, :published_name, :registration_number].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/journey_patterns/show.rabl b/app/views/api/v1/journey_patterns/show.rabl index 60eed951c..882660360 100644 --- a/app/views/api/v1/journey_patterns/show.rabl +++ b/app/views/api/v1/journey_patterns/show.rabl @@ -1,22 +1,21 @@ object @journey_pattern extends "api/v1/trident_objects/show" -attributes :name, :comment, :registration_number -attributes :published_name - -child :route do - attributes :objectid, :name, :published_name, :number, :direction, :wayback -end -child :vehicle_journeys do |vj| - attributes :objectid +[:name, :published_name, :registration_number, :comment].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} end -child :stop_points => :stop_areas do |stop_point| - node(:stop_area) do |n| - { :objectid => n.stop_area.objectid, :name => n.stop_area.name, - :parent => n.stop_area.parent.objectid, - :area_type => n.stop_area.area_type, - :longitude => n.stop_area.longitude, :latitude => n.stop_area.latitude, - :long_lat_type => n.stop_area.long_lat_type} - end + +node(:route_short_description) do |journey_pattern| + partial("api/v1/routes/short_description", :object => journey_pattern.route) end +node(:vehicle_journey_object_ids) do |journey_pattern| + journey_pattern.vehicle_journeys.map(&:objectid) +end unless root_object.vehicle_journeys.empty? + +child :stop_points => :stop_area_short_descriptions do |stop_points| + node do |stop_point| + partial("api/v1/stop_areas/short_description", :object => stop_point.stop_area) + end +end unless root_object.stop_points.empty? + diff --git a/app/views/api/v1/lines/short_description.rabl b/app/views/api/v1/lines/short_description.rabl new file mode 100644 index 000000000..7d42e4584 --- /dev/null +++ b/app/views/api/v1/lines/short_description.rabl @@ -0,0 +1,6 @@ +object @line +extends "api/v1/trident_objects/short_description" + +[ :name, :published_name, :number, :registration_number].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/lines/show.rabl b/app/views/api/v1/lines/show.rabl index 9c36d13b1..dcd497aa5 100644 --- a/app/views/api/v1/lines/show.rabl +++ b/app/views/api/v1/lines/show.rabl @@ -1,12 +1,14 @@ object @line extends "api/v1/trident_objects/show" -attributes :name, :number, :published_name, :transport_mode_name -attributes :registration_number, :comment, :mobility_restricted_suitability, :int_user_needs - -child :network do - attributes :objectid, :name, :description, :registration_number +[ :name, :number, :published_name, :transport_mode_name, :registration_number, :comment, :mobility_restricted_suitability].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} end -child :company do - attributes :objectid, :name, :short_name, :registration_number -end +node :network_short_description do |line| + partial("api/v1/networks/short_description", :object => line.network) +end unless root_object.network.nil? + +node :company_short_description do |line| + partial("api/v1/companies/short_description", :object => line.company) +end unless root_object.company.nil? + diff --git a/app/views/api/v1/networks/short_description.rabl b/app/views/api/v1/networks/short_description.rabl new file mode 100644 index 000000000..9dc458064 --- /dev/null +++ b/app/views/api/v1/networks/short_description.rabl @@ -0,0 +1,6 @@ +object @network +extends "api/v1/trident_objects/short_description" + +[ :name, :description, :registration_number].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/networks/show.rabl b/app/views/api/v1/networks/show.rabl index 7869ef7ec..ae5915da2 100644 --- a/app/views/api/v1/networks/show.rabl +++ b/app/views/api/v1/networks/show.rabl @@ -1,4 +1,7 @@ object @network extends "api/v1/trident_objects/show" -attributes :version_date, :description, :name, :registration_number, :source_name -attributes :source_type, :source_identifier, :comment + +[ :version_date, :description, :name, :registration_number, :source_name, + :source_type, :source_identifier, :comment].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/routes/short_description.rabl b/app/views/api/v1/routes/short_description.rabl new file mode 100644 index 000000000..ae149167d --- /dev/null +++ b/app/views/api/v1/routes/short_description.rabl @@ -0,0 +1,7 @@ +object @route +extends "api/v1/trident_objects/short_description" + +[ :name, :published_name, :number, :direction, :wayback].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end + diff --git a/app/views/api/v1/routes/show.rabl b/app/views/api/v1/routes/show.rabl index 2e481432d..e3a7fdffa 100644 --- a/app/views/api/v1/routes/show.rabl +++ b/app/views/api/v1/routes/show.rabl @@ -1,24 +1,29 @@ object @route extends "api/v1/trident_objects/show" -attributes :direction_code, :wayback_code, :name -attributes :comment, :opposite_route_id, :published_name, :number, :direction, :wayback - -child :line do - attributes :objectid, :name, :published_name, :number, :registration_number +[:name, :published_name, :number, :direction].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} end +attributes :opposite_route_id => :way_back_route_id, :unless => lambda { |m| m.opposite_route_id.nil?} +attributes :comment, :unless => lambda { |m| m.comment.nil?} +attributes :wayback => :way_back, :unless => lambda { |m| m.wayback.nil?} -child :journey_patterns do |journey_pattern| - attributes :objectid, :name, :published_name, :registration_number +node :line_short_description do |route| + partial("api/v1/lines/short_description", :object => route.line) end -child :vehicle_journeys do |vj| - attributes :objectid -end +child :journey_patterns => :journey_pattern_short_descriptions do |journey_patterns| + node do |journey| + partial("api/v1/journey_patterns/short_description", :object => journey) + end +end unless root_object.journey_patterns.empty? -child :stop_areas do |stop_area| - attributes :objectid, :name, :area_type, :longitude, :latitude, :long_lat_type - glue stop_area.parent do - attributes :objectid => :parent - end -end +node(:vehicle_journey_object_ids) do |route| + route.vehicle_journeys.map(&:objectid) +end unless root_object.vehicle_journeys.empty? + +child :stop_areas => :stop_area_short_descriptions do |stop_areas| + node do |stop_area| + partial("api/v1/stop_areas/short_description", :object => stop_area) + end +end unless root_object.stop_areas.empty? diff --git a/app/views/api/v1/stop_areas/short_description.rabl b/app/views/api/v1/stop_areas/short_description.rabl new file mode 100644 index 000000000..73627c5a1 --- /dev/null +++ b/app/views/api/v1/stop_areas/short_description.rabl @@ -0,0 +1,10 @@ +object @stop_area +extends "api/v1/trident_objects/short_description" + +[ :name, :area_type, :longitude, :latitude, :long_lat_type].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end +node(:parent_object_id) do |stop_area| + stop_area.parent.objectid +end unless root_object.parent.nil? + diff --git a/app/views/api/v1/stop_areas/show.rabl b/app/views/api/v1/stop_areas/show.rabl index db0f628bb..976d96342 100644 --- a/app/views/api/v1/stop_areas/show.rabl +++ b/app/views/api/v1/stop_areas/show.rabl @@ -1,11 +1,21 @@ object @stop_area extends "api/v1/trident_objects/show" -attributes :routing_stop_ids, :routing_line_ids -attributes :name, :comment, :area_type, :registration_number -attributes :nearest_topic_name, :fare_code, :longitude, :latitude, :long_lat_type, :x, :y, :projection_type -attributes :country_code, :street_name - -child :parent => :parent do - attributes :objectid, :name, :area_type, :longitude, :latitude, :long_lat_type +[ :name, :area_type,:nearest_topic_name, :fare_code, :registration_number, + :longitude, :latitude, :long_lat_type, + :country_code, :street_name, :x, :y, :projection_type, :comment +].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} end + +node(:routing_stop_area_object_ids) do |stop_area| + stop_area.routing_stops.map(&:objectid) +end unless root_object.routing_stops.empty? + +node(:routing_line_object_ids) do |stop_area| + stop_area.routing_lines.map(&:objectid) +end unless root_object.routing_lines.empty? + +node :parent do |stop_area| + partial("api/v1/stop_areas/short_description", :object => stop_area.parent) +end unless root_object.parent.nil? diff --git a/app/views/api/v1/time_tables/show.rabl b/app/views/api/v1/time_tables/show.rabl index 90c5bc12c..ae1e6e180 100644 --- a/app/views/api/v1/time_tables/show.rabl +++ b/app/views/api/v1/time_tables/show.rabl @@ -1,14 +1,18 @@ object @time_table extends "api/v1/trident_objects/show" -attributes :version, :comment -attributes :monday,:tuesday,:wednesday,:thursday,:friday,:saturday,:sunday - -child :dates => :dates do |date| - attributes :date, :position +[ :version, :comment].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} end -child :periods => :periods do |period| - attributes :period_start, :period_end +node(:dates) do |time_table| + time_table.dates.map(&:date) +end unless root_object.dates.empty? + +unless root_object.periods.empty? + attributes :monday,:tuesday,:wednesday,:thursday,:friday,:saturday,:sunday + child :periods => :periods do |period| + attributes :period_start, :period_end + end end diff --git a/app/views/api/v1/trident_objects/short_description.rabl b/app/views/api/v1/trident_objects/short_description.rabl new file mode 100644 index 000000000..09f829850 --- /dev/null +++ b/app/views/api/v1/trident_objects/short_description.rabl @@ -0,0 +1,3 @@ +attributes :objectid => :object_id +attributes :object_version + diff --git a/app/views/api/v1/trident_objects/show.rabl b/app/views/api/v1/trident_objects/show.rabl index 4f28ac822..7d58d9a55 100644 --- a/app/views/api/v1/trident_objects/show.rabl +++ b/app/views/api/v1/trident_objects/show.rabl @@ -1,2 +1,5 @@ -attributes :objectid, :object_version, :creation_time, :creator_id +attributes :objectid => :object_id +[ :object_version, :creation_time, :creator_id].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end diff --git a/app/views/api/v1/vehicle_journeys/show.rabl b/app/views/api/v1/vehicle_journeys/show.rabl index 488fb4766..e7288fffb 100644 --- a/app/views/api/v1/vehicle_journeys/show.rabl +++ b/app/views/api/v1/vehicle_journeys/show.rabl @@ -1,24 +1,32 @@ object @vehicle_journey extends "api/v1/trident_objects/show" -attributes :comment, :status_value -attributes :transport_mode, :published_journey_name, :published_journey_identifier, :facility, :vehicle_type_identifier, :number - -child :route do - attributes :objectid, :name, :published_name, :number, :direction, :wayback -end +[ :published_journey_name, :published_journey_identifier, :transport_mode, :vehicle_type_identifier, :status_value, :facility, :number, :comment].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end -child :journey_pattern do - attributes :objectid, :name, :published_name, :registration_number +node(:route_short_description) do |vehicle| + partial("api/v1/routes/short_description", :object => vehicle.route) end -child :time_tables do - attributes :objectid +node(:journey_pattern_short_description) do |vehicle| + partial("api/v1/routes/short_description", :object => vehicle.journey_pattern) end -child :vehicle_journey_at_stops do |vjas| - attributes :position, :connecting_service_id, :boarding_alighting_possibility, :arrival_time, :departure_time, :waiting_time, :elapse_duration, :headway_frequency - node(:stop_area) do |vjas| - {:objectid => vjas.stop_point.stop_area.objectid} +node(:time_table_object_ids) do |vehicle| + vehicle.time_tables.map(&:objectid) +end unless root_object.time_tables.empty? + +child :vehicle_journey_at_stops do |vehicle_stops| + node do |vehicle_stop| + node(:stop_area_object_id) { vehicle_stop.stop_point.stop_area.objectid } + + [ :connecting_service_id, :arrival_time, :departure_time, :waiting_time, :elapse_duration, + :headway_frequency, :boarding_alighting_possibility].each do |attr| + node( attr) do + vehicle_stop.send(attr) + end unless vehicle_stop.send(attr).nil? + end + attributes :order => vehicle_stop.position, :unless => lambda { |m| m.send( :position).nil?} end end |
