use of org.talend.dq.nodes.DBTableRepNode 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.DBTableRepNode 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.DBTableRepNode in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method createDBTableRepNode.
/**
* DOC talend Comment method "createDBTableRepNode".
*
* @param findModelElement
* @return
*/
private static RepositoryNode createDBTableRepNode(TdTable findModelElement, IRepositoryViewObject lastVersion) {
TdTableRepositoryObject tdTableRepositoryObject = new TdTableRepositoryObject(lastVersion, findModelElement);
tdTableRepositoryObject.setId(findModelElement.getName());
tdTableRepositoryObject.setLabel(findModelElement.getName());
DBTableRepNode dbTableRepNode = new DBTableRepNode(tdTableRepositoryObject, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
dbTableRepNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_COLUMN);
dbTableRepNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_COLUMN);
tdTableRepositoryObject.setRepositoryNode(dbTableRepNode);
return dbTableRepNode;
}
use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method recursiveFindTdTable.
public static DBTableRepNode recursiveFindTdTable(TdTable tdTable) {
if (tdTable == null) {
return null;
}
String uuidTdTable = getUUID(tdTable);
if (uuidTdTable == null) {
return null;
}
IRepositoryNode schemaOrCatalogNode = recursiveFind(ColumnSetHelper.getParentCatalogOrSchema(tdTable));
if (schemaOrCatalogNode == null) {
return null;
}
List<IRepositoryNode> childrens = schemaOrCatalogNode.getChildren();
List<IRepositoryNode> children = null;
if (!childrens.isEmpty()) {
children = childrens.get(0).getChildren();
}
if (null != children && children.size() > 0) {
IRepositoryNode iRepositoryNode = children.get(0);
if (iRepositoryNode != null && iRepositoryNode instanceof DBTableRepNode) {
for (IRepositoryNode childNode : children) {
if (childNode != null && childNode instanceof DBTableRepNode) {
DBTableRepNode dbTableRepNode = (DBTableRepNode) childNode;
if (uuidTdTable.equals(getUUID(dbTableRepNode.getTdTable()))) {
return dbTableRepNode;
}
}
}
}
}
return null;
}
use of org.talend.dq.nodes.DBTableRepNode in project tdq-studio-se by Talend.
the class PreviewProvider 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 treeSelection = ((TreeSelection) this.getContext().getSelection());
Object firstElement = treeSelection.getFirstElement();
NamedColumnSet set = null;
if (firstElement instanceof DBTableRepNode) {
set = ((DBTableRepNode) firstElement).getTdTable();
} else if (firstElement instanceof DBViewRepNode) {
set = ((DBViewRepNode) firstElement).getTdView();
}
if (set != null) {
PreviewAction action = new PreviewAction(set);
menu.add(action);
}
}
Aggregations