Search in sources :

Example 1 with DQRule

use of org.talend.dataquality.rules.DQRule in project tdq-studio-se by Talend.

the class AbstractAnalysisMetadataPage method updateDQRuleDependency.

/**
 * ADD gdbu 2011-6-1 bug : 19833
 *
 * DOC gdbu Comment method "updateDQRuleDependency".
 *
 * @param dqRules
 */
protected void updateDQRuleDependency(List<DQRule> dqRules) {
    for (DQRule dqRule : dqRules) {
        List<Dependency> realSupplierDependency = new ArrayList<Dependency>();
        EList<Dependency> supplierDependency = dqRule.getSupplierDependency();
        for (Dependency dependency : supplierDependency) {
            EList<ModelElement> client = dependency.getClient();
            for (ModelElement modelElement : client) {
                if (modelElement instanceof Analysis) {
                    List<DQRule> dqRules2 = getDqRules((Analysis) modelElement);
                    if (dqRules2.contains(dqRule)) {
                        realSupplierDependency.add(dependency);
                    }
                }
            }
        }
        supplierDependency.clear();
        supplierDependency.addAll(realSupplierDependency);
    }
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) ArrayList(java.util.ArrayList) Dependency(orgomg.cwm.objectmodel.core.Dependency) DQRule(org.talend.dataquality.rules.DQRule)

Example 2 with DQRule

use of org.talend.dataquality.rules.DQRule in project tdq-studio-se by Talend.

the class AbstractAnalysisMetadataPage method getDqRules.

/**
 * ADD gdbu 2011-6-1 bug : 19833
 *
 * DOC gdbu Comment method "getDqRules". Get all DQRule from analysis.
 *
 * @param analysis
 * @return
 */
public List<DQRule> getDqRules(Analysis analysis) {
    List<DQRule> result = new ArrayList<DQRule>();
    EList<Indicator> indicators = analysis.getResults().getIndicators();
    for (Indicator indicator : indicators) {
        IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
        if (indicatorDefinition instanceof DQRule) {
            result.add((DQRule) indicatorDefinition);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) Indicator(org.talend.dataquality.indicators.Indicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) DQRule(org.talend.dataquality.rules.DQRule)

Example 3 with DQRule

use of org.talend.dataquality.rules.DQRule in project tdq-studio-se by Talend.

the class FileTreeLabelProviderTest method setUpBeforeClass.

/**
 * DOC zshen Comment method "setUpBeforeClass".
 *
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    DQRule createSqlRule = RulesFactory.eINSTANCE.createWhereRule();
    ParserRule createParserRule = RulesFactory.eINSTANCE.createParserRule();
    MatchRuleDefinition createMatchRuleDefinition = RulesFactory.eINSTANCE.createMatchRuleDefinition();
    // $NON-NLS-1$
    createSqlRule.setName("sqlRule1");
    // $NON-NLS-1$
    createParserRule.setName("parserRule1");
    // $NON-NLS-1$
    createMatchRuleDefinition.setName("matchRule");
    createTDQSQLRuleItem = PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
    createTDQSQLRuleItem.setDqrule(createSqlRule);
    createTDQParserRuleItem = PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
    createTDQParserRuleItem.setDqrule(createParserRule);
    createTDQMatchRuleItem = PropertiesFactory.eINSTANCE.createTDQMatchRuleItem();
    createTDQMatchRuleItem.setMatchRule(createMatchRuleDefinition);
    Property createSQLRuleProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    createSQLRuleProperty.setItem(createTDQSQLRuleItem);
    createSQLRuleProperty.setLabel(createSqlRule.getName());
    Property createParserRuleProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    createParserRuleProperty.setItem(createTDQParserRuleItem);
    createParserRuleProperty.setLabel(createParserRule.getName());
    Property createMatchRuleProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    createMatchRuleProperty.setItem(createTDQMatchRuleItem);
    createMatchRuleProperty.setLabel(createMatchRuleDefinition.getName());
    ProxyRepositoryFactory.getInstance().create(createTDQSQLRuleItem, Path.EMPTY);
    ProxyRepositoryFactory.getInstance().create(createTDQParserRuleItem, Path.EMPTY);
    ProxyRepositoryFactory.getInstance().create(createTDQMatchRuleItem, Path.EMPTY);
}
Also used : ParserRule(org.talend.dataquality.rules.ParserRule) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) Property(org.talend.core.model.properties.Property) DQRule(org.talend.dataquality.rules.DQRule) BeforeClass(org.junit.BeforeClass)

Example 4 with DQRule

use of org.talend.dataquality.rules.DQRule in project tdq-studio-se by Talend.

the class AElementPersistance method createItem.

/**
 * DOC bZhou Comment method "createItem".
 *
 * @param element
 * @return
 */
public Item createItem(ModelElement element) {
    Item item = null;
    // MOD mzhao feature 13114, 2010-05-19 distinguish tdq items.
    if (ModelElementIdentifier.isAnalysis(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
        ((TDQAnalysisItem) item).setAnalysis((Analysis) element);
    } else if (ModelElementIdentifier.isDQRule(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
        ((TDQBusinessRuleItem) item).setDqrule((DQRule) element);
    } else if (ModelElementIdentifier.isDataProvider(element)) {
        if (element instanceof DatabaseConnection) {
            item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
            ((ConnectionItem) item).setConnection((DatabaseConnection) element);
        }
        ((ConnectionItem) item).setConnection((Connection) element);
    } else if (ModelElementIdentifier.isMatchRule(element)) {
        // this Condition must before the IndicatorDefinition one because MatchRule instance of it.
        item = PropertiesFactory.eINSTANCE.createTDQMatchRuleItem();
        ((TDQMatchRuleItem) item).setMatchRule((MatchRuleDefinition) element);
    } else if (ModelElementIdentifier.isID(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
        ((TDQIndicatorDefinitionItem) item).setIndicatorDefinition((IndicatorDefinition) element);
    } else if (ModelElementIdentifier.isPattern(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQPatternItem();
        ((TDQPatternItem) item).setPattern((Pattern) element);
    } else if (ModelElementIdentifier.isReport(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQReportItem();
        ((TDQReportItem) item).setReport((Report) element);
    } else {
        item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createTDQItem();
    }
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(false);
    item.setState(itemState);
    if (item instanceof TDQItem) {
        setTDQItemFileName(element, item);
    }
    Resource eResource = element.eResource();
    if (eResource != null) {
        URI uri = eResource.getURI();
        if (uri.isPlatform()) {
            IPath elementPath = new Path(uri.toPlatformString(true)).removeLastSegments(1);
            IPath typedPath = ResourceManager.getRootProject().getFullPath().append(PropertyHelper.getItemTypedPath(item));
            IPath statePath = elementPath.makeRelativeTo(typedPath);
            itemState.setPath(statePath.toString());
        }
    }
    return item;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Pattern(org.talend.dataquality.domain.pattern.Pattern) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) IPath(org.eclipse.core.runtime.IPath) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Resource(org.eclipse.emf.ecore.resource.Resource) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) URI(org.eclipse.emf.common.util.URI) DQRule(org.talend.dataquality.rules.DQRule) Item(org.talend.core.model.properties.Item) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) TDQItem(org.talend.core.model.properties.TDQItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) ItemState(org.talend.core.model.properties.ItemState) TDQItem(org.talend.core.model.properties.TDQItem) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 5 with DQRule

use of org.talend.dataquality.rules.DQRule in project tdq-studio-se by Talend.

the class DQRuleWriter 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 DQRule item") {

        @Override
        protected void run() throws LoginException, PersistenceException {
            TDQBusinessRuleItem ruleItem = (TDQBusinessRuleItem) item;
            DQRule rule = ruleItem.getDqrule();
            // MOD yyi 2012-02-07 TDQ-4621:Update dependencies(connection) when careDependency is true.
            if (careDependency) {
                saveWithDependencies(ruleItem, rule);
            } else {
                saveWithoutDependencies(ruleItem, rule);
            }
        }
    };
    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) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) DQRule(org.talend.dataquality.rules.DQRule)

Aggregations

DQRule (org.talend.dataquality.rules.DQRule)11 Property (org.talend.core.model.properties.Property)5 Analysis (org.talend.dataquality.analysis.Analysis)5 TDQBusinessRuleItem (org.talend.dataquality.properties.TDQBusinessRuleItem)5 Pattern (org.talend.dataquality.domain.pattern.Pattern)4 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)4 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)4 PersistenceException (org.talend.commons.exception.PersistenceException)3 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)3 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)3 TDQPatternItem (org.talend.dataquality.properties.TDQPatternItem)3 ArrayList (java.util.ArrayList)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)2 Item (org.talend.core.model.properties.Item)2 TDQItem (org.talend.core.model.properties.TDQItem)2 TDQMatchRuleItem (org.talend.dataquality.properties.TDQMatchRuleItem)2 TDQReportItem (org.talend.dataquality.properties.TDQReportItem)2 AnalysisWriter (org.talend.dq.writer.impl.AnalysisWriter)2 ReturnCode (org.talend.utils.sugars.ReturnCode)2