Search in sources :

Example 36 with HL7TreeNode

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

the class HL7OutputManager 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)

Example 37 with HL7TreeNode

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

the class HL7OutputManager method getRootTable.

public List<Map<String, String>> getRootTable() {
    List<Map<String, String>> result = new ArrayList<Map<String, String>>();
    for (HL7TreeNode rootNode : this.getOriginalNodes()) {
        // if (!(rootNode instanceof HL7Root)) {
        initNodeOrder(rootNode);
        order = 1;
        // }
        //$NON-NLS-1$
        tableLoader((Element) rootNode, "", result, rootNode.getDefaultValue());
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode) HashMap(java.util.HashMap) Map(java.util.Map)

Example 38 with HL7TreeNode

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

the class HL7OutputManager method initNodeOrder.

public void initNodeOrder(HL7TreeNode node) {
    if (node == null) {
        return;
    }
    HL7TreeNode parent = node.getParent();
    if (parent == null) {
        node.setOrder(1);
        String path = getPath(node);
        orderMap.put(path, order);
        order++;
    }
    List<HL7TreeNode> childNode = node.getChildren();
    for (HL7TreeNode child : childNode) {
        child.setOrder(order);
        String path = getPath(child);
        orderMap.put(path, order);
        order++;
        if (child.getChildren().size() > 0) {
            initNodeOrder(child);
        }
    }
}
Also used : HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode)

Example 39 with HL7TreeNode

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

the class HL7OutputManager method getLoopTable.

public List<Map<String, String>> getLoopTable() {
    List<Map<String, String>> result = new ArrayList<Map<String, String>>();
    for (HL7TreeNode rootNode : this.getOriginalNodes()) {
        Element loopNode = (Element) getLoopNode(rootNode);
        if (loopNode != null) {
            String path = getPath(loopNode);
            //$NON-NLS-1$
            tableLoader(loopNode, path.substring(0, path.lastIndexOf("/")), result, loopNode.getDefaultValue());
        }
    }
    return result;
}
Also used : Element(org.talend.designer.hl7.ui.data.Element) ArrayList(java.util.ArrayList) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode) HashMap(java.util.HashMap) Map(java.util.Map)

Example 40 with HL7TreeNode

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

the class UIManager method autoMap.

/**
     * 
     * DOC xzhang Comment method "autoMap".
     */
public void autoMap(String currentSchema) {
    if (this.hl7Manager instanceof HL7OutputManager) {
        List<HL7TreeNode> roots = this.hl7Manager.getTreeData("");
        List<HL7TreeNode> mappableNodes = new ArrayList<HL7TreeNode>();
        for (HL7TreeNode root : roots) {
            getMappableNode((Element) root, mappableNodes);
        }
        List<IMetadataColumn> schemaData = this.hl7Manager.getSchemaData(currentSchema);
        for (HL7TreeNode node : mappableNodes) {
            for (IMetadataColumn column : schemaData) {
                if (node.getLabel().equals(column.getLabel())) {
                    node.setDefaultValue(null);
                    node.setColumn(column);
                    break;
                }
            // String[] splits = node.getColumnLabel().split(":");
            // for (String s : splits) {
            // if (s.equals(column.getLabel())) {
            // node.setDefaultValue(null);
            // node.setColumn(column);
            // break;
            // }
            // }
            }
        }
        // this.hl7UI.refreshXMLViewer(root);
        this.hl7UI.redrawLinkers();
        return;
    }
    this.hl7UI.autoMap();
}
Also used : ArrayList(java.util.ArrayList) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

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