Search in sources :

Example 31 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class AbstractPredefinedAnalysisAction method run.

@Override
public void run() {
    // do something before open the wizard
    if (preDo()) {
        WizardDialog dialog = getPredefinedDialog();
        if (dialog == null) {
            dialog = getStandardAnalysisWizardDialog();
        }
        dialog.setPageSize(500, 340);
        if (dialog.open() == Window.OK) {
            ModelElementIndicator[] predefinedColumnIndicator = getPredefinedColumnIndicator();
            if (predefinedColumnIndicator != null) {
                ColumnAnalysisDetailsPage masterPage = getMasterPage();
                if (masterPage != null) {
                    masterPage.refreshPreviewTable(predefinedColumnIndicator, false);
                    masterPage.refreshTheTree(predefinedColumnIndicator);
                    if (needChangeExecuteLanguageToJava()) {
                        masterPage.changeExecuteLanguageToJava(true);
                    }
                    masterPage.doSave(null);
                }
            }
        }
    }
}
Also used : WizardDialog(org.eclipse.jface.wizard.WizardDialog) ColumnAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.ColumnAnalysisDetailsPage) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 32 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class OpenIndicatorSelectorAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    AbstractColumnDropTree treeViewer = page.getTreeViewer();
    if (treeViewer instanceof AnalysisColumnTreeViewer) {
        AnalysisColumnTreeViewer columnTreeViewer = (AnalysisColumnTreeViewer) treeViewer;
        ModelElementIndicator[] modelElementIndicator = columnTreeViewer.openIndicatorSelectDialog(null);
        if (modelElementIndicator != null) {
            page.refreshCurrentTreeViewer(modelElementIndicator);
            if (columnTreeViewer.isGridPreviewColumnMoved()) {
                page.refreshPreviewTable(true);
            }
        }
    }
}
Also used : AbstractColumnDropTree(org.talend.dataprofiler.core.ui.editor.composite.AbstractColumnDropTree) AnalysisColumnTreeViewer(org.talend.dataprofiler.core.ui.editor.composite.AnalysisColumnTreeViewer) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 33 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class AbstractIndicatorSelectGrid method processNodeSelection.

/**
 * recursively check if a entire row/column is selected/
 *
 * @param grid
 * @param parentItem
 * @param currentItem
 */
void processNodeSelection(GridItem parentItem, GridItem currentItem) {
    if (currentItem.hasChildren()) {
        // declare and initialize variables
        Boolean[] allCheckedInColumn = new Boolean[getColumnCount()];
        Boolean[] hasCheckedInColumn = new Boolean[getColumnCount()];
        for (int j = 1; j < getColumnCount(); j++) {
            allCheckedInColumn[j] = true;
            hasCheckedInColumn[j] = false;
        }
        for (int i = 0; i < currentItem.getItemCount(); i++) {
            GridItem childItem = currentItem.getItem(i);
            // process the children of current item, this must be done before handling the current item
            processNodeSelection(currentItem, childItem);
            boolean allCheckedInRow = true;
            boolean hasCheckedInRow = false;
            boolean expanded = false;
            for (int j = 2; j < getColumnCount(); j++) {
                if (childItem.getChecked(j)) {
                    hasCheckedInRow = true;
                    hasCheckedInColumn[j] = true;
                    expanded = true;
                    if (childItem.getGrayed(j)) {
                        allCheckedInRow = false;
                        allCheckedInColumn[j] = false;
                    }
                } else {
                    if (childItem.getCheckable(j)) {
                        allCheckedInRow = false;
                        allCheckedInColumn[j] = false;
                    }
                }
            }
            childItem.setChecked(1, hasCheckedInRow);
            childItem.setGrayed(1, hasCheckedInRow && !allCheckedInRow);
            if (expanded) {
                currentItem.setExpanded(true);
            }
        }
        // process the selections of indicator category row
        boolean entireCategoryChecked = true;
        for (int j = 2; j < getColumnCount(); j++) {
            if (currentItem.getCheckable(j)) {
                if (hasCheckedInColumn[j]) {
                    hasCheckedInColumn[1] = true;
                    currentItem.setChecked(j, true);
                } else {
                    currentItem.setChecked(j, false);
                }
                if (!allCheckedInColumn[j]) {
                    currentItem.setGrayed(j, hasCheckedInColumn[j]);
                    entireCategoryChecked = false;
                } else {
                    currentItem.setGrayed(j, false);
                }
                // are selected
                if (hasCheckedInColumn[j] && allCheckedInColumn[j]) {
                    IIndicatorNode indicatorNode = (IIndicatorNode) currentItem.getData();
                    IndicatorEnum indicatorEnum = indicatorNode.getIndicatorEnum();
                    ModelElementIndicator meIndicator = (ModelElementIndicator) getColumn(j).getData();
                    if (indicatorEnum != null && meIndicator != null && (indicatorEnum == IndicatorEnum.RangeIndicatorEnum || indicatorEnum == IndicatorEnum.IQRIndicatorEnum)) {
                        meIndicator.addTempIndicatorEnum(indicatorEnum);
                    }
                }
            }
        }
        if (currentItem.getCheckable(1)) {
            currentItem.setChecked(1, hasCheckedInColumn[1]);
            currentItem.setGrayed(1, hasCheckedInColumn[1] && !entireCategoryChecked);
        }
    }
}
Also used : TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) GridItem(org.eclipse.nebula.widgets.grid.GridItem) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) Point(org.eclipse.swt.graphics.Point) IIndicatorNode(org.talend.dq.nodes.indicator.IIndicatorNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 34 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class ColumnAnalysisDetailsPage method saveAnalysis.

/**
 * @param outputFolder
 * @throws DataprofilerCoreException
 */
@Override
public void saveAnalysis() throws DataprofilerCoreException {
    analysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
    analysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
    analysisHandler.clearAnalysis();
    Analysis analysis = analysisHandler.getAnalysis();
    for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
        domain.setName(getCurrentModelElement().getName());
    }
    analysis.getParameters().setExecutionLanguage(ExecutionLanguage.get(execLang));
    // save the number of connections per analysis
    this.saveNumberOfConnectionsPerAnalysis();
    try {
        // MOD zshen feature 12919 to save analysisParameter.
        analysis.getParameters().setMaxNumberRows(Integer.parseInt(maxNumText.getText()));
    } catch (NumberFormatException nfe) {
        // $NON-NLS-1$
        MessageDialogWithToggle.openError(// $NON-NLS-1$
        null, // $NON-NLS-1$
        DefaultMessagesImpl.getString("AbstractAnalysisMetadataPage.SaveAnalysis"), // $NON-NLS-1$
        DefaultMessagesImpl.getString(// $NON-NLS-1$
        "ColumnMasterDetailsPage.emptyField", // $NON-NLS-1$
        DefaultMessagesImpl.getString("ColumnMasterDetailsPage.maxNumberLabel")));
        maxNumText.setText(String.valueOf(analysis.getParameters().getMaxNumberRows()));
    }
    analysis.getParameters().setStoreData(drillDownCheck.getSelection());
    // ~12919
    ModelElementIndicator[] modelElementIndicators = this.getCurrentModelElementIndicators();
    if (modelElementIndicators != null && modelElementIndicators.length != 0) {
        Connection tdProvider = ModelElementIndicatorHelper.getTdDataProvider(modelElementIndicators[0]);
        if (tdProvider.eIsProxy()) {
            // Resolve the connection again
            tdProvider = (Connection) EObjectHelper.resolveObject(tdProvider);
        }
        analysis.getContext().setConnection(tdProvider);
        for (ModelElementIndicator modelElementIndicator : modelElementIndicators) {
            IRepositoryViewObject reposObject = modelElementIndicator.getModelElementRepositoryNode().getObject();
            ModelElement modelEle = null;
            if (reposObject instanceof MetadataColumnRepositoryObject) {
                modelEle = ((MetadataColumnRepositoryObject) reposObject).getTdColumn();
            }
            analysisHandler.addIndicator(modelEle, modelElementIndicator.getIndicators());
            DataminingType type = MetadataHelper.getDataminingType(modelEle);
            if (type == null) {
                type = MetadataHelper.getDefaultDataminingType(modelElementIndicator.getJavaType());
            }
            analysisHandler.setDatamingType(type.getLiteral(), modelEle);
        }
    } else {
        analysis.getContext().setConnection(null);
    }
    analysisHandler.setStringDataFilter(dataFilterComp.getDataFilterString());
    // 2011.1.12 MOD by zshen to unify anlysis and connection id when saving.
    this.nameText.setText(analysisHandler.getName());
    TaggedValueHelper.setTaggedValue(getCurrentModelElement(), TaggedValueHelper.IS_USE_SAMPLE_DATA, isRunWithSampleData.toString());
    // TDQ-5581,if has removed emlements(patten/udi),should remove dependency each other before saving.
    // MOD yyi 2012-02-08 TDQ-4621:Explicitly set true for updating dependencies.
    ReturnCode saved = ElementWriterFactory.getInstance().createAnalysisWrite().save(getCurrentRepNode().getObject().getProperty().getItem(), true);
    // MOD yyi 2012-02-03 TDQ-3602:Avoid to rewriting all analyzes after saving, no reason to update all analyzes
    // which is depended in the referred connection.
    // Extract saving log function.
    // @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#logSaved(ReturnCode)
    logSaved(saved);
    treeViewer.setDirty(false);
    dataFilterComp.setDirty(false);
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ReturnCode(org.talend.utils.sugars.ReturnCode) Analysis(org.talend.dataquality.analysis.Analysis) FileConnection(org.talend.core.model.metadata.builder.connection.FileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) Domain(org.talend.dataquality.domain.Domain) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 35 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class ColumnAnalysisDetailsPage method recomputeIndicators.

public void recomputeIndicators() {
    analysisHandler = new ModelElementAnalysisHandler();
    analysisHandler.setAnalysis(getCurrentModelElement());
    // Handle JUDIs
    UDIHelper.updateJUDIsForAnalysis(getCurrentModelElement());
    stringDataFilter = analysisHandler.getStringDataFilterwithContext();
    EList<ModelElement> analyzedColumns = analysisHandler.getAnalyzedColumns();
    List<ModelElementIndicator> meIndicatorList = new ArrayList<ModelElementIndicator>();
    ModelElementIndicator currentIndicator = null;
    for (ModelElement element : analyzedColumns) {
        TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
        // MOD qiongli 2011-1-10,16796:delimitefile
        MetadataColumn mdColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(element);
        if (tdColumn == null && mdColumn == null) {
            continue;
        }
        // MOD qiongli TDQ-7052 if the node is filtered ,it will be return null,so should create a new node.
        RepositoryNode repNode = RepositoryNodeHelper.recursiveFind(element);
        if (repNode == null) {
            repNode = RepositoryNodeHelper.createRepositoryNode(element);
        }
        // MOD mzhao feature 15750, The column is recompute from the file, here create a new repository view object.
        if (tdColumn == null && mdColumn != null) {
            currentIndicator = ModelElementIndicatorHelper.createDFColumnIndicator(repNode);
        } else if (tdColumn != null) {
            currentIndicator = ModelElementIndicatorHelper.createModelElementIndicator(repNode);
        }
        DataminingType dataminingType = DataminingType.get(analysisHandler.getDatamingType(element));
        MetadataHelper.setDataminingType(dataminingType == null ? DataminingType.NOMINAL : dataminingType, element);
        Collection<Indicator> indicatorList = analysisHandler.getIndicators(element);
        if (currentIndicator != null) {
            currentIndicator.setIndicators(indicatorList.toArray(new Indicator[indicatorList.size()]));
            meIndicatorList.add(currentIndicator);
        }
    }
    currentModelElementIndicators = meIndicatorList.toArray(new ModelElementIndicator[meIndicatorList.size()]);
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) ModelElementAnalysisHandler(org.talend.dq.analysis.ModelElementAnalysisHandler) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) Indicator(org.talend.dataquality.indicators.Indicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Aggregations

ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)58 IRepositoryNode (org.talend.repository.model.IRepositoryNode)22 ArrayList (java.util.ArrayList)16 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)16 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)15 Indicator (org.talend.dataquality.indicators.Indicator)13 IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)12 TreeItem (org.eclipse.swt.widgets.TreeItem)11 RepositoryNode (org.talend.repository.model.RepositoryNode)10 IndicatorEnum (org.talend.dq.nodes.indicator.type.IndicatorEnum)9 MetadataXmlElementTypeRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject)7 Connection (org.talend.core.model.metadata.builder.connection.Connection)6 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)6 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)5 TreeEditor (org.eclipse.swt.custom.TreeEditor)4 MouseAdapter (org.eclipse.swt.events.MouseAdapter)4 MouseEvent (org.eclipse.swt.events.MouseEvent)4 Composite (org.eclipse.swt.widgets.Composite)4 Label (org.eclipse.swt.widgets.Label)4