class GoodData::Model::SchemaBlueprint

Attributes

data[RW]
project_blueprint[RW]

Public Class Methods

new(dim, blueprint) click to toggle source
# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 12
def initialize(dim, blueprint)
  @data = dim
  @project_blueprint = blueprint
end

Public Instance Methods

==(other) click to toggle source

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

@param name [GoodData::Model::DatasetBlueprint] Name of a field @return [Boolean] matching fields

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 158
def ==(other)
  to_hash == other.to_hash
end
anchor() click to toggle source

Returns anchor

@return [GoodData::Model::AnchorBlueprintField] anchor on schema

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 27
def anchor
  nil
end
anchor?() click to toggle source

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

@return [Boolean] is anchor on schema?l70

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 20
def anchor?
  true
end
attributes(_id = :all, _options = {}) click to toggle source

Returns list of all attributes defined on the schema.

@return [Array<GoodData::Model::AttributeBlueprintField>] attributes on schema

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 55
def attributes(_id = :all, _options = {})
  []
end
attributes_and_anchors() click to toggle source

Returns list of attributes and anchor.

@return [Array<GoodData::Model::AnchorBlueprintField | GoodData::Model::AttributeBlueprintField>]

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 76
def attributes_and_anchors
  []
end
breaks() click to toggle source

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.

@return [Array<GoodData::Model::AnchorBlueprintField | GoodData::Model::AttributeBlueprintField>]

# 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
bridges() click to toggle source

Returns list of all bridges defined on the schema.

@return [Array<GoodData::Model::BridgeBlueprintField>] refs on schema

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 41
def bridges
  []
end
broken_by() click to toggle source

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.

@return [Array<GoodData::Model::BlueprintField>]

# 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 = {}) click to toggle source

Returns list of all facts defined on the schema.

@return [Array<GoodData::Model::FactBlueprintField>] facts on schema

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 48
def facts(_id = :all, _options = {})
  []
end
fields() click to toggle source

Returns list of all fields defined on the schema.

@return [Array<GoodData::Model::BlueprintField>] all fields on schema

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 69
def fields
  []
end
find_dataset(dataset, options = {}) click to toggle source

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

@param dataset [String] Name of a dataset @param options [Hash] additional options. See ProjectBlueprint form more @return [GoodData::Model::DatasetBlueprint] returns matching dataset or throws an error

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 106
def find_dataset(dataset, options = {})
  project_blueprint.find_dataset(dataset, options)
end
id() click to toggle source

Returns id of the schema

@return [String] returns id

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 113
def id
  data[:id]
end
labels(_id = :all, _options = {}) click to toggle source

Returns list of all labels defined on the schema.

@return [Array<GoodData::Model::LabelBlueprintField>] labels on schema

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 62
def labels(_id = :all, _options = {})
  []
end
referenced_by() click to toggle source

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

@return [Array<GoodData::Model::SchemaBlueprint>] returns id

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 120
def referenced_by
  @project_blueprint.referencing(self)
end
references() click to toggle source

Returns list of all references defined on the schema.

@return [Array<GoodData::Model::ReferenceBlueprintField>] refs on schema

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 34
def references
  []
end
referencing() click to toggle source

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

@return [Array<GoodData::Model::SchemaBlueprint>] returns id

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 127
def referencing
  references.map(&:dataset)
end
title() click to toggle source

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

@return [String]

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 135
def title
  data[:title] || GoodData::Helpers.titleize(data[:id])
end
to_hash() click to toggle source
# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 162
def to_hash
  @data
end
valid?() click to toggle source

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

@return [Boolean] is model valid?

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 142
def valid?
  validate.empty?
end
validate() click to toggle source

Validates the blueprint and returns array of errors.

@return [Array<Hash>] returns array of errors or empty array

# File lib/gooddata/models/blueprint/schema_blueprint.rb, line 149
def validate
  fields.flat_map(&:validate)
end