use of org.talend.dq.nodes.DBViewRepNode 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.DBViewRepNode 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;
}
use of org.talend.dq.nodes.DBViewRepNode in project tdq-studio-se by Talend.
the class ColumnsSelectionDialog method getAllCheckElements.
protected void getAllCheckElements() {
// Added TDQ-8718 20140506 yyin: should not load from DB(connect) when get checked elements
DQDBFolderRepositoryNode.setCallingFromColumnDialog(true);
DQDBFolderRepositoryNode.setLoadDBFromDialog(false);
try {
Object[] checkedNodes = this.getTreeViewer().getCheckedElements();
for (Object checkedNode : checkedNodes) {
IRepositoryNode repNode = (IRepositoryNode) checkedNode;
if (repNode instanceof DBColumnRepNode || repNode instanceof DFColumnRepNode) {
if (!allCheckedElements.contains(repNode)) {
allCheckedElements.add(repNode);
}
} else if (repNode instanceof DFTableRepNode || repNode instanceof DBTableRepNode || repNode instanceof DBViewRepNode) {
if (!getTableviewCheckedElements(allCheckedElements, repNode)) {
List<IRepositoryNode> children = repNode.getChildren().get(0).getChildren();
for (IRepositoryNode node : children) {
if (!allCheckedElements.contains(node)) {
allCheckedElements.add(node);
}
}
}
}
}
} finally {
// Added TDQ-8718 20140506 yyin
DQDBFolderRepositoryNode.setCallingFromColumnDialog(false);
DQDBFolderRepositoryNode.setLoadDBFromDialog(true);
}
// ADD msjian 2011-7-8 feature 22206: Add filters
Iterator<?> it = modelElementCheckedMap.keySet().iterator();
while (it.hasNext()) {
RepositoryNode reposNode = (RepositoryNode) it.next();
List<?> columnList = (ArrayList<?>) modelElementCheckedMap.get(reposNode);
for (int i = 0; i < columnList.size(); i++) {
if (columnList.get(i) instanceof DBColumnRepNode || columnList.get(i) instanceof DFColumnRepNode) {
if (!allCheckedElements.contains(columnList.get(i))) {
allCheckedElements.add((IRepositoryNode) columnList.get(i));
}
}
}
}
}
use of org.talend.dq.nodes.DBViewRepNode in project tdq-studio-se by Talend.
the class SemanticDiscoveryActionProvider method fillContextMenu.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
public void fillContextMenu(IMenuManager menu) {
// MOD mzhao user readonly role on svn repository mode.
if (!isShowMenu()) {
return;
}
TreeSelection currentSelection = ((TreeSelection) this.getContext().getSelection());
Object firstElement = currentSelection.getFirstElement();
boolean selectedMoreThanOne = currentSelection.size() > 1;
// keep all of columns belong to same one table and create SemanticDiscoveryAction.
if (selectedMoreThanOne || firstElement instanceof ColumnRepNode) {
Set<String> currentTableSet = new HashSet<String>();
MetadataTable createTable = ConnectionFactory.eINSTANCE.createMetadataTable();
List<String> filterNames = new ArrayList<String>();
Iterator<Object> columnIterator = currentSelection.iterator();
while (columnIterator.hasNext()) {
Object columnNode = columnIterator.next();
MetadataColumn metadataColumn = null;
if (DBColumnRepNode.class.isInstance(columnNode)) {
metadataColumn = ((DBColumnRepNode) columnNode).getTdColumn();
createTable = ColumnHelper.getColumnOwnerAsMetadataTable(metadataColumn);
} else if (DFColumnRepNode.class.isInstance(columnNode)) {
metadataColumn = ((DFColumnRepNode) columnNode).getMetadataColumn();
createTable = ColumnHelper.getColumnOwnerAsMetadataTable(metadataColumn);
} else {
// If not all of elements which be selected is columns
return;
}
currentTableSet.add(ResourceHelper.getUUID(createTable));
// all of columns should come from same table
if (currentTableSet.size() > 1) {
return;
}
filterNames.add(metadataColumn.getName());
}
MetadataTable metadataTableWithFilter = new MetadataTableWithFilter(filterNames, createTable);
semanticDiscoveryAction = new SemanticDiscoveryAction(metadataTableWithFilter);
} else {
// otherwise the selection is valid, only two possible status: only one columnset is select.
if (firstElement instanceof DBTableRepNode) {
DBTableRepNode node = (DBTableRepNode) firstElement;
semanticDiscoveryAction = new SemanticDiscoveryAction(node.getTdTable());
} else if (firstElement instanceof DBViewRepNode) {
DBViewRepNode node = (DBViewRepNode) firstElement;
semanticDiscoveryAction = new SemanticDiscoveryAction(node.getTdView());
} else if (firstElement instanceof DFTableRepNode) {
DFTableRepNode node = (DFTableRepNode) firstElement;
semanticDiscoveryAction = new SemanticDiscoveryAction(node.getMetadataTable());
}
}
menu.add(semanticDiscoveryAction);
}
use of org.talend.dq.nodes.DBViewRepNode in project tdq-studio-se by Talend.
the class OverviewResultPage method runTableAnalysis.
/**
* run TableAnalysis with view name.
*
* @param viewName
*/
protected void runTableAnalysis(String viewName) {
Package parentPack = (Package) currentSelectionSchemaIndicator.getAnalyzedElement();
TdView tdView = getView(parentPack, viewName);
if (null == tdView) {
FolderNodeHelper.getTableFolderNode(parentPack).loadChildren();
tdView = getView(parentPack, viewName);
}
DBViewRepNode dbViewRepNode = RepositoryNodeHelper.recursiveFindTdView(tdView);
new AnalyzeColumnSetAction(dbViewRepNode).run();
}
Aggregations