Class: GoodData::Model::SchemaBlueprint

Inherits:
Object
  • Object
show all
Defined in:
lib/gooddata/models/blueprint/schema_blueprint.rb

Direct Known Subclasses

DatasetBlueprint, DateDimension

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dim, blueprint) ⇒ SchemaBlueprint

Returns a new instance of SchemaBlueprint.



12
13
14
15
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 12

def initialize(dim, blueprint)
  @data = dim
  @project_blueprint = blueprint
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



10
11
12
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 10

def data
  @data
end

#project_blueprintObject

Returns the value of attribute project_blueprint.



10
11
12
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 10

def project_blueprint
  @project_blueprint
end

Instance Method Details

#==(other) ⇒ Boolean

Compares two blueprints. This is done by comapring the hash represenatation. It has to be exacty identical including the order of the columns

Parameters:

Returns:

  • (Boolean)

    matching fields



158
159
160
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 158

def ==(other)
  to_hash == other.to_hash
end

#anchorGoodData::Model::AnchorBlueprintField

Returns anchor

Returns:



27
28
29
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 27

def anchor
  nil
end

#anchor?Boolean

Returns true if anchor is present. Currently returns always true. Probably good to remove

Returns:

  • (Boolean)

    is anchor on schema?l70



20
21
22
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 20

def anchor?
  true
end

#attributes(_id = :all, _options = {}) ⇒ Array<GoodData::Model::AttributeBlueprintField>

Returns list of all attributes defined on the schema.

Returns:



55
56
57
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 55

def attributes(_id = :all, _options = {})
  []
end

#attributes_and_anchorsArray<GoodData::Model::AnchorBlueprintField | GoodData::Model::AttributeBlueprintField>

Returns list of attributes and anchor.



76
77
78
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 76

def attributes_and_anchors
  []
end

#breaksArray<GoodData::Model::AnchorBlueprintField | GoodData::Model::AttributeBlueprintField>

Returns list of attributes that are broken by attributes in this dataset. This means all anchors and attributes from this dataset and the ones that are referenced by any dataset. It works transitively. Includes only anchors that have labels.



96
97
98
99
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 96

def breaks
  attrs = attributes_and_anchors.reject { |a| a.labels.empty? }
  referenced_by.empty? ? attrs : attrs + referenced_by.flat_map(&:breaks)
end

#bridgesArray<GoodData::Model::BridgeBlueprintField>

Returns list of all bridges defined on the schema.

Returns:



41
42
43
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 41

def bridges
  []
end

#broken_byArray<GoodData::Model::BlueprintField>

Returns list of attributes that can break facts in a given dataset. This basically means that it is giving you all attributes from this dataset and datasets that are referenced by given dataset transitively. Includes only anchors that have labels.



86
87
88
89
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 86

def broken_by
  attrs = attributes_and_anchors.reject { |a| a.labels.empty? }
  attrs + references.map(&:dataset).flat_map(&:broken_by)
end

#facts(_id = :all, _options = {}) ⇒ Array<GoodData::Model::FactBlueprintField>

Returns list of all facts defined on the schema.

Returns:



48
49
50
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 48

def facts(_id = :all, _options = {})
  []
end

#fieldsArray<GoodData::Model::BlueprintField>

Returns list of all fields defined on the schema.

Returns:



69
70
71
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 69

def fields
  []
end

#find_dataset(dataset, options = {}) ⇒ GoodData::Model::DatasetBlueprint

Relays request on finding a dataset in the associated project blueprint. Used by reference fields

Parameters:

  • dataset (String)

    Name of a dataset

  • options (Hash) (defaults to: {})

    additional options. See ProjectBlueprint form more

Returns:



106
107
108
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 106

def find_dataset(dataset, options = {})
  project_blueprint.find_dataset(dataset, options)
end

#idString

Returns id of the schema

Returns:

  • (String)

    returns id



113
114
115
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 113

def id
  data[:id]
end

#labels(_id = :all, _options = {}) ⇒ Array<GoodData::Model::LabelBlueprintField>

Returns list of all labels defined on the schema.

Returns:



62
63
64
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 62

def labels(_id = :all, _options = {})
  []
end

#referenced_byArray<GoodData::Model::SchemaBlueprint>

Returns dataset that are referencing this dataset (directly through references not transitively).

Returns:



120
121
122
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 120

def referenced_by
  @project_blueprint.referencing(self)
end

#referencesArray<GoodData::Model::ReferenceBlueprintField>

Returns list of all references defined on the schema.

Returns:



34
35
36
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 34

def references
  []
end

#referencingArray<GoodData::Model::SchemaBlueprint>

Returns dataset that are referenced by this dataset (directly through references not transitively).

Returns:



127
128
129
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 127

def referencing
  references.map(&:dataset)
end

#titleString

Returns title of the dataset. If it is not set up. It is generated for you based on the name which is titleized

Returns:

  • (String)


135
136
137
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 135

def title
  data[:title] || GoodData::Helpers.titleize(data[:id])
end

#to_hashObject



162
163
164
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 162

def to_hash
  @data
end

#valid?Boolean

Validates the blueprint and returns true if model is valid. False otherwise.

Returns:

  • (Boolean)

    is model valid?



142
143
144
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 142

def valid?
  validate.empty?
end

#validateArray<Hash>

Validates the blueprint and returns array of errors.

Returns:

  • (Array<Hash>)

    returns array of errors or empty array



149
150
151
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 149

def validate
  fields.flat_map(&:validate)
end