def generateVisualizerTable(cls, table: TableModel,
                                visio: VisualizationModel) -> TableModel:
        columns = list()

        for columnId in visio.usedColumns:
            if columnId != visio.xColumn:
                columnIndex = DataController.getElementIndexById(
                    table.columns, columnId)
                columns.append(table.columns[columnIndex])

        returnTable = TableModel(columns, table.name, table.id,
                                 table.properties, table.aggregator,
                                 table.filters, table.isDeleted)

        # setting used colors in table:
        # 1- rows:
        returnTable.rowsColors = table.rowsColors
        # 2- columns:
        columnsColors = list()
        for columnId in visio.usedColumns:
            if columnId != visio.xColumn:
                columnIndex = DataController.getElementIndexById(
                    table.columns, columnId)
                columnsColors.append(table.columnsColors[columnIndex])
        returnTable.columnsColors = columnsColors

        return returnTable
Exemple #2
0
 def sugreCoatAggregatedTable(cls, table: TableModel) -> TableModel:
     if table.aggregator.isActive:
         table.columns.clear()
         table.columns.extend(table.aggregator.aggregatedTable)
         table.rowsColors = table.rowsColors[:len(table.columns[0].cells) - 1]
         table.rowsVisibility = table.rowsVisibility[:len(table.columns[0].cells) - 1]
         return table
     else:
         return table
Exemple #3
0
    def _generateTableFromDict(cls, columns: dict, name: str, id: int,
                               randomColumnsColors: List, randomRowsColors: List) -> TableModel:
        columnIdCounter = 0
        bufferColumnsList = []
        for columnName in columns.keys():
            bufferColumnsList.append(cls._generateColumnFromDict(columns[columnName], columnName, columnIdCounter))
            columnIdCounter += 1

        properties = PropertiesModel(enums.FileType.Excel.value, 50)
        aggregator = AggregationModel([], 0, '', False)
        table = TableModel(bufferColumnsList, name, id, properties, aggregator,[] , False)
        table.rowsColors = randomRowsColors
        table.columnsColors = randomColumnsColors
        return table
Exemple #4
0
def dataSourceModifier(request, id):
    if request.method == 'PUT':
        newTable = TableModel.from_json(json.loads(request.body.decode()))
        newTable = dataController.updateTableById(newTable, int(id))
        return HttpResponse(
            json.dumps(newTable,
                       indent=4,
                       cls=ObjectEncoder,
                       ensure_ascii=False))
    elif request.method == 'DELETE':
        table = dataController.deleteTable(id)
        return HttpResponse(
            json.dumps(table, indent=4, cls=ObjectEncoder, ensure_ascii=False))
    else:
        return HttpResponseNotFound(
            'No such request({} <{}>) is available'.format(
                request.path, request.method))
Exemple #5
0
def dataSourcesHandler(request):
    if request.method == 'GET':
        fullTables = dataController.getFinaleTables()
        return HttpResponse(
            json.dumps(fullTables,
                       indent=4,
                       cls=ObjectEncoder,
                       ensure_ascii=False))
    elif request.method == 'POST':
        table = TableModel.from_json(json.loads(request.body.decode()))
        dataController.insertNewTable(table)
        return HttpResponse(
            json.dumps(table, indent=4, cls=ObjectEncoder, ensure_ascii=False))
    else:
        return HttpResponseNotFound(
            'No such request({} <{}>) is available'.format(
                request.path, request.method))
Exemple #6
0
style3 = ColumnStyleModel('#DBD56E', 1.0, 1.0, 'Calibri')

column1 = ColumnModel(cells1, str(cells1[0].value), 0, style1, False)
column2 = ColumnModel(cells2, str(cells2[0].value), 1, style2, False)
column3 = ColumnModel(cells3, str(cells3[0].value), 2, style3, False)

columns = [column1, column2, column3]

#=================================================================================================================
#=================================================================================================================

properties = PropertiesModel(enums.FileType.DataI.value, 50)

aggregator = AggregationModel([], 0, False)

dataSource = TableModel(columns, 'Table1', 0, properties, aggregator, False)

#Adding a column:
#=================================================================================================================
#=================================================================================================================

newCells = [
    CellModel('الوزن', enums.CellType.string.value),
    CellModel(10, enums.CellType.numeric.value),
    CellModel(17, enums.CellType.numeric.value),
    CellModel(55, enums.CellType.numeric.value),
    CellModel(39, enums.CellType.numeric.value),
    CellModel(71, enums.CellType.numeric.value),
    CellModel(66, enums.CellType.numeric.value),
    CellModel(55, enums.CellType.numeric.value),
    CellModel(21, enums.CellType.numeric.value),
Exemple #7
0
 def insertNewTable(cls, data: DataModel, table: TableModel):
     id = DataController.getMaxIdInList(data.dataSources)
     table.id = id + 1
     data.dataSources.append(table)