Search in sources :

Example 1 with AttributeMapping

use of io.siddhi.core.stream.input.source.AttributeMapping in project siddhi by wso2.

the class TestTrpSourceMapper method mapAndProcess.

@Override
protected void mapAndProcess(Object eventObject, InputEventHandler inputEventHandler) throws MappingFailedException, InterruptedException {
    if (eventObject != null) {
        if (eventObject instanceof Event) {
            Event output = new Event(streamDefinition.getAttributeList().size());
            for (AttributeMapping attributeMapping : attributeMappingList) {
                output.getData()[attributeMapping.getPosition()] = ((Event) eventObject).getData(Integer.parseInt(attributeMapping.getMapping()));
            }
            inputEventHandler.sendEvent(output);
        } else {
            throw new MappingFailedException(Collections.singletonList(new ErroneousEvent(eventObject, "Event object must be either Event[], Event or Object[] " + "but found " + eventObject.getClass().getCanonicalName())));
        }
    }
}
Also used : AttributeMapping(io.siddhi.core.stream.input.source.AttributeMapping) ErroneousEvent(io.siddhi.core.util.error.handler.model.ErroneousEvent) Event(io.siddhi.core.event.Event) MappingFailedException(io.siddhi.core.exception.MappingFailedException) ErroneousEvent(io.siddhi.core.util.error.handler.model.ErroneousEvent)

Aggregations

Event (io.siddhi.core.event.Event)1 MappingFailedException (io.siddhi.core.exception.MappingFailedException)1 AttributeMapping (io.siddhi.core.stream.input.source.AttributeMapping)1 ErroneousEvent (io.siddhi.core.util.error.handler.model.ErroneousEvent)1