use of org.finos.symphony.toolkit.workflow.sources.symphony.json.HeaderDetails 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.json.HeaderDetails in project spring-bot by finos.
the class TestEntityJsonConversion method testLegacyLoad.
@Test
public void testLegacyLoad() throws Exception {
String toLoad = StreamUtils.copyToString(TestEntityJsonConversion.class.getResourceAsStream("legacyJsonFormat.json"), StandardCharsets.UTF_8);
EntityJson ej = converter.readValue(toLoad);
HeaderDetails hd = (HeaderDetails) ej.get(HeaderDetails.KEY);
Assertions.assertEquals(3, hd.getTags().size());
HashTag first = new HashTag("symphony-workflow");
Assertions.assertEquals(first, hd.getTags().get(0));
}
Aggregations