Search in sources :

Example 1 with HL7FileNode

use of org.talend.core.model.metadata.builder.connection.HL7FileNode 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 HL7FileNode

use of org.talend.core.model.metadata.builder.connection.HL7FileNode 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 3 with HL7FileNode

use of org.talend.core.model.metadata.builder.connection.HL7FileNode in project tdi-studio-se by Talend.

the class ComponentChooseDialog method createRefreshingPropertiesCommand.

/**
     * DOC bqian Comment method "createRefreshingPropertiesCommand".
     *
     * @param selectedNode
     * @param node
     */
private List<Command> createRefreshingPropertiesCommand(CompoundCommand cc, RepositoryNode selectedNode, Node node) {
    // List<Command> list = new ArrayList<Command>();
    if (selectedNode.getObject().getProperty().getItem() instanceof ConnectionItem) {
        String propertyId = selectedNode.getObject().getProperty().getId();
        ConnectionItem originalConnectionItem = (ConnectionItem) selectedNode.getObject().getProperty().getItem();
        ConnectionItem connectionItem = originalConnectionItem;
        Connection originalConnection = connectionItem.getConnection();
        Connection connection = connectionItem.getConnection();
        // if component is CDC, replace by the CDC connection.
        if (node.getComponent().getName().contains("CDC")) {
            // to replace by a flag CDC in component? //$NON-NLS-1$
            if (selectedNode.getObject().getProperty().getItem() instanceof DatabaseConnectionItem) {
                final DatabaseConnection databaseConnection = (DatabaseConnection) connection;
                CDCConnection cdcConn = databaseConnection.getCdcConns();
                if (cdcConn != null) {
                    EList cdcTypes = cdcConn.getCdcTypes();
                    if (cdcTypes != null && !cdcTypes.isEmpty()) {
                        CDCType cdcType = (CDCType) cdcTypes.get(0);
                        // replace property by CDC property.
                        propertyId = cdcType.getLinkDB();
                        try {
                            IRepositoryViewObject object = ProxyRepositoryFactory.getInstance().getLastVersion(propertyId);
                            if (object != null) {
                                if (object.getProperty().getItem() instanceof DatabaseConnectionItem) {
                                    DatabaseConnectionItem dbConnItem = (DatabaseConnectionItem) object.getProperty().getItem();
                                    // replace connection by CDC connection
                                    connectionItem = dbConnItem;
                                    connection = dbConnItem.getConnection();
                                }
                            }
                        } catch (PersistenceException e) {
                            ExceptionHandler.process(e);
                        }
                        // set cdc type mode.
                        IElementParameter logModeParam = node.getElementParameter(EParameterName.CDC_TYPE_MODE.getName());
                        if (logModeParam != null) {
                            String cdcTypeMode = ((DatabaseConnection) originalConnection).getCdcTypeMode();
                            Command logModeCmd = new PropertyChangeCommand(node, EParameterName.CDC_TYPE_MODE.getName(), CDCTypeMode.LOG_MODE.getName().equals(cdcTypeMode));
                            cc.add(logModeCmd);
                        }
                        // set lib for as400 so far.
                        //$NON-NLS-1$
                        final String name = "SOURCE_LIB";
                        IElementParameter libParam = node.getElementParameter(name);
                        if (libParam != null) {
                            Object propValue;
                            if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(databaseConnection.getSID())) {
                                propValue = databaseConnection.getSID();
                            } else {
                                propValue = TalendTextUtils.addQuotes(databaseConnection.getSID());
                            }
                            Command libSettingCmd = new PropertyChangeCommand(node, name, propValue);
                            cc.add(libSettingCmd);
                        }
                    }
                }
            }
        }
        // fore EBCDIC, by cli
        if ((connectionItem instanceof EbcdicConnectionItem) && PluginChecker.isEBCDICPluginLoaded()) {
            // TDI-20505:integration the drag/drop for EBCDIC connection and EBCDIC metadataTable
            IRepositoryViewObject object = selectedNode.getObject();
            if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_EBCDIC) {
                for (MetadataTable table : ConnectionHelper.getTables(originalConnection)) {
                    Command ebcdicCmd = new RepositoryChangeMetadataForEBCDICCommand(node, IEbcdicConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
                    cc.add(ebcdicCmd);
                }
            }
            if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE) {
                MetadataTable table = null;
                if (object instanceof MetadataTableRepositoryObject) {
                    table = ((MetadataTableRepositoryObject) object).getTable();
                }
                Command ebcdicCmd = new RepositoryChangeMetadataForEBCDICCommand(node, IEbcdicConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
                cc.add(ebcdicCmd);
            }
        }
        // fore HL7, by gcui
        if ((selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) || (selectedNode.getParent() != null && selectedNode.getParent().getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded())) {
            if (originalConnection instanceof HL7ConnectionImpl) {
                if (((HL7ConnectionImpl) originalConnection).getRoot() != null) {
                    List<Map<String, String>> mapList = new ArrayList<Map<String, String>>();
                    for (Object obj : ((HL7ConnectionImpl) originalConnection).getRoot()) {
                        if (obj instanceof HL7FileNode) {
                            Map<String, String> newMap = new HashMap<String, String>();
                            newMap.put(IHL7Constant.ATTRIBUTE, ((HL7FileNode) obj).getAttribute());
                            newMap.put(IHL7Constant.PATH, ((HL7FileNode) obj).getFilePath());
                            newMap.put(IHL7Constant.COLUMN, ((HL7FileNode) obj).getRelatedColumn());
                            newMap.put(IHL7Constant.ORDER, String.valueOf(((HL7FileNode) obj).getOrder()));
                            newMap.put(IHL7Constant.VALUE, ((HL7FileNode) obj).getDefaultValue());
                            newMap.put(IHL7Constant.REPEATABLE, String.valueOf(((HL7FileNode) obj).isRepeatable()));
                            mapList.add(newMap);
                        }
                    }
                    IExternalNode externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
                    if (externalNode != null && externalNode.getElementParameter("ROOT") != null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        externalNode.getElementParameter("ROOT").setValue(mapList);
                    }
                    String fileName = ((HL7ConnectionImpl) originalConnection).getOutputFilePath();
                    if (externalNode != null && externalNode.getElementParameter("FILENAME") != null && fileName != null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        externalNode.getElementParameter("FILENAME").setValue(TalendTextUtils.addQuotes(fileName));
                    }
                }
            }
            // fore HL7, by gcui
            if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) {
                for (MetadataTable table : ConnectionHelper.getTablesWithOrders(originalConnection)) {
                    Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(node, IHL7Constant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
                    cc.add(hl7Cmd);
                }
            }
        }
        // for brms
        if ((selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_BRMS && PluginChecker.isBRMSPluginLoaded()) || (selectedNode.getParent() != null && selectedNode.getParent().getObjectType() == ERepositoryObjectType.METADATA_FILE_BRMS && PluginChecker.isBRMSPluginLoaded())) {
            if (originalConnection instanceof BRMSConnectionImpl) {
                if (((BRMSConnectionImpl) originalConnection).getRoot() != null) {
                    List<Map<String, String>> rootList = new ArrayList<Map<String, String>>();
                    List<Map<String, String>> loopList = new ArrayList<Map<String, String>>();
                    List<Map<String, String>> groupList = new ArrayList<Map<String, String>>();
                    for (Object obj : ((BRMSConnectionImpl) originalConnection).getRoot()) {
                        if (obj instanceof XMLFileNode) {
                            Map<String, String> rootMap = new HashMap<String, String>();
                            //$NON-NLS-1$
                            rootMap.put("ATTRIBUTE", ((XMLFileNode) obj).getAttribute());
                            //$NON-NLS-1$
                            rootMap.put("PATH", ((XMLFileNode) obj).getXMLPath());
                            //$NON-NLS-1$
                            rootMap.put("COLUMN", ((XMLFileNode) obj).getRelatedColumn());
                            //$NON-NLS-1$
                            rootMap.put("ORDER", String.valueOf(((XMLFileNode) obj).getOrder()));
                            //$NON-NLS-1$
                            rootMap.put("VALUE", ((XMLFileNode) obj).getDefaultValue());
                            rootList.add(rootMap);
                        }
                    }
                    for (Object obj : ((BRMSConnectionImpl) originalConnection).getLoop()) {
                        if (obj instanceof XMLFileNode) {
                            Map<String, String> loopMap = new HashMap<String, String>();
                            //$NON-NLS-1$
                            loopMap.put("ATTRIBUTE", ((XMLFileNode) obj).getAttribute());
                            //$NON-NLS-1$
                            loopMap.put("PATH", ((XMLFileNode) obj).getXMLPath());
                            //$NON-NLS-1$
                            loopMap.put("COLUMN", ((XMLFileNode) obj).getRelatedColumn());
                            //$NON-NLS-1$
                            loopMap.put("ORDER", String.valueOf(((XMLFileNode) obj).getOrder()));
                            //$NON-NLS-1$
                            loopMap.put("VALUE", ((XMLFileNode) obj).getDefaultValue());
                            loopList.add(loopMap);
                        }
                    }
                    for (Object obj : ((BRMSConnectionImpl) originalConnection).getGroup()) {
                        if (obj instanceof XMLFileNode) {
                            Map<String, String> groupMap = new HashMap<String, String>();
                            //$NON-NLS-1$
                            groupMap.put("ATTRIBUTE", ((XMLFileNode) obj).getAttribute());
                            //$NON-NLS-1$
                            groupMap.put("PATH", ((XMLFileNode) obj).getXMLPath());
                            //$NON-NLS-1$
                            groupMap.put("COLUMN", ((XMLFileNode) obj).getRelatedColumn());
                            //$NON-NLS-1$
                            groupMap.put("ORDER", String.valueOf(((XMLFileNode) obj).getOrder()));
                            //$NON-NLS-1$
                            groupMap.put("VALUE", ((XMLFileNode) obj).getDefaultValue());
                            groupList.add(groupMap);
                        }
                    }
                    IExternalNode externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
                    if (externalNode != null && externalNode.getElementParameter("ROOT") != null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        externalNode.getElementParameter("ROOT").setValue(rootList);
                    }
                    if (externalNode != null && externalNode.getElementParameter("LOOP") != null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        externalNode.getElementParameter("LOOP").setValue(loopList);
                    }
                    if (externalNode != null && externalNode.getElementParameter("GROUP") != null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        externalNode.getElementParameter("GROUP").setValue(groupList);
                    }
                }
            }
        }
        IElementParameter propertyParam = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
        if (propertyParam != null) {
            propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
            propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).setValue(propertyId);
        }
        IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
        Map<String, IMetadataTable> repositoryTableMap = new HashMap<String, IMetadataTable>();
        if (!originalConnection.isReadOnly()) {
            for (Object tableObj : ConnectionHelper.getTables(originalConnection)) {
                org.talend.core.model.metadata.builder.connection.MetadataTable table;
                table = (org.talend.core.model.metadata.builder.connection.MetadataTable) tableObj;
                if (factory.getStatus(originalConnectionItem) != ERepositoryStatus.DELETED) {
                    if (!factory.isDeleted(table)) {
                        String value = table.getId();
                        IMetadataTable newTable = ConvertionHelper.convert(table);
                        repositoryTableMap.put(value, newTable);
                    }
                }
            }
        }
        // DesignerPlugin.getDefault().getProxyRepositoryFactory().getLastVersion("")
        if (propertyParam != null) {
            // command used to set property type
            IMetadataTable metadataTable = null;
            // && selectedNode.getObjectType() == ERepositoryObjectType.METADATA_CON_TABLE) {
            if (selectedNode.getObject() instanceof IMetadataTable) {
                metadataTable = (IMetadataTable) selectedNode.getObject();
                if (metadataTable != null && repositoryTableMap.get(metadataTable.getId()) != null) {
                    metadataTable = repositoryTableMap.get(metadataTable.getId());
                }
            }
            // }
            ChangeValuesFromRepository command1 = new ChangeValuesFromRepository(node, connection, metadataTable, propertyParam.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), propertyId, //$NON-NLS-1$
            true);
            command1.setMaps(repositoryTableMap);
            if (selectedNode.getProperties(EProperties.CONTENT_TYPE) != ERepositoryObjectType.METADATA_CON_QUERY) {
                command1.setGuessQuery(true);
            }
            setSAPSpecailValueForCommand(selectedNode, command1);
            // for salesForce module
            SalesforceModuleRepositoryObject sfObject = null;
            if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
                sfObject = (SalesforceModuleRepositoryObject) selectedNode.getObject();
            } else if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE) {
                IRepositoryViewObject object = selectedNode.getParent().getObject();
                if (object instanceof SalesforceModuleRepositoryObject) {
                    sfObject = (SalesforceModuleRepositoryObject) object;
                }
            }
            if (sfObject != null) {
                ModelElement modelElement = sfObject.getModelElement();
                if (modelElement instanceof SalesforceModuleUnit) {
                    command1.setSalesForceModuleUnit((SalesforceModuleUnit) modelElement);
                }
            }
            cc.add(command1);
        }
        // command used to set metadata
        getChangeMetadataCommand(cc, selectedNode, node, originalConnectionItem);
        // command used to set query
        if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_QUERY) {
            IElementParameter queryParam = node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
            QueryRepositoryObject object = (QueryRepositoryObject) selectedNode.getObject();
            Query query = object.getQuery();
            //$NON-NLS-1$
            String value = originalConnectionItem.getProperty().getId() + " - " + query.getLabel();
            if (queryParam != null) {
                RepositoryChangeQueryCommand command3 = new RepositoryChangeQueryCommand(node, query, queryParam.getName() + ":" + EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName(), //$NON-NLS-1$
                value);
                cc.add(command3);
            }
        } else {
            if (connection instanceof DatabaseConnection && hasQuery(node)) {
                DatabaseConnection connection2 = (DatabaseConnection) connection;
                String schema = connection2.getUiSchema();
                String dbType = connection2.getDatabaseType();
                QueryGuessCommand queryGuessCommand = null;
                if (node.getMetadataList().size() == 0) {
                    queryGuessCommand = new QueryGuessCommand(node, null, schema, dbType);
                } else {
                    // modified by hyWang for bug 7190
                    queryGuessCommand = new QueryGuessCommand(node, node.getMetadataList().get(0), schema, dbType, connection);
                }
                if (queryGuessCommand != null) {
                    cc.add(queryGuessCommand);
                }
            }
        }
    // context, moved to ChangeValuesFromRepository(bug 5198)
    // ConnectionContextHelper.addContextForNodeParameter(node, connectionItem);
    } else if (selectedNode.getObject().getProperty().getItem() instanceof ProcessItem) {
        ProcessItem processItem = (ProcessItem) selectedNode.getObject().getProperty().getItem();
        // command used to set job
        String value = processItem.getProperty().getId();
        PropertyChangeCommand command4 = new PropertyChangeCommand(node, EParameterName.PROCESS_TYPE_PROCESS.getName(), value);
        cc.add(command4);
        PropertyChangeCommand command5 = new PropertyChangeCommand(node, EParameterName.PROCESS_TYPE_CONTEXT.getName(), processItem.getProcess().getDefaultContext());
        cc.add(command5);
    } else if (selectedNode.getObject().getProperty().getItem() instanceof FileItem) {
        // hywang add for 6484
        if (selectedNode.getObject().getProperty().getItem() instanceof RulesItem) {
            RulesItem rulesItem = (RulesItem) selectedNode.getObject().getProperty().getItem();
            //                String displayName = "Rules:" + rulesItem.getProperty().getLabel(); //$NON-NLS-N$
            IElementParameter propertyParam = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
            if (propertyParam != null) {
                propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                // propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName())
                // .setListItemsDisplayName(new String[] { displayName });
                final String showId = rulesItem.getProperty().getId();
                PropertyChangeCommand command6 = new PropertyChangeCommand(node, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
                cc.add(command6);
            }
        }
    } else if (selectedNode.getObject().getProperty().getItem() instanceof LinkRulesItem) {
        LinkRulesItem linkItem = (LinkRulesItem) selectedNode.getObject().getProperty().getItem();
        IElementParameter propertyParam = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
        if (propertyParam != null) {
            propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
            // propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName())
            // .setListItemsDisplayName(new String[] { displayName });
            final String showId = linkItem.getProperty().getId();
            PropertyChangeCommand command7 = new PropertyChangeCommand(node, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
            cc.add(command7);
        }
    }
    return null;
}
Also used : Query(org.talend.core.model.metadata.builder.connection.Query) HashMap(java.util.HashMap) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ArrayList(java.util.ArrayList) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) RepositoryChangeQueryCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeQueryCommand) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) HL7ConnectionImpl(org.talend.core.model.metadata.builder.connection.impl.HL7ConnectionImpl) SalesforceModuleUnit(org.talend.core.model.metadata.builder.connection.SalesforceModuleUnit) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) FileItem(org.talend.core.model.properties.FileItem) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) BRMSConnectionImpl(org.talend.core.model.metadata.builder.connection.impl.BRMSConnectionImpl) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject) Map(java.util.Map) HashMap(java.util.HashMap) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) RulesItem(org.talend.core.model.properties.RulesItem) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) IElementParameter(org.talend.core.model.process.IElementParameter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IExternalNode(org.talend.core.model.process.IExternalNode) PolylineConnection(org.eclipse.draw2d.PolylineConnection) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) CDCConnection(org.talend.core.model.metadata.builder.connection.CDCConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) CDCConnection(org.talend.core.model.metadata.builder.connection.CDCConnection) RepositoryChangeMetadataForEBCDICCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForEBCDICCommand) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) EList(org.eclipse.emf.common.util.EList) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) RepositoryChangeMetadataForSAPCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPCommand) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) RepositoryChangeQueryCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeQueryCommand) ConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.ConnectionReconnectCommand) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) RepositoryChangeMetadataForEBCDICCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForEBCDICCommand) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) CDCType(org.talend.core.model.metadata.builder.connection.CDCType)

Example 4 with HL7FileNode

use of org.talend.core.model.metadata.builder.connection.HL7FileNode in project tdi-studio-se by Talend.

the class HL7PublicUtil method tableLoader.

public void tableLoader(Element element, String parentPath, List<HL7FileNode> table, String defaultValue, Map<String, Integer> orderMap) {
    HL7FileNode hl7FileNode = ConnectionFactory.eINSTANCE.createHL7FileNode();
    String currentPath = parentPath + "/" + element.getLabel();
    hl7FileNode.setFilePath(currentPath);
    hl7FileNode.setRelatedColumn(element.getColumnLabel());
    hl7FileNode.setAttribute(element.isMain() ? "main" : "branch");
    hl7FileNode.setDefaultValue(defaultValue);
    // xmlFileNode.setType(element.getDataType());
    hl7FileNode.setOrder(getNodeOrder(element, orderMap));
    hl7FileNode.setRepeatable(element.isRepetable());
    table.add(hl7FileNode);
    for (HL7TreeNode att : element.getAttributeChildren()) {
        hl7FileNode = ConnectionFactory.eINSTANCE.createHL7FileNode();
        hl7FileNode.setFilePath(att.getLabel());
        hl7FileNode.setRelatedColumn(att.getColumnLabel());
        hl7FileNode.setAttribute("attri");
        hl7FileNode.setDefaultValue(att.getDefaultValue());
        // xmlFileNode.setType(att.getDataType());
        hl7FileNode.setOrder(getNodeOrder(att, orderMap));
        hl7FileNode.setRepeatable(att.isRepetable());
        table.add(hl7FileNode);
    }
    for (HL7TreeNode att : element.getNameSpaceChildren()) {
        hl7FileNode = ConnectionFactory.eINSTANCE.createHL7FileNode();
        hl7FileNode.setFilePath(att.getLabel());
        hl7FileNode.setRelatedColumn(att.getColumnLabel());
        hl7FileNode.setAttribute("ns");
        hl7FileNode.setDefaultValue(att.getDefaultValue());
        // xmlFileNode.setType(att.getDataType());
        hl7FileNode.setOrder(getNodeOrder(att, orderMap));
        hl7FileNode.setRepeatable(att.isRepetable());
        table.add(hl7FileNode);
    }
    List<HL7TreeNode> children = element.getElementChildren();
    for (HL7TreeNode child : children) {
        // if (!child.isGroup() && !child.isLoop()) {
        tableLoader((Element) child, currentPath, table, child.getDefaultValue(), orderMap);
    // }
    }
}
Also used : HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode)

Aggregations

HL7FileNode (org.talend.core.model.metadata.builder.connection.HL7FileNode)4 ArrayList (java.util.ArrayList)3 HL7TreeNode (org.talend.designer.hl7.ui.data.HL7TreeNode)3 HashMap (java.util.HashMap)2 EList (org.eclipse.emf.common.util.EList)2 Command (org.eclipse.gef.commands.Command)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)2 RepositoryChangeMetadataForHL7Command (org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command)2 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)2 Message (ca.uhn.hl7v2.model.Message)1 Map (java.util.Map)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 CDCConnection (org.talend.core.model.metadata.builder.connection.CDCConnection)1 CDCType (org.talend.core.model.metadata.builder.connection.CDCType)1 Connection (org.talend.core.model.metadata.builder.connection.Connection)1 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)1