Search in sources :

Example 31 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.

the class RecycleBinRepNode method addItemToRecycleBin.

private void addItemToRecycleBin(DQRepositoryNode parentNode, Item item, List<DQRepositoryNode> foldersList, Project project) {
    ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
    DQRepositoryNode currentParentNode = parentNode;
    if (item instanceof FolderItem) {
        itemType = getFolderContentType((FolderItem) item);
        FolderItem folderItem = (FolderItem) item;
        EList<Item> childrenList = folderItem.getChildren();
        if (childrenList.isEmpty()) {
            initChildren(folderItem, itemType);
        }
        if (folderItem.getState() != null && folderItem.getState().isDeleted()) {
            // need to display this folder in the recycle bin.
            Folder folder = new Folder(folderItem.getProperty(), itemType);
            DQRepositoryNode folderNode = null;
            for (DQRepositoryNode existingFolder : foldersList) {
                if (existingFolder.getContentType() == null) {
                    // this can appear temporary when another user has deleted a folder
                    break;
                }
                if (existingFolder.getContentType().equals(folder.getRepositoryObjectType()) && existingFolder.getProperties(EProperties.LABEL).equals(folder.getLabel())) {
                    folderNode = existingFolder;
                    break;
                }
            }
            if (folderNode == null) {
                folderNode = new DQRepositoryNode(folder, parentNode, ENodeType.SIMPLE_FOLDER, project);
                folderNode.setProperties(EProperties.CONTENT_TYPE, itemType);
                folderNode.setProperties(EProperties.LABEL, folder.getLabel());
                foldersList.add(folderNode);
                parentNode.getChildren(false).add(folderNode);
                folderNode.setParent(parentNode);
            }
            for (Item curItem : new ArrayList<Item>(childrenList)) {
                if (isAviableFolderForDQ(curItem, itemType)) {
                    addItemToRecycleBin(folderNode, curItem, foldersList, project);
                }
            }
            currentParentNode = folderNode;
        } else {
            for (Item curItem : new ArrayList<Item>(childrenList)) {
                if (isAviableFolderForDQ(curItem, itemType)) {
                    addItemToRecycleBin(parentNode, curItem, foldersList, project);
                }
            }
        }
    } else if (item.getState() != null && item.getState().isDeleted()) {
        // try {
        // IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(getProject(),
        // item.getProperty().getId());
        // String version = lastVersion.getVersion();
        // if (item.getProperty() .getVersion() .equals(version)) {
        DQRepositoryNode repNode = new DQRepositoryNode(new RepositoryViewObject(item.getProperty()), currentParentNode, ENodeType.REPOSITORY_ELEMENT, project);
        repNode.setProperties(EProperties.CONTENT_TYPE, itemType);
        repNode.setProperties(EProperties.LABEL, item.getProperty().getLabel());
        currentParentNode.getChildren(false).add(repNode);
        repNode.setParent(currentParentNode);
    // }
    // } catch (PersistenceException e) {
    // ExceptionHandler.process(e);
    // }
    }
}
Also used : Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) FolderItem(org.talend.core.model.properties.FolderItem) ArrayList(java.util.ArrayList) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Folder(org.talend.core.model.repository.Folder) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 32 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tmdm-studio-se by Talend.

the class RemoveFromRepositoryAction method removeFolderObject.

private void removeFolderObject(IRepositoryViewObject viewObj) {
    if (removed.contains(viewObj.getId())) {
        return;
    }
    for (IRepositoryViewObject childObj : viewObj.getChildren()) {
        if (childObj instanceof FolderRepositoryObject) {
            removeFolderObject(childObj);
        } else {
            removeServerObject(childObj);
        }
    }
    removed.add(viewObj.getId());
    // 
    ContainerItem containerItem = (ContainerItem) viewObj.getProperty().getItem();
    String path = containerItem.getState().getPath();
    ERepositoryObjectType repObjType = containerItem.getRepObjType();
    ContainerCacheService.removeContainer(repObjType, path);
    FolderItem folderItem = factory.getFolderItem(ProjectManager.getInstance().getCurrentProject(), repObjType, new Path(path));
    folderItem.getState().setDeleted(true);
}
Also used : Path(org.eclipse.core.runtime.Path) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) FolderItem(org.talend.core.model.properties.FolderItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 33 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tbd-studio-se by Talend.

the class HadoopClusterRepositoryTypeProcessor method selectRepositoryNode.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.repository.ui.processor.SingleTypeProcessor#selectRepositoryNode(org.eclipse.jface.viewers.Viewer,
     * org.talend.repository.model.RepositoryNode, org.talend.repository.model.RepositoryNode)
     */
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
    final String repositoryType = getRepositoryType();
    if (node == null || repositoryType == null) {
        return false;
    }
    ERepositoryObjectType repObjType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    if (repObjType == ERepositoryObjectType.REFERENCED_PROJECTS) {
        return true;
    }
    if (node.getType() == ENodeType.SYSTEM_FOLDER) {
        return true;
    }
    if (node.getType() == ENodeType.SIMPLE_FOLDER || HCRepositoryUtil.isHadoopContainerNode(node)) {
        return isValidFolder(node);
    }
    IRepositoryViewObject object = node.getObject();
    if (object == null || object.getProperty().getItem() == null) {
        return false;
    }
    if (object instanceof MetadataTable) {
        return false;
    }
    Item item = object.getProperty().getItem();
    if (item instanceof FolderItem) {
        return true;
    }
    return true;
}
Also used : Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) FolderItem(org.talend.core.model.properties.FolderItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.MetadataTable) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 34 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tbd-studio-se by Talend.

the class HadoopSubRepositoryTypeProcessor method selectRepositoryNode.

/*
     * (non-Javadoc)
     *
     * @see
     * org.talend.repository.ui.processor.SingleTypeProcessor#selectRepositoryNode(org.eclipse.jface.viewers.Viewer,
     * org.talend.repository.model.RepositoryNode, org.talend.repository.model.RepositoryNode)
     */
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
    final String repositoryType = getRepositoryType();
    if (node == null || repositoryType == null) {
        return false;
    }
    ERepositoryObjectType repObjType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    if (repObjType == ERepositoryObjectType.REFERENCED_PROJECTS) {
        return true;
    }
    if (node.getType() == ENodeType.SYSTEM_FOLDER) {
        return true;
    }
    if (node.getType() == ENodeType.SIMPLE_FOLDER || HCRepositoryUtil.isHadoopContainerNode(node)) {
        return isValidFolder(node);
    }
    IRepositoryViewObject object = node.getObject();
    if (object == null || object.getProperty().getItem() == null) {
        return false;
    }
    if (object instanceof MetadataTable) {
        return false;
    }
    Item item = object.getProperty().getItem();
    if (item instanceof FolderItem) {
        return true;
    }
    return true;
}
Also used : Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) FolderItem(org.talend.core.model.properties.FolderItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.MetadataTable) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 35 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tbd-studio-se by Talend.

the class NoSQLRepositoryTypeProcessor method selectRepositoryNode.

/*
     * (non-Javadoc)
     *
     * @see
     * org.talend.repository.ui.processor.SingleTypeProcessor#selectRepositoryNode(org.eclipse.jface.viewers.Viewer,
     * org.talend.repository.model.RepositoryNode, org.talend.repository.model.RepositoryNode)
     */
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
    final String repositoryType = getRepositoryType();
    if (node == null || repositoryType == null) {
        return false;
    }
    ERepositoryObjectType repObjType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    if (repObjType == ERepositoryObjectType.REFERENCED_PROJECTS) {
        return true;
    }
    if (node.getType() == ENodeType.SYSTEM_FOLDER) {
        return true;
    }
    IRepositoryViewObject object = node.getObject();
    if (object == null || object.getProperty().getItem() == null) {
        return false;
    }
    if (object instanceof MetadataTable) {
        return false;
    }
    Item item = object.getProperty().getItem();
    if (item instanceof FolderItem) {
        return true;
    }
    if (item instanceof NoSQLConnectionItem) {
        NoSQLConnectionItem connectionItem = (NoSQLConnectionItem) item;
        NoSQLConnection connection = (NoSQLConnection) connectionItem.getConnection();
        if (repositoryType.startsWith(INoSQLConstants.NOSQL_TYPE_PREFIX)) {
            // $NON-NLS-1$
            String realDbType = repositoryType.substring(repositoryType.indexOf(":") + 1);
            if (!StringUtils.equalsIgnoreCase(realDbType, connection.getDbType())) {
                return false;
            }
        }
    }
    return true;
}
Also used : Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem) FolderItem(org.talend.core.model.properties.FolderItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.MetadataTable) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem)

Aggregations

FolderItem (org.talend.core.model.properties.FolderItem)35 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)17 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)16 Item (org.talend.core.model.properties.Item)15 IFolder (org.eclipse.core.resources.IFolder)10 Folder (org.talend.core.model.repository.Folder)10 MetadataTable (org.talend.core.model.metadata.MetadataTable)7 Property (org.talend.core.model.properties.Property)6 ArrayList (java.util.ArrayList)5 IPath (org.eclipse.core.runtime.IPath)5 Path (org.eclipse.core.runtime.Path)5 PersistenceException (org.talend.commons.exception.PersistenceException)5 IFile (org.eclipse.core.resources.IFile)4 IProject (org.eclipse.core.resources.IProject)4 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 ProcessItem (org.talend.core.model.properties.ProcessItem)4 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)4 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)4 URL (java.net.URL)3 EObject (org.eclipse.emf.ecore.EObject)3