use of org.finos.symphony.toolkit.workflow.response.WorkResponse in project spring-bot by finos.
the class SchedulerTests method handleFeedLeaderTest.
@SuppressWarnings("unchecked")
@Test
public void handleFeedLeaderTest() {
when(history.getLastFromHistory(Mockito.any(Class.class), Mockito.any(Addressable.class))).thenReturn(reminderList());
when(leaderService.isLeader(Mockito.any())).thenReturn(true);
when(rooms.getAllConversations()).thenReturn(createStreams());
scheduler.everyFiveMinutesWeekday();
verify(responseHandlers).accept(Mockito.any(WorkResponse.class));
ArgumentCaptor<WorkResponse> argumentCaptor = ArgumentCaptor.forClass(WorkResponse.class);
verify(responseHandlers).accept(argumentCaptor.capture());
WorkResponse fr = argumentCaptor.getValue();
Reminder r = (Reminder) fr.getFormObject();
Assertions.assertEquals(r.getLocalTime(), expectedTime);
// reminder timefinder tests to chck formresponse
}
use of org.finos.symphony.toolkit.workflow.response.WorkResponse in project spring-bot by finos.
the class EditActionElementsConsumer method acceptFormAction.
@Override
public void acceptFormAction(FormAction u) {
if (u.getAction().equals(EDIT)) {
Object o = u.getData().get(WorkResponse.OBJECT_KEY);
rh.accept(new WorkResponse(u.getAddressable(), o, WorkMode.EDIT));
}
}
use of org.finos.symphony.toolkit.workflow.response.WorkResponse in project spring-bot by finos.
the class TableEditRow method updateData.
protected void updateData(FormAction in, String verb) {
String tableLocation = verb.substring(0, verb.length() - UPDATE_SUFFIX.length() - 1);
tableLocation = fixSpel(tableLocation);
int lastBracket = tableLocation.lastIndexOf('[');
int row = Integer.parseInt(tableLocation.substring(lastBracket + 1, tableLocation.length() - 1));
tableLocation = tableLocation.substring(0, lastBracket);
Object updated = in.getFormData();
Expression e = spel.parseExpression(tableLocation);
Object data = in.getData().get(WORKFLOW_001);
@SuppressWarnings("unchecked") List<Object> listToUpdate = (List<Object>) e.getValue(data);
listToUpdate.set(row, updated);
WorkResponse wr = new WorkResponse(in.getAddressable(), data, WorkMode.EDIT);
rh.accept(wr);
}
use of org.finos.symphony.toolkit.workflow.response.WorkResponse in project spring-bot by finos.
the class TableEditRow method createEditForm.
protected void createEditForm(FormAction in, String verb) {
String tableLocation = verb.substring(0, verb.length() - EDIT_SUFFIX.length() - 1);
tableLocation = fixSpel(tableLocation);
Expression e = spel.parseExpression(tableLocation);
Object data = in.getData().get(WorkResponse.OBJECT_KEY);
Object o = e.getValue(data);
Class<?> c = o.getClass();
Map<String, Object> json = WorkResponse.createEntityMap(o, ButtonList.of(new Button(tableLocation + "." + UPDATE_SUFFIX, Type.ACTION, "Update")), null);
json.put(WORKFLOW_001, data);
WorkResponse wr = new WorkResponse(in.getAddressable(), json, WorkResponse.getTemplateNameForClass(WorkMode.EDIT, c), WorkMode.EDIT, c);
rh.accept(wr);
}
use of org.finos.symphony.toolkit.workflow.response.WorkResponse 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