Search in sources :

Example 1 with TDQReportItem

use of org.talend.dataquality.properties.TDQReportItem 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 2 with TDQReportItem

use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method createRealReport.

/**
 * DOC talend Comment method "createRealReport".
 *
 * @param name the name of report
 * @param folder the path which report location
 * @param isDelete the report whether is logic delate
 */
public static Report createRealReport(String name, IFolder folder, Boolean isDelete) {
    IPath createPath = Path.EMPTY;
    if (folder != null) {
        createPath = new Path(folder.getFullPath().lastSegment());
    }
    Report report1 = ReportHelper.createReport(name);
    TDQReportItem item1 = PropertiesFactoryImpl.eINSTANCE.createTDQReportItem();
    org.talend.core.model.properties.Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    property1.setId(EcoreUtil.generateUUID());
    property1.setItem(item1);
    property1.setLabel(report1.getName());
    item1.setProperty(property1);
    item1.setReport(report1);
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(isDelete);
    item1.setState(itemState);
    try {
        ProxyRepositoryFactory.getInstance().create(item1, createPath, false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    return report1;
}
Also used : Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IPath(org.eclipse.core.runtime.IPath) Report(orgomg.cwmx.analysis.informationreporting.Report) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) TDQReportItem(org.talend.dataquality.properties.TDQReportItem)

Example 3 with TDQReportItem

use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method createRealReportNode.

/**
 * create a real ReportRepNode.
 *
 * @param name report name
 * @param folder report's parent folder
 * @param isDelete delete flag
 * @return
 */
public static ReportRepNode createRealReportNode(String name, RepositoryNode parentNode, IPath createPath, Boolean isDelete) {
    ReportRepNode reportRepNode = null;
    Report report = ReportHelper.createReport(name);
    TDQReportItem reportItem = PropertiesFactoryImpl.eINSTANCE.createTDQReportItem();
    org.talend.core.model.properties.Property reportProperty = PropertiesFactory.eINSTANCE.createProperty();
    reportProperty.setId(EcoreUtil.generateUUID());
    reportProperty.setItem(reportItem);
    reportProperty.setLabel(report.getName());
    reportItem.setProperty(reportProperty);
    reportItem.setReport(report);
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(isDelete);
    reportItem.setState(itemState);
    try {
        ProxyRepositoryFactory.getInstance().create(reportItem, createPath, false);
        IRepositoryViewObject reportViewObject = new RepositoryViewObject(reportProperty);
        reportRepNode = new ReportRepNode(reportViewObject, parentNode, ENodeType.REPOSITORY_ELEMENT, null);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    return reportRepNode;
}
Also used : ReportRepNode(org.talend.dq.nodes.ReportRepNode) Report(orgomg.cwmx.analysis.informationreporting.Report) ItemState(org.talend.core.model.properties.ItemState) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 4 with TDQReportItem

use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.

the class ResourceViewLabelProviderTest method createReport.

private void createReport(String name, IPath createPath, Boolean isDelete) {
    Report report1 = ReportHelper.createReport(name);
    TDQReportItem item1 = PropertiesFactoryImpl.eINSTANCE.createTDQReportItem();
    org.talend.core.model.properties.Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    property1.setId(EcoreUtil.generateUUID());
    property1.setItem(item1);
    property1.setLabel(report1.getName());
    item1.setProperty(property1);
    item1.setReport(report1);
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(isDelete);
    item1.setState(itemState);
    try {
        ProxyRepositoryFactory.getInstance().create(item1, createPath, false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : Report(orgomg.cwmx.analysis.informationreporting.Report) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) TDQReportItem(org.talend.dataquality.properties.TDQReportItem)

Example 5 with TDQReportItem

use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.

the class PropertyHelper method getModelElement.

/**
 * DOC bZhou Comment method "getModelElement".
 *
 * Get model element from property recognized by current system.
 *
 * @param property
 * @return
 */
public static ModelElement getModelElement(Property property) {
    Item item = property.getItem();
    assert item != null;
    ModelElement element = (ModelElement) new org.talend.core.model.properties.util.PropertiesSwitch() {

        @Override
        public Object caseDatabaseConnectionItem(DatabaseConnectionItem object) {
            return object.getConnection();
        }

        @Override
        public Object caseMDMConnectionItem(MDMConnectionItem object) {
            return object.getConnection();
        }

        @Override
        public Object caseDelimitedFileConnectionItem(DelimitedFileConnectionItem object) {
            return object.getConnection();
        }
    }.doSwitch(item);
    if (element == null) {
        element = new org.talend.dataquality.properties.util.PropertiesSwitch<ModelElement>() {

            @Override
            public ModelElement caseTDQReportItem(TDQReportItem object) {
                return object.getReport();
            }

            @Override
            public ModelElement caseTDQAnalysisItem(TDQAnalysisItem object) {
                return object.getAnalysis();
            }

            @Override
            public ModelElement caseTDQBusinessRuleItem(TDQBusinessRuleItem object) {
                return object.getDqrule();
            }

            /*
                 * (non-Javadoc)
                 * 
                 * @see
                 * org.talend.dataquality.properties.util.PropertiesSwitch#caseTDQMatchRuleItem(org.talend.dataquality
                 * .properties.TDQMatchRuleItem)
                 */
            @Override
            public ModelElement caseTDQMatchRuleItem(TDQMatchRuleItem object) {
                return object.getMatchRule();
            }

            @Override
            public ModelElement caseTDQIndicatorDefinitionItem(TDQIndicatorDefinitionItem object) {
                return object.getIndicatorDefinition();
            }

            @Override
            public ModelElement caseTDQPatternItem(TDQPatternItem object) {
                return object.getPattern();
            }
        }.doSwitch(item);
    }
    return element;
}
Also used : TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) DelimitedFileConnectionItem(org.talend.core.model.properties.DelimitedFileConnectionItem) Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) TDQItem(org.talend.core.model.properties.TDQItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) DelimitedFileConnectionItem(org.talend.core.model.properties.DelimitedFileConnectionItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Aggregations

TDQReportItem (org.talend.dataquality.properties.TDQReportItem)17 Report (orgomg.cwmx.analysis.informationreporting.Report)9 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)8 Item (org.talend.core.model.properties.Item)7 TDQPatternItem (org.talend.dataquality.properties.TDQPatternItem)7 TdReport (org.talend.dataquality.reports.TdReport)7 Analysis (org.talend.dataquality.analysis.Analysis)6 PersistenceException (org.talend.commons.exception.PersistenceException)5 Property (org.talend.core.model.properties.Property)5 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)5 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 ItemState (org.talend.core.model.properties.ItemState)4 Pattern (org.talend.dataquality.domain.pattern.Pattern)4 TDQBusinessRuleItem (org.talend.dataquality.properties.TDQBusinessRuleItem)4 IPath (org.eclipse.core.runtime.IPath)3 Connection (org.talend.core.model.metadata.builder.connection.Connection)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3 TDQItem (org.talend.core.model.properties.TDQItem)3 IFolder (org.eclipse.core.resources.IFolder)2 CoreException (org.eclipse.core.runtime.CoreException)2