Search in sources :

Example 6 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem 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 7 with ContainerItem

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

the class CreateFolderAction method doRun.

@Override
protected void doRun() {
    Object object = getSelectedObject().get(0);
    if (object != null && object instanceof FolderRepositoryObject) {
        final FolderRepositoryObject containerViewObject = (FolderRepositoryObject) object;
        InputDialog dlg = new InputDialog(getShell(), Messages.CreateFolderAction_newCategory, Messages.CreateFolderAction_inputCategoryName, null, new IInputValidator() {

            public String isValid(String newText) {
                if ((newText == null) || "".equals(newText)) {
                    return Messages.Common_nameCanNotBeEmpty;
                }
                // $NON-NLS-1$
                Pattern p = Pattern.compile("([\\s*|\\W*]+)");
                Matcher m = p.matcher(newText);
                if (m.find()) {
                    m.group(1);
                    return Messages.Common_nameInvalid;
                }
                if (RepositoryResourceUtil.isDeletedFolder(containerViewObject.getRepositoryObjectType(), containerViewObject, newText)) {
                    return Messages.Common_nameIsUsed;
                }
                for (IRepositoryViewObject viewObj : containerViewObject.getChildren()) {
                    Item item = viewObj.getProperty().getItem();
                    if (item instanceof ContainerItem) {
                        if (((ContainerItem) item).getLabel().equals(newText)) {
                            return Messages.CreateFolderAction_nameIsUsed;
                        }
                    }
                }
                return null;
            }
        });
        dlg.setBlockOnOpen(true);
        if (dlg.open() == Window.CANCEL) {
            return;
        }
        String categoryName = dlg.getValue();
        // 
        if (categoryName != null) {
            IRepositoryViewObject folderViewObject = RepositoryResourceUtil.createFolderViewObject(containerViewObject.getRepositoryObjectType(), categoryName, containerViewObject.getProperty().getItem(), false);
            containerViewObject.getChildren().add(folderViewObject);
            commonViewer.refresh(containerViewObject);
            commonViewer.expandToLevel(containerViewObject, 1);
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) InputDialog(org.eclipse.jface.dialogs.InputDialog) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) Matcher(java.util.regex.Matcher) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 8 with ContainerItem

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

the class RepositoryNodeConfigurationManager method getConfiguration.

public static IRepositoryNodeConfiguration getConfiguration(Item item) {
    EClass eClass = item.eClass();
    IRepositoryNodeConfiguration configuration = itemConfMap.get(eClass);
    if (configuration != null) {
        return configuration;
    }
    for (IRepositoryNodeConfiguration conf : getConfigurations()) {
        IRepositoryNodeResourceProvider resourceProvider = conf.getResourceProvider();
        if (resourceProvider != null) {
            if (resourceProvider.canHandleItem(item)) {
                if (!(item instanceof ContainerItem)) {
                    itemConfMap.put(eClass, conf);
                }
                return conf;
            }
        }
    }
    if (recycleBinNodeConfiguration.getResourceProvider().canHandleItem(item)) {
        return recycleBinNodeConfiguration;
    }
    return null;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IRepositoryNodeResourceProvider(org.talend.mdm.repository.core.IRepositoryNodeResourceProvider) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration)

Example 9 with ContainerItem

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

the class RepositoryResourceUtil method convertToNode.

public static RepositoryNode convertToNode(IRepositoryViewObject viewObj) {
    Item item = viewObj.getProperty().getItem();
    ENodeType type = ENodeType.REPOSITORY_ELEMENT;
    if (item instanceof ContainerItem) {
        FolderType folderType = ((ContainerItem) item).getType();
        switch(folderType.getValue()) {
            case FolderType.SYSTEM_FOLDER:
                type = ENodeType.SYSTEM_FOLDER;
                break;
            case FolderType.STABLE_SYSTEM_FOLDER:
                type = ENodeType.STABLE_SYSTEM_FOLDER;
                break;
            case FolderType.FOLDER:
                type = ENodeType.SIMPLE_FOLDER;
                break;
            default:
                break;
        }
    }
    ERepositoryObjectType repObjType = viewObj.getRepositoryObjectType();
    RepositoryNode node = new MDMRepositoryNode(viewObj, null, type);
    node.setProperties(EProperties.LABEL, viewObj.getLabel());
    node.setProperties(EProperties.CONTENT_TYPE, repObjType);
    addChildrenToNode(viewObj, node);
    return node;
}
Also used : ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) WorkspaceRootItem(org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem) Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) MDMRepositoryNode(org.talend.mdm.repository.core.bridge.MDMRepositoryNode) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) RepositoryNode(org.talend.repository.model.RepositoryNode) MDMRepositoryNode(org.talend.mdm.repository.core.bridge.MDMRepositoryNode) FolderType(org.talend.core.model.properties.FolderType)

Example 10 with ContainerItem

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

the class RepositoryResourceUtil method isDeletedFolder.

public static boolean isDeletedFolder(Item item, ERepositoryObjectType type) {
    ItemState state = item.getState();
    if (item instanceof ContainerItem) {
        String path = ERepositoryObjectType.getFolderName(type);
        if (!path.isEmpty()) {
            path += state.getPath();
        }
        List<String> deletedFolderPaths = ProjectManager.getInstance().getCurrentProject().getEmfProject().getDeletedFolders();
        return deletedFolderPaths.contains(path);
    } else {
        return state.isDeleted();
    }
}
Also used : ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ItemState(org.talend.core.model.properties.ItemState)

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