Search in sources :

Example 1 with WorkspaceRootItem

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

the class RepositoryNodeActionProviderAdapter method getActions.

@Override
public List<AbstractRepositoryAction> getActions(IRepositoryViewObject viewObj) {
    List<AbstractRepositoryAction> actions = new LinkedList<AbstractRepositoryAction>();
    // 
    Item item = viewObj.getProperty().getItem();
    if (item instanceof MDMItem) {
        if (item instanceof ContainerItem) {
            FolderType type = ((FolderItem) item).getType();
            switch(type.getValue()) {
                case FolderType.SYSTEM_FOLDER:
                    addAction(actions, createFolderAction, viewObj);
                    addAction(actions, pasteAction, viewObj);
                    actions.add(importServerObjectAction);
                    actions.add(importObjectAction);
                    break;
                case FolderType.STABLE_SYSTEM_FOLDER:
                    break;
                case FolderType.FOLDER:
                    addAction(actions, createFolderAction, viewObj);
                    if (!((ContainerItem) item).getRepObjType().equals(ERepositoryObjectType.PROCESS)) {
                        actions.add(removeFromRepositoryAction);
                    }
                    addAction(actions, pasteAction, viewObj);
                    break;
            }
        } else if (item instanceof MDMServerObjectItem) {
            addAction(actions, removeFromRepositoryAction, viewObj);
            addAction(actions, mdmEditPropertyAction, viewObj);
            addAction(actions, openVersionAction, viewObj);
            addAction(actions, copyAction, viewObj);
            addAction(actions, pasteAction, viewObj);
            addAction(actions, duplicateAction, viewObj);
            if (exAdapter != null) {
                exAdapter.addActions(actions, viewObj);
            }
        } else if (item instanceof WorkspaceRootItem) {
            // fix bug TMDM-3168
            actions.add(importObjectAction);
        }
    }
    if (enableDebug) {
        // for debug digestValue
        addAction(actions, debugDigestValueAction, viewObj);
    }
    // 
    actions.add(refreshAction);
    actions.add(exportObjectAction);
    // action provider
    for (IRepositoryNodeActionProvider provider : getExtendActionProviders()) {
        List<AbstractRepositoryAction> providerActions = provider.getActions(viewObj);
        if (providerActions != null) {
            actions.addAll(providerActions);
        }
    }
    if (viewObj.getRepositoryObjectType() != null && IServerObjectRepositoryType.TYPE_EVENTMANAGER.equals(viewObj.getRepositoryObjectType())) {
        actions.add(emAction);
    }
    // 
    return actions;
}
Also used : MDMItem(org.talend.mdm.repository.model.mdmproperties.MDMItem) AbstractRepositoryAction(org.talend.mdm.repository.core.AbstractRepositoryAction) WorkspaceRootItem(org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem) Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) FolderItem(org.talend.core.model.properties.FolderItem) MDMItem(org.talend.mdm.repository.model.mdmproperties.MDMItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) WorkspaceRootItem(org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) FolderItem(org.talend.core.model.properties.FolderItem) IRepositoryNodeActionProvider(org.talend.mdm.repository.core.IRepositoryNodeActionProvider) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) LinkedList(java.util.LinkedList) FolderType(org.talend.core.model.properties.FolderType)

Example 2 with WorkspaceRootItem

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

the class RepositoryResourceUtil method assertItem.

public static Item assertItem(Item item) {
    if (item == null) {
        throw new IllegalArgumentException();
    }
    if (item instanceof WorkspaceRootItem) {
        return item;
    }
    Property property = item.getProperty();
    if (property != null) {
        Resource eResource = item.eResource();
        if (eResource == null || eResource.getResourceSet() == null) {
            IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
            try {
                IRepositoryViewObject newViewObj = factory.getLastVersion(property.getId());
                property = newViewObj.getProperty();
                if (property != null) {
                    eResource = property.getItem().eResource();
                    if (eResource == null || eResource.getResourceSet() == null) {
                        property = factory.reload(property);
                        newViewObj = new RepositoryViewObject(property);
                    }
                }
                ContainerCacheService.put(newViewObj);
                return newViewObj.getProperty().getItem();
            } catch (PersistenceException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
    return item;
}
Also used : WorkspaceRootItem(org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem) Resource(org.eclipse.emf.ecore.resource.Resource) IResource(org.eclipse.core.resources.IResource) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 3 with WorkspaceRootItem

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

the class RepositoryResourceUtil method getCategoryViewObjectsWithRecycle.

public static IRepositoryViewObject[] getCategoryViewObjectsWithRecycle() {
    if (rootViewObj == null) {
        // 
        rootViewObj = null;
        Property prop = PropertiesFactory.eINSTANCE.createProperty();
        prop.setId(EcoreUtil.generateUUID());
        ItemState state = PropertiesFactory.eINSTANCE.createItemState();
        WorkspaceRootItem item = MdmpropertiesFactory.eINSTANCE.createWorkspaceRootItem();
        item.setState(state);
        prop.setItem(item);
        rootViewObj = new WSRootRepositoryObject(prop);
        // 
        IRepositoryViewObject[] cvos = getCategoryViewObjects();
        List<IRepositoryViewObject> newViewObjs = rootViewObj.getChildren();
        for (IRepositoryViewObject viewObj : cvos) {
            newViewObjs.add(viewObj);
        }
        // 
        newViewObjs.add(getCategoryViewObject(RepositoryNodeConfigurationManager.getRecycleBinNodeConfiguration()));
    }
    return new IRepositoryViewObject[] { rootViewObj };
}
Also used : WorkspaceRootItem(org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem) ItemState(org.talend.core.model.properties.ItemState) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject)

Aggregations

WorkspaceRootItem (org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem)3 Property (org.talend.core.model.properties.Property)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 LinkedList (java.util.LinkedList)1 IResource (org.eclipse.core.resources.IResource)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 FolderItem (org.talend.core.model.properties.FolderItem)1 FolderType (org.talend.core.model.properties.FolderType)1 Item (org.talend.core.model.properties.Item)1 ItemState (org.talend.core.model.properties.ItemState)1 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)1 AbstractRepositoryAction (org.talend.mdm.repository.core.AbstractRepositoryAction)1 IRepositoryNodeActionProvider (org.talend.mdm.repository.core.IRepositoryNodeActionProvider)1 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)1 MDMItem (org.talend.mdm.repository.model.mdmproperties.MDMItem)1 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)1 WSRootRepositoryObject (org.talend.mdm.repository.models.WSRootRepositoryObject)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1