Search in sources :

Example 1 with FormResponse

use of org.finos.symphony.toolkit.workflow.response.FormResponse in project spring-bot by finos.

the class WebHookOps method template.

@Exposed(description = "Change the template used by the last called webhook", addToHelp = true, isButton = true, isMessage = true)
public static Response template(SymphonyHistory hist, Addressable a, Workflow wf) {
    Optional<EntityJson> ej = hist.getLastEntityJsonFromHistory(ActiveWebHooks.class, a);
    if (ej.isEmpty()) {
        return new ErrorResponse(wf, a, "No webhooks defined");
    }
    Optional<WebHook> activeHook = hist.getFromEntityJson(ej.get(), WebHook.class);
    if (activeHook.isEmpty()) {
        return new ErrorResponse(wf, a, "Active Hook not set");
    }
    Template t = activeHook.get().getTemplate();
    ButtonList bl = new ButtonList();
    bl.add(new Button(TEMPLATE_UPDATE, Type.ACTION, "Update Template"));
    return new FormResponse(wf, a, ej.get(), "Template Edit", "Update the template used by " + activeHook.get().getDisplayName(), t, true, bl);
}
Also used : FormResponse(org.finos.symphony.toolkit.workflow.response.FormResponse) EntityJson(org.finos.symphony.toolkit.json.EntityJson) Button(org.finos.symphony.toolkit.workflow.form.Button) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) ErrorResponse(org.finos.symphony.toolkit.workflow.response.ErrorResponse) Exposed(org.finos.symphony.toolkit.workflow.java.Exposed)

Aggregations

EntityJson (org.finos.symphony.toolkit.json.EntityJson)1 Button (org.finos.symphony.toolkit.workflow.form.Button)1 ButtonList (org.finos.symphony.toolkit.workflow.form.ButtonList)1 Exposed (org.finos.symphony.toolkit.workflow.java.Exposed)1 ErrorResponse (org.finos.symphony.toolkit.workflow.response.ErrorResponse)1 FormResponse (org.finos.symphony.toolkit.workflow.response.FormResponse)1