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