use of org.talend.dataquality.reports.TdReport in project tdq-studio-se by Talend.
the class RepNodeUtils method updateJrxmlRelatedReport.
/**
* when the report's user defined template(Jrxml file) changed its name, or be moved, the path info in the report's
* anaMap: jrxml source should also be updated. This method is used to update the related reports when the jrxml
* name or path is changed.
*
* @param jrxmlFileNames : the whole path with whole name of the jrxml, e.g./TDQ_Libraries/JRXML
* Template/columnset/column_set_basic_0.1.jrxml
* @param jrxmlFileNamesAfterMove
*/
public static void updateJrxmlRelatedReport(List<String> jrxmlFileNames, List<String> jrxmlFileNamesAfterMove) {
if (jrxmlFileNames.size() == 0 || jrxmlFileNamesAfterMove.size() == 0 || jrxmlFileNamesAfterMove.size() < jrxmlFileNames.size()) {
return;
}
Project project = ProjectManager.getInstance().getCurrentProject();
// get all reports
IRepositoryNode ReportRootFolderNode = RepositoryNodeHelper.getDataProfilingFolderNode(EResourceConstant.REPORTS);
List<ReportRepNode> repNodes = RepositoryNodeHelper.getReportRepNodes(ReportRootFolderNode, true, true);
// go through every report to :if any one used current jrxml-->modify its jrxml resource name
for (ReportRepNode report : repNodes) {
boolean isUpdated = false;
EList<AnalysisMap> analysisMap = ((TdReport) report.getReport()).getAnalysisMap();
for (AnalysisMap anaMap : analysisMap) {
for (int i = 0; i < jrxmlFileNames.size(); i++) {
String oldPath = jrxmlFileNames.get(i);
if (isUsedByJrxml(new Path(oldPath), anaMap)) {
// like: ../../../TDQ_Libraries/JRXML Template/column1/b01_column_basic_0.1.jrxml
String newPath = getRelativeJrxmlPath(report.getReport(), jrxmlFileNamesAfterMove.get(i));
// Added 20130128, using event/listener to refresh the page if opening
EventManager.getInstance().publish(report, EventEnum.DQ_JRXML_RENAME, newPath);
// save the new jrxml path.
anaMap.setJrxmlSource(newPath);
isUpdated = true;
}
}
}
if (isUpdated) {
try {
ProxyRepositoryFactory.getInstance().save(project, report.getObject().getProperty().getItem());
} catch (PersistenceException e) {
// $NON-NLS-1$
MessageUI.openError(DefaultMessagesImpl.getString("RepNodeUtils.updateReport.fail", report.getLabel()));
}
}
}
}
use of org.talend.dataquality.reports.TdReport 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.TdReport in project tdq-studio-se by Talend.
the class RespositoryDetailView method createFileDetail.
private boolean createFileDetail(boolean is, IFile fe2) {
if (fe2.getFileExtension().equals(FactoriesUtil.PATTERN)) {
Pattern pattern = PatternResourceFileHelper.getInstance().findPattern(fe2);
createPatternDetail(pattern);
is = false;
} else if (fe2.getFileExtension().equals(FactoriesUtil.ANA)) {
Analysis ana = AnaResourceFileHelper.getInstance().findAnalysis(fe2);
createAnaysisDetail(ana);
is = false;
} else if (fe2.getFileExtension().equals(FactoriesUtil.REP)) {
TdReport rep = RepResourceFileHelper.getInstance().findReport(fe2);
createReportDetail(rep);
is = false;
} else if (fe2.getFileExtension().equals(FactoriesUtil.SQL)) {
createSqlFileDetail(fe2);
is = false;
}
return is;
}
use of org.talend.dataquality.reports.TdReport 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.TdReport in project tdq-studio-se by Talend.
the class TreeMessageInfoDialog method getLabelProvider.
protected ILabelProvider getLabelProvider() {
if (labelProvider == null) {
labelProvider = new LabelProvider() {
@Override
public String getText(Object obj) {
if (obj == null) {
// $NON-NLS-1$
return "";
}
if (obj instanceof ImpactNode) {
return ((ImpactNode) obj).toString();
} else if (obj instanceof IFile) {
IFile file = (IFile) obj;
ModelElement modelElement = ModelElementFileFactory.getModelElement(file);
// MOD msjian TDQ-5909: modify to displayName
return modelElement != null ? PropertyHelper.getProperty(modelElement).getDisplayName() : file.getName();
} else if (obj instanceof RepositoryViewObject) {
// Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
return ((IRepositoryViewObject) obj).getLabel();
} else if (obj instanceof MetadataTable) {
// ADD TDQ-7146: for all type's connection table/view node
return ((ModelElement) obj).getName();
}
Property property = PropertyHelper.getProperty((ModelElement) obj);
return property == null ? ((ModelElement) obj).getName() : property.getDisplayName();
}
@Override
public Image getImage(Object obj) {
ModelElement modelElement = null;
if (obj instanceof ModelElement) {
modelElement = (ModelElement) obj;
} else if (obj instanceof ImpactNode) {
modelElement = ((ImpactNode) obj).getNodeElement();
} else if (obj instanceof IFile) {
modelElement = ModelElementFileFactory.getModelElement((IFile) obj);
} else if (obj instanceof RepositoryViewObject) {
// Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
return ImageLib.getImage(ImageLib.JRXML_ICON);
}
// ~
if (modelElement == null) {
if (((ImpactNode) obj).getNode() != null) {
return ImageLib.getImage(ImageLib.JRXML_ICON);
}
return super.getImage(obj);
}
Image modelElementImage = null;
String imgName = null;
if (modelElement instanceof Analysis) {
imgName = ImageLib.ANALYSIS_OBJECT;
} else if (modelElement instanceof TdReport) {
imgName = ImageLib.REPORT_OBJECT;
} else if (modelElement instanceof DatabaseConnection) {
imgName = ImageLib.CONNECTION;
} else if (modelElement instanceof DelimitedFileConnection) {
imgName = ImageLib.FILE_DELIMITED;
} else if (modelElement instanceof Pattern) {
imgName = ImageLib.PATTERN_REG;
} else if (modelElement instanceof IndicatorDefinition) {
// IndicatorDefinition
if (modelElement instanceof DQRule) {
imgName = ImageLib.DQ_RULE;
} else if (modelElement instanceof MatchRuleDefinition) {
imgName = ImageLib.MATCH_RULE_ICON;
} else {
imgName = ImageLib.IND_DEFINITION;
}
// TDQ-8550~
} else if (modelElement instanceof MetadataTable) {
imgName = ImageLib.TABLE;
}
if (imgName != null) {
modelElementImage = ImageLib.getImage(imgName);
}
// add lock icon on the image
if (modelElementImage != null) {
if (modelElement != null) {
Property property = PropertyHelper.getProperty(modelElement);
if (property != null) {
Item item = property.getItem();
if (item != null) {
if (ProxyRepositoryManager.getInstance().isLockByUserOwn(item)) {
modelElementImage = ImageLib.createLockedByOwnIcon(imgName);
} else if (ProxyRepositoryManager.getInstance().isLockByOthers(item)) {
modelElementImage = ImageLib.createLockedByOtherIcon(imgName);
}
}
}
}
return modelElementImage;
}
return super.getImage(obj);
}
};
}
return labelProvider;
}
Aggregations