Class: GoodData::UserFilter

Inherits:
MdObject show all
Defined in:
lib/gooddata/models/user_filters/user_filter.rb

Direct Known Subclasses

MandatoryUserFilter, VariableUserFilter

Constant Summary

Constants inherited from MdObject

MdObject::IDENTIFIERS_CFG, MdObject::MD_OBJ_CTG

Constants included from Mixin::MdIdToUri

Mixin::MdIdToUri::IDENTIFIERS_CFG

Constants included from Mixin::MdObjectIndexer

Mixin::MdObjectIndexer::MD_OBJ_CTG

Constants included from Mixin::MdObjectQuery

Mixin::MdObjectQuery::ERROR_MESSAGE_NO_PROJECT

Instance Attribute Summary

Attributes inherited from Rest::Object

#client, #json, #project

Instance Method Summary collapse

Methods inherited from MdObject

#add_tag, #browser_uri, #deprecated, #deprecated=, find_replaceable_values, #get_flag?, #listed?, #production, #production=, #project, #reload!, #remove_tag, replace, #replace, #replace!, replace_bracketed, replace_quoted, #restricted, #restricted=, #save, #save_as, #set_flag, #tag_set, #unlisted, #unlisted=, #validate

Methods included from Mixin::MdIdToUri

#identifier_to_uri

Methods included from Mixin::MdObjectIndexer

#[]

Methods included from Mixin::MdObjectQuery

#all, #dependency, #dependency?, #query, #usedby, #usedby?, #using, #using?

Methods included from Mixin::MdFinders

#find_by_identifier, #find_by_tag, #find_by_title, #find_first_by_identifier, #find_first_by_title

Methods included from Mixin::MdObjId

#uri_obj_id

Methods included from Mixin::MdGrantees

#change_permission, #grant, #grantees, #revoke

Methods included from Mixin::MdRelations

#dependency, #dependency?, #usedby, #usedby?, #using, #using?

Methods included from Mixin::ObjId

#obj_id

Methods included from Mixin::Links

#links

Methods inherited from Rest::Object

client, default_client, #saved?

Methods included from Mixin::DataPropertyReader

#data_property_reader

Methods included from Mixin::DataPropertyWriter

#data_property_writer

Methods included from Mixin::MetaPropertyReader

#metadata_property_reader

Methods included from Mixin::MetaPropertyWriter

#metadata_property_writer

Methods included from Mixin::MetaGetter

#meta

Methods included from Mixin::DataGetter

#data

Methods included from Mixin::RootKeyGetter

#root_key

Methods included from Mixin::ContentGetter

#content

Constructor Details

#initialize(data) ⇒ UserFilter

Returns a new instance of UserFilter.



9
10
11
12
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 9

def initialize(data)
  @dirty = false
  @json = GoodData::Helpers.symbolize_keys(data)
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



14
15
16
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 14

def ==(other)
  other.class == self.class && other.related_uri == related_uri && other.expression == expression
end

#deleteString

Deletes the filter from the server

Returns:

  • (String)


96
97
98
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 96

def delete
  client.delete(uri)
end

#expressionString

Returns the MAQL expression of the filter

Returns:

  • (String)

    MAQL expression



59
60
61
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 59

def expression
  @json[:expression]
end

#expression=(expression) ⇒ String

Allows to set the MAQL expression of the filter

Parameters:

  • expression (String)

    MAQL expression

Returns:

  • (String)

    MAQL expression



67
68
69
70
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 67

def expression=(expression)
  @dirty = true
  @json[:expression] = expression
end

#hashObject



19
20
21
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 19

def hash
  [related_uri, expression].hash
end

#levelSymbol

Returns the level this filter is applied on. Either project or user. This is useful for variables where you can have both types. Project level is the default that is applied when user does not have assigned a value. When both user and project value and user value is missing value, you will get 'uncomputable report' errors.

Returns:

  • (Symbol)

    level on which this filter will be applied



52
53
54
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 52

def level
  @json[:level].to_sym
end

#pretty_expressionString

Returns pretty version of the expression

Returns:

  • (String)


89
90
91
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 89

def pretty_expression
  SmallGoodZilla.pretty_print(expression, client: client, project: project)
end

Returns the the object of this filter is related to. It can be either project or a user

Returns:



33
34
35
36
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 33

def related(uri = related_uri)
  return unless uri
  level == :project ? client.projects(uri) : client.create(GoodData::Profile, client.get(uri))
end

Returns the uri of the object this filter is related to. It can be either project or a user

Returns:

  • (String)

    Uri of related object



26
27
28
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 26

def related_uri
  @json[:related]
end

#uriString

Gives you URI of the filter

Returns:

  • (String)


75
76
77
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 75

def uri
  @json[:uri]
end

#uri=(uri) ⇒ String

Allows to set URI of the filter

Returns:

  • (String)


82
83
84
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 82

def uri=(uri)
  @json[:uri] = uri
end

#variableGoodData::Project | GoodData::Profile

Returns the the object of this filter is related to. It can be either project or a user

Returns:



41
42
43
44
# File 'lib/gooddata/models/user_filters/user_filter.rb', line 41

def variable
  uri = @json[:prompt]
  GoodData::Variable[uri, client: client, project: project]
end