use of bind.feature.generichierarchy.case1.model.Message 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);
}
}
use of bind.feature.generichierarchy.case1.model.Message in project tdi-studio-se by Talend.
the class HL7MessageTreeContentProvider method getChildren.
public Object[] getChildren(Object parentElement) {
List values = new ArrayList();
if (parentElement instanceof Message) {
Message messParent = (Message) parentElement;
String[] childNames = messParent.getNames();
if (!values.isEmpty()) {
values.clear();
}
for (int i = 0; i < childNames.length; i++) {
try {
Structure[] childReps = messParent.getAll(childNames[i]);
for (int j = 0; j < childReps.length; j++) {
if (childReps[j] instanceof Message) {
values.add(childReps[j]);
}
if (childReps[j] instanceof Group) {
values.add((Group) childReps[j]);
allSegmentFromGroup.clear();
getAllSegmentsFromGroup((Group) childReps[j]);
}
if (childReps[j] instanceof Segment) {
SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j);
if (sModel.getTypes() != null && sModel.getTypes().length > 0) {
values.add(sModel);
if (!allSegmentsForMessage.contains(sModel)) {
allSegmentsForMessage.add(sModel);
}
}
}
}
// values.addAll(Arrays.asList(childReps));
} catch (HL7Exception e) {
e.printStackTrace();
}
}
return values.toArray();
}
if (parentElement instanceof Segment) {
values.clear();
Segment segment = (Segment) parentElement;
SegmentModel sm = new SegmentModel(segment, segment, 0, 0);
return sm.getTypes();
}
if (parentElement instanceof SegmentModel) {
SegmentModel sm = (SegmentModel) parentElement;
return sm.getTypes();
}
if (parentElement instanceof TypeModel) {
TypeModel tm = (TypeModel) parentElement;
return tm.getPrimitives();
}
if (parentElement instanceof Group) {
values.clear();
Group group = (Group) parentElement;
String[] childNames = group.getNames();
for (int i = 0; i < childNames.length; i++) {
try {
Structure[] childReps = group.getAll(childNames[i]);
for (int j = 0; j < childReps.length; j++) {
if (childReps[j] instanceof Segment) {
SegmentModel sm = new SegmentModel((Segment) childReps[j], group, i, j);
if (sm.getTypes() != null && sm.getTypes().length > 0) {
values.add(sm);
}
} else {
values.add(childReps[j]);
}
}
// values.addAll(Arrays.asList(childReps));
} catch (HL7Exception e) {
e.printStackTrace();
}
}
return values.toArray();
}
return new Object[0];
}
use of bind.feature.generichierarchy.case1.model.Message in project tdi-studio-se by Talend.
the class HL7Parse method doParse.
/**
* DOC gcui Comment method "doParse".
*
* @param filePath
* @return
*/
public List<Message> doParse(String filePath, String startChar, String endChar) {
List<Message> messageList = new ArrayList<Message>();
String filePathNoQuotes = TalendTextUtils.removeQuotes(filePath);
File file = Path.fromOSString(filePathNoQuotes).toFile();
if (file.exists()) {
ByteArray array = PropertiesFactory.eINSTANCE.createByteArray();
try {
array.setInnerContentFromFile(file);
TalendHL7Reader talendHL7Reader = new TalendHL7Reader(new java.io.FileInputStream(file), "ISO-8859-15");
if (startChar != null) {
talendHL7Reader.setStartMsgChar(stringParse2Char(startChar));
}
if (endChar != null) {
talendHL7Reader.setEndMsgChar(stringParse2Char(endChar));
}
String HL7InputTem = null;
String messageText = "";
while ((HL7InputTem = talendHL7Reader.getMessage()) != null) {
Message message = getHL7MessageInput(HL7InputTem);
messageList.add(message);
messageText = messageText + HL7InputTem + "\r";
}
if (messageText == null || "".equals(messageText)) {
messageText = new String(array.getInnerContent());
}
talendHL7Reader.close();
} catch (IOException ex) {
ExceptionHandler.process(ex);
}
} else {
MessageBox message = new MessageBox(new Shell(), SWT.APPLICATION_MODAL | SWT.OK);
//$NON-NLS-1$
message.setText("The file is not exist");
//$NON-NLS-1$
message.setMessage("Please check the file path and select the file again");
if (message.open() == SWT.OK) {
message.getParent().getShell().close();
}
}
return messageList;
}
use of bind.feature.generichierarchy.case1.model.Message in project tdi-studio-se by Talend.
the class HL7Parse method doParse.
/**
* DOC gcui Comment method "doParse".
*
* @param msgList
* @return
*/
public List<Message> doParse(List<String> msgList) {
List<Message> messageList = new ArrayList<Message>();
for (int i = 0; i < msgList.size(); i++) {
Message message = getHL7MessageInput(msgList.get(i));
messageList.add(message);
}
return messageList;
}
use of bind.feature.generichierarchy.case1.model.Message in project tdi-studio-se by Talend.
the class HL7UI method initMessageTree.
public void initMessageTree() {
HL7Parse hl7Parse = new HL7Parse();
List<Message> messageList = new ArrayList<Message>();
if (initMsgContentList != null && initMsgContentList.size() > 0) {
messageList = hl7Parse.doParse(initMsgContentList);
if (messageList != null && messageList.size() > 0) {
messageViewer.setInput(messageList.toArray());
} else {
messageViewer.setInput(null);
}
} else {
filePath = externalNode.getElementParameter(EParameterName.FILENAME.getName()).getValue().toString();
String filePathNoQuotes = TalendTextUtils.removeQuotes(filePath);
File file = Path.fromOSString(filePathNoQuotes).toFile();
if (file.exists()) {
messageList = hl7Parse.doParse(filePath, startChar, endChar);
if (messageList != null && messageList.size() > 0) {
messageViewer.setInput(messageList.toArray());
} else {
messageViewer.setInput(null);
}
}
}
}
Aggregations