Search in sources :

Example 1 with RepositoryNodeBuilder

use of org.talend.dataprofiler.core.ui.views.provider.RepositoryNodeBuilder in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method createRealSourceFileFolderRepNode.

/**
 * create the real SourceFileFolderRepNode.
 *
 * @param parentNode
 * @return
 */
public static SourceFileFolderRepNode createRealSourceFileFolderRepNode(RepositoryNode parentNode) {
    SourceFileFolderRepNode node = null;
    RepositoryNodeBuilder instance = RepositoryNodeBuilder.getInstance();
    try {
        node = (SourceFileFolderRepNode) instance.createRepositoryNodeSystemFolder(instance.getFolderHelper(), parentNode, EResourceConstant.SOURCE_FILES);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    return node;
}
Also used : SourceFileFolderRepNode(org.talend.dq.nodes.SourceFileFolderRepNode) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryNodeBuilder(org.talend.dataprofiler.core.ui.views.provider.RepositoryNodeBuilder)

Example 2 with RepositoryNodeBuilder

use of org.talend.dataprofiler.core.ui.views.provider.RepositoryNodeBuilder in project tdq-studio-se by Talend.

the class DQStructureManager method createDQStructureUnit.

/**
 * DOC zhao Comment method "createDQStructureUnit".
 */
private void createDQStructureUnit() {
    RepositoryNodeBuilder instance = RepositoryNodeBuilder.getInstance();
    Plugin plugin = CorePlugin.getDefault();
    try {
        IProject project = ResourceManager.getRootProject();
        if (!project.exists()) {
            project = createNewProject(ResourceManager.getRootProjectName());
        }
        if (!project.getFolder(EResourceConstant.DB_CONNECTIONS.getPath()).exists()) {
            ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.METADATA, Path.EMPTY, EResourceConstant.DB_CONNECTIONS.getName());
        }
        if (!project.getFolder(EResourceConstant.FILEDELIMITED.getPath()).exists()) {
            ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.METADATA, Path.EMPTY, EResourceConstant.FILEDELIMITED.getName());
        }
        if (!project.getFolder(EResourceConstant.ANALYSIS.getPath()).exists()) {
            ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_DATA_PROFILING, Path.EMPTY, EResourceConstant.ANALYSIS.getName());
        }
        if (PluginChecker.isTDQLoaded()) {
            if (!project.getFolder(EResourceConstant.REPORTS.getPath()).exists()) {
                ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_DATA_PROFILING, Path.EMPTY, EResourceConstant.REPORTS.getName());
            }
            // Added 20150421 TDQ-9605
            if (!project.getFolder(EResourceConstant.HADOOP_CLUSTER.getPath()).exists() && HadoopClusterUtils.getDefault().isServiceInstalled()) {
                ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.METADATA, Path.EMPTY, EResourceConstant.HADOOP_CLUSTER.getName());
            }
        }
        if (!project.getFolder(EResourceConstant.PATTERNS.getPath()).exists()) {
            ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES, Path.EMPTY, EResourceConstant.PATTERNS.getName());
        }
        if (!project.getFolder(EResourceConstant.RULES.getPath()).exists()) {
            ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES, Path.EMPTY, EResourceConstant.RULES.getName());
        }
        Folder rulesSQLFoler = null;
        if (!project.getFolder(EResourceConstant.RULES_SQL.getPath()).exists()) {
            rulesSQLFoler = ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_RULES, Path.EMPTY, EResourceConstant.RULES_SQL.getName());
        } else {
            rulesSQLFoler = instance.getObjectFolder(EResourceConstant.RULES_SQL);
        }
        rulesSQLFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_RULES_SQL.getFolder());
        Folder rulesMatchLFoler = null;
        if (!project.getFolder(EResourceConstant.RULES_MATCHER.getPath()).exists()) {
            rulesMatchLFoler = ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_RULES, Path.EMPTY, EResourceConstant.RULES_MATCHER.getName());
        } else {
            rulesMatchLFoler = instance.getObjectFolder(EResourceConstant.RULES_MATCHER);
        }
        rulesMatchLFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_RULES_MATCHER.getFolder());
        Folder rulesParserFoler = null;
        if (!project.getFolder(EResourceConstant.RULES_PARSER.getPath()).exists()) {
            if (PluginChecker.isTDQLoaded()) {
                rulesParserFoler = ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_RULES, Path.EMPTY, EResourceConstant.RULES_PARSER.getName());
            }
        } else {
            rulesParserFoler = instance.getObjectFolder(EResourceConstant.RULES_PARSER);
        }
        if (rulesParserFoler != null) {
            rulesParserFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_RULES_PARSER.getFolder());
        }
        if (!project.getFolder(EResourceConstant.EXCHANGE.getPath()).exists()) {
            ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES, Path.EMPTY, EResourceConstant.EXCHANGE.getName());
        }
        if (!project.getFolder(EResourceConstant.INDICATORS.getPath()).exists()) {
            ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES, Path.EMPTY, EResourceConstant.INDICATORS.getName());
        }
        Folder systemIndicatorFoler = null;
        if (!project.getFolder(EResourceConstant.SYSTEM_INDICATORS.getPath()).exists()) {
            systemIndicatorFoler = ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_INDICATOR_ELEMENT, Path.EMPTY, EResourceConstant.SYSTEM_INDICATORS.getName());
        } else {
            systemIndicatorFoler = instance.getObjectFolder(EResourceConstant.SYSTEM_INDICATORS);
        }
        systemIndicatorFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_SYSTEM_INDICATORS.getFolder());
        if (!project.getFolder(EResourceConstant.USER_DEFINED_INDICATORS.getPath()).exists()) {
            ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_INDICATOR_ELEMENT, Path.EMPTY, EResourceConstant.USER_DEFINED_INDICATORS.getName());
        }
        if (!project.getFolder(EResourceConstant.USER_DEFINED_INDICATORS_LIB.getPath()).exists()) {
            // MOD zhsne 18724: Java UDI enhancements add lib folder under UDI folder.
            ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS, Path.EMPTY, EResourceConstant.USER_DEFINED_INDICATORS_LIB.getName());
        }
        if (PluginChecker.isTDQLoaded()) {
            if (!project.getFolder(EResourceConstant.JRXML_TEMPLATE.getPath()).exists()) {
                ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES, Path.EMPTY, EResourceConstant.JRXML_TEMPLATE.getName());
            }
            if (!project.getFolder(EResourceConstant.CONTEXT.getPath()).exists()) {
                ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.CONTEXT, Path.EMPTY, EResourceConstant.CONTEXT.getName());
            }
        }
        Folder patternRegexFoler = null;
        if (!project.getFolder(EResourceConstant.PATTERN_REGEX.getPath()).exists()) {
            patternRegexFoler = ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_PATTERN_ELEMENT, Path.EMPTY, EResourceConstant.PATTERN_REGEX.getName());
        } else {
            patternRegexFoler = instance.getObjectFolder(EResourceConstant.PATTERN_REGEX);
        }
        patternRegexFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_PATTERN_REGEX.getFolder());
        Folder patternSQLFoler = null;
        if (!project.getFolder(EResourceConstant.PATTERN_SQL.getPath()).exists()) {
            patternSQLFoler = ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_PATTERN_ELEMENT, Path.EMPTY, EResourceConstant.PATTERN_SQL.getName());
        } else {
            patternSQLFoler = instance.getObjectFolder(EResourceConstant.PATTERN_SQL);
        }
        patternSQLFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_PATTERN_SQL.getFolder());
        Folder sourceFileFoler = null;
        if (!project.getFolder(EResourceConstant.SOURCE_FILES.getPath()).exists()) {
            sourceFileFoler = ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES, Path.EMPTY, EResourceConstant.SOURCE_FILES.getName());
        } else {
            sourceFileFoler = instance.getObjectFolder(EResourceConstant.SOURCE_FILES);
        }
        sourceFileFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getFolder());
        // use the tos create folder API
        if (systemIndicatorFoler != null && patternRegexFoler != null && patternSQLFoler != null && sourceFileFoler != null && rulesSQLFoler != null) {
            copyFilesToFolder(plugin, SYSTEM_INDICATOR_PATH, true, systemIndicatorFoler, null, ERepositoryObjectType.TDQ_SYSTEM_INDICATORS);
            copyFilesToFolder(plugin, PATTERN_PATH, true, patternRegexFoler, null, ERepositoryObjectType.TDQ_PATTERN_REGEX);
            copyFilesToFolder(plugin, SQL_LIKE_PATH, true, patternSQLFoler, null, ERepositoryObjectType.TDQ_PATTERN_SQL);
            copyFilesToFolder(plugin, DEMO_PATH, true, sourceFileFoler, null, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
            copyFilesToFolder(plugin, RULES_PATH, true, rulesSQLFoler, null, ERepositoryObjectType.TDQ_RULES_SQL);
        }
        if (rulesParserFoler != null) {
            copyFilesToFolder(plugin, RULES_PARSER, true, rulesParserFoler, null, ERepositoryObjectType.TDQ_RULES_PARSER);
        }
        WorkspaceVersionHelper.storeVersion();
        // MOD qiongli 2011-12-6 TDQ-4095,make the definition file commit to svn with the DQ struct files.move
        // this code from DQRespositoryView.initWorkspace()
        IFile defFile = ResourceManager.getLibrariesFolder().getFile(DefinitionHandler.FILENAME);
        if (!defFile.exists()) {
            DefinitionHandler handler = DefinitionHandler.getInstance();
            // TDQ-4714 update the aggregateDefinitions tag for some indicator definition.
            handler.updateAggregates();
        }
        ResourceService.refreshStructure();
    } catch (Exception ex) {
        ExceptionHandler.process(ex);
        ProxyRepositoryManager.getInstance().save();
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) Folder(org.talend.core.model.repository.Folder) IFolder(org.eclipse.core.resources.IFolder) RepositoryNodeBuilder(org.talend.dataprofiler.core.ui.views.provider.RepositoryNodeBuilder) DefinitionHandler(org.talend.dq.indicators.definitions.DefinitionHandler) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException) PersistenceException(org.talend.commons.exception.PersistenceException) CorePlugin(org.talend.dataprofiler.core.CorePlugin) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) CoreRuntimePlugin(org.talend.core.runtime.CoreRuntimePlugin) Plugin(org.eclipse.core.runtime.Plugin)

Example 3 with RepositoryNodeBuilder

use of org.talend.dataprofiler.core.ui.views.provider.RepositoryNodeBuilder in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method createRealDataProfilingNode.

/**
 * create the real RepositoryNode for DataProfiling.
 *
 * @return
 */
public static RepositoryNode createRealDataProfilingNode(IProject project) {
    RepositoryNode node = null;
    RepositoryNodeBuilder instance = RepositoryNodeBuilder.getInstance();
    FolderHelper folderHelper = instance.getFolderHelper();
    IFolder iFolder = project.getFolder(Path.fromPortableString(ERepositoryObjectType.TDQ_DATA_PROFILING.getFolder()));
    IRepositoryViewObject viewObject = null;
    if (folderHelper != null) {
        IPath relativePath = iFolder.getFullPath().makeRelativeTo((project).getFullPath());
        FolderItem folder2 = folderHelper.getFolder(relativePath);
        if (folder2 != null && relativePath != null) {
            viewObject = new Folder(folder2.getProperty(), instance.retrieveRepObjectTypeByPath(relativePath.toOSString()));
        }
    } else {
        viewObject = new Folder(iFolder.getName(), iFolder.getName());
    }
    node = new RepositoryNode(viewObject, null, ENodeType.SYSTEM_FOLDER);
    viewObject.setRepositoryNode(node);
    return node;
}
Also used : FolderHelper(org.talend.core.repository.model.FolderHelper) FolderItem(org.talend.core.model.properties.FolderItem) IPath(org.eclipse.core.runtime.IPath) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Folder(org.talend.core.model.repository.Folder) IFolder(org.eclipse.core.resources.IFolder) RepositoryNodeBuilder(org.talend.dataprofiler.core.ui.views.provider.RepositoryNodeBuilder) IFolder(org.eclipse.core.resources.IFolder)

Example 4 with RepositoryNodeBuilder

use of org.talend.dataprofiler.core.ui.views.provider.RepositoryNodeBuilder in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method createRealReportFolderRepNode.

/**
 * create the real ReportFolderRepNode.
 *
 * @param parentNode
 * @return
 */
public static ReportFolderRepNode createRealReportFolderRepNode(RepositoryNode parentNode) {
    ReportFolderRepNode node = null;
    RepositoryNodeBuilder instance = RepositoryNodeBuilder.getInstance();
    try {
        node = (ReportFolderRepNode) instance.createRepositoryNodeSystemFolder(instance.getFolderHelper(), parentNode, EResourceConstant.REPORTS);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    return node;
}
Also used : ReportFolderRepNode(org.talend.dq.nodes.ReportFolderRepNode) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryNodeBuilder(org.talend.dataprofiler.core.ui.views.provider.RepositoryNodeBuilder)

Aggregations

RepositoryNodeBuilder (org.talend.dataprofiler.core.ui.views.provider.RepositoryNodeBuilder)4 PersistenceException (org.talend.commons.exception.PersistenceException)3 IFolder (org.eclipse.core.resources.IFolder)2 Folder (org.talend.core.model.repository.Folder)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 ResourcesPlugin (org.eclipse.core.resources.ResourcesPlugin)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 Plugin (org.eclipse.core.runtime.Plugin)1 FolderItem (org.talend.core.model.properties.FolderItem)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 FolderHelper (org.talend.core.repository.model.FolderHelper)1 CoreRuntimePlugin (org.talend.core.runtime.CoreRuntimePlugin)1 CorePlugin (org.talend.dataprofiler.core.CorePlugin)1 DefinitionHandler (org.talend.dq.indicators.definitions.DefinitionHandler)1 ReportFolderRepNode (org.talend.dq.nodes.ReportFolderRepNode)1