use of org.talend.dataquality.analysis.Analysis 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;
}
use of org.talend.dataquality.analysis.Analysis 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();
}
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class AnalysisHelper method getAnalysisUUID.
/**
* Get Analysis uuid by indicator
*
* @param indicator
* @return
*/
public static String getAnalysisUUID(Indicator indicator) {
Analysis analysis = getAnalysis(indicator);
String analysisUUID = null;
if (analysis != null) {
analysisUUID = ResourceHelper.getUUID(analysis);
}
return analysisUUID;
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class AnalysisHelper method createAnalysis.
/**
* Method "createAnalysis".
*
* @param name the name of the analysis
* @return the new analysis with the given name
*/
public static Analysis createAnalysis(String name) {
Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
analysis.setName(name);
return analysis;
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class EObjectHelper method getFirstDependency.
/**
* get the first Dependency of node(only used for METADATA_CON_TABLE and METADATA_CON_VIEW).
*
* @param node
* @return
*/
public static List<ModelElement> getFirstDependency(IRepositoryNode node) {
List<ModelElement> result = new ArrayList<ModelElement>();
if (node == null) {
return result;
}
// use the connection supplier to get analyses, and then check them when they use the droped table
// get the connection
ModelElement deleteModel = RepositoryNodeHelper.getMetadataElement(node);
Connection connection = ModelElementHelper.getConnection(deleteModel);
if (connection == null) {
return result;
}
// get the supplier Dependency of the connection
EList<Dependency> supplierDependency = connection.getSupplierDependency();
if (supplierDependency != null && supplierDependency.size() > 0) {
EList<ModelElement> clients = supplierDependency.get(0).getClient();
for (ModelElement client : clients) {
if (!(client instanceof Analysis)) {
continue;
}
Analysis analysis = (Analysis) client;
if (analysis.eIsProxy()) {
analysis = (Analysis) EObjectHelper.resolveObject(analysis);
}
AnalysisContext context = analysis.getContext();
EList<ModelElement> analysedElements = context.getAnalysedElements();
if (analysedElements != null && analysedElements.size() > 0) {
ModelElement analysisModel = null;
ModelElement firstAnalysisElement = analysedElements.get(0);
if (firstAnalysisElement instanceof MetadataColumn) {
analysisModel = ModelElementHelper.getContainer(firstAnalysisElement);
} else if (firstAnalysisElement instanceof MetadataTable) {
analysisModel = firstAnalysisElement;
}
if (compareModelElement(deleteModel, analysisModel)) {
result.add(analysis);
break;
}
}
}
}
return result;
}
Aggregations