use of org.talend.dataquality.indicators.sql.UserDefIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method addColumnUdi.
/**
* DOC xqliu Comment method "addColumnUdi". ADD xqliu 2010-02-23 feature 11617
*
* @param treeItem
* @param meIndicator
* @param columnIndex
* @return
*/
private TreeEditor addColumnUdi(final TreeItem treeItem, final ModelElementIndicator meIndicator, int columnIndex) {
TreeEditor addUdiEditor = new TreeEditor(tree);
// $NON-NLS-1$
Label addUdiLabl = createTreeItemLabel(tree, ImageLib.ADD_IND_DEFINITION, "AnalysisColumnTreeViewer.addUdi");
addUdiLabl.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
DataManager dm = getAnalysis().getContext().getConnection();
if (dm == null) {
masterPage.doSave(null);
}
CheckedTreeSelectionDialog dialog = UDIUtils.createUdiCheckedTreeSelectionDialog(meIndicator);
if (dialog.open() == Window.OK) {
// MOD qiongli 2012-10-24 TDQ-6308,just remove some deselected indicatorUnit then set dirty to
// true,just create new indicatorUnit for some new added UDI then set dirty to true.
List<IndicatorDefinition> allSelectedIndicatorDefinitions = new ArrayList<IndicatorDefinition>();
Set<String> allSelectedIndNames = new HashSet<String>();
for (Object obj : dialog.getResult()) {
if (obj instanceof SysIndicatorDefinitionRepNode) {
IndicatorDefinition udid = ((SysIndicatorDefinitionRepNode) obj).getIndicatorDefinition();
allSelectedIndicatorDefinitions.add(udid);
if (udid != null) {
allSelectedIndNames.add(udid.getName());
}
}
}
Set<String> oldSelectedIndNames = new HashSet<String>();
for (IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
Indicator indicator = indicatorUnit.getIndicator();
if (indicator instanceof UserDefIndicator) {
if (allSelectedIndNames.contains(indicator.getName())) {
oldSelectedIndNames.add(indicator.getName());
} else {
// remove the UDI from UI need to insert this UDI into removeList
deleteIndicatorItems(meIndicator, indicatorUnit);
if (!isDirty()) {
setDirty(true);
}
}
}
}
treeItem.removeAll();
for (IndicatorDefinition udid : allSelectedIndicatorDefinitions) {
if (udid != null && oldSelectedIndNames.contains(udid.getName())) {
continue;
}
IndicatorUnit[] addIndicatorUnits = null;
try {
addIndicatorUnits = UDIUtils.createIndicatorUnit(udid, meIndicator, getAnalysis());
} catch (Throwable e1) {
log.warn(e1, e1);
}
if (addIndicatorUnits != null && addIndicatorUnits.length > 0) {
for (IndicatorUnit unit : addIndicatorUnits) {
createOneUnit(treeItem, unit);
}
if (!isDirty()) {
setDirty(true);
}
}
}
treeItem.setExpanded(true);
masterPage.refreshTheTree(masterPage.getCurrentModelElementIndicators());
}
}
});
addUdiEditor.minimumWidth = addUdiLabl.getImage().getBounds().width;
addUdiEditor.setEditor(addUdiLabl, treeItem, columnIndex);
return addUdiEditor;
}
use of org.talend.dataquality.indicators.sql.UserDefIndicator in project tdq-studio-se by Talend.
the class ModelElementTreeMenuProvider method editUDIndicator.
/**
* DOC yyi Comment method "editUDIndicator" 2009-09-04.
*
* @param tree
*/
private void editUDIndicator(Tree tree) {
TreeItem[] selection = tree.getSelection();
if (selection.length > 0) {
TreeItem treeItem = selection[0];
IndicatorUnit indicatorUnit = (IndicatorUnit) treeItem.getData(AbstractColumnDropTree.INDICATOR_UNIT_KEY);
UserDefIndicator indicator = (UserDefIndicator) indicatorUnit.getIndicator();
IFile file = ResourceFileMap.findCorrespondingFile(indicator.getIndicatorDefinition());
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
activePage.openEditor(new FileEditorInput(file), // $NON-NLS-1$
"org.talend.dataprofiler.core.ui.editor.indicator.IndicatorEditor");
} catch (PartInitException e1) {
log.error(e1, e1);
}
}
}
use of org.talend.dataquality.indicators.sql.UserDefIndicator in project tdq-studio-se by Talend.
the class IndicatorEvaluator method getMessageForInvalidJUDIs.
/**
* check each UDI if has realted java expression(class) for Java Engine,remove it from elementToIndicators(no need
* to compute),then populate the message
*
* @param analysis
* @return
*/
protected ReturnCode getMessageForInvalidJUDIs() {
ReturnCode ret = new ReturnCode(Boolean.TRUE);
Set<String> invalidUdiNames = new HashSet<String>();
Set<String> columns = elementToIndicators.keySet();
Iterator<String> colIt = columns.iterator();
while (colIt.hasNext()) {
String nextCol = colIt.next();
List<Indicator> indicators = elementToIndicators.get(nextCol);
List<Indicator> needRemovedInds = new ArrayList<Indicator>();
for (Indicator ind : indicators) {
if (ind instanceof UserDefIndicator && UDIHelper.isJavaUDI(ind) && !UDIHelper.isJUDIValid(ind.getIndicatorDefinition())) {
invalidUdiNames.add(ind.getName());
needRemovedInds.add(ind);
}
}
if (!needRemovedInds.isEmpty()) {
indicators.removeAll(needRemovedInds);
allIndicators.removeAll(needRemovedInds);
}
}
if (!invalidUdiNames.isEmpty()) {
String message = invalidUdiNames.toString();
// $NON-NLS-1$
ret.setReturnCode(Messages.getString("IndicatorEvaluator.NoExpressionFound", message), false);
}
return ret;
}
Aggregations