Search in sources :

Example 16 with Connection

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

the class EncryptDbPasswordMigrationTask method encryptItem.

/**
     * DOC chuang Comment method "encryptItem".
     * 
     * @param item
     * @return
     */
private ExecutionResult encryptItem(DatabaseConnectionItem item) {
    Connection conn = item.getConnection();
    if (conn instanceof DatabaseConnection) {
        DatabaseConnection dbConn = (DatabaseConnection) conn;
        if (needEncrypted(dbConn)) {
            try {
                encryptPassword(dbConn);
                factory.save(item, true);
            } catch (Exception e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 17 with Connection

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

the class EncryptPassword4FTPItemFileMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    if (item instanceof FTPConnectionItem) {
        FTPConnectionItem item1 = (FTPConnectionItem) item;
        Connection connection = item1.getConnection();
        if (connection instanceof FTPConnection) {
            FTPConnection ftpConn = (FTPConnection) connection;
            try {
                if (encryptPassword(ftpConn)) {
                    factory.save(item, true);
                }
            } catch (Exception e1) {
                ExceptionHandler.process(e1);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : Connection(org.talend.core.model.metadata.builder.connection.Connection) FTPConnection(org.talend.core.model.metadata.builder.connection.FTPConnection) FTPConnectionItem(org.talend.core.model.properties.FTPConnectionItem) FTPConnection(org.talend.core.model.metadata.builder.connection.FTPConnection)

Example 18 with Connection

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

the class ConvertLabelForConnectionItemMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    boolean changed = false;
    if (item instanceof ConnectionItem) {
        ConnectionItem conItem = (ConnectionItem) item;
        Connection connection = conItem.getConnection();
        Set tables = ConnectionHelper.getTables(connection);
        for (Object tableObj : tables) {
            MetadataTable table = (MetadataTable) tableObj;
            String label = table.getLabel();
            if (label != null) {
                String validateValue = MetadataToolHelper.validateValue(label);
                if (validateValue != null && !label.equals(validateValue)) {
                    table.setLabel(validateValue);
                    changed = true;
                }
            }
        }
    }
    if (changed) {
        try {
            FACTORY.save(item, true);
            return ExecutionResult.SUCCESS_NO_ALERT;
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : Set(java.util.Set) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Connection(org.talend.core.model.metadata.builder.connection.Connection) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 19 with Connection

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

the class RepositoryChangeMetadataCommand method setTableRelevantParameterValues.

protected void setTableRelevantParameterValues() {
    Connection conn = connection;
    if (conn == null) {
        if (newPropValue != null && newPropValue instanceof String) {
            String schemaId = (String) newPropValue;
            //$NON-NLS-1$
            String[] values = schemaId.split(" - ");
            String repositoryID = values[0];
            IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(repositoryID);
            if (repositoryNode != null && repositoryNode.getObject() != null) {
                Item item = repositoryNode.getObject().getProperty().getItem();
                if (item instanceof ConnectionItem) {
                    ConnectionItem conItem = (ConnectionItem) item;
                    conn = conItem.getConnection();
                }
            }
        }
    }
    for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
        if (handler.canHandle(conn)) {
            handler.handleTableRelevantParameters(conn, node, newOutputMetadata);
        }
    }
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) SalesforceSchemaConnectionItem(org.talend.core.model.properties.SalesforceSchemaConnectionItem) Item(org.talend.core.model.properties.Item) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IDragAndDropServiceHandler(org.talend.core.model.utils.IDragAndDropServiceHandler) ConnectionItem(org.talend.core.model.properties.ConnectionItem) SalesforceSchemaConnectionItem(org.talend.core.model.properties.SalesforceSchemaConnectionItem) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) SalesforceSchemaConnection(org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection)

Example 20 with Connection

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

the class ComponentChooseDialog method propaHadoopCfgChanges.

/**
     * DOC ycbai Comment method "propaHadoopCfgChanges".
     *
     * <P>
     * Propagate the changes from hadoop cluster to M/R process when drag&drop hadoop subnode from repository view to
     * M/R process.
     * </P>
     *
     * @param repositoryNode
     */
private void propaHadoopCfgChanges(IRepositoryNode repositoryNode) {
    if (repositoryNode == null || repositoryNode.getObject() == null) {
        return;
    }
    IHadoopClusterService hadoopClusterService = HadoopRepositoryUtil.getHadoopClusterService();
    if (hadoopClusterService == null || !hadoopClusterService.isHadoopSubnode(repositoryNode)) {
        return;
    }
    IProcess process = editor.getProcess();
    if (!ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process.getComponentsType()) && !ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType()) && !ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
        return;
    }
    if ((process instanceof IProcess2) && (((IProcess2) process).getProperty().getItem() instanceof JobletProcessItem)) {
        return;
    }
    Item subItem = repositoryNode.getObject().getProperty().getItem();
    String propertyParamName = MR_PROPERTY_PREFIX + EParameterName.PROPERTY_TYPE.getName();
    String propertyRepTypeParamName = MR_PROPERTY_PREFIX + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
    IElementParameter propertyParam = process.getElementParameter(propertyParamName);
    if (propertyParam == null) {
        return;
    }
    String repositoryValue = propertyParam.getRepositoryValue();
    if (repositoryValue == null) {
        return;
    }
    //$NON-NLS-1$
    String[] supportedRepositoryTypes = repositoryValue.split("\\|");
    String repositoryType = hadoopClusterService.getRepositoryTypeOfHadoopSubItem(subItem);
    if (!ArrayUtils.contains(supportedRepositoryTypes, repositoryType)) {
        return;
    }
    Item hadoopClusterItem = hadoopClusterService.getHadoopClusterBySubitemId(new Project(ProjectManager.getInstance().getProject(subItem)), subItem.getProperty().getId());
    String hadoopClusterId = hadoopClusterItem.getProperty().getId();
    if (EmfComponent.REPOSITORY.equals(propertyParam.getValue())) {
        // do nothing when select the same hadoop cluster.
        String propertyId = (String) process.getElementParameter(propertyRepTypeParamName).getValue();
        if (hadoopClusterId.equals(propertyId)) {
            return;
        }
    }
    Connection connection = ((ConnectionItem) subItem).getConnection();
    if (hadoopClusterService.hasDiffsFromClusterToProcess(subItem, process)) {
        boolean confirmUpdate = MessageDialog.openConfirm(editor.getSite().getShell(), //$NON-NLS-1$
        Messages.getString("TalendEditorDropTargetListener.updateHadoopCfgDialog.title"), //$NON-NLS-1$
        Messages.getString("TalendEditorDropTargetListener.updateHadoopCfgDialog.msg"));
        if (confirmUpdate) {
            // Update spark mode to YARN_CLIENT if repository
            if (ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType()) || ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
                IElementParameter sparkLocalParam = process.getElementParameter(HadoopConstants.SPARK_LOCAL_MODE);
                IElementParameter sparkParam = process.getElementParameter(HadoopConstants.SPARK_MODE);
                if (sparkLocalParam != null && (Boolean) (sparkLocalParam.getValue())) {
                    sparkLocalParam.setValue(false);
                }
                if (sparkParam != null && !HadoopConstants.SPARK_MODE_YARN_CLIENT.equals(sparkParam.getValue())) {
                    sparkParam.setValue(HadoopConstants.SPARK_MODE_YARN_CLIENT);
                }
            }
            propertyParam.setValue(EmfComponent.REPOSITORY);
            ChangeValuesFromRepository command = new ChangeValuesFromRepository(process, connection, propertyRepTypeParamName, subItem.getProperty().getId());
            execCommandStack(command);
        }
    }
}
Also used : ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) 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) 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) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) RulesItem(org.talend.core.model.properties.RulesItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) FileItem(org.talend.core.model.properties.FileItem) Project(org.talend.core.model.general.Project) IHadoopClusterService(org.talend.core.hadoop.IHadoopClusterService) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) IElementParameter(org.talend.core.model.process.IElementParameter) IProcess(org.talend.core.model.process.IProcess)

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