use of com.developmentontheedge.beans.DynamicPropertySet 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.DynamicPropertySet 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());
}
use of com.developmentontheedge.beans.DynamicPropertySet in project be5 by DevelopmentOnTheEdge.
the class FilterHelper method processFilterParams.
public <T extends DynamicPropertySet> T processFilterParams(T dps, Map<String, Object> presetValues, Map<String, String> operationParams) {
Map<String, Object> filterPresetValues = new HashMap<>(operationParams);
filterPresetValues.putAll(presetValues);
List<String> searchPresets = new ArrayList<>();
if (!filterPresetValues.containsKey(SEARCH_PARAM)) {
searchPresets.addAll(presetValues.entrySet().stream().filter(x -> x.getValue() != null).map(Map.Entry::getKey).collect(Collectors.toList()));
} else {
if (filterPresetValues.get(SEARCH_PRESETS_PARAM) != null) {
searchPresets.addAll(Arrays.asList(((String) filterPresetValues.get(SEARCH_PRESETS_PARAM)).split(",")));
}
}
for (DynamicProperty property : dps) {
if (!property.getBooleanAttribute(BeanInfoConstants.LABEL_FIELD)) {
// remove defaultValue
property.setValue(null);
}
}
dpsHelper.setValues(dps, filterPresetValues);
for (DynamicProperty property : dps) {
property.setCanBeNull(true);
if (searchPresets.contains(property.getName()))
property.setReadOnly(true);
}
dps.add(new DynamicPropertyBuilder(SEARCH_PRESETS_PARAM, String.class).value(searchPresets.size() > 0 ? String.join(",", searchPresets) : null).readonly().nullable().hidden().get());
dps.add(new DynamicPropertyBuilder(SEARCH_PARAM, Boolean.class).value(true).readonly().nullable().hidden().get());
return dps;
}
use of com.developmentontheedge.beans.DynamicPropertySet 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;
}
use of com.developmentontheedge.beans.DynamicPropertySet in project be5 by DevelopmentOnTheEdge.
the class CellFormatter method toTable.
/**
* Returns a two-dimensional listDps of processed content. Each element is either a string or a table.
*/
private List<List<Object>> toTable(String subquery, VarResolver varResolver) {
List<DynamicPropertySet> list = queryExecutor.executeSubQuery(subquery, varResolver);
List<List<Object>> lists = new ArrayList<>();
for (DynamicPropertySet dps : list) {
List<Object> objects = toRow(dps, varResolver);
lists.add(objects);
}
return lists;
}
Aggregations