use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.
the class RespositoryDetailView method createTechnicalDetail.
private void createTechnicalDetail(IRepositoryViewObject reposViewObj) {
// MOD klliu the DQRepositoryview unified with tos, so refactor as follow bug 19154 2011-02-28
if (reposViewObj.getProperty() != null) {
Item item = reposViewObj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
createTechnicalDetail(conn);
} else if (item instanceof TDQAnalysisItem) {
Analysis analysis = ((TDQAnalysisItem) item).getAnalysis();
createTechnicalDetail(analysis);
} else if (item instanceof TDQPatternItem) {
Pattern pattern = ((TDQPatternItem) item).getPattern();
createTechnicalDetail(pattern);
} else if (item instanceof TDQReportItem) {
Report report = ((TDQReportItem) item).getReport();
createTechnicalDetail(report);
}
}
}
use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.
the class AElementPersistance method createItem.
/**
* DOC bZhou Comment method "createItem".
*
* @param element
* @return
*/
public Item createItem(ModelElement element) {
Item item = null;
// MOD mzhao feature 13114, 2010-05-19 distinguish tdq items.
if (ModelElementIdentifier.isAnalysis(element)) {
item = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
((TDQAnalysisItem) item).setAnalysis((Analysis) element);
} else if (ModelElementIdentifier.isDQRule(element)) {
item = PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
((TDQBusinessRuleItem) item).setDqrule((DQRule) element);
} else if (ModelElementIdentifier.isDataProvider(element)) {
if (element instanceof DatabaseConnection) {
item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
((ConnectionItem) item).setConnection((DatabaseConnection) element);
}
((ConnectionItem) item).setConnection((Connection) element);
} else if (ModelElementIdentifier.isMatchRule(element)) {
// this Condition must before the IndicatorDefinition one because MatchRule instance of it.
item = PropertiesFactory.eINSTANCE.createTDQMatchRuleItem();
((TDQMatchRuleItem) item).setMatchRule((MatchRuleDefinition) element);
} else if (ModelElementIdentifier.isID(element)) {
item = PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
((TDQIndicatorDefinitionItem) item).setIndicatorDefinition((IndicatorDefinition) element);
} else if (ModelElementIdentifier.isPattern(element)) {
item = PropertiesFactory.eINSTANCE.createTDQPatternItem();
((TDQPatternItem) item).setPattern((Pattern) element);
} else if (ModelElementIdentifier.isReport(element)) {
item = PropertiesFactory.eINSTANCE.createTDQReportItem();
((TDQReportItem) item).setReport((Report) element);
} else {
item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createTDQItem();
}
ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(false);
item.setState(itemState);
if (item instanceof TDQItem) {
setTDQItemFileName(element, item);
}
Resource eResource = element.eResource();
if (eResource != null) {
URI uri = eResource.getURI();
if (uri.isPlatform()) {
IPath elementPath = new Path(uri.toPlatformString(true)).removeLastSegments(1);
IPath typedPath = ResourceManager.getRootProject().getFullPath().append(PropertyHelper.getItemTypedPath(item));
IPath statePath = elementPath.makeRelativeTo(typedPath);
itemState.setPath(statePath.toString());
}
}
return item;
}
use of org.talend.dataquality.properties.TDQReportItem 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.properties.TDQReportItem in project tdq-studio-se by Talend.
the class TDQResourceChangeHandler method moveReportGeneratedDocFolder.
@Override
public void moveReportGeneratedDocFolder(TDQItem tdqItem, File tarFolder) {
if (tdqItem instanceof TDQReportItem && tarFolder.exists()) {
TDQReportItem tdqReportItem = (TDQReportItem) tdqItem;
Report report = tdqReportItem.getReport();
IFile iFile = ModelElementHelper.getIFile(report);
IFolder outputFolder = ReportFileHelper.getOutputFolder(iFile);
File srcFolder = WorkspaceUtils.ifolderToFile(outputFolder);
FilesUtils.copyDirectoryWithoutSvnFolder(srcFolder, tarFolder);
File newFolder = new File(tarFolder.getAbsolutePath() + File.separator + srcFolder.getName());
if (newFolder.exists()) {
IFolder ifolder = WorkspaceUtils.fileToIFolder(newFolder);
if (ifolder != null) {
try {
ifolder.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
log.info(e);
}
}
}
}
}
use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.
the class RemoveAnalysisAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
DQRespositoryView findView = CorePlugin.getDefault().getRepositoryView();
if (findView == null) {
return;
}
TreeSelection treeSelection = (TreeSelection) findView.getCommonViewer().getSelection();
TreePath[] paths = treeSelection.getPaths();
List<Analysis> analysisList;
Analysis analysisObj = null;
Map<TDQReportItem, List<Analysis>> removeMap = new HashMap<TDQReportItem, List<Analysis>>();
for (TreePath path : paths) {
Object lastSegment = path.getLastSegment();
if (!(lastSegment instanceof ReportAnalysisRepNode)) {
return;
}
// MOD sizhaoliu 2012-06-12 TDQ-5051 "Remove Anaysis" menu item is not in the right place
ReportAnalysisRepNode repNode = (ReportAnalysisRepNode) lastSegment;
analysisObj = repNode.getAnalysis();
TDQReportItem reportItem = repNode.getReportItem();
analysisList = removeMap.get(reportItem);
if (analysisList == null) {
analysisList = new ArrayList<Analysis>();
analysisList.add(analysisObj);
removeMap.put(reportItem, analysisList);
} else {
analysisList.add(analysisObj);
}
}
if (analysisObj == null) {
return;
}
String message = paths.length > 1 ? DefaultMessagesImpl.getString("RemoveAnalysisAction.areYouDeleteElement0", // $NON-NLS-1$
paths.length) : // $NON-NLS-1$
DefaultMessagesImpl.getString("RemoveAnalysisAction.areYouDeleteElement2", analysisObj.getName());
boolean openConfirm = MessageDialog.openConfirm(null, DefaultMessagesImpl.getString("RemoveAnalysisAction.confirmResourceDelete"), // $NON-NLS-1$
message);
if (openConfirm) {
Iterator<TDQReportItem> iterator = removeMap.keySet().iterator();
while (iterator.hasNext()) {
TDQReportItem reportItem = iterator.next();
ReportHelper.removeAnalyses((TdReport) reportItem.getReport(), removeMap.get(reportItem));
// save now modified resources (that contain the Dependency
// objects)
ElementWriterFactory.getInstance().createReportWriter().save(reportItem, true);
}
IFolder reportsFolder = ResourceManager.getReportsFolder();
try {
reportsFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
log.error(e, e);
}
findView.getCommonViewer().refresh();
}
}
Aggregations