use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class Be5QueryExecutor method applySort.
private void applySort(DebugQueryLogger dql, AstStart ast) {
if (sortColumn >= 0) {
try {
DynamicProperty[] schema = getSchema(new Formatter().format(ast, context, parserContext));
int sortCol = getQuerySortingColumn(schema);
if (sortCol > 0) {
AstSelect sel = (AstSelect) ast.getQuery().jjtGetChild(ast.getQuery().jjtGetNumChildren() - 1);
AstOrderBy orderBy = sel.getOrderBy();
if (orderBy == null) {
orderBy = new AstOrderBy();
sel.addChild(orderBy);
AstLimit astLimit = sel.children().select(AstLimit.class).findFirst().orElse(null);
if (astLimit != null) {
sel.removeChild(astLimit);
sel.addChild(astLimit);
}
}
AstOrderingElement oe = new AstOrderingElement(AstNumericConstant.of(sortCol));
if (sortDesc) {
oe.setDirectionToken(new Token(0, "DESC"));
}
orderBy.addChild(oe);
orderBy.moveToFront(oe);
}
dql.log("With sort", ast);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class BeConnectionProfile method getProperties.
public DynamicPropertySet getProperties() {
return new AbstractDynamicPropertySet() {
private static final long serialVersionUID = 1L;
@Override
public int size() {
return properties.size();
}
@Override
public boolean replaceWith(String name, DynamicProperty prop) {
if (!properties.containsKey(name))
return false;
properties.put(name, (String) prop.getValue());
return true;
}
@Override
public void renameProperty(String from, String to) {
String value = properties.get(from);
properties.remove(from);
properties.put(to, value);
}
@Override
public Object remove(String name) {
return properties.remove(name);
}
@Override
public Iterator<DynamicProperty> propertyIterator() {
return StreamEx.ofKeys(properties).map(this::findProperty).iterator();
}
@Override
public Iterator<String> nameIterator() {
return properties.keySet().iterator();
}
@Override
public boolean moveTo(String name, int index) {
throw new UnsupportedOperationException();
}
@Override
public boolean contains(DynamicProperty property) {
return properties.containsKey(property.getName());
}
@Override
public Map<String, Object> asMap() {
return new LinkedHashMap<>(properties);
}
@Override
public boolean addBefore(String propName, DynamicProperty property) {
throw new UnsupportedOperationException();
}
@Override
public boolean addAfter(String propName, DynamicProperty property) {
throw new UnsupportedOperationException();
}
@Override
public void add(DynamicProperty property) {
properties.put(property.getName(), (String) property.getValue());
}
@Override
protected DynamicProperty findProperty(String name) {
String value = properties.get(name);
return value == null ? null : new DynamicProperty(name, String.class, value);
}
};
}
use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class Login method getParameters.
@Override
public Object getParameters(Map<String, Object> presetValues) throws Exception {
dpsHelper.addDpForColumns(dps, getInfo().getEntity(), Arrays.asList("user_name", "user_pass"), presetValues);
DynamicProperty user_pass = dps.getProperty("user_pass");
user_pass.setAttribute(CAN_BE_NULL, false);
user_pass.setAttribute(PASSWORD_FIELD, true);
return dps;
}
use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method setOperationParams.
public <T extends DynamicPropertySet> T setOperationParams(T dps, Map<String, String> operationParams) {
Map<String, ?> params = ParseRequestUtils.getOperationParamsWithoutFilter(operationParams);
for (Map.Entry<String, ?> entry : params.entrySet()) {
DynamicProperty property = dps.getProperty(entry.getKey());
if (property != null) {
property.setValue(entry.getValue());
property.setReadOnly(true);
}
}
return dps;
}
use of com.developmentontheedge.beans.DynamicProperty in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method getDynamicPropertyWithoutTags.
public DynamicProperty getDynamicPropertyWithoutTags(ColumnDef columnDef, BeModelElement modelElements) {
DynamicProperty dp = new DynamicProperty(columnDef.getName(), meta.getColumnType(columnDef));
if (modelElements.getClass() == Query.class) {
dp.setDisplayName(userAwareMeta.getColumnTitle(columnDef.getEntity().getName(), modelElements.getName(), columnDef.getName()));
} else if (modelElements.getClass() == Entity.class) {
dp.setDisplayName(userAwareMeta.getColumnTitle(columnDef.getEntity().getName(), columnDef.getName()));
} else if (modelElements.getClass() == JavaOperation.class || modelElements.getClass() == GroovyOperation.class) {
dp.setDisplayName(userAwareMeta.getLocalizedOperationField(columnDef.getEntity().getName(), modelElements.getName(), columnDef.getName()));
}
if (columnDef.getDefaultValue() != null) {
dp.setValue(meta.getColumnDefaultValue(columnDef));
}
if (columnDef.isCanBeNull() || (columnDef.getTypeString().equals(SqlColumnType.TYPE_BOOL) && columnDef.getDefaultValue() != null)) {
dp.setCanBeNull(true);
}
if (SqlColumnType.TYPE_VARCHAR.equals(columnDef.getType().getTypeName()) || SqlColumnType.TYPE_CHAR.equals(columnDef.getType().getTypeName())) {
dp.setAttribute(BeanInfoConstants.COLUMN_SIZE_ATTR, columnDef.getType().getSize());
}
if (SqlColumnType.TYPE_DECIMAL.equals(columnDef.getType().getTypeName())) {
int size = columnDef.getType().getSize();
dp.setAttribute(BeanInfoConstants.VALIDATION_RULES, Arrays.asList(getRange(size, false), step(getPrecision(columnDef.getType().getPrecision()))));
}
if (SqlColumnType.TYPE_CURRENCY.equals(columnDef.getType().getTypeName())) {
dp.setAttribute(BeanInfoConstants.VALIDATION_RULES, Arrays.asList(getRange(columnDef.getType().getSize(), false), step(0.01)));
}
if (SqlColumnType.TYPE_INT.equals(columnDef.getType().getTypeName()) || SqlColumnType.TYPE_UINT.equals(columnDef.getType().getTypeName())) {
boolean unsigned = SqlColumnType.TYPE_UINT.equals(columnDef.getType().getTypeName());
dp.setAttribute(BeanInfoConstants.VALIDATION_RULES, Arrays.asList(range(unsigned ? 0 : Integer.MIN_VALUE, Integer.MAX_VALUE), step(1)));
}
if (SqlColumnType.TYPE_BIGINT.equals(columnDef.getType().getTypeName()) || SqlColumnType.TYPE_UBIGINT.equals(columnDef.getType().getTypeName())) {
boolean unsigned = SqlColumnType.TYPE_UBIGINT.equals(columnDef.getType().getTypeName());
dp.setAttribute(BeanInfoConstants.VALIDATION_RULES, Arrays.asList(range(unsigned ? 0 : Long.MIN_VALUE, Long.MAX_VALUE), step(1)));
}
if (columnDef.getName().endsWith(HIDDEN_COLUMN_PREFIX))
dp.setHidden(true);
return dp;
}
Aggregations