Search in sources :

Example 1 with TableModel

use of com.developmentontheedge.be5.query.impl.model.TableModel in project be5 by DevelopmentOnTheEdge.

the class OperationHelper method getTagsFromCustomSelectionViewExecute.

// 
// public Map<String, String> getTagsMapFromQuery( Map<String, String> parameters, String query, Object... params )
// {
// //return getTagsListFromQuery( Collections.emptyMap(), query, params );
// List<String[]> tags = db.selectList("SELECT " + valueColumnName + ", " + textColumnName + " FROM " + tableName,
// rs -> new String[]{rs.getString(valueColumnName), rs.getString(textColumnName)}
// );
// String[][] stockArr = new String[tags.size()][2];
// return tags.toArray(stockArr);
// }
private String[][] getTagsFromCustomSelectionViewExecute(Query query, Map<String, ?> parameters) {
    String entityName = query.getEntity().getName();
    // todo refactoring Be5QueryExecutor,
    Map<String, String> stringStringMap = new HashMap<>();
    // parameters.forEach((key, value) -> stringStringMap.put(key, value.toString()));
    for (Map.Entry<String, ?> entry : parameters.entrySet()) {
        if (entry.getValue() != null)
            stringStringMap.put(entry.getKey(), entry.getValue().toString());
    }
    TableModel table = TableModel.from(query, stringStringMap, false, injector).limit(Integer.MAX_VALUE).build();
    String[][] stockArr = new String[table.getRows().size()][2];
    int i = 0;
    for (TableModel.RowModel row : table.getRows()) {
        String first = row.getCells().size() >= 1 ? row.getCells().get(0).content.toString() : "";
        String second = row.getCells().size() >= 2 ? row.getCells().get(1).content.toString() : "";
        stockArr[i++] = new String[] { first, userAwareMeta.getColumnTitle(entityName, second) };
    }
    return stockArr;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TableModel(com.developmentontheedge.be5.query.impl.model.TableModel)

Example 2 with TableModel

use of com.developmentontheedge.be5.query.impl.model.TableModel in project be5 by DevelopmentOnTheEdge.

the class TableRowsBuilder method build.

public List<RowT> build(TableModel tableModel) {
    List<RowT> rows = new ArrayList<>();
    for (RowModel rowModel : tableModel.getRows()) {
        List<CellT> cells = new ArrayList<>();
        for (CellModel cellModel : rowModel.getCells()) {
            cells.add(createCell(cellModel));
        }
        rows.add(createRow(rowModel, cells));
    }
    return rows;
}
Also used : ArrayList(java.util.ArrayList) RowModel(com.developmentontheedge.be5.query.impl.model.TableModel.RowModel) CellModel(com.developmentontheedge.be5.query.impl.model.TableModel.CellModel)

Example 3 with TableModel

use of com.developmentontheedge.be5.query.impl.model.TableModel in project be5 by DevelopmentOnTheEdge.

the class DocumentGeneratorImpl method getTable.

public TablePresentation getTable(Query query, Map<String, String> parameters, int sortColumn, boolean sortDesc) {
    List<TableOperationPresentation> operations = collectOperations(query);
    final boolean selectable = !operations.isEmpty() && query.getType() == QueryType.D1;
    int limit = userAwareMeta.getQuerySettings(query).getMaxRecordsPerPage();
    if (limit == 0) {
        // todo delete defaultPageLimit, use getQuerySettings(query).getMaxRecordsPerPage()
        limit = Integer.parseInt(getLayoutObject(query).getOrDefault("defaultPageLimit", coreUtils.getSystemSetting("be5_defaultPageLimit", "10")).toString());
    }
    TableModel table = TableModel.from(query, parameters, selectable, injector).sortOrder(sortColumn, sortDesc).limit(limit).build();
    return getTable(query, parameters, table);
}
Also used : TableOperationPresentation(com.developmentontheedge.be5.model.TableOperationPresentation) TableModel(com.developmentontheedge.be5.query.impl.model.TableModel)

Aggregations

TableModel (com.developmentontheedge.be5.query.impl.model.TableModel)2 TableOperationPresentation (com.developmentontheedge.be5.model.TableOperationPresentation)1 CellModel (com.developmentontheedge.be5.query.impl.model.TableModel.CellModel)1 RowModel (com.developmentontheedge.be5.query.impl.model.TableModel.RowModel)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1