Search in sources :

Example 11 with TdReport

use of org.talend.dataquality.reports.TdReport in project tdq-studio-se by Talend.

the class ReportHelper method createReport.

public static TdReport createReport(String name) {
    TdReport report = ReportsFactory.eINSTANCE.createTdReport();
    report.setName(name);
    return report;
}
Also used : TdReport(org.talend.dataquality.reports.TdReport)

Example 12 with TdReport

use of org.talend.dataquality.reports.TdReport in project tdq-studio-se by Talend.

the class EObjectHelper method getDependedReportOfJrxml.

/**
 * Go throught all reports in the project and return all which used the current jrxml.
 *
 * @param node the Jrxml node
 * @return list of reports who used this jrxml as user defined template
 */
public static List<ModelElement> getDependedReportOfJrxml(IRepositoryNode node) {
    List<ModelElement> dependedReport = new ArrayList<ModelElement>();
    if (node.getObject().getProperty() == null) {
        return dependedReport;
    }
    IPath path = PropertyHelper.getItemPath(node.getObject().getProperty());
    // check if it has depended Report
    // get all reports
    List<ReportRepNode> repNodes = RepositoryNodeHelper.getReportRepNodes(RepositoryNodeHelper.getDataProfilingFolderNode(EResourceConstant.REPORTS), true, true);
    // go through every report to find if any one used current jrxml
    for (ReportRepNode report : repNodes) {
        EList<AnalysisMap> analysisMap = ((TdReport) report.getReport()).getAnalysisMap();
        for (AnalysisMap anaMap : analysisMap) {
            if (isUsedByDeletedJrxml(path, anaMap)) {
                dependedReport.add(report.getReport());
                break;
            }
        }
    }
    return dependedReport;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IPath(org.eclipse.core.runtime.IPath) ReportRepNode(org.talend.dq.nodes.ReportRepNode) TdReport(org.talend.dataquality.reports.TdReport) ArrayList(java.util.ArrayList) AnalysisMap(org.talend.dataquality.reports.AnalysisMap)

Example 13 with TdReport

use of org.talend.dataquality.reports.TdReport in project tdq-studio-se by Talend.

the class ContextHelperTest method testGetOutputFolderFromReports.

/**
 * Test method for {@link org.talend.dq.helper.ContextHelper#getOutputFolderFromReports(java.util.List)}.
 */
@Test
public void testGetOutputFolderFromReports() {
    // $NON-NLS-1$
    String empty = "";
    // $NON-NLS-1$
    String blank = "      ";
    // $NON-NLS-1$
    String defaultStr = "default";
    // $NON-NLS-1$
    String var1 = "context.outputFolder";
    // $NON-NLS-1$
    String var1a = "outputFolder";
    // $NON-NLS-1$
    String var2 = "context.of2";
    // $NON-NLS-1$
    String var2a = "of2";
    // $NON-NLS-1$
    String folder1 = "/home/user/talend/a";
    // $NON-NLS-1$
    String folder2 = "/home/user/talend/b";
    Assert.assertNull(ContextHelper.getOutputFolderFromReports(null));
    Assert.assertNull(ContextHelper.getOutputFolderFromReports(new ArrayList<TdReport>()));
    List<TdReport> reports = new ArrayList<TdReport>();
    TdReport tdReport = ReportsFactory.eINSTANCE.createTdReport();
    tdReport.setDefaultContext(defaultStr);
    TaggedValue tv = CoreFactory.eINSTANCE.createTaggedValue();
    tv.setTag(TaggedValueHelper.OUTPUT_FOLDER_TAG);
    tv.setValue(empty);
    tdReport.getTaggedValue().add(tv);
    reports.add(tdReport);
    Assert.assertNull(ContextHelper.getOutputFolderFromReports(reports));
    tv.setValue(blank);
    Assert.assertNull(ContextHelper.getOutputFolderFromReports(reports));
    tv.setValue(folder1);
    Assert.assertEquals(folder1, ContextHelper.getOutputFolderFromReports(reports));
    tv.setValue(var1);
    Assert.assertEquals(var1, ContextHelper.getOutputFolderFromReports(reports));
    TdReport tdReport2 = ReportsFactory.eINSTANCE.createTdReport();
    tdReport2.setDefaultContext(defaultStr);
    TaggedValue tv2 = CoreFactory.eINSTANCE.createTaggedValue();
    tv2.setTag(TaggedValueHelper.OUTPUT_FOLDER_TAG);
    tv2.setValue(empty);
    tdReport2.getTaggedValue().add(tv2);
    reports.add(tdReport2);
    ContextType ct = TalendFileFactory.eINSTANCE.createContextType();
    ct.setName(defaultStr);
    ContextParameterType cpt = TalendFileFactory.eINSTANCE.createContextParameterType();
    cpt.setName(var1a);
    cpt.setValue(folder1);
    ct.getContextParameter().add(cpt);
    tdReport.getContext().add(ct);
    ContextType ct2 = TalendFileFactory.eINSTANCE.createContextType();
    ct2.setName(defaultStr);
    ContextParameterType cpt2 = TalendFileFactory.eINSTANCE.createContextParameterType();
    cpt2.setName(var2a);
    cpt2.setValue(folder2);
    ct2.getContextParameter().add(cpt2);
    tdReport2.getContext().add(ct2);
    // both context, different output folder
    tv.setValue(var1);
    tv2.setValue(var2);
    Assert.assertNull(ContextHelper.getOutputFolderFromReports(reports));
    // both context, same output folder
    cpt2.setValue(folder1);
    ct2.getContextParameter().clear();
    ct2.getContextParameter().add(cpt2);
    tdReport2.getContext().clear();
    tdReport2.getContext().add(ct2);
    String temp = ContextHelper.getOutputFolderFromReports(reports);
    Assert.assertTrue(var1.equals(temp) || var2.equals(temp));
    // both real folder, different output folder
    tv.setValue(folder1);
    tdReport.getTaggedValue().clear();
    tdReport.getTaggedValue().add(tv);
    tv2.setValue(folder2);
    tdReport2.getTaggedValue().clear();
    tdReport2.getTaggedValue().add(tv2);
    Assert.assertNull(ContextHelper.getOutputFolderFromReports(reports));
    // both real folder, same output folder
    tv2.setValue(folder1);
    tdReport2.getTaggedValue().clear();
    tdReport2.getTaggedValue().add(tv2);
    Assert.assertEquals(folder1, ContextHelper.getOutputFolderFromReports(reports));
    // context and real folder, different output folder
    tv2.setValue(var2);
    tdReport2.getTaggedValue().clear();
    tdReport2.getTaggedValue().add(tv2);
    cpt2.setValue(folder2);
    ct2.getContextParameter().clear();
    ct2.getContextParameter().add(cpt2);
    tdReport2.getContext().clear();
    tdReport2.getContext().add(ct2);
    Assert.assertNull(ContextHelper.getOutputFolderFromReports(reports));
    // context and real folder, same output folder
    cpt2.setValue(folder1);
    ct2.getContextParameter().clear();
    ct2.getContextParameter().add(cpt2);
    tdReport2.getContext().clear();
    tdReport2.getContext().add(ct2);
    Assert.assertEquals(folder1, ContextHelper.getOutputFolderFromReports(reports));
    // one report's output folder is empty(mean default location)
    tv2.setValue(empty);
    tdReport2.getTaggedValue().clear();
    tdReport2.getTaggedValue().add(tv2);
    Assert.assertNull(ContextHelper.getOutputFolderFromReports(reports));
    // one report's output folder is blank(mean default location)
    tv2.setValue(blank);
    tdReport2.getTaggedValue().clear();
    tdReport2.getTaggedValue().add(tv2);
    Assert.assertNull(ContextHelper.getOutputFolderFromReports(reports));
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) TdReport(org.talend.dataquality.reports.TdReport) ArrayList(java.util.ArrayList) ContextParameterType(org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType) Test(org.junit.Test)

Example 14 with TdReport

use of org.talend.dataquality.reports.TdReport in project tdq-studio-se by Talend.

the class ReportWriter method addDependencies.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.writer.AElementPersistance#addDependencies(orgomg.cwm.objectmodel.core.ModelElement)
     */
@Override
public void addDependencies(ModelElement element) {
    TdReport report = (TdReport) element;
    List<Analysis> analyses = ReportHelper.getAnalyses(report);
    for (Analysis ana : analyses) {
        // TDQ-7999,filter the proxy.
        if (!ana.eIsProxy()) {
            AnalysisRepNode recursiveFindAnalysis = RepositoryNodeHelper.recursiveFindAnalysis(ana);
            // only do save when the dependency is not reference project node
            if (recursiveFindAnalysis != null && recursiveFindAnalysis.getProject().isMainProject()) {
                TypedReturnCode<Dependency> dependencyReturn = DependenciesHandler.getInstance().setDependencyOn(report, ana);
                if (dependencyReturn.isOk()) {
                    try {
                        Property property = PropertyHelper.getProperty(ana);
                        if (property != null) {
                            Item item = property.getItem();
                            if (item instanceof TDQAnalysisItem) {
                                TDQAnalysisItem anaItem = (TDQAnalysisItem) item;
                                anaItem.setAnalysis(ana);
                            }
                        }
                        ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(ana.eResource());
                    } catch (PersistenceException e) {
                        log.error(e, e);
                    }
                }
            }
        }
    }
}
Also used : TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Item(org.talend.core.model.properties.Item) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) Analysis(org.talend.dataquality.analysis.Analysis) TdReport(org.talend.dataquality.reports.TdReport) PersistenceException(org.talend.commons.exception.PersistenceException) Dependency(orgomg.cwm.objectmodel.core.Dependency) Property(org.talend.core.model.properties.Property) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 15 with TdReport

use of org.talend.dataquality.reports.TdReport in project tdq-studio-se by Talend.

the class DQRepositoryViewLabelProvider method addWarnIconIfNeeded.

/**
 * if it is needed,add a over warning icon..eg., it is empty analysis or report; imported a MDM analysis or report.
 *
 * @param image
 * @param node
 * @param originalImageName
 * @return
 */
private Image addWarnIconIfNeeded(IRepositoryNode node, String originalImageName) {
    ModelElement modEle = RepositoryNodeHelper.getResourceModelElement(node);
    ERepositoryObjectType objectType = node.getObjectType();
    if (modEle != null) {
        if (ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT == objectType) {
            Analysis analysis = (Analysis) modEle;
            AnalysisContext context = analysis.getContext();
            if (context == null) {
                return ImageLib.createInvalidIcon(originalImageName);
            }
            EList<ModelElement> analysedElements = context.getAnalysedElements();
            DataManager connection = context.getConnection();
            if (analysedElements.isEmpty() || connection instanceof MDMConnection) {
                return ImageLib.createInvalidIcon(originalImageName);
            }
        } else if (ERepositoryObjectType.TDQ_REPORT_ELEMENT == objectType) {
            TdReport report = (TdReport) modEle;
            EList<AnalysisMap> analysisMap = report.getAnalysisMap();
            if (analysisMap.isEmpty()) {
                return ImageLib.createInvalidIcon(originalImageName);
            }
            for (AnalysisMap anaMap : report.getAnalysisMap()) {
                Analysis analysis = anaMap.getAnalysis();
                if (analysis == null || analysis.getContext() == null) {
                    continue;
                }
                DataManager connection = analysis.getContext().getConnection();
                if (connection instanceof MDMConnection) {
                    return ImageLib.createInvalidIcon(originalImageName);
                }
            }
        }
    }
    return ImageLib.getImage(originalImageName);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) EList(org.eclipse.emf.common.util.EList) Analysis(org.talend.dataquality.analysis.Analysis) TdReport(org.talend.dataquality.reports.TdReport) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection)

Aggregations

TdReport (org.talend.dataquality.reports.TdReport)18 Analysis (org.talend.dataquality.analysis.Analysis)9 AnalysisMap (org.talend.dataquality.reports.AnalysisMap)8 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)7 ArrayList (java.util.ArrayList)5 IPath (org.eclipse.core.runtime.IPath)5 Property (org.talend.core.model.properties.Property)5 TDQReportItem (org.talend.dataquality.properties.TDQReportItem)4 IFile (org.eclipse.core.resources.IFile)3 EList (org.eclipse.emf.common.util.EList)3 Item (org.talend.core.model.properties.Item)3 IFolder (org.eclipse.core.resources.IFolder)2 Path (org.eclipse.core.runtime.Path)2 Test (org.junit.Test)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 Pattern (org.talend.dataquality.domain.pattern.Pattern)2 ReportType (org.talend.dataquality.helpers.ReportHelper.ReportType)2 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)2