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