Search in sources :

Example 81 with ReturnCode

use of org.talend.utils.sugars.ReturnCode 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 82 with ReturnCode

use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.

the class BlockingKeySection method refreshChart.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchTableSection#RefreshChart()
     */
@Override
public void refreshChart() {
    if (getBlockKeyDefinitionList().size() <= 0) {
        MessageDialogWithToggle.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("BlockingKeySection.RefreshChartError"), // $NON-NLS-1$ //$NON-NLS-2$
        DefaultMessagesImpl.getString("BlockingKeySection.NoBlockKey"));
        return;
    }
    ReturnCode checkResultStatus = checkResultStatus();
    if (!checkResultStatus.isOk()) {
        if (checkResultStatus.getMessage() != null && !checkResultStatus.getMessage().equals(StringUtils.EMPTY)) {
            MessageDialogWithToggle.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("BlockingKeySection.RefreshChartError"), // $NON-NLS-1$
            checkResultStatus.getMessage());
        }
        return;
    }
    listeners.firePropertyChange(MatchAnalysisConstant.NEED_REFRESH_DATA, true, false);
    BlockingKeyHandler executeGenerateBlockingAction = computeResult();
    if (executeGenerateBlockingAction.getResultDataList().size() == 0) {
        return;
    }
    blockingKeyDataChart.refresh(executeGenerateBlockingAction.getResultDatas());
    MatchRuleAnlaysisUtils.refreshDataTable(analysis, executeGenerateBlockingAction.getResultDataList());
    executeGenerateBlockingAction.getResultDatas().clear();
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) BlockingKeyHandler(org.talend.dataquality.record.linkage.genkey.BlockingKeyHandler)

Example 83 with ReturnCode

use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.

the class MatchingKeySection method refreshChart.

public void refreshChart(boolean needCompute) {
    if (!hasMatchKey(true)) {
        MessageDialogWithToggle.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("BlockingKeySection.RefreshChartError"), // $NON-NLS-1$ //$NON-NLS-2$
        DefaultMessagesImpl.getString("MatchMasterDetailsPage.NoMatchKey"));
        return;
    }
    ReturnCode checkResultStatus = checkResultStatus();
    if (!checkResultStatus.isOk()) {
        MessageDialogWithToggle.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("BlockingKeySection.RefreshChartError"), // $NON-NLS-1$
        checkResultStatus.getMessage());
        return;
    }
    listeners.firePropertyChange(MatchAnalysisConstant.NEED_REFRESH_DATA, true, false);
    List<Object[]> results;
    // MOD TDQ-9741: "chart" button will compute, "hide group" will not compute
    if (needCompute) {
        TypedReturnCode<RecordMatchingIndicator> computeMatchResult = computeMatchResult();
        if (!computeMatchResult.isOk()) {
            if (computeMatchResult.getMessage() != null && !computeMatchResult.getMessage().equals(StringUtils.EMPTY)) {
                MessageDialogWithToggle.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("RunAnalysisAction.runAnalysis"), // $NON-NLS-1$
                computeMatchResult.getMessage());
            }
            return;
        }
        RecordMatchingIndicator recordMatchingIndicator = computeMatchResult.getObject();
        matchRuleChartComp.refresh(recordMatchingIndicator.getGroupSize2groupFrequency());
        // sort the result before refresh
        results = MatchRuleAnlaysisUtils.sortResultByGID(recordMatchingIndicator.getMatchRowSchema(), this.getTableResult());
    } else {
        // for "hide group" , get the result from the last "chart" directly.
        matchRuleChartComp.refresh(getChartResult());
        results = getTableResult();
    }
    // refresh related table
    MatchRuleAnlaysisUtils.refreshDataTable(analysis, results);
    // Clear the match row data.
    matchRows.clear();
}
Also used : TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)

Example 84 with ReturnCode

use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.

the class DefaultSurvivorshipDefinitionSection method checkResultStatus.

@Override
public ReturnCode checkResultStatus() {
    ReturnCode returnCode = new ReturnCode(true);
    for (DefaultSurvivorshipDefinition dsd : matchRuleDef.getDefaultSurvivorshipDefinitions()) {
        String algorithmType = dsd.getFunction().getAlgorithmType();
        if (!MatchRuleAnlaysisUtils.isSurvivorShipFunctionConsistentWithType(algorithmType, dsd.getDataType())) {
            returnCode.setOk(false);
            String message = DefaultMessagesImpl.getString(// $NON-NLS-1$
            "DefaultSurvivorshipDefinitionSection.survivorshipFunctionNotMatch", // $NON-NLS-1$
            dsd.getDataType(), SurvivorShipAlgorithmEnum.getTypeBySavedValue(algorithmType).getValue());
            returnCode.setMessage(// $NON-NLS-1$
            DefaultMessagesImpl.getString(// $NON-NLS-1$
            "MatchingKeySection.invalidSurvivorshipFunction", getSectionName(), message));
            return returnCode;
        }
    }
    return returnCode;
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) DefaultSurvivorshipDefinition(org.talend.dataquality.rules.DefaultSurvivorshipDefinition)

Example 85 with ReturnCode

use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.

the class DataSampleTable method reDrawTable.

/**
 * Redraw the table by special columns and reload the data if needed
 *
 * @param columns New input columns
 * @param withData where need to reload data with same time
 */
public void reDrawTable(ModelElement[] columns, boolean withData) {
    if (tablePanel != null && !tablePanel.isDisposed()) {
        tablePanel.dispose();
    }
    needLoadData = withData;
    List<Object[]> listOfData = null;
    try {
        listOfData = getPreviewData(columns, withData);
        isDataAvailable = new ReturnCode();
    } catch (SQLException e) {
        isDataAvailable.setMessage(e.getMessage());
        isDataAvailable.setOk(false);
        needLoadData = false;
    }
    createNatTable(listOfData, drawCanvas, columns);
    drawCanvas.setVisible(columns != null && columns.length > 0);
    drawCanvas.layout();
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) SQLException(java.sql.SQLException)

Aggregations

ReturnCode (org.talend.utils.sugars.ReturnCode)175 ArrayList (java.util.ArrayList)42 TypedReturnCode (org.talend.utils.sugars.TypedReturnCode)42 Test (org.junit.Test)29 File (java.io.File)26 Connection (org.talend.core.model.metadata.builder.connection.Connection)26 Indicator (org.talend.dataquality.indicators.Indicator)25 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)20 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)18 Analysis (org.talend.dataquality.analysis.Analysis)18 Property (org.talend.core.model.properties.Property)17 IFile (org.eclipse.core.resources.IFile)16 IRepositoryNode (org.talend.repository.model.IRepositoryNode)16 IFolder (org.eclipse.core.resources.IFolder)15 SQLException (java.sql.SQLException)14 PersistenceException (org.talend.commons.exception.PersistenceException)11 TdColumn (org.talend.cwm.relational.TdColumn)11 IOException (java.io.IOException)10 EObject (org.eclipse.emf.ecore.EObject)10 IMetadataConnection (org.talend.core.model.metadata.IMetadataConnection)10