Search in sources :

Example 31 with HL7TreeNode

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

the class CreateHL7ElementAction method init.

public void init() {
    HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
    if (node == null) {
        this.setEnabled(false);
        return;
    }
    if (node instanceof Attribute) {
        this.setEnabled(false);
        return;
    }
    if (node instanceof NameSpaceNode) {
        this.setEnabled(false);
        return;
    }
    this.setEnabled(true);
}
Also used : NameSpaceNode(org.talend.designer.hl7.ui.data.NameSpaceNode) Attribute(org.talend.designer.hl7.ui.data.Attribute) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode)

Example 32 with HL7TreeNode

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

the class HL7FixValueAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
    setFixValue(node);
}
Also used : HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode)

Example 33 with HL7TreeNode

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

the class ImportHL7StructureAction method initXmlTreeData.

private void initXmlTreeData(List<String> schemaList, List<HL7FileNode> root, List<HL7TreeNode> treeData) {
    Map<String, HL7TreeNode> mapNodes = new HashMap<String, HL7TreeNode>();
    List<? extends IConnection> incomingConnections = new ArrayList<IConnection>();
    if (hl7ui != null) {
        if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
            ((HL7OutputManager) hl7ui.gethl7Manager()).getContents().clear();
            incomingConnections = NodeUtil.getIncomingConnections(hl7ui.gethl7Manager().getHl7Component(), IConnectionCategory.FLOW);
        }
    }
    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    List<MetadataTable> iMetadataTables = new ArrayList<MetadataTable>();
    HL7TreeNode rootNode = null;
    Map<String, IMetadataTable> schemaNameToInputTable = new HashMap<String, IMetadataTable>();
    Map<String, MetadataTable> schemaNameToOutputTable = new HashMap<String, MetadataTable>();
    for (String schemaName : schemaList) {
        IMetadataTable metadataTable = null;
        for (IConnection connection : incomingConnections) {
            if (connection.getUniqueName().equals(schemaName)) {
                metadataTable = connection.getMetadataTable();
                metadataTable.setLabel(connection.getUniqueName());
                schemaNameToInputTable.put(schemaName, metadataTable);
                break;
            }
        }
        MetadataTable targetMetadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
        targetMetadataTable.setId(factory.getNextId());
        schemaNameToOutputTable.put(schemaName, targetMetadataTable);
        targetMetadataTable.setLabel(schemaName);
        iMetadataTables.add(targetMetadataTable);
    }
    HL7TreeNode current = null;
    HL7TreeNode temp = null;
    String currentPath = null;
    String defaultValue = null;
    int nodeOrder = 0;
    boolean haveOrder = true;
    // build root tree
    for (int i = 0; i < root.size(); i++) {
        HL7FileNode node = root.get(i);
        String newPath = node.getFilePath();
        defaultValue = node.getDefaultValue();
        String columnName = node.getRelatedColumn();
        // String type = node.getType();
        String orderValue = String.valueOf(node.getOrder());
        if (orderValue == null || "".equals(orderValue)) {
            haveOrder = false;
        }
        if (haveOrder) {
            nodeOrder = node.getOrder();
        }
        String rowName = columnName;
        if (columnName != null && columnName.contains(":")) {
            String[] names = columnName.split(":");
            rowName = names[0];
            columnName = names[1];
        } else {
            columnName = null;
        }
        temp = this.addElement(current, currentPath, newPath, defaultValue, mapNodes);
        if (temp == null) {
            // should not happen
            continue;
        }
        // temp.setDataType(type);
        if (rootNode == null) {
            rootNode = temp;
        }
        if (node.getAttribute().equals("main")) {
            temp.setMain(true);
        }
        current = temp;
        currentPath = newPath;
        if (haveOrder) {
            temp.setOrder(nodeOrder);
        }
        if (rowName != null && rowName.length() > 0) {
            temp.setRow(rowName);
        }
        if (columnName != null) {
            IMetadataTable metadataTable = schemaNameToInputTable.get(rowName);
            // group node can not get the metadata table
            if (metadataTable == null) {
                IMetadataTable metadataTableTemp = null;
                for (IConnection connection : incomingConnections) {
                    metadataTableTemp = connection.getMetadataTable();
                    String connectionName = metadataTableTemp.getLabel();
                    if (connectionName == null) {
                        connectionName = connection.getUniqueName();
                    }
                    if (columnName.startsWith(connectionName)) {
                        break;
                    }
                }
                temp.setColumnName(columnName);
                if (metadataTableTemp != null) {
                    temp.setColumn(metadataTableTemp.getColumn(columnName));
                    temp.setTable(metadataTableTemp);
                }
            } else {
                temp.setColumnName(columnName);
                temp.setColumn(metadataTable.getColumn(columnName));
                temp.setTable(metadataTable);
            }
            //
            if (!temp.isMain()) {
                MetadataColumn newColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
                newColumn.setLabel(columnName);
                newColumn.setName(temp.getLabel());
                newColumn.setLength(226);
                newColumn.setTalendType("id_String");
                schemaNameToOutputTable.get(rowName).getColumns().add(newColumn);
            }
        }
    }
    if (rootNode == null) {
        rootNode = new Element("rootTag");
    }
    if (haveOrder) {
        orderNode(rootNode);
    }
    if (rootNode != null) {
        treeData.add(rootNode);
    }
    if (hl7ui != null) {
        if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
            ((HL7OutputManager) hl7ui.gethl7Manager()).getContents().put(rootNode.getColumnLabel(), treeData);
        }
    } else if (form != null) {
        for (HL7TreeNode hl7Node : treeData) {
            form.getContents().put(rootNode.getColumnLabel(), hl7Node);
        }
    }
    if (hl7ui != null) {
        // execute the commands,initialize the propertiesView .
        List<Command> commands = new ArrayList<Command>();
        for (MetadataTable tableTemp : iMetadataTables) {
            Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(hl7ui.gethl7Manager().getHl7Component(), IHL7Constant.TABLE_SCHEMAS, tableTemp.getLabel(), ConvertionHelper.convert(tableTemp));
            commands.add(hl7Cmd);
        }
        for (Command command : commands) {
            command.execute();
        }
    }
}
Also used : HashMap(java.util.HashMap) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) Element(org.talend.designer.hl7.ui.data.Element) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) Command(org.eclipse.gef.commands.Command) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode) HL7OutputManager(org.talend.designer.hl7.managers.HL7OutputManager) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 34 with HL7TreeNode

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

the class ImportHL7StructureAction method selectionChanged.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
     */
@Override
public void selectionChanged(IStructuredSelection selection) {
    this.setEnabled(true);
    HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
    if (node != null && form != null) {
        // hl7ui.setSelectedText(node.getLabel());
        // Added by Marvin Wang on Sep. 11, 2012 for bug TDI-20702.
        form.setSelectedText(node.getLabel());
    }
}
Also used : HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode)

Example 35 with HL7TreeNode

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

the class SetRepetableAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
    if (!node.isRepetable()) {
        if (node.isGroup()) {
            node.setGroup(false);
        }
        node.setRepetable(true);
        node.setMain(true);
        upsetMainNode(node);
    } else {
        node.setRepetable(false);
    }
    xmlViewer.refresh();
}
Also used : 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