Search in sources :

Example 36 with ModelElementIndicator

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

the class ColumnAnalysisDetailsPage method canRun.

@Override
protected ReturnCode canRun() {
    // ADD xqliu 2010-01-22 bug 11200
    ReturnCode checkMdmExecutionEngine = checkMdmExecutionEngine();
    if (!checkMdmExecutionEngine.isOk()) {
        return checkMdmExecutionEngine;
    }
    if (checkJUDIUpdate()) {
        recomputeIndicators();
        computePagination();
    }
    // ~
    ModelElementIndicator[] modelElementIndicators = treeViewer.getModelElementIndicator();
    if (modelElementIndicators == null || modelElementIndicators.length == 0) {
        return new ReturnCode(DefaultMessagesImpl.getString("ColumnMasterDetailsPage.NoColumnAssigned", analysisHandler.getName()), // $NON-NLS-1$
        false);
    }
    for (ModelElementIndicator modelElementIndicator : modelElementIndicators) {
        if (modelElementIndicator.getIndicators().length == 0) {
            // $NON-NLS-1$
            return new ReturnCode(DefaultMessagesImpl.getString("ColumnMasterDetailsPage.NoIndicatorAssigned"), false);
        }
    }
    return new ReturnCode(true);
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 37 with ModelElementIndicator

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

the class ColumnSetAnalysisDetailsPage method saveAnalysis.

/**
 * @param outputFolder
 * @throws DataprofilerCoreException
 */
@Override
public void saveAnalysis() throws DataprofilerCoreException {
    columnSetAnalysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
    columnSetAnalysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
    // columnSetAnalysisHandler.setName(columnSetAnalysisHandler.getName().replace(" ", ""));
    for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
        domain.setName(getCurrentModelElement().getName());
    }
    // ~
    columnSetAnalysisHandler.clearAnalysis();
    simpleStatIndicator.getAnalyzedColumns().clear();
    allMatchIndicator.getAnalyzedColumns().clear();
    // set execute engine
    Analysis analysis = columnSetAnalysisHandler.getAnalysis();
    analysis.getParameters().setExecutionLanguage(ExecutionLanguage.get(execLang));
    // set data filter
    columnSetAnalysisHandler.setStringDataFilter(dataFilterComp.getDataFilterString());
    // save analysis
    List<IRepositoryNode> repositoryNodes = treeViewer.getColumnSetMultiValueList();
    Connection tdProvider = null;
    IRepositoryViewObject reposObject = null;
    if (repositoryNodes != null && repositoryNodes.size() != 0) {
        ConnectionItem item = (ConnectionItem) repositoryNodes.get(0).getObject().getProperty().getItem();
        tdProvider = item.getConnection();
        if (tdProvider.eIsProxy()) {
            // Resolve the connection again
            tdProvider = (Connection) EObjectHelper.resolveObject(tdProvider);
        }
        analysis.getContext().setConnection(tdProvider);
        List<ModelElement> columnList = new ArrayList<ModelElement>();
        for (IRepositoryNode rd : repositoryNodes) {
            reposObject = rd.getObject();
            columnList.add(((MetadataColumnRepositoryObject) reposObject).getTdColumn());
        }
        simpleStatIndicator.getAnalyzedColumns().addAll(columnList);
        columnSetAnalysisHandler.addIndicator(columnList, simpleStatIndicator);
        // ~ MOD mzhao feature 13040. 2010-05-21
        allMatchIndicator.getCompositeRegexMatchingIndicators().clear();
        ModelElementIndicator[] modelElementIndicator = treeViewer.getModelElementIndicator();
        if (modelElementIndicator != null) {
            for (ModelElementIndicator modelElementInd : modelElementIndicator) {
                Indicator[] inds = modelElementInd.getPatternIndicators();
                for (Indicator ind : inds) {
                    if (ind instanceof RegexpMatchingIndicator) {
                        // MOD yyi 2011-06-15 22419:column set pattern for MDM
                        IRepositoryViewObject obj = modelElementInd.getModelElementRepositoryNode().getObject();
                        ModelElement analyzedElt = ((MetadataColumnRepositoryObject) obj).getTdColumn();
                        ind.setAnalyzedElement(analyzedElt);
                        allMatchIndicator.getCompositeRegexMatchingIndicators().add((RegexpMatchingIndicator) ind);
                    }
                }
            }
        }
        if (allMatchIndicator.getCompositeRegexMatchingIndicators().size() > 0) {
            allMatchIndicator.getAnalyzedColumns().addAll(columnList);
            columnSetAnalysisHandler.addIndicator(columnList, allMatchIndicator);
        }
    // ~
    } else {
        analysis.getContext().setConnection(null);
    }
    TaggedValueHelper.setTaggedValue(getCurrentModelElement(), TaggedValueHelper.IS_USE_SAMPLE_DATA, isRunWithSampleData.toString());
    // save the number of connections per analysis
    this.saveNumberOfConnectionsPerAnalysis();
    // 2011.1.12 MOD by zhsne to unify anlysis and connection id when saving.
    this.nameText.setText(columnSetAnalysisHandler.getName());
    // TDQ-5581,if has removed emlements(patten),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 : ReturnCode(org.talend.utils.sugars.ReturnCode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) FileConnection(org.talend.core.model.metadata.builder.connection.FileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ArrayList(java.util.ArrayList) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) Domain(org.talend.dataquality.domain.Domain) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 38 with ModelElementIndicator

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

the class AbstractAnalysisMetadataPage method openColumnsSelectionDialog.

/**
 * open the column selection dialog.
 */
public void openColumnsSelectionDialog() {
    if (connCombo != null) {
        reloadDataproviderAndFillConnCombo();
    }
    RepositoryNode connNode = getConnComboSelectNode();
    List<IRepositoryNode> reposViewObjList = new ArrayList<IRepositoryNode>();
    for (ModelElementIndicator modelElementIndicator : currentModelElementIndicators) {
        reposViewObjList.add(modelElementIndicator.getModelElementRepositoryNode());
    }
    ColumnsSelectionDialog dialog = new ColumnsSelectWithConstraintDialog(this, null, DefaultMessagesImpl.getString("ColumnMasterDetailsPage.columnSelection"), reposViewObjList, connNode, // $NON-NLS-1$
    DefaultMessagesImpl.getString(// $NON-NLS-1$
    "ColumnMasterDetailsPage.columnSelections"));
    if (dialog.open() == Window.OK) {
        Object[] modelElements = dialog.getResult();
        setTreeViewInput(modelElements);
        // TDQ-11590: automatically refresh the data table after we select column with the "select columns" dialog.
        refreshPreviewData();
    // TDQ-11590~
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ColumnsSelectionDialog(org.talend.dataprofiler.core.ui.dialog.ColumnsSelectionDialog) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ISubRepositoryObject(org.talend.core.model.repository.ISubRepositoryObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) ColumnsSelectWithConstraintDialog(org.talend.dataprofiler.core.ui.dialog.ColumnsSelectWithConstraintDialog)

Example 39 with ModelElementIndicator

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

the class ModelElementIndicatorHelper method getModelElementFromMEIndicator.

/**
 * Convert from ModelElementIndicators to ModelElement
 *
 * @param ModelElementIndicators
 * @return
 */
public static ModelElement[] getModelElementFromMEIndicator(ModelElementIndicator[] ModelElementIndicators) {
    if (ModelElementIndicators == null) {
        return new ModelElement[0];
    }
    ModelElement[] selectedColumns = new ModelElement[ModelElementIndicators.length];
    int index = 0;
    for (ModelElementIndicator modelElemIndi : ModelElementIndicators) {
        IRepositoryViewObject currentObject = modelElemIndi.getModelElementRepositoryNode().getObject();
        if (ISubRepositoryObject.class.isInstance(currentObject)) {
            selectedColumns[index++] = ((ISubRepositoryObject) currentObject).getModelElement();
        }
    }
    return selectedColumns;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 40 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator 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)

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