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();
}
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;
}
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);
}
}
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);
}
}
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();
}
Aggregations