示例#1
0
    def to_dict(self, **options):
        """Return dictionary representation of the dimension"""

        out = IgnoringDictionary()
        out.setnoempty("name", self.name)
        out.setnoempty("label", self.label)
        out.setnoempty("default_hierarchy_name", self.default_hierarchy_name)

        levels_dict = {}
        for level in self.levels:
            levels_dict[level.name] = level.to_dict(**options)
        out["levels"] = levels_dict

        hier_dict = {}
        for hier in self.hierarchies.values():
            hier_dict[hier.name] = hier.to_dict(**options)
        out["hierarchies"] = hier_dict

        # Use only for reading, during initialization these keys are ignored, as they are derived
        # They are provided here for convenience.
        out["is_flat"] = self.is_flat
        out["has_details"] = self.has_details


    	# * levels: list of dimension levels (see: :class:`brewery.cubes.Level`)
    	# * hierarchies: list of dimension hierarchies

        return out
示例#2
0
    def to_dict(self, **options):
        """Convert to dictionary"""

        out = IgnoringDictionary()
        out.setnoempty("name", self.name)
        out.setnoempty("label", self.label)
        out.setnoempty("levels", self._levels.keys())

        return out
示例#3
0
文件: model.py 项目: trumant/cubes
    def to_dict(self):
        """Convert to dictionary"""

        out = IgnoringDictionary()
        out.setnoempty("name", self.name)
        out.setnoempty("label", self.label)
        out.setnoempty("levels", self.level_names)

        return out
示例#4
0
文件: model.py 项目: trumant/cubes
    def to_dict(self):
        """Return dict representation of the dimension"""

        out = IgnoringDictionary()
        out.setnoempty("name", self.name)
        out.setnoempty("label", self.label)
        out.setnoempty("default_hierarchy_name", self.default_hierarchy_name)

        levels_dict = {}
        for level in self.levels:
            levels_dict[level.name] = level.to_dict()
        out["levels"] = levels_dict

        hier_dict = {}
        for hier in self.hierarchies.values():
            hier_dict[hier.name] = hier.to_dict()
        out["hierarchies"] = hier_dict


    	# * levels: list of dimension levels (see: :class:`brewery.cubes.Level`)
    	# * hierarchies: list of dimension hierarchies

        return out
示例#5
0
    def to_dict(self, expand_dimensions = False, with_mappings = True, **options):
        """Convert to dictionary
        
        Options:
        
            * `expand_dimensions` - if set to True then fully expand dimension information
        
        """

        out = IgnoringDictionary()
        out.setnoempty("name", self.name)
        out.setnoempty("label", self.label)

        array = []
        for attr in self.measures:
            array.append(attr.to_dict())
        out.setnoempty("measures", array)

        array = []
        for attr in self.details:
            array.append(attr.to_dict())
        out.setnoempty("details", array)

        if expand_dimensions:
            dims = [dim.to_dict(**options) for dim in self.dimensions]
        else:
            dims = [dim.name for dim in self.dimensions]

        out.setnoempty("dimensions", dims)

        if with_mappings:
            out.setnoempty("mappings", self.mappings)
            out.setnoempty("fact", self.fact)
            out.setnoempty("joins", self.joins)

        out.setnoempty("key", self.key)

        return out
示例#6
0
    def to_dict(self, **options):
        """Return dictionary representation of the model. All object references within the dictionary are
        name based

        Options:
        
            * `expand_dimensions` - if set to True then fully expand dimension information in cubes
            * `full_attribute_names` - if set to True then attribute names will be written as
              ``dimension_name.attribute_name``
        """

        out = IgnoringDictionary()

        out.setnoempty("name", self.name)
        out.setnoempty("label", self.label)
        out.setnoempty("description", self.description)

        dims = {}
        for dim in self._dimensions.values():
            dims[dim.name] = dim.to_dict(**options)

        out.setnoempty("dimensions", dims)

        cubes = {}
        for cube in self.cubes.values():
            cubes[cube.name] = cube.to_dict(**options)

        out.setnoempty("cubes", cubes)

        return out
示例#7
0
    def to_dict(self, full_attribute_names = False, **options):
        """Convert to dictionary"""

        out = IgnoringDictionary()
        out.setnoempty("name", self.name)
        out.setnoempty("label", self.label)
        out.setnoempty("missing_key_value", self.null_value)

        dimname = self.dimension.name

        key_name = str(self.key)
        if full_attribute_names:
            out.setnoempty("key", dimname + "." + key_name)
        else:
            out.setnoempty("key", key_name)

        array = []
        for attr in self.attributes:
            array.append(attr.to_dict(dimension = self.dimension, **options))
        out.setnoempty("attributes", array)
        out.setnoempty("label_attribute", self._label_attribute)

        return out
示例#8
0
文件: model.py 项目: trumant/cubes
    def to_dict(self):
        """Convert to dictionary"""

        out = IgnoringDictionary()
        out.setnoempty("name", self.name)
        out.setnoempty("label", self.label)
        out.setnoempty("key", self.key)
        out.setnoempty("attributes", self.attributes)
        out.setnoempty("label_attribute", self.label_attribute)

        return out
示例#9
0
文件: model.py 项目: trumant/cubes
    def to_dict(self):
        """Convert to dictionary"""

        out = IgnoringDictionary()
        out.setnoempty("name", self.name)
        out.setnoempty("label", self.label)
        out.setnoempty("measures", self.measures)

        dims = [dim.name for dim in self.dimensions]

        # Give sorted list so we can nicely compare dictionaries
        out.setnoempty("dimensions", dims.sort())

        out.setnoempty("mappings", self.mappings)
        out.setnoempty("fact", self.fact)
        out.setnoempty("joins", self.joins)

        return out
示例#10
0
文件: model.py 项目: trumant/cubes
    def to_dict(self):
        """Return dictionary representation of the model. All object references within the dictionary are
        name based"""

        def add_value(d, key, value):
            if value:
                d[key] = value
                
        
        out = IgnoringDictionary()

        out.setnoempty("name", self.name)
        out.setnoempty("label", self.label)
        out.setnoempty("description", self.description)

        dims = {}
        for dim in self.dimensions:
            dims[dim.name] = dim.to_dict()

        out.setnoempty("dimensions", dims)

        cubes = {}
        for cube in self.cubes.values():
            cubes[cube.name] = cube.to_dict()

        out.setnoempty("cubes", cubes)

        return out