Search in sources :

Example 6 with DynamicPropertySetSupport

use of com.developmentontheedge.beans.DynamicPropertySetSupport in project be5 by DevelopmentOnTheEdge.

the class Be5QueryExecutor method executeSubQuery.

@Override
public List<DynamicPropertySet> executeSubQuery(String subqueryName, CellFormatter.VarResolver varResolver) {
    AstBeSqlSubQuery subQuery = contextApplier.applyVars(subqueryName, varResolver::resolve);
    if (subQuery.getQuery() == null) {
        return Collections.emptyList();
    }
    String finalSql = new Formatter().format(subQuery.getQuery(), context, parserContext);
    List<DynamicPropertySet> dynamicPropertySets;
    try {
        dynamicPropertySets = listDps(finalSql);
    } catch (Throwable e) {
        // TODO only for Document presentation, for operations must be error throw
        Be5Exception be5Exception = Be5Exception.internalInQuery(e, query);
        log.log(Level.SEVERE, be5Exception.toString() + " Final SQL: " + finalSql, be5Exception);
        DynamicPropertySetSupport dynamicProperties = new DynamicPropertySetSupport();
        dynamicProperties.add(new DynamicProperty("___ID", String.class, "-1"));
        dynamicProperties.add(new DynamicProperty("error", String.class, UserInfoHolder.isSystemDeveloper() ? Be5Exception.getMessage(e) : "error"));
        dynamicPropertySets = Collections.singletonList(dynamicProperties);
    }
    // return Collections.singletonList(dynamicProperties);
    return dynamicPropertySets;
}
Also used : DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet) Be5Exception(com.developmentontheedge.be5.api.exceptions.Be5Exception) DynamicProperty(com.developmentontheedge.beans.DynamicProperty) Formatter(com.developmentontheedge.sql.format.Formatter) AstBeSqlSubQuery(com.developmentontheedge.sql.model.AstBeSqlSubQuery) DynamicPropertySetSupport(com.developmentontheedge.beans.DynamicPropertySetSupport)

Example 7 with DynamicPropertySetSupport

use of com.developmentontheedge.beans.DynamicPropertySetSupport in project be5 by DevelopmentOnTheEdge.

the class EntityModelBase method add.

@Override
public String add(Map<String, ? super Object> values) {
    Objects.requireNonNull(values);
    DynamicPropertySet dps = new DynamicPropertySetSupport();
    dpsHelper.addDpForColumnsWithoutTags(dps, entity, values.keySet(), values);
    return add(dps);
}
Also used : DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet) DynamicPropertySetSupport(com.developmentontheedge.beans.DynamicPropertySetSupport)

Example 8 with DynamicPropertySetSupport

use of com.developmentontheedge.beans.DynamicPropertySetSupport in project be5 by DevelopmentOnTheEdge.

the class EntityModelBase method set.

@Override
public int set(String id, Map<String, ? super Object> values) {
    Objects.requireNonNull(id);
    Objects.requireNonNull(values);
    DynamicPropertySet dps = new DynamicPropertySetSupport();
    dpsHelper.addDpForColumnsWithoutTags(dps, entity, values.keySet(), values);
    return this.set(id, dps);
}
Also used : DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet) DynamicPropertySetSupport(com.developmentontheedge.beans.DynamicPropertySetSupport)

Example 9 with DynamicPropertySetSupport

use of com.developmentontheedge.beans.DynamicPropertySetSupport in project be5 by DevelopmentOnTheEdge.

the class EntityModelBase method getColumns.

@Override
public RecordModel getColumns(List<String> columns, Map<String, ? super Object> conditions) {
    Objects.requireNonNull(conditions);
    AstSelect sql = Ast.select(addPrimaryKeyColumnIfNotEmpty(columns)).from(entity.getName()).where(conditions);
    DynamicPropertySet dps = db.select(sql.format(), rs -> {
        DynamicPropertySet newDps = new DynamicPropertySetSupport();
        dpsHelper.addDpWithoutTags(newDps, entity, rs);
        return newDps;
    }, conditions.values().toArray());
    return dps == null ? null : new RecordModelBase(this, dps);
}
Also used : AstSelect(com.developmentontheedge.sql.model.AstSelect) DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet) DynamicPropertySetSupport(com.developmentontheedge.beans.DynamicPropertySetSupport)

Example 10 with DynamicPropertySetSupport

use of com.developmentontheedge.beans.DynamicPropertySetSupport in project be5 by DevelopmentOnTheEdge.

the class FilterByParamsInQueryOperation method getParameters.

@Override
public Object getParameters(Map<String, Object> presetValues) throws Exception {
    DynamicPropertySet dps = new DynamicPropertySetSupport();
    dpsHelper.addParamsFromQuery(dps, getInfo().getModel(), getQuery());
    return filterHelper.processFilterParams(dps, presetValues, context.getOperationParams());
}
Also used : DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet) DynamicPropertySetSupport(com.developmentontheedge.beans.DynamicPropertySetSupport)

Aggregations

DynamicPropertySetSupport (com.developmentontheedge.beans.DynamicPropertySetSupport)12 DynamicPropertySet (com.developmentontheedge.beans.DynamicPropertySet)11 DynamicProperty (com.developmentontheedge.beans.DynamicProperty)4 Be5Exception (com.developmentontheedge.be5.api.exceptions.Be5Exception)2 Entity (com.developmentontheedge.be5.metadata.model.Entity)1 SqlMockOperationTest (com.developmentontheedge.be5.test.SqlMockOperationTest)1 Formatter (com.developmentontheedge.sql.format.Formatter)1 AstBeSqlSubQuery (com.developmentontheedge.sql.model.AstBeSqlSubQuery)1 AstSelect (com.developmentontheedge.sql.model.AstSelect)1 SQLException (java.sql.SQLException)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Test (org.junit.Test)1