Search in sources :

Example 6 with FolderType

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

the class RepositoryResourceUtilTest method testIsSystemFolder.

@Test
public void testIsSystemFolder() throws Exception {
    String folderName = "system";
    FolderType[] folderTypes = { FolderType.FOLDER_LITERAL, FolderType.STABLE_SYSTEM_FOLDER_LITERAL };
    ContainerItem mockContainerItem = mock(ContainerItem.class);
    when(mockContainerItem.getType()).thenReturn(FolderType.SYSTEM_FOLDER_LITERAL);
    boolean result = Whitebox.invokeMethod(RepositoryResourceUtil.class, "isSystemFolder", mockContainerItem, folderName);
    assertTrue(result);
    for (FolderType folderType : folderTypes) {
        when(mockContainerItem.getType()).thenReturn(folderType);
        result = Whitebox.invokeMethod(RepositoryResourceUtil.class, "isSystemFolder", mockContainerItem, folderName);
        assertFalse(result);
    }
    Item mockItem = mock(Item.class);
    result = Whitebox.invokeMethod(RepositoryResourceUtil.class, "isSystemFolder", mockItem, folderName);
    assertFalse(result);
}
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) FolderType(org.talend.core.model.properties.FolderType) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with FolderType

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

the class WorkspaceRootItemImpl method setType.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setType(FolderType newType) {
    FolderType oldType = type;
    type = newType == null ? TYPE_EDEFAULT : newType;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, MdmpropertiesPackage.WORKSPACE_ROOT_ITEM__TYPE, oldType, type));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) FolderType(org.talend.core.model.properties.FolderType)

Example 8 with FolderType

use of org.talend.core.model.properties.FolderType 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)

Aggregations

FolderType (org.talend.core.model.properties.FolderType)8 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)6 Item (org.talend.core.model.properties.Item)5 FolderItem (org.talend.core.model.properties.FolderItem)3 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 AbstractRepositoryAction (org.talend.mdm.repository.core.AbstractRepositoryAction)2 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)2 WorkspaceRootItem (org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem)2 ENodeType (org.talend.repository.model.IRepositoryNode.ENodeType)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 LinkedList (java.util.LinkedList)1 BusinessProcessItem (org.talend.core.model.properties.BusinessProcessItem)1 ProcessItem (org.talend.core.model.properties.ProcessItem)1 Property (org.talend.core.model.properties.Property)1 TDQMatchRuleItem (org.talend.dataquality.properties.TDQMatchRuleItem)1 IRepositoryNodeActionProvider (org.talend.mdm.repository.core.IRepositoryNodeActionProvider)1