Search in sources :

Example 6 with AnalysisResult

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

the class AElementPersistanceRealTest method testSaveWithoutDependenciesReport.

/**
 * Test method for
 * {@link org.talend.dq.writer.AElementPersistance#saveWithoutDependencies(org.talend.core.model.properties.Item, orgomg.cwm.objectmodel.core.ModelElement)}
 * .
 *
 * @throws PersistenceException
 */
@Test
public void testSaveWithoutDependenciesReport() throws PersistenceException {
    ReportWriter createReportWriter = ElementWriterFactory.getInstance().createReportWriter();
    // create analysis
    Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    createAnalysis.setResults(createAnalysisResult);
    // $NON-NLS-1$
    createAnalysis.setName("AElementPersistanceRealTestanalysis6");
    // 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("AElementPersistanceRealTestanalysis6");
    createAnalysisProperty.setId(EcoreUtil.generateUUID());
    createTDQAnalysisItem.setProperty(createAnalysisProperty);
    ProxyRepositoryFactory.getInstance().create(createTDQAnalysisItem, Path.EMPTY, false);
    // create report
    TdReport createTdReport = ReportsFactory.eINSTANCE.createTdReport();
    TDQReportItem createTDQReportItem = PropertiesFactory.eINSTANCE.createTDQReportItem();
    createTDQReportItem.setReport(createTdReport);
    Property createReportProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    // $NON-NLS-1$
    createReportProperty.setLabel("AElementPersistanceRealTestreport6");
    createTDQReportItem.setProperty(createReportProperty);
    createReportProperty.setId(EcoreUtil.generateUUID());
    ProxyRepositoryFactory.getInstance().create(createTDQReportItem, Path.EMPTY, false);
    createTdReport.addAnalysis(createAnalysis);
    // $NON-NLS-1$
    String repName = "rep61";
    // $NON-NLS-1$
    String exceptedFileName = repName + "_0.1.rep";
    createTdReport.setName(repName);
    ReturnCode create = createReportWriter.saveWithoutDependencies(createTDQReportItem, createTdReport);
    assertTrue(create.isOk());
    Assert.assertEquals(exceptedFileName, createTDQReportItem.getFilename());
    // $NON-NLS-1$
    String repName2 = "rep62";
    // $NON-NLS-1$
    String exceptedFileName2 = repName2 + "_0.1.rep";
    createTdReport.setName(repName2);
    create = createReportWriter.saveWithDependencies(createTDQReportItem, createTdReport);
    assertTrue(create.isOk());
    Assert.assertEquals(exceptedFileName2, createTDQReportItem.getFilename());
}
Also used : ReportWriter(org.talend.dq.writer.impl.ReportWriter) ReturnCode(org.talend.utils.sugars.ReturnCode) Analysis(org.talend.dataquality.analysis.Analysis) TdReport(org.talend.dataquality.reports.TdReport) Property(org.talend.core.model.properties.Property) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Test(org.junit.Test)

Example 7 with AnalysisResult

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

the class EMFSharedResourcesTest method createRealAnalysis.

private Item createRealAnalysis(String name, IFolder folder, Boolean isDelete) {
    IPath createPath = Path.EMPTY;
    if (folder != null) {
        createPath = new Path(folder.getFullPath().lastSegment());
    }
    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) {
        fail(e.getMessage());
    }
    return item1;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) Analysis(org.talend.dataquality.analysis.Analysis) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 8 with AnalysisResult

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

the class UnitTestBuildHelper method createRealAnalysis.

/**
 * DOC qiongli Comment method "createRealAnalysis".
 *
 * @param name
 * @param folder
 * @param isDelete
 * @return
 */
public static Analysis createRealAnalysis(String name, IFolder folder, Boolean isDelete) {
    IPath createPath = Path.EMPTY;
    if (folder != null) {
        createPath = new Path(folder.getFullPath().lastSegment());
    }
    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());
    }
    return analysis1;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) Analysis(org.talend.dataquality.analysis.Analysis) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 9 with AnalysisResult

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

the class MatchAnalysisExecutorTest method executeAnalysis.

/**
 * DOC zhao Comment method "executeAnalysis".
 *
 * @param matchAnalysisExecutor
 * @param analysis
 * @param matchIndicator
 */
private void executeAnalysis(MatchAnalysisExecutor matchAnalysisExecutor, Analysis analysis, RecordMatchingIndicator matchIndicator) {
    BlockKeyIndicator blockKeyIndicator = ColumnsetPackage.eINSTANCE.getColumnsetFactory().createBlockKeyIndicator();
    AnalysisResult anaResult = AnalysisPackage.eINSTANCE.getAnalysisFactory().createAnalysisResult();
    anaResult.setResultMetadata(AnalysisPackage.eINSTANCE.getAnalysisFactory().createExecutionInformations());
    analysis.setResults(anaResult);
    analysis.getResults().getIndicators().add(matchIndicator);
    analysis.getResults().getIndicators().add(blockKeyIndicator);
    matchAnalysisExecutor.setMonitor(new NullProgressMonitor());
    matchAnalysisExecutor.execute(analysis);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) BlockKeyIndicator(org.talend.dataquality.indicators.columnset.BlockKeyIndicator) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult)

Example 10 with AnalysisResult

use of org.talend.dataquality.analysis.AnalysisResult 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

AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)40 Analysis (org.talend.dataquality.analysis.Analysis)26 Test (org.junit.Test)15 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)15 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)14 ExecutionInformations (org.talend.dataquality.analysis.ExecutionInformations)13 Property (org.talend.core.model.properties.Property)11 PersistenceException (org.talend.commons.exception.PersistenceException)10 ItemState (org.talend.core.model.properties.ItemState)10 Path (org.eclipse.core.runtime.Path)8 TdColumn (org.talend.cwm.relational.TdColumn)8 TdTable (org.talend.cwm.relational.TdTable)8 Indicator (org.talend.dataquality.indicators.Indicator)8 IPath (org.eclipse.core.runtime.IPath)7 AnalysisParameters (org.talend.dataquality.analysis.AnalysisParameters)7 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)7 ReturnCode (org.talend.utils.sugars.ReturnCode)7 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)6 Before (org.junit.Before)5 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)4