Search in sources :

Example 1 with TableBuilder

use of com.developmentontheedge.be5.query.TableBuilder in project be5 by DevelopmentOnTheEdge.

the class DocumentGeneratorImpl method routeAndRun.

@Override
public Object routeAndRun(Query query, Map<String, String> parameters, int sortColumn, boolean sortDesc) {
    switch(query.getType()) {
        case STATIC:
            if (ActionUtils.isStaticPage(query)) {
                return getStatic(query);
            } else {
                throw Be5Exception.internalInQuery(new IllegalStateException("Unsupported static request"), query);
            }
        case D1:
        case D1_UNKNOWN:
            return getTable(query, parameters, sortColumn, sortDesc);
        case D2:
        case CONTAINER:
        case CUSTOM:
        case JAVASCRIPT:
            throw Be5Exception.internal("Not support operation type: " + query.getType());
        case GROOVY:
            try {
                Class aClass = groovyRegister.getClass(query.getEntity() + query.getName(), query.getQuery(), query.getFileName());
                if (aClass != null) {
                    TableBuilder tableBuilder = (TableBuilder) aClass.newInstance();
                    tableBuilder.initialize(query, parameters);
                    injector.injectAnnotatedFields(tableBuilder);
                    return getTable(query, parameters, tableBuilder.getTableModel());
                } else {
                    throw Be5Exception.internal("Class " + query.getQuery() + " is null.");
                }
            } catch (NoClassDefFoundError | IllegalAccessException | InstantiationException e) {
                throw new UnsupportedOperationException("Groovy feature has been excluded", e);
            }
        default:
            throw Be5Exception.internal("Unknown action type '" + query.getType() + "'");
    }
}
Also used : TableBuilder(com.developmentontheedge.be5.query.TableBuilder)

Aggregations

TableBuilder (com.developmentontheedge.be5.query.TableBuilder)1