use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class TableAnalysisDPSelectionPage method addListeners.
@Override
protected void addListeners() {
addListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (object instanceof NamedColumnSet) {
advanceToNextPageOrFinish();
}
}
});
addListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
// Connection oldTdDataProvider = null;
NamedColumnSetAnalysisParameter paraneter = (NamedColumnSetAnalysisParameter) getConnectionParams();
List tempList = ((IStructuredSelection) event.getSelection()).toList();
List<NamedColumnSet> setList = new ArrayList<NamedColumnSet>();
for (Object object : tempList) {
if (object instanceof DBTableRepNode) {
DBTableRepNode tableNode = (DBTableRepNode) object;
// MOD klliu if table node is not initialized , then init that . bug 20097 2011-03-31
if (!tableNode.isInitialized()) {
tableNode.getChildren().get(0).getChildren();
}
// ~
setList.add(tableNode.getTdTable());
}
// if (object instanceof NamedColumnSet) {
// NamedColumnSet set = (NamedColumnSet) object;
// Connection tdProvider = ConnectionHelper.getTdDataProvider(TableHelper
// .getParentCatalogOrSchema(set));
// oldTdDataProvider = oldTdDataProvider == null ? tdProvider : oldTdDataProvider;
// if (oldTdDataProvider != null && !oldTdDataProvider.equals(tdProvider)) {
// MessageUI.openWarning(DefaultMessagesImpl
// .getString("TableAnalysisDPSelectionPage.TableSelectWarning")); //$NON-NLS-1$
// } else if (tdProvider != null && paraneter != null) {
// setList.add(set);
// paraneter.setTdDataProvider(oldTdDataProvider);
// }
// }
}
if (setList.size() > 0 && paraneter != null) {
paraneter.setNamedColumnSets(setList.toArray(new NamedColumnSet[setList.size()]));
DBTableRepNode recursiveFind = (DBTableRepNode) RepositoryNodeHelper.recursiveFind((TdTable) setList.get(0));
RepositoryNode parent = recursiveFind.getParent().getParent();
// MOD qiongli 2011-3-16 bug 19475
RepositoryNode catalogNode = parent;
if (parent instanceof DBCatalogRepNode) {
parent = parent.getParent();
} else if (parent instanceof DBSchemaRepNode) {
parent = parent.getParent();
if (parent instanceof DBCatalogRepNode) {
catalogNode = parent;
parent = parent.getParent();
}
}
// TdTableRepositoryObject tableViewObject = (TdTableRepositoryObject) recursiveFind.getObject();
// IRepositoryViewObject viewObject = parent.getObject();
DBConnectionRepNode connNode = (DBConnectionRepNode) parent;
paraneter.setConnectionRepNode(connNode);
Connection connection = ConnectionHelper.getConnection((TdTable) setList.get(0));
paraneter.setTdDataProvider(connection);
List<IRepositoryNode> packagesNode = new ArrayList<IRepositoryNode>();
packagesNode.add(catalogNode);
paraneter.setPackages(packagesNode);
setPageComplete(true);
} else {
setPageComplete(false);
}
}
});
}
use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class ImageLib method getImageNameByRepositoryNode.
public static String getImageNameByRepositoryNode(IRepositoryNode node) {
String imageName = null;
IRepositoryViewObject viewObject = node.getObject();
ENodeType type = node.getType();
if (node instanceof ReportAnalysisRepNode) {
imageName = ImageLib.ANALYSIS_OBJECT;
} else if (node instanceof RecycleBinRepNode) {
imageName = ImageLib.RECYCLEBIN_EMPTY;
} else if (type.equals(ENodeType.SYSTEM_FOLDER)) {
String label = viewObject.getLabel();
if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
imageName = ImageLib.DATA_PROFILING;
} else if (label.equals(EResourceConstant.METADATA.getName())) {
imageName = ImageLib.METADATA;
} else if (node instanceof DBConnectionFolderRepNode) {
imageName = ImageLib.CONNECTION;
} else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
imageName = ImageLib.FILE_DELIMITED;
} else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
imageName = ImageLib.HADOOP_CLUSTER;
} else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
imageName = ImageLib.LIBRARIES;
} else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
imageName = ImageLib.EXCHANGE;
} else {
imageName = ImageLib.FOLDERNODE_IMAGE;
}
} else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
if (node instanceof DBConnectionRepNode) {
imageName = ImageLib.TD_DATAPROVIDER;
} else if (node instanceof DFConnectionRepNode) {
imageName = ImageLib.FILE_DELIMITED;
} else if (node instanceof AnalysisRepNode) {
imageName = ImageLib.ANALYSIS_OBJECT;
} else if (node instanceof ReportRepNode) {
imageName = ImageLib.REPORT_OBJECT;
} else if (node instanceof SysIndicatorDefinitionRepNode) {
imageName = ImageLib.IND_DEFINITION;
} else if (node instanceof PatternRepNode) {
imageName = ImageLib.PATTERN_REG;
} else if (node instanceof RuleRepNode) {
imageName = ImageLib.DQ_RULE;
} else if (node instanceof SourceFileRepNode) {
imageName = ImageLib.SOURCE_FILE;
} else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
imageName = ImageLib.EXCHANGE;
} else if (node instanceof JrxmlTempleteRepNode) {
imageName = ImageLib.JRXML_ICON;
}
} else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
if (node instanceof DBCatalogRepNode) {
imageName = ImageLib.CATALOG;
} else if (node instanceof DBSchemaRepNode) {
imageName = ImageLib.SCHEMA;
} else if (node instanceof DBTableFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (node instanceof DBViewFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
imageName = ImageLib.TABLE;
} else if (node instanceof DBViewRepNode) {
imageName = ImageLib.VIEW;
} else if (node instanceof DBColumnRepNode) {
if (((DBColumnRepNode) node).isKey()) {
imageName = ImageLib.PK_COLUMN;
} else {
imageName = ImageLib.TD_COLUMN;
}
} else if (node instanceof DFColumnRepNode) {
imageName = ImageLib.TD_COLUMN;
} else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
}
}
return imageName;
}
use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class CreateAnalysisOnHDFSAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
DBTableRepNode newTableNode = openCreateHiveTable();
if (newTableNode != null) {
List<IRepositoryNode> allColumns = newTableNode.getAllColumns();
TreePath[] paths = new TreePath[allColumns.size()];
int i = 0;
for (IRepositoryNode column : allColumns) {
paths[i++] = new TreePath(new Object[] { column });
}
CreateColumnAnalysisAction analysisAction = new CreateColumnAnalysisAction();
analysisAction.setSelection(new TreeSelection(paths));
analysisAction.run();
}
}
use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class ColumnsSelectionDialog method addCheckedListener.
/*
* (non-Javadoc)
*
* @seeorg.talend.dataprofiler.core.ui.dialog.TwoPartCheckSelectionDialog# addCheckedListener()
*/
@Override
protected void addCheckedListener() {
// When user checks a checkbox in the tree, check all its children
getTreeViewer().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
// Added TDQ-8718 20140506 yyin: should not load from db when checking
DQDBFolderRepositoryNode.setCallingFromColumnDialog(true);
DQDBFolderRepositoryNode.setLoadDBFromDialog(false);
try {
ColumnSelectionViewer columnViewer = (ColumnSelectionViewer) event.getSource();
TreePath treePath = new TreePath(new Object[] { event.getElement() });
columnViewer.setSelection(new TreeSelection(treePath));
setOutput(event.getElement());
RepositoryNode selectedNode = (RepositoryNode) event.getElement();
if (selectedNode instanceof DBTableRepNode || selectedNode instanceof DBViewRepNode || selectedNode instanceof DFTableRepNode) {
handleTreeElementsChecked(selectedNode, event.getChecked());
} else {
checkChildrenElements(selectedNode, event.getChecked());
}
getTreeViewer().setSubtreeChecked(event.getElement(), event.getChecked());
updateStatusBySelection();
} finally {
// Added TDQ-8718 20140506 yyin
DQDBFolderRepositoryNode.setCallingFromColumnDialog(false);
DQDBFolderRepositoryNode.setLoadDBFromDialog(true);
}
}
private void checkChildrenElements(RepositoryNode repNode, Boolean checkedFlag) {
Set<?> keySet = modelElementCheckedMap.keySet();
RepositoryNode[] repNodeArray = (RepositoryNode[]) modelElementCheckedMap.keySet().toArray(new RepositoryNode[keySet.size()]);
for (RepositoryNode reposNode : repNodeArray) {
RepositoryNode parentNode = reposNode.getParent();
while (parentNode != null) {
if (repNode.equals(parentNode)) {
handleTreeElementsChecked(reposNode, checkedFlag);
break;
} else {
parentNode = parentNode.getParent();
}
}
}
}
});
getTableViewer().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
handleTableElementsChecked((RepositoryNode) event.getElement(), event.getChecked());
updateStatusBySelection();
}
});
}
use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class ColumnsSelectionDialog method getAllCheckedTableNodes.
/**
* Compute the checked Table Nodes.
*
* @param repNodeArray
* @return
*/
private List<RepositoryNode> getAllCheckedTableNodes() {
Set<?> keySet = modelElementCheckedMap.keySet();
RepositoryNode[] tableNodesFromMap = keySet.toArray(new RepositoryNode[keySet.size()]);
List<RepositoryNode> allcheckedTableNodes = new ArrayList<RepositoryNode>();
for (Object checkElement : this.getTreeViewer().getCheckedElements()) {
if ((checkElement instanceof DBTableRepNode || checkElement instanceof DBViewRepNode || checkElement instanceof DFTableRepNode) && ((RepositoryNode) checkElement).getId() != null) {
allcheckedTableNodes.add((RepositoryNode) checkElement);
}
}
for (RepositoryNode node : tableNodesFromMap) {
if (node.getId() == null) {
continue;
}
if (!allcheckedTableNodes.contains(node)) {
allcheckedTableNodes.add(node);
}
}
return allcheckedTableNodes;
}
Aggregations