Search in sources :

Example 31 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.

the class AbstractRemoveCommandStackAction method removeFolderObject.

private void removeFolderObject(FolderRepositoryObject viewObj) {
    Project project = ProjectManager.getInstance().getCurrentProject();
    ContainerItem containerItem = (ContainerItem) viewObj.getProperty().getItem();
    String path = containerItem.getState().getPath();
    ERepositoryObjectType repObjType = containerItem.getRepObjType();
    // ContainerCacheService.removeContainer(repObjType, path);
    for (IRepositoryViewObject childObj : viewObj.getChildren()) {
        if (childObj instanceof FolderRepositoryObject) {
            removeFolderObject((FolderRepositoryObject) childObj);
        } else {
            removeServerObject(childObj);
        }
    }
    try {
        factory.deleteFolder(project, repObjType, new Path(path), false);
    } catch (PersistenceException e) {
        log.error(e.getMessage(), e);
    }
}
Also used : Path(org.eclipse.core.runtime.Path) Project(org.talend.core.model.general.Project) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 32 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.

the class ContainerCacheService method putContainer.

public static void putContainer(IRepositoryViewObject viewObj) {
    Item item = viewObj.getProperty().getItem();
    if (item instanceof ContainerItem) {
        ERepositoryObjectType repObjType = ((ContainerItem) item).getRepObjType();
        Map<String, IRepositoryViewObject> map = containerMap.get(repObjType);
        if (map == null) {
            map = new HashMap<String, IRepositoryViewObject>();
            containerMap.put(repObjType, map);
        }
        // 
        String path = correctPath(item.getState().getPath());
        map.put(path, viewObj);
    }
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 33 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.

the class ContainerCacheService method getParent.

public static IRepositoryViewObject getParent(IRepositoryViewObject obj) {
    ERepositoryObjectType type = obj.getRepositoryObjectType();
    Item item = obj.getProperty().getItem();
    String path = item.getState().getPath();
    if (item instanceof ContainerItem) {
        if (path.length() > 1) {
            int pos = path.lastIndexOf(DIVIDE);
            if (pos >= 0) {
                path = path.substring(0, pos);
            }
        } else {
            return null;
        }
    }
    return get(type, path);
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 34 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.

the class AbstractContentProvider method getChildren.

public Object[] getChildren(Object element) {
    Item item = RepositoryResourceUtil.getItemFromRepViewObj(element);
    if (item != null && item instanceof ContainerItem) {
        ContainerItem containerItem = (ContainerItem) item;
        // recycle
        if (RepositoryResourceUtil.isDeletedFolder(item, ((IRepositoryViewObject) element).getRepositoryObjectType())) {
            AbstractContentProvider recycleContentProvider = (AbstractContentProvider) RepositoryNodeConfigurationManager.getRecycleBinNodeConfiguration().getContentProvider();
            return recycleContentProvider.getChildren(element);
        }
        // 
        FolderType containerType = containerItem.getType();
        List<IRepositoryViewObject> children = ((FolderRepositoryObject) element).getChildren();
        if (containerType == FolderType.SYSTEM_FOLDER_LITERAL) {
            List<IRepositoryViewObject> viewObjects = getViewObjFromSystemFolder(containerItem);
            if (viewObjects != null) {
                children.clear();
                children.addAll(viewObjects);
                return viewObjects.toArray();
            }
        }
        if (containerType == FolderType.FOLDER_LITERAL || containerType == FolderType.STABLE_SYSTEM_FOLDER_LITERAL) {
            List<IRepositoryViewObject> viewObjects = getViewObjFromFolder(containerItem);
            if (viewObjects != null) {
                children.clear();
                children.addAll(viewObjects);
                return viewObjects.toArray();
            }
        }
    // if (containerType == FolderType.STABLE_SYSTEM_FOLDER_LITERAL) {
    // List<IRepositoryViewObject> children = ((ContainerRepositoryObject) element).getChildren();
    // if (children != null) {
    // return children.toArray();
    // }
    // }
    }
    return new Object[0];
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) FolderType(org.talend.core.model.properties.FolderType) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 35 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.

the class ViewActionProvider method getActions.

@Override
public List<AbstractRepositoryAction> getActions(IRepositoryViewObject viewObj) {
    List<AbstractRepositoryAction> actions = super.getActions(viewObj);
    Item item = viewObj.getProperty().getItem();
    String path = item.getState().getPath();
    if (path.isEmpty()) {
        actions.remove(createFolderAction);
    }
    if ((item instanceof ContainerItem) && (path.equals(IPath.SEPARATOR + IViewNodeConstDef.PATH_SEARCHFILTER) || path.equals(IPath.SEPARATOR + IViewNodeConstDef.PATH_WEBFILTER))) {
        actions.remove(removeFromRepositoryAction);
    }
    if (RepositoryResourceUtil.hasContainerItem(viewObj, FolderType.SYSTEM_FOLDER_LITERAL, FolderType.FOLDER_LITERAL)) {
        addAction(actions, addAction, viewObj);
    }
    if (viewObj.getProperty().getItem() instanceof MDMServerObjectItem) {
        int index = actions.indexOf(mdmEditPropertyAction);
        if (index != -1) {
            actions.add(index, editViewProcessPropertyAction);
            actions.remove(mdmEditPropertyAction);
        }
        addAction(actions, renameViewAction, viewObj);
        addAction(actions, browseViewAction, viewObj);
        // deploy
        addAction(actions, deployToAction, viewObj);
        addAction(actions, deployToLastServerAction, viewObj);
        addAction(actions, deployAnotherToAction, viewObj);
        addAction(actions, undeployAction, viewObj);
    }
    addAction(actions, deployAllAction, viewObj);
    return actions;
}
Also used : AbstractRepositoryAction(org.talend.mdm.repository.core.AbstractRepositoryAction) Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)

Aggregations

ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)46 Item (org.talend.core.model.properties.Item)28 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)24 ItemState (org.talend.core.model.properties.ItemState)18 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)16 Test (org.junit.Test)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)11 FolderRepositoryObject (org.talend.mdm.repository.models.FolderRepositoryObject)11 Property (org.talend.core.model.properties.Property)10 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)9 Resource (org.eclipse.emf.ecore.resource.Resource)8 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)8 AbstractSimpleAddActionTest (org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest)8 FolderType (org.talend.core.model.properties.FolderType)6 FolderItem (org.talend.core.model.properties.FolderItem)5 Path (org.eclipse.core.runtime.Path)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 WSDataModelItem (org.talend.mdm.repository.model.mdmproperties.WSDataModelItem)4 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)4