use of org.finos.symphony.toolkit.workflow.form.FormSubmission in project spring-bot by finos.
the class TestTableEdit method testDeleteRows.
@Test
public void testDeleteRows() throws Exception {
EntityJson ej = new EntityJson();
ej.put(WorkResponse.OBJECT_KEY, to);
Map<String, Object> selects = Collections.singletonMap("items", Collections.singletonList(Collections.singletonMap("selected", "true")));
FormSubmission uc = new FormSubmission(TestObjects.class.getCanonicalName(), selects);
FormAction ea = new FormAction(room, u, uc, "items." + TableDeleteRows.ACTION_SUFFIX, ej);
deleteRows.accept(ea);
testTemplating("abc123", "testDeleteRows.ml", "testDeleteRows.json");
}
use of org.finos.symphony.toolkit.workflow.form.FormSubmission in project spring-bot by finos.
the class TableDeleteRows method acceptFormAction.
@SuppressWarnings("unchecked")
@Override
public void acceptFormAction(FormAction ea) {
String verb = ea.getAction();
if (verb == null) {
return;
}
if (verb.endsWith(ACTION_SUFFIX)) {
Object data = ea.getData().get(WorkResponse.OBJECT_KEY);
// get the table to modify
String tableLocation = verb.substring(0, verb.length() - ACTION_SUFFIX.length() - 1);
tableLocation = TableEditRow.fixSpel(tableLocation);
Expression e = spel.parseExpression(tableLocation);
List<Object> table = (List<Object>) e.getValue(data);
Object deleteStructure = ((FormSubmission) ea.getFormData()).structure;
String mapLocation = convertSpelToMapSpel(tableLocation);
e = spel.parseExpression(mapLocation);
List<Integer> toRemove = getRowsToDelete((List<Object>) e.getValue(deleteStructure));
for (Integer i : toRemove) {
table.remove((int) i);
}
WorkResponse out = new WorkResponse(ea.getAddressable(), data, WorkMode.EDIT);
rh.accept(out);
}
}
Aggregations