lib/gooddata/models/metadata/report_definition.rb in gooddata-0.6.3 vs lib/gooddata/models/metadata/report_definition.rb in gooddata-0.6.4
- old
+ new
@@ -9,18 +9,17 @@
# TODO: Add more doc ...
class ReportDefinition < GoodData::MdObject
root_key :reportDefinition
class << self
- def [](id, options = {})
- if id == :all
- uri = GoodData.project.md['query'] + '/reportdefinition/'
- result = GoodData.get(uri)
- result['query']['entries']
- else
- super
- end
+ # Method intended to get all objects of that type in a specified project
+ #
+ # @param options [Hash] the options hash
+ # @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default
+ # @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
+ def all(options = {})
+ query('reportdefinition', ReportDefinition, options)
end
def create_metrics_part(left, top)
stuff = Array(left) + Array(top)
stuff.select { |item| item.respond_to?(:metric?) && item.metric? }.map do |metric|
@@ -70,11 +69,11 @@
fail "Object given by id \"#{item}\" could not be found" if x.nil?
case x.raw_data.keys.first.to_s
when 'attribute'
GoodData::Attribute.new(x.raw_data).display_forms.first
when 'attributeDisplayForm'
- GoodData::DisplayForm.new(x.raw_data)
+ GoodData::Label.new(x.raw_data)
when 'metric'
GoodData::Metric.new(x.raw_data)
end
elsif item.is_a?(Hash) && item.keys.include?(:title)
case item[:type].to_s
@@ -89,20 +88,20 @@
when 'metric'
GoodData::Metric.get_by_id(item[:id])
when 'attribute'
GoodData::Attribute.get_by_id(item[:id]).display_forms.first
when 'label'
- GoodData::DisplayForm.get_by_id(item[:id])
+ GoodData::Label.get_by_id(item[:id])
end
elsif item.is_a?(Hash) && (item.keys.include?(:identifier))
case item[:type].to_s
when 'metric'
GoodData::Metric.get_by_id(item[:identifier])
when 'attribute'
result = GoodData::Attribute.get_by_id(item[:identifier])
result.display_forms.first
when 'label'
- GoodData::DisplayForm.get_by_id(item[:identifier])
+ GoodData::Label.get_by_id(item[:identifier])
end
else
item
end
end