Search in sources :

Example 6 with AnalysisMap

use of org.talend.dataquality.reports.AnalysisMap 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 7 with AnalysisMap

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

the class ReportExecutor method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.analysis.IReportExecutor#execute(org.talend.dataquality.reports.TdReport)
     */
public ReturnCode execute(TdReport report, IProgressMonitor monitor) throws AnalysisExecutionException {
    atLeastOneFailure = false;
    long startTime = System.currentTimeMillis();
    if (report.eIsProxy()) {
        report = (TdReport) EObjectHelper.resolveObject(report);
    }
    EList<AnalysisMap> analysisMaps = report.getAnalysisMap();
    StringBuilder strBuilder = new StringBuilder();
    // loop on analysis maps is faster than loop on analyses
    for (AnalysisMap analysisMap : analysisMaps) {
        Analysis analysis = analysisMap.getAnalysis();
        if (analysisMap.isMustRefresh()) {
            if (analysis == null) {
                return new ReturnCode(Messages.getString("ReportExecutor.CannotEvaluateNullAnalysis", report.getName()), // $NON-NLS-1$
                false);
            }
            ReturnCode executeRc = AnalysisExecutorSelector.executeAnalysis(analysis, monitor);
            if (executeRc.getMessage() != null && !StringUtils.EMPTY.equals(executeRc.getMessage().trim())) {
                throw new AnalysisExecutionException(Messages.getString("ReportExecutor.failRunAnalysis", analysis.getName(), executeRc.getMessage()));
            }
            // ADD msjian TDQ-5952: we should close connections always
            TdqAnalysisConnectionPool.closeConnectionPool(analysis);
            // TDQ-5952~
            if (!executeRc.isOk()) {
                log.error("Failed to execute analysis " + analysis.getName() + ". Reason: " + executeRc.getMessage());
                atLeastOneFailure = true;
            }
            if (log.isInfoEnabled()) {
                strBuilder.append("Report " + report.getName() + ": Analysis " + analysis.getName() + " refreshed. State: " + executeRc.isOk() + "\n");
            }
        } else {
            // skipped analysis
            if (log.isInfoEnabled()) {
                strBuilder.append("Report " + report.getName() + ": Analysis " + analysis.getName() + " skipped.\n");
            }
        }
    }
    // log execution
    if (log.isInfoEnabled()) {
        if (strBuilder.length() == 0) {
            log.info("Generating reports for \"" + report.getName() + "\" without refreshing any analysis.");
        } else {
            log.info(strBuilder.toString());
        }
    }
    long endTime = System.currentTimeMillis();
    // fill in the execution informations
    ExecutionInformations execInformations = ReportHelper.getExecutionInformations(report);
    execInformations.setExecutionDate(new Date(startTime));
    int duration = (int) (endTime - startTime);
    execInformations.setExecutionDuration(duration);
    execInformations.setExecutionNumber(execInformations.getExecutionNumber() + 1);
    if (atLeastOneFailure) {
        execInformations.setLastRunOk(false);
        // $NON-NLS-1$
        String err = Messages.getString("ReportExecutor.AnalysisExecutionFailed", report.getName());
        execInformations.setMessage(err);
        return new ReturnCode(err, false);
    }
    // else
    execInformations.setLastRunOk(true);
    execInformations.setLastExecutionNumberOk(execInformations.getExecutionNumber());
    execInformations.setMessage(null);
    return new ReturnCode();
}
Also used : ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) ReturnCode(org.talend.utils.sugars.ReturnCode) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisExecutionException(org.talend.cwm.exception.AnalysisExecutionException) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) Date(java.util.Date)

Example 8 with AnalysisMap

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

the class ReportWriter method removeDependencies.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.writer.AElementPersistance#removeDependencies(org.talend.core.model.properties.Item)
     */
@Override
protected ReturnCode removeDependencies(Item item) {
    ReturnCode rc = new ReturnCode();
    TDQReportItem anaItem = (TDQReportItem) item;
    TdReport report = (TdReport) anaItem.getReport();
    List<Property> clintDependency = DependenciesHandler.getInstance().getClintDependency(anaItem.getProperty());
    EList<AnalysisMap> analysisMap = report.getAnalysisMap();
    for (Property currentClient : clintDependency) {
        ModelElement modelElement = PropertyHelper.getModelElement(currentClient);
        if (!analysisMap.contains(modelElement)) {
            boolean isSuccess = DependenciesHandler.getInstance().removeDependenciesBetweenModel(report, modelElement);
            if (isSuccess) {
                rc.setOk(EMFUtil.saveSingleResource(modelElement.eResource()));
            } else {
                rc.setOk(false);
                rc.setMessage(// $NON-NLS-1$
                Messages.getString(// $NON-NLS-1$
                "ReportWriter.CanNotFindDependencyElement", // $NON-NLS-1$
                report.getName(), modelElement.getName()));
            }
        }
    }
    return rc;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) TdReport(org.talend.dataquality.reports.TdReport) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) Property(org.talend.core.model.properties.Property) TDQReportItem(org.talend.dataquality.properties.TDQReportItem)

Example 9 with AnalysisMap

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

the class TdReportImpl method setReportType.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT Set report type and jrxml file path to analysis map.
 */
@Override
public void setReportType(String reportType, String jrxmlSource, Analysis analysis) {
    EList<AnalysisMap> anMaps = this.getAnalysisMap();
    for (AnalysisMap anMap : anMaps) {
        if (ResourceHelper.areSame(analysis, anMap.getAnalysis())) {
            anMap.setReportType(reportType);
            anMap.setJrxmlSource(jrxmlSource);
            break;
        }
    }
}
Also used : AnalysisMap(org.talend.dataquality.reports.AnalysisMap)

Example 10 with AnalysisMap

use of org.talend.dataquality.reports.AnalysisMap 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)

Aggregations

AnalysisMap (org.talend.dataquality.reports.AnalysisMap)18 TdReport (org.talend.dataquality.reports.TdReport)8 IPath (org.eclipse.core.runtime.IPath)5 Analysis (org.talend.dataquality.analysis.Analysis)5 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)5 ArrayList (java.util.ArrayList)4 Path (org.eclipse.core.runtime.Path)4 EList (org.eclipse.emf.common.util.EList)3 ReportType (org.talend.dataquality.helpers.ReportHelper.ReportType)3 ReportRepNode (org.talend.dq.nodes.ReportRepNode)3 IRepositoryNode (org.talend.repository.model.IRepositoryNode)3 IFile (org.eclipse.core.resources.IFile)2 Project (org.talend.core.model.general.Project)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)2 Item (org.talend.core.model.properties.Item)2 Property (org.talend.core.model.properties.Property)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 TDQReportItem (org.talend.dataquality.properties.TDQReportItem)2 ReturnCode (org.talend.utils.sugars.ReturnCode)2 File (java.io.File)1