use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.
the class ItemRecordTest method createAnalysis.
private Property createAnalysis(String name) throws PersistenceException {
// create analysis
Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
AnalysisContext createAnalysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
createAnalysis.setResults(createAnalysisResult);
createAnalysis.setContext(createAnalysisContext);
createAnalysis.setName(name);
// create analysis item
TDQAnalysisItem createTDQAnalysisItem = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
createTDQAnalysisItem.setAnalysis(createAnalysis);
Property createAnalysisProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
createAnalysisProperty.setLabel(name);
createTDQAnalysisItem.setProperty(createAnalysisProperty);
createAnalysisProperty.setId(EcoreUtil.generateUUID());
ProxyRepositoryFactory.getInstance().create(createTDQAnalysisItem, Path.EMPTY, false);
return createAnalysisProperty;
}
use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.
the class AElementPersistanceRealTest method testSaveWithDependenciesAnalysis.
/**
* Test method for
* {@link org.talend.dq.writer.AElementPersistance#saveWithDependencies(org.talend.core.model.properties.Item, orgomg.cwm.objectmodel.core.ModelElement)}
* .
*
* @throws PersistenceException
*/
@Test
public void testSaveWithDependenciesAnalysis() throws PersistenceException {
AnalysisWriter createAnalysisWriter = ElementWriterFactory.getInstance().createAnalysisWrite();
String anaName = "AElementPersistanceRealTestanalysis5";
// create analysis
Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
AnalysisContext createAnalysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
createAnalysis.setResults(createAnalysisResult);
createAnalysis.setContext(createAnalysisContext);
createAnalysis.setName(anaName);
// create analysis item
TDQAnalysisItem createTDQAnalysisItem = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
createTDQAnalysisItem.setAnalysis(createAnalysis);
Property createAnalysisProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
// $NON-NLS-1$
createAnalysisProperty.setLabel("AElementPersistanceRealTestanalysis5");
createTDQAnalysisItem.setProperty(createAnalysisProperty);
createAnalysisProperty.setId(EcoreUtil.generateUUID());
ProxyRepositoryFactory.getInstance().create(createTDQAnalysisItem, Path.EMPTY, false);
// create pattern match indicator
WhereRuleIndicator whereRuleIndicator = IndicatorSqlFactory.eINSTANCE.createWhereRuleIndicator();
// create definition
createAnalysisResult.getIndicators().add(whereRuleIndicator);
DQRule dqRule = RulesFactory.eINSTANCE.createWhereRule();
whereRuleIndicator.setIndicatorDefinition(dqRule);
TDQBusinessRuleItem createTDQBusinessRuleItem = PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
createTDQBusinessRuleItem.setDqrule(dqRule);
Property createPatternProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
// $NON-NLS-1$
createPatternProperty.setLabel("AElementPersistanceRealTestDQRule5");
createTDQBusinessRuleItem.setProperty(createPatternProperty);
createPatternProperty.setId(EcoreUtil.generateUUID());
ProxyRepositoryFactory.getInstance().create(createTDQBusinessRuleItem, Path.EMPTY, false);
// $NON-NLS-1$
String exceptedFileName = anaName + "_0.1.ana";
ReturnCode create = createAnalysisWriter.saveWithDependencies(createTDQAnalysisItem, createAnalysis);
assertTrue(create.isOk());
Assert.assertEquals(exceptedFileName, createTDQAnalysisItem.getFilename());
// $NON-NLS-1$
String anaName2 = "ana52";
// $NON-NLS-1$
String exceptedFileName2 = anaName2 + "_0.1.ana";
createAnalysis.setName(anaName2);
create = createAnalysisWriter.saveWithDependencies(createTDQAnalysisItem, createAnalysis);
assertTrue(create.isOk());
Assert.assertEquals(exceptedFileName2, createTDQAnalysisItem.getFilename());
}
use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.
the class ResourceUtils method createAnalysis.
public static Analysis createAnalysis(Indicator indicator) {
AnalysisParameters createAnalysisParameters = AnalysisFactory.eINSTANCE.createAnalysisParameters();
setUUID(null, createAnalysisParameters);
createAnalysisParameters.setAnalysisType(AnalysisType.MULTIPLE_COLUMN);
Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
setUUID(null, createAnalysis);
AnalysisContext createAnalysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
setUUID(null, createAnalysisContext);
// $NON-NLS-1$
MetadataColumn createMetadataColumn = createMetadataColumn("columnName");
createAnalysisContext.getAnalysedElements().add(createMetadataColumn);
createAnalysis.setContext(createAnalysisContext);
AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
setUUID(null, createAnalysisResult);
ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
setUUID(null, createExecutionInformations);
createAnalysisResult.setResultMetadata(createExecutionInformations);
createAnalysisResult.getIndicators().add(indicator);
indicator.setAnalyzedElement(createMetadataColumn);
createAnalysis.setResults(createAnalysisResult);
createAnalysis.setParameters(createAnalysisParameters);
// $NON-NLS-1$
createAnalysis.setName("anaName");
// $NON-NLS-1$
MetadataHelper.setAuthor(createAnalysis, "shenze");
createAnalysis.setCreationDate(new Date(System.currentTimeMillis()));
setUUID(null, indicator);
return createAnalysis;
}
use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.
the class ColumnAnalysisSqlExecutor method createSqlStatement.
/*
* (non-Javadoc)
*
* @see org.talend.dq.analysis.AnalysisExecutor#createSqlStatement(org.talend.dataquality.analysis.Analysis)
*/
@Override
public String createSqlStatement(Analysis analysis) {
this.cachedAnalysis = analysis;
AnalysisResult results = analysis.getResults();
assert results != null;
try {
// --- get data filter
ModelElementAnalysisHandler handler = new ModelElementAnalysisHandler();
handler.setAnalysis(analysis);
String stringDataFilter = handler.getStringDataFilter();
// --- get all the leaf indicators used for the sql computation
Collection<Indicator> leafIndicators = IndicatorHelper.getIndicatorLeaves(results);
// --- create one sql statement for each leaf indicator
for (Indicator indicator : leafIndicators) {
if (!this.continueRun()) {
break;
}
if (!createSqlQuery(stringDataFilter, indicator)) {
log.error(Messages.getString("ColumnAnalysisSqlExecutor.CREATEQUERYERROR", // $NON-NLS-1$
AnalysisExecutorHelper.getIndicatorName(indicator)));
// return null;
}
}
} catch (AnalysisExecutionException e) {
log.error(e, e);
return null;
}
return PluginConstant.EMPTY_STRING;
}
use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.
the class TableAnalysisSqlExecutor method createSqlStatement.
@Override
protected String createSqlStatement(Analysis analysis) {
this.cachedAnalysis = analysis;
AnalysisResult results = analysis.getResults();
assert results != null;
try {
// --- get data filter
stringDataFilter = ContextHelper.getDataFilterWithoutContext(analysis);
// --- get all the leaf indicators used for the sql computation
Collection<Indicator> leafIndicators = IndicatorHelper.getIndicatorLeavesBySingleNode(results);
// --- create one sql statement for each leaf indicator
for (Indicator indicator : leafIndicators) {
if (!createSqlQuery(stringDataFilter, indicator, false)) {
log.error(Messages.getString("ColumnAnalysisSqlExecutor.CREATEQUERYERROR", // $NON-NLS-1$
AnalysisExecutorHelper.getIndicatorName(indicator)));
return null;
}
}
} catch (AnalysisExecutionException e) {
log.error(e, e);
return null;
}
return PluginConstant.EMPTY_STRING;
}
Aggregations