use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.
the class SQLPatternExplorerTest method setUp.
/**
* DOC msjian Comment method "setUp".
*
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
UnitTestBuildHelper.initProjectStructure();
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQItemService.class)) {
ITDQItemService tdqService = (ITDQItemService) GlobalServiceRegister.getDefault().getService(ITDQItemService.class);
tdqService.createDQStructor();
}
sqlPatternExplorer = new SQLPatternExplorer();
// mock setEntity
SqlPatternMatchingIndicator indicator = creatSqlPatternMatchingIndicator();
Analysis ana = UnitTestBuildHelper.createAndInitAnalysis();
AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
createAnalysisResult.setResultMetadata(createExecutionInformations);
createAnalysisResult.getIndicators().add(indicator);
ana.setResults(createAnalysisResult);
sqlPatternExplorer.setAnalysis(ana);
// $NON-NLS-1$ //$NON-NLS-2$
ChartDataEntity chartDataEntity = new ChartDataEntity(indicator, "name1", "1");
chartDataEntity.setLabelNull(false);
// $NON-NLS-1$
chartDataEntity.setKey("name1");
sqlPatternExplorer.setEnitty(chartDataEntity);
IndicatorDefinition definition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
TdExpression expression = RelationalFactory.eINSTANCE.createTdExpression();
expression.setBody("SELECT * FROM tbi.customer ");
// $NON-NLS-1$
expression.setLanguage("SQL");
definition.getSqlGenericExpression().add(expression);
indicator.setIndicatorDefinition(definition);
indicator.getInstantiatedExpressions().add(expression);
}
use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.
the class ResourceViewLabelProviderTest method createAnalysis.
private void createAnalysis(String name, IPath createPath, Boolean isDelete) {
Analysis analysis1 = AnalysisHelper.createAnalysis(name);
TDQAnalysisItem item1 = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
org.talend.core.model.properties.Property property1 = PropertiesFactory.eINSTANCE.createProperty();
property1.setId(EcoreUtil.generateUUID());
property1.setItem(item1);
property1.setLabel(analysis1.getName());
item1.setProperty(property1);
item1.setAnalysis(analysis1);
ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(isDelete);
item1.setState(itemState);
AnalysisResult analysisResult1 = AnalysisFactory.eINSTANCE.createAnalysisResult();
analysis1.setResults(analysisResult1);
try {
ProxyRepositoryFactory.getInstance().create(item1, createPath, false);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
}
use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.
the class ColumnSetIndicatorEvaluator method executeSqlQuery.
@Override
protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
ReturnCode ok = new ReturnCode(true);
AnalysisResult anaResult = analysis.getResults();
EMap<Indicator, AnalyzedDataSet> indicToRowMap = anaResult.getIndicToRowMap();
indicToRowMap.clear();
if (isDelimitedFile) {
ok = evaluateByDelimitedFile(sqlStatement, ok);
} else {
ok = evaluateBySql(sqlStatement, ok);
}
return ok;
}
use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.
the class AnalysisExecutorHelper method check.
/**
* Method "check" checks that the analysis can be run.
*
* @param analysis the analysis to prepare
* @return true if ok.
*/
public static ReturnCode check(Analysis analysis) {
ReturnCode rc = new ReturnCode(Boolean.TRUE);
// --- check existence of context
AnalysisContext context = analysis.getContext();
if (context == null) {
// $NON-NLS-1$
rc.setMessage(Messages.getString("AnalysisExecutor.ContextNull", analysis.getName()));
rc.setOk(Boolean.FALSE);
return rc;
}
// --- check that there exists at least on element to analyze
if (context.getAnalysedElements().size() == 0) {
// $NON-NLS-1$
rc.setMessage(Messages.getString("ColumnAnalysisExecutor.AnalysisHaveAtLeastOneColumn"));
rc.setOk(Boolean.FALSE);
return rc;
}
// --- check that the connection has been set
DataManager connection = context.getConnection();
if (connection == null) {
// $NON-NLS-1$
rc.setMessage(Messages.getString("AnalysisExecutor.NoConnectionFound", analysis.getName()));
rc.setOk(Boolean.FALSE);
return rc;
}
if (log.isInfoEnabled()) {
if (SoftwaredeploymentPackage.eINSTANCE.getDataProvider().isInstance(connection)) {
// MOD 20130225 TDQ-6632 the name of the item should be given (not the pathname)
// $NON-NLS-1$
log.info(Messages.getString("AnalysisExecutor.CONNECTIONTO", connection.getName()));
}
}
AnalysisResult results = analysis.getResults();
if (results == null) {
// $NON-NLS-1$
rc.setMessage(Messages.getString("AnalysisExecutor.AnalysisnotNotPrepareCorrect", analysis.getName()));
rc.setOk(Boolean.FALSE);
return rc;
}
// --- check the the dependeny files are exists ADDED mzhao TDQ-10428---
rc = checkDependentFiles(analysis);
return rc;
}
use of org.talend.dataquality.analysis.AnalysisResult in project tdq-studio-se by Talend.
the class FrequencyTypeStateUtil method isWithRowCountIndicator.
public static boolean isWithRowCountIndicator(Indicator indicator) {
ModelElement currentAnalyzedElement = indicator.getAnalyzedElement();
InternalEObject eIndicator = (InternalEObject) indicator;
AnalysisResult result = (AnalysisResult) eIndicator.eContainer();
// MOD msjian TDQ-5960: fix a NPE
if (result == null) {
return false;
}
EList<Indicator> indicators = result.getIndicators();
if (indicators != null) {
for (Indicator indi : indicators) {
ModelElement analyzedElement = indi.getAnalyzedElement();
if (analyzedElement == currentAnalyzedElement) {
if (indi instanceof RowCountIndicator) {
return true;
} else if (indi instanceof CountsIndicator) {
CountsIndicator cindi = (CountsIndicator) indi;
return cindi.getRowCountIndicator() != null;
}
}
}
}
return false;
}
Aggregations