use of com.ibm.streamsx.health.hapi.mapper.ObxToSplMapper in project streamsx.health by IBMStreams.
the class OruR01Ingest method run.
@Override
public void run() {
Topology topology = new Topology("OruR01Ingest");
ObxToSplMapper mapper = new ObxToSplMapper();
addDependencies(topology);
TStream<Message> messages = topology.endlessSource(new HapiMessageSupplier(getPort()));
// transform message to Observation object
TStream<Observation> observationStream = messages.multiTransform(message -> {
return mapper.messageToModel(message);
});
StreamSchema schema = Type.Factory.getStreamSchema(Observation.OBSERVATION_SCHEMA_SPL);
@SuppressWarnings("serial") SPLStream splObservations = SPLStreams.convertStream(observationStream, new BiFunction<Observation, OutputTuple, OutputTuple>() {
@Override
public OutputTuple apply(Observation observation, OutputTuple outTuple) {
return mapper.modelToSpl(observation, outTuple);
}
}, schema);
splObservations.print();
splObservations.publish(getTopic());
try {
StreamsContextFactory.getStreamsContext(StreamsContext.Type.DISTRIBUTED).submit(topology);
} catch (Exception e) {
TRACE.error("Unable to submit topology", e);
}
}
Aggregations