Class: GoodData::MandatoryUserFilter
- Inherits:
-
UserFilter
- Object
- Rest::Object
- Rest::Resource
- MdObject
- UserFilter
- GoodData::MandatoryUserFilter
- Defined in:
- lib/gooddata/models/user_filters/mandatory_user_filter.rb
Constant Summary
Constants inherited from MdObject
GoodData::MdObject::IDENTIFIERS_CFG, GoodData::MdObject::MD_OBJ_CTG
Constants included from GoodData::Mixin::MdIdToUri
GoodData::Mixin::MdIdToUri::IDENTIFIERS_CFG
Constants included from GoodData::Mixin::MdObjectIndexer
GoodData::Mixin::MdObjectIndexer::MD_OBJ_CTG
Constants included from GoodData::Mixin::MdObjectQuery
GoodData::Mixin::MdObjectQuery::ERROR_MESSAGE_NO_PROJECT
Instance Attribute Summary
Attributes inherited from Rest::Object
Class Method Summary collapse
- .[](id, options = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
- .all(options = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
- .count(options = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
Instance Method Summary collapse
- #related ⇒ Object
-
#save ⇒ GoodData::MandatoryUserFilter
Creates or updates the mandatory user filter on the server.
Methods inherited from UserFilter
#==, #delete, #expression, #expression=, #hash, #initialize, #level, #pretty_expression, #related_uri, #uri, #uri=, #variable
Methods inherited from MdObject
#==, #add_tag, #browser_uri, #delete, #deprecated, #deprecated=, find_replaceable_values, #get_flag?, #initialize, #listed?, #production, #production=, #project, #reload!, #remove_tag, replace, #replace, #replace!, replace_bracketed, replace_quoted, #restricted, #restricted=, #save_as, #set_flag, #tag_set, #unlisted, #unlisted=, #validate
Methods included from GoodData::Mixin::MdIdToUri
Methods included from GoodData::Mixin::MdObjectIndexer
Methods included from GoodData::Mixin::MdObjectQuery
#all, #dependency, #dependency?, #query, #usedby, #usedby?, #using, #using?
Methods included from GoodData::Mixin::MdFinders
#find_by_identifier, #find_by_tag, #find_by_title, #find_first_by_identifier, #find_first_by_title
Methods included from GoodData::Mixin::MdObjId
Methods included from GoodData::Mixin::MdGrantees
#change_permission, #grant, #grantees, #revoke
Methods included from GoodData::Mixin::MdRelations
#dependency, #dependency?, #usedby, #usedby?, #using, #using?
Methods included from GoodData::Mixin::ObjId
Methods included from GoodData::Mixin::Links
Methods inherited from Rest::Resource
Methods inherited from Rest::Object
client, default_client, #initialize, #saved?
Methods included from GoodData::Mixin::DataPropertyReader
Methods included from GoodData::Mixin::DataPropertyWriter
Methods included from GoodData::Mixin::MetaPropertyReader
Methods included from GoodData::Mixin::MetaPropertyWriter
Methods included from GoodData::Mixin::MetaGetter
Methods included from GoodData::Mixin::DataGetter
Methods included from GoodData::Mixin::RootKeyGetter
Methods included from GoodData::Mixin::ContentGetter
Constructor Details
This class inherits a constructor from GoodData::UserFilter
Class Method Details
.[](id, options = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/gooddata/models/user_filters/mandatory_user_filter.rb', line 12 def [](id, = { client: GoodData.connection, project: GoodData.project }) if id == :all all() else super end end |
.all(options = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gooddata/models/user_filters/mandatory_user_filter.rb', line 20 def all( = { client: GoodData.connection, project: GoodData.project }) c = client() project = [:project] filters = query('userFilter', nil, ) count = 1_000 offset = 0 user_lookup = {} loop do result = c.get("/gdc/md/#{project.pid}/userfilters?count=#{count}&offset=#{offset}") result['userFilters']['items'].each do |item| item['userFilters'].each do |f| user_lookup[f] = user_lookup[f] ? Array(user_lookup[f]).concat([item['user']]) : item['user'] end end break if result['userFilters']['length'] < offset offset += count end mufs = filters.map do |filter_data| payload = { 'expression' => filter_data['userFilter']['content']['expression'], 'related' => user_lookup[filter_data['userFilter']['meta']['uri']], 'level' => :user, 'type' => :filter, 'uri' => filter_data['userFilter']['meta']['uri'] } c.create(GoodData::MandatoryUserFilter, payload, project: project) end mufs.enum_for end |
.count(options = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
50 51 52 53 54 |
# File 'lib/gooddata/models/user_filters/mandatory_user_filter.rb', line 50 def count( = { client: GoodData.connection, project: GoodData.project }) c = client() project = [:project] c.get(project.md['query'] + '/userfilters/')['query']['entries'].count end |
Instance Method Details
#related ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/gooddata/models/user_filters/mandatory_user_filter.rb', line 76 def if .is_a? Array .map { |u| super u } else super end end |
#save ⇒ GoodData::MandatoryUserFilter
Creates or updates the mandatory user filter on the server
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/gooddata/models/user_filters/mandatory_user_filter.rb', line 60 def save data = { 'userFilter' => { 'content' => { 'expression' => expression }, 'meta' => { 'category' => 'userFilter', 'title' => } } } res = client.post(project.md['obj'], data) @json[:uri] = res['uri'] end |