Search in sources :

Example 71 with IndicatorDefinition

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

the class AnalysisHelper method getUserDefinedIndicators.

public static List<IndicatorDefinition> getUserDefinedIndicators(Analysis analysis) {
    List<IndicatorDefinition> rets = new ArrayList<IndicatorDefinition>();
    EList<Indicator> indicators = analysis.getResults().getIndicators();
    for (Indicator indicator : indicators) {
        if (indicator instanceof UserDefIndicator) {
            rets.add(indicator.getIndicatorDefinition());
        }
    }
    return rets;
}
Also used : ArrayList(java.util.ArrayList) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Example 72 with IndicatorDefinition

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

the class AnalysisExecutorHelper method checkIndicatorWithChild.

/**
 * DOC zhao Comment method "checkIndicatorWithChild".
 *
 * @param indicator
 * @return
 */
private static ReturnCode checkIndicatorWithChild(Indicator indicator) {
    ReturnCode rc = new ReturnCode(Boolean.TRUE);
    if (indicator.getBuiltInIndicatorDefinition() != null) {
        return rc;
    }
    // Get indicator definition from dependent file
    IndicatorDefinition dependentDefinition = indicator.getIndicatorDefinition();
    if (isDependentFileExist(dependentDefinition)) {
        IndicatorDefinition deepCopiedDefinition;
        if (dependentDefinition instanceof WhereRule) {
            deepCopiedDefinition = copyWhereRule((WhereRule) dependentDefinition);
        } else {
            deepCopiedDefinition = EObjectHelper.deepCopy(dependentDefinition);
        }
        // Hot copy to built-in definition.
        deepCopiedDefinition.getSupplierDependency().clear();
        // TDQ-10737 Because 'BuiltInIndicatorDefinition' is a containment reference, need to Clear these 3 non-containment
        // reference list
        deepCopiedDefinition.getCategories().clear();
        deepCopiedDefinition.getAggregatedDefinitions().clear();
        deepCopiedDefinition.getSubCategories().clear();
        indicator.setBuiltInIndicatorDefinition(deepCopiedDefinition);
        EMFUtil.saveResource(indicator.eResource());
    } else {
        IndicatorDefinition builtInDefinition = indicator.getBuiltInIndicatorDefinition();
        if (builtInDefinition == null) {
            // $NON-NLS-1$
            rc.setMessage(Messages.getString("AnalysisExecutor.BuiltInNoIndicators"));
            rc.setOk(false);
            return rc;
        } else {
            indicator.setIndicatorDefinition(null);
        }
    }
    return rc;
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) WhereRule(org.talend.dataquality.rules.WhereRule) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 73 with IndicatorDefinition

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

the class AnalysisExecutorHelper method copyWhereRule.

/**
 * When deep copy, if the where rule contains some joins, it will copy all related tables(extended in related db),
 * but this is not what we want, so we use a temp list to store the joins, and then clear the joins before deep copy
 * to avoid copy many useless things, and restore the joins after deep copy.
 *
 * @param dependentDefinition
 */
private static IndicatorDefinition copyWhereRule(WhereRule dependentDefinition) {
    // firstly clear the dependency of the analysis
    dependentDefinition.getSupplierDependency().clear();
    // then , record the joins in a temp list
    EList<JoinElement> joins = dependentDefinition.getJoins();
    List<JoinElement> copyJoins = new ArrayList<JoinElement>();
    if (!joins.isEmpty()) {
        for (JoinElement element : joins) {
            copyJoins.add(element);
        }
        dependentDefinition.getJoins().clear();
    }
    IndicatorDefinition deepCopiedDefinition = EObjectHelper.deepCopy(dependentDefinition);
    // after deep copy, restore the joins.
    if (!copyJoins.isEmpty()) {
        ((WhereRule) deepCopiedDefinition).getJoins().addAll(copyJoins);
        dependentDefinition.getJoins().addAll(copyJoins);
    }
    return deepCopiedDefinition;
}
Also used : JoinElement(org.talend.dataquality.rules.JoinElement) ArrayList(java.util.ArrayList) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 74 with IndicatorDefinition

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

the class IndcatorSwitchImp method setIndicatorDefinition.

private Boolean setIndicatorDefinition(Indicator indicator, String definitionLabel) {
    if (definitionLabel == null) {
        return false;
    }
    // get the definition
    IndicatorDefinition indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(definitionLabel);
    if (indicatorDefinition == null) {
        return false;
    }
    // else
    indicator.setIndicatorDefinition(indicatorDefinition);
    return true;
}
Also used : IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 75 with IndicatorDefinition

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

the class ExportWizardPage method getElements.

/**
 * DOC bZhou Comment method "getElements".
 *
 * @return
 */
public ItemRecord[] getElements() {
    List<ItemRecord> itemRecords = new ArrayList<ItemRecord>();
    boolean sumIndicatorAdded = false;
    Object[] checkedElements = repositoryTree.getCheckedElements();
    for (Object obj : checkedElements) {
        if (obj instanceof ItemRecord) {
            ItemRecord record = (ItemRecord) obj;
            // MOD qiongli 2012-4-20,add related subreport jrxml/jasper file to elements.
            File file = record.getFile();
            if (file.isFile()) {
                itemRecords.add(record);
                if (file.getName().endsWith(FactoriesUtil.JRXML)) {
                    addSubRepToElements(record, itemRecords);
                }
                // if it is Mean Indicator, add it's dependency Sum Indicator
                if (!sumIndicatorAdded) {
                    // $NON-NLS-1$
                    String meanIndicatorUuid = "_ccI48RF2Ed2PKb6nEJEvhw";
                    // $NON-NLS-1$
                    String sumIndicatorLabel = "Sum";
                    ModelElement element = record.getElement();
                    if (element != null && element instanceof IndicatorDefinition && meanIndicatorUuid.equals(ResourceHelper.getUUID(element))) {
                        IndicatorDefinition sumIndicator = DefinitionHandler.getInstance().getIndicatorDefinition(sumIndicatorLabel);
                        if (sumIndicator != null) {
                            IFile sumIndicatorIFile = IndicatorResourceFileHelper.findCorrespondingFile(sumIndicator);
                            if (sumIndicatorIFile != null) {
                                File sumIndicatorFile = WorkspaceUtils.ifileToFile(sumIndicatorIFile);
                                if (sumIndicatorFile != null) {
                                    itemRecords.add(new ItemRecord(sumIndicatorFile));
                                    sumIndicatorAdded = true;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return itemRecords.toArray(new ItemRecord[itemRecords.size()]);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IFile(org.eclipse.core.resources.IFile) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) ArrayList(java.util.ArrayList) IFile(org.eclipse.core.resources.IFile) File(java.io.File) 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