Search in sources :

Example 1 with VersionSpace

use of org.finos.symphony.toolkit.json.VersionSpace in project spring-bot by finos.

the class SymphonyWorkflowConfig method entityJsonConverter.

@Bean
@ConditionalOnMissingBean
public EntityJsonConverter entityJsonConverter() {
    List<VersionSpace> workAnnotatedversionSpaces = scanForWorkClasses();
    List<VersionSpace> chatWorkflowVersionSpaces = Arrays.asList(new VersionSpace(EntityJson.getSymphonyTypeName(Security.class), CashTag.class, "1.0", "0.*"), new VersionSpace(EntityJson.getSymphonyTypeName(Hashtag.class), HashTag.class, "1.0", "0.*"), new VersionSpace(EntityJson.getSymphonyTypeName(Mention.class), SymphonyUser.class, "1.0"), new VersionSpace(EntityJson.getSymphonyTypeName(Chat.class), SymphonyRoom.class, "1.0"), new VersionSpace(UserId.class, "1.0"), new VersionSpace(DisplayName.class, "1.0"), new VersionSpace(RoomName.class, "1.0"), new VersionSpace(StreamID.class, "1.0"), new VersionSpace(EmailAddress.class, "1.0"), ObjectMapperFactory.noVersion(Ticker.class), ObjectMapperFactory.noVersion(Cusip.class), ObjectMapperFactory.noVersion(Isin.class), ObjectMapperFactory.noVersion(Openfigi.class), LogMessage.VERSION_SPACE, RoomWelcomeEventConsumer.VERSION_SPACE);
    List<VersionSpace> combined = new ArrayList<>();
    combined.addAll(chatWorkflowVersionSpaces);
    combined.addAll(workAnnotatedversionSpaces);
    return new EntityJsonConverter(combined);
}
Also used : Openfigi(org.symphonyoss.fin.security.id.Openfigi) StreamID(com.symphony.user.StreamID) RoomName(org.finos.symphony.toolkit.workflow.sources.symphony.content.RoomName) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) Ticker(org.symphonyoss.fin.security.id.Ticker) ArrayList(java.util.ArrayList) VersionSpace(org.finos.symphony.toolkit.json.VersionSpace) CashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.CashTag) Isin(org.symphonyoss.fin.security.id.Isin) EmailAddress(com.symphony.user.EmailAddress) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom) Cusip(org.symphonyoss.fin.security.id.Cusip) EntityJsonConverter(org.finos.symphony.toolkit.workflow.sources.symphony.json.EntityJsonConverter) UserId(com.symphony.user.UserId) DisplayName(com.symphony.user.DisplayName) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with VersionSpace

use of org.finos.symphony.toolkit.json.VersionSpace in project spring-bot by finos.

the class KoreAIConfig method koreAIObjectMapper.

public static ObjectMapper koreAIObjectMapper() {
    ObjectMapper out = new ObjectMapper();
    ObjectMapperFactory.initialize(out, ObjectMapperFactory.extendedSymphonyVersionSpace(LogMessage.VERSION_SPACE, new VersionSpace(KoreAIResponse.class), new VersionSpace(ObjectNode.class), new VersionSpace(V4User.class)));
    return out;
}
Also used : VersionSpace(org.finos.symphony.toolkit.json.VersionSpace) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with VersionSpace

use of org.finos.symphony.toolkit.json.VersionSpace in project spring-bot by finos.

the class KoreAIResponseHandlerImplTest method setup.

@BeforeEach
public void setup() throws Exception {
    om = new ObjectMapper();
    ObjectMapperFactory.initialize(om, ObjectMapperFactory.extendedSymphonyVersionSpace(new VersionSpace(KoreAIResponse.class)));
    this.builder = new KoreAIResponseBuilderImpl(new ObjectMapper(), JsonNodeFactory.instance);
    this.output = new KoreAIResponseHandlerImpl(api, rl, true, true, om, "classpath:/test-templates");
    Mockito.when(api.v4StreamSidMessageCreatePost(Mockito.isNull(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.isNull(), Mockito.isNull(), Mockito.isNull(), Mockito.isNull())).then((a) -> {
        streamId.add(a.getArgument(1));
        messageMLResponse.add(a.getArgument(2));
        jsonResponse.add(a.getArgument(3));
        return null;
    });
    jsonResponse = new ArrayList<String>();
    messageMLResponse = new ArrayList<String>();
    streamId = new ArrayList<String>();
}
Also used : VersionSpace(org.finos.symphony.toolkit.json.VersionSpace) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) KoreAIResponseBuilderImpl(org.finos.symphony.toolkit.koreai.response.KoreAIResponseBuilderImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with VersionSpace

use of org.finos.symphony.toolkit.json.VersionSpace 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

VersionSpace (org.finos.symphony.toolkit.json.VersionSpace)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 DisplayName (com.symphony.user.DisplayName)2 EmailAddress (com.symphony.user.EmailAddress)2 StreamID (com.symphony.user.StreamID)2 UserId (com.symphony.user.UserId)2 ArrayList (java.util.ArrayList)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 Mention (com.symphony.user.Mention)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 EntityJson (org.finos.symphony.toolkit.json.EntityJson)1