Search in sources :

Example 1 with Chat

use of org.finos.symphony.toolkit.workflow.content.Chat in project spring-bot by finos.

the class ClaimController method add.

@ChatButton(value = NewClaim.class, buttonText = "add")
public List<Response> add(NewClaim sc, User u, Addressable from) {
    OpenedClaim c = new OpenedClaim();
    c.amount = sc.amount;
    c.author = u;
    c.description = sc.description;
    c.status = Status.OPEN;
    Chat approvalRoom = conversations.getExistingChat("Claim Approval Room");
    return Arrays.asList(new WorkResponse(approvalRoom, c, WorkMode.VIEW), new MessageResponse(from, Message.of("Your claim has been sent to the Approval Room for processing")));
}
Also used : MessageResponse(org.finos.symphony.toolkit.workflow.response.MessageResponse) Chat(org.finos.symphony.toolkit.workflow.content.Chat) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton)

Example 2 with Chat

use of org.finos.symphony.toolkit.workflow.content.Chat in project spring-bot by finos.

the class PollController method poll.

@ChatButton(buttonText = "start", showWhen = WorkMode.EDIT, value = PollCreateForm.class)
public List<WorkResponse> poll(PollCreateForm cf, Chat r, User a) {
    int[] i = { 0 };
    List<String> options = Arrays.asList(cf.option1, cf.option2, cf.option3, cf.option4, cf.option5, cf.option6).stream().filter(s -> StringUtils.hasText(s)).collect(Collectors.toList());
    ButtonList buttons = new ButtonList(options.stream().map(s -> new Button(PollController.class, "poll" + (i[0]++), Type.ACTION, s)).collect(Collectors.toList()));
    HashTag id = new HashTag(UUID.randomUUID().toString());
    Poll p = new Poll(options);
    p.setPoller(a);
    p.setQuestion(cf.getQuestion());
    p.setOptions(options);
    p.setId(id);
    List<User> users = rooms.getChatMembers(r);
    List<WorkResponse> out = users.stream().filter(u -> !isMe(u)).map(u -> createResponseForUser(cf, options, id, buttons, u)).collect(Collectors.toList());
    out.add(new WorkResponse(r, p, WorkMode.VIEW));
    doScheduling(p, cf, r);
    return out;
}
Also used : Arrays(java.util.Arrays) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) User(org.finos.symphony.toolkit.workflow.content.User) SymphonyIdentity(com.symphony.api.id.SymphonyIdentity) WorkMode(org.finos.symphony.toolkit.workflow.annotations.WorkMode) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) ArrayList(java.util.ArrayList) ResponseHandlers(org.finos.symphony.toolkit.workflow.response.handlers.ResponseHandlers) Conversations(org.finos.symphony.toolkit.workflow.conversations.Conversations) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton) ErrorMap(org.finos.symphony.toolkit.workflow.form.ErrorMap) Type(org.finos.symphony.toolkit.workflow.form.Button.Type) TaskScheduler(org.springframework.scheduling.TaskScheduler) Chat(org.finos.symphony.toolkit.workflow.content.Chat) UUID(java.util.UUID) Button(org.finos.symphony.toolkit.workflow.form.Button) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) History(org.finos.symphony.toolkit.workflow.history.History) List(java.util.List) ChatRequest(org.finos.symphony.toolkit.workflow.annotations.ChatRequest) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) ChatResponseBody(org.finos.symphony.toolkit.workflow.annotations.ChatResponseBody) StringUtils(org.springframework.util.StringUtils) User(org.finos.symphony.toolkit.workflow.content.User) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton) Button(org.finos.symphony.toolkit.workflow.form.Button) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) ButtonList(org.finos.symphony.toolkit.workflow.form.ButtonList) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton)

Example 3 with Chat

use of org.finos.symphony.toolkit.workflow.content.Chat in project spring-bot by finos.

the class TestHandlerMapping method pressButton.

private void pressButton(String s) throws Exception {
    EntityJson jsonObjects = new EntityJson();
    jsonObjects.put("1", new SymphonyUser(123l, "gaurav", "gaurav@example.com"));
    jsonObjects.put("2", new HashTag("SomeTopic"));
    Chat r = new SymphonyRoom("The Room Where It Happened", "abc123");
    User author = new SymphonyUser(ROB_EXAMPLE_ID, ROB_NAME, ROB_EXAMPLE_EMAIL);
    Object fd = new StartClaim();
    Action a = new FormAction(r, author, fd, s, 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) StartClaim(org.finos.symphony.toolkit.workflow.fixture.StartClaim) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) Chat(org.finos.symphony.toolkit.workflow.content.Chat) FormAction(org.finos.symphony.toolkit.workflow.actions.FormAction) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)

Example 4 with Chat

use of org.finos.symphony.toolkit.workflow.content.Chat 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 5 with Chat

use of org.finos.symphony.toolkit.workflow.content.Chat in project spring-bot by finos.

the class SymphonyConversationsImpl method ensureChat.

@Override
public SymphonyRoom ensureChat(Chat r, List<User> users, Map<String, Object> meta) {
    String description = "";
    String name = r.getName();
    boolean isPublic = false;
    description = (String) meta.getOrDefault(ROOM_DESCRIPTION, "");
    isPublic = (boolean) meta.getOrDefault(ROOM_PUBLIC, false);
    SymphonyRoom theRoom = null;
    if (r instanceof SymphonyRoom) {
        if (((SymphonyRoom) r).getStreamId() != null) {
            theRoom = (SymphonyRoom) r;
        } else {
            theRoom = loadRoomByName(name);
        }
    }
    if (theRoom == null) {
        // create the room
        V3RoomAttributes ra = new V3RoomAttributes().name(name).description(description)._public(isPublic).discoverable(isPublic);
        V3RoomDetail detail = streamsApi.v3RoomCreatePost(ra, null);
        String streamId = detail.getRoomSystemInfo().getId();
        theRoom = new SymphonyRoom(name, streamId);
        // next, we need to make sure that all of the admins are members of the room and owners.
        List<Long> adminIds = getDefaultAdministrators().stream().filter(u -> u instanceof SymphonyUser).map(u -> (SymphonyUser) u).map(su -> Long.parseLong(su.getUserId())).filter(id -> id != null).collect(Collectors.toList());
        for (Long user : adminIds) {
            UserId u = new UserId().id(user);
            rmApi.v1RoomIdMembershipAddPost(u, null, streamId);
            rmApi.v1RoomIdMembershipPromoteOwnerPost(u, null, streamId);
        }
        LOG.info("Created room {} with admins {} ", theRoom, getDefaultAdministrators());
    }
    // next, ensure that all the users are in the room
    String streamId = theRoom.getStreamId();
    users.stream().filter(u -> u instanceof SymphonyUser).map(u -> (SymphonyUser) u).forEach(u -> rmApi.v1RoomIdMembershipAddPost(new UserId().id(Long.parseLong(u.getUserId())), null, streamId));
    return theRoom;
}
Also used : V2RoomSearchCriteria(com.symphony.api.model.V2RoomSearchCriteria) User(org.finos.symphony.toolkit.workflow.content.User) SymphonyIdentity(com.symphony.api.id.SymphonyIdentity) TypeEnum(com.symphony.api.model.StreamType.TypeEnum) LoggerFactory(org.slf4j.LoggerFactory) V3RoomDetail(com.symphony.api.model.V3RoomDetail) StreamsApi(com.symphony.api.pod.StreamsApi) InitializingBean(org.springframework.beans.factory.InitializingBean) V3RoomAttributes(com.symphony.api.model.V3RoomAttributes) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Map(java.util.Map) StreamList(com.symphony.api.model.StreamList) UserV2(com.symphony.api.model.UserV2) V3RoomSearchResults(com.symphony.api.model.V3RoomSearchResults) Logger(org.slf4j.Logger) UsersApi(com.symphony.api.pod.UsersApi) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) AbstractStreamResolving(org.finos.symphony.toolkit.workflow.sources.symphony.streams.AbstractStreamResolving) MembershipList(com.symphony.api.model.MembershipList) SymphonyApiProperties(org.finos.symphony.toolkit.spring.api.properties.SymphonyApiProperties) RoomMembershipApi(com.symphony.api.pod.RoomMembershipApi) Set(java.util.Set) Chat(org.finos.symphony.toolkit.workflow.content.Chat) Collectors(java.util.stream.Collectors) List(java.util.List) Addressable(org.finos.symphony.toolkit.workflow.content.Addressable) StreamAttributes(com.symphony.api.model.StreamAttributes) StreamID(com.symphony.user.StreamID) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom) StreamFilter(com.symphony.api.model.StreamFilter) Collections(java.util.Collections) StreamType(com.symphony.api.model.StreamType) UserId(com.symphony.api.model.UserId) V3RoomDetail(com.symphony.api.model.V3RoomDetail) UserId(com.symphony.api.model.UserId) V3RoomAttributes(com.symphony.api.model.V3RoomAttributes) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)

Aggregations

Chat (org.finos.symphony.toolkit.workflow.content.Chat)5 User (org.finos.symphony.toolkit.workflow.content.User)4 HashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag)3 SymphonyRoom (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)3 SymphonyUser (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser)3 SymphonyIdentity (com.symphony.api.id.SymphonyIdentity)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 EntityJson (org.finos.symphony.toolkit.json.EntityJson)2 Action (org.finos.symphony.toolkit.workflow.actions.Action)2 FormAction (org.finos.symphony.toolkit.workflow.actions.FormAction)2 SimpleMessageAction (org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction)2 ChatButton (org.finos.symphony.toolkit.workflow.annotations.ChatButton)2 MembershipList (com.symphony.api.model.MembershipList)1 StreamAttributes (com.symphony.api.model.StreamAttributes)1 StreamFilter (com.symphony.api.model.StreamFilter)1 StreamList (com.symphony.api.model.StreamList)1 StreamType (com.symphony.api.model.StreamType)1 TypeEnum (com.symphony.api.model.StreamType.TypeEnum)1