use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class ChangeConnectionAction method changedDatabaseConnection.
private ReturnCode changedDatabaseConnection() throws ReloadCompareException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final EList<ModelElement> analyzedElements = analysisItem.getAnalysis().getContext() == null ? null : analysisItem.getAnalysis().getContext().getAnalysedElements();
if (analyzedElements == null || analyzedElements.size() == 0) {
analysisItem.getAnalysis().getContext().setConnection(newDataProvider);
return new ReturnCode(Boolean.TRUE);
}
// MOD qiongli 2011-1-10,feature 16796.
if (oldDataProvider instanceof DelimitedFileConnection) {
// "Can't change this connection!");
if (!// $NON-NLS-1$
MessageDialog.openConfirm(// $NON-NLS-1$
shell, // $NON-NLS-1$
DefaultMessagesImpl.getString("ChangeConnectionAction.ChangeConnection"), DefaultMessagesImpl.getString("ChangeConnectionAction.ChangeConnectionTips"))) {
// $NON-NLS-1$
return new ReturnCode(Boolean.FALSE);
}
}
// Open synchronized dialog.
boolean retCode = MessageDialog.openQuestion(shell, // $NON-NLS-1$
DefaultMessagesImpl.getString("ChangeConnectionAction.ChangeConnection"), // $NON-NLS-1$
DefaultMessagesImpl.getString("ChangeConnectionAction.MayCauseAsynProblem"));
if (retCode) {
if (analyzedElements.get(0) instanceof TdColumn) {
anaEleSynDialog = new AnalyzedColumnsSynDialog(shell, analysisItem.getAnalysis(), newDataProvider, analyzedElements);
} else if (analyzedElements.get(0) instanceof ColumnSet) {
anaEleSynDialog = new AnalyzedColumnSetsSynDialog(shell, analysisItem.getAnalysis(), newDataProvider, analyzedElements);
} else if (analyzedElements.get(0) instanceof Package) {
anaEleSynDialog = new AnalyzedPackageSynDialog(shell, analysisItem.getAnalysis(), newDataProvider, analyzedElements);
}
final List<SynTreeModel> treeModelLs = anaEleSynDialog == null ? null : anaEleSynDialog.getSynInputModel();
if (treeModelLs != null && treeModelLs.size() > 0) {
// Make attempt to reload from db before showing asyned
// message.
boolean isReload = MessageDialog.openQuestion(shell, // $NON-NLS-1$
DefaultMessagesImpl.getString("ChangeConnectionAction.ReloadFromDatabase"), // $NON-NLS-1$
DefaultMessagesImpl.getString("ChangeConnectionAction.ExistElementAsynchronuos"));
if (isReload) {
ModelElement newDataProviderModel = treeModelLs.get(0).getNewDataProvElement();
if (newDataProviderModel != null && (newDataProviderModel instanceof ColumnSet || newDataProviderModel instanceof Package)) {
if (newDataProviderModel instanceof Package) {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
reloadByColumnSetFolderLevel(treeModelLs, anaEleSynDialog, newDataProvider);
if (analyzedElements.get(0) instanceof TdColumn) {
// Reload column folder
reloadByColumnFolderLevel(treeModelLs, anaEleSynDialog, newDataProvider);
}
} catch (ReloadCompareException e) {
log.error(e, e);
}
}
};
try {
ProgressUI.popProgressDialog(op);
} catch (InvocationTargetException e) {
log.error(e, e);
} catch (InterruptedException e) {
log.error(e, e);
}
} else if (newDataProviderModel instanceof ColumnSet) {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
reloadByColumnFolderLevel(treeModelLs, anaEleSynDialog, newDataProvider);
} catch (ReloadCompareException e) {
log.error(e, e);
}
}
};
try {
ProgressUI.popProgressDialog(op);
} catch (InvocationTargetException e) {
log.error(e, e);
} catch (InterruptedException e) {
log.error(e, e);
}
}
}
}
}
// Open asyned dialog.
if (treeModelLs != null && treeModelLs.size() > 0) {
// Open confirmation dialog to see whether user want to
// continue or not.
int returnCode = anaEleSynDialog.open();
if (returnCode != Window.OK) {
return new ReturnCode(Boolean.FALSE);
}
}
// Synchronize analyzed elements.
boolean isExistSynedElement = synAnalyzedElements(anaEleSynDialog, analysisItem.getAnalysis(), oldDataProvider, newDataProvider);
// Add new dependencies.
if (isExistSynedElement) {
DependenciesHandler.getInstance().setDependencyOn(analysisItem.getAnalysis(), newDataProvider);
ElementWriterFactory.getInstance().createDataProviderWriter().save(newDataProvider);
}
// Refresh analysis editor viewer.
ElementWriterFactory.getInstance().createAnalysisWrite().save(analysisItem, false);
// Refresh the repository tree view to adapt for the new analysis
CorePlugin.getDefault().refreshDQView(RepositoryNodeHelper.getDataProfilingFolderNode(EResourceConstant.ANALYSIS));
} else {
return new ReturnCode(Boolean.FALSE);
}
return new ReturnCode(Boolean.TRUE);
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class PreviewColumnAction method run.
@Override
public void run() {
if (modelElements[0] instanceof TdColumn) {
TdColumn[] columns = new TdColumn[modelElements.length];
int i = 0;
for (ModelElement me : modelElements) {
columns[i] = (TdColumn) me;
++i;
}
if (ColumnHelper.isFromSameTable(Arrays.asList(columns))) {
TdColumn oneColumn = columns[0];
Connection dataprovider = ConnectionHelper.getTdDataProvider(oneColumn);
ColumnSet columnSetOwner = ColumnHelper.getColumnOwnerAsColumnSet(oneColumn);
DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
String columnsWithPrefix = language.getQueryColumnsWithPrefix(columns);
String columnSetName = language.getQueryColumnSetWithPrefix(columnSetOwner);
// $NON-NLS-1$ //$NON-NLS-2$
String query = "select " + columnsWithPrefix + " from " + columnSetName;
SqlExplorerUtils.getDefault().runInDQViewer(dataprovider, query, columnSetName);
} else {
MessageDialogWithToggle.openWarning(null, DefaultMessagesImpl.getString("PreviewColumnAction.Warning"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("PreviewColumnAction.previewColumns"));
}
}
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class PreviewColumnProvider method fillContextMenu.
@Override
public void fillContextMenu(IMenuManager menu) {
// MOD mzhao user readonly role on svn repository mode.
if (!isShowMenu()) {
return;
}
TreeSelection treeSelection = ((TreeSelection) this.getContext().getSelection());
List<TdColumn> list = new ArrayList<TdColumn>();
Object[] selectedObjs = treeSelection.toArray();
for (Object obj : selectedObjs) {
// MOD msjian 2011-12-7 TDQ-4091: the tdColumn info is not correct
if (obj instanceof DBColumnRepNode) {
list.add(((DBColumnRepNode) obj).getTdColumn());
}
// TDQ-4091 ~
}
if (!list.isEmpty()) {
PreviewColumnAction action = new PreviewColumnAction(list.toArray(new TdColumn[list.size()]));
menu.add(action);
}
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class ColumnDependencyIndicatorImpl method setColumnB.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void setColumnB(TdColumn newColumnB) {
TdColumn oldColumnB = columnB;
columnB = newColumnB;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ColumnsetPackage.COLUMN_DEPENDENCY_INDICATOR__COLUMN_B, oldColumnB, columnB));
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class ColumnSetMultiValueIndicatorImpl method isSameMiningType.
private Boolean isSameMiningType(ModelElement column, DataminingType type) {
// MOD yyi 2011-02-25 16660: edit connection, save it will get error
final MetadataColumn mdColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(column);
final TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(column);
if (tdColumn == null && mdColumn == null) {
if (column == null) {
log.error("The list of analyzed column contains a null column");
} else {
log.error("Analyzed element should be a TdColumn instead of a Column. Analyzed element is " + column.getName());
}
// Column which is null is not a nominal type.
return false;
}
// MOD qiongli 2011-3-8.fetature 19192,add mdColumn for MetadataColumn(delimited file)
DataminingType dataminingType = MetadataHelper.getDataminingType(column);
if (dataminingType != null && type == dataminingType) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
Aggregations