Search in sources :

Example 36 with AnalysisContext

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());
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) Property(org.talend.core.model.properties.Property) AnalysisWriter(org.talend.dq.writer.impl.AnalysisWriter) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) DQRule(org.talend.dataquality.rules.DQRule) Test(org.junit.Test)

Example 37 with AnalysisContext

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;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Date(java.util.Date)

Example 38 with AnalysisContext

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;
}
Also used : DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext)

Example 39 with AnalysisContext

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;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext)

Example 40 with AnalysisContext

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
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Analysis(org.talend.dataquality.analysis.Analysis) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Aggregations

AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)40 Analysis (org.talend.dataquality.analysis.Analysis)30 Test (org.junit.Test)17 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)15 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)13 AnalysisParameters (org.talend.dataquality.analysis.AnalysisParameters)13 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)12 TdColumn (org.talend.cwm.relational.TdColumn)11 TdTable (org.talend.cwm.relational.TdTable)11 ArrayList (java.util.ArrayList)9 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)8 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)7 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)7 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)7 DataManager (orgomg.cwm.foundation.softwaredeployment.DataManager)7 Catalog (orgomg.cwm.resource.relational.Catalog)7 IPath (org.eclipse.core.runtime.IPath)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 Property (org.talend.core.model.properties.Property)6 TdExpression (org.talend.cwm.relational.TdExpression)6