Search in sources :

Example 1 with ReportType

use of org.talend.dataquality.helpers.ReportHelper.ReportType in project tdq-studio-se by Talend.

the class LocalRepositoryObjectCRUD method relocateJrxmlTemplates.

/**
 * update user define jrxml template path.
 *
 * @param sourceNode
 * @param targetNode
 * @link {@link #moveReportRepNode(IRepositoryNode, IRepositoryNode)}
 */
private void relocateJrxmlTemplates(IRepositoryNode sourceNode, IRepositoryNode targetNode) {
    IPath targetPath = RepositoryNodeHelper.getPath(targetNode);
    IFolder targetFolder = ResourceManager.getRootProject().getFolder(targetPath);
    TdReport rep = (TdReport) RepositoryNodeHelper.getModelElementFromRepositoryNode(sourceNode);
    IPath jrxmlPath = null;
    IPath relativePath = null;
    ReportType reportType = null;
    for (AnalysisMap anaMap : rep.getAnalysisMap()) {
        reportType = ReportHelper.ReportType.getReportType(anaMap.getAnalysis(), anaMap.getReportType());
        // Relocate the jrxml template path for user define type.
        if (ReportHelper.ReportType.USER_MADE.equals(reportType)) {
            jrxmlPath = RepResourceFileHelper.findCorrespondingFile(rep).getParent().getLocation().append(anaMap.getJrxmlSource());
            // $NON-NLS-1$
            relativePath = jrxmlPath.makeRelativeTo(targetFolder.getLocation().append("/"));
            anaMap.setJrxmlSource(relativePath.toString());
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) TdReport(org.talend.dataquality.reports.TdReport) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) ReportType(org.talend.dataquality.helpers.ReportHelper.ReportType) IFolder(org.eclipse.core.resources.IFolder)

Example 2 with ReportType

use of org.talend.dataquality.helpers.ReportHelper.ReportType in project tdq-studio-se by Talend.

the class ItemRecord method computeDependencies.

/**
 * DOC bZhou Comment method "computeDependencies".
 */
private void computeDependencies(ModelElement mElement) {
    if (isJRXml()) {
        Collection<TdReport> allReports = (Collection<TdReport>) RepResourceFileHelper.getInstance().getAllElement();
        for (TdReport report : allReports) {
            // MOD yyi 2012-02-20 TDQ-4545 TDQ-4701: Change to relative path comparing.
            IPath pathRepFile = RepResourceFileHelper.findCorrespondingFile(report).getLocation();
            IPath pathJrxmlFile = new Path(file.getPath());
            String path = pathJrxmlFile.makeRelativeTo(pathRepFile).toString();
            for (AnalysisMap anaMap : report.getAnalysisMap()) {
                if (StringUtils.equals(path, anaMap.getJrxmlSource())) {
                    // TODO the File is jrxml, but the ModelElement is report ???
                    this.dependencySet.add(file);
                }
            }
        }
    } else if (mElement != null) {
        if (mElement instanceof Connection) {
            includeContextDependency((Connection) mElement);
            return;
        }
        List<File> dependencyFile = getClintDependencyForExport(mElement);
        for (File df : dependencyFile) {
            ModelElement modelElement = getElement(df);
            if (modelElement != null) {
                File depFile = EObjectHelper.modelElement2File(modelElement);
                if (depFile != null) {
                    this.dependencySet.add(depFile);
                }
                // MOD sizhaoliu 2013-04-13 TDQ-7082
                if (modelElement instanceof IndicatorDefinition) {
                    if (modelElement instanceof UDIndicatorDefinition) {
                        includeJUDIDependencies((IndicatorDefinition) modelElement);
                    } else {
                        for (IndicatorDefinition definition : ((IndicatorDefinition) modelElement).getAggregatedDefinitions()) {
                            includeAggregatedDependencies(definition);
                        }
                    }
                }
            }
        }
        // MOD yyi 2012-02-20 TDQ-4545 TDQ-4701: Map user define jrxm templates with report.
        if (mElement instanceof TdReport) {
            TdReport rep = (TdReport) mElement;
            for (AnalysisMap anaMap : rep.getAnalysisMap()) {
                ReportType reportType = ReportHelper.ReportType.getReportType(anaMap.getAnalysis(), anaMap.getReportType());
                boolean isUserMade = ReportHelper.ReportType.USER_MADE.equals(reportType);
                if (isUserMade) {
                    traverseFolderAndAddJrxmlDependencies(getJrxmlFolderFromReport(rep, ResourceManager.getJRXMLFolder()));
                }
            }
        } else if (mElement instanceof IndicatorDefinition) {
            // MOD sizhaoliu 2013-04-13 TDQ-7082
            IndicatorDefinition definition = (IndicatorDefinition) mElement;
            if (definition instanceof UDIndicatorDefinition) {
                includeJUDIDependencies(definition);
            } else {
                for (IndicatorDefinition defInd : definition.getAggregatedDefinitions()) {
                    includeAggregatedDependencies(defInd);
                }
            }
            // folder
            if (mElement instanceof MatchRuleDefinition) {
                includeCustomMatcherJarDependencies((MatchRuleDefinition) mElement);
            }
        } else if (mElement instanceof Analysis && AnalysisType.MATCH_ANALYSIS == AnalysisHelper.getAnalysisType((Analysis) mElement)) {
            includeCustomMatcherJarDependencies((Analysis) mElement);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) TdReport(org.talend.dataquality.reports.TdReport) Connection(org.talend.core.model.metadata.builder.connection.Connection) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) Collection(java.util.Collection) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) File(java.io.File) ReportType(org.talend.dataquality.helpers.ReportHelper.ReportType)

Example 3 with ReportType

use of org.talend.dataquality.helpers.ReportHelper.ReportType in project tdq-studio-se by Talend.

the class TdReportImpl method addAnalysis.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT addAnalysis(Analysis analysis)
 */
@Override
public boolean addAnalysis(Analysis analysis) {
    // MOD yyin 20120530 TDQ-5050
    // boolean added = this.getComponent().add(analysis);
    // if (added) {
    AnalysisMap createAnalysisMap = ReportsFactory.eINSTANCE.createAnalysisMap();
    createAnalysisMap.setAnalysis(analysis);
    // refresh by default
    createAnalysisMap.setMustRefresh(true);
    // MOD mzhao 2009-02-16 Basic type by default.
    ReportType reportType2 = ReportType.getReportType(analysis, ReportHelper.BASIC);
    if (reportType2 != null) {
        createAnalysisMap.setReportType(reportType2.getLabel());
    }
    this.getAnalysisMap().add(createAnalysisMap);
    // }
    return true;
}
Also used : AnalysisMap(org.talend.dataquality.reports.AnalysisMap) ReportType(org.talend.dataquality.helpers.ReportHelper.ReportType)

Example 4 with ReportType

use of org.talend.dataquality.helpers.ReportHelper.ReportType in project tdq-studio-se by Talend.

the class EObjectHelper method isUsedByDeletedJrxml.

/**
 * check if the anaMap comtains the Jrxml or not, by compare the jrxml's path with anaMap's jrxml source(when user
 * mode)
 *
 * @param path the path of the jrxml saved in the analysis map
 * @param anaMap the analysis map in the report.
 * @return the analysis map used the current jrxml or not.
 */
private static boolean isUsedByDeletedJrxml(IPath path, AnalysisMap anaMap) {
    ReportType reportType = ReportHelper.ReportType.getReportType(anaMap.getAnalysis(), anaMap.getReportType());
    // compare the Jrxml path if the report has the user defined one.
    if (ReportHelper.ReportType.USER_MADE.equals(reportType)) {
        String jrxmlPath = anaMap.getJrxmlSource();
        String deletedpath = path.removeFirstSegments(2).toString();
        if (jrxmlPath.contains(deletedpath)) {
            return true;
        }
    }
    return false;
}
Also used : ReportType(org.talend.dataquality.helpers.ReportHelper.ReportType)

Aggregations

ReportType (org.talend.dataquality.helpers.ReportHelper.ReportType)4 AnalysisMap (org.talend.dataquality.reports.AnalysisMap)3 IPath (org.eclipse.core.runtime.IPath)2 TdReport (org.talend.dataquality.reports.TdReport)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 IFolder (org.eclipse.core.resources.IFolder)1 Path (org.eclipse.core.runtime.Path)1 EList (org.eclipse.emf.common.util.EList)1 Connection (org.talend.core.model.metadata.builder.connection.Connection)1 Analysis (org.talend.dataquality.analysis.Analysis)1 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)1 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)1 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)1 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)1