Search in sources :

Example 1 with Work

use of org.finos.symphony.toolkit.workflow.annotations.Work in project spring-bot by finos.

the class WorkResponseConverter method canConvert.

@Override
public boolean canConvert(Object in) {
    if (in == null) {
        return false;
    }
    Class<?> c = in.getClass();
    Work work = c.getAnnotation(Work.class);
    if (work != null) {
        return true;
    }
    return false;
}
Also used : Work(org.finos.symphony.toolkit.workflow.annotations.Work)

Example 2 with Work

use of org.finos.symphony.toolkit.workflow.annotations.Work 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 Work

use of org.finos.symphony.toolkit.workflow.annotations.Work in project spring-bot by finos.

the class SymphonyWorkflowConfig method scanForWorkClasses.

protected List<VersionSpace> scanForWorkClasses() {
    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
    scanner.addIncludeFilter(new AnnotationTypeFilter(Work.class));
    Set<BeanDefinition> toAdd = scanner.findCandidateComponents(getPackageName(ChatWorkflowConfig.class));
    for (String ent : ac.getBeanNamesForAnnotation(SpringBootApplication.class)) {
        String packageName = getPackageName(ac.getBean(ent).getClass());
        Set<BeanDefinition> user = scanner.findCandidateComponents(packageName);
        toAdd.addAll(user);
    }
    List<VersionSpace> versionSpaces = toAdd.stream().map(bd -> bd.getBeanClassName()).map(s -> {
        try {
            return Class.forName(s);
        } catch (ClassNotFoundException e) {
            LOG.error("Couldn't instantiate: " + s, e);
            return null;
        }
    }).filter(x -> x != null).flatMap(c -> {
        Work w = c.getAnnotation(Work.class);
        String[] jsonTypeName = w.jsonTypeName();
        return IntStream.range(0, jsonTypeName.length).mapToObj(i -> {
            String t = jsonTypeName[i];
            if (i == 0) {
                t = StringUtils.hasText(t) ? t : EntityJson.getSymphonyTypeName(c);
                String writeVersion = w.writeVersion();
                String[] readVersions = w.readVersions();
                return new VersionSpace(t, c, writeVersion, readVersions);
            } else {
                String[] readVersions = w.readVersions();
                return new VersionSpace(t, c, null, readVersions);
            }
        });
    }).collect(Collectors.toList());
    return versionSpaces;
}
Also used : Paragraph(org.finos.symphony.toolkit.workflow.content.Paragraph) Arrays(java.util.Arrays) SymphonyHistoryImpl(org.finos.symphony.toolkit.workflow.sources.symphony.history.SymphonyHistoryImpl) Validator(org.springframework.validation.Validator) SymphonyIdentity(com.symphony.api.id.SymphonyIdentity) RoomWelcomeEventConsumer(org.finos.symphony.toolkit.stream.welcome.RoomWelcomeEventConsumer) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Security(org.symphonyoss.fin.Security) FormMessageMLConverter(org.finos.symphony.toolkit.workflow.sources.symphony.handlers.FormMessageMLConverter) StreamsApi(com.symphony.api.pod.StreamsApi) CashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.CashTag) MessagesApi(com.symphony.api.agent.MessagesApi) AttachmentHandler(org.finos.symphony.toolkit.workflow.sources.symphony.handlers.AttachmentHandler) UserId(com.symphony.user.UserId) FreemarkerTypeConverterConfig(org.finos.symphony.toolkit.workflow.sources.symphony.handlers.freemarker.FreemarkerTypeConverterConfig) AddressingChecker(org.finos.symphony.toolkit.workflow.actions.consumers.AddressingChecker) UserV2(com.symphony.api.model.UserV2) AnnotationTypeFilter(org.springframework.core.type.filter.AnnotationTypeFilter) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) UnorderedList(org.finos.symphony.toolkit.workflow.content.UnorderedList) FreemarkerFormMessageMLConverter(org.finos.symphony.toolkit.workflow.sources.symphony.handlers.freemarker.FreemarkerFormMessageMLConverter) ResourceLoader(org.springframework.core.io.ResourceLoader) SymphonyApiProperties(org.finos.symphony.toolkit.spring.api.properties.SymphonyApiProperties) ActionConsumer(org.finos.symphony.toolkit.workflow.actions.consumers.ActionConsumer) Hashtag(org.symphonyoss.taxonomy.Hashtag) SymphonyHistory(org.finos.symphony.toolkit.workflow.sources.symphony.history.SymphonyHistory) RoomMembershipApi(com.symphony.api.pod.RoomMembershipApi) Set(java.util.Set) FormConverter(org.finos.symphony.toolkit.workflow.sources.symphony.elements.FormConverter) Collectors(java.util.stream.Collectors) ElementsHandler(org.finos.symphony.toolkit.workflow.sources.symphony.elements.ElementsHandler) TypeConverter(org.finos.symphony.toolkit.workflow.sources.symphony.handlers.freemarker.TypeConverter) MessageMLParser(org.finos.symphony.toolkit.workflow.sources.symphony.messages.MessageMLParser) EmailAddress(com.symphony.user.EmailAddress) Configuration(org.springframework.context.annotation.Configuration) List(java.util.List) PresentationMLHandler(org.finos.symphony.toolkit.workflow.sources.symphony.messages.PresentationMLHandler) SymphonyResponseHandler(org.finos.symphony.toolkit.workflow.sources.symphony.handlers.SymphonyResponseHandler) Ticker(org.symphonyoss.fin.security.id.Ticker) Lazy(org.springframework.context.annotation.Lazy) CodeBlock(org.finos.symphony.toolkit.workflow.content.CodeBlock) IntStream(java.util.stream.IntStream) Mention(com.symphony.user.Mention) Table(org.finos.symphony.toolkit.workflow.content.Table) Word(org.finos.symphony.toolkit.workflow.content.Word) LogMessage(org.finos.symphony.toolkit.stream.log.LogMessage) InRoomAddressingChecker(org.finos.symphony.toolkit.workflow.actions.consumers.InRoomAddressingChecker) DisplayName(com.symphony.user.DisplayName) ArrayList(java.util.ArrayList) Openfigi(org.symphonyoss.fin.security.id.Openfigi) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) SymphonyConversationsImpl(org.finos.symphony.toolkit.workflow.sources.symphony.conversations.SymphonyConversationsImpl) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Message(org.finos.symphony.toolkit.workflow.content.Message) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) VersionSpace(org.finos.symphony.toolkit.json.VersionSpace) OrderedList(org.finos.symphony.toolkit.workflow.content.OrderedList) HeaderTagResponseHandler(org.finos.symphony.toolkit.workflow.sources.symphony.handlers.HeaderTagResponseHandler) MessageMLWriter(org.finos.symphony.toolkit.workflow.sources.symphony.messages.MessageMLWriter) Logger(org.slf4j.Logger) SpringBootApplication(org.springframework.boot.autoconfigure.SpringBootApplication) Isin(org.symphonyoss.fin.security.id.Isin) UsersApi(com.symphony.api.pod.UsersApi) ChatWorkflowConfig(org.finos.symphony.toolkit.workflow.ChatWorkflowConfig) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) SymphonyApiConfig(org.finos.symphony.toolkit.spring.api.SymphonyApiConfig) ClassPathScanningCandidateComponentProvider(org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider) Import(org.springframework.context.annotation.Import) Chat(org.finos.symphony.toolkit.workflow.content.Chat) SymphonyConversations(org.finos.symphony.toolkit.workflow.sources.symphony.conversations.SymphonyConversations) ApplicationContext(org.springframework.context.ApplicationContext) SharedStreamSingleBotConfig(org.finos.symphony.toolkit.stream.single.SharedStreamSingleBotConfig) RoomName(org.finos.symphony.toolkit.workflow.sources.symphony.content.RoomName) JerseyAttachmentHandlerConfig(org.finos.symphony.toolkit.workflow.sources.symphony.handlers.jersey.JerseyAttachmentHandlerConfig) Work(org.finos.symphony.toolkit.workflow.annotations.Work) StreamID(com.symphony.user.StreamID) EntityJson(org.finos.symphony.toolkit.json.EntityJson) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom) Cusip(org.symphonyoss.fin.security.id.Cusip) Bean(org.springframework.context.annotation.Bean) EntityJsonConverter(org.finos.symphony.toolkit.workflow.sources.symphony.json.EntityJsonConverter) AutoConfigureBefore(org.springframework.boot.autoconfigure.AutoConfigureBefore) ObjectMapperFactory(org.finos.symphony.toolkit.json.ObjectMapperFactory) StringUtils(org.springframework.util.StringUtils) AnnotationTypeFilter(org.springframework.core.type.filter.AnnotationTypeFilter) ClassPathScanningCandidateComponentProvider(org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider) Work(org.finos.symphony.toolkit.workflow.annotations.Work) ChatWorkflowConfig(org.finos.symphony.toolkit.workflow.ChatWorkflowConfig) VersionSpace(org.finos.symphony.toolkit.json.VersionSpace) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Aggregations

Work (org.finos.symphony.toolkit.workflow.annotations.Work)3 HashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag)2 MessagesApi (com.symphony.api.agent.MessagesApi)1 SymphonyIdentity (com.symphony.api.id.SymphonyIdentity)1 UserV2 (com.symphony.api.model.UserV2)1 RoomMembershipApi (com.symphony.api.pod.RoomMembershipApi)1 StreamsApi (com.symphony.api.pod.StreamsApi)1 UsersApi (com.symphony.api.pod.UsersApi)1 DisplayName (com.symphony.user.DisplayName)1 EmailAddress (com.symphony.user.EmailAddress)1 Mention (com.symphony.user.Mention)1 StreamID (com.symphony.user.StreamID)1 UserId (com.symphony.user.UserId)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1