Search in sources :

Example 16 with HL7TreeNode

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

the class SetRepetableAction method init.

public void init() {
    setText(SET_AS_REPEATABLE_ELEMENT);
    HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
    if (node == null) {
        this.setEnabled(false);
        return;
    }
    if (node.isRepetable()) {
        this.setEnabled(true);
        this.setText(REMOVE_REPEATABLE);
        return;
    }
    if (node.getLabel().length() != 3) {
        this.setEnabled(false);
        return;
    }
    this.setEnabled(true);
}
Also used : HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode)

Example 17 with HL7TreeNode

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

the class ImportHL7StructureAction method sortOrder.

private void sortOrder(HL7TreeNode treeNode, HL7TreeNode node) {
    if (node != null) {
        List<HL7TreeNode> children = node.getChildren();
        if (treeNode != null) {
            int tmpOrder = 0;
            int attrNsCount = 0;
            for (HL7TreeNode child : children) {
                if (child.getOrder() < treeNode.getOrder()) {
                    tmpOrder++;
                }
                if (child.isAttribute() || child.isNameSpace()) {
                    attrNsCount++;
                }
            }
            if (tmpOrder > -1) {
                int oldOrder = children.indexOf(treeNode);
                if (oldOrder != -1 && oldOrder != tmpOrder) {
                    node.removeChild(treeNode);
                    if (children.size() > tmpOrder) {
                        node.addChild(tmpOrder - attrNsCount, treeNode);
                    } else {
                        node.addChild(treeNode);
                    }
                }
            }
        }
    }
}
Also used : HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode)

Example 18 with HL7TreeNode

use of org.talend.designer.hl7.ui.data.HL7TreeNode 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 19 with HL7TreeNode

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

the class ImportHL7StructureAction method orderNode.

private void orderNode(HL7TreeNode node) {
    // reset the order.
    if (node != null) {
        List<HL7TreeNode> firstSubChildren = node.getChildren();
        HL7TreeNode foundNode = null;
        for (HL7TreeNode childen : firstSubChildren) {
            if (childen.isRepetable()) {
                foundNode = childen;
                sortOrder(foundNode, node);
                break;
            } else if (childen.isGroup()) {
                foundNode = childen;
                sortOrder(foundNode, node);
                orderNode(childen);
            } else {
                orderNode(childen);
            }
        }
    }
}
Also used : HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode)

Example 20 with HL7TreeNode

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

the class ImportHL7StructureAction method addElement.

protected HL7TreeNode addElement(HL7TreeNode current, String currentPath, String newPath, String defaultValue, Map<String, HL7TreeNode> mapNodes) {
    HL7TreeNode temp = mapNodes.get(newPath);
    if (temp == null) {
        // if node is not existing, create it.
        //$NON-NLS-1$
        String name = newPath.substring(newPath.lastIndexOf("/") + 1);
        temp = new Element(name, defaultValue);
        if (current == null) {
            // root node
            mapNodes.put(newPath, temp);
            return temp;
        }
        mapNodes.put(newPath, temp);
        //$NON-NLS-1$
        String parentPath = newPath.substring(0, newPath.lastIndexOf("/"));
        HL7TreeNode parentNode = mapNodes.get(parentPath);
        if (parentNode != null) {
            parentNode.addChild(temp);
        } else {
            ExceptionHandler.log("Error when parsing the HL7 data, parent not existing for:" + parentPath);
        }
    }
    return temp;
}
Also used : Element(org.talend.designer.hl7.ui.data.Element) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode)

Aggregations

HL7TreeNode (org.talend.designer.hl7.ui.data.HL7TreeNode)41 Element (org.talend.designer.hl7.ui.data.Element)13 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)6 List (java.util.List)4 Map (java.util.Map)4 TreeItem (org.eclipse.swt.widgets.TreeItem)4 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)3 HL7FileNode (org.talend.core.model.metadata.builder.connection.HL7FileNode)3 HL7OutputManager (org.talend.designer.hl7.managers.HL7OutputManager)3 Group (ca.uhn.hl7v2.model.Group)2 Message (ca.uhn.hl7v2.model.Message)2 TableItem (org.eclipse.swt.widgets.TableItem)2 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)2 IConnection (org.talend.core.model.process.IConnection)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 EList (org.eclipse.emf.common.util.EList)1 Command (org.eclipse.gef.commands.Command)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1