use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.
the class UndefinedExpressionGrid method onExpressionTypeChanged.
void onExpressionTypeChanged(final ExpressionType type) {
final Optional<Expression> expression = expressionEditorDefinitionsSupplier.get().stream().filter(e -> e.getType().equals(type)).map(ExpressionEditorDefinition::getModelClass).findFirst().get();
final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
expressionEditorDefinition.ifPresent(ed -> {
final Optional<BaseExpressionGrid> editor = ed.getEditor(parent, nodeUUID, hasExpression, expression, hasName, nesting);
final GridCellValueTuple gcv = new GridCellValueTuple<>(parent.getRowIndex(), parent.getColumnIndex(), parent.getGridWidget(), new ExpressionCellValue(editor));
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new SetCellValueCommand(gcv, () -> uiModelMapper, () -> editor.ifPresent(e -> {
e.selectFirstCell();
synchroniseViewWhenExpressionEditorChanged(e);
})));
});
}
use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.
the class UndefinedExpressionUIModelMapper method toDMNModel.
@Override
@SuppressWarnings("unchecked")
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
cell.get().ifPresent(v -> {
final ExpressionCellValue ecv = (ExpressionCellValue) v;
ecv.getValue().ifPresent(beg -> hasExpression.setExpression((Expression) beg.getExpression().orElse(null)));
});
}
use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.
the class DeleteRelationColumnCommand method newGraphCommand.
@Override
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) {
return new AbstractGraphCommand() {
@Override
protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) {
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) {
final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT;
relation.getRow().forEach(row -> row.getExpression().remove(iiIndex));
relation.getColumn().remove(iiIndex);
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) {
final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT;
relation.getColumn().add(iiIndex, oldInformationItem);
IntStream.range(0, relation.getRow().size()).forEach(rowIndex -> {
final Expression value = oldColumnData.get(rowIndex);
relation.getRow().get(rowIndex).getExpression().add(iiIndex, value);
});
return GraphCommandResultBuilder.SUCCESS;
}
};
}
use of org.eclipse.bpmn2.Expression in project vorto by eclipse.
the class AbstractDataMapper method matchesCondition.
private boolean matchesCondition(Map<String, String> attributes, JXPathContext context) {
if (attributes.containsKey(ATTRIBUTE_CONDITION) && !attributes.get(ATTRIBUTE_CONDITION).equals("")) {
Expression e = JEXL.createExpression(normalizeCondition(attributes.get(ATTRIBUTE_CONDITION)));
JexlContext jc = new ObjectContext<Object>(JEXL, context.getContextBean());
jc.set("this", context.getContextBean());
return (boolean) e.evaluate(jc);
} else {
return true;
}
}
use of org.eclipse.bpmn2.Expression in project rubia-forums by flashboss.
the class ForumsACLResource method evaluate.
public boolean evaluate() {
boolean isCriteriaMet = true;
if (criteria != null) {
try {
JexlEngine jexl = new JexlEngine();
JexlContext context2 = new MapContext();
if (criteria != null) {
Expression expression = jexl.createExpression(criteria);
context2.set("param", map.get("runtimeInfo"));
context2.set("identity", map.get("identity"));
Object value = expression.evaluate(context2);
isCriteriaMet = ((Boolean) value).booleanValue();
}
} catch (Exception e) {
log.error(e);
isCriteriaMet = false;
}
}
return isCriteriaMet;
}
Aggregations