use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class DynamicPropertySetMetaClass method leftShift.
// todo refactoring duplicate code
public static DynamicPropertySet leftShift(DynamicPropertySet dps, Map<String, Object> properties) {
Map<String, Object> map = new HashMap<>();
map.putAll(properties);
String name = asString(removeFromMap(map, "name"));
if (name == null) {
name = "null";
}
Object value = removeFromMap(map, "value");
if (value != null && value.getClass() == GStringImpl.class) {
value = value.toString();
}
String displayName = asString(removeFromMap(map, "DISPLAY_NAME"));
Boolean isHidden = (Boolean) removeFromMap(map, "HIDDEN");
Class type = (Class) removeFromMap(map, "TYPE");
if (type == java.sql.Date.class && value != null) {
value = Utils.changeType(value, java.sql.Date.class);
}
DynamicProperty dp = dps.getProperty(name);
if (dp == null) {
dp = new DynamicProperty(name, type != null ? type : value != null ? value.getClass() : String.class);
dps.add(dp);
}
dp.setValue(value);
if (displayName != null)
dp.setDisplayName(displayName);
if (isHidden == Boolean.TRUE)
dp.setHidden(true);
for (String key : map.keySet()) {
String attributeName = beanInfoConstants.get(key);
if (attributeName != null) {
dp.setAttribute(attributeName, map.get(key));
} else {
log.warning("Not found attribute: " + key + " in BeanInfoConstants");
}
}
return dps;
}
use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class GDynamicPropertySetSupport method add.
// may be add
// public DynamicProperty setAt(String name, String value)
// {
// DynamicProperty property = new DynamicProperty(name, String.class, value);
// super.add(property);
// return property;
// }
public DynamicProperty add(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = DPSAttributes.class) Closure cl) {
DPSAttributes builder = getBuilder(cl);
Objects.requireNonNull(builder.getName());
DynamicProperty property = new DynamicProperty(builder.getName(), builder.getTYPE());
add(property);
return DynamicPropertyMetaClass.leftShift(property, builder.getMap());
}
use of com.developmentontheedge.beans.DynamicProperty 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);
}
use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method addTags.
private <T extends DynamicPropertySet> T addTags(T dps, BeModelElement modelElements, Collection<String> columnNames) {
Map<String, ColumnDef> columns = meta.getColumns(getEntity(modelElements));
for (String propertyName : columnNames) {
DynamicProperty property = dps.getProperty(propertyName);
ColumnDef columnDef = columns.get(property.getName());
if (columnDef != null)
addTags(property, columnDef);
}
return dps;
}
use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method setValues.
public <T extends DynamicPropertySet> T setValues(T dps, ResultSet resultSet) {
try {
ResultSetMetaData metaData = resultSet.getMetaData();
for (int i = 1; i <= metaData.getColumnCount(); i++) {
String name = metaData.getColumnName(i);
DynamicProperty property = dps.getProperty(name);
if (property != null) {
property.setValue(DpsRecordAdapter.getSqlValue(property.getType(), resultSet, i));
}
}
} catch (SQLException e) {
throw Be5Exception.internal(e);
}
return dps;
}
Aggregations