use of io.siddhi.core.util.transport.TemplateBuilder in project siddhi by wso2.
the class SinkMapper method buildMapperTemplate.
/**
* Method to create mapper template.
*
* @param streamDefinition Stream definition corresponding to mapper
* @param unmappedPayloadList mapper payload template list
*/
protected void buildMapperTemplate(StreamDefinition streamDefinition, List<Element> unmappedPayloadList) {
if (unmappedPayloadList != null && !unmappedPayloadList.isEmpty()) {
templateBuilderMap = new HashMap<>();
for (Element e : unmappedPayloadList) {
TemplateBuilder templateBuilder = new TemplateBuilder(streamDefinition, e.getValue());
if (templateBuilderMap.containsKey(e.getKey())) {
throw new SiddhiAppCreationException("Duplicate Keys, " + e.getKey() + ", in @payload() ");
}
templateBuilderMap.put(e.getKey(), templateBuilder);
}
}
}
use of io.siddhi.core.util.transport.TemplateBuilder in project siddhi by wso2.
the class TestSinkOptionSinkMapper method mapAndSend.
@Override
public void mapAndSend(Event[] events, OptionHolder optionHolder, Map<String, TemplateBuilder> payloadTemplateBuilderMap, SinkListener sinkListener) {
for (Event event : events) {
String topic = topicOption.getValue(event);
if (mapType) {
for (TemplateBuilder templateBuilder : payloadTemplateBuilderMap.values()) {
sinkListener.publish(new Event(System.currentTimeMillis(), new Object[] { sinkType, topic, templateBuilder.isObjectMessage() + "-" + templateBuilder.getType().toString() }));
}
} else {
// to change the topic as topic is picked from the original event
event.getData()[0] = sinkType;
sinkListener.publish(new Event(System.currentTimeMillis(), new Object[] { sinkType, topic, prefix }));
}
}
}
use of io.siddhi.core.util.transport.TemplateBuilder in project siddhi by wso2.
the class TestSinkOptionSinkMapper method mapAndSend.
@Override
public void mapAndSend(Event event, OptionHolder optionHolder, Map<String, TemplateBuilder> payloadTemplateBuilderMap, SinkListener sinkListener) {
String topic = topicOption.getValue(event);
if (mapType) {
for (TemplateBuilder templateBuilder : payloadTemplateBuilderMap.values()) {
sinkListener.publish(new Event(System.currentTimeMillis(), new Object[] { sinkType, topic, templateBuilder.isObjectMessage() + "-" + templateBuilder.getType().toString() }));
}
} else {
// to change the topic as topic is picked from the original event
event.getData()[0] = sinkType;
sinkListener.publish(new Event(System.currentTimeMillis(), new Object[] { sinkType, topic, prefix }));
}
}
Aggregations