Search in sources :

Example 1 with ExecutionInformations

use of org.talend.dataquality.analysis.ExecutionInformations 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 2 with ExecutionInformations

use of org.talend.dataquality.analysis.ExecutionInformations in project tdq-studio-se by Talend.

the class ExecutionInformationsItemProvider method getText.

/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public String getText(Object object) {
    Date labelValue = ((ExecutionInformations) object).getExecutionDate();
    String label = labelValue == null ? null : labelValue.toString();
    return label == null || label.length() == 0 ? getString("_UI_ExecutionInformations_type") : getString("_UI_ExecutionInformations_type") + " " + label;
}
Also used : ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) Date(java.util.Date)

Example 3 with ExecutionInformations

use of org.talend.dataquality.analysis.ExecutionInformations in project tdq-studio-se by Talend.

the class AnalysisHandlerTest method testChangeDefaultRowLoaded.

/**
 * Test method for {@link org.talend.dq.analysis.AnalysisHandler#changeDefaultRowLoaded(java.lang.String)}.
 */
@Test
public void testChangeDefaultRowLoaded() {
    int rowCountValue = 100;
    Analysis createAna = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    createAna.setResults(createAnalysisResult);
    ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
    createAnalysisResult.setResultMetadata(createExecutionInformations);
    AnalysisHandler createHandler = AnalysisHandler.createHandler(createAna);
    createHandler.changeDefaultRowLoaded(String.valueOf(rowCountValue));
    String defaultLoadedRowCount = createHandler.getDefaultLoadedRowCount();
    Assert.assertEquals(Integer.valueOf(rowCountValue), Integer.valueOf(defaultLoadedRowCount));
}
Also used : ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Test(org.junit.Test)

Example 4 with ExecutionInformations

use of org.talend.dataquality.analysis.ExecutionInformations in project tdq-studio-se by Talend.

the class ColumnAnalysisExecutorTest method testCreateSqlStatement_1.

/**
 * when there are some catelog
 * {@link org.talend.dq.analysis.ColumnAnalysisExecutor#createSqlStatement(org.talend.dataquality.analysis.Analysis)}
 * .
 */
@Test
public void testCreateSqlStatement_1() {
    Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisContext context = AnalysisFactory.eINSTANCE.createAnalysisContext();
    analysis.setContext(context);
    TdColumn tdColumn = RelationalFactory.eINSTANCE.createTdColumn();
    TdTable tdTable = RelationalFactory.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    tdTable.setName("tableName");
    tdColumn.setOwner(tdTable);
    // $NON-NLS-1$
    tdColumn.setName("columnName");
    AnalysisParameters analysisPara = AnalysisFactory.eINSTANCE.createAnalysisParameters();
    analysisPara.setStoreData(false);
    analysis.setParameters(analysisPara);
    context.getAnalysedElements().add(tdColumn);
    AnalysisResult analysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    ExecutionInformations info = AnalysisFactory.eINSTANCE.createExecutionInformations();
    analysisResult.setResultMetadata(info);
    analysis.setResults(analysisResult);
    // mock(Catalog.class);
    Package catalog = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
    // $NON-NLS-1$
    catalog.setName("catalogName");
    tdTable.setNamespace(catalog);
    DatabaseConnection createConnection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
    createConnection.getTaggedValue().add(TaggedValueHelper.createTaggedValue(TaggedValueHelper.DB_PRODUCT_NAME, SupportDBUrlType.MYSQLDEFAULTURL.getLanguage()));
    analysis.getContext().setConnection(createConnection);
    ColumnAnalysisExecutor columnAnalysisExecutor = new ColumnAnalysisExecutor();
    // $NON-NLS-1$
    assertEquals("SELECT `columnName` FROM `catalogName`.`tableName`", columnAnalysisExecutor.createSqlStatement(analysis));
}
Also used : ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) TdColumn(org.talend.cwm.relational.TdColumn) TdTable(org.talend.cwm.relational.TdTable) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Package(orgomg.cwm.objectmodel.core.Package) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Test(org.junit.Test)

Example 5 with ExecutionInformations

use of org.talend.dataquality.analysis.ExecutionInformations in project tdq-studio-se by Talend.

the class ColumnAnalysisExecutorTest method testCreateSqlStatement_2.

/**
 * when there are some schema.
 * {@link org.talend.dq.analysis.ColumnAnalysisExecutor#createSqlStatement(org.talend.dataquality.analysis.Analysis)}
 * .
 */
@Test
public void testCreateSqlStatement_2() {
    Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisContext context = AnalysisFactory.eINSTANCE.createAnalysisContext();
    analysis.setContext(context);
    TdColumn tdColumn = RelationalFactory.eINSTANCE.createTdColumn();
    TdTable tdTable = RelationalFactory.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    tdTable.setName("tableName");
    tdColumn.setOwner(tdTable);
    // $NON-NLS-1$
    tdColumn.setName("columnName");
    AnalysisParameters analysisPara = AnalysisFactory.eINSTANCE.createAnalysisParameters();
    analysisPara.setStoreData(false);
    analysis.setParameters(analysisPara);
    context.getAnalysedElements().add(tdColumn);
    AnalysisResult analysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    ExecutionInformations info = AnalysisFactory.eINSTANCE.createExecutionInformations();
    analysisResult.setResultMetadata(info);
    analysis.setResults(analysisResult);
    // mock(Schema.class);
    Package schema = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createSchema();
    // $NON-NLS-1$
    schema.setName("schemaName");
    tdTable.setNamespace(schema);
    // mock(Catalog.class);
    Package catalog = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
    // $NON-NLS-1$
    catalog.setName("catalogName");
    schema.setNamespace(catalog);
    DatabaseConnection createConnection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
    createConnection.getTaggedValue().add(TaggedValueHelper.createTaggedValue(TaggedValueHelper.DB_PRODUCT_NAME, SupportDBUrlType.MSSQLDEFAULTURL.getLanguage()));
    analysis.getContext().setConnection(createConnection);
    ColumnAnalysisExecutor columnAnalysisExecutor = new ColumnAnalysisExecutor();
    assertEquals("SELECT columnName FROM catalogName.schemaName.tableName", // $NON-NLS-1$
    columnAnalysisExecutor.createSqlStatement(analysis));
}
Also used : ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) TdColumn(org.talend.cwm.relational.TdColumn) TdTable(org.talend.cwm.relational.TdTable) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Package(orgomg.cwm.objectmodel.core.Package) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Test(org.junit.Test)

Aggregations

ExecutionInformations (org.talend.dataquality.analysis.ExecutionInformations)23 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)13 Analysis (org.talend.dataquality.analysis.Analysis)11 Test (org.junit.Test)6 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)6 Date (java.util.Date)5 TdColumn (org.talend.cwm.relational.TdColumn)5 TdTable (org.talend.cwm.relational.TdTable)5 AnalysisParameters (org.talend.dataquality.analysis.AnalysisParameters)5 TdExpression (org.talend.cwm.relational.TdExpression)4 Before (org.junit.Before)3 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)3 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)3 ReturnCode (org.talend.utils.sugars.ReturnCode)3 Package (orgomg.cwm.objectmodel.core.Package)3 SQLException (java.sql.SQLException)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 TdSqlDataType (org.talend.cwm.relational.TdSqlDataType)2