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