Search in sources :

Example 56 with Analysis

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);
        }
    }
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IFile(org.eclipse.core.resources.IFile) Analysis(org.talend.dataquality.analysis.Analysis) ArrayList(java.util.ArrayList) Dependency(orgomg.cwm.objectmodel.core.Dependency) URI(org.eclipse.emf.common.util.URI) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Example 57 with Analysis

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));
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 58 with 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();
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) Analysis(org.talend.dataquality.analysis.Analysis)

Example 59 with Analysis

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();
        }
    }
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IFile(org.eclipse.core.resources.IFile) Analysis(org.talend.dataquality.analysis.Analysis) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) Dependency(orgomg.cwm.objectmodel.core.Dependency) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 60 with Analysis

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);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis)

Aggregations

Analysis (org.talend.dataquality.analysis.Analysis)137 Test (org.junit.Test)36 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)36 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)30 ArrayList (java.util.ArrayList)28 Property (org.talend.core.model.properties.Property)28 Indicator (org.talend.dataquality.indicators.Indicator)27 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)27 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)26 PersistenceException (org.talend.commons.exception.PersistenceException)19 Connection (org.talend.core.model.metadata.builder.connection.Connection)18 ReturnCode (org.talend.utils.sugars.ReturnCode)18 Dependency (orgomg.cwm.objectmodel.core.Dependency)18 TdColumn (org.talend.cwm.relational.TdColumn)16 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)16 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)15 Pattern (org.talend.dataquality.domain.pattern.Pattern)15 IFile (org.eclipse.core.resources.IFile)14 File (java.io.File)12 IPath (org.eclipse.core.runtime.IPath)12