Search in sources :

Example 1 with HL7Parse

use of org.talend.designer.hl7.ui.header.HL7Parse in project tdi-studio-se by Talend.

the class ImportHL7StructureAction method treeNodeAdapt.

private List treeNodeAdapt() {
    List<HL7TreeNode> treeData = new ArrayList<HL7TreeNode>();
    FileDialog f = null;
    if (hl7ui != null) {
        f = new FileDialog(hl7ui.getHl7UIParent().getShell());
    } else if (form != null) {
        f = new FileDialog(form.getShell());
    }
    String file = f.open();
    if (file == null) {
        return treeData;
    }
    HL7Parse hl7Parse = new HL7Parse();
    List<String> msgContentList = new ArrayList<String>();
    List<Message> messageList = hl7Parse.doParse(file, "'\\u000b'", "'\\u001c'");
    List<HL7TreeNode> nodeList = hl7Util.getHL7TreeNodes(messageList);
    if (!nodeList.isEmpty()) {
        HL7TreeNode hl7TreeNode = nodeList.get(0);
        List<HL7FileNode> table = new ArrayList<HL7FileNode>();
        if (hl7Connection != null) {
            EList root = hl7Connection.getRoot();
            root.clear();
            if (hl7TreeNode != null) {
                hl7Util.initNodeOrder(hl7TreeNode, orderMap);
                hl7Util.tableLoader((Element) hl7TreeNode, "", root, hl7TreeNode.getDefaultValue(), orderMap);
            }
            table.addAll(root);
        } else {
            if (hl7TreeNode != null) {
                hl7Util.initNodeOrder(hl7TreeNode, orderMap);
                hl7Util.tableLoader((Element) hl7TreeNode, "", table, hl7TreeNode.getDefaultValue(), orderMap);
            }
        }
        List<String> schemaList = new ArrayList<String>();
        for (HL7FileNode node : table) {
            String columnName = node.getRelatedColumn();
            if (columnName.contains(":")) {
                columnName = columnName.substring(0, columnName.indexOf(":"));
            }
            if (!schemaList.contains(columnName) && !"".equals(columnName)) {
                schemaList.add(columnName);
            }
        }
        initXmlTreeData(schemaList, table, treeData);
    }
    return treeData;
}
Also used : EList(org.eclipse.emf.common.util.EList) Message(ca.uhn.hl7v2.model.Message) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) ArrayList(java.util.ArrayList) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode) FileDialog(org.eclipse.swt.widgets.FileDialog) HL7Parse(org.talend.designer.hl7.ui.header.HL7Parse)

Example 2 with HL7Parse

use of org.talend.designer.hl7.ui.header.HL7Parse 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);
            }
        }
    }
}
Also used : Message(ca.uhn.hl7v2.model.Message) ArrayList(java.util.ArrayList) HL7Parse(org.talend.designer.hl7.ui.header.HL7Parse) File(java.io.File)

Aggregations

Message (ca.uhn.hl7v2.model.Message)2 ArrayList (java.util.ArrayList)2 HL7Parse (org.talend.designer.hl7.ui.header.HL7Parse)2 File (java.io.File)1 EList (org.eclipse.emf.common.util.EList)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 HL7FileNode (org.talend.core.model.metadata.builder.connection.HL7FileNode)1 HL7TreeNode (org.talend.designer.hl7.ui.data.HL7TreeNode)1