use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class ReorderingLibraryFoldersTask method moveItems.
private void moveItems(IFolder oldSubFolder, IFolder newSubfolder) throws CoreException {
if (!oldSubFolder.exists()) {
return;
}
for (IResource oldResource : oldSubFolder.members()) {
if (newSubfolder.getName().equals(oldResource.getName())) {
continue;
}
// cannot simply copy EMF files: need to keep the links between files when moving them. See bug 9461
if (oldResource instanceof IFolder) {
IFolder oldFolder = (IFolder) oldResource;
IFolder newFolder = DQStructureManager.getInstance().createNewFolder(newSubfolder, oldFolder.getName());
moveItems(oldFolder, newFolder);
// delete folder
oldFolder.delete(true, null);
}
if (oldResource instanceof IFile) {
IFile file = (IFile) oldResource;
final ModelElement eltFromLibraryFolder = getModelElement(file);
final EList<Dependency> supplierDependency = eltFromLibraryFolder.getSupplierDependency();
if (supplierDependency.isEmpty()) {
// simple copy of file is enough
oldResource.copy(newSubfolder.getFolder(oldResource.getName()).getFullPath(), true, null);
} else {
// handle dependent analyses
List<Analysis> analyses = new ArrayList<Analysis>();
for (Dependency dependency : supplierDependency) {
URI newUri = URI.createPlatformResourceURI(newSubfolder.getFullPath().toOSString(), true);
// move pattern
EMFUtil.changeUri(eltFromLibraryFolder.eResource(), newUri);
final EList<ModelElement> clientAnalyses = dependency.getClient();
for (ModelElement modelElement : clientAnalyses) {
Analysis analysis = DataqualitySwitchHelper.ANALYSIS_SWITCH.doSwitch(modelElement);
if (analysis != null) {
analyses.add(analysis);
}
}
}
// clean the dependencies that do not refer to an existing object.
for (Analysis analysis : analyses) {
final EList<Dependency> clientDependency = analysis.getClientDependency();
List<Dependency> newClientDeps = new ArrayList<Dependency>();
for (Dependency dependency : clientDependency) {
if (!dependency.eIsProxy()) {
newClientDeps.add(dependency);
}
}
clientDependency.clear();
clientDependency.addAll(newClientDeps);
AnaResourceFileHelper.getInstance().save(analysis);
}
}
remove(file);
}
}
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class TDQAnalysisItemImpl method setAnalysis.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAnalysis(Analysis newAnalysis) {
Analysis oldAnalysis = analysis;
analysis = newAnalysis;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, PropertiesPackage.TDQ_ANALYSIS_ITEM__ANALYSIS, oldAnalysis, analysis));
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class ResourceManager method getMapDBCatalogName.
/**
* Get the catalog name of current indicator.
*
* @param indicator we should find the name of analysis,analysisElement,indicatorDefinition.So that it should be
* used by some one analysis
*
* ColumnAnalysis like(../analysisName/columnName/indicatorName) others like(../analysisName/indicatorName)
* @return
*/
public static String getMapDBCatalogName(Indicator indicator) {
Analysis analysis = AnalysisHelper.getAnalysis(indicator);
String analysisUUID = null;
String indicatorUUID = ResourceHelper.getUUID(indicator);
String modelElementName = Path.EMPTY.toString();
if (analysis == null) {
// $NON-NLS-1$
log.error(Messages.getString("ResourceManager.CanNotGetAnalysis"));
} else {
analysisUUID = ResourceHelper.getUUID(analysis);
if (AnalysisType.MULTIPLE_COLUMN.equals(analysis.getParameters().getAnalysisType())) {
modelElementName = indicator.getAnalyzedElement().getName();
// TDQ-12795, only for file delimited connection, the name of the column maybe null, but the label always has value.
if (modelElementName == null) {
if (indicator.getAnalyzedElement() instanceof MetadataColumn) {
if (indicator.getAnalyzedElement().eIsProxy()) {
modelElementName = Path.EMPTY.toString();
} else {
modelElementName = ((MetadataColumn) indicator.getAnalyzedElement()).getLabel();
}
} else {
modelElementName = Path.EMPTY.toString();
log.error(Messages.getString("ResourceManager.CanNotGetColunName"));
}
}
}
}
return getTempMapDBFolder().append(analysisUUID).append(modelElementName).append(indicatorUUID).append("_").toString();
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class TDQResourceChangeHandler method updateDependeciesWhenVersionChange.
@Override
public void updateDependeciesWhenVersionChange(ConnectionItem connItem, String oldVersion, String newVersion) {
Connection connection = connItem.getConnection();
if (connection != null) {
EList<Dependency> supplierDependencies = connection.getSupplierDependency();
if (supplierDependencies != null && !supplierDependencies.isEmpty()) {
Dependency[] arraySupplierDeps = supplierDependencies.toArray(new Dependency[supplierDependencies.size()]);
for (Dependency supplierDep : arraySupplierDeps) {
EList<ModelElement> clients = supplierDep.getClient();
if (clients != null && !clients.isEmpty()) {
ModelElement[] arrayClients = clients.toArray(new ModelElement[clients.size()]);
for (ModelElement client : arrayClients) {
if (client instanceof Analysis) {
IFile clientFile = AnaResourceFileHelper.findCorrespondingFile(client);
if (clientFile != null) {
File file = WorkspaceUtils.ifileToFile(clientFile);
if (file != null) {
replaceVersionInfo(connection.getName(), file, oldVersion, newVersion);
reloadFile(file);
}
}
}
}
}
}
ResourceService.refreshStructure();
WorkbenchUtils.refreshAnalysesNode();
WorkbenchUtils.refreshMetadataNode();
}
}
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class DeleteModelElementConfirmDialog method addDenpendencyElements.
/**
* The first level node is (connection, DQ rule, Pattern), the second level is analysis, Jrxml, the third is report
* only for analysis , need to check if there are some reports depends on this analysis and list them if any.
*
* @param node
* @param dependencies
*/
private static void addDenpendencyElements(IRepositoryNode node, List<ModelElement> dependencies) {
ImpactNode impactNode;
// if node is a jrxml
if (ERepositoryObjectType.TDQ_JRAXML_ELEMENT.equals(node.getObject().getRepositoryObjectType())) {
impactNode = new ImpactNode(node);
} else {
impactNode = new ImpactNode(RepositoryNodeHelper.getModelElementFromRepositoryNode(node));
}
for (ModelElement element : dependencies) {
// only for analysis
if (element instanceof Analysis) {
List<ModelElement> dependReports = EObjectHelper.getDependencyClients(element);
if (dependReports.size() > 0) {
ImpactNode anaNode = new ImpactNode(element);
for (ModelElement report : dependReports) {
anaNode.addRequireModelElement(report);
}
// impactNodes.add(anaNode);
impactNode.addRequireModelElement(anaNode);
} else {
impactNode.addRequireModelElement(element);
}
} else {
impactNode.addRequireModelElement(element);
}
}
impactNodes.add(impactNode);
}
Aggregations