Search in sources :

Example 1 with TalendHL7Reader

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);
        }
    }
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ByteArray(org.talend.core.model.properties.ByteArray) TalendHL7Reader(org.talend.designer.hl7.ui.header.TalendHL7Reader) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 ByteArray (org.talend.core.model.properties.ByteArray)1 TalendHL7Reader (org.talend.designer.hl7.ui.header.TalendHL7Reader)1