Search in sources :

Example 16 with IndicatorCategory

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

the class SysIndicatorFolderRepNode method createChildrenNode.

/**
 * DOC msjian Comment method "createChildrenNode".
 *
 * @param withDeleted
 * @param project
 * @throws PersistenceException
 */
private void createChildrenNode(boolean withDeleted, Project project) throws PersistenceException {
    RootContainer<String, IRepositoryViewObject> tdqViewObjects = super.getTdqViewObjects(project, this);
    // sub folders
    for (Container<String, IRepositoryViewObject> container : tdqViewObjects.getSubContainer()) {
        Folder folder = new Folder((Property) container.getProperty(), RepositoryNodeHelper.getSystemIndicatorFolderRepositoryType(container.getLabel()));
        if (isIgnoreFolder(withDeleted, project, folder)) {
            continue;
        }
        SysIndicatorFolderRepNode childNodeFolder = new SysIndicatorFolderRepNode(folder, this, ENodeType.SYSTEM_FOLDER, project);
        childNodeFolder.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_SYSTEM_INDICATORS);
        childNodeFolder.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_SYSTEM_INDICATORS);
        super.getChildren().add(childNodeFolder);
    }
    // rule files
    for (IRepositoryViewObject viewObject : tdqViewObjects.getMembers()) {
        if (!withDeleted && viewObject.isDeleted()) {
            continue;
        }
        // TDQ-11110: hidden some system indicators.
        String viewObjectlabel = viewObject.getLabel();
        if (// $NON-NLS-1$
        viewObjectlabel.equals("Multiple Column Correlation") || // $NON-NLS-1$
        viewObjectlabel.equals("Multiple Column Frequency Table") || // $NON-NLS-1$
        viewObjectlabel.equals("All Match") || viewObjectlabel.equals("Multiple Column Simple Statistics")) {
            // $NON-NLS-1$
            continue;
        }
        if (!viewObjectlabel.equals("Sum")) {
            // $NON-NLS-1$
            SysIndicatorDefinitionRepNode repNode = new SysIndicatorDefinitionRepNode(viewObject, this, ENodeType.REPOSITORY_ELEMENT, project);
            repNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_SYSTEM_INDICATORS);
            repNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_SYSTEM_INDICATORS);
            viewObject.setRepositoryNode(repNode);
            repNode.setSystemIndicator(true);
            // MOD gdbu 2011-7-27 bug : 23161
            List<TdExpression> indiExpression = repNode.getIndicatorDefinition().getSqlGenericExpression();
            // MOD qiongli 2011-7-27,feature 22362
            boolean isPhoneNumberStatics = false;
            IndicatorCategory category = IndicatorCategoryHelper.getCategory(repNode.getIndicatorDefinition());
            if (category != null && IndicatorCategoryHelper.isPhoneNumberCategory(category)) {
                isPhoneNumberStatics = true;
            }
            if (!isPhoneNumberStatics && !isEastAsiaPatternFequencyStatics(repNode.getIndicatorDefinition()) && (indiExpression == null || indiExpression.size() == 0)) {
                continue;
            }
            // ~23161
            super.getChildren().add(repNode);
        }
    }
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IndicatorCategory(org.talend.dataquality.indicators.definition.IndicatorCategory) Folder(org.talend.core.model.repository.Folder)

Example 17 with IndicatorCategory

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

the class NewParserRulesWizard method createAndSaveCWMFile.

public TypedReturnCode<Object> createAndSaveCWMFile(ModelElement cwmElement) {
    ParserRule parserRule = (ParserRule) cwmElement;
    TaggedValueHelper.setValidStatus(true, parserRule);
    if (isComeFromTestEditor()) {
        // MOD klliu bug TDQ-4772 2012-03-20
        // copy the informations of old Expressions for the new parser rule,and it's used when an new rule is
        // created in testing rule editor.
        List<TdExpression> ruleExpressions = parameter.getParserRule().getExpression();
        for (TdExpression expression : ruleExpressions) {
            parserRule.addExpression(expression.getName(), expression.getLanguage(), expression.getBody());
        }
    // ~
    } else {
        parserRule.addExpression(parameter.getParserRuleName(), parameter.getParserRuleType(), parameter.getParserRuleValue());
        IndicatorCategory ruleIndicatorCategory = DefinitionHandler.getInstance().getDQRuleIndicatorCategory();
        if (ruleIndicatorCategory != null && !parserRule.getCategories().contains(ruleIndicatorCategory)) {
            parserRule.getCategories().add(ruleIndicatorCategory);
        }
    }
    IFolder folder = parameter.getFolderProvider().getFolderResource();
    return ElementWriterFactory.getInstance().createdRuleWriter().create(parserRule, folder);
}
Also used : ParserRule(org.talend.dataquality.rules.ParserRule) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorCategory(org.talend.dataquality.indicators.definition.IndicatorCategory) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IndicatorCategory (org.talend.dataquality.indicators.definition.IndicatorCategory)17 TdExpression (org.talend.cwm.relational.TdExpression)5 ArrayList (java.util.ArrayList)4 IFolder (org.eclipse.core.resources.IFolder)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)2 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)2 ParserRule (org.talend.dataquality.rules.ParserRule)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 CoreException (org.eclipse.core.runtime.CoreException)1 EList (org.eclipse.emf.common.util.EList)1 LoginException (org.talend.commons.exception.LoginException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Property (org.talend.core.model.properties.Property)1 Folder (org.talend.core.model.repository.Folder)1 BusinessRuleItemEditorInput (org.talend.dataprofiler.core.ui.editor.dqrules.BusinessRuleItemEditorInput)1 DQRuleEditor (org.talend.dataprofiler.core.ui.editor.dqrules.DQRuleEditor)1 AverageLengthIndicator (org.talend.dataquality.indicators.AverageLengthIndicator)1