Search in sources :

Example 1 with HeaderDetails

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));
    }
}
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 2 with HeaderDetails

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));
}
Also used : EntityJson(org.finos.symphony.toolkit.json.EntityJson) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) HeaderDetails(org.finos.symphony.toolkit.workflow.sources.symphony.json.HeaderDetails) Test(org.junit.jupiter.api.Test)

Aggregations

HashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag)2 HeaderDetails (org.finos.symphony.toolkit.workflow.sources.symphony.json.HeaderDetails)2 LinkedHashSet (java.util.LinkedHashSet)1 EntityJson (org.finos.symphony.toolkit.json.EntityJson)1 Work (org.finos.symphony.toolkit.workflow.annotations.Work)1 WorkResponse (org.finos.symphony.toolkit.workflow.response.WorkResponse)1 Test (org.junit.jupiter.api.Test)1