Search in sources :

Example 61 with IndicatorDefinition

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

the class IndicatorSelectDialog method updateIndicatorInfo.

public void updateIndicatorInfo(GridItem item) {
    // $NON-NLS-1$
    String DESCRIPTION = DefaultMessagesImpl.getString("IndicatorSelectDialog.description");
    // $NON-NLS-1$
    String PURPOSE = DefaultMessagesImpl.getString("IndicatorSelectDialog.purpose");
    IIndicatorNode indicatorNode = ((IIndicatorNode) item.getData());
    if (indicatorNode != null) {
        Indicator indicator = indicatorNode.getIndicatorInstance();
        if (indicator != null) {
            IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
            if ("".equals(MetadataHelper.getPurpose(indicatorDefinition))) {
                purposeLabel.setText(PURPOSE + " " + indicator.getName());
            } else {
                purposeLabel.setText(PURPOSE + " " + MetadataHelper.getPurpose(indicatorDefinition));
            }
            String description = DESCRIPTION + " " + MetadataHelper.getDescription(indicatorDefinition);
            descriptionLabel.setText(description);
            return;
        }
    }
    purposeLabel.setText(PURPOSE + " " + item.getText());
    descriptionLabel.setText(DESCRIPTION + " " + item.getText());
}
Also used : IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) IIndicatorNode(org.talend.dq.nodes.indicator.IIndicatorNode) DatePatternFreqIndicator(org.talend.dataquality.indicators.DatePatternFreqIndicator) PhoneNumbStatisticsIndicator(org.talend.dataquality.indicators.PhoneNumbStatisticsIndicator) DelimitedFileIndicator(org.talend.dataprofiler.core.model.DelimitedFileIndicator) Indicator(org.talend.dataquality.indicators.Indicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 62 with IndicatorDefinition

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

the class IndicatorDefinitionWriter method checkNameUpdate.

/**
 * when the udi name is changed, it will be losted in the indicator selection dialog. so need to reload(TDQ-14249)
 *
 * @param oldName
 * @param item
 */
private void checkNameUpdate(String oldName, Item item) {
    String newName = item.getProperty().getLabel();
    if (!StringUtils.equals(newName, oldName)) {
        IndicatorDefinition oldIndicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(oldName);
        IndicatorDefinition newIndicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(newName);
        if (newIndicatorDefinition == null && oldIndicatorDefinition != null) {
            DefinitionHandler.getInstance().reloadAllUDIs();
        }
    }
}
Also used : IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 63 with IndicatorDefinition

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

the class IndicatorDefinitionWriter method updateDependencies.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.writer.AElementPersistance#updateDependencies(orgomg.cwm.objectmodel.core.ModelElement)
     */
// @Override
protected void updateDependencies(ModelElement element) {
    // update client dependency
    // if IndicatorDefinition have client depencency, add codes here
    IndicatorDefinition definition = (IndicatorDefinition) element;
    Property property = PropertyHelper.getProperty(definition);
    List<IRepositoryViewObject> listIndicatorDependency = DependenciesHandler.getInstance().getIndicatorDependency(new RepositoryViewObject(property));
    for (IRepositoryViewObject viewObject : listIndicatorDependency) {
        Item item = viewObject.getProperty().getItem();
        if (item instanceof TDQAnalysisItem) {
            try {
                ProxyRepositoryFactory.getInstance().save(item);
            } catch (PersistenceException e) {
                log.error(e, e);
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) Property(org.talend.core.model.properties.Property) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 64 with IndicatorDefinition

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

the class IndicatorDefinitionWriter method save.

@Override
public ReturnCode save(final Item item, final boolean careDependency) {
    ReturnCode rc = new ReturnCode();
    RepositoryWorkUnit<Object> repositoryWorkUnit = new // $NON-NLS-1$
    RepositoryWorkUnit<Object>(// $NON-NLS-1$
    "save Indicator Definition item") {

        @Override
        protected void run() throws LoginException, PersistenceException {
            TDQIndicatorDefinitionItem indicatorItem = (TDQIndicatorDefinitionItem) item;
            IndicatorDefinition indiDefinition = indicatorItem.getIndicatorDefinition();
            String oldName = indiDefinition.getLabel();
            indiDefinition.setLabel(indiDefinition.getName());
            // MOD yyi 2012-02-07 TDQ-4621:Update dependencies when careDependency is true.
            if (careDependency) {
                saveWithDependencies(indicatorItem, indiDefinition);
            } else {
                saveWithoutDependencies(indicatorItem, indiDefinition);
            }
            updateDependencies(indiDefinition);
            checkNameUpdate(oldName, item);
        }
    };
    repositoryWorkUnit.setAvoidUnloadResources(true);
    ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(repositoryWorkUnit);
    try {
        repositoryWorkUnit.throwPersistenceExceptionIfAny();
    } catch (PersistenceException e) {
        log.error(e, e);
        rc.setOk(Boolean.FALSE);
        rc.setMessage(e.getMessage());
    }
    return rc;
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 65 with IndicatorDefinition

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

the class DQRuleUtilities method createIndicatorUnit.

/**
 * DOC xqliu Comment method "createIndicatorUnit".
 *
 * @param fe
 * @param tableIndicator
 * @param analysis
 * @return
 */
public static TableIndicatorUnit createIndicatorUnit(RuleRepNode ruleRepNode, TableIndicator tableIndicator, Analysis analysis) {
    IndicatorDefinition whereRule = ruleRepNode.getRule();
    for (Indicator indicator : tableIndicator.getIndicators()) {
        if (whereRule.getName().equals(indicator.getName())) {
            return null;
        }
    }
    WhereRuleIndicator[] compositeWhereRuleIndicator = createCompositeWhereRuleIndicator(tableIndicator.getColumnSet(), whereRule);
    IndicatorEnum type = IndicatorEnum.findIndicatorEnum(compositeWhereRuleIndicator[0].eClass());
    TableIndicatorUnit addIndicatorUnit = tableIndicator.addSpecialIndicator(whereRule, type, compositeWhereRuleIndicator[0]);
    DependenciesHandler.getInstance().setUsageDependencyOn(analysis, whereRule);
    return addIndicatorUnit;
}
Also used : WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) TableIndicator(org.talend.dataprofiler.core.model.TableIndicator) Indicator(org.talend.dataquality.indicators.Indicator) WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator)

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