Search in sources :

Example 41 with IndicatorUnit

use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.

the class DateFrequencyStateUtilTest method setUp.

@Before
public void setUp() throws Exception {
    mapVal2Freq = new HashMap<Object, Long>();
    mapVal2Freq.put(1993, 4L);
    mapVal2Freq.put(1994, 23L);
    mapVal2Freq.put(1996, 15L);
    mapVal2Freq.put(1999, 11L);
    yearLowFrequencyIndicator = IndicatorsFactory.eINSTANCE.createYearLowFrequencyIndicator();
    yearLowFrequencyIndicator.setValueToFreq(mapVal2Freq);
    yearLowFrequencyIndicator.setComputed(true);
    units = new ArrayList<IndicatorUnit>();
    ModelElementIndicator modelElementIndicator = UnitTestBuildHelper.createModelElementIndicator();
    ColumnIndicatorUnit columnIndicatorUnit = new ColumnIndicatorUnit(IndicatorEnum.YearLowFrequencyIndicatorEnum, yearLowFrequencyIndicator, modelElementIndicator);
    units.add(columnIndicatorUnit);
}
Also used : ColumnIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.ColumnIndicatorUnit) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ColumnIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.ColumnIndicatorUnit) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) Before(org.junit.Before)

Example 42 with IndicatorUnit

use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.

the class PatternStatisticsStateTest method setUp.

/**
 * init the state.
 *
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    List<IndicatorUnit> units = new ArrayList<IndicatorUnit>();
    RegexpMatchingIndicator indicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
    // $NON-NLS-1$
    indicator.setName("Blank text");
    indicator.setComputed(true);
    units.add(new ColumnSetIndicatorUnit(IndicatorEnum.AllMatchIndicatorEnum, indicator));
    patternStatisticsState = new PatternStatisticsState(units);
}
Also used : IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ColumnSetIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.ColumnSetIndicatorUnit) ArrayList(java.util.ArrayList) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) ColumnSetIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.ColumnSetIndicatorUnit) Before(org.junit.Before)

Example 43 with IndicatorUnit

use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.

the class AnalysisColumnTreeViewer method moveSelectedElements.

/**
 * DOC yyi 7466 2010-03-22 change the order of appearence of indicators.
 *
 * @param newTree
 * @param step
 */
protected void moveSelectedElements(Tree newTree, int step) {
    TreeItem[] selection = newTree.getSelection();
    if (selection != null) {
        // used to set the selected columns focus at last
        List<Object> selectedDataList = new ArrayList<Object>();
        // TDQ-11530 msjian: get all selected data's list first to check how to move
        List<IndicatorUnit> indicatorUnitList = new ArrayList<IndicatorUnit>();
        List<ModelElementIndicator> dataList = new ArrayList<ModelElementIndicator>();
        for (TreeItem item : selection) {
            IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
            if (indicatorUnit != null) {
                indicatorUnitList.add(indicatorUnit);
            } else {
                ModelElementIndicator data = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
                dataList.add(data);
            }
        }
        for (TreeItem item : selection) {
            IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
            ModelElementIndicator data = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
            if (indicatorUnit != null) {
                TypedReturnCode<IndicatorUnit[]> code = sortIndicatorUnits(data.getIndicatorUnits(), indicatorUnit, step, indicatorUnitList);
                if (code.isOk()) {
                    if (null != code.getObject()) {
                        Indicator[] inds = new Indicator[code.getObject().length];
                        for (int i = 0; i < code.getObject().length; i++) {
                            inds[i] = code.getObject()[i].getIndicator();
                        }
                        data.setIndicators(inds);
                    }
                    selectedDataList.add(indicatorUnit);
                }
            } else {
                int index = ArrayUtils.indexOf(modelElementIndicators, data);
                int changeIndex = index + step;
                if (changeIndex > -1 && changeIndex < modelElementIndicators.length) {
                    ModelElementIndicator tmpElement = modelElementIndicators[changeIndex];
                    // when the changed one is the selected one too, get next one
                    while (dataList.contains(tmpElement)) {
                        tmpElement = modelElementIndicators[++changeIndex];
                    }
                    modelElementIndicators[changeIndex] = modelElementIndicators[index];
                    modelElementIndicators[index] = tmpElement;
                    // after the data changed successfully remove it from the selected list
                    dataList.remove(data);
                    selectedDataList.add(data);
                }
            }
        }
        setElements(modelElementIndicators, true, false);
        for (Object obj : selectedDataList) {
            selectElement(tree.getItems(), obj);
        }
        masterPage.synNagivatorStat();
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ArrayList(java.util.ArrayList) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) DelimitedFileIndicator(org.talend.dataprofiler.core.model.DelimitedFileIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataXmlElementTypeRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 44 with IndicatorUnit

use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit 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;
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Set(java.util.Set) HashSet(java.util.HashSet) TreeEditor(org.eclipse.swt.custom.TreeEditor) CheckedTreeSelectionDialog(org.eclipse.ui.dialogs.CheckedTreeSelectionDialog) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) DelimitedFileIndicator(org.talend.dataprofiler.core.model.DelimitedFileIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) List(java.util.List) ArrayList(java.util.ArrayList) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataXmlElementTypeRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Example 45 with IndicatorUnit

use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.

the class ModelElementTreeMenuProvider method viewQueryForSelectedElement.

/**
 * DOC mzhao Comment method "viewQueryForSelectedElement".
 *
 * @param newTree
 */
private void viewQueryForSelectedElement(Tree newTree) {
    TreeItem[] selection = newTree.getSelection();
    for (TreeItem item : selection) {
        ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(AbstractColumnDropTree.MODELELEMENT_INDICATOR_KEY);
        ConnectionItem connItem = (ConnectionItem) meIndicator.getModelElementRepositoryNode().getObject().getProperty().getItem();
        Connection dataprovider = connItem.getConnection();
        IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(AbstractColumnDropTree.INDICATOR_UNIT_KEY);
        DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
        Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
        if (expression == null) {
            MessageDialogWithToggle.openWarning(null, DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.Warn"), // $NON-NLS-1$ //$NON-NLS-2$
            DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.NoQueryDefined"));
            return;
        }
        SqlExplorerUtils.getDefault().runInDQViewer(dataprovider, expression.getBody(), meIndicator.getModelElementRepositoryNode().getObject().getProperty().getLabel());
    }
}
Also used : DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) TreeItem(org.eclipse.swt.widgets.TreeItem) Expression(orgomg.cwm.objectmodel.core.Expression) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Connection(org.talend.core.model.metadata.builder.connection.Connection) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ColumnIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.ColumnIndicatorUnit) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Aggregations

IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)54 ArrayList (java.util.ArrayList)24 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)17 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)17 ColumnIndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.ColumnIndicatorUnit)13 CustomerDefaultCategoryDataset (org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset)10 TreeItem (org.eclipse.swt.widgets.TreeItem)9 Indicator (org.talend.dataquality.indicators.Indicator)9 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 FrequencyExt (org.talend.dq.indicators.ext.FrequencyExt)7 BoxIndicator (org.talend.dataquality.indicators.BoxIndicator)5 CountsIndicator (org.talend.dataquality.indicators.CountsIndicator)5 IQRIndicator (org.talend.dataquality.indicators.IQRIndicator)5 PhoneNumbStatisticsIndicator (org.talend.dataquality.indicators.PhoneNumbStatisticsIndicator)5 IRepositoryNode (org.talend.repository.model.IRepositoryNode)5 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)4 ColumnSetIndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.ColumnSetIndicatorUnit)4 IndicatorEnum (org.talend.dq.nodes.indicator.type.IndicatorEnum)4 IChartTypeStates (org.talend.dataprofiler.core.ui.editor.preview.model.states.IChartTypeStates)3 AverageLengthIndicator (org.talend.dataquality.indicators.AverageLengthIndicator)3