Search in sources :

Example 11 with ReloadCompareException

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

the class AbstractComparisonLevel method createTempConnectionFile.

/**
 * DOC rli Comment method "createTempConnectionFile".
 *
 * @throws ReloadCompareException
 */
protected IFile createTempConnectionFile() throws ReloadCompareException {
    IFile tempConnectionFile = DQStructureComparer.getTempRefreshFile();
    // 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());
    }
    tempReloadProvider = upperCaseConnection(returnProvider.getObject());
    tempReloadProvider.setComponent(oldDataProvider.getComponent());
    // MOD mzhao bug:9012 2009-09-08
    ElementWriterFactory.getInstance().createDataProviderWriter().create(tempReloadProvider, tempConnectionFile.getFullPath(), false);
    tempReloadProvider.setComponent(null);
    oldDataProvider.getComponent();
    return tempConnectionFile;
}
Also used : IFile(org.eclipse.core.resources.IFile) Connection(org.talend.core.model.metadata.builder.connection.Connection) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException)

Example 12 with ReloadCompareException

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

the class AbstractComparisonLevel method createCopyedProvider.

@SuppressWarnings("deprecation")
protected void createCopyedProvider() throws ReloadCompareException {
    IFile selectedFile = WorkspaceUtils.getModelElementResource(oldDataProvider);
    IFile createNeedReloadElementsFile = DQStructureComparer.getNeedReloadElementsFile();
    IFile copyedFile = DQStructureComparer.copyedToDestinationFile(selectedFile, createNeedReloadElementsFile);
    TypedReturnCode<Connection> returnValue = DqRepositoryViewService.readFromFile(copyedFile);
    if (returnValue.isOk()) {
        copyedDataProvider = returnValue.getObject();
    } else {
        DQStructureComparer.deleteFile(createNeedReloadElementsFile);
        throw new ReloadCompareException(returnValue.getMessage());
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) Connection(org.talend.core.model.metadata.builder.connection.Connection) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException)

Example 13 with ReloadCompareException

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

the class TableViewComparisonLevel method getRightResource.

@Override
protected Resource getRightResource() throws ReloadCompareException {
    ColumnSet selectedColumnSet = null;
    if (selectedObj instanceof RepositoryNode) {
        selectedColumnSet = (ColumnSet) RepositoryNodeHelper.getMetadataElement((RepositoryNode) selectedObj);
    } else if (selectedObj instanceof DBColumnFolderRepNode) {
        DBColumnFolderRepNode columnFolderRepNode = (DBColumnFolderRepNode) selectedObj;
        selectedColumnSet = columnFolderRepNode.getColumnSet();
    } else {
        selectedColumnSet = (ColumnSet) selectedObj;
    }
    ColumnSet findMatchedColumnSet = DQStructureComparer.findMatchedColumnSet(selectedColumnSet, tempReloadProvider);
    List<TdColumn> columns = null;
    try {
        // MOD scorreia 2009-01-29 clear content of findMatchedColumnSet
        ColumnSetHelper.setColumns(findMatchedColumnSet, EMPTY_COLUMN_LIST);
        columns = DqRepositoryViewService.getColumns(tempReloadProvider, findMatchedColumnSet, true);
    } catch (Exception e1) {
        throw new ReloadCompareException(e1);
    }
    // MOD scorreia 2009-01-29 columns are stored in the table
    // ColumnSetHelper.addColumns(findMatchedColumnSet, columns);
    URI uri = tempReloadProvider.eResource().getURI();
    Resource rightResource = null;
    rightResource = EMFSharedResources.getInstance().getResource(uri, true);
    if (rightResource == null) {
        // $NON-NLS-1$
        throw new ReloadCompareException(DefaultMessagesImpl.getString("TableViewComparisonLevel.NoFactoryFoundForURI", uri));
    }
    rightResource.getContents().clear();
    for (TdColumn column : columns) {
        DQStructureComparer.clearSubNode(column);
        rightResource.getContents().add(column);
    }
    EMFSharedResources.getInstance().saveResource(rightResource);
    return upperCaseResource(rightResource);
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) Resource(org.eclipse.emf.ecore.resource.Resource) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) RepositoryNode(org.talend.repository.model.RepositoryNode) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) URI(org.eclipse.emf.common.util.URI) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException)

Example 14 with ReloadCompareException

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

the class TableViewComparisonLevel method getSavedReloadObject.

@Override
protected EObject getSavedReloadObject() throws ReloadCompareException {
    ColumnSet selectedColumnSet = getCurrentColumnSet();
    ColumnSet toReloadcolumnSet = DQStructureComparer.findMatchedColumnSet(selectedColumnSet, tempReloadProvider);
    // ADD TDQ-11146 msjian: to save the TaggedValues before clear
    if (PluginChecker.isTDQLoaded()) {
        tmpConceptName = TaggedValueHelper.getValueString(TaggedValueHelper.CONCEPT_NAME, toReloadcolumnSet);
        EList<Feature> feature = toReloadcolumnSet.getFeature();
        tmpTaggedValuesMap = new HashMap<String, String[]>();
        for (Feature fea : feature) {
            String[] values = new String[] { StringUtils.EMPTY, StringUtils.EMPTY };
            values[0] = TaggedValueHelper.getValueString(TaggedValueHelper.SEMANTIC_NAME, fea);
            values[1] = TaggedValueHelper.getValueString(TaggedValueHelper.CONTENT_TYPE, fea);
            if (StringUtils.isNotBlank(values[0]) || StringUtils.isNotBlank(values[1])) {
                tmpTaggedValuesMap.put(fea.getName(), values);
            }
        }
    }
    // TDQ-11146~
    // MOD scorreia 2009-01-29 clear content of findMatchedColumnSet
    ColumnSetHelper.setColumns(toReloadcolumnSet, EMPTY_COLUMN_LIST);
    toReloadcolumnSet.getOwnedElement().clear();
    try {
        DqRepositoryViewService.getColumns(tempReloadProvider, toReloadcolumnSet, true);
        // MOD mzhao 2009-11-12 save to resoure after reload.
        util.saveResource(toReloadcolumnSet.eResource());
    } catch (Exception e1) {
        throw new ReloadCompareException(e1);
    }
    // ColumnSetHelper.setColumns(toReloadcolumnSet, columns);
    return toReloadcolumnSet;
}
Also used : ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) Feature(orgomg.cwm.objectmodel.core.Feature) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException)

Example 15 with ReloadCompareException

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

the class RenameComparedElementAction method getRightResource.

private Resource getRightResource(ColumnSet selectedColumnSet) throws ReloadCompareException {
    Connection tempReloadProvider = createTempConnectionFile();
    Package matchedPackage = DQStructureComparer.findMatchedPackage((Package) originCompareElement, tempReloadProvider);
    IFolderNode columnSetFolderNode = FolderNodeHelper.getFolderNode(matchedPackage, selectedColumnSet);
    columnSetFolderNode.loadChildren();
    ColumnSet findMatchedColumnSet = DQStructureComparer.findMatchedColumnSet(selectedColumnSet, tempReloadProvider);
    List<TdColumn> columns = null;
    try {
        columns = DqRepositoryViewService.getColumns(tempReloadProvider, findMatchedColumnSet, null, true);
    } catch (Exception e1) {
        throw new ReloadCompareException(e1);
    }
    URI uri = tempReloadProvider.eResource().getURI();
    Resource rightResource = null;
    rightResource = EMFSharedResources.getInstance().getResource(uri, true);
    if (rightResource == null) {
        // $NON-NLS-1$
        throw new ReloadCompareException("NoFactoryFoundForURI" + uri.toFileString());
    }
    rightResource.getContents().clear();
    for (TdColumn column : columns) {
        DQStructureComparer.clearSubNode(column);
        rightResource.getContents().add(column);
    }
    EMFSharedResources.getInstance().saveResource(rightResource);
    return rightResource;
}
Also used : IFolderNode(org.talend.dq.nodes.foldernode.IFolderNode) TdColumn(org.talend.cwm.relational.TdColumn) Connection(org.talend.core.model.metadata.builder.connection.Connection) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) Resource(org.eclipse.emf.ecore.resource.Resource) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) Package(orgomg.cwm.objectmodel.core.Package) URI(org.eclipse.emf.common.util.URI) 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