Search in sources :

Example 86 with DatabaseConnection

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

the class TOPRepositoryService method removeAliasInSQLExplorer.

public boolean removeAliasInSQLExplorer(IRepositoryNode children) {
    boolean hasDependencyItem = true;
    // MOD klliu 2011-04-28 bug 20204 removing connection is synced to the connection view of SQL explore
    Item item = children.getObject().getProperty().getItem();
    // MOD mzhao filter the connections which is not a type of database.
    if (item != null && item instanceof ConnectionItem) {
        Connection connection = ((ConnectionItem) item).getConnection();
        if (connection instanceof DatabaseConnection || connection instanceof DelimitedFileConnection || connection instanceof MDMConnection) {
            CWMPlugin.getDefault().removeAliasInSQLExplorer(connection);
        }
    }
    return hasDependencyItem;
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) 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) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection)

Example 87 with DatabaseConnection

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

the class TOPRepositoryService method reloadDatabase.

/**
 * Comment method "reloadDatabase".
 *
 * @param connectionItem
 * @deprecated instead of it by TDQCompareService.reloadDatabase
 */
@Deprecated
public ReturnCode reloadDatabase(ConnectionItem connectionItem) {
    ReturnCode retCode = new ReturnCode(Boolean.TRUE);
    Connection conn = connectionItem.getConnection();
    try {
        if (conn instanceof DatabaseConnection) {
            List<ModelElement> dependencyClients = EObjectHelper.getDependencyClients(conn);
            if (!(dependencyClients == null || dependencyClients.isEmpty())) {
                int isOk = DeleteModelElementConfirmDialog.showElementImpactConfirmDialog(null, new ModelElement[] { conn }, // $NON-NLS-1$
                DefaultMessagesImpl.getString("TOPRepositoryService.dependcyTile"), DefaultMessagesImpl.getString("TOPRepositoryService.dependcyMessage", // $NON-NLS-1$
                conn.getLabel()));
                if (isOk != Dialog.OK) {
                    retCode.setOk(Boolean.FALSE);
                    // $NON-NLS-1$
                    retCode.setMessage("The user canceled the operation!");
                    return retCode;
                }
            }
            final IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(conn);
            Connection newConnection = creatComparisonLevel.reloadCurrentLevelElement();
            // update the sql explore.
            Property property = PropertyHelper.getProperty(newConnection);
            if (property != null) {
                Item newItem = property.getItem();
                if (newItem != null) {
                    CWMPlugin.getDefault().updateConnetionAliasByName(newConnection, newConnection.getLabel());
                // notifySQLExplorer(newItem);
                }
            }
            // update the related analyses.
            WorkbenchUtils.impactExistingAnalyses(newConnection);
        }
    } catch (ReloadCompareException e) {
        log.error(e, e);
        retCode.setOk(Boolean.FALSE);
        retCode.setMessage(e.getMessage());
    } catch (PartInitException e) {
        log.error(e, e);
        retCode.setOk(Boolean.FALSE);
        retCode.setMessage(e.getMessage());
    }
    return retCode;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property) IComparisonLevel(org.talend.cwm.compare.factory.IComparisonLevel)

Example 88 with DatabaseConnection

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

the class ExportConnectionToTOSAction method fillCatalogSchema.

/**
 * DOC gdbu Comment method "fillCatalogSchema".
 *
 * @deprecated Won't be used.
 * @param tdDataProvider
 */
@Deprecated
protected DatabaseConnection fillCatalogSchema(IMetadataConnection newMetadataConn) {
    MetadataFillFactory instance = MetadataFillFactory.getDBInstance(newMetadataConn);
    ReturnCode rc = instance.createConnection(newMetadataConn);
    DatabaseConnection dbConn = null;
    if (rc.isOk()) {
        dbConn = (DatabaseConnection) instance.fillUIConnParams(newMetadataConn, null);
        DatabaseMetaData dbMetadata = null;
        java.sql.Connection sqlConn = null;
        try {
            if (rc instanceof TypedReturnCode) {
                Object sqlConnObject = ((TypedReturnCode) rc).getObject();
                if (sqlConnObject instanceof java.sql.Connection) {
                    sqlConn = (java.sql.Connection) sqlConnObject;
                    dbMetadata = ExtractMetaDataUtils.getInstance().getConnectionMetadata(sqlConn);
                }
            }
            List<String> packageFilterCatalog = MetadataConnectionUtils.getPackageFilter(dbConn, dbMetadata, true);
            instance.fillCatalogs(dbConn, dbMetadata, packageFilterCatalog);
            List<String> packageFilterSchema = MetadataConnectionUtils.getPackageFilter(dbConn, dbMetadata, false);
            instance.fillSchemas(dbConn, dbMetadata, packageFilterSchema);
        } catch (SQLException e) {
            log.error(e, e);
        } finally {
            if (sqlConn != null) {
                ConnectionUtils.closeConnection(sqlConn);
            }
        }
    } else {
        log.error(rc.getMessage());
    }
    return dbConn;
}
Also used : TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) SQLException(java.sql.SQLException) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) DatabaseMetaData(java.sql.DatabaseMetaData) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) MetadataFillFactory(org.talend.metadata.managment.model.MetadataFillFactory) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection)

Example 89 with DatabaseConnection

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

the class AliasAndManaDriverHelper method addJars.

/**
 * add jars into ManagedDriver attribute.these jars have a real path so that can be accessed.
 *
 * @param connection
 * @param manDr
 * @throws MalformedURLException
 */
public void addJars(Connection connection, ManagedDriver manDr) throws MalformedURLException {
    List<String> driverJarNameList = new ArrayList<String>();
    DatabaseConnection dbConnnection = (DatabaseConnection) connection;
    String driverJarPath = JavaSqlFactory.getDriverJarPath(dbConnnection);
    if (ConnectionHelper.isJDBC(dbConnnection) && driverJarPath != null) {
        // $NON-NLS-1$
        String[] pathArray = driverJarPath.split(";");
        for (String path : pathArray) {
            driverJarNameList.add(path);
        }
    } else {
        String databaseType = dbConnnection.getDatabaseType();
        if (StringUtils.equals(EDatabaseTypeName.IMPALA.getDisplayName(), databaseType)) {
            driverJarNameList = getImpalaDriverJarNameList(dbConnnection);
        } else {
            driverJarNameList = EDatabaseVersion4Drivers.getDrivers(databaseType, dbConnnection.getDbVersionString());
        }
    }
    manDr.setJars(getDriverJarRealPaths(driverJarNameList));
}
Also used : ArrayList(java.util.ArrayList) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection)

Example 90 with DatabaseConnection

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

the class TreeMessageInfoDialog method getLabelProvider.

protected ILabelProvider getLabelProvider() {
    if (labelProvider == null) {
        labelProvider = new LabelProvider() {

            @Override
            public String getText(Object obj) {
                if (obj == null) {
                    // $NON-NLS-1$
                    return "";
                }
                if (obj instanceof ImpactNode) {
                    return ((ImpactNode) obj).toString();
                } else if (obj instanceof IFile) {
                    IFile file = (IFile) obj;
                    ModelElement modelElement = ModelElementFileFactory.getModelElement(file);
                    // MOD msjian TDQ-5909: modify to displayName
                    return modelElement != null ? PropertyHelper.getProperty(modelElement).getDisplayName() : file.getName();
                } else if (obj instanceof RepositoryViewObject) {
                    // Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
                    return ((IRepositoryViewObject) obj).getLabel();
                } else if (obj instanceof MetadataTable) {
                    // ADD TDQ-7146: for all type's connection table/view node
                    return ((ModelElement) obj).getName();
                }
                Property property = PropertyHelper.getProperty((ModelElement) obj);
                return property == null ? ((ModelElement) obj).getName() : property.getDisplayName();
            }

            @Override
            public Image getImage(Object obj) {
                ModelElement modelElement = null;
                if (obj instanceof ModelElement) {
                    modelElement = (ModelElement) obj;
                } else if (obj instanceof ImpactNode) {
                    modelElement = ((ImpactNode) obj).getNodeElement();
                } else if (obj instanceof IFile) {
                    modelElement = ModelElementFileFactory.getModelElement((IFile) obj);
                } else if (obj instanceof RepositoryViewObject) {
                    // Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
                    return ImageLib.getImage(ImageLib.JRXML_ICON);
                }
                // ~
                if (modelElement == null) {
                    if (((ImpactNode) obj).getNode() != null) {
                        return ImageLib.getImage(ImageLib.JRXML_ICON);
                    }
                    return super.getImage(obj);
                }
                Image modelElementImage = null;
                String imgName = null;
                if (modelElement instanceof Analysis) {
                    imgName = ImageLib.ANALYSIS_OBJECT;
                } else if (modelElement instanceof TdReport) {
                    imgName = ImageLib.REPORT_OBJECT;
                } else if (modelElement instanceof DatabaseConnection) {
                    imgName = ImageLib.CONNECTION;
                } else if (modelElement instanceof DelimitedFileConnection) {
                    imgName = ImageLib.FILE_DELIMITED;
                } else if (modelElement instanceof Pattern) {
                    imgName = ImageLib.PATTERN_REG;
                } else if (modelElement instanceof IndicatorDefinition) {
                    // IndicatorDefinition
                    if (modelElement instanceof DQRule) {
                        imgName = ImageLib.DQ_RULE;
                    } else if (modelElement instanceof MatchRuleDefinition) {
                        imgName = ImageLib.MATCH_RULE_ICON;
                    } else {
                        imgName = ImageLib.IND_DEFINITION;
                    }
                // TDQ-8550~
                } else if (modelElement instanceof MetadataTable) {
                    imgName = ImageLib.TABLE;
                }
                if (imgName != null) {
                    modelElementImage = ImageLib.getImage(imgName);
                }
                // add lock icon on the image
                if (modelElementImage != null) {
                    if (modelElement != null) {
                        Property property = PropertyHelper.getProperty(modelElement);
                        if (property != null) {
                            Item item = property.getItem();
                            if (item != null) {
                                if (ProxyRepositoryManager.getInstance().isLockByUserOwn(item)) {
                                    modelElementImage = ImageLib.createLockedByOwnIcon(imgName);
                                } else if (ProxyRepositoryManager.getInstance().isLockByOthers(item)) {
                                    modelElementImage = ImageLib.createLockedByOtherIcon(imgName);
                                }
                            }
                        }
                    }
                    return modelElementImage;
                }
                return super.getImage(obj);
            }
        };
    }
    return labelProvider;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) IFile(org.eclipse.core.resources.IFile) ImpactNode(org.talend.dataprofiler.core.ui.dialog.message.DeleteModelElementConfirmDialog.ImpactNode) TdReport(org.talend.dataquality.reports.TdReport) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) Image(org.eclipse.swt.graphics.Image) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) DQRule(org.talend.dataquality.rules.DQRule) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Item(org.talend.core.model.properties.Item) Analysis(org.talend.dataquality.analysis.Analysis) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) Property(org.talend.core.model.properties.Property) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Aggregations

DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)211 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)66 Connection (org.talend.core.model.metadata.builder.connection.Connection)53 ConnectionItem (org.talend.core.model.properties.ConnectionItem)42 ArrayList (java.util.ArrayList)41 PersistenceException (org.talend.commons.exception.PersistenceException)41 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)39 Test (org.junit.Test)33 IMetadataConnection (org.talend.core.model.metadata.IMetadataConnection)30 Property (org.talend.core.model.properties.Property)30 Item (org.talend.core.model.properties.Item)26 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)20 IElementParameter (org.talend.core.model.process.IElementParameter)19 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)18 RepositoryNode (org.talend.repository.model.RepositoryNode)18 SQLException (java.sql.SQLException)17 TdTable (org.talend.cwm.relational.TdTable)17 Catalog (orgomg.cwm.resource.relational.Catalog)17 List (java.util.List)15 ReturnCode (org.talend.utils.sugars.ReturnCode)14