use of org.talend.dq.nodes.ColumnRepNode in project tdq-studio-se by Talend.
the class NumericalDPSelectionPage method addListeners.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.wizard.analysis.column.ColumnAnalysisDOSelectionPage#addListeners()
*/
@Override
protected void addListeners() {
addListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
nodes = new ArrayList<IRepositoryNode>();
if (object instanceof ColumnRepNode) {
// only support interger type
RepositoryNode repositoryNode = (ColumnRepNode) object;
nodes.add(repositoryNode);
if (RepNodeUtils.isAllNumberalColumns(nodes)) {
advanceToNextPageOrFinish();
}
}
}
});
addListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
try {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
nodes = new ArrayList<IRepositoryNode>();
if (object instanceof ColumnRepNode) {
List<IRepositoryNode> list = ((IStructuredSelection) event.getSelection()).toList();
nodes.addAll(list);
if (nodes.size() == 0 || RepNodeUtils.isValidSelectionFromSameTable(nodes)) {
if (RepNodeUtils.isAllNumberalColumns(nodes)) {
setPageComplete(true);
setMessage(chooseConnStr);
} else {
setPageComplete(false);
setMessage(DefaultMessagesImpl.getString("ColumnAnalysisDOSelectionPage.selectColumnError2"), // $NON-NLS-1$
ERROR);
}
} else {
setPageComplete(false);
// $NON-NLS-1$
setMessage(DefaultMessagesImpl.getString("ColumnAnalysisDOSelectionPage.selectColumnError1"), ERROR);
}
} else {
setPageComplete(false);
setMessage(chooseConnStr);
}
} catch (Exception e) {
log.error(e, e);
}
}
});
}
use of org.talend.dq.nodes.ColumnRepNode in project tdq-studio-se by Talend.
the class MatchWizard method updateAnalysisBySelectedNode.
// when calling this method, the validation of the selection has been approved.the nodes will only contains one
// column set, or some columns from one same column set.
private void updateAnalysisBySelectedNode(AnalysisEditor editor) {
MatchAnalysisDetailsPage masterPage = (MatchAnalysisDetailsPage) editor.getMasterPage();
List<IRepositoryNode> nodes = selectionPage.nodes;
if (nodes != null && nodes.size() > 0) {
// if the first selected node is not column type(there should only one column set in the selected node then)
if (!(nodes.get(0) instanceof ColumnRepNode)) {
nodes = ((ColumnSetRepNode) nodes.get(0)).getAllColumns();
}
// update analyze data label by selected nodes names(don't cotain columnRepNode).
if (nodes.size() > 0) {
masterPage.updateAnalyzeDataLabel(nodes.get(0));
}
// give the selected columns to the master page
masterPage.setSelectedNodes(nodes.toArray(new RepositoryNode[nodes.size()]));
masterPage.doSave(new NullProgressMonitor());
masterPage.updateAllColumnsToKeySection();
}
}
use of org.talend.dq.nodes.ColumnRepNode in project tdq-studio-se by Talend.
the class NominalValuesDPSelectionPage method addListeners.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.wizard.analysis.column.ColumnAnalysisDOSelectionPage#addListeners()
*/
@Override
protected void addListeners() {
addListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (object instanceof ColumnRepNode) {
RepositoryNode repositoryNode = (ColumnRepNode) object;
DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
// int javaSQLType = TalendTypeConvert.convertToJDBCType(column.getTalendType());
if (Java2SqlType.isTextInSQL(javaSQLType)) {
advanceToNextPageOrFinish();
} else {
List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
tempList.add(columnNode);
setAddTextIndicator(false);
if (!tempList.isEmpty()) {
ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
dialog.setElements(tempList.toArray());
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
dialog.setSize(80, 20);
dialog.create();
if (Window.OK == dialog.open()) {
// use MetadataHelper
for (DFColumnRepNode col : tempList) {
MetadataHelper.setDataminingType(DataminingType.NOMINAL, col.getMetadataColumn());
}
advanceToNextPageOrFinish();
}
}
}
}
}
});
addListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
try {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
nodes = new ArrayList<IRepositoryNode>();
if (object instanceof ColumnRepNode) {
List<IRepositoryNode> list = ((IStructuredSelection) event.getSelection()).toList();
nodes.addAll(list);
if (nodes.size() == 0 || RepNodeUtils.isValidSelectionFromSameTable(nodes)) {
List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
for (IRepositoryNode obj : nodes) {
if (object instanceof ColumnRepNode) {
RepositoryNode repositoryNode = (ColumnRepNode) obj;
DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
if (!Java2SqlType.isTextInSQL(javaSQLType)) {
tempList.add(columnNode);
setAddTextIndicator(false);
}
}
}
if (!tempList.isEmpty()) {
ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
dialog.setElements(tempList.toArray());
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
dialog.setSize(80, 20);
dialog.create();
if (Window.OK == dialog.open()) {
// zqin get the column and change their datamining type to "Nominal"
for (DFColumnRepNode column : tempList) {
MetadataHelper.setDataminingType(DataminingType.NOMINAL, column.getMetadataColumn());
}
setPageComplete(true);
setMessage(chooseConnStr);
}
} else {
setPageComplete(true);
setMessage(chooseConnStr);
}
} else {
setPageComplete(false);
// $NON-NLS-1$
setMessage(DefaultMessagesImpl.getString("ColumnAnalysisDOSelectionPage.selectColumnError1"), ERROR);
}
} else {
setPageComplete(false);
setMessage(chooseConnStr);
}
} catch (Exception e) {
log.error(e, e);
}
}
});
}
use of org.talend.dq.nodes.ColumnRepNode 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.ColumnRepNode in project tdq-studio-se by Talend.
the class MatchAnalysisDetailsPage method updateAllKeys.
/**
* if some columns are deleted : remove the blocking/match key which used this column ; if some column still there :
* update the index info in their keys; if some new columns added : do nothing
*
* @param oldSelectedColumns
*/
private void updateAllKeys(List<IRepositoryNode> oldSelectedColumns) {
for (IRepositoryNode oldSelectNode : oldSelectedColumns) {
int newPosition = positionInNewSelectColumns(oldSelectNode);
if (newPosition > -1) {
// update the position of the column
addColumnGivenIndex(oldSelectNode, newPosition);
} else {
// delete all keys which used this column
if (selectAlgorithmSection.isVSRMode()) {
matchingKeySection.removeKeyFromAllTab(oldSelectNode.getLabel());
} else {
matchAndSurvivorKeySection.removeKeyFromAllTab(oldSelectNode.getLabel());
}
blockingKeySection.removeBlockingKey(oldSelectNode.getLabel());
this.particularDefaultSurvivorshipSection.removeParticularKey(oldSelectNode.getLabel());
}
}
// add new columns
for (IRepositoryNode selectedOne : this.selectedNodes) {
if (!oldSelectedColumns.contains(selectedOne)) {
// the old doesnot contain the current, it need to be added to the columnMap
int positionInNewSelectColumns = positionInNewSelectColumns(selectedOne);
if (selectedOne instanceof ColumnRepNode) {
addColumnGivenIndex(selectedOne, positionInNewSelectColumns);
} else if (selectedOne instanceof ColumnSetRepNode) {
List<IRepositoryNode> colNodes = ((ColumnSetRepNode) selectedOne).getAllColumns();
for (IRepositoryNode colNode : colNodes) {
addColumnGivenIndex(colNode, positionInNewSelectColumns);
}
}
}
}
if (selectAlgorithmSection.isVSRMode()) {
this.matchingKeySection.redrawnSubTableContent();
} else {
matchAndSurvivorKeySection.redrawnSubTableContent();
}
this.blockingKeySection.redrawnSubTableContent();
this.particularDefaultSurvivorshipSection.redrawnSubTableContent();
}
Aggregations