Search in sources :

Example 16 with AnalysisParameters

use of org.talend.dataquality.analysis.AnalysisParameters 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 17 with AnalysisParameters

use of org.talend.dataquality.analysis.AnalysisParameters in project tdq-studio-se by Talend.

the class AnalysisHelper method setAnalysisType.

/**
 * Method "setAnalysisType".
 *
 * @param analysis an analysis
 * @param analysisType the type to set to the analysis
 */
public static void setAnalysisType(Analysis analysis, AnalysisType analysisType) {
    AnalysisParameters parameters = analysis.getParameters();
    if (parameters == null) {
        parameters = AnalysisFactory.eINSTANCE.createAnalysisParameters();
        analysis.setParameters(parameters);
    }
    parameters.setAnalysisType(analysisType);
}
Also used : AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters)

Example 18 with AnalysisParameters

use of org.talend.dataquality.analysis.AnalysisParameters in project tdq-studio-se by Talend.

the class AnalysisHelper method getStringDataFilter.

/**
 * DOC xqliu Comment method "getStringDataFilter".
 *
 * @param analysis
 * @param index 0 for DataFilterA, 1 for DataFilterB
 * @return
 */
public static String getStringDataFilter(Analysis analysis, int index) {
    AnalysisParameters parameters = analysis.getParameters();
    if (parameters == null) {
        return null;
    }
    EList<Domain> dataFilters = parameters.getDataFilter();
    // remove existing filters
    if (dataFilters == null || dataFilters.isEmpty()) {
        return null;
    }
    int i = 0;
    for (Domain domain : dataFilters) {
        if (domain == null) {
            continue;
        }
        EList<RangeRestriction> ranges = domain.getRanges();
        for (RangeRestriction rangeRestriction : ranges) {
            BooleanExpressionNode expressions = rangeRestriction.getExpressions();
            if (expressions == null) {
                continue;
            }
            Expression expression = expressions.getExpression();
            if (expression == null) {
                continue;
            }
            if (i == index) {
                // MOD klliu 2011-07-14 bug 23150 solve an NPE
                String body = expression.getBody();
                if (body == null) {
                    continue;
                }
                // ~
                return body.trim();
            } else if (i > index) {
                return null;
            }
        }
        i++;
    }
    return null;
}
Also used : Expression(orgomg.cwm.objectmodel.core.Expression) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) BooleanExpressionNode(org.talend.dataquality.expressions.BooleanExpressionNode) RangeRestriction(org.talend.dataquality.domain.RangeRestriction) Domain(org.talend.dataquality.domain.Domain)

Example 19 with AnalysisParameters

use of org.talend.dataquality.analysis.AnalysisParameters in project tdq-studio-se by Talend.

the class AnalysisImpl method basicSetParameters.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetParameters(AnalysisParameters newParameters, NotificationChain msgs) {
    AnalysisParameters oldParameters = parameters;
    parameters = newParameters;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AnalysisPackage.ANALYSIS__PARAMETERS, oldParameters, newParameters);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

AnalysisParameters (org.talend.dataquality.analysis.AnalysisParameters)19 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)13 Analysis (org.talend.dataquality.analysis.Analysis)10 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)7 Test (org.junit.Test)6 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)6 TdTable (org.talend.cwm.relational.TdTable)6 TdColumn (org.talend.cwm.relational.TdColumn)5 ExecutionInformations (org.talend.dataquality.analysis.ExecutionInformations)5 Before (org.junit.Before)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)3 Domain (org.talend.dataquality.domain.Domain)3 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)3 Package (orgomg.cwm.objectmodel.core.Package)3 IPath (org.eclipse.core.runtime.IPath)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 TdSqlDataType (org.talend.cwm.relational.TdSqlDataType)2 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)2