Search in sources :

Example 16 with ReloadCompareException

use of org.talend.cwm.compare.exception.ReloadCompareException in project tdq-studio-se by Talend.

the class RenameComparedElementAction method createTempConnectionFile.

private Connection createTempConnectionFile() throws ReloadCompareException {
    Package catalogOrSchema = getTopLevelPackage();
    Connection oldDataProvider = (Connection) catalogOrSchema.getDataManager().get(0);
    IFile tempConnectionFile = DQStructureComparer.getSecondComparisonLocalFile();
    // MOD mzhao ,Extract method getRefreshedDataProvider to class
    // DQStructureComparer for common use.
    TypedReturnCode<Connection> returnProvider = DQStructureComparer.getRefreshedDataProvider(oldDataProvider);
    if (!returnProvider.isOk()) {
        throw new ReloadCompareException(returnProvider.getMessage());
    }
    Connection tempReloadProvider = returnProvider.getObject();
    tempReloadProvider.setComponent(oldDataProvider.getComponent());
    ElementWriterFactory.getInstance().createDataProviderWriter().create(tempReloadProvider, tempConnectionFile);
    tempReloadProvider.setComponent(null);
    oldDataProvider.getComponent();
    return tempReloadProvider;
}
Also used : IFile(org.eclipse.core.resources.IFile) Connection(org.talend.core.model.metadata.builder.connection.Connection) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) Package(orgomg.cwm.objectmodel.core.Package)

Example 17 with ReloadCompareException

use of org.talend.cwm.compare.exception.ReloadCompareException in project tdq-studio-se by Talend.

the class ReloadDatabaseAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    returnCode = new ReturnCode(true);
    if (!isSupport()) {
        // $NON-NLS-1$
        returnCode.setReturnCode(Messages.getString("ReloadDatabaseAction.NotSupportMessage"), false);
        return;
    }
    // MOD TDQ-7528 20130627 yyin: if needCompare=false,no need to popup select compare dialog
    if (this.needCompare) {
        // popup a dialog to warn the user better do the compare before the reload, and provide two buttons:
        // if the user click the compare button, the compare will be executed.
        // if the user click the reload button, the reload will continue.
        // $NON-NLS-1$
        String[] dialogButtonLabels = { Messages.getString("ReloadDatabaseAction.ReloadLabel") };
        MessageDialog dialog = new MessageDialog(CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("ReloadDatabaseAction.ReloadLabel"), null, Messages.getString("ReloadDatabaseAction.IsContinue"), 3, dialogButtonLabels, // $NON-NLS-1$ //$NON-NLS-2$
        SWT.NONE);
        int open = dialog.open();
        // when click close, do nothing.
        if (open == -1) {
            return;
        }
    // when click compare
    // if (open == 0) {
    // // go to compare instead of reloading now
    // new PopComparisonUIAction(selectedObject, Messages.getString("ReloadDatabaseAction.CompareLabel")).run();//$NON-NLS-1$
    // returnCode.setReturnCode(Messages.getString("ReloadDatabaseAction.IsContinue"), false);//$NON-NLS-1$
    // return;
    // }// ~
    }
    Connection conn = getConnection();
    List<ModelElement> dependencyClients = EObjectHelper.getDependencyClients(conn);
    if (!(dependencyClients == null || dependencyClients.isEmpty())) {
        int isOk = DeleteModelElementConfirmDialog.showElementImpactConfirmDialog(null, new ModelElement[] { conn }, // $NON-NLS-1$
        DefaultMessagesImpl.getString("TOPRepositoryService.dependcyTile"), // $NON-NLS-1$
        DefaultMessagesImpl.getString("TOPRepositoryService.dependcyMessage", conn.getLabel()));
        if (isOk != Dialog.OK) {
            // $NON-NLS-1$
            returnCode.setReturnCode("The user canceled the operation!", false);
            return;
        }
    }
    IRunnableWithProgress op = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            final IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(selectedObject);
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    try {
                        Connection oldDataProvider = creatComparisonLevel.reloadCurrentLevelElement();
                        // MOD mzhao 2009-07-13 bug 7454 Impact existing analysis.
                        // MOD qiongli 2011-9-8,move method 'impactExistingAnalyses(...)' to class WorkbenchUtils
                        // update the sql explore.
                        Property property = PropertyHelper.getProperty(oldDataProvider);
                        if (property != null) {
                            Item newItem = property.getItem();
                            if (newItem != null) {
                                CWMPlugin.getDefault().updateConnetionAliasByName(oldDataProvider, oldDataProvider.getLabel());
                            }
                        }
                        // update the related analyses.
                        WorkbenchUtils.impactExistingAnalyses(oldDataProvider);
                        // Update software system.
                        updateSoftwareSystem(oldDataProvider);
                    } catch (ReloadCompareException e) {
                        // $NON-NLS-1$
                        MessageUI.openError(Messages.getString("ReloadDatabaseAction.Error", e.getMessage()));
                        log.error(e, e);
                        returnCode.setReturnCode(e.getMessage(), false);
                    } catch (PartInitException e) {
                        log.error(e, e);
                        returnCode.setReturnCode(e.getMessage(), false);
                    }
                }
            });
        }
    };
    try {
        ProgressUI.popProgressDialog(op);
        CorePlugin.getDefault().refreshDQView(selectedObject);
    } catch (InvocationTargetException e) {
        // $NON-NLS-1$
        MessageUI.openError(Messages.getString("ReloadDatabaseAction.checkConnectionFailured", e.getCause().getMessage()));
        log.error(e, e);
    } catch (InterruptedException e) {
        log.error(e, e);
    }
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property) IComparisonLevel(org.talend.cwm.compare.factory.IComparisonLevel)

Example 18 with ReloadCompareException

use of org.talend.cwm.compare.exception.ReloadCompareException in project tdq-studio-se by Talend.

the class RunAnalysisAction method reloadConnection.

/**
 * reload analysis connection.
 */
private void reloadConnection(TDQAnalysisItem runItem) {
    if (AnalysisHelper.getReloadDatabases(runItem.getAnalysis())) {
        Connection conntion = (Connection) runItem.getAnalysis().getContext().getConnection();
        if (conntion != null) {
            try {
                RepositoryNode connectionNode = RepositoryNodeHelper.recursiveFind(conntion);
                ComparisonLevelFactory.creatComparisonLevel(connectionNode).reloadCurrentLevelElement();
                CorePlugin.getDefault().refreshDQView(connectionNode);
            } catch (ReloadCompareException e) {
                log.error(e, e);
            }
        }
    }
}
Also used : DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 19 with ReloadCompareException

use of org.talend.cwm.compare.exception.ReloadCompareException in project tdq-studio-se by Talend.

the class TOPRepositoryService method reloadTableList.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.core.ITDQRepositoryService#reloadTableList(org.talend.core.model.properties.DatabaseConnectionItem)
     */
public void reloadTableList(final DatabaseConnectionItem hiveConnectionItem2) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRunnable operation = new IWorkspaceRunnable() {

        public void run(IProgressMonitor monitor) throws CoreException {
            RepositoryNode tableFolder = TableUtils.getTableFolder(hiveConnectionItem2);
            if (tableFolder != null) {
                IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(tableFolder);
                try {
                    creatComparisonLevel.reloadCurrentLevelElement();
                } catch (ReloadCompareException e) {
                    log.error(e, e);
                }
                CorePlugin.getDefault().refreshDQView(tableFolder);
            }
        }
    };
    try {
        workspace.run(operation, null);
    } catch (CoreException e) {
        log.error(e, e);
    }
}
Also used : IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IComparisonLevel(org.talend.cwm.compare.factory.IComparisonLevel)

Aggregations

ReloadCompareException (org.talend.cwm.compare.exception.ReloadCompareException)19 Connection (org.talend.core.model.metadata.builder.connection.Connection)10 ColumnSet (orgomg.cwm.resource.relational.ColumnSet)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 IComparisonLevel (org.talend.cwm.compare.factory.IComparisonLevel)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IFile (org.eclipse.core.resources.IFile)4 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)4 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)4 TdColumn (org.talend.cwm.relational.TdColumn)4 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)4 Package (orgomg.cwm.objectmodel.core.Package)4 URI (org.eclipse.emf.common.util.URI)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 ReturnCode (org.talend.utils.sugars.ReturnCode)3 Shell (org.eclipse.swt.widgets.Shell)2 PartInitException (org.eclipse.ui.PartInitException)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2