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);
}
}
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;
}
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);
}
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;
}
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;
}
Aggregations