Search in sources :

Example 31 with Connection

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

the class ComboController method createButtonCommand.

/**
     * This method is used for "Guess Query" button.
     * 
     * @return
     */
private Command createButtonCommand() {
    IMetadataTable repositoryMetadata = null;
    IMetadataTable newRepositoryMetadata = null;
    String realTableName = null;
    String realTableId = null;
    // Only for getting the real table name.
    if (elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()).equals(EmfComponent.REPOSITORY)) {
        String paramName;
        IElementParameter repositorySchemaTypeParameter = elem.getElementParameter(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
        Object repositoryControl = hashCurControls.get(repositorySchemaTypeParameter.getName());
        paramName = EParameterName.REPOSITORY_SCHEMA_TYPE.getName();
        if (repositoryControl != null) {
            String selectedComboItem = ((CCombo) repositoryControl).getText();
            if (selectedComboItem != null && selectedComboItem.length() > 0) {
                //$NON-NLS-1$
                String value = new String("");
                for (int i = 0; i < elem.getElementParameters().size(); i++) {
                    IElementParameter param = elem.getElementParameters().get(i);
                    if (param.getName().equals(paramName)) {
                        for (int j = 0; j < param.getListItemsValue().length; j++) {
                            if (selectedComboItem.equals(param.getListItemsDisplayName()[j])) {
                                value = (String) param.getListItemsValue()[j];
                            }
                        }
                    }
                }
                if (elem instanceof Node) {
                    // this.dynamicProperty.updateRepositoryList();
                    String connectionId = value.toString().split(" - ")[0];
                    String tableLabel = value.toString().split(" - ")[1];
                    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                    Item item = null;
                    try {
                        IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
                        if (repobj != null) {
                            Property property = repobj.getProperty();
                            if (property != null) {
                                item = property.getItem();
                            }
                        }
                    } catch (PersistenceException e) {
                        ExceptionHandler.process(e);
                    }
                    if (item != null && item instanceof ConnectionItem) {
                        boolean findTable = false;
                        Connection connection = ((ConnectionItem) item).getConnection();
                        for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
                            if (table.getLabel().equals(tableLabel)) {
                                repositoryMetadata = ConvertionHelper.convert(table);
                                findTable = true;
                                break;
                            }
                        }
                        if (!findTable) {
                            repositoryMetadata = new MetadataTable();
                        }
                    }
                // if (repositoryTableMap.containsKey(value)) {
                // repositoryMetadata = repositoryTableMap.get(value);
                // realTableName = repositoryMetadata.getTableName();
                // realTableId = repositoryMetadata.getId();
                // } else {
                // repositoryMetadata = new MetadataTable();
                // }
                }
            }
        }
    }
    // Ends
    QueryGuessCommand cmd = null;
    INode node = null;
    if (elem instanceof INode) {
        node = (INode) elem;
    } else {
        // else instanceof Connection
        node = ((IConnection) elem).getSource();
    }
    newRepositoryMetadata = node.getMetadataList().get(0);
    if (newRepositoryMetadata == null) {
        String schemaSelected = (String) node.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
        if (schemaSelected != null) {
            String connectionId = schemaSelected.toString().split(" - ")[0];
            String tableLabel = schemaSelected.toString().split(" - ")[1];
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            Item item = null;
            try {
                IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
                if (repobj != null) {
                    Property property = repobj.getProperty();
                    if (property != null) {
                        item = property.getItem();
                    }
                }
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
            if (item != null && item instanceof ConnectionItem) {
                boolean findTable = false;
                Connection connection = ((ConnectionItem) item).getConnection();
                for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
                    if (table.getLabel().equals(tableLabel)) {
                        repositoryMetadata = ConvertionHelper.convert(table);
                        findTable = true;
                        break;
                    }
                }
                if (!findTable) {
                    repositoryMetadata = new MetadataTable();
                }
            }
        // repositoryMetadata = repositoryTableMap.get(schemaSelected);
        } else if (newRepositoryMetadata == null) {
            MessageDialog.openWarning(new Shell(), Messages.getString("ComboController.alert"), //$NON-NLS-1$ //$NON-NLS-2$
            Messages.getString("ComboController.nothingGuess"));
            return cmd;
        }
    }
    cmd = new QueryGuessCommand(node, newRepositoryMetadata);
    /* parameter can be null,the setMaps won't use the third parameter */
    cmd.setMaps(dynamicProperty.getTableIdAndDbTypeMap(), dynamicProperty.getTableIdAndDbSchemaMap(), null);
    //$NON-NLS-1$
    String type = getValueFromRepositoryName("TYPE");
    cmd.setParameters(realTableId, realTableName, type);
    return cmd;
}
Also used : INode(org.talend.core.model.process.INode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) Point(org.eclipse.swt.graphics.Point) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Shell(org.eclipse.swt.widgets.Shell) CCombo(org.eclipse.swt.custom.CCombo) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 32 with Connection

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

the class AbstractRepositoryController method getConnection.

/**
     *
     * DOC wzhang Comment method "getConnection".
     *
     * @return
     */
private Connection getConnection() {
    if (this.elem == null) {
        return null;
    }
    if (elem instanceof Node) {
        IElementParameter elementParameter = ((Node) elem).getElementParameter(EParameterName.PROPERTY_TYPE.getName());
        if (elementParameter != null && !EmfComponent.BUILTIN.equals(elementParameter.getValue())) {
            String propertyValue = (String) (((Node) elem).getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()));
            IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(propertyValue);
            if (lastVersion != null) {
                final Item item = lastVersion.getProperty().getItem();
                if (item != null && item instanceof ConnectionItem) {
                    Connection repositoryConn = ((ConnectionItem) item).getConnection();
                    return repositoryConn;
                }
            }
        }
    }
    return null;
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Node(org.talend.designer.core.ui.editor.nodes.Node) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Connection(org.talend.core.model.metadata.builder.connection.Connection) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 33 with Connection

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

the class DbTypeListController method getCurrentDbms.

private static String getCurrentDbms(INode node) {
    boolean hasMappingType = false;
    String currentDbms = null;
    for (IElementParameter currentParam : node.getElementParameters()) {
        if (currentParam.getFieldType().equals(EParameterFieldType.MAPPING_TYPE) && currentParam.isShow(node.getElementParameters())) {
            currentDbms = (String) currentParam.getValue();
            hasMappingType = true;
        }
    }
    if (!hasMappingType) {
        // if there is no mapping type, then check if a db repository schema is used
        //$NON-NLS-1$
        IElementParameter schemaTypeParameter = node.getElementParameter("SCHEMA_TYPE");
        if (schemaTypeParameter == null) {
            return null;
        }
        String schemaType = (String) schemaTypeParameter.getValue();
        if (schemaType.equals("REPOSITORY")) {
            //$NON-NLS-1$
            // repository mode
            //$NON-NLS-1$
            String metaRepositoryName = (String) node.getElementParameter("REPOSITORY_SCHEMA_TYPE").getValue();
            Connection connection = MetadataToolHelper.getConnectionFromRepository(metaRepositoryName);
            if (connection instanceof DatabaseConnection) {
                // bug 13200
                if (((DatabaseConnection) connection).getDatabaseType().equals(EDatabaseTypeName.GENERAL_JDBC.getDisplayName())) {
                    // bug 7618 modify
                    currentDbms = (DBConnectionContextUtils.cloneOriginalValueConnection((DatabaseConnection) connection, true, null)).getDbmsId();
                } else {
                    currentDbms = ((DatabaseConnection) connection).getDbmsId();
                }
            }
        } else {
            //$NON-NLS-1$
            String componentDbType = "";
            for (IElementParameter param : (List<IElementParameter>) node.getElementParameters()) {
                if (param.getRepositoryValue() != null) {
                    if (param.getRepositoryValue().equals("TYPE")) {
                        //$NON-NLS-1$
                        componentDbType = (String) param.getValue();
                    }
                }
            }
            String componentProduct = EDatabaseTypeName.getTypeFromDbType(componentDbType).getProduct();
            if (EDatabaseTypeName.supportDbType(componentDbType)) {
                currentDbms = MetadataTalendType.getDefaultDbmsFromProduct(componentProduct).getId();
            }
        }
    }
    return currentDbms;
}
Also used : DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) IElementParameter(org.talend.core.model.process.IElementParameter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) List(java.util.List)

Example 34 with Connection

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

the class AddQuoteMarkMigrationTask method addQuote.

/**
     * Add quote marks to the separators.
     * 
     * yzhang Comment method "addQuote".
     * 
     * @throws PersistenceException
     */
private void addQuote(ConnectionItem connItem) throws PersistenceException {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    Connection conn = connItem.getConnection();
    if (conn instanceof FileConnection) {
        FileConnection fileConnection = (FileConnection) conn;
        String old = null;
        old = fileConnection.getFieldSeparatorValue();
        if (!isWithinQuote(old)) {
            fileConnection.setFieldSeparatorValue(surroundDQuote(old));
            modified = true;
        }
        old = fileConnection.getRowSeparatorValue();
        if (!isWithinQuote(old)) {
            fileConnection.setRowSeparatorValue(surroundDQuote(old));
            modified = true;
        }
        old = fileConnection.getEscapeChar();
        if (!isWithinQuote(old)) {
            fileConnection.setEscapeChar(TalendTextUtils.addQuotes(old));
            modified = true;
        }
        old = fileConnection.getTextEnclosure();
        if (!isWithinQuote(old)) {
            fileConnection.setTextEnclosure(TalendTextUtils.addQuotes(old));
            modified = true;
        }
    }
    if (modified) {
        factory.save(connItem);
    }
}
Also used : ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) FileConnection(org.talend.core.model.metadata.builder.connection.FileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) FileConnection(org.talend.core.model.metadata.builder.connection.FileConnection)

Example 35 with Connection

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

the class PropertyTypeController method createButtonCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createControl(org.eclipse
     * .swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
     * org.eclipse.swt.widgets.Control)
     */
@Override
protected Command createButtonCommand(Button button) {
    // hwang add for feature 6484
    FileItem repositoryFileItem = null;
    LinkRulesItem linkItem = null;
    Map<String, FileItem> repositoryFileItemMap = null;
    Map<String, LinkRulesItem> repositoryLinkRulesItemMap = null;
    String paramName = (String) button.getData(PARAMETER_NAME);
    IElementParameter param = elem.getElementParameter(paramName);
    Object data = button.getData(NAME);
    if (data != null && data.equals(REPOSITORY_CHOICE)) {
        IElementParameter dbTypeParam = null;
        if (elem instanceof org.talend.designer.core.ui.editor.process.Process || elem instanceof StatsAndLogsElement || elem instanceof ImplicitContextLoadElement) {
            if (EParameterName.PROPERTY_TYPE.getName().equals(paramName)) {
                dbTypeParam = elem.getElementParameter(EParameterName.DB_TYPE.getName());
            } else if (JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()).equals(paramName)) {
                dbTypeParam = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName()));
            }
        }
        Item item = null;
        String id = null;
        RepositoryNode selectNode = null;
        if (id == null) {
            RepositoryReviewDialog dialog = null;
            if (dbTypeParam != null) {
                String[] listRepositoryItems = dbTypeParam.getListRepositoryItems();
                dialog = new RepositoryReviewDialog(Display.getCurrent().getActiveShell(), ERepositoryObjectType.METADATA, param.getRepositoryValue(), listRepositoryItems);
            } else {
                // Added TDQ-11688
                ITDQPatternService service = null;
                if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
                    service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
                }
                if (service != null && service.isSinglePatternNode(elem)) {
                    return processPattern(elem);
                }
                // ~
                dialog = new RepositoryReviewDialog(Display.getCurrent().getActiveShell(), ERepositoryObjectType.METADATA, elem, param);
            }
            if (dialog.open() == RepositoryReviewDialog.OK) {
                selectNode = dialog.getResult();
                id = selectNode.getObject().getId();
            }
        }
        if (id != null && !"".equals(id)) {
            //$NON-NLS-1$
            IElementParameter repositoryParam = param.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
            //$NON-NLS-1$
            String fullParamName = paramName + ":" + getRepositoryChoiceParamName();
            Connection repositoryConnection = null;
            // Map<String, ConnectionItem> repositoryConnectionItemMap =
            // dynamicProperty.getRepositoryConnectionItemMap();
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            try {
                IRepositoryViewObject repobj = factory.getLastVersion(id);
                if (repobj != null) {
                    Property property = repobj.getProperty();
                    if (property != null) {
                        item = property.getItem();
                    }
                }
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
            if (item != null) {
                if (item instanceof ConnectionItem) {
                    repositoryConnection = ((ConnectionItem) item).getConnection();
                }
            } else {
                repositoryConnection = null;
                if (repositoryParam != null) {
                    item = selectNode.getObject().getProperty().getItem();
                    if (item instanceof ConnectionItem) {
                        repositoryConnection = ((ConnectionItem) item).getConnection();
                    }
                }
            }
            if (repositoryConnection != null) {
                CompoundCommand compoundCommand = new CompoundCommand();
                ChangeValuesFromRepository changeValuesFromRepository = null;
                if (selectNode.getObjectType() == ERepositoryObjectType.SERVICESOPERATION && GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
                    IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
                    IProcess2 process = (IProcess2) RepositoryPlugin.getDefault().getDesignerCoreService().getCurrentProcess();
                    String currentJobId = process.getProperty().getId();
                    String serviceId = item.getProperty().getId();
                    String portId = selectNode.getParent().getObject().getId();
                    String operationId = selectNode.getObject().getId();
                    changeValuesFromRepository = new ChangeValuesFromRepository(elem, repositoryConnection, param.getName() + ":" + //$NON-NLS-1$
                    EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$ //$NON-NLS-2$
                    serviceId + " - " + portId + " - " + operationId);
                    service.deleteOldRelation(currentJobId);
                    //$NON-NLS-1$ //$NON-NLS-2$
                    service.updateOperation((INode) elem, serviceId + " - " + portId + " - " + operationId, selectNode);
                } else {
                    changeValuesFromRepository = new ChangeValuesFromRepository(elem, repositoryConnection, fullParamName, id);
                }
                if (changeValuesFromRepository != null) {
                    compoundCommand.add(changeValuesFromRepository);
                }
                updateDBType(compoundCommand, repositoryConnection);
                return compoundCommand;
            }
            // for ruleItem,hywang add
            if (dynamicProperty instanceof MultipleThreadDynamicComposite) {
                repositoryFileItemMap = ((MultipleThreadDynamicComposite) dynamicProperty).getRepositoryFileItemMap();
                repositoryLinkRulesItemMap = ((MultipleThreadDynamicComposite) dynamicProperty).getRepositoryLinkRulesItemMap();
            }
            if (repositoryFileItemMap.containsKey(id)) {
                repositoryFileItem = repositoryFileItemMap.get(id);
            } else if (repositoryLinkRulesItemMap.containsKey(id)) {
                linkItem = repositoryLinkRulesItemMap.get(id);
            } else {
                if (!repositoryFileItemMap.isEmpty()) {
                    repositoryFileItem = repositoryFileItemMap.values().iterator().next();
                } else {
                    repositoryFileItem = null;
                }
            }
            if (repositoryFileItem == null && item instanceof FileItem) {
                repositoryFileItem = (FileItem) item;
            }
            if (repositoryFileItem != null) {
                CompoundCommand compoundCommand = new CompoundCommand();
                final String showId = repositoryFileItem.getProperty().getId();
                Command command = new PropertyChangeCommand(elem, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
                compoundCommand.add(command);
                return compoundCommand;
            }
            if (linkItem != null) {
                CompoundCommand compoundCommand = new CompoundCommand();
                final String showId = linkItem.getProperty().getId();
                Command command = new PropertyChangeCommand(elem, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
                compoundCommand.add(command);
                return compoundCommand;
            }
        }
    } else {
        // 1. open wizard
        if (elem instanceof INode) {
            INode node = (INode) elem;
            final IRepositoryService repositoryService = CorePlugin.getDefault().getRepositoryService();
            if (param != null) {
                RepositoryNode realNode = null;
                String repositoryValue = param.getRepositoryValue();
                if (repositoryValue != null && repositoryValue.startsWith(ERepositoryCategoryType.DATABASE.getName())) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_CONNECTIONS);
                } else // file delimited
                if (ERepositoryCategoryType.DELIMITED.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_DELIMITED);
                }
                // file positional
                if (ERepositoryCategoryType.POSITIONAL.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_POSITIONAL);
                }
                // file regexp
                if (ERepositoryCategoryType.REGEX.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_REGEXP);
                }
                // file xml
                if (ERepositoryCategoryType.XML.getName().equals(repositoryValue) || // bug 18012
                repositoryValue.startsWith(ERepositoryCategoryType.XML.getName())) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_XML);
                }
                // file ldif
                if (ERepositoryCategoryType.LDIF.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_LDIF);
                }
                // excel
                if (ERepositoryCategoryType.EXCEL.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_EXCEL);
                }
                // generic schema
                if (ERepositoryCategoryType.GENERIC.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_GENERIC_SCHEMA);
                }
                // ldap
                if (ERepositoryCategoryType.LDAP.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_LDAP_SCHEMA);
                }
                // wsdl
                if (ERepositoryCategoryType.WSDL.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_WSDL_SCHEMA);
                }
                if (ERepositoryCategoryType.WEBSERVICE.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_WSDL_SCHEMA);
                }
                // salesforce
                if (ERepositoryCategoryType.SALESFORCE.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA);
                }
                // ebcdic
                if (ERepositoryCategoryType.EBCDIC.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_EBCDIC);
                }
                // mdm
                if (ERepositoryCategoryType.MDM.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_MDMCONNECTION);
                }
                // sap
                if (ERepositoryCategoryType.SAP.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SAPCONNECTIONS);
                }
                // sapIDoc
                if (ERepositoryCategoryType.SAPIDOC.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SAP_IDOC);
                }
                if (ERepositoryCategoryType.HEADERFOOTER.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_HEADER_FOOTER);
                }
                // brms
                if (ERepositoryCategoryType.BRMS.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_BRMS);
                }
                // hl7
                if (ERepositoryCategoryType.HL7.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_HL7);
                }
                // last resort we assume that the repository value was named after the root component type key
                if (realNode == null) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.getTypeFromKey(repositoryValue));
                }
                if (realNode != null) {
                    final IMetadataService metadataService = CorePlugin.getDefault().getMetadataService();
                    if (metadataService != null) {
                        ConnectionItem connItem = metadataService.openMetadataConnection(true, realNode, node);
                        if (connItem != null) {
                            IElementParameter propertyParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
                            propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                            // 2. commnd
                            Command cmd = new ChangeValuesFromRepository(node, connItem.getConnection(), //$NON-NLS-1$
                            propertyParam.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), connItem.getProperty().getId());
                            executeCommand(cmd);
                            // see bug in feature 5998.refresh repositoryList.
                            if (dynamicProperty instanceof MultipleThreadDynamicComposite) {
                                ((MultipleThreadDynamicComposite) dynamicProperty).updateRepositoryList();
                            }
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : INode(org.talend.core.model.process.INode) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) MultipleThreadDynamicComposite(org.talend.designer.core.ui.views.properties.MultipleThreadDynamicComposite) IRepositoryService(org.talend.repository.model.IRepositoryService) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) FileItem(org.talend.core.model.properties.FileItem) IElementParameter(org.talend.core.model.process.IElementParameter) ITDQPatternService(org.talend.core.ITDQPatternService) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) 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) RepositoryNode(org.talend.repository.model.RepositoryNode) RepositoryReviewDialog(org.talend.repository.ui.dialog.RepositoryReviewDialog) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) FileItem(org.talend.core.model.properties.FileItem) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IESBService(org.talend.core.IESBService) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ImplicitContextLoadElement(org.talend.designer.core.ui.projectsetting.ImplicitContextLoadElement) StatsAndLogsElement(org.talend.designer.core.ui.projectsetting.StatsAndLogsElement) IMetadataService(org.talend.repository.model.IMetadataService)

Aggregations

Connection (org.talend.core.model.metadata.builder.connection.Connection)74 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)42 ConnectionItem (org.talend.core.model.properties.ConnectionItem)39 PersistenceException (org.talend.commons.exception.PersistenceException)28 IElementParameter (org.talend.core.model.process.IElementParameter)27 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)26 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)20 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)19 Item (org.talend.core.model.properties.Item)19 ArrayList (java.util.ArrayList)14 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)14 Property (org.talend.core.model.properties.Property)14 ChangeValuesFromRepository (org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository)13 QueriesConnection (org.talend.core.model.metadata.builder.connection.QueriesConnection)12 XmlFileConnection (org.talend.core.model.metadata.builder.connection.XmlFileConnection)9 IConnection (org.talend.core.model.process.IConnection)9 IMetadataConnection (org.talend.core.model.metadata.IMetadataConnection)8 IDynamicProperty (org.talend.core.ui.properties.tab.IDynamicProperty)8 List (java.util.List)7 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)7