Search in sources :

Example 1 with DynamicPropertySet

use of com.developmentontheedge.beans.DynamicPropertySet 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 DynamicPropertySet

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

the class TestOperation method invoke.

@Override
public void invoke(Object parameters) throws Exception {
    DynamicPropertySet dps = (DynamicPropertySet) parameters;
    db.insert(dpsHelper.generateInsertSql(getInfo().getEntity(), dps), dpsHelper.getValues(dps));
    setResultRedirectThisOperation();
}
Also used : DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet)

Example 3 with DynamicPropertySet

use of com.developmentontheedge.beans.DynamicPropertySet 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 4 with DynamicPropertySet

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

the class TestOperationProperty method invoke.

@Override
public void invoke(Object parameters) throws Exception {
    DynamicPropertySet dps = (DynamicPropertySet) parameters;
    db.insert(dpsHelper.generateInsertSql(getInfo().getEntity(), dps), dpsHelper.getValues(dps));
}
Also used : DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet)

Example 5 with DynamicPropertySet

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

the class OperationHelper method readAsList.

public List<List<Object>> readAsList(String sql, Object... params) {
    List<List<Object>> vals = new ArrayList<>();
    List<DynamicPropertySet> list = readAsRecords(sql, params);
    for (int i = 0; i < list.size(); i++) {
        List<Object> propertyList = new ArrayList<>();
        for (DynamicProperty property : list.get(i)) {
            propertyList.add(property.getValue());
        }
        vals.add(propertyList);
    }
    return vals;
}
Also used : DynamicPropertySet(com.developmentontheedge.beans.DynamicPropertySet) DynamicProperty(com.developmentontheedge.beans.DynamicProperty) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

DynamicPropertySet (com.developmentontheedge.beans.DynamicPropertySet)17 DynamicPropertySetSupport (com.developmentontheedge.beans.DynamicPropertySetSupport)11 DynamicProperty (com.developmentontheedge.beans.DynamicProperty)7 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 Be5Exception (com.developmentontheedge.be5.api.exceptions.Be5Exception)2 HashMap (java.util.HashMap)2 SEARCH_PARAM (com.developmentontheedge.be5.api.FrontendConstants.SEARCH_PARAM)1 SEARCH_PRESETS_PARAM (com.developmentontheedge.be5.api.FrontendConstants.SEARCH_PRESETS_PARAM)1 Entity (com.developmentontheedge.be5.metadata.model.Entity)1 Query (com.developmentontheedge.be5.metadata.model.Query)1 JsonApiModel (com.developmentontheedge.be5.model.jsonapi.JsonApiModel)1 DocumentGenerator (com.developmentontheedge.be5.query.DocumentGenerator)1 SqlMockOperationTest (com.developmentontheedge.be5.test.SqlMockOperationTest)1 BeanInfoConstants (com.developmentontheedge.beans.BeanInfoConstants)1 DynamicPropertyBuilder (com.developmentontheedge.beans.DynamicPropertyBuilder)1 ColumnRef (com.developmentontheedge.sql.format.ColumnRef)1 FilterApplier (com.developmentontheedge.sql.format.FilterApplier)1 Formatter (com.developmentontheedge.sql.format.Formatter)1