Search in sources :

Example 1 with DynamicPropertySetSupport

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

the class StandardOperationsTest method editOperationGenerateStringPrimaryKey.

@Test
public void editOperationGenerateStringPrimaryKey() {
    DynamicPropertySet dps = new DynamicPropertySetSupport();
    dpsHelper.addDpExcludeAutoIncrement(dps, meta.getEntity("propertyTypes"));
    dps.setValue("name", "TestName");
    dps.setValue("CODE", "02");
    when(SqlServiceMock.mock.select(any(), any(), any())).thenReturn(dps);
    Object first = generateOperation("propertyTypes", "All records", "Edit", "01", "{}").getFirst();
    verify(SqlServiceMock.mock).select(eq("SELECT * FROM propertyTypes WHERE CODE =?"), any(), eq("01"));
    assertEquals("{'CODE':'02','name':'TestName'}", oneQuotes(JsonFactory.bean(first).getJsonObject("values").toString()));
}
Also used : DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet) DynamicPropertySetSupport(com.developmentontheedge.beans.DynamicPropertySetSupport) Test(org.junit.Test) SqlMockOperationTest(com.developmentontheedge.be5.test.SqlMockOperationTest)

Example 2 with DynamicPropertySetSupport

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

the class TestOperationProperty method getParameters.

@Override
public Object getParameters(Map<String, Object> presetValues) throws Exception {
    DynamicPropertySet dps = new DynamicPropertySetSupport();
    dps.add(new DynamicProperty("simple", "Name", String.class));
    dps.add(new DynamicProperty("simpleNumber", "Number", Long.class));
    dps.add(new DynamicProperty("getOrDefault", "Name", String.class, presetValues.getOrDefault("getOrDefault", "defaultValue")));
    dps.add(new DynamicProperty("getOrDefaultNumber", "Name", Long.class, presetValues.getOrDefault("getOrDefaultNumber", "3")));
    return dpsHelper.setValues(dps, presetValues);
}
Also used : DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet) DynamicProperty(com.developmentontheedge.beans.DynamicProperty) DynamicPropertySetSupport(com.developmentontheedge.beans.DynamicPropertySetSupport)

Example 3 with DynamicPropertySetSupport

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

the class DpsRecordAdapter method createDps.

public static DynamicPropertySet createDps(ResultSet resultSet, MetaProcessor metaProcessor) {
    try {
        DynamicProperty[] schema = createSchema(resultSet.getMetaData());
        DynamicPropertySet row = new DynamicPropertySetSupport();
        for (int i = 0; i < schema.length; i++) {
            DynamicProperty dp = schema[i];
            Object refIdxObj = dp.getAttribute(COLUMN_REF_IDX_PROPERTY);
            if (refIdxObj instanceof Integer) {
                int refIdx = (int) refIdxObj;
                if (refIdx >= 0) {
                    Map<String, Map<String, String>> tags = new TreeMap<>();
                    BeTagParser.parseTags(tags, resultSet.getString(i + 1));
                    DynamicPropertyMeta.add(schema[refIdx], tags);
                    dp.setAttribute(COLUMN_REF_IDX_PROPERTY, -1);
                }
                continue;
            }
            Object val = getSqlValue(dp.getType(), resultSet, i + 1);
            // todo test Map<String, Map<String, String>> metaInfo = DynamicPropertyMeta.get(dp);
            // metaProcessor.process(val, metaInfo);
            DynamicProperty property = DynamicPropertySetSupport.cloneProperty(dp);
            property.setValue(val);
            row.add(property);
        }
        return row;
    } catch (Exception e) {
        throw Be5Exception.internal(e);
    }
}
Also used : DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet) DynamicProperty(com.developmentontheedge.beans.DynamicProperty) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) SQLException(java.sql.SQLException) Be5Exception(com.developmentontheedge.be5.api.exceptions.Be5Exception) DynamicPropertySetSupport(com.developmentontheedge.beans.DynamicPropertySetSupport)

Example 4 with DynamicPropertySetSupport

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

the class FilterOperation method getParameters.

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

Example 5 with DynamicPropertySetSupport

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

the class SilentInsertWithoutCollectionsOperation method getParameters.

@Override
public Object getParameters(Map<String, Object> presetValues) throws Exception {
    DynamicPropertySetSupport dps = new DynamicPropertySetSupport();
    dps = dpsHelper.addDpExcludeAutoIncrement(dps, getInfo().getModel(), presetValues);
    return dpsHelper.setOperationParams(dps, context.getOperationParams());
}
Also used : 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