use of org.talend.designer.hl7.ui.header.TalendHL7Reader in project tdi-studio-se by Talend.
the class HL7Manager method readMessageContent.
private void readMessageContent() {
filePath = hl7Component.getElementParameter(EParameterName.FILENAME.getName()).getValue().toString();
String filePathNoQuotes = TalendTextUtils.removeQuotes(filePath);
File file = Path.fromOSString(filePathNoQuotes).toFile();
startChar = hl7Component.getElementParameter("START_MSG").getValue().toString();
endChar = hl7Component.getElementParameter("END_MSG").getValue().toString();
//$NON-NLS-1$
IElementParameter messagePara = hl7Component.getElementParameter("MESSAGE");
List<Map<String, String>> msgListMap = (List<Map<String, String>>) messagePara.getValue();
if (msgListMap != null && msgListMap.size() > 0) {
for (Map<String, String> msgMap : msgListMap) {
if (msgMap.get("MSGITEM") != null && msgMap.get("MSGITEM") instanceof String) {
String msgItem = msgMap.get("MSGITEM");
initMsgContentList.add(msgItem);
}
}
} else if (file.exists()) {
hasFile = true;
ByteArray array = PropertiesFactory.eINSTANCE.createByteArray();
try {
array.setInnerContentFromFile(file);
TalendHL7Reader talendHL7Reader = new TalendHL7Reader(new java.io.FileInputStream(file), "ISO-8859-15");
String HL7InputTem = null;
String messageText = "";
while ((HL7InputTem = talendHL7Reader.getMessage()) != null) {
initMsgContentList.add(HL7InputTem);
}
if (initMsgContentList == null || initMsgContentList.size() == 0) {
String msgText = new String(array.getInnerContent());
initMsgContentList.add(msgText);
}
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
}
Aggregations