Search in sources :

Example 11 with DatabaseConnectionItem

use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.

the class TAmazonOracleDndFilter method except.

@Override
public boolean except(Item item, ERepositoryObjectType type, RepositoryNode seletetedNode, IComponent component, String repositoryType) {
    if (component != null) {
        // for tAmazonOracleInput/Output/Connection/Row
        if (component.getName().startsWith("tAmazonOracle")) {
            //$NON-NLS-1$
            String dbType = null;
            if (item != null && item instanceof DatabaseConnectionItem) {
                if (((DatabaseConnectionItem) item).getConnection() instanceof DatabaseConnection) {
                    dbType = ((DatabaseConnection) ((DatabaseConnectionItem) item).getConnection()).getDatabaseType();
                }
            }
            Node node = new Node(component);
            if (node != null) {
                //$NON-NLS-1$
                IElementParameter param = node.getElementParameter("CONNECTION_TYPE");
                if (param != null) {
                    Object[] valuesList = param.getListItemsValue();
                    for (Object element : valuesList) {
                        String conType = EDatabaseTypeName.getTypeFromDbType(element.toString()).getDisplayName();
                        if (conType != null && dbType != null && conType.equals(dbType)) {
                            return false;
                        }
                    }
                }
            }
            return true;
        } else if (("tOracleCDCOutput").equals(component.getName())) {
            //$NON-NLS-1$
            if (item != null && item instanceof DatabaseConnectionItem) {
                if (((DatabaseConnectionItem) item).getConnection() instanceof DatabaseConnection) {
                    DatabaseConnection connection = ((DatabaseConnection) ((DatabaseConnectionItem) item).getConnection());
                    if (MetadataConnectionUtils.isOracle(connection)) {
                        String version = connection.getDbVersionString();
                        if (EDatabaseVersion4Drivers.ORACLE_12.name().equals(version)) {
                            return false;
                        }
                    }
                }
            }
            return true;
        }
    }
    return false;
}
Also used : RepositoryNode(org.talend.repository.model.RepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IElementParameter(org.talend.core.model.process.IElementParameter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 12 with DatabaseConnectionItem

use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.

the class MysqlOutputDBVersionForBug13250 method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
public ExecutionResult execute(Item item) {
    if (item instanceof DatabaseConnectionItem) {
        boolean modify = false;
        DatabaseConnectionItem mysqlConnItem = (DatabaseConnectionItem) item;
        if (mysqlConnItem.getConnection() instanceof DatabaseConnection) {
            DatabaseConnection mysqlConnection = (DatabaseConnection) mysqlConnItem.getConnection();
            if ("MySQL".equalsIgnoreCase(mysqlConnection.getDatabaseType())) {
                if (mysqlConnection.getDbVersionString() == null || "".equals(mysqlConnection.getDbVersionString())) {
                    mysqlConnection.setDbVersionString("MYSQL_5");
                    modify = true;
                }
            }
        }
        if (modify) {
            try {
                ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                factory.save(item, true);
                return ExecutionResult.SUCCESS_WITH_ALERT;
            } catch (Exception e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 13 with DatabaseConnectionItem

use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.

the class SchemaTypeProcessor method selectRepositoryNode.

@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
    if (super.selectRepositoryNode(viewer, parentNode, node)) {
        IRepositoryViewObject object = node.getObject();
        if (object != null) {
            // query
            if (object instanceof Query) {
                return false;
            }
        }
        // cdc
        ICDCProviderService cdcService = null;
        if (PluginChecker.isCDCPluginLoaded()) {
            cdcService = (ICDCProviderService) GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
        }
        String repositoryType = getRepositoryType();
        if (ERepositoryCategoryType.CDC.getName().equals(repositoryType) && (object != null)) {
            if (object.getRepositoryObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
                DatabaseConnectionItem item = (DatabaseConnectionItem) object.getProperty().getItem();
                DatabaseConnection connection = (DatabaseConnection) item.getConnection();
                if (cdcService != null && cdcService.canCreateCDCConnection(connection)) {
                    return true;
                }
                return false;
            }
            if (object instanceof MetadataTable) {
                return ((MetadataTableRepositoryObject) object).getTable().isActivatedCDC();
            }
        }
        return true;
    }
    return false;
}
Also used : Query(org.talend.core.model.metadata.Query) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.MetadataTable) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) ICDCProviderService(org.talend.core.ui.ICDCProviderService) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 14 with DatabaseConnectionItem

use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.

the class SQLBuilderDialog method deleteNoUseTable.

private void deleteNoUseTable() {
    // add for bug TDI-17097
    connection = (DatabaseConnection) SQLBuilderRepositoryNodeManager.getItem(SQLBuilderRepositoryNodeManager.getRoot(nodeInEditor)).getConnection();
    if (SQLBuilderRepositoryNodeManager.tList instanceof List) {
        if (SQLBuilderRepositoryNodeManager.tList.size() == 0) {
            SQLBuilderRepositoryNodeManager.tList.addAll(ConnectionHelper.getTables(connection));
        }
    } else {
        SQLBuilderRepositoryNodeManager.tList = new ArrayList<MetadataTable>();
        SQLBuilderRepositoryNodeManager.tList.addAll(ConnectionHelper.getTables(connection));
    }
    if (SQLBuilderRepositoryNodeManager.tList == null || SQLBuilderRepositoryNodeManager.tList.size() == 0) {
        return;
    }
    // changed for bug TDI-19892
    if (node == null) {
        SQLBuilderRepositoryNodeManager.tList = null;
        return;
    }
    IRepositoryViewObject repositoryObject = node.getObject();
    Item item = repositoryObject.getProperty().getItem();
    if (item instanceof DatabaseConnectionItem) {
        manager.deleteNouseTables(((DatabaseConnectionItem) item).getConnection());
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) CTabItem(org.eclipse.swt.custom.CTabItem) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) List(java.util.List) ArrayList(java.util.ArrayList) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 15 with DatabaseConnectionItem

use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.

the class MetadataColumnComparator method saveEMFMetadataColumn.

@SuppressWarnings("unchecked")
private static void saveEMFMetadataColumn(String id, List<MetadataColumn> columnNodes) {
    DatabaseConnectionItem item = getEMFItem(id);
    final DatabaseConnection connection = (DatabaseConnection) item.getConnection();
    IMetadataConnection iMetadataConnection = ConvertionHelper.convert(connection);
    Set<MetadataTable> tableset = ConnectionHelper.getTables(connection);
    List<MetadataTable> tables = new ArrayList<MetadataTable>();
    tables.addAll(tableset);
    List<MetadataColumn> emfCols = new ArrayList<MetadataColumn>();
    List<MetadataColumn> dbCols = new ArrayList<MetadataColumn>();
    for (MetadataColumn col : columnNodes) {
        for (MetadataTable table : tables) {
            if (table.getLabel().equals(col.getTable().getLabel())) {
                List<TdColumn> returnCols = ExtractMetaDataFromDataBase.returnMetadataColumnsFormTable(iMetadataConnection, table.getSourceName());
                for (MetadataColumn emfcolumn : table.getColumns()) {
                    for (MetadataColumn column : returnCols) {
                        if (emfcolumn.getLabel().equals(col.getLabel()) && column.getLabel().equals(col.getOriginalField())) {
                            emfCols.add(emfcolumn);
                            dbCols.add(column);
                        }
                    }
                }
            }
        }
    }
    saveOneMetadataColumn(emfCols, columnNodes, dbCols);
    saveMetaData(item);
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ArrayList(java.util.ArrayList) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Aggregations

DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)50 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)40 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)23 PersistenceException (org.talend.commons.exception.PersistenceException)16 Connection (org.talend.core.model.metadata.builder.connection.Connection)13 Item (org.talend.core.model.properties.Item)13 ConnectionItem (org.talend.core.model.properties.ConnectionItem)12 ArrayList (java.util.ArrayList)11 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)11 IElementParameter (org.talend.core.model.process.IElementParameter)10 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)9 Query (org.talend.core.model.metadata.builder.connection.Query)9 RepositoryNode (org.talend.repository.model.RepositoryNode)9 INode (org.talend.core.model.process.INode)7 IMetadataConnection (org.talend.core.model.metadata.IMetadataConnection)6 ContextItem (org.talend.core.model.properties.ContextItem)6 QueryRepositoryObject (org.talend.core.repository.model.repositoryObject.QueryRepositoryObject)6 Node (org.talend.designer.core.ui.editor.nodes.Node)6 List (java.util.List)5 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)5