Search in sources :

Example 1 with DataManager

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

the class MatchAnalysisDetailsPage method registerEvents.

private void registerEvents(Composite dataSampleComposite) {
    // register: refresh the result page after running it from menu
    afterCreateConnectionReceiver = new EventReceiver() {

        @Override
        public boolean handle(Object data) {
            // check if the connection is unavailable, give a warning dialog to user without opening the columns
            // select dialog
            DataManager dataManager = (DataManager) data;
            if (ConnectionUtils.checkConnection(dataManager, getAnalysisHandler().getAnalysis().getName())) {
                // need to give the new connection to the dialog to show only this new one in the dialog.
                openColumnsSelectionDialog(dataManager);
                // reset the select key buttons status
                resetSelectKeyButton();
            }
            return true;
        }
    };
    EventManager.getInstance().register(dataSampleComposite, EventEnum.DQ_SELECT_ELEMENT_AFTER_CREATE_CONNECTION, afterCreateConnectionReceiver);
    // register: refresh the data sample table to display the running result(with GID, SCORE, ...)
    refreshTableDataReceiver = new EventReceiver() {

        @Override
        public boolean handle(final Object data) {
            Display.getDefault().asyncExec(new Runnable() {

                @SuppressWarnings("unchecked")
                public void run() {
                    refreshTable((List<Object[]>) data);
                }
            });
            return true;
        }
    };
    EventManager.getInstance().register(analysisHandler.getAnalysis(), EventEnum.DQ_MATCH_ANALYSIS_REFRESH_WITH_RESULT, refreshTableDataReceiver);
}
Also used : MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) EventReceiver(org.talend.dataprofiler.core.ui.events.EventReceiver)

Example 2 with DataManager

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

the class OverviewResultPage method refreshSumSection.

/**
 * DOC qzhang Comment method "refreshSumSection".
 *
 * @param summarySection
 */
private void refreshSumSection() {
    fillDataProvider();
    if (getTdDataProvider() == null) {
        return;
    }
    if (sumSectionClient != null && !sumSectionClient.isDisposed()) {
        Control[] children = sumSectionClient.getChildren();
        for (Control control : children) {
            control.dispose();
        }
    }
    Composite leftComp = new Composite(sumSectionClient, SWT.NONE);
    leftComp.setLayout(new GridLayout(2, false));
    GridData subCompData = new GridData(GridData.FILL_HORIZONTAL);
    subCompData.verticalAlignment = GridData.BEGINNING;
    leftComp.setLayoutData(subCompData);
    Composite rightComp = new Composite(sumSectionClient, SWT.NONE);
    rightComp.setLayout(new GridLayout(2, false));
    rightComp.setLayoutData(subCompData);
    String connectionStr = JavaSqlFactory.getURL(getTdDataProvider());
    Properties pameterProperties = SupportDBUrlStore.getInstance().getDBPameterProperties(connectionStr);
    // $NON-NLS-1$
    toolkit.createLabel(leftComp, DefaultMessagesImpl.getString("ConnectionMasterDetailsPage.DBMS"));
    // MOD TDQ-8539, find the db type from the connection, not from the properties file
    toolkit.createLabel(leftComp, getDatabaseType(pameterProperties));
    String serverName = JavaSqlFactory.getServerName(getTdDataProvider());
    // $NON-NLS-1$
    toolkit.createLabel(leftComp, DefaultMessagesImpl.getString("ConnectionMasterDetailsPage.server"));
    toolkit.createLabel(leftComp, serverName == null ? PluginConstant.EMPTY_STRING : serverName);
    String port = JavaSqlFactory.getPort(getTdDataProvider());
    // $NON-NLS-1$
    toolkit.createLabel(leftComp, DefaultMessagesImpl.getString("ConnectionMasterDetailsPage.port"));
    toolkit.createLabel(leftComp, port == null ? PluginConstant.EMPTY_STRING : port);
    String username = JavaSqlFactory.getUsername(getTdDataProvider());
    // $NON-NLS-1$
    toolkit.createLabel(leftComp, DefaultMessagesImpl.getString("ConnectionMasterDetailsPage.connectAs"));
    toolkit.createLabel(leftComp, username);
    List<Catalog> tdCatalogs = getCatalogs();
    // TDQ-6735 get the correct numbers of schema.
    // MOD TDQ-8539 , get the schemas size
    int schemaSize = masterPage.getSchamas(tdCatalogs);
    toolkit.createLabel(leftComp, // $NON-NLS-1$
    DefaultMessagesImpl.getString("ConnectionMasterDetailsPage.catalogs", PluginConstant.EMPTY_STRING));
    toolkit.createLabel(leftComp, PluginConstant.EMPTY_STRING + tdCatalogs.size());
    toolkit.createLabel(leftComp, // $NON-NLS-1$
    DefaultMessagesImpl.getString("ConnectionMasterDetailsPage.schemata", PluginConstant.EMPTY_STRING));
    toolkit.createLabel(leftComp, PluginConstant.EMPTY_STRING + schemaSize);
    ExecutionInformations resultMetadata = masterPage.getCurrentModelElement().getResults().getResultMetadata();
    toolkit.createLabel(rightComp, // $NON-NLS-1$
    DefaultMessagesImpl.getString("ConnectionMasterDetailsPage.createionDate", PluginConstant.EMPTY_STRING));
    toolkit.createLabel(rightComp, getFormatDateStr(masterPage.getCurrentModelElement().getCreationDate()));
    toolkit.createLabel(rightComp, // $NON-NLS-1$
    DefaultMessagesImpl.getString("AbstractAnalysisResultPage.executionDate", PluginConstant.EMPTY_STRING));
    toolkit.createLabel(rightComp, getFormatDateStr(resultMetadata.getExecutionDate()));
    toolkit.createLabel(rightComp, // $NON-NLS-1$
    DefaultMessagesImpl.getString("AbstractAnalysisResultPage.executionDuration", PluginConstant.EMPTY_STRING));
    // $NON-NLS-1$
    toolkit.createLabel(rightComp, PluginConstant.EMPTY_STRING + resultMetadata.getExecutionDuration() / 1000.0d + "s");
    String executeStatus = (resultMetadata.isLastRunOk() ? DefaultMessagesImpl.getString("ConnectionMasterDetailsPage.success") : // $NON-NLS-1$ //$NON-NLS-2$
    DefaultMessagesImpl.getString("ConnectionMasterDetailsPage.failure", resultMetadata.getMessage()));
    Label rightLabel = toolkit.createLabel(rightComp, // $NON-NLS-1$
    DefaultMessagesImpl.getString("AbstractAnalysisResultPage.executionStatus"));
    int executionNumber = resultMetadata.getExecutionNumber();
    if (!resultMetadata.isLastRunOk() && executionNumber != 0) {
        rightLabel.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
    }
    rightLabel = toolkit.createLabel(rightComp, executionNumber == 0 ? PluginConstant.EMPTY_STRING : executeStatus);
    toolkit.createLabel(rightComp, // $NON-NLS-1$
    DefaultMessagesImpl.getString("AbstractAnalysisResultPage.numberOfExecution", PluginConstant.EMPTY_STRING));
    toolkit.createLabel(rightComp, PluginConstant.EMPTY_STRING + executionNumber);
    toolkit.createLabel(rightComp, // $NON-NLS-1$
    DefaultMessagesImpl.getString("AbstractAnalysisResultPage.lastSucessfulExecution", PluginConstant.EMPTY_STRING));
    toolkit.createLabel(rightComp, PluginConstant.EMPTY_STRING + resultMetadata.getLastExecutionNumberOk());
    // MOD qiongli 2011-5-16
    DataManager connection = masterPage.getCurrentModelElement().getContext().getConnection();
    if (connection != null) {
        RepositoryNode connNode = RepositoryNodeHelper.recursiveFind(connection);
        if (connNode != null && connNode.getObject().isDeleted()) {
            Label leftLabel = toolkit.createLabel(leftComp, // $NON-NLS-1$
            DefaultMessagesImpl.getString("AbstractPagePart.LogicalDeleteWarn", connNode.getLabel()));
            leftLabel.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
            toolkit.createLabel(rightComp, PluginConstant.EMPTY_STRING);
            toolkit.createLabel(rightComp, PluginConstant.EMPTY_STRING);
        }
    }
    sumSectionClient.layout();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) Properties(java.util.Properties) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Catalog(orgomg.cwm.resource.relational.Catalog) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) GridData(org.eclipse.swt.layout.GridData)

Example 3 with DataManager

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

the class AbstractAnalysisMetadataPage method getConnectionVersion.

/**
 * get the database's version of the Analysis.
 *
 * @return
 */
public String getConnectionVersion() {
    String version = null;
    if (getCurrentModelElement() != null) {
        DataManager dm = getCurrentModelElement().getContext().getConnection();
        if (dm != null) {
            if (dm instanceof Connection) {
                Connection connection = (Connection) dm;
                version = connection.getVersion();
                if (version == null) {
                    version = initConnectionVersion(connection);
                }
            }
        }
    }
    return version == null ? getConnectionVersionDefault() : version;
}
Also used : Connection(org.talend.core.model.metadata.builder.connection.Connection) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager)

Example 4 with DataManager

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

the class DataExplorerTestHelper method getAnalysis.

public static Analysis getAnalysis(Indicator indicator, DbmsLanguage dbmsLanguage) {
    Analysis analysis = mock(Analysis.class);
    AnalysisContext context = mock(AnalysisContext.class);
    when(analysis.getContext()).thenReturn(context);
    DataManager dataManager = mock(DataManager.class);
    when(context.getConnection()).thenReturn(dataManager);
    // mock setEntity
    when(indicator.eClass()).thenReturn(null);
    // MOCKING STATIC METHODS
    stub(method(DbmsLanguageFactory.class, "createDbmsLanguage", DataManager.class, ExecutionLanguage.class)).toReturn(dbmsLanguage);
    return analysis;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext)

Example 5 with DataManager

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

the class SummaryStastictisExplorerRealTest method testGetQueryMap.

/**
 * Test method for {@link org.talend.dq.analysis.explore.SummaryStastictisExplorer#getQueryMap()}.
 */
@Test
public void testGetQueryMap() {
    // testing code for SQL Engine here
    SummaryStastictisExplorer summaryExplorerSql = new SummaryStastictisExplorer();
    Analysis analysisReal = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisParameters analysisParametersReal = AnalysisFactory.eINSTANCE.createAnalysisParameters();
    analysisParametersReal.setExecutionLanguage(ExecutionLanguage.SQL);
    analysisReal.setParameters(analysisParametersReal);
    AnalysisContext analysisContextReal = AnalysisFactory.eINSTANCE.createAnalysisContext();
    DataManager dataManagerReal = SoftwaredeploymentFactory.eINSTANCE.createDataManager();
    analysisContextReal.setConnection(dataManagerReal);
    analysisReal.setContext(analysisContextReal);
    summaryExplorerSql.setAnalysis(analysisReal);
    TdColumn tdColumnReal = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdColumn();
    TdTable tdTableReal = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    tdTableReal.setName("tableName");
    tdColumnReal.setOwner(tdTableReal);
    // $NON-NLS-1$
    tdColumnReal.setName("id");
    TdSqlDataType tdsqlReal = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdSqlDataType();
    // $NON-NLS-1$
    tdsqlReal.setName("Integer");
    tdColumnReal.setSqlDataType(tdsqlReal);
    // test for MeanIndicator
    MeanIndicator meanIndicator = IndicatorsFactory.eINSTANCE.createMeanIndicator();
    meanIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition meanIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    meanIndicatorDef.setName("Mean");
    meanIndicator.setIndicatorDefinition(meanIndicatorDef);
    ChartDataEntity entityReal = new ChartDataEntity();
    // $NON-NLS-1$
    entityReal.setValue("0");
    entityReal.setIndicator(meanIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    Map<String, String> queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for MedianIndicator
    MedianIndicator medianIndicator = IndicatorsFactory.eINSTANCE.createMedianIndicator();
    medianIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition medianIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    medianIndicatorDef.setName("Median");
    medianIndicator.setIndicatorDefinition(medianIndicatorDef);
    entityReal.setIndicator(medianIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 1);
    // test for IQRIndicator
    MaxValueIndicator maxValueIndicator = IndicatorsFactory.eINSTANCE.createMaxValueIndicator();
    // $NON-NLS-1$
    maxValueIndicator.setValue("80");
    IndicatorDefinition maxValueIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    maxValueIndicatorDef.setName("Maximum");
    maxValueIndicator.setIndicatorDefinition(maxValueIndicatorDef);
    MinValueIndicator minValueIndicator = IndicatorsFactory.eINSTANCE.createMinValueIndicator();
    // $NON-NLS-1$
    minValueIndicator.setValue("20");
    IndicatorDefinition minValueIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    minValueIndicatorDef.setName("Minimum");
    minValueIndicator.setIndicatorDefinition(minValueIndicatorDef);
    IQRIndicator iqrIndicator = IndicatorsFactory.eINSTANCE.createIQRIndicator();
    iqrIndicator.setUpperValue(maxValueIndicator);
    iqrIndicator.setLowerValue(minValueIndicator);
    iqrIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition iqrIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    iqrIndicatorDef.setName("Inter Quartile Range");
    iqrIndicator.setIndicatorDefinition(iqrIndicatorDef);
    entityReal.setIndicator(iqrIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 2);
    // test for LowerQuartileIndicator
    LowerQuartileIndicator lowerQuartileIndicator = IndicatorsFactory.eINSTANCE.createLowerQuartileIndicator();
    lowerQuartileIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition lowerQuartileIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    lowerQuartileIndicatorDef.setName("Lower Quartile");
    lowerQuartileIndicator.setIndicatorDefinition(lowerQuartileIndicatorDef);
    entityReal.setIndicator(lowerQuartileIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 1);
    // test for UpperQuartileIndicator
    UpperQuartileIndicator upperQuartileIndicator = IndicatorsFactory.eINSTANCE.createUpperQuartileIndicator();
    upperQuartileIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition upperQuartileIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    upperQuartileIndicatorDef.setName("Upper Quartile");
    upperQuartileIndicator.setIndicatorDefinition(upperQuartileIndicatorDef);
    entityReal.setIndicator(upperQuartileIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 1);
    // test for RangeIndicator
    RangeIndicator rangeIndicator = IndicatorsFactory.eINSTANCE.createRangeIndicator();
    rangeIndicator.setUpperValue(maxValueIndicator);
    rangeIndicator.setLowerValue(minValueIndicator);
    rangeIndicator.setAnalyzedElement(tdColumnReal);
    IndicatorDefinition rangeIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    rangeIndicatorDef.setName("Range");
    rangeIndicator.setIndicatorDefinition(rangeIndicatorDef);
    entityReal.setIndicator(rangeIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 2);
    // test for MinValueIndicator
    minValueIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(minValueIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 1);
    // test for MaxValueIndicator
    maxValueIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(maxValueIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.size() == 1);
    // testing code for Java Engine here
    analysisParametersReal.setExecutionLanguage(ExecutionLanguage.JAVA);
    analysisReal.setParameters(analysisParametersReal);
    summaryExplorerSql.setAnalysis(analysisReal);
    // test for MeanIndicator
    meanIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(meanIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for MedianIndicator
    medianIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(medianIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for IQRIndicator
    iqrIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(iqrIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for LowerQuartileIndicator
    lowerQuartileIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(lowerQuartileIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for UpperQuartileIndicator
    upperQuartileIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(upperQuartileIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for RangeIndicator
    rangeIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(rangeIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for MinValueIndicator
    minValueIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(minValueIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
    // test for MaxValueIndicator
    maxValueIndicator.setAnalyzedElement(tdColumnReal);
    entityReal.setIndicator(maxValueIndicator);
    summaryExplorerSql.setEnitty(entityReal);
    queryMap = summaryExplorerSql.getQueryMap();
    Assert.assertTrue(queryMap.isEmpty());
}
Also used : TdTable(org.talend.cwm.relational.TdTable) MedianIndicator(org.talend.dataquality.indicators.MedianIndicator) IQRIndicator(org.talend.dataquality.indicators.IQRIndicator) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) TdSqlDataType(org.talend.cwm.relational.TdSqlDataType) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) MaxValueIndicator(org.talend.dataquality.indicators.MaxValueIndicator) TdColumn(org.talend.cwm.relational.TdColumn) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) RangeIndicator(org.talend.dataquality.indicators.RangeIndicator) LowerQuartileIndicator(org.talend.dataquality.indicators.LowerQuartileIndicator) UpperQuartileIndicator(org.talend.dataquality.indicators.UpperQuartileIndicator) MeanIndicator(org.talend.dataquality.indicators.MeanIndicator) MinValueIndicator(org.talend.dataquality.indicators.MinValueIndicator) Test(org.junit.Test)

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