Search in sources :

Example 6 with ButtonList

use of org.finos.symphony.toolkit.workflow.form.ButtonList in project spring-bot by finos.

the class TestFormMessageML method testValidation.

@Test
public void testValidation() throws Exception {
    TestObject a = new TestObject("83274239874", true, true, "rob", 234786, 2138);
    SymphonyRoom theRoom = new SymphonyRoom("tesxt room", "abc123");
    ButtonList bl = new ButtonList();
    Button submit = new Button("submit", Type.ACTION, "GO");
    bl.add(submit);
    Errors eh = ErrorHelp.createErrorHolder();
    validator.validate(a, eh);
    WorkResponse wr = new WorkResponse(theRoom, a, WorkMode.EDIT, bl, ElementsHandler.convertErrorsToMap(eh));
    testTemplating(wr, "abc123", "testValidation.ml", "testValidation.json");
}
Also used : Errors(org.springframework.validation.Errors) Button(org.finos.symphony.toolkit.workflow.form.Button) TestObject(org.finos.symphony.toolkit.workflow.fixture.TestObject) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom) Test(org.junit.jupiter.api.Test)

Example 7 with ButtonList

use of org.finos.symphony.toolkit.workflow.form.ButtonList in project spring-bot by finos.

the class TestFormMessageML method createWeirdFieldsWorkResponse.

protected WorkResponse createWeirdFieldsWorkResponse(WorkMode wm) {
    SymphonyRoom theRoom = new SymphonyRoom("tesxt room", "abc123");
    SymphonyUser someUser = new SymphonyUser(2678l, "bob", "bob@example.com");
    WeirdObject to4 = new WeirdObject();
    to4.setTheId(new HashTag("adf360dd-06fe-43a4-9a62-2c17fe2deefa"));
    to4.setC(Choice.C);
    to4.setSomeUser(someUser);
    to4.setCashTag(new CashTag("rameses"));
    to4.setB(true);
    to4.setC(Choice.B);
    Button submit = new Button("submit", Type.ACTION, "GO");
    WorkResponse wr = new WorkResponse(theRoom, to4, wm);
    ButtonList bl = (ButtonList) wr.getData().get(ButtonList.KEY);
    bl.add(submit);
    return wr;
}
Also used : WeirdObject(org.finos.symphony.toolkit.workflow.fixture.WeirdObject) Button(org.finos.symphony.toolkit.workflow.form.Button) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) CashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.CashTag) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)

Example 8 with ButtonList

use of org.finos.symphony.toolkit.workflow.form.ButtonList in project spring-bot by finos.

the class ButtonsResponseHandler method accept.

@Override
public void accept(Response t) {
    if (t instanceof WorkResponse) {
        Object o = ((WorkResponse) t).getFormObject();
        WorkMode wm = ((WorkResponse) t).getMode();
        ButtonList obl = (ButtonList) ((WorkResponse) t).getData().get(ButtonList.KEY);
        if ((obl != null) && (obl.getContents().size() > 0)) {
            return;
        }
        obl = new ButtonList();
        ((WorkResponse) t).getData().put(ButtonList.KEY, obl);
        final ButtonList bl = obl;
        initExposedHandlerMappings();
        exposedHandlerMappings.stream().flatMap(hm -> hm.getAllHandlers(t.getAddress(), null).stream()).filter(cm -> exposedMatchesObject(cm.getMapping(), o)).filter(cm -> cm.isButtonFor(o, wm)).forEach(cm -> {
            ChatButton e = cm.getMapping();
            String value = cm.getUniqueName();
            String text = e.buttonText();
            text = StringUtils.hasText(text) ? text : formatFieldName(cm.getHandlerMethod().getMethod().getName());
            bl.add(new Button(value, Type.ACTION, text));
        });
        Collections.sort((List<Button>) bl.getContents());
    }
}
Also used : Arrays(java.util.Arrays) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) Type(org.finos.symphony.toolkit.workflow.form.Button.Type) WorkMode(org.finos.symphony.toolkit.workflow.annotations.WorkMode) Response(org.finos.symphony.toolkit.workflow.response.Response) BeansException(org.springframework.beans.BeansException) Button(org.finos.symphony.toolkit.workflow.form.Button) ChatHandlerMapping(org.finos.symphony.toolkit.workflow.java.mapping.ChatHandlerMapping) Collectors(java.util.stream.Collectors) ApplicationContext(org.springframework.context.ApplicationContext) List(java.util.List) Optional(java.util.Optional) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) ResolvableType(org.springframework.core.ResolvableType) Collections(java.util.Collections) ApplicationContextAware(org.springframework.context.ApplicationContextAware) StringUtils(org.springframework.util.StringUtils) Button(org.finos.symphony.toolkit.workflow.form.Button) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) WorkMode(org.finos.symphony.toolkit.workflow.annotations.WorkMode)

Aggregations

Button (org.finos.symphony.toolkit.workflow.form.Button)8 ButtonList (org.finos.symphony.toolkit.workflow.form.ButtonList)8 WorkResponse (org.finos.symphony.toolkit.workflow.response.WorkResponse)7 SymphonyRoom (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)4 ChatButton (org.finos.symphony.toolkit.workflow.annotations.ChatButton)3 Arrays (java.util.Arrays)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ChatRequest (org.finos.symphony.toolkit.workflow.annotations.ChatRequest)2 WorkMode (org.finos.symphony.toolkit.workflow.annotations.WorkMode)2 Type (org.finos.symphony.toolkit.workflow.form.Button.Type)2 HashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag)2 StringUtils (org.springframework.util.StringUtils)2 SymphonyIdentity (com.symphony.api.id.SymphonyIdentity)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 EntityJson (org.finos.symphony.toolkit.json.EntityJson)1