Search in sources :

Example 26 with ColumnSet

use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.

the class ChangeConnectionAction method reloadByColumnSetFolderLevel.

private void reloadByColumnSetFolderLevel(List<SynTreeModel> treeModelLs, AnalyzedElementSynDialog anaEleSynDialog, Connection newDataProv) throws ReloadCompareException {
    ModelElement oldDataProviderModel = treeModelLs.get(0).getOldDataProvElement();
    // Reload columnSet folder
    ColumnSet columnset = null;
    if (oldDataProviderModel instanceof ColumnSet) {
        columnset = (ColumnSet) oldDataProviderModel;
    } else if (oldDataProviderModel instanceof TdColumn) {
        columnset = ColumnHelper.getColumnOwnerAsColumnSet(oldDataProviderModel);
    } else {
        return;
    }
    // MOD mzhao bug 8567 2010-03-29
    IFolderNode reloadFolder = FolderNodeHelper.getFolderNode((Package) treeModelLs.get(0).getNewDataProvElement(), columnset);
    if (reloadFolder != null) {
        IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(reloadFolder);
        if (creatComparisonLevel != null) {
            // FIXME newDataProv is never used in the following codes.
            newDataProv = creatComparisonLevel.reloadCurrentLevelElement();
        }
        // Recompute after reload
        // FIXME treeModelLs is never used in the following codes.
        treeModelLs = anaEleSynDialog.getSynInputModel();
    }
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IFolderNode(org.talend.dq.nodes.foldernode.IFolderNode) TdColumn(org.talend.cwm.relational.TdColumn) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) IComparisonLevel(org.talend.cwm.compare.factory.IComparisonLevel)

Example 27 with ColumnSet

use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.

the class ChangeConnectionAction method reloadByColumnFolderLevel.

private void reloadByColumnFolderLevel(List<SynTreeModel> treeModelLs, AnalyzedElementSynDialog anaEleSynDialog, Connection newDataProv) throws ReloadCompareException {
    ModelElement newDataProviderModel = treeModelLs.get(0).getNewDataProvElement();
    // If schema or catalog changed, we did not load anymore.
    // Reload column folder
    ColumnSet columnset = null;
    if (newDataProviderModel instanceof ColumnSet) {
        columnset = (ColumnSet) newDataProviderModel;
    } else if (newDataProviderModel instanceof TdColumn) {
        columnset = ColumnHelper.getColumnOwnerAsColumnSet(newDataProviderModel);
    } else {
        return;
    }
    // MOD mzhao bug 8567 2010-03-29
    IFolderNode reloadFolder = FolderNodeHelper.getFolderNodes(columnset)[0];
    if (reloadFolder != null) {
        IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(reloadFolder);
        if (creatComparisonLevel != null) {
            // FIXME newDataProv is never used in the following codes.
            newDataProv = creatComparisonLevel.reloadCurrentLevelElement();
        }
        // Recompute after reload
        // FIXME treeModelLs is never used in the following codes.
        treeModelLs = anaEleSynDialog.getSynInputModel();
    }
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IFolderNode(org.talend.dq.nodes.foldernode.IFolderNode) TdColumn(org.talend.cwm.relational.TdColumn) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) IComparisonLevel(org.talend.cwm.compare.factory.IComparisonLevel)

Example 28 with ColumnSet

use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.

the class ChangeConnectionAction method changedDatabaseConnection.

private ReturnCode changedDatabaseConnection() throws ReloadCompareException {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    final EList<ModelElement> analyzedElements = analysisItem.getAnalysis().getContext() == null ? null : analysisItem.getAnalysis().getContext().getAnalysedElements();
    if (analyzedElements == null || analyzedElements.size() == 0) {
        analysisItem.getAnalysis().getContext().setConnection(newDataProvider);
        return new ReturnCode(Boolean.TRUE);
    }
    // MOD qiongli 2011-1-10,feature 16796.
    if (oldDataProvider instanceof DelimitedFileConnection) {
        // "Can't change this connection!");
        if (!// $NON-NLS-1$
        MessageDialog.openConfirm(// $NON-NLS-1$
        shell, // $NON-NLS-1$
        DefaultMessagesImpl.getString("ChangeConnectionAction.ChangeConnection"), DefaultMessagesImpl.getString("ChangeConnectionAction.ChangeConnectionTips"))) {
            // $NON-NLS-1$
            return new ReturnCode(Boolean.FALSE);
        }
    }
    // Open synchronized dialog.
    boolean retCode = MessageDialog.openQuestion(shell, // $NON-NLS-1$
    DefaultMessagesImpl.getString("ChangeConnectionAction.ChangeConnection"), // $NON-NLS-1$
    DefaultMessagesImpl.getString("ChangeConnectionAction.MayCauseAsynProblem"));
    if (retCode) {
        if (analyzedElements.get(0) instanceof TdColumn) {
            anaEleSynDialog = new AnalyzedColumnsSynDialog(shell, analysisItem.getAnalysis(), newDataProvider, analyzedElements);
        } else if (analyzedElements.get(0) instanceof ColumnSet) {
            anaEleSynDialog = new AnalyzedColumnSetsSynDialog(shell, analysisItem.getAnalysis(), newDataProvider, analyzedElements);
        } else if (analyzedElements.get(0) instanceof Package) {
            anaEleSynDialog = new AnalyzedPackageSynDialog(shell, analysisItem.getAnalysis(), newDataProvider, analyzedElements);
        }
        final List<SynTreeModel> treeModelLs = anaEleSynDialog == null ? null : anaEleSynDialog.getSynInputModel();
        if (treeModelLs != null && treeModelLs.size() > 0) {
            // Make attempt to reload from db before showing asyned
            // message.
            boolean isReload = MessageDialog.openQuestion(shell, // $NON-NLS-1$
            DefaultMessagesImpl.getString("ChangeConnectionAction.ReloadFromDatabase"), // $NON-NLS-1$
            DefaultMessagesImpl.getString("ChangeConnectionAction.ExistElementAsynchronuos"));
            if (isReload) {
                ModelElement newDataProviderModel = treeModelLs.get(0).getNewDataProvElement();
                if (newDataProviderModel != null && (newDataProviderModel instanceof ColumnSet || newDataProviderModel instanceof Package)) {
                    if (newDataProviderModel instanceof Package) {
                        IRunnableWithProgress op = new IRunnableWithProgress() {

                            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                                try {
                                    reloadByColumnSetFolderLevel(treeModelLs, anaEleSynDialog, newDataProvider);
                                    if (analyzedElements.get(0) instanceof TdColumn) {
                                        // Reload column folder
                                        reloadByColumnFolderLevel(treeModelLs, anaEleSynDialog, newDataProvider);
                                    }
                                } catch (ReloadCompareException e) {
                                    log.error(e, e);
                                }
                            }
                        };
                        try {
                            ProgressUI.popProgressDialog(op);
                        } catch (InvocationTargetException e) {
                            log.error(e, e);
                        } catch (InterruptedException e) {
                            log.error(e, e);
                        }
                    } else if (newDataProviderModel instanceof ColumnSet) {
                        IRunnableWithProgress op = new IRunnableWithProgress() {

                            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                                try {
                                    reloadByColumnFolderLevel(treeModelLs, anaEleSynDialog, newDataProvider);
                                } catch (ReloadCompareException e) {
                                    log.error(e, e);
                                }
                            }
                        };
                        try {
                            ProgressUI.popProgressDialog(op);
                        } catch (InvocationTargetException e) {
                            log.error(e, e);
                        } catch (InterruptedException e) {
                            log.error(e, e);
                        }
                    }
                }
            }
        }
        // Open asyned dialog.
        if (treeModelLs != null && treeModelLs.size() > 0) {
            // Open confirmation dialog to see whether user want to
            // continue or not.
            int returnCode = anaEleSynDialog.open();
            if (returnCode != Window.OK) {
                return new ReturnCode(Boolean.FALSE);
            }
        }
        // Synchronize analyzed elements.
        boolean isExistSynedElement = synAnalyzedElements(anaEleSynDialog, analysisItem.getAnalysis(), oldDataProvider, newDataProvider);
        // Add new dependencies.
        if (isExistSynedElement) {
            DependenciesHandler.getInstance().setDependencyOn(analysisItem.getAnalysis(), newDataProvider);
            ElementWriterFactory.getInstance().createDataProviderWriter().save(newDataProvider);
        }
        // Refresh analysis editor viewer.
        ElementWriterFactory.getInstance().createAnalysisWrite().save(analysisItem, false);
        // Refresh the repository tree view to adapt for the new analysis
        CorePlugin.getDefault().refreshDQView(RepositoryNodeHelper.getDataProfilingFolderNode(EResourceConstant.ANALYSIS));
    } else {
        return new ReturnCode(Boolean.FALSE);
    }
    return new ReturnCode(Boolean.TRUE);
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TdColumn(org.talend.cwm.relational.TdColumn) AnalyzedColumnSetsSynDialog(org.talend.dataprofiler.core.ui.dialog.AnalyzedColumnSetsSynDialog) AnalyzedPackageSynDialog(org.talend.dataprofiler.core.ui.dialog.AnalyzedPackageSynDialog) SynTreeModel(org.talend.dataprofiler.core.ui.dialog.AnalyzedElementSynDialog.SynTreeModel) Package(orgomg.cwm.objectmodel.core.Package) AnalyzedColumnsSynDialog(org.talend.dataprofiler.core.ui.dialog.AnalyzedColumnsSynDialog)

Example 29 with ColumnSet

use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.

the class PreviewColumnAction method run.

@Override
public void run() {
    if (modelElements[0] instanceof TdColumn) {
        TdColumn[] columns = new TdColumn[modelElements.length];
        int i = 0;
        for (ModelElement me : modelElements) {
            columns[i] = (TdColumn) me;
            ++i;
        }
        if (ColumnHelper.isFromSameTable(Arrays.asList(columns))) {
            TdColumn oneColumn = columns[0];
            Connection dataprovider = ConnectionHelper.getTdDataProvider(oneColumn);
            ColumnSet columnSetOwner = ColumnHelper.getColumnOwnerAsColumnSet(oneColumn);
            DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
            String columnsWithPrefix = language.getQueryColumnsWithPrefix(columns);
            String columnSetName = language.getQueryColumnSetWithPrefix(columnSetOwner);
            // $NON-NLS-1$ //$NON-NLS-2$
            String query = "select " + columnsWithPrefix + " from " + columnSetName;
            SqlExplorerUtils.getDefault().runInDQViewer(dataprovider, query, columnSetName);
        } else {
            MessageDialogWithToggle.openWarning(null, DefaultMessagesImpl.getString("PreviewColumnAction.Warning"), // $NON-NLS-1$ //$NON-NLS-2$
            DefaultMessagesImpl.getString("PreviewColumnAction.previewColumns"));
        }
    }
}
Also used : DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn) Connection(org.talend.core.model.metadata.builder.connection.Connection) ColumnSet(orgomg.cwm.resource.relational.ColumnSet)

Example 30 with ColumnSet

use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.

the class AnalysisExecutorHelper method findColumnSetOwner.

/**
 * DOC qiongli Comment method "findColumnSetOwner".
 *
 * @param column
 * @return
 * @deprecated instead of it by {@link ColumnHelper#getColumnOwnerAsColumnSet(ModelElement)}
 */
@Deprecated
public static ModelElement findColumnSetOwner(ModelElement column) {
    EObject owner = column.eContainer();
    ColumnSet set = SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(owner);
    MetadataTable mdColumn = SwitchHelpers.METADATA_TABLE_SWITCH.doSwitch(owner);
    if (null == set && mdColumn != null) {
        return mdColumn;
    } else if (null != set) {
        return set;
    }
    return column;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ColumnSet(orgomg.cwm.resource.relational.ColumnSet)

Aggregations

ColumnSet (orgomg.cwm.resource.relational.ColumnSet)55 TdColumn (org.talend.cwm.relational.TdColumn)35 Package (orgomg.cwm.objectmodel.core.Package)14 ArrayList (java.util.ArrayList)12 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)11 Connection (org.talend.core.model.metadata.builder.connection.Connection)9 RepositoryNode (org.talend.repository.model.RepositoryNode)9 ReloadCompareException (org.talend.cwm.compare.exception.ReloadCompareException)7 TdTable (org.talend.cwm.relational.TdTable)7 Catalog (orgomg.cwm.resource.relational.Catalog)7 Schema (orgomg.cwm.resource.relational.Schema)7 Resource (org.eclipse.emf.ecore.resource.Resource)6 EObject (org.eclipse.emf.ecore.EObject)5 ReturnCode (org.talend.utils.sugars.ReturnCode)5 Indicator (org.talend.dataquality.indicators.Indicator)4 IRepositoryNode (org.talend.repository.model.IRepositoryNode)4 List (java.util.List)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)3 DuplicateCountIndicator (org.talend.dataquality.indicators.DuplicateCountIndicator)3