Search in sources :

Example 6 with DQStructureManager

use of org.talend.dataprofiler.core.manager.DQStructureManager in project tdq-studio-se by Talend.

the class SplitSysIndicatorTask method doExecute.

@Override
protected boolean doExecute() throws Exception {
    boolean ok = true;
    // Copy system indicators.
    DQStructureManager manager = DQStructureManager.getInstance();
    IFolder systemIndicatorFolder = ResourceManager.getSystemIndicatorFolder();
    if (!systemIndicatorFolder.exists()) {
        systemIndicatorFolder = manager.createNewFolder(ResourceManager.getIndicatorFolder(), EResourceConstant.SYSTEM_INDICATORS);
    }
    manager.copyFilesToFolder(CorePlugin.getDefault(), DQStructureManager.SYSTEM_INDICATOR_PATH, true, systemIndicatorFolder, null, true);
    DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
    // Migration for analyses (indicator definition)
    Collection<Analysis> analyses = (Collection<Analysis>) AnaResourceFileHelper.getInstance().getAllElement();
    for (Analysis ana : analyses) {
        try {
            for (Indicator ind : ana.getResults().getIndicators()) {
                updateIndDefinition(ind);
                if (ind instanceof CompositeIndicator) {
                    for (Indicator indLeave : IndicatorHelper.getIndicatorLeavesBySingleNode(ind)) {
                        updateIndDefinition(indLeave);
                    }
                }
            }
            EMFSharedResources.getInstance().saveResource(ana.eResource());
        } catch (Exception e) {
            log.warn(e, e);
            ok = false;
        }
    }
    // MOD qiongli 2011-11-16 TDQ-3694,should relaod definitions and all categories after changing the definition
    // file.
    // Copy system indicator categories.
    IFile file = ResourceManager.getLibrariesFolder().getFile(DefinitionHandler.FILENAME);
    file.delete(true, new NullProgressMonitor());
    DefinitionHandler.getInstance().copyDefinitionsIntoFolder(ResourceManager.getLibrariesFolder());
    URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), false);
    EMFSharedResources.getInstance().reloadResource(uri);
    DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
    return ok;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) DQStructureManager(org.talend.dataprofiler.core.manager.DQStructureManager) Analysis(org.talend.dataquality.analysis.Analysis) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) Collection(java.util.Collection) URI(org.eclipse.emf.common.util.URI) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

DQStructureManager (org.talend.dataprofiler.core.manager.DQStructureManager)6 IFolder (org.eclipse.core.resources.IFolder)5 Path (org.eclipse.core.runtime.Path)2 Collection (java.util.Collection)1 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 URI (org.eclipse.emf.common.util.URI)1 Analysis (org.talend.dataquality.analysis.Analysis)1 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)1 Indicator (org.talend.dataquality.indicators.Indicator)1 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)1