use of org.talend.dataquality.rules.JoinElement in project tdq-studio-se by Talend.
the class JoinConditionTableViewer method addJoinElement.
/**
* DOC xqliu Comment method "addJoinElement".
*
* @return
*/
public JoinElement addJoinElement() {
JoinElement newJoinElement = RulesFactory.eINSTANCE.createJoinElement();
newJoinElement.setOperator(PluginConstant.DEFAULT_OPERATOR);
this.myTableViewer.add(newJoinElement);
this.myJoinElement.add(newJoinElement);
this.masterPage.setDirty(true);
return newJoinElement;
}
use of org.talend.dataquality.rules.JoinElement in project tdq-studio-se by Talend.
the class DQRuleMasterDetailsPage method createButtons.
/**
* DOC xqliu Comment method "createButtons".
*
* @param parent
*/
private void createButtons(Composite parent, final JoinConditionTableViewer jcTableViewer) {
Composite buttonsComposite = new Composite(parent, SWT.NONE);
buttonsComposite.setLayout(new GridLayout(2, false));
GridData labelGd = new GridData();
labelGd.horizontalAlignment = SWT.LEFT;
labelGd.widthHint = 30;
final Button addButton = new Button(buttonsComposite, SWT.NONE);
addButton.setImage(ImageLib.getImage(ImageLib.ADD_ACTION));
addButton.setLayoutData(labelGd);
addButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
jcTableViewer.addJoinElement();
}
});
final Button delButton = new Button(buttonsComposite, SWT.NONE);
delButton.setImage(ImageLib.getImage(ImageLib.DELETE_ACTION));
delButton.setLayoutData(labelGd);
delButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
JoinElement join = (JoinElement) ((IStructuredSelection) jcTableViewer.getSelection()).getFirstElement();
if (join != null) {
jcTableViewer.removeJoinElement(join);
}
}
});
}
use of org.talend.dataquality.rules.JoinElement in project tdq-studio-se by Talend.
the class DQRuleMasterDetailsPage method createAddButton.
/**
* DOC xqliu Comment method "createAddButton".
*
* @param parent top composite
*/
private void createAddButton(Composite parent) {
final Button addButton = new Button(parent, SWT.NONE);
addButton.setImage(ImageLib.getImage(ImageLib.ADD_ACTION));
// $NON-NLS-1$
addButton.setToolTipText(DefaultMessagesImpl.getString("DQRuleMasterDetailsPage.add"));
GridData labelGd = new GridData();
labelGd.horizontalAlignment = SWT.CENTER;
labelGd.widthHint = 65;
addButton.setLayoutData(labelGd);
addButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
JoinElement newJoinElement = RulesFactory.eINSTANCE.createJoinElement();
newJoinElement.setOperator(PluginConstant.DEFAULT_OPERATOR);
creatNewJoinElementLine(newJoinElement);
tempJoinElements.add(newJoinElement);
joinConditionSection.setExpanded(true);
setDirty(true);
}
});
}
use of org.talend.dataquality.rules.JoinElement in project tdq-studio-se by Talend.
the class DQRuleMasterDetailsPage method checkValus.
/**
* DOC xqliu Comment method "checkValus".
*
* @return
*/
private boolean checkValus() {
boolean ret = true;
// $NON-NLS-1$
String msg = "";
String cl = getCriticalityLevelText().getText();
if (cl == null || "".equals(cl)) {
// $NON-NLS-1$
ret = false;
// $NON-NLS-1$ //$NON-NLS-2$
msg += DefaultMessagesImpl.getString("DQRuleMasterDetailsPage.criticalityLevelIsEmpty") + "\n";
} else {
try {
int i = Integer.valueOf(cl).intValue();
if (!(i >= PluginConstant.CRITICALITY_LEVEL_MIN && i <= PluginConstant.CRITICALITY_LEVEL_MAX)) {
ret = false;
// $NON-NLS-1$ //$NON-NLS-2$
msg += DefaultMessagesImpl.getString("DQRuleMasterDetailsPage.criticalityLevelIsInvalid") + "\n";
}
} catch (NumberFormatException e) {
ret = false;
// $NON-NLS-1$ //$NON-NLS-2$
msg += DefaultMessagesImpl.getString("DQRuleMasterDetailsPage.criticalityLevelIsInvalid") + "\n";
}
}
String wh = getWhereText().getText();
if (wh == null || "".equals(wh)) {
// $NON-NLS-1$
ret = false;
// $NON-NLS-1$ //$NON-NLS-2$
msg += DefaultMessagesImpl.getString("DQRuleMasterDetailsPage.whereClauseIsEmpty") + "\n";
} else {
if (wh.startsWith(PluginConstant.WHERE)) {
ret = false;
// $NON-NLS-1$ //$NON-NLS-2$
msg += DefaultMessagesImpl.getString("DQRuleMasterDetailsPage.whereClauseIsInvalid") + "\n";
}
}
for (JoinElement join : this.tempJoinElements) {
String tableAliasA = join.getTableAliasA();
String tableAliasB = join.getTableAliasB();
if (tableAliasA == null || "".equals(tableAliasA) || tableAliasB == null || "".equals(tableAliasB)) {
// $NON-NLS-1$ //$NON-NLS-2$
ret = false;
// $NON-NLS-1$ //$NON-NLS-2$
msg += DefaultMessagesImpl.getString("DQRuleMasterDetailsPage.emptyTableAlias") + "\n";
break;
} else if (tableAliasA.equals(tableAliasB)) {
ret = false;
String tableA = ColumnHelper.getColumnSetOwner(join.getColA()).getName();
String tableB = ColumnHelper.getColumnSetOwner(join.getColB()).getName();
// $NON-NLS-1$ //$NON-NLS-2$
msg += DefaultMessagesImpl.getString("DQRuleMasterDetailsPage.sameTableAlias", tableA, tableB) + "\n";
} else {
if (!checkAlias(tableAliasA)) {
ret = false;
// $NON-NLS-1$ //$NON-NLS-2$
msg += DefaultMessagesImpl.getString("DQRuleMasterDetailsPage.invalidAliasName", tableAliasA) + "\n";
}
if (!checkAlias(tableAliasB)) {
ret = false;
// $NON-NLS-1$ //$NON-NLS-2$
msg += DefaultMessagesImpl.getString("DQRuleMasterDetailsPage.invalidAliasName", tableAliasB) + "\n";
}
}
}
if (!ret) {
MessageUI.openWarning(msg);
}
return ret;
}
use of org.talend.dataquality.rules.JoinElement in project tdq-studio-se by Talend.
the class ChartTableFactory method addMenuAndTip.
public static void addMenuAndTip(final TableViewer tbViewer, final IDataExplorer explorer, final Analysis analysis) {
final Table table = tbViewer.getTable();
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
// MOD xqliu 2009-05-11 bug 6561
if (table.getMenu() != null) {
table.getMenu().setVisible(false);
}
if (e.button == 3) {
StructuredSelection selection = (StructuredSelection) tbViewer.getSelection();
final ChartDataEntity dataEntity = (ChartDataEntity) selection.getFirstElement();
final Indicator indicator = dataEntity != null ? dataEntity.getIndicator() : null;
if (indicator != null && dataEntity != null) {
Menu menu = new Menu(table.getShell(), SWT.POP_UP);
table.setMenu(menu);
MenuItemEntity[] itemEntities = ChartTableMenuGenerator.generate(explorer, analysis, dataEntity);
if (ExecutionLanguage.SQL == analysis.getParameters().getExecutionLanguage()) {
boolean showExtraMenu = false;
for (final MenuItemEntity itemEntity : itemEntities) {
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText(itemEntity.geti18nLabel());
item.setImage(itemEntity.getIcon());
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e1) {
// DBMSLanguage.
if (isPatternMatchingIndicator(indicator) && !((PatternExplorer) explorer).isImplementRegexFunction(itemEntity.getLabel())) {
MessageDialog.openInformation(null, itemEntity.getLabel(), // $NON-NLS-1$
DefaultMessagesImpl.getString("ChartTableFactory.NoSupportPatternTeradata"));
return;
}
String query = itemEntity.getQuery();
String editorName = indicator.getName();
Connection tdDataProvider = (Connection) analysis.getContext().getConnection();
SqlExplorerUtils.getDefault().runInDQViewer(tdDataProvider, query, editorName);
}
});
// condition columns
if (IndicatorHelper.isWhereRuleIndicator(indicator)) {
// MOD yyin 20121126 TDQ-6477,show the menu only when Join condition exists
WhereRuleIndicator ind = (WhereRuleIndicator) indicator;
EList<JoinElement> joinConditions = ind.getJoinConditions();
if (joinConditions.size() > 0) {
showExtraMenu = true;
}
}
if (isPatternFrequencyIndicator(indicator) && !isEastAsiaPatternFrequencyIndicator(indicator)) {
createMenuOfGenerateRegularPattern(analysis, menu, dataEntity);
}
}
// show extra menu to create simple analysis, help user to find the duplicated rows
if (showExtraMenu) {
MenuItem itemCreateWhereRule = new MenuItem(menu, SWT.PUSH);
itemCreateWhereRule.setText(DefaultMessagesImpl.getString(// $NON-NLS-1$
"ChartTableFactory.JoinConditionColumnsAnalysis"));
itemCreateWhereRule.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e1) {
final StructuredSelection selectionOne = (StructuredSelection) tbViewer.getSelection();
// MOD xqliu 2012-05-11 TDQ-5314
Object firstElement = selectionOne.getFirstElement();
if (firstElement instanceof WhereRuleChartDataEntity) {
// get the WhereRuleIndicator
WhereRuleChartDataEntity wrChartDataEntity = (WhereRuleChartDataEntity) firstElement;
WhereRuleIndicator wrInd = (WhereRuleIndicator) wrChartDataEntity.getIndicator();
// run the CreateDuplicatesAnalysisAction
CreateDuplicatesAnalysisAction action = new CreateDuplicatesAnalysisAction(buildColumnsMap(wrInd));
action.run();
}
// ~ TDQ-5314
}
/**
* DOC xqliu Comment method "buildColumnsMap".
*
* @param wrInd
* @return
*/
private Map<ColumnSet, List<TdColumn>> buildColumnsMap(WhereRuleIndicator wrInd) {
Map<ColumnSet, List<TdColumn>> map = new HashMap<ColumnSet, List<TdColumn>>();
// get all columns from the WhereRuleIndicator
List<TdColumn> columns = new ArrayList<TdColumn>();
EList<JoinElement> joinConditions = wrInd.getJoinConditions();
for (JoinElement joinElement : joinConditions) {
// add left column
TdColumn tempColumn = (TdColumn) joinElement.getColA();
if (!columns.contains(tempColumn)) {
columns.add(tempColumn);
}
// add right column
tempColumn = (TdColumn) joinElement.getColB();
if (!columns.contains(tempColumn)) {
columns.add(tempColumn);
}
}
// build the map
for (TdColumn column : columns) {
ColumnSet columnSet = ColumnHelper.getColumnOwnerAsColumnSet(column);
List<TdColumn> list = map.get(columnSet);
if (list == null) {
list = new ArrayList<TdColumn>();
map.put(columnSet, list);
}
list.add(column);
}
// get the user selected map
return getUserSelectedMap(map);
}
/**
* DOC xqliu Comment method "getUserSelectedMap".
*
* @param map
* @return
*/
private Map<ColumnSet, List<TdColumn>> getUserSelectedMap(Map<ColumnSet, List<TdColumn>> map) {
Map<ColumnSet, List<TdColumn>> userMap = new HashMap<ColumnSet, List<TdColumn>>();
// get the column nodes
List<RepositoryNode> columnNodes = getColumnNodes(map);
// get the connection node
RepositoryNode rootNode = getConnectionNode(map);
// show the dialog, let user select the columns
if (!columnNodes.isEmpty() && rootNode != null) {
ColumnsMapSelectionDialog dialog = new ColumnsMapSelectionDialog(null, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), // $NON-NLS-1$
DefaultMessagesImpl.getString("ColumnsMapSelectionDialog.columnSelection"), // $NON-NLS-1$
columnNodes, // $NON-NLS-1$
rootNode, // $NON-NLS-1$
DefaultMessagesImpl.getString("ColumnsMapSelectionDialog.columnSelections"));
dialog.setAllMap(map);
if (dialog.open() == Window.OK) {
userMap = dialog.getUserMap();
}
}
return userMap;
}
/**
* DOC xqliu Comment method "getConnectionNode".
*
* @param map
* @return
*/
private RepositoryNode getConnectionNode(Map<ColumnSet, List<TdColumn>> map) {
RepositoryNode node = null;
if (map != null && !map.isEmpty()) {
Connection connection = ConnectionHelper.getConnection(map.keySet().iterator().next());
if (connection != null) {
node = RepositoryNodeHelper.recursiveFind(connection);
}
}
return node;
}
/**
* DOC xqliu Comment method "getColumnNodes".
*
* @param map
* @return
*/
private List<RepositoryNode> getColumnNodes(Map<ColumnSet, List<TdColumn>> map) {
List<RepositoryNode> nodes = new ArrayList<RepositoryNode>();
if (map != null && !map.isEmpty()) {
List<TdColumn> columns = new ArrayList<TdColumn>();
Set<ColumnSet> keySet = map.keySet();
for (ColumnSet cs : keySet) {
columns.addAll(map.get(cs));
}
if (!columns.isEmpty()) {
for (TdColumn column : columns) {
nodes.add(RepositoryNodeHelper.recursiveFind(column));
}
}
}
return nodes;
}
});
}
} else {
if (analysis.getParameters().isStoreData()) {
// if allow drill down
if (indicator.isUsedMapDBMode()) {
DrillDownUtils.createDrillDownMenuForMapDB(dataEntity, menu, itemEntities, analysis);
} else {
DrillDownUtils.createDrillDownMenuForJava(dataEntity, menu, itemEntities, analysis);
}
if (isPatternFrequencyIndicator(indicator) && !isEastAsiaPatternFrequencyIndicator(indicator)) {
for (final MenuItemEntity itemEntity : itemEntities) {
createMenuOfGenerateRegularPattern(analysis, menu, dataEntity);
}
}
}
// MOD by zshen feature 11574:add menu "Generate regular pattern" to date pattern
if (isDatePatternFrequencyIndicator(indicator)) {
final DatePatternFreqIndicator dateIndicator = (DatePatternFreqIndicator) indicator;
MenuItem itemCreatePatt = new MenuItem(menu, SWT.PUSH);
// $NON-NLS-1$
itemCreatePatt.setText(DefaultMessagesImpl.getString("ChartTableFactory.GenerateRegularPattern"));
itemCreatePatt.setImage(ImageLib.getImage(ImageLib.PATTERN_REG));
itemCreatePatt.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e1) {
DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage(analysis);
IFolder folder = ResourceManager.getPatternRegexFolder();
String model = dataEntity.getLabel();
String regex = dateIndicator.getRegex(model);
new CreatePatternAction(folder, ExpressionType.REGEXP, "'" + regex + "'", model == null ? "" : "match \"" + model + "\"", language.getDbmsName()).run();
}
});
}
}
addJobGenerationMenu(menu, analysis, indicator);
// ~11574
menu.setVisible(true);
}
}
}
});
// add tooltip
TableUtils.addTooltipForTable(table);
TableUtils.addActionTooltip(table);
}
Aggregations