Search in sources :

Example 46 with IndicatorDefinition

use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.

the class ItemRecord method getSystemIndicaotrOfAnalysis.

/**
 * get Analysis Dependency (for indicator only).
 *
 * @return get the list of indicator which in use by the analysis
 */
private List<File> getSystemIndicaotrOfAnalysis(ModelElement mElement) {
    List<File> listFile = new ArrayList<File>();
    if (mElement instanceof Analysis) {
        Analysis anaElement = (Analysis) mElement;
        List<Indicator> indicators = IndicatorHelper.getIndicators(anaElement.getResults());
        for (Indicator indicator : indicators) {
            if (indicator instanceof UserDefIndicator) {
                // whereRuleIndicator or UDIIndicator
                continue;
            }
            boolean isContain = false;
            IndicatorDefinition newIndicatorDefinition = indicator.getIndicatorDefinition();
            // MOD qiongli 2012-5-11 TDQ-5256
            if (newIndicatorDefinition == null) {
                continue;
            }
            for (File lf : listFile) {
                ModelElement me = getElement(lf);
                if (me != null && me instanceof IndicatorDefinition) {
                    IndicatorDefinition oldIndicatorDefinition = (IndicatorDefinition) me;
                    if (ModelElementHelper.compareUUID(oldIndicatorDefinition, newIndicatorDefinition)) {
                        isContain = true;
                        break;
                    }
                }
            }
            if (!isContain) {
                File depFile = EObjectHelper.modelElement2File(newIndicatorDefinition);
                if (depFile != null) {
                    FILE_ELEMENT_MAP.put(depFile, newIndicatorDefinition);
                    listFile.add(depFile);
                }
            }
        }
    }
    return listFile;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) ArrayList(java.util.ArrayList) File(java.io.File) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator)

Example 47 with IndicatorDefinition

use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.

the class ImportWizardPage method checkforErrors.

/**
 * check that directory exist and issue an error message if not. <br>
 * check that the folder is a data quality repository or issue an error.<br>
 * check that anything is check in the tree or issue an error.<br>
 */
protected void checkforErrors() {
    List<String> dErrors = new ArrayList<String>();
    if (repositoryTree.getTree().getItems().length == 0) {
        // $NON-NLS-1$
        dErrors.add(Messages.getString("ImportWizardPage.0"));
    }
    if (repositoryTree.getCheckedElements().length == 0) {
        // $NON-NLS-1$
        dErrors.add(Messages.getString("ImportWizardPage.1"));
    }
    dErrors.addAll(writer.check());
    ItemRecord[] elements = getElements();
    for (ItemRecord record : elements) {
        dErrors.addAll(record.getErrors());
        for (File depFile : record.getDependencySet()) {
            ItemRecord findRecord = ItemRecord.findRecord(depFile);
            if (findRecord == null || !repositoryTree.getChecked(findRecord)) {
                // TDQ-12410: if the dependency comes from reference project, we ingore it.
                if (!DqFileUtils.isFileUnderBasePath(depFile, writer.getBasePath())) {
                    continue;
                }
                ModelElement element = ItemRecord.getElement(depFile);
                // Indicator, don't add it into errors even if it is not exist
                if (element instanceof IndicatorDefinition) {
                    String uuid = ResourceHelper.getUUID(element);
                    if (IndicatorDefinitionFileHelper.isTechnialIndicator(uuid)) {
                        continue;
                    }
                }
                // MOD qiongli 2012-12-13 TDQ-5356 use itself file name for jrxml
                boolean isJrxmlDepFile = depFile.getName().endsWith(FactoriesUtil.JRXML);
                // MOD msjian TDQ-5909: modify to displayName
                String dptLabel = element != null && !isJrxmlDepFile && PropertyHelper.getProperty(element) != null ? PropertyHelper.getProperty(element).getDisplayName() : depFile.getName();
                // TDQ-5909~
                // $NON-NLS-1$ //$NON-NLS-2$
                dErrors.add("\"" + record.getName() + "\" miss dependency :" + dptLabel);
            }
        }
    }
    if (!dErrors.isEmpty()) {
        setErrorMessage(dErrors.get(0));
    } else {
        setErrorMessage(null);
    }
    updatePageStatus();
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ArrayList(java.util.ArrayList) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) File(java.io.File) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 48 with IndicatorDefinition

use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.

the class FileSystemImportWriter method updateAnalysisClientDependence.

/**
 * remove the old client dependency add a new one in Anlaysis.
 *
 * @param supplierItem
 * @param modelElement
 * @throws PersistenceException
 */
private void updateAnalysisClientDependence(TDQItem supplierItem, Property property) throws PersistenceException {
    ModelElement anaModelElement = PropertyHelper.getModelElement(property);
    if (anaModelElement != null) {
        Analysis analysis = (Analysis) anaModelElement;
        EList<Dependency> clientDependency = anaModelElement.getClientDependency();
        Iterator<Dependency> it = clientDependency.iterator();
        ModelElement supplierModelElement = RepositoryNodeHelper.getResourceModelElement(supplierItem);
        Resource supModeResource = supplierModelElement.eResource();
        while (it.hasNext()) {
            Dependency clientDep = it.next();
            // systemSupplyModelElement,remove it.
            if (clientDep.eResource() == null) {
                URI clientDepURI = ((InternalEObject) clientDep).eProxyURI();
                boolean isUDI = clientDepURI.path().contains(ResourceManager.getUDIFolder().getProjectRelativePath().toString());
                boolean isPattern = clientDepURI.path().contains(ResourceManager.getPatternFolder().getProjectRelativePath().toString());
                if (supModeResource != null && (isUDI || isPattern) && clientDepURI.lastSegment().equals(supModeResource.getURI().lastSegment())) {
                    it.remove();
                    break;
                }
            }
        }
        DependenciesHandler.getInstance().setUsageDependencyOn(anaModelElement, supplierModelElement);
        // TDQ-8436 remove the old pattern and add the new pattern in analysis Indicator Parameters.
        if (isPattern(supplierModelElement)) {
            updatePatternInAnaParams(supplierModelElement, analysis);
            ElementWriterFactory.getInstance().createPatternWriter().save(supplierItem, true);
        }
        // remove old udi and set a new one in the analysis indicators.
        if (supplierModelElement instanceof UDIndicatorDefinition) {
            if (analysis.getResults() != null) {
                EList<Indicator> indicators = analysis.getResults().getIndicators();
                Iterator<Indicator> itIndicators = indicators.iterator();
                while (itIndicators.hasNext()) {
                    Indicator indicator = itIndicators.next();
                    IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
                    if (indicatorDefinition.eResource() == null) {
                        URI indicatorDefURI = ((InternalEObject) indicatorDefinition).eProxyURI();
                        if (supModeResource != null && UDIHelper.isUDI(indicator) && indicatorDefURI.lastSegment().equals(supModeResource.getURI().lastSegment())) {
                            indicator.setIndicatorDefinition((UDIndicatorDefinition) supplierModelElement);
                            break;
                        }
                    }
                }
                ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(supplierItem, true);
            }
        }
        // only save analysis item at here.
        ProxyRepositoryFactory.getInstance().save(property.getItem(), true);
    }
}
Also used : UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Resource(org.eclipse.emf.ecore.resource.Resource) Dependency(orgomg.cwm.objectmodel.core.Dependency) URI(org.eclipse.emf.common.util.URI) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) Indicator(org.talend.dataquality.indicators.Indicator) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 49 with IndicatorDefinition

use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.

the class ColumnAnalysisSqlExecutor method getIndicatorDefinition.

/**
 * DOC talend Comment method "getIndicatorDefinition".
 *
 * @param indicator
 * @return
 */
private TypedReturnCode<IndicatorDefinition> getIndicatorDefinition(Indicator indicator) {
    TypedReturnCode<IndicatorDefinition> rt = new TypedReturnCode<IndicatorDefinition>(true);
    IndicatorDefinition indicatorDefinition;
    String label = indicator.getIndicatorDefinition().getLabel();
    if (label == null || PluginConstant.EMPTY_STRING.equals(label)) {
        indicatorDefinition = indicator.getIndicatorDefinition();
    } else {
        indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(label);
    }
    // TDQ-10559: when the indicator is in reference project, the above can get NOTHING
    if (indicatorDefinition == null) {
        indicatorDefinition = indicator.getIndicatorDefinition();
        if (indicatorDefinition.eIsProxy()) {
            indicatorDefinition = (IndicatorDefinition) EObjectHelper.resolveObject(indicatorDefinition);
        }
    }
    if (indicatorDefinition == null) {
        traceError(Messages.getString("ColumnAnalysisSqlExecutor.INTERNALERROR", // $NON-NLS-1$
        AnalysisExecutorHelper.getIndicatorName(indicator)));
        rt.setOk(false);
    }
    rt.setObject(indicatorDefinition);
    return rt;
}
Also used : TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 50 with IndicatorDefinition

use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.

the class MultiColumnAnalysisExecutor method initializeNumericFunctions.

/**
 * DOC scorreia Comment method "initializeNumericFunctions".
 *
 * @param indicator
 * @return
 */
private EList<String> initializeNumericFunctions(ColumnSetMultiValueIndicator indicator) {
    final EList<String> numericFunctions = indicator.getNumericFunctions();
    if (!numericFunctions.isEmpty()) {
        // could be already set
        return numericFunctions;
    }
    final IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
    final List<String> aggregate1argFunctions = dbms().getAggregate1argFunctions(indicatorDefinition);
    numericFunctions.addAll(aggregate1argFunctions);
    return numericFunctions;
}
Also used : IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Aggregations

IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)141 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)37 Test (org.junit.Test)35 ArrayList (java.util.ArrayList)34 TdExpression (org.talend.cwm.relational.TdExpression)31 File (java.io.File)22 Analysis (org.talend.dataquality.analysis.Analysis)16 IFile (org.eclipse.core.resources.IFile)15 Property (org.talend.core.model.properties.Property)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)14 PersistenceException (org.talend.commons.exception.PersistenceException)13 Indicator (org.talend.dataquality.indicators.Indicator)12 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)12 Path (org.eclipse.core.runtime.Path)10 IFolder (org.eclipse.core.resources.IFolder)9 BasicEList (org.eclipse.emf.common.util.BasicEList)9 TdColumn (org.talend.cwm.relational.TdColumn)9 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)7 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)7