use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class ResourceDropAdapterAssistant method handleDrop.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop (org.eclipse.ui.navigator.CommonDropAdapter,
* org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object)
*/
@Override
public IStatus handleDrop(CommonDropAdapter aDropAdapter, DropTargetEvent aDropTargetEvent, Object target) {
// alwaysOverwrite = false;
if (aDropAdapter.getCurrentTarget() == null || aDropTargetEvent.data == null) {
return Status.CANCEL_STATUS;
}
// IStatus status = null;
IResource[] resources = null;
TransferData currentTransfer = aDropAdapter.getCurrentTransfer();
if (LocalSelectionTransfer.getTransfer().isSupportedType(currentTransfer)) {
resources = getSelectedResources();
} else if (ResourceTransfer.getInstance().isSupportedType(currentTransfer)) {
resources = (IResource[]) aDropTargetEvent.data;
}
if ((target instanceof IFile)) {
// && dropRep
TdReport findReport = RepResourceFileHelper.getInstance().findReport(((IFile) target));
List<Analysis> analyses = ReportHelper.getAnalyses(findReport);
Map<String, Analysis> resourcesMap = new HashMap<String, Analysis>();
for (Analysis ana : analyses) {
String uriString = ana.eResource().getURI().toString();
resourcesMap.put(uriString, ana);
}
if (resources != null && resources.length > 0) {
List<Analysis> anaList = new ArrayList<Analysis>();
for (IResource res : resources) {
Analysis findAnalysis = AnaResourceFileHelper.getInstance().findAnalysis((IFile) res);
if (findAnalysis != null) {
String uriKey = findAnalysis.eResource().getURI().toString();
if (resourcesMap.containsKey(uriKey)) {
findReport.removeAnalysis(resourcesMap.get(uriKey));
}
anaList.add(findAnalysis);
}
}
// ReportHelper.addAnalyses(anaList, findReport);
RepResourceFileHelper.getInstance().save(findReport);
}
} else if (resources != null && (target instanceof IFolder)) {
// && dropSql
IFolder folder = (IFolder) target;
// IPath location = folder.getFullPath();
for (IResource res : resources) {
if (res.getType() != IResource.FILE) {
return null;
}
if (folder.equals(res.getParent())) {
continue;
}
String name = res.getName();
IFile fileRes = (IFile) res;
IFile movedIFile = folder.getFile(name);
if (!FactoriesUtil.isEmfFile(fileRes.getFileExtension())) {
try {
fileRes.move(movedIFile.getFullPath(), false, null);
fileRes.getParent().refreshLocal(IResource.DEPTH_INFINITE, null);
folder.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
return Status.OK_STATUS;
}
IContainer srcParent = fileRes.getParent();
URI srcUri = URI.createPlatformResourceURI((fileRes).getFullPath().toString(), false);
Resource resource = EMFSharedResources.getInstance().getResource(srcUri, true);
if (resource != null) {
URI desUri = URI.createPlatformResourceURI(folder.getFullPath().toString(), false);
EMFSharedResources.getInstance().saveToUri(resource, desUri);
// ADD xqliu 2010-09-21 bug 15685
IFile propertyFile = PropertyHelper.getPropertyFile(fileRes);
if (propertyFile != null) {
IFile movedPropertyFile = folder.getFile(propertyFile.getName());
try {
propertyFile.move(movedPropertyFile.getFullPath(), true, null);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
// ~ 15685
}
try {
closeEditorIfOpened(fileRes);
fileRes.delete(true, null);
srcParent.refreshLocal(IResource.DEPTH_INFINITE, null);
folder.refreshLocal(IResource.DEPTH_INFINITE, null);
// ADD xqliu 2010-09-25 bug 15685 update the path of ItemState
Property property = PropertyHelper.getProperty(PropertyHelper.getPropertyFile(movedIFile));
property.getItem().getState().setPath(PropertyHelper.computePath(property));
// ~ 15685
} catch (CoreException e) {
ExceptionHandler.process(e);
}
movedIFile = folder.getFile(name);
}
}
ProxyRepositoryManager.getInstance().save();
CorePlugin.getDefault().refreshDQView();
return null;
}
use of org.talend.dataquality.analysis.Analysis 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.analysis.Analysis in project tdq-studio-se by Talend.
the class ItemRecord method getClintDependencyForExport.
/**
* @param mElement
* @return SupplierDependency
*
* getClintDependency here will contain system indicators so only will be used by export case
*/
public List<File> getClintDependencyForExport(ModelElement mElement) {
List<File> result = new ArrayList<File>();
if (mElement != null) {
result = iterateClientDependencies(mElement);
// current object is analysis case
if (mElement instanceof Analysis) {
result.addAll(getSystemIndicaotrOfAnalysis(mElement));
} else {
// if object is report, then the analyses inside reports should be considered. The system indicators of
// analyses should be added into the result list too.
List<File> tempList = new ArrayList<File>();
tempList.addAll(result);
for (File tempFile : tempList) {
ModelElement me = getElement(tempFile);
if (me != null && me instanceof Analysis) {
result.addAll(getSystemIndicaotrOfAnalysis(me));
}
}
}
}
return result;
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class ItemRecord method getSystemIndicaotrOfAnalysis.
/**
* get Analysis Dependency (for indicator only).
*
* @return get the list of indicator which in use by the analysis
*/
private List<File> getSystemIndicaotrOfAnalysis(ModelElement mElement) {
List<File> listFile = new ArrayList<File>();
if (mElement instanceof Analysis) {
Analysis anaElement = (Analysis) mElement;
List<Indicator> indicators = IndicatorHelper.getIndicators(anaElement.getResults());
for (Indicator indicator : indicators) {
if (indicator instanceof UserDefIndicator) {
// whereRuleIndicator or UDIIndicator
continue;
}
boolean isContain = false;
IndicatorDefinition newIndicatorDefinition = indicator.getIndicatorDefinition();
// MOD qiongli 2012-5-11 TDQ-5256
if (newIndicatorDefinition == null) {
continue;
}
for (File lf : listFile) {
ModelElement me = getElement(lf);
if (me != null && me instanceof IndicatorDefinition) {
IndicatorDefinition oldIndicatorDefinition = (IndicatorDefinition) me;
if (ModelElementHelper.compareUUID(oldIndicatorDefinition, newIndicatorDefinition)) {
isContain = true;
break;
}
}
}
if (!isContain) {
File depFile = EObjectHelper.modelElement2File(newIndicatorDefinition);
if (depFile != null) {
FILE_ELEMENT_MAP.put(depFile, newIndicatorDefinition);
listFile.add(depFile);
}
}
}
}
return listFile;
}
use of org.talend.dataquality.analysis.Analysis 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;
}
Aggregations