Search in sources :

Example 11 with IndicatorDefinition

use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.

the class AddHiveCharMapInPatternFrenquencyTask method doExecute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.migration.AMigrationTask#doExecute()
     */
@Override
protected boolean doExecute() throws Exception {
    DefinitionHandler definitionHandler = DefinitionHandler.getInstance();
    boolean isFrequencyAdded = true;
    boolean isLowFrequencyAdded = true;
    // Add CharacterMapping of hive to pattern frenquency indicator
    IndicatorDefinition hiveDefinition = definitionHandler.getDefinitionById(PATTERN_FREQUENCY_UUID);
    if (hiveDefinition != null && !IndicatorDefinitionFileHelper.isExistCharacterMappingWithLanguage(hiveDefinition, hive)) {
        IndicatorDefinitionFileHelper.addCharacterMapping(hiveDefinition, hive, CHAR_NAME, CHAR_TOREPLACE, CHAR_REPLACE);
        isFrequencyAdded = IndicatorDefinitionFileHelper.save(hiveDefinition);
    }
    // Update CharacterMapping of hive to pattern low frenquency indicator
    IndicatorDefinition lowDefinition = definitionHandler.getDefinitionById(PATTERN_LOW_FREQUENCY_UUID);
    if (hiveDefinition != null && !IndicatorDefinitionFileHelper.isExistCharacterMappingWithLanguage(lowDefinition, hive)) {
        IndicatorDefinitionFileHelper.addCharacterMapping(lowDefinition, hive, CHAR_NAME, CHAR_TOREPLACE, CHAR_REPLACE);
        isLowFrequencyAdded = IndicatorDefinitionFileHelper.save(lowDefinition);
    }
    DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
    if (!isFrequencyAdded || !isLowFrequencyAdded) {
        return false;
    }
    return true;
}
Also used : DefinitionHandler(org.talend.dq.indicators.definitions.DefinitionHandler) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 12 with IndicatorDefinition

use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.

the class UpdateAllIndicators4DefaultTask method doExecute.

@Override
protected boolean doExecute() throws Exception {
    boolean result = true;
    List<IndicatorDefinition> indiDefinitions = DefinitionHandler.getInstance().getIndicatorsDefinitions();
    for (IndicatorDefinition indiDefinition : indiDefinitions) {
        if (indiDefinition != null) {
            EList<TdExpression> sqlGenericExpression = indiDefinition.getSqlGenericExpression();
            for (TdExpression exp : sqlGenericExpression) {
                // both "Default" and "Default "
                if (Language.equals(exp.getLanguage().trim())) {
                    exp.setLanguage(newLanguage);
                    break;
                }
            }
            result = result && IndicatorDefinitionFileHelper.save(indiDefinition);
        }
    }
    DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
    return result;
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 13 with IndicatorDefinition

use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.

the class IndicatorImpl method setIndicatorDefinition.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override
public void setIndicatorDefinition(IndicatorDefinition newIndicatorDefinition) {
    IndicatorDefinition oldIndicatorDefinition = indicatorDefinition;
    indicatorDefinition = newIndicatorDefinition;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, IndicatorsPackage.INDICATOR__INDICATOR_DEFINITION, oldIndicatorDefinition, indicatorDefinition));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 14 with IndicatorDefinition

use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.

the class UDIHelperTest method testContainsJavaUDI4.

/**
 * Test method for
 * {@link org.talend.dq.helper.UDIHelper#containsJavaUDI(org.talend.dataquality.indicators.definition.IndicatorDefinition)}
 * .
 */
@Test
public void testContainsJavaUDI4() {
    // prepare data
    IndicatorDefinition javaIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    // testMethod
    assertFalse(UDIHelper.containsJavaUDI(javaIndicatorDefinition));
}
Also used : IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) Test(org.junit.Test)

Example 15 with IndicatorDefinition

use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.

the class MultiColumnAnalysisExecutorTest method setUp.

@Before
public void setUp() throws Exception {
    analysis = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisContext context = AnalysisFactory.eINSTANCE.createAnalysisContext();
    analysis.setContext(context);
    // mock(Catalog.class);
    Package catalog = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
    // $NON-NLS-1$
    catalog.setName("tbi");
    TdTable tdTable = RelationalFactory.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    tdTable.setName("customer");
    tdTable.setNamespace(catalog);
    TdColumn tdColumn = RelationalFactory.eINSTANCE.createTdColumn();
    tdColumn.setOwner(tdTable);
    // $NON-NLS-1$
    tdColumn.setName("date_accnt_opened");
    tdColumn.setContentType(DataminingType.INTERVAL.getName());
    TdColumn tdColumn2 = RelationalFactory.eINSTANCE.createTdColumn();
    tdColumn2.setOwner(tdTable);
    // $NON-NLS-1$
    tdColumn2.setName("product_id");
    tdColumn2.setContentType(DataminingType.INTERVAL.getName());
    AnalysisParameters analysisPara = AnalysisFactory.eINSTANCE.createAnalysisParameters();
    analysisPara.setStoreData(false);
    // set analysis type is columnset
    analysisPara.setAnalysisType(AnalysisType.COLUMN_SET);
    analysis.setParameters(analysisPara);
    context.getAnalysedElements().add(tdColumn);
    context.getAnalysedElements().add(tdColumn2);
    AnalysisResult analysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    ExecutionInformations info = AnalysisFactory.eINSTANCE.createExecutionInformations();
    analysisResult.setResultMetadata(info);
    simpleStatIndicator = ColumnsetFactory.eINSTANCE.createSimpleStatIndicator();
    TdExpression expression = RelationalFactory.eINSTANCE.createTdExpression();
    expression.setBody(// $NON-NLS-1$
    "SELECT <%=__COLUMN_NAMES__%> FROM <%=__TABLE_NAME__%> <%=__WHERE_CLAUSE__%> GROUP BY <%=__GROUP_BY_ALIAS__%>");
    // $NON-NLS-1$
    expression.setLanguage("SQL");
    IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    indicatorDefinition.getSqlGenericExpression().add(expression);
    simpleStatIndicator.setIndicatorDefinition(indicatorDefinition);
    // $NON-NLS-1$
    simpleStatIndicator.getDateFunctions().add("");
    // $NON-NLS-1$
    simpleStatIndicator.getNumericFunctions().add("");
    simpleStatIndicator.setDataminingType(DataminingType.NOMINAL);
    simpleStatIndicator.getAnalyzedColumns().add(tdColumn);
    simpleStatIndicator.getAnalyzedColumns().add(tdColumn2);
    analysisResult.getIndicators().add(simpleStatIndicator);
    analysis.setResults(analysisResult);
}
Also used : ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) TdTable(org.talend.cwm.relational.TdTable) TdColumn(org.talend.cwm.relational.TdColumn) TdExpression(org.talend.cwm.relational.TdExpression) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Package(orgomg.cwm.objectmodel.core.Package) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Before(org.junit.Before)

Aggregations

IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)141 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)37 Test (org.junit.Test)35 ArrayList (java.util.ArrayList)34 TdExpression (org.talend.cwm.relational.TdExpression)31 File (java.io.File)22 Analysis (org.talend.dataquality.analysis.Analysis)16 IFile (org.eclipse.core.resources.IFile)15 Property (org.talend.core.model.properties.Property)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)14 PersistenceException (org.talend.commons.exception.PersistenceException)13 Indicator (org.talend.dataquality.indicators.Indicator)12 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)12 Path (org.eclipse.core.runtime.Path)10 IFolder (org.eclipse.core.resources.IFolder)9 BasicEList (org.eclipse.emf.common.util.BasicEList)9 TdColumn (org.talend.cwm.relational.TdColumn)9 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)7 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)7