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);
}
}
}
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();
}
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;
}
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;
}
}
}
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;
}
Aggregations