Search in sources :

Example 21 with DataManager

use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.

the class AbstractAnalysisMetadataPage method getCurrentConnectionRepNode.

protected IRepositoryNode getCurrentConnectionRepNode() {
    // MOD klliu 2010-12-10
    IEditorInput editorInput = getEditor().getEditorInput();
    if (editorInput instanceof AnalysisItemEditorInput) {
        AnalysisItemEditorInput fileEditorInput = (AnalysisItemEditorInput) editorInput;
        return fileEditorInput.getConnectionNode();
    } else {
        // ADD TDQ-9613 msjian: when the user do something from the other views for example: from task view
        FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
        Analysis findAnalysis = AnaResourceFileHelper.getInstance().findAnalysis(fileEditorInput.getFile());
        DataManager connection = findAnalysis.getContext().getConnection();
        if (connection != null) {
            return RepositoryNodeHelper.recursiveFind(connection);
        }
    // TDQ-9613~
    }
    return null;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) FileEditorInput(org.eclipse.ui.part.FileEditorInput) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) IEditorInput(org.eclipse.ui.IEditorInput)

Example 22 with DataManager

use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.

the class DQRepositoryViewLabelProvider method addWarnIconIfNeeded.

/**
 * if it is needed,add a over warning icon..eg., it is empty analysis or report; imported a MDM analysis or report.
 *
 * @param image
 * @param node
 * @param originalImageName
 * @return
 */
private Image addWarnIconIfNeeded(IRepositoryNode node, String originalImageName) {
    ModelElement modEle = RepositoryNodeHelper.getResourceModelElement(node);
    ERepositoryObjectType objectType = node.getObjectType();
    if (modEle != null) {
        if (ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT == objectType) {
            Analysis analysis = (Analysis) modEle;
            AnalysisContext context = analysis.getContext();
            if (context == null) {
                return ImageLib.createInvalidIcon(originalImageName);
            }
            EList<ModelElement> analysedElements = context.getAnalysedElements();
            DataManager connection = context.getConnection();
            if (analysedElements.isEmpty() || connection instanceof MDMConnection) {
                return ImageLib.createInvalidIcon(originalImageName);
            }
        } else if (ERepositoryObjectType.TDQ_REPORT_ELEMENT == objectType) {
            TdReport report = (TdReport) modEle;
            EList<AnalysisMap> analysisMap = report.getAnalysisMap();
            if (analysisMap.isEmpty()) {
                return ImageLib.createInvalidIcon(originalImageName);
            }
            for (AnalysisMap anaMap : report.getAnalysisMap()) {
                Analysis analysis = anaMap.getAnalysis();
                if (analysis == null || analysis.getContext() == null) {
                    continue;
                }
                DataManager connection = analysis.getContext().getConnection();
                if (connection instanceof MDMConnection) {
                    return ImageLib.createInvalidIcon(originalImageName);
                }
            }
        }
    }
    return ImageLib.getImage(originalImageName);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) EList(org.eclipse.emf.common.util.EList) Analysis(org.talend.dataquality.analysis.Analysis) TdReport(org.talend.dataquality.reports.TdReport) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection)

Example 23 with DataManager

use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.

the class ColumnCorrelationAnalysisHandler method addIndicator.

/**
 * The resources that are connected to this analysis and that are potentially modified.
 */
// private Collection<Resource> modifiedResources = new HashSet<Resource>();
/**
 * Method "addColumnToAnalyze".
 *
 * @param column
 * @return
 */
public boolean addIndicator(List<TdColumn> columns, Indicator indicator) {
    for (ModelElement tdColumn : columns) {
        if (!analysis.getContext().getAnalysedElements().contains(tdColumn)) {
            analysis.getContext().getAnalysedElements().add(tdColumn);
        }
    }
    // store first level of indicators in result.
    analysis.getResults().getIndicators().add(indicator);
    initializeIndicator(indicator, columns);
    DataManager connection = analysis.getContext().getConnection();
    if (connection == null) {
        // try to get one
        for (ModelElement element : columns) {
            TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
            // $NON-NLS-1$
            log.error(Messages.getString("ColumnCorrelationAnalysisHandler.CONNNOTBEENSETINANALYSIS"));
            connection = ConnectionHelper.getTdDataProvider(tdColumn);
            if (connection != null) {
                analysis.getContext().setConnection(connection);
            }
        }
    }
    TypedReturnCode<Dependency> rc = DependenciesHandler.getInstance().setDependencyOn(analysis, connection);
    return rc.isOk();
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) Dependency(orgomg.cwm.objectmodel.core.Dependency)

Example 24 with DataManager

use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.

the class TableAnalysisHandler method addIndicator.

public boolean addIndicator(NamedColumnSet set, Indicator... indicators) {
    if (!analysis.getContext().getAnalysedElements().contains(set)) {
        analysis.getContext().getAnalysedElements().add(set);
    }
    for (Indicator indicator : indicators) {
        // store first level of indicators in result.
        analysis.getResults().getIndicators().add(indicator);
        initializeIndicator(indicator, set);
    }
    DataManager connection = analysis.getContext().getConnection();
    if (connection == null) {
        // try to get one
        // $NON-NLS-1$
        log.error(Messages.getString("ColumnCorrelationAnalysisHandler.CONNNOTBEENSETINANALYSIS"));
        connection = ConnectionHelper.getTdDataProvider(PackageHelper.getParentPackage((MetadataTable) set));
        analysis.getContext().setConnection(connection);
    }
    TypedReturnCode<Dependency> rc = DependenciesHandler.getInstance().setDependencyOn(analysis, connection);
    return rc.isOk();
}
Also used : DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) Dependency(orgomg.cwm.objectmodel.core.Dependency) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator)

Example 25 with DataManager

use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.

the class TdqAnalysisConnectionPool method newConnection.

/**
 * DOC xqliu Comment method "newConnection".
 *
 * @return
 */
private Connection newConnection() {
    Connection conn = null;
    if (isFull()) {
        return conn;
    }
    DataManager datamanager = analysis.getContext().getConnection();
    if (datamanager == null) {
        // $NON-NLS-1$
        log.error(Messages.getString("AnalysisExecutor.DataManagerNull", analysis.getName()));
        return null;
    }
    if (datamanager != null && datamanager.eIsProxy()) {
        datamanager = (DataManager) EObjectHelper.resolveObject(datamanager);
    }
    org.talend.core.model.metadata.builder.connection.Connection dataprovider = SwitchHelpers.CONNECTION_SWITCH.doSwitch(datamanager);
    TypedReturnCode<Connection> trcConn = null;
    IMetadataConnection metadataConnection = ConvertionHelper.convert(dataprovider);
    if (metadataConnection != null && EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(metadataConnection.getDbType())) {
        trcConn = new TypedReturnCode<Connection>(false);
        try {
            HiveConnectionHandler hiveConnHandler = HiveConnectionManager.getInstance().createHandler(metadataConnection);
            Connection hiveConnection = hiveConnHandler.createHiveConnection();
            if (hiveConnection != null) {
                trcConn.setOk(true);
                trcConn.setObject(hiveConnection);
            }
        } catch (ClassNotFoundException e) {
            trcConn.setOk(false);
            log.error(e);
        } catch (InstantiationException e) {
            trcConn.setOk(false);
            log.error(e);
        } catch (IllegalAccessException e) {
            trcConn.setOk(false);
            log.error(e);
        } catch (SQLException e) {
            trcConn.setOk(false);
            log.error(e);
        }
    } else {
        trcConn = JavaSqlFactory.createConnection(dataprovider);
    }
    if (trcConn != null && trcConn.isOk()) {
        conn = trcConn.getObject();
        synchronized (this.synchronizedFlag) {
            this.getPConnections().add(new PooledTdqAnalysisConnection(conn));
        }
    }
    if (conn != null) {
        try {
            if (metadataConnection != null && EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(metadataConnection.getDbType())) {
            // don't set the max connection number if it is hive connection
            } else {
                DatabaseMetaData metaData = conn.getMetaData();
                int currentDriverMaxConnections = new Float(metaData.getMaxConnections() * DEFAULT_CONNECTION_NUMBER_OFFSET).intValue();
                synchronized (this.synchronizedFlag) {
                    this.setDriverMaxConnections(currentDriverMaxConnections);
                }
            }
        } catch (SQLException e) {
            log.debug(e, e);
        }
    }
    return conn;
}
Also used : HiveConnectionHandler(org.talend.metadata.managment.hive.handler.HiveConnectionHandler) SQLException(java.sql.SQLException) Connection(java.sql.Connection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) DatabaseMetaData(java.sql.DatabaseMetaData)

Aggregations

DataManager (orgomg.cwm.foundation.softwaredeployment.DataManager)37 Analysis (org.talend.dataquality.analysis.Analysis)8 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)7 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 ArrayList (java.util.ArrayList)5 Connection (org.talend.core.model.metadata.builder.connection.Connection)5 TdColumn (org.talend.cwm.relational.TdColumn)4 Indicator (org.talend.dataquality.indicators.Indicator)4 RepositoryNode (org.talend.repository.model.RepositoryNode)4 Dependency (orgomg.cwm.objectmodel.core.Dependency)4 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)4 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)3 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)3 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)3 SQLException (java.sql.SQLException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 EList (org.eclipse.emf.common.util.EList)2 EObject (org.eclipse.emf.ecore.EObject)2