use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method getLabel.
public DynamicProperty getLabel(String name, String text) {
DynamicProperty label = new DynamicProperty(name, String.class, text);
label.setAttribute(BeanInfoConstants.LABEL_FIELD, true);
label.setAttribute(BeanInfoConstants.CAN_BE_NULL, true);
return label;
}
use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method getLabelRaw.
public DynamicProperty getLabelRaw(String name, String text) {
DynamicProperty label = getLabel(name, text);
label.setAttribute(BeanInfoConstants.RAW_VALUE, true);
return label;
}
use of com.developmentontheedge.beans.DynamicProperty 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;
}
use of com.developmentontheedge.beans.DynamicProperty 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);
}
}
use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class DpsRecordAdapter method createSchema.
public static DynamicProperty[] createSchema(ResultSetMetaData metaData) {
try {
int count = metaData.getColumnCount();
DynamicProperty[] schema = new DynamicProperty[count];
Set<String> names = new HashSet<>();
// TODO: support ";ColumnName" declarations
for (int i = 1; i <= count; i++) {
String columnLabel = metaData.getColumnLabel(i);
if (columnLabel.startsWith(";")) {
String refName = columnLabel.substring(1);
int refId = IntStreamEx.ofIndices(schema, dp -> dp != null && dp.getName().equals(refName)).findAny().orElseThrow(() -> Be5Exception.internal("no previous column with name " + refName));
DynamicProperty dp = new DynamicProperty(columnLabel, String.class);
dp.setAttribute(COLUMN_REF_IDX_PROPERTY, refId);
dp.setHidden(true);
schema[i - 1] = dp;
continue;
}
String[] parts = columnLabel.split(";", 2);
String name = getUniqueName(names, parts[0]);
Class<?> clazz = getTypeClass(metaData.getColumnType(i));
DynamicProperty dp = new DynamicProperty(name, clazz);
if (name.startsWith(DatabaseConstants.HIDDEN_COLUMN_PREFIX)) {
dp.setHidden(true);
}
Map<String, Map<String, String>> tags = new TreeMap<>();
if (parts.length == 2)
BeTagParser.parseTags(tags, parts[1]);
DynamicPropertyMeta.set(dp, tags);
// TODO: support various types, attributes, tags, meta
schema[i - 1] = dp;
}
return schema;
} catch (SQLException e) {
throw Be5Exception.internal(e);
}
}
Aggregations