Search in sources :

Example 6 with SimpleMessageAction

use of org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction in project spring-bot by finos.

the class TestHandlerMapping method execute.

private void execute(String s) throws Exception {
    EntityJson jsonObjects = new EntityJson();
    jsonObjects.put("1", new SymphonyUser(123l, "gaurav", "gaurav@example.com"));
    jsonObjects.put("2", new Taxonomy(Arrays.asList(new HashTag("SomeTopic"))));
    Message m = smp.parse("<messageML>/" + s + "</messageML>", jsonObjects);
    Chat r = new SymphonyRoom("The Room Where It Happened", "abc123");
    User author = new SymphonyUser(ROB_EXAMPLE_ID, ROB_NAME, ROB_EXAMPLE_EMAIL);
    Action a = new SimpleMessageAction(r, author, m, jsonObjects);
    Action.CURRENT_ACTION.set(a);
    mc.accept(a);
}
Also used : Action(org.finos.symphony.toolkit.workflow.actions.Action) SimpleMessageAction(org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction) FormAction(org.finos.symphony.toolkit.workflow.actions.FormAction) EntityJson(org.finos.symphony.toolkit.json.EntityJson) User(org.finos.symphony.toolkit.workflow.content.User) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) Message(org.finos.symphony.toolkit.workflow.content.Message) Taxonomy(org.symphonyoss.Taxonomy) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) Chat(org.finos.symphony.toolkit.workflow.content.Chat) SimpleMessageAction(org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)

Example 7 with SimpleMessageAction

use of org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction in project spring-bot by finos.

the class TestHandlerMapping method getMappingsFor.

private List<ChatMapping<ChatRequest>> getMappingsFor(String s) throws Exception {
    EntityJson jsonObjects = new EntityJson();
    Message m = smp.parse("<messageML>" + s + "</messageML>", jsonObjects);
    Action a = new SimpleMessageAction(null, null, m, jsonObjects);
    return hm.getHandlers(a);
}
Also used : Action(org.finos.symphony.toolkit.workflow.actions.Action) SimpleMessageAction(org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction) FormAction(org.finos.symphony.toolkit.workflow.actions.FormAction) EntityJson(org.finos.symphony.toolkit.json.EntityJson) Message(org.finos.symphony.toolkit.workflow.content.Message) SimpleMessageAction(org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction)

Example 8 with SimpleMessageAction

use of org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction in project spring-bot by finos.

the class PresentationMLHandler method accept.

@Override
public void accept(V4Event t) {
    try {
        V4MessageSent ms = t.getPayload().getMessageSent();
        if ((ms != null) && (!ms.getMessage().getUser().getEmail().equals(botIdentity.getEmail()))) {
            // ok, this is a message, and it's from a third party.  Parse it.
            EntityJson ej = jsonConverter.readValue(ms.getMessage().getData());
            Message words = messageParser.parse(ms.getMessage().getMessage(), ej);
            Addressable rr = ruBuilder.loadRoomById(ms.getMessage().getStream().getStreamId());
            User u = ruBuilder.loadUserById(ms.getMessage().getUser().getUserId());
            // TODO: multi-user chat (not room)
            rr = rr == null ? u : rr;
            SimpleMessageAction sma = new SimpleMessageAction(rr, u, words, ej);
            try {
                Action.CURRENT_ACTION.set(sma);
                for (ActionConsumer c : messageConsumers) {
                    c.accept(sma);
                }
            } finally {
                Action.CURRENT_ACTION.set(Action.NULL_ACTION);
            }
        }
    } catch (Exception e) {
        LOG.error("Couldn't handle event " + t, e);
    }
}
Also used : EntityJson(org.finos.symphony.toolkit.json.EntityJson) User(org.finos.symphony.toolkit.workflow.content.User) Message(org.finos.symphony.toolkit.workflow.content.Message) ActionConsumer(org.finos.symphony.toolkit.workflow.actions.consumers.ActionConsumer) SimpleMessageAction(org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction) V4MessageSent(com.symphony.api.model.V4MessageSent) Addressable(org.finos.symphony.toolkit.workflow.content.Addressable)

Aggregations

SimpleMessageAction (org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction)8 Message (org.finos.symphony.toolkit.workflow.content.Message)6 User (org.finos.symphony.toolkit.workflow.content.User)4 EntityJson (org.finos.symphony.toolkit.json.EntityJson)3 Action (org.finos.symphony.toolkit.workflow.actions.Action)3 FormAction (org.finos.symphony.toolkit.workflow.actions.FormAction)3 Addressable (org.finos.symphony.toolkit.workflow.content.Addressable)3 WorkResponse (org.finos.symphony.toolkit.workflow.response.WorkResponse)2 V4MessageSent (com.symphony.api.model.V4MessageSent)1 CoreDocument (edu.stanford.nlp.pipeline.CoreDocument)1 CoreEntityMention (edu.stanford.nlp.pipeline.CoreEntityMention)1 TimeAnnotations (edu.stanford.nlp.time.TimeAnnotations)1 Timex (edu.stanford.nlp.time.Timex)1 ParseException (java.text.ParseException)1 LocalDateTime (java.time.LocalDateTime)1 Calendar (java.util.Calendar)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ActionConsumer (org.finos.symphony.toolkit.workflow.actions.consumers.ActionConsumer)1 ChatRequest (org.finos.symphony.toolkit.workflow.annotations.ChatRequest)1