Пример #1
0
    def from_dict(cls, view_as_dict: Dict, cube_name: str = None) -> 'NativeView':
        titles, columns, rows = [], [], []

        for selection in view_as_dict['Titles']:
            if selection['Subset']['Name'] == '':
                subset = AnonymousSubset.from_dict(selection['Subset'])
            else:
                subset = Subset.from_dict(selection['Subset'])
            selected = selection['Selected']['Name'] if selection['Selected'] else ""
            titles.append(ViewTitleSelection(dimension_name=subset.dimension_name,
                                             subset=subset, selected=selected))
        for i, axe in enumerate([view_as_dict['Columns'], view_as_dict['Rows']]):
            for selection in axe:
                if selection['Subset']['Name'] == '':
                    subset = AnonymousSubset.from_dict(selection['Subset'])
                else:
                    subset = Subset.from_dict(selection['Subset'])
                axis_selection = ViewAxisSelection(dimension_name=subset.dimension_name,
                                                   subset=subset)
                columns.append(axis_selection) if i == 0 else rows.append(axis_selection)

        return cls(
            cube_name=view_as_dict["@odata.context"][20:view_as_dict["@odata.context"].find("')/")]
            if not cube_name else cube_name,
            view_name=view_as_dict['Name'],
            suppress_empty_columns=view_as_dict['SuppressEmptyColumns'],
            suppress_empty_rows=view_as_dict['SuppressEmptyRows'],
            format_string=view_as_dict['FormatString'],
            titles=titles,
            columns=columns,
            rows=rows)
Пример #2
0
    def add_row(self, dimension_name: str, subset: Subset = None):
        """ Add Dimension or Subset to the row-axis

        :param dimension_name:
        :param subset: instance of TM1py.Subset. Can be None instead.
        :return:
        """
        view_axis_selection = ViewAxisSelection(dimension_name=dimension_name, subset=subset)
        self._rows.append(view_axis_selection)
Пример #3
0
    def add_column(self, dimension_name: str, subset: Union[Subset, AnonymousSubset] = None):
        """ Add Dimension or Subset to the column-axis

        :param dimension_name: name of the dimension
        :param subset: instance of TM1py.Subset. Can be None
        :return:
        """
        view_axis_selection = ViewAxisSelection(dimension_name=dimension_name, subset=subset)
        self._columns.append(view_axis_selection)