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;
}
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));
}
}
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;
}
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;
}
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);
}
Aggregations