Search in sources :

Example 1 with HashTag

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

the class TestFormCollectionsMessageML method createTestCollections.

private TestCollections createTestCollections() {
    MiniBean mb1 = new MiniBean("A String", 4973, Arrays.asList("Amsidh", "Rob"));
    MiniBean mb2 = new MiniBean("Another String", 45, Arrays.asList("Terry", "James"));
    MiniBean mb3 = new MiniBean("Thing 3", 8787, null);
    TestCollections out = new TestCollections(Arrays.asList("a", "b", "c"), Arrays.asList(Choice.A, Choice.B), Arrays.asList(mb1, mb2, mb3), Arrays.asList(new HashTag("abc"), new HashTag("def")));
    return out;
}
Also used : MiniBean(org.finos.symphony.toolkit.workflow.fixture.TestCollections.MiniBean) TestCollections(org.finos.symphony.toolkit.workflow.fixture.TestCollections) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag)

Example 2 with HashTag

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

the class HeaderTagResponseHandler method accept.

/**
 * This ensures that the JSON data being sent will contain a HeaderDetails
 * object, which contains a list of {@link HashTag}s that need to be present in
 * the message for indexing purposes.
 */
@Override
public void accept(Response t) {
    if (t instanceof WorkResponse) {
        WorkResponse workResponse = (WorkResponse) t;
        HeaderDetails hd = (HeaderDetails) workResponse.getData().get(HeaderDetails.KEY);
        if (hd == null) {
            hd = new HeaderDetails();
            workResponse.getData().put(HeaderDetails.KEY, hd);
        }
        // make sure all tags are unique, maintain order from original.
        Set<HashTag> tags = new LinkedHashSet<>();
        tags.addAll(hd.getTags());
        // check through other stuff in the json response
        for (Object o2 : workResponse.getData().values()) {
            Work w = o2 != null ? o2.getClass().getAnnotation(Work.class) : null;
            if ((w != null) && (w.index())) {
                tags.addAll(TagSupport.classHashTags(o2));
            }
        }
        hd.setTags(new ArrayList<HashTag>(tags));
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) Work(org.finos.symphony.toolkit.workflow.annotations.Work) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) HeaderDetails(org.finos.symphony.toolkit.workflow.sources.symphony.json.HeaderDetails)

Example 3 with HashTag

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

the class TimedAlerter method allItemsInFeed.

private int allItemsInFeed(Feed f, Addressable a, FeedList fl) {
    int count = 0;
    try {
        for (SyndEntry e : loader.createSyndFeed(f).getEntries()) {
            if (passesFilter(e, fl)) {
                HashTag fht = createFeedHashTag(f);
                HashTag aht = createArticleHashTag(e.getLink());
                Article article = new Article(e.getTitle(), e.getAuthor(), f.getName(), e.getLink(), fl, fht, aht);
                count += sender.post(a, article);
            }
        }
    } catch (Exception e) {
        LOG.error("Coulnd't process feed" + f.getName(), e);
    }
    return count;
}
Also used : SyndEntry(com.rometools.rome.feed.synd.SyndEntry) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) Article(org.finos.symphony.rssbot.feed.Article)

Example 4 with HashTag

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

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

the class TestContents method testContents.

@Test
public void testContents() {
    // tag def
    doAssertsOnContent(new CashTag("id123"), new CashTag("id123"));
    doAssertsOnContent(new HashTag("id123"), new HashTag("id123"));
    // room def
    doAssertsOnObject(new SymphonyRoom("abc", "abc123"), new SymphonyRoom("abc", "abc123"));
    doAssertsOnObject(new SymphonyRoom(null, "abc123"), new SymphonyRoom(null, "abc123"));
    doAssertsOnObject(new SymphonyRoom("abc", "abc123"), new SymphonyRoom("abc", "abc123"));
    doAssertsOnObject(new SymphonyRoom("abc", null), new SymphonyRoom("abc", null));
    // user def
    doAssertsOnObject(new SymphonyUser(123l, "rob", "rob@example.com"), new SymphonyUser(123l, "rob", "rob@example.com"));
    doAssertsOnObject(new SymphonyUser("rob", "rob@example.com"), new SymphonyUser("rob", "rob@example.com"));
    doAssertsOnObject(new SymphonyUser(null, "rob@example.com"), new SymphonyUser(null, "rob@example.com"));
    doAssertsOnObject(new SymphonyUser(123l, "rob", null), new SymphonyUser(123l, "rob", null));
    // id
    UUID some = UUID.randomUUID();
    doAssertsOnContent(HashTag.createID(some), HashTag.createID(some));
    // wordx
    Word w1 = Word.of("hello");
    Word w2 = Word.of("bye");
    doAssertsOnContent(w1, Word.of("hello"));
    // paragraph
    Paragraph p1 = Paragraph.of(Arrays.asList(w1, w2));
    Paragraph p2 = Paragraph.of(Arrays.asList(w1, w2));
    doAssertsOnContent(p1, p2);
    doAssertsOnContent(p1.getNth(Word.class, 0).get(), p2.getNth(Word.class, 0).get());
    // message
    Message m1 = Message.of(Arrays.asList(p1, p2));
    Message m2 = Message.of(Arrays.asList(p1, p2));
    doAssertsOnContent(m1, m2);
}
Also used : Word(org.finos.symphony.toolkit.workflow.content.Word) Message(org.finos.symphony.toolkit.workflow.content.Message) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) CashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.CashTag) UUID(java.util.UUID) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom) Paragraph(org.finos.symphony.toolkit.workflow.content.Paragraph) Test(org.junit.jupiter.api.Test)

Aggregations

HashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag)11 SymphonyUser (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser)6 WorkResponse (org.finos.symphony.toolkit.workflow.response.WorkResponse)4 SymphonyRoom (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)4 EntityJson (org.finos.symphony.toolkit.json.EntityJson)3 Chat (org.finos.symphony.toolkit.workflow.content.Chat)3 Message (org.finos.symphony.toolkit.workflow.content.Message)3 User (org.finos.symphony.toolkit.workflow.content.User)3 CashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.CashTag)3 UUID (java.util.UUID)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 WeirdObject (org.finos.symphony.toolkit.workflow.fixture.WeirdObject)2 Button (org.finos.symphony.toolkit.workflow.form.Button)2 ButtonList (org.finos.symphony.toolkit.workflow.form.ButtonList)2 Test (org.junit.jupiter.api.Test)2 Taxonomy (org.symphonyoss.Taxonomy)2 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)1 SymphonyIdentity (com.symphony.api.id.SymphonyIdentity)1