Search in sources :

Example 1 with ReloadCompareException

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

the class AbstractTableComparisonLevel method createTempProvider.

public Connection createTempProvider(IFile tempConnectionFile) throws ReloadCompareException {
    URI uri = URI.createPlatformResourceURI(tempConnectionFile.getFullPath().toString(), false);
    Resource resource = EMFSharedResources.getInstance().getResource(uri, true);
    if (resource == null) {
        // $NON-NLS-1$
        throw new ReloadCompareException(DefaultMessagesImpl.getString("TableViewComparisonLevel.NoFactoryFoundForURI", uri));
    }
    Collection<Connection> tdDataProviders = ConnectionHelper.getTdDataProviders(resource.getContents());
    if (tdDataProviders.isEmpty()) {
        throw new ReloadCompareException(// $NON-NLS-1$
        DefaultMessagesImpl.getString(// $NON-NLS-1$
        "TableViewComparisonLevel.NoDataProviderFound", tempConnectionFile.getLocation().toFile().getAbsolutePath()));
    }
    if (tdDataProviders.size() > 1) {
        throw new ReloadCompareException(DefaultMessagesImpl.getString(// $NON-NLS-1$
        "TableViewComparisonLevel.TooManyDataProviderInFile", // $NON-NLS-1$
        tdDataProviders.size(), tempConnectionFile.getLocation().toFile().getAbsolutePath()));
    }
    return tdDataProviders.iterator().next();
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) Connection(org.talend.core.model.metadata.builder.connection.Connection) URI(org.eclipse.emf.common.util.URI)

Example 2 with ReloadCompareException

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

the class CatalogSchemaComparisonLevel method reloadElementOfPackage.

/**
 * DOC rli Comment method "reloadElementOfPackage".
 *
 * @param toReloadObj
 * @return
 * @throws ReloadCompareException
 */
private List<ColumnSet> reloadElementOfPackage(Package toReloadObj) throws ReloadCompareException {
    List<ColumnSet> columnSetList = new ArrayList<ColumnSet>();
    try {
        // MOD by msjian bug 2011-5-16 20875, the reload element is not added correctly
        Catalog catalogObj = SwitchHelpers.CATALOG_SWITCH.doSwitch(toReloadObj);
        Schema schemaObj = SwitchHelpers.SCHEMA_SWITCH.doSwitch(toReloadObj);
        if (schemaObj != null) {
            List<ModelElement> elementList = schemaObj.getOwnedElement();
            if (elementList != null && elementList.size() > 0) {
                elementList.clear();
            }
            List<TdTable> tables = DqRepositoryViewService.getTables(tempReloadProvider, schemaObj, null, true, true);
            SchemaHelper.addTables(tables, schemaObj);
            columnSetList.addAll(tables);
            List<TdView> views = DqRepositoryViewService.getViews(tempReloadProvider, schemaObj, null, true, true);
            SchemaHelper.addViews(views, schemaObj);
            columnSetList.addAll(views);
        } else {
            List<ModelElement> elementList = catalogObj.getOwnedElement();
            if (elementList != null && elementList.size() > 0) {
                elementList.clear();
            }
            List<TdTable> tables = DqRepositoryViewService.getTables(tempReloadProvider, catalogObj, null, true, true);
            CatalogHelper.addTables(tables, catalogObj);
            columnSetList.addAll(tables);
            List<TdView> views = DqRepositoryViewService.getViews(tempReloadProvider, catalogObj, null, true, true);
            CatalogHelper.addViews(views, catalogObj);
            columnSetList.addAll(views);
        }
    // else {
    // List<TdTable> tables = DqRepositoryViewService.getTables(tempReloadProvider, (Schema) toReloadObj, null,
    // true);
    // SchemaHelper.addTables(tables, (Schema) toReloadObj);
    // columnSetList.addAll(tables);
    // 
    // List<TdView> views = DqRepositoryViewService.getViews(tempReloadProvider, (Schema) toReloadObj, null,
    // true);
    // SchemaHelper.addViews(views, (Schema) toReloadObj);
    // columnSetList.addAll(views);
    // 
    // }
    } catch (Exception e1) {
        throw new ReloadCompareException(e1);
    }
    // EMFSharedResources.getInstance().saveResource(tempReloadProvider.eResource());
    return columnSetList;
}
Also used : TdTable(org.talend.cwm.relational.TdTable) Schema(orgomg.cwm.resource.relational.Schema) ArrayList(java.util.ArrayList) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) Catalog(orgomg.cwm.resource.relational.Catalog) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdView(org.talend.cwm.relational.TdView)

Example 3 with ReloadCompareException

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

the class SelectedComparisonAction method run.

@Override
public void run() {
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            final IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(selectedObj1, selectedObj2);
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    try {
                        creatComparisonLevel.popComparisonUI(new UiHandler());
                    } catch (ReloadCompareException e) {
                        log.error(e, e);
                    }
                }
            });
        }
    };
    try {
        ProgressUI.popProgressDialog(op);
        if (selectedObj1 instanceof Connection && selectedObj2 instanceof Connection) {
            DQRespositoryView repositoryView = CorePlugin.getDefault().getRepositoryView();
            if (repositoryView != null) {
                repositoryView.refresh();
            }
        }
    } catch (InvocationTargetException e) {
        // $NON-NLS-1$
        MessageUI.openError(Messages.getString("PopComparisonUIAction.checkConnectionFailure", e.getCause().getMessage()));
        log.error(e, e);
    } catch (InterruptedException e) {
        log.error(e, e);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) Connection(org.talend.core.model.metadata.builder.connection.Connection) DQRespositoryView(org.talend.dataprofiler.core.ui.views.DQRespositoryView) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IComparisonLevel(org.talend.cwm.compare.factory.IComparisonLevel)

Example 4 with ReloadCompareException

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

the class PopComparisonUIAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            final IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(selectedObject);
            try {
                if (creatComparisonLevel != null) {
                    creatComparisonLevel.popComparisonUI(new UiHandler());
                } else {
                    // $NON-NLS-1$
                    String errMsg = Messages.getString("PopComparisonUIAction.dontSupport");
                    log.error(errMsg, new Exception(errMsg));
                }
            } catch (ReloadCompareException e) {
                MessageDialog.openError(shell, // $NON-NLS-1$
                Messages.getString("PopComparisonUIAction.ErrorDuringComparison"), // $NON-NLS-1$
                e.getMessage());
                log.error(e, e);
            }
        }
    };
    try {
        ProgressUI.popProgressDialog(op, false, false);
    } catch (InvocationTargetException e) {
        MessageDialog.openInformation(shell, Messages.getString("PopComparisonUIAction.connectionFailure"), // $NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("PopComparisonUIAction.checkConnectionFailure"));
        log.error(e, e);
    } catch (InterruptedException e) {
        log.error(e, e);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IComparisonLevel(org.talend.cwm.compare.factory.IComparisonLevel)

Example 5 with ReloadCompareException

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

the class SelectedLocalComparison method createTempConnectionFile.

@SuppressWarnings("deprecation")
protected void createTempConnectionFile() throws ReloadCompareException {
    // First resource.
    IFile selectedFile1 = PrvResourceFileHelper.getInstance().findCorrespondingFile(firstSelectedDataProvider);
    if (selectedFile1 == null) {
        selectedFile1 = ResourceManager.getRoot().getFile(new Path(firstSelectedDataProvider.eResource().getURI().toPlatformString(false)));
    }
    IFile firstConnectionFile = DQStructureComparer.getFirstComparisonLocalFile();
    IFile copyedFile1 = DQStructureComparer.copyedToDestinationFile(selectedFile1, firstConnectionFile);
    TypedReturnCode<Connection> returnProvider = DqRepositoryViewService.readFromFile(copyedFile1);
    if (!returnProvider.isOk()) {
        throw new ReloadCompareException(returnProvider.getMessage());
    }
    tempFirstSelectedDataProvider = returnProvider.getObject();
    // Second resource.
    IFile selectedFile2 = PrvResourceFileHelper.getInstance().findCorrespondingFile(secondSelectedDataProvider);
    if (selectedFile2 == null) {
        selectedFile2 = ResourceManager.getRoot().getFile(new Path(secondSelectedDataProvider.eResource().getURI().toPlatformString(false)));
    }
    IFile secondConnectionFile = DQStructureComparer.getSecondComparisonLocalFile();
    IFile copyedFile2 = DQStructureComparer.copyedToDestinationFile(selectedFile2, secondConnectionFile);
    TypedReturnCode<Connection> returnProvider2 = DqRepositoryViewService.readFromFile(copyedFile2);
    if (!returnProvider2.isOk()) {
        throw new ReloadCompareException(returnProvider2.getMessage());
    }
    tempSecondSelectedDataProvider = returnProvider2.getObject();
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) 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)

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