use of org.talend.dataquality.analysis.AnalysisContext 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.AnalysisContext 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.AnalysisContext in project tdq-studio-se by Talend.
the class DataExplorer method setAnalysis.
public boolean setAnalysis(Analysis analysis) {
this.analysis = analysis;
AnalysisContext context = this.analysis.getContext();
if (context == null) {
// $NON-NLS-1$
log.error(Messages.getString("DataExplorer.ANALYSISCONTEXTISNULL", analysis.getName()));
return false;
}
DataManager dataManager = context.getConnection();
if (dataManager == null) {
// $NON-NLS-1$
log.error(Messages.getString("DataExplorer.NOCONNFOUND") + analysis.getName());
return false;
}
this.dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(dataManager);
return true;
}
use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.
the class AnalysisImpl method basicSetContext.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetContext(AnalysisContext newContext, NotificationChain msgs) {
AnalysisContext oldContext = context;
context = newContext;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AnalysisPackage.ANALYSIS__CONTEXT, oldContext, newContext);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.talend.dataquality.analysis.AnalysisContext in project tdq-studio-se by Talend.
the class AnalysisSubFolderRepNode method getChildren.
/*
* (non-Jsdoc)
*
* @see org.talend.dq.nodes.AnalysisFolderRepNode#getChildren()
*/
@Override
public List<IRepositoryNode> getChildren() {
IRepositoryViewObject anaViewObject = this.getObject();
anaElement = new ArrayList<IRepositoryNode>();
if (anaViewObject == null) {
anaViewObject = this.getParent().getObject();
TDQAnalysisItem item = (TDQAnalysisItem) anaViewObject.getProperty().getItem();
Analysis analysis = item.getAnalysis();
AnalysisContext context = analysis.getContext();
EList<ModelElement> analysedElements = context.getAnalysedElements();
// EList<Indicator> indicators = results.getIndicators();
for (ModelElement analyzedElement : analysedElements) {
// ModelElement analyzedElement = indicator.getAnalyzedElement();
IRepositoryNode elementNode = doSwichNode(analyzedElement, this);
if (null == elementNode) {
// just when filtering 'elementNode' could be null
continue;
}
if (elementNode instanceof DBConnectionRepNode) {
List<IRepositoryNode> children = elementNode.getChildren();
anaElement.addAll(children);
} else {
anaElement.add(elementNode);
}
}
// MOD gdbu 2011-7-1 bug : 22204
return filterResultsIfAny(anaElement);
}
return filterResultsIfAny(super.getChildren());
// ~22204
}
Aggregations