Search in sources :

Example 16 with Folder

use of org.talend.core.model.repository.Folder in project tdq-studio-se by Talend.

the class RulesParserFolderRepNode method getChildrenForProject.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.nodes.DQFolderRepNode#getChildrenForProject(boolean, org.talend.core.model.general.Project)
     */
@Override
public void getChildrenForProject(boolean withDeleted, Project project) throws PersistenceException {
    RootContainer<String, IRepositoryViewObject> tdqViewObjects = super.getTdqViewObjects(project, this);
    // sub folders
    for (Container<String, IRepositoryViewObject> container : tdqViewObjects.getSubContainer()) {
        Folder folder = new Folder((Property) container.getProperty(), ERepositoryObjectType.TDQ_RULES_PARSER);
        if (isIgnoreFolder(withDeleted, project, folder)) {
            continue;
        }
        RulesParserSubFolderRepNode childNodeFolder = new RulesParserSubFolderRepNode(folder, this, ENodeType.SIMPLE_FOLDER, project);
        childNodeFolder.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_RULES_PARSER);
        childNodeFolder.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_RULES_PARSER);
        super.getChildren().add(childNodeFolder);
    }
    // rule files
    for (IRepositoryViewObject viewObject : tdqViewObjects.getMembers()) {
        if (!withDeleted && viewObject.isDeleted()) {
            continue;
        }
        RuleRepNode repNode = new RuleRepNode(viewObject, this, ENodeType.REPOSITORY_ELEMENT, project);
        repNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_RULES_PARSER);
        repNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_RULES_PARSER);
        viewObject.setRepositoryNode(repNode);
        super.getChildren().add(repNode);
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Folder(org.talend.core.model.repository.Folder)

Example 17 with Folder

use of org.talend.core.model.repository.Folder in project tdq-studio-se by Talend.

the class RulesSQLFolderRepNode method getChildrenForProject.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.nodes.DQFolderRepNode#getChildrenForProject(boolean, org.talend.core.model.general.Project)
     */
@Override
public void getChildrenForProject(boolean withDeleted, Project project) throws PersistenceException {
    RootContainer<String, IRepositoryViewObject> tdqViewObjects = super.getTdqViewObjects(project, this);
    // sub folders
    for (Container<String, IRepositoryViewObject> container : tdqViewObjects.getSubContainer()) {
        Folder folder = new Folder((Property) container.getProperty(), ERepositoryObjectType.TDQ_RULES_SQL);
        if (isIgnoreFolder(withDeleted, project, folder)) {
            continue;
        }
        RulesSQLSubFolderRepNode childNodeFolder = new RulesSQLSubFolderRepNode(folder, this, ENodeType.SIMPLE_FOLDER, project);
        childNodeFolder.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_RULES_SQL);
        childNodeFolder.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_RULES_SQL);
        super.getChildren().add(childNodeFolder);
    }
    // rule files
    for (IRepositoryViewObject viewObject : tdqViewObjects.getMembers()) {
        if (!withDeleted && viewObject.isDeleted()) {
            continue;
        }
        RuleRepNode repNode = new RuleRepNode(viewObject, this, ENodeType.REPOSITORY_ELEMENT, project);
        repNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_RULES_SQL);
        repNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_RULES_SQL);
        viewObject.setRepositoryNode(repNode);
        // ADD msjian TDQ-4914: when the node is SystemDemoRule from ref project, we don't show it
        if (ProxyRepositoryManager.getInstance().isMergeRefProject()) {
            if (!project.isMainProject()) {
                ModelElement meNode = RepositoryNodeHelper.getResourceModelElement(repNode);
                if (meNode != null) {
                    String uuid = RepositoryNodeHelper.getUUID(meNode);
                    if (RepositoryNodeHelper.isSystemDemoRule(uuid)) {
                        continue;
                    }
                }
            }
        }
        // TDQ-4914~
        super.getChildren().add(repNode);
    }
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Folder(org.talend.core.model.repository.Folder)

Example 18 with Folder

use of org.talend.core.model.repository.Folder in project tdq-studio-se by Talend.

the class SourceFileFolderRepNode method getChildrenForProject.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.nodes.DQFolderRepNode#getChildrenForProject(boolean, org.talend.core.model.general.Project)
     */
@Override
public void getChildrenForProject(boolean withDeleted, org.talend.core.model.general.Project project) throws PersistenceException {
    RootContainer<String, IRepositoryViewObject> sourceFiles = super.getTdqViewObjects(project, this);
    // sub folders
    for (Container<String, IRepositoryViewObject> container : sourceFiles.getSubContainer()) {
        Folder folder = new Folder((Property) container.getProperty(), ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
        if (isIgnoreFolder(withDeleted, project, folder)) {
            continue;
        }
        SourceFileSubFolderNode childNodeFolder = new SourceFileSubFolderNode(folder, this, ENodeType.SIMPLE_FOLDER, project);
        childNodeFolder.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
        childNodeFolder.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
        super.getChildren().add(childNodeFolder);
    }
    // source files
    for (IRepositoryViewObject viewObject : sourceFiles.getMembers()) {
        if (!withDeleted && viewObject.isDeleted()) {
            continue;
        }
        // ADD msjian TDQ-4914: when the node is SystemDemoRule from ref project, we don't show it
        if (ProxyRepositoryManager.getInstance().isMergeRefProject()) {
            if (!project.isMainProject()) {
                if (RepositoryNodeHelper.isSystemDemoSourceFile(viewObject.getLabel())) {
                    continue;
                }
            }
        }
        // TDQ-4914~
        SourceFileRepNode repNode = new SourceFileRepNode(viewObject, this, ENodeType.REPOSITORY_ELEMENT, project);
        repNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
        repNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
        viewObject.setRepositoryNode(repNode);
        super.getChildren().add(repNode);
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Folder(org.talend.core.model.repository.Folder)

Example 19 with Folder

use of org.talend.core.model.repository.Folder in project tdq-studio-se by Talend.

the class UserDefIndicatorFolderRepNode method getChildrenForProject.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.nodes.DQFolderRepNode#getChildrenForProject(boolean, org.talend.core.model.general.Project)
     */
@Override
public void getChildrenForProject(boolean withDeleted, Project project) throws PersistenceException {
    RootContainer<String, IRepositoryViewObject> tdqViewObjects = super.getTdqViewObjects(project, this);
    // sub folders
    for (Container<String, IRepositoryViewObject> container : tdqViewObjects.getSubContainer()) {
        Folder folder = new Folder((Property) container.getProperty(), ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS);
        if (isIgnoreFolder(withDeleted, project, folder) || "lib".equals(folder.getLabel())) {
            // $NON-NLS-1$
            continue;
        }
        UserDefIndicatorSubFolderRepNode childNodeFolder = new UserDefIndicatorSubFolderRepNode(folder, this, ENodeType.SIMPLE_FOLDER, project);
        childNodeFolder.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS);
        childNodeFolder.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS);
        super.getChildren().add(childNodeFolder);
    }
    // rule files
    for (IRepositoryViewObject viewObject : tdqViewObjects.getMembers()) {
        if (!withDeleted && viewObject.isDeleted()) {
            continue;
        }
        SysIndicatorDefinitionRepNode repNode = new SysIndicatorDefinitionRepNode(viewObject, this, ENodeType.REPOSITORY_ELEMENT, project);
        repNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS);
        repNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS);
        viewObject.setRepositoryNode(repNode);
        super.getChildren().add(repNode);
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Folder(org.talend.core.model.repository.Folder)

Example 20 with Folder

use of org.talend.core.model.repository.Folder in project tdq-studio-se by Talend.

the class DQStructureManager method copyFilesToFolder.

/**
 * DOC klliu Comment method "copyFilesToFolder".
 *
 * @param plugin
 * @param srcPath
 * @param recurse
 * @param desFolder
 * @param suffix
 * @param type
 * @throws IOException
 * @throws CoreException
 */
public void copyFilesToFolder(Plugin plugin, String srcPath, boolean recurse, Folder desFolder, String suffix, ERepositoryObjectType type) throws IOException, CoreException {
    if (plugin == null) {
        return;
    }
    IProject project = ResourceManager.getRootProject();
    Enumeration<?> paths = null;
    paths = plugin.getBundle().getEntryPaths(srcPath);
    if (paths == null) {
        return;
    }
    while (paths.hasMoreElements()) {
        String nextElement = (String) paths.nextElement();
        // $NON-NLS-1$
        String currentPath = "/" + nextElement;
        URL resourceURL = plugin.getBundle().getEntry(currentPath);
        URL fileURL = null;
        File file = null;
        try {
            fileURL = FileLocator.toFileURL(resourceURL);
            file = new File(fileURL.getFile());
            if (file.isDirectory() && recurse) {
                if (file.getName().startsWith(".")) {
                    // $NON-NLS-1$
                    continue;
                }
                Folder sourcefolder = null;
                IFolder targetfolder = WorkbenchUtils.folder2IFolder(desFolder);
                if (!targetfolder.getFolder(file.getName()).exists()) {
                    sourcefolder = ProxyRepositoryFactory.getInstance().createFolder(type, Path.EMPTY, file.getName());
                } else {
                    FolderItem folderItem = ProxyRepositoryFactory.getInstance().getFolderItem(ProjectManager.getInstance().getCurrentProject(), type, new Path(file.getName()));
                    if (folderItem == null) {
                        sourcefolder = ProxyRepositoryFactory.getInstance().createFolder(type, Path.EMPTY, file.getName());
                        // $NON-NLS-1$
                        String subSourceFolder = type.getFolder().concat("/").concat(file.getName());
                        sourcefolder.getProperty().getItem().getState().setPath(subSourceFolder);
                    } else {
                        // $NON-NLS-1$
                        String subSourceFolder = type.getFolder().concat("/").concat(file.getName());
                        sourcefolder = new Folder(folderItem.getProperty(), type);
                        sourcefolder.getProperty().getItem().getState().setPath(subSourceFolder);
                    }
                }
                copyFilesToFolder(plugin, currentPath, recurse, sourcefolder, suffix, type);
                continue;
            }
            if (suffix != null && !file.getName().endsWith(suffix)) {
                continue;
            }
            String fileName = new Path(fileURL.getPath()).lastSegment();
            InputStream openStream = fileURL.openStream();
            String folderName = null;
            if (type.equals(ERepositoryObjectType.TDQ_PATTERN_ELEMENT)) {
                folderName = ERepositoryObjectType.getFolderName(type);
            }
            if (type.equals(ERepositoryObjectType.TDQ_RULES_SQL) || type.equals(ERepositoryObjectType.TDQ_RULES_PARSER)) {
                folderName = ERepositoryObjectType.getFolderName(type);
            } else if (type.equals(ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT)) {
                folderName = ERepositoryObjectType.getFolderName(type);
            } else {
                // $NON-NLS-1$
                folderName = ERepositoryObjectType.getFolderName(type) + "/" + desFolder.getLabel();
            }
            if (folderName.equals("date")) {
                // $NON-NLS-1$
                continue;
            }
            IFolder folder = project.getFolder(folderName);
            if (type.equals(ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT)) {
                String name = file.getName();
                // $NON-NLS-1$
                int indexOf = name.indexOf(".");
                String label = name.substring(0, indexOf);
                String extendtion = name.substring(indexOf + 1);
                createSourceFileItem(file, Path.EMPTY, label, extendtion);
            } else {
                copyFileToFolder(openStream, fileName, folder);
            }
            openStream.close();
        } catch (IOException e) {
            log.error(e, e);
        } catch (PersistenceException e) {
            log.error(e, e);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) InputStream(java.io.InputStream) IOException(java.io.IOException) Folder(org.talend.core.model.repository.Folder) IFolder(org.eclipse.core.resources.IFolder) IProject(org.eclipse.core.resources.IProject) URL(java.net.URL) FolderItem(org.talend.core.model.properties.FolderItem) PersistenceException(org.talend.commons.exception.PersistenceException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

Folder (org.talend.core.model.repository.Folder)45 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)34 IFolder (org.eclipse.core.resources.IFolder)16 FolderItem (org.talend.core.model.properties.FolderItem)10 ArrayList (java.util.ArrayList)9 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)9 RepositoryNode (org.talend.repository.model.RepositoryNode)9 IPath (org.eclipse.core.runtime.IPath)7 IRepositoryNode (org.talend.repository.model.IRepositoryNode)7 PersistenceException (org.talend.commons.exception.PersistenceException)5 File (java.io.File)4 IContainer (org.eclipse.core.resources.IContainer)4 IProject (org.eclipse.core.resources.IProject)4 Path (org.eclipse.core.runtime.Path)4 Item (org.talend.core.model.properties.Item)4 IFile (org.eclipse.core.resources.IFile)3 Project (org.talend.core.model.general.Project)3 ItemState (org.talend.core.model.properties.ItemState)3 Property (org.talend.core.model.properties.Property)3 IOException (java.io.IOException)2